Rev 1142 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1138 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * (see the web pages for full authors list) |
||
11 | * |
||
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
17 | */ |
||
18 | |||
19 | /* |
||
20 | * Copyright (C) 2000 Paolo Gai |
||
21 | * |
||
22 | * This program is free software; you can redistribute it and/or modify |
||
23 | * it under the terms of the GNU General Public License as published by |
||
24 | * the Free Software Foundation; either version 2 of the License, or |
||
25 | * (at your option) any later version. |
||
26 | * |
||
27 | * This program is distributed in the hope that it will be useful, |
||
28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
30 | * GNU General Public License for more details. |
||
31 | * |
||
32 | * You should have received a copy of the GNU General Public License |
||
33 | * along with this program; if not, write to the Free Software |
||
34 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
35 | * |
||
36 | */ |
||
37 | |||
38 | /* |
||
39 | * CVS : $Id: initfile.c,v 1.1 2003-03-20 13:26:45 giacomo Exp $ |
||
40 | * |
||
41 | * File: $File$ |
||
42 | * Revision: $Revision: 1.1 $ |
||
43 | * Last update: $Date: 2003-03-20 13:26:45 $ |
||
44 | */ |
||
45 | |||
46 | #include "kernel/kern.h" |
||
47 | #include "modules/edf.h" |
||
48 | #include "modules/rr.h" |
||
49 | #include "modules/cbs.h" |
||
50 | #include "modules/dummy.h" |
||
51 | |||
52 | #include "modules/sem.h" |
||
53 | #include "modules/hartport.h" |
||
54 | #include "modules/cabs.h" |
||
55 | #include "modules/pi.h" |
||
56 | #include "modules/pc.h" |
||
57 | #include "modules/srp.h" |
||
58 | #include "modules/npp.h" |
||
59 | #include "modules/nop.h" |
||
60 | #include "modules/nopm.h" |
||
61 | |||
62 | #include "fs/bdevinit.h" |
||
63 | #include "fs/fsinit.h" |
||
64 | #include "fs/bdev.h" |
||
65 | |||
66 | #include "drivers/keyb.h" |
||
67 | |||
68 | /*+ sysyem tick in us +*/ |
||
69 | #define TICK 1000 |
||
70 | |||
71 | /*+ RR tick in us +*/ |
||
72 | #define RRTICK 10000 |
||
73 | |||
74 | dev_t root_device=-1; |
||
75 | dev_t temp_device=-1; |
||
76 | |||
77 | int __register_sub_init(void) |
||
78 | { |
||
79 | #if defined(EDFSCHED) |
||
80 | extern void BD_EDF_register_module(void); |
||
81 | BD_EDF_register_module(); |
||
82 | #elif defined(PSCANSCHED) |
||
83 | extern void BD_PSCAN_register_module(void); |
||
84 | BD_PSCAN_register_module(); |
||
85 | #endif |
||
86 | return 0; |
||
87 | } |
||
88 | |||
89 | int choose_root_callback(dev_t dev,u_int8_t fs) |
||
90 | { |
||
91 | if (fs==FS_MSDOS) return dev; |
||
92 | return -1; |
||
93 | } |
||
94 | |||
95 | int choose_temp_callback(__dev_t dev,__uint8_t fs) |
||
96 | { |
||
97 | static int flag=0; |
||
98 | if (fs==FS_MSDOS) { |
||
99 | if (flag) return dev; |
||
100 | flag=1; |
||
101 | } |
||
102 | return -1; |
||
103 | } |
||
104 | |||
105 | int __bdev_sub_init(void) |
||
106 | { |
||
107 | BDEV_PARMS bdev=BASE_BDEV; |
||
108 | |||
109 | bdev_def_showinfo(bdev,FALSE); |
||
110 | bdev_init(&bdev); |
||
111 | |||
112 | root_device=bdev_scan_devices(choose_root_callback); |
||
113 | if (root_device<0) { |
||
114 | cprintf("can't find root device to mount on /!!!\n"); |
||
115 | sys_end(); |
||
116 | return -1; |
||
117 | } |
||
118 | |||
119 | return 0; |
||
120 | |||
121 | } |
||
122 | |||
123 | int __fs_sub_init(void) |
||
124 | { |
||
125 | extern int libc_initialize(void); |
||
126 | FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
||
127 | |||
128 | filesystem_def_rootdevice(fs,root_device); |
||
129 | filesystem_def_fs(fs,FS_MSDOS); |
||
130 | filesystem_def_showinfo(fs,FALSE); |
||
131 | filesystem_init(&fs); |
||
132 | |||
133 | libc_initialize(); |
||
134 | |||
135 | return 0; |
||
136 | } |
||
137 | |||
138 | TIME __kernel_register_levels__(void *arg) |
||
139 | { |
||
140 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
141 | extern int __register_sub_init_prologue(void); |
||
142 | extern int __register_sub_init(void); |
||
143 | |||
144 | //__register_sub_init_prologue(); |
||
145 | |||
146 | EDF_register_level(EDF_ENABLE_ALL); |
||
147 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
148 | CBS_register_level(CBS_ENABLE_ALL, 0); |
||
149 | dummy_register_level(); |
||
150 | |||
151 | SEM_register_module(); |
||
152 | |||
153 | CABS_register_module(); |
||
154 | |||
155 | PI_register_module(); |
||
156 | PC_register_module(); |
||
157 | NPP_register_module(); |
||
158 | SRP_register_module(); |
||
159 | NOP_register_module(); |
||
160 | NOPM_register_module(); |
||
161 | |||
162 | __register_sub_init(); |
||
163 | |||
164 | return TICK; |
||
165 | } |
||
166 | |||
167 | TASK __init__(void *arg) |
||
168 | { |
||
169 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
170 | KEYB_PARMS keyb = BASE_KEYB; |
||
171 | extern int __bdev_sub_init(void); |
||
172 | extern int __fs_sub_init(void); |
||
173 | extern void ctrlc_exit(KEY_EVT *k); |
||
174 | |||
175 | HARTPORT_init(); |
||
176 | |||
177 | KEYB_init(&keyb); |
||
178 | |||
179 | __bdev_sub_init(); |
||
180 | __fs_sub_init(); |
||
181 | |||
182 | __call_main__(mb); |
||
183 | |||
184 | return (void *)0; |
||
185 | } |
||
186 |