blob: ec72c8a1929e8e41e34ee133bfabd2fac55f5030 [file] [log] [blame]
adamdunkels0b5590d2003-09-05 21:16:38 +00001/*
adamdunkels840ba812004-09-18 20:52:10 +00002 * Copyright (c) 2002-2004, Adam Dunkels.
adamdunkels0b5590d2003-09-05 21:16:38 +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.
adamdunkelsfb24dff2004-09-12 14:07:30 +000014 * 3. The name of the author may not be used to endorse or promote
adamdunkels0b5590d2003-09-05 21:16:38 +000015 * products derived from this software without specific prior
16 * written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
adamdunkels840ba812004-09-18 20:52:10 +000030 * This file is part of the Contiki operating system
adamdunkels0b5590d2003-09-05 21:16:38 +000031 *
adamdunkels840ba812004-09-18 20:52:10 +000032 * $Id: main-rrnet.c,v 1.4 2004/09/18 20:52:10 adamdunkels Exp $
adamdunkels0b5590d2003-09-05 21:16:38 +000033 *
34 */
35
adamdunkels840ba812004-09-18 20:52:10 +000036#include "contiki.h"
37
adamdunkels0b5590d2003-09-05 21:16:38 +000038#include "ctk.h"
39#include "ctk-draw.h"
adamdunkels840ba812004-09-18 20:52:10 +000040#include "ek.h"
adamdunkels0b5590d2003-09-05 21:16:38 +000041
42#include "program-handler.h"
43
adamdunkels840ba812004-09-18 20:52:10 +000044
adamdunkels0b5590d2003-09-05 21:16:38 +000045#include "uip.h"
46#include "uip_arp.h"
adamdunkels840ba812004-09-18 20:52:10 +000047
adamdunkels0b5590d2003-09-05 21:16:38 +000048#include "resolv.h"
adamdunkels0b5590d2003-09-05 21:16:38 +000049
adamdunkels0b5590d2003-09-05 21:16:38 +000050#include "netconf-dsc.h"
adamdunkels840ba812004-09-18 20:52:10 +000051#include "irc-dsc.h"
52#include "dhcp-dsc.h"
adamdunkels0b5590d2003-09-05 21:16:38 +000053
adamdunkels840ba812004-09-18 20:52:10 +000054#include "cfs-cbm.h"
adamdunkels0b5590d2003-09-05 21:16:38 +000055
adamdunkels840ba812004-09-18 20:52:10 +000056#include "clock.h"
adamdunkels0b5590d2003-09-05 21:16:38 +000057
adamdunkels840ba812004-09-18 20:52:10 +000058#include <cbm.h>
59
60unsigned char
61uip_fw_forward(void)
62{
63 return 0;
64}
65void
66uip_fw_periodic(void)
67{
68 return;
69}
adamdunkels0b5590d2003-09-05 21:16:38 +000070/*-----------------------------------------------------------------------------------*/
adamdunkels840ba812004-09-18 20:52:10 +000071EK_EVENTHANDLER(eventhandler, ev, data)
adamdunkels0b5590d2003-09-05 21:16:38 +000072{
73 u16_t addr[2];
adamdunkels840ba812004-09-18 20:52:10 +000074 switch(ev) {
75 case EK_EVENT_INIT:
76 uip_ipaddr(addr, 192,168,3,2);
77 uip_sethostaddr(addr);
78
79 uip_ipaddr(addr, 192,168,3,1);
80 uip_setdraddr(addr);
81
82 uip_ipaddr(addr, 255,255,255,0);
83 uip_setnetmask(addr);
84
85 uip_ipaddr(addr, 195,54,122,204);
86 resolv_conf(addr);
87
88 /* program_handler_load("config.prg", NULL);*/
89 break;
90 }
91}
92/*-----------------------------------------------------------------------------------*/
93EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
94 eventhandler, NULL, NULL);
95/*-----------------------------------------------------------------------------------*/
96void
97log_message(char *part1, char *part2)
98{
99 while(*part1 != 0) {
100 cbm_k_bsout(*part1++);
101 }
102
103 while(*part2 != 0) {
104 cbm_k_bsout(*part2++);
105 }
106
107
108 cbm_k_bsout('\n');
109}
110/*-----------------------------------------------------------------------------------*/
111clock_time_t
112clock_time(void)
113{
114 return clock();
115}
116/*-----------------------------------------------------------------------------------*/
117#pragma optimize(push, off)
118static void
119setup_curunit(void)
120{
121 asm("lda $ba");
122 asm("sta %v", _curunit);
123}
124#pragma optimize(pop)
125/*-----------------------------------------------------------------------------------*/
126void
127main(void)
128{
129
130 setup_curunit();
131
132 log_message("Starting ", CONTIKI_VERSION_STRING);
133
134 ek_init();
135
136 ek_start(&init);
137
138 log_message(": TCP/IP", "");
139
140 tcpip_init(NULL);
141
142 resolv_init(NULL);
143
144 log_message(": CTK GUI", "");
adamdunkels0b5590d2003-09-05 21:16:38 +0000145 ctk_init();
146
adamdunkels840ba812004-09-18 20:52:10 +0000147 /* log_message(": Initial filesystem", "");
148 cfs_init_init(NULL);*/
adamdunkels0b5590d2003-09-05 21:16:38 +0000149
adamdunkels0b5590d2003-09-05 21:16:38 +0000150 program_handler_init();
adamdunkels840ba812004-09-18 20:52:10 +0000151
152 program_handler_add(&netconf_dsc, "Network config", 1);
153 program_handler_add(&dhcp_dsc, "DHCP", 1);
154 program_handler_add(&irc_dsc, "IRC", 1);
adamdunkels0b5590d2003-09-05 21:16:38 +0000155
adamdunkels0b5590d2003-09-05 21:16:38 +0000156
adamdunkels840ba812004-09-18 20:52:10 +0000157 ctk_80col_service_init(NULL);
158 rrnet_drv_init(NULL);
adamdunkels0b5590d2003-09-05 21:16:38 +0000159
adamdunkels840ba812004-09-18 20:52:10 +0000160 log_message("Starting process scheduling", "");
adamdunkels0b5590d2003-09-05 21:16:38 +0000161
adamdunkels840ba812004-09-18 20:52:10 +0000162 while(1) {
163 ek_run();
164 }
adamdunkels0b5590d2003-09-05 21:16:38 +0000165}
166/*-----------------------------------------------------------------------------------*/