blob: 858795fb3e1ebf5195983f91645f9d1070a8b7c2 [file] [log] [blame]
adamdunkels3023dee2003-07-04 10:54:51 +00001/*
2 * Copyright (c) 2002, Adam Dunkels.
3 * 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 *
35 * $Id: contiki-main.c,v 1.1 2003/07/04 10:54:51 adamdunkels Exp $
36 *
37 */
38
39#include "ctk.h"
40#include "ctk-draw.h"
41#include "ctk-vncserver.h"
42#include "dispatcher.h"
43
44
45#include "uip_main.h"
46#include "uip.h"
47#include "uip_arp.h"
48#include "rtl8019-drv.h"
49#include "resolv.h"
50
51#include "webserver.h"
52#include "program-handler.h"
53#include "about-dsc.h"
54#include "netconf-dsc.h"
55#include "processes-dsc.h"
56#include "calc-dsc.h"
57#include "www-dsc.h"
58#include "webserver-dsc.h"
59/*#include "directory-dsc.h"*/
60#include "weblinks-dsc.h"
61
62#include "debug.h"
63#include "uip.h"
64#include "uip_arp.h"
65#include "compiler.h"
66#include "rtl8019dev.h"
67
68
69#include "avr/pgmspace.h"
70
71
72static const struct uip_eth_addr ethaddr = {{0x00,0x06,0x98,0x01,0x02,0x26}};
73
74
75static u16_t addr[2];
76
77/*-----------------------------------------------------------------------------------*/
78static void setup_xram(void) __attribute__ ((naked)) \
79 __attribute__ ((section (".init1")));
80
81static void
82setup_xram(void)
83{
84 outp(BV(SRE) | BV(SRW), MCUCR);
85}
86/*-----------------------------------------------------------------------------------*/
87static unsigned short count;
88
89static void init_timer(void)
90{
91 /* timer overflows every 32.8ms (with 8MHz clock) */
92 /* timer0 prescale 1/1024 (5) */
93 outp(5, TCCR0);
94
95 /* interrupt on overflow */
96 sbi(TIMSK, TOIE0);
97
98 count = 0;
99}
100
101SIGNAL(SIG_OVERFLOW0)
102{
103 ++count;
104}
105
106unsigned short
107clock(void)
108{
109 return count;
110}
111/*-----------------------------------------------------------------------------------*/
112int
113main(int argc, char **argv)
114{
115
116 /* Setup stack pointer so that it does not interfere with the rest
117 of the RAM. */
118 /* asm("ldi r28,lo8(0x00807fff)");
119 asm("ldi r29,hi8(0x00807fff)");
120 asm("out 0x3e, r29");
121 asm("out 0x3d, r28");*/
122
123 /* Fiddle with RS232 settings of the AVR: */
124 /* Enable transmit. */
125 UCSR0B = _BV(TXEN);
126 /* Set baud rate (23 =~ 38400) */
127 UBRR0H = 0;
128 UBRR0L = 23;
129 UDR0 = '\n';
130
131
132 outp(BV(SRE) | BV(SRW), MCUCR);
133
134
135 /* end RS232 fiddling. */
136
137 init_timer();
138 sei();
139
140 uip_init();
141
142 resolv_init();
143
144
145 debug_print8(1);
146
147
148 uip_setethaddr(ethaddr);
149
150
151
152#if 1
153 uip_ipaddr(addr, 193,10,67,152);
154 uip_sethostaddr(addr);
155
156 uip_ipaddr(addr, 193,10,67,1);
157 uip_setdraddr(addr);
158
159 uip_ipaddr(addr, 255,255,255,0);
160 uip_setnetmask(addr);
161
162 uip_ipaddr(addr, 193,10,66,195);
163 resolv_conf(addr);
164
165#else
166
167 uip_ipaddr(addr, 192,168,1,2);
168 uip_sethostaddr(addr);
169
170 uip_ipaddr(addr, 192,168,1,1);
171 uip_setdraddr(addr);
172
173 uip_ipaddr(addr, 255,255,255,0);
174 uip_setnetmask(addr);
175
176 uip_ipaddr(addr, 195,54,122,204);
177 resolv_conf(addr);
178#endif
179
180
181
182 debug_print8(2);
183 resolv_query("www.sics.se");
184
185
186
187 debug_print8(3);
188 ek_init();
189
190
191
192 debug_print8(4);
193 dispatcher_init();
194
195
196
197
198 debug_print8(5);
199 ctk_init();
200
201 debug_print8(6);
202 rtl8019_drv_init();
203
204 debug_print8(8);
205 ctk_vncserver_init();
206
207 debug_print8(7);
208 program_handler_init();
209
210 webserver_init();
211
212
213 /* program_handler_add(&directory_dsc, "Directory", 1);*/
214 program_handler_add(&about_dsc, "About", 1);
215 program_handler_add(&webserver_dsc, "Web server", 1);
216 program_handler_add(&www_dsc, "Web browser", 1);
217 /* program_handler_add(&calc_dsc, "Calculator", 0);*/
218 program_handler_add(&processes_dsc, "Processes", 0);
219 program_handler_add(&weblinks_dsc, "Web links", 1);
220
221
222 debug_print8(64);
223 ek_run();
224
225
226 return 0;
227
228 argv = argv;
229 argc = argc;
230}
231/*-----------------------------------------------------------------------------------*/