blob: 1671de76c504277e3fe27adce83d984ccada7343 [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 *
oliverschmidt2fa33232005-01-26 21:33:29 +000035 * $Id: main.c,v 1.7 2005/01/26 21:33:29 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"
54#include "email-dsc.h"
55#include "irc-dsc.h"
56#include "memstat-dsc.h"
57#include "telnet-dsc.h"
58#include "processes-dsc.h"
59#include "www-dsc.h"
oliverschmidt3cf3d302004-06-08 20:28:33 +000060
oliverschmidt9e652ff2004-07-11 12:24:52 +000061#include "clock.h"
62
oliverschmidt2fa33232005-01-26 21:33:29 +000063
64unsigned char lanslot;
65
adamdunkelsa4ed8472003-04-10 07:25:26 +000066/*-----------------------------------------------------------------------------------*/
oliverschmidt9e652ff2004-07-11 12:24:52 +000067unsigned char
68uip_fw_forward(void)
adamdunkelsa4ed8472003-04-10 07:25:26 +000069{
oliverschmidt9e652ff2004-07-11 12:24:52 +000070 return 0;
71}
72/*-----------------------------------------------------------------------------------*/
73void
74uip_fw_periodic(void)
75{
76 return;
77}
78/*-----------------------------------------------------------------------------------*/
oliverschmidt76872e82004-12-26 14:13:34 +000079EK_EVENTHANDLER(eventhandler, ev, data)
80{
81 switch(ev) {
82 case EK_EVENT_INIT:
83 program_handler_load("config.prg", NULL);
84 break;
85 }
86}
87/*-----------------------------------------------------------------------------------*/
88EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
89 eventhandler, NULL, NULL);
90/*-----------------------------------------------------------------------------------*/
oliverschmidt9e652ff2004-07-11 12:24:52 +000091clock_time_t
92clock_time(void)
93{
94 static clock_time_t counter;
95
96 return ++counter;
oliverschmidt3cf3d302004-06-08 20:28:33 +000097}
98/*-----------------------------------------------------------------------------------*/
99void
100main(void)
101{
oliverschmidt9e652ff2004-07-11 12:24:52 +0000102 ek_init();
oliverschmidt76872e82004-12-26 14:13:34 +0000103 ek_start(&init);
104
oliverschmidt9e652ff2004-07-11 12:24:52 +0000105 tcpip_init(NULL);
oliverschmidt76872e82004-12-26 14:13:34 +0000106 resolv_init(NULL);
oliverschmidt3cf3d302004-06-08 20:28:33 +0000107
adamdunkelsa4ed8472003-04-10 07:25:26 +0000108 ctk_init();
oliverschmidt3cf3d302004-06-08 20:28:33 +0000109
adamdunkelsa4ed8472003-04-10 07:25:26 +0000110 program_handler_init();
adamdunkelsa4ed8472003-04-10 07:25:26 +0000111
oliverschmidt76872e82004-12-26 14:13:34 +0000112 program_handler_add(&www_dsc, "Web browser", 1);
113 program_handler_add(&email_dsc, "E-mail", 1);
114 program_handler_add(&irc_dsc, "IRC client", 1);
115 program_handler_add(&telnet_dsc, "Telnet", 1);
116 program_handler_add(&processes_dsc, "Processes", 1);
117 program_handler_add(&memstat_dsc, "Memory stats", 1);
118 program_handler_add(&calc_dsc, "Calculator", 1);
119 program_handler_add(&dhcp_dsc, "DHCP client", 1);
120 program_handler_add(&configedit_dsc, "Configuration", 0);
121 program_handler_add(&about_dsc, "About Contiki", 0);
adamdunkelsa4ed8472003-04-10 07:25:26 +0000122
oliverschmidt76872e82004-12-26 14:13:34 +0000123 while(1) {
124 if(ek_run() == 0) {
125 program_handler_load("welcome.prg", NULL);
126 break;
127 }
128 }
oliverschmidt9e652ff2004-07-11 12:24:52 +0000129 while(1) {
130 ek_run();
131 }
adamdunkelsa4ed8472003-04-10 07:25:26 +0000132}
133/*-----------------------------------------------------------------------------------*/