blob: 1a679931df501e6fd3e7c3dfc7b9612c37843c9f [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 *
adamdunkelsa96489a2004-09-18 21:06:47 +000032 * $Id: main-rrnet.c,v 1.5 2004/09/18 21:06:47 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:
adamdunkels840ba812004-09-18 20:52:10 +000076 break;
77 }
78}
79/*-----------------------------------------------------------------------------------*/
80EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
81 eventhandler, NULL, NULL);
82/*-----------------------------------------------------------------------------------*/
83void
84log_message(char *part1, char *part2)
85{
86 while(*part1 != 0) {
87 cbm_k_bsout(*part1++);
88 }
89
90 while(*part2 != 0) {
91 cbm_k_bsout(*part2++);
92 }
93
94
95 cbm_k_bsout('\n');
96}
97/*-----------------------------------------------------------------------------------*/
98clock_time_t
99clock_time(void)
100{
101 return clock();
102}
103/*-----------------------------------------------------------------------------------*/
104#pragma optimize(push, off)
105static void
106setup_curunit(void)
107{
108 asm("lda $ba");
109 asm("sta %v", _curunit);
110}
111#pragma optimize(pop)
112/*-----------------------------------------------------------------------------------*/
113void
114main(void)
115{
116
117 setup_curunit();
118
119 log_message("Starting ", CONTIKI_VERSION_STRING);
120
121 ek_init();
122
123 ek_start(&init);
124
125 log_message(": TCP/IP", "");
126
127 tcpip_init(NULL);
128
129 resolv_init(NULL);
130
131 log_message(": CTK GUI", "");
adamdunkels0b5590d2003-09-05 21:16:38 +0000132 ctk_init();
133
adamdunkels840ba812004-09-18 20:52:10 +0000134 /* log_message(": Initial filesystem", "");
135 cfs_init_init(NULL);*/
adamdunkels0b5590d2003-09-05 21:16:38 +0000136
adamdunkels0b5590d2003-09-05 21:16:38 +0000137 program_handler_init();
adamdunkels840ba812004-09-18 20:52:10 +0000138
139 program_handler_add(&netconf_dsc, "Network config", 1);
140 program_handler_add(&dhcp_dsc, "DHCP", 1);
141 program_handler_add(&irc_dsc, "IRC", 1);
adamdunkels0b5590d2003-09-05 21:16:38 +0000142
adamdunkels0b5590d2003-09-05 21:16:38 +0000143
adamdunkels840ba812004-09-18 20:52:10 +0000144 ctk_80col_service_init(NULL);
145 rrnet_drv_init(NULL);
adamdunkels0b5590d2003-09-05 21:16:38 +0000146
adamdunkels840ba812004-09-18 20:52:10 +0000147 log_message("Starting process scheduling", "");
adamdunkels0b5590d2003-09-05 21:16:38 +0000148
adamdunkels840ba812004-09-18 20:52:10 +0000149 while(1) {
150 ek_run();
151 }
adamdunkels0b5590d2003-09-05 21:16:38 +0000152}
153/*-----------------------------------------------------------------------------------*/