Rev 1625 | Rev 1650 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1624 | 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 | /* |
||
1636 | giacomo | 39 | * CVS : $Id: initfile.c,v 1.2 2004-06-01 11:54:11 giacomo Exp $ |
1624 | giacomo | 40 | * |
41 | * File: $File$ |
||
1636 | giacomo | 42 | * Revision: $Revision: 1.2 $ |
43 | * Last update: $Date: 2004-06-01 11:54:11 $ |
||
1624 | giacomo | 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 "drivers/keyb.h" |
||
63 | |||
64 | #include <fs/bdevinit.h> |
||
65 | #include <fs/fsinit.h> |
||
66 | #include <fs/bdev.h> |
||
67 | |||
68 | |||
69 | /*+ sysyem tick in us +*/ |
||
70 | #define TICK 1000 |
||
71 | |||
72 | /*+ RR tick in us +*/ |
||
73 | #define RRTICK 10000 |
||
74 | |||
75 | TIME __kernel_register_levels__(void *arg) |
||
76 | { |
||
77 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
78 | extern int __register_sub_init_prologue(void); |
||
79 | extern int __register_sub_init(void); |
||
80 | |||
81 | __register_sub_init_prologue(); |
||
82 | |||
83 | EDF_register_level(EDF_ENABLE_ALL); |
||
84 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
85 | CBS_register_level(CBS_ENABLE_ALL, 0); |
||
86 | dummy_register_level(); |
||
87 | |||
88 | SEM_register_module(); |
||
89 | |||
90 | CABS_register_module(); |
||
91 | |||
92 | PI_register_module(); |
||
93 | PC_register_module(); |
||
94 | NPP_register_module(); |
||
95 | SRP_register_module(); |
||
96 | NOP_register_module(); |
||
97 | NOPM_register_module(); |
||
98 | |||
99 | __register_sub_init(); |
||
100 | |||
101 | return TICK; |
||
102 | } |
||
103 | |||
104 | TASK __init__(void *arg) |
||
105 | { |
||
106 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
107 | KEYB_PARMS keyb = BASE_KEYB; |
||
108 | extern int __bdev_sub_init(void); |
||
109 | extern int __fs_sub_init(void); |
||
110 | extern void ctrlc_exit(KEY_EVT *k); |
||
111 | |||
112 | HARTPORT_init(); |
||
113 | |||
114 | keyb_def_ctrlC(keyb, ctrlc_exit); |
||
115 | KEYB_init(&keyb); |
||
116 | |||
117 | __bdev_sub_init(); |
||
118 | __fs_sub_init(); |
||
119 | |||
120 | __call_main__(mb); |
||
121 | |||
122 | return (void *)0; |
||
123 | } |
||
124 | |||
125 | #define PSCANSCHED 1 |
||
126 | #define NOTRACE |
||
127 | |||
128 | int __register_sub_init_prologue(void) |
||
129 | { |
||
130 | return 0; |
||
131 | } |
||
132 | |||
133 | int __register_sub_init(void) |
||
134 | { |
||
135 | #if defined(EDFSCHED) |
||
136 | extern void BD_EDF_register_module(void); |
||
137 | BD_EDF_register_module(); |
||
138 | #elif defined(PSCANSCHED) |
||
139 | extern void BD_PSCAN_register_module(void); |
||
140 | BD_PSCAN_register_module(); |
||
141 | #endif |
||
142 | return 0; |
||
143 | } |
||
144 | |||
145 | dev_t root_device=-1; |
||
146 | dev_t temp_device=-1; |
||
147 | |||
148 | int choose_root_callback(dev_t dev,u_int8_t fs) |
||
149 | { |
||
150 | if (fs==FS_MSDOS) return dev; |
||
151 | return -1; |
||
152 | } |
||
153 | |||
154 | int choose_temp_callback(__dev_t dev,__uint8_t fs) |
||
155 | { |
||
156 | static int flag=0; |
||
157 | if (fs==FS_MSDOS) { |
||
158 | if (flag) return dev; |
||
159 | flag=1; |
||
160 | } |
||
161 | return -1; |
||
162 | } |
||
163 | |||
164 | int __bdev_sub_init(void) |
||
165 | { |
||
166 | BDEV_PARMS bdev=BASE_BDEV; |
||
167 | |||
168 | bdev_def_showinfo(bdev,FALSE); |
||
169 | bdev_init(&bdev); |
||
170 | |||
171 | root_device=bdev_scan_devices(choose_root_callback); |
||
172 | if (root_device<0) { |
||
173 | cprintf("can't find root device to mount on /!!!\n"); |
||
174 | sys_end(); |
||
175 | return -1; |
||
176 | } |
||
177 | |||
178 | /* |
||
179 | temp_device=bdev_scan_devices(choose_temp_callback); |
||
180 | if (temp_device<0) { |
||
181 | cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
||
182 | } |
||
183 | */ |
||
184 | |||
185 | return 0; |
||
186 | } |
||
187 | |||
188 | |||
189 | int __fs_sub_init(void) |
||
190 | { |
||
191 | extern int libc_initialize(void); |
||
192 | FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
||
193 | struct mount_opts opts; |
||
194 | // int res; |
||
195 | |||
196 | filesystem_def_rootdevice(fs,root_device); |
||
197 | filesystem_def_fs(fs,FS_MSDOS); |
||
198 | filesystem_def_showinfo(fs,FALSE); |
||
199 | filesystem_def_options(fs,opts); |
||
200 | |||
201 | memset(&opts,0,sizeof(struct mount_opts)); |
||
202 | opts.flags=MOUNT_FLAG_RW; |
||
203 | |||
204 | |||
205 | filesystem_init(&fs); |
||
206 | |||
207 | /* |
||
208 | if (temp_device>=0) { |
||
209 | memset(&opts,0,sizeof(struct mount_opts)); |
||
210 | opts.flags=MOUNT_FLAG_RW; |
||
211 | res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
||
212 | if (res!=0) { |
||
213 | cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
||
214 | } else |
||
215 | cprintf("mounted /TEMP rw\n"); |
||
216 | } |
||
217 | */ |
||
218 | |||
219 | libc_initialize(); |
||
220 | |||
221 | return 0; |
||
222 | } |
||
223 | |||
224 | void ctrlc_exit(KEY_EVT *k) |
||
225 | { |
||
226 | extern void dump_sem_table(void); |
||
227 | extern void dump_nop_table(void); |
||
228 | #ifndef NOGRX |
||
229 | grx_close(); |
||
230 | #endif |
||
231 | cprintf("CTRL-C pressed!\n"); |
||
232 | sys_end(); |
||
233 | } |
||
234 | |||
235 | |||
236 | |||
237 | |||
238 | |||
239 | |||
240 |