Added SHT11 driver for TMote.
[sos-2x.git] / kernel / main.c
blob72bccee9d1e46b6924de6c8f60992a383d400ee0
1 /* -*- Mode: C; tab-width:4 -*- */
2 /* ex: set ts=4 shiftwidth=4 softtabstop=4 cindent: */
3 /*
4 * Copyright (c) 2003 The Regents of the University of California.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided
15 * with the distribution.
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgement:
18 * This product includes software developed by Networked &
19 * Embedded Systems Lab at UCLA
20 * 4. Neither the name of the University nor that of the Laboratory
21 * may be used to endorse or promote products derived from this
22 * software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
28 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
31 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
38 /**
39 * @brief SOS booting sequence
40 * @author Simon Han (simonhan@ee.ucla.edu)
42 * Platform dependent booting sequence should go to
43 * hardware.c or hardware_*.c of particular platform
45 #include <hardware.h>
46 #include <sos_sched.h>
47 #include <message_queue.h>
48 #include <sos_module_fetcher.h>
49 #include <random.h>
50 #include <sensor.h>
51 #include <malloc.h>
52 #include <monitor.h>
53 #include <fntable.h>
54 #include <sos_info.h>
55 #include <sos_shm.h>
56 #include <message.h>
57 //#include <version_sync.h>
59 #ifdef SOS_SFI
60 #include <sfi_jumptable.h>
61 #endif
64 /**
65 * @brief application start
67 * Application will define this function
69 extern void sos_start();
72 /**
73 * @file SOS core loop
74 * @brief main function
75 * @author Simon Han (simonhan@ee.ucla.edu)
78 /**
79 * @brief Core event loop
81 int sos_main(uint8_t cond){
83 //! disable interrupt
84 DISABLE_GLOBAL_INTERRUPTS();
86 //! Initialize the ID
87 id_init();
89 //! initialize memory manager
90 mem_init();
92 shm_init();
94 //! initialize message pool
95 msg_queue_init();
97 //! initialize random number generator
98 random_init();
100 //! initialize scheduler
101 sched_init(cond);
103 //! initialize sensor manager
104 sensor_init();
106 //! initialize the Function Table
107 fntable_init();
109 //! Initialize the monitor
110 monitor_init();
112 //! initialize hardware
113 hardware_init();
115 codemem_init();
117 routing_init();
119 //! starting memory module
120 mem_start();
122 #ifdef SOS_SFI
123 //! Initialize SFI
124 sfi_modtable_init();
125 #endif
127 //! Initialize the code fetcher
128 fetcher_init();
130 //! enable interrupt
131 ENABLE_GLOBAL_INTERRUPTS();
133 #ifdef SOS_USE_PREEMPTION
134 // Enable preemption
135 preemption_status = ENABLED;
136 #endif
137 DEBUG("SOS booted\n");
138 //! start application
139 sos_start();
141 //! enter main sched loop
142 //! should never return from this call
143 sched();
144 return 0;