blob: d54bd6d5b2b83e719b3905b9cec44d335a47e7c1 [file] [log] [blame]
adamdunkelsa4ed8472003-04-10 07:25:26 +00001/*
oliverschmidt9e652ff2004-07-11 12:24:52 +00002 * Copyright (c) 2004, Adam Dunkels.
adamdunkelsa4ed8472003-04-10 07:25:26 +00003 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
14 * 3. All advertising materials mentioning features or use of this
15 * software must display the following acknowledgement:
16 * This product includes software developed by Adam Dunkels.
17 * 4. The name of the author may not be used to endorse or promote
18 * products derived from this software without specific prior
19 * written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * This file is part of the Contiki desktop environment
34 *
oliverschmidt1419ac32005-03-18 00:35:26 +000035 * $Id: main.c,v 1.9 2005/03/18 00:35:26 oliverschmidt Exp $
adamdunkelsa4ed8472003-04-10 07:25:26 +000036 *
37 */
38
39#include "ctk.h"
40#include "ctk-draw.h"
oliverschmidt9e652ff2004-07-11 12:24:52 +000041#include "ek.h"
adamdunkelsa4ed8472003-04-10 07:25:26 +000042
adamdunkelsa4ed8472003-04-10 07:25:26 +000043#include "program-handler.h"
44
oliverschmidt3cf3d302004-06-08 20:28:33 +000045#include "uip.h"
46#include "uip_arp.h"
47
48#include "resolv.h"
49
oliverschmidt3cf3d302004-06-08 20:28:33 +000050#include "about-dsc.h"
oliverschmidt76872e82004-12-26 14:13:34 +000051#include "calc-dsc.h"
52#include "configedit-dsc.h"
53#include "dhcp-dsc.h"
oliverschmidt76872e82004-12-26 14:13:34 +000054#include "irc-dsc.h"
55#include "memstat-dsc.h"
56#include "telnet-dsc.h"
57#include "processes-dsc.h"
58#include "www-dsc.h"
oliverschmidt3cf3d302004-06-08 20:28:33 +000059
oliverschmidt9e652ff2004-07-11 12:24:52 +000060#include "clock.h"
61
oliverschmidt2fa33232005-01-26 21:33:29 +000062
63unsigned char lanslot;
64
oliverschmidtd9f33142005-02-17 22:45:02 +000065#pragma bssseg(push, "UIPBUF");
66u8_t uip_buf[UIP_BUFSIZE + 2];
67#pragma bssseg(pop);
68
adamdunkelsa4ed8472003-04-10 07:25:26 +000069/*-----------------------------------------------------------------------------------*/
oliverschmidt9e652ff2004-07-11 12:24:52 +000070unsigned char
71uip_fw_forward(void)
adamdunkelsa4ed8472003-04-10 07:25:26 +000072{
oliverschmidt9e652ff2004-07-11 12:24:52 +000073 return 0;
74}
75/*-----------------------------------------------------------------------------------*/
76void
77uip_fw_periodic(void)
78{
79 return;
80}
81/*-----------------------------------------------------------------------------------*/
oliverschmidt76872e82004-12-26 14:13:34 +000082EK_EVENTHANDLER(eventhandler, ev, data)
83{
84 switch(ev) {
85 case EK_EVENT_INIT:
86 program_handler_load("config.prg", NULL);
87 break;
88 }
89}
90/*-----------------------------------------------------------------------------------*/
91EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
92 eventhandler, NULL, NULL);
93/*-----------------------------------------------------------------------------------*/
oliverschmidt9e652ff2004-07-11 12:24:52 +000094clock_time_t
95clock_time(void)
96{
97 static clock_time_t counter;
98
99 return ++counter;
oliverschmidt3cf3d302004-06-08 20:28:33 +0000100}
101/*-----------------------------------------------------------------------------------*/
102void
103main(void)
104{
oliverschmidt9e652ff2004-07-11 12:24:52 +0000105 ek_init();
oliverschmidt76872e82004-12-26 14:13:34 +0000106 ek_start(&init);
107
oliverschmidt9e652ff2004-07-11 12:24:52 +0000108 tcpip_init(NULL);
oliverschmidt76872e82004-12-26 14:13:34 +0000109 resolv_init(NULL);
oliverschmidt3cf3d302004-06-08 20:28:33 +0000110
adamdunkelsa4ed8472003-04-10 07:25:26 +0000111 ctk_init();
oliverschmidt3cf3d302004-06-08 20:28:33 +0000112
adamdunkelsa4ed8472003-04-10 07:25:26 +0000113 program_handler_init();
adamdunkelsa4ed8472003-04-10 07:25:26 +0000114
oliverschmidt76872e82004-12-26 14:13:34 +0000115 program_handler_add(&www_dsc, "Web browser", 1);
oliverschmidt76872e82004-12-26 14:13:34 +0000116 program_handler_add(&irc_dsc, "IRC client", 1);
117 program_handler_add(&telnet_dsc, "Telnet", 1);
oliverschmidt76872e82004-12-26 14:13:34 +0000118 program_handler_add(&dhcp_dsc, "DHCP client", 1);
119 program_handler_add(&configedit_dsc, "Configuration", 0);
oliverschmidt1419ac32005-03-18 00:35:26 +0000120 program_handler_add(&processes_dsc, "Processes", 0);
121 program_handler_add(&memstat_dsc, "Memory stats", 0);
122 program_handler_add(&calc_dsc, "Calculator", 0);
oliverschmidt76872e82004-12-26 14:13:34 +0000123 program_handler_add(&about_dsc, "About Contiki", 0);
adamdunkelsa4ed8472003-04-10 07:25:26 +0000124
oliverschmidt76872e82004-12-26 14:13:34 +0000125 while(1) {
126 if(ek_run() == 0) {
127 program_handler_load("welcome.prg", NULL);
128 break;
129 }
130 }
oliverschmidt9e652ff2004-07-11 12:24:52 +0000131 while(1) {
132 ek_run();
133 }
adamdunkelsa4ed8472003-04-10 07:25:26 +0000134}
135/*-----------------------------------------------------------------------------------*/