blob: f9ecc890a5e408a0d8499f4a7a1e3ae5d8dae23a [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 *
oliverschmidt63e299e2005-05-06 22:38:17 +000035 * $Id: main.c,v 1.12 2005/05/06 22:38:17 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
oliverschmidt63e299e2005-05-06 22:38:17 +000050#include "www-dsc.h"
oliverschmidt7ca33552005-05-05 00:14:16 +000051#include "email-dsc.h"
oliverschmidt18f390a2005-04-19 23:00:00 +000052#include "ftp-dsc.h"
oliverschmidt63e299e2005-05-06 22:38:17 +000053#include "directory-dsc.h"
oliverschmidt3cf3d302004-06-08 20:28:33 +000054
oliverschmidt9e652ff2004-07-11 12:24:52 +000055#include "clock.h"
56
oliverschmidt2fa33232005-01-26 21:33:29 +000057
58unsigned char lanslot;
59
oliverschmidtd9f33142005-02-17 22:45:02 +000060#pragma bssseg(push, "UIPBUF");
61u8_t uip_buf[UIP_BUFSIZE + 2];
62#pragma bssseg(pop);
63
adamdunkelsa4ed8472003-04-10 07:25:26 +000064/*-----------------------------------------------------------------------------------*/
oliverschmidt9e652ff2004-07-11 12:24:52 +000065unsigned char
66uip_fw_forward(void)
adamdunkelsa4ed8472003-04-10 07:25:26 +000067{
oliverschmidt9e652ff2004-07-11 12:24:52 +000068 return 0;
69}
70/*-----------------------------------------------------------------------------------*/
71void
72uip_fw_periodic(void)
73{
74 return;
75}
76/*-----------------------------------------------------------------------------------*/
oliverschmidt76872e82004-12-26 14:13:34 +000077EK_EVENTHANDLER(eventhandler, ev, data)
78{
79 switch(ev) {
80 case EK_EVENT_INIT:
81 program_handler_load("config.prg", NULL);
82 break;
83 }
84}
85/*-----------------------------------------------------------------------------------*/
86EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
87 eventhandler, NULL, NULL);
88/*-----------------------------------------------------------------------------------*/
oliverschmidt9e652ff2004-07-11 12:24:52 +000089clock_time_t
90clock_time(void)
91{
92 static clock_time_t counter;
93
94 return ++counter;
oliverschmidt3cf3d302004-06-08 20:28:33 +000095}
96/*-----------------------------------------------------------------------------------*/
97void
98main(void)
99{
oliverschmidt9e652ff2004-07-11 12:24:52 +0000100 ek_init();
oliverschmidt76872e82004-12-26 14:13:34 +0000101 ek_start(&init);
102
oliverschmidt9e652ff2004-07-11 12:24:52 +0000103 tcpip_init(NULL);
oliverschmidt76872e82004-12-26 14:13:34 +0000104 resolv_init(NULL);
oliverschmidt3cf3d302004-06-08 20:28:33 +0000105
adamdunkelsa4ed8472003-04-10 07:25:26 +0000106 ctk_init();
oliverschmidt3cf3d302004-06-08 20:28:33 +0000107
adamdunkelsa4ed8472003-04-10 07:25:26 +0000108 program_handler_init();
adamdunkelsa4ed8472003-04-10 07:25:26 +0000109
oliverschmidt63e299e2005-05-06 22:38:17 +0000110 program_handler_add(&www_dsc, "Web browser", 1);
111 program_handler_add(&email_dsc, "E-mail", 1);
112 program_handler_add(&ftp_dsc, "FTP client", 1);
113 program_handler_add(&directory_dsc, "Directory", 1);
adamdunkelsa4ed8472003-04-10 07:25:26 +0000114
oliverschmidt76872e82004-12-26 14:13:34 +0000115 while(1) {
116 if(ek_run() == 0) {
117 program_handler_load("welcome.prg", NULL);
118 break;
119 }
120 }
oliverschmidt9e652ff2004-07-11 12:24:52 +0000121 while(1) {
122 ek_run();
123 }
adamdunkelsa4ed8472003-04-10 07:25:26 +0000124}
125/*-----------------------------------------------------------------------------------*/