Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | /* |
2 | * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
||
3 | * |
||
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * Gerardo Lamastra <gerardo@sssup.it> |
||
6 | * |
||
7 | * Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
||
8 | * (see authors.txt for full list of hartik's authors) |
||
9 | * |
||
10 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
11 | * |
||
12 | * http://www.sssup.it |
||
13 | * http://retis.sssup.it |
||
14 | * http://hartik.sssup.it |
||
15 | */ |
||
16 | |||
17 | /* |
||
18 | * Copyright (C) 2000 Massimiliano Giorgi |
||
19 | * |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation; either version 2 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * This program is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program; if not, write to the Free Software |
||
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
33 | * |
||
34 | */ |
||
35 | |||
36 | /* |
||
37 | * CVS : $Id: hello.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $ |
||
38 | * |
||
39 | * File: $File$ |
||
40 | * Revision: $Revision: 1.1.1.1 $ |
||
41 | * Last update: $Date: 2002-09-02 09:37:48 $ |
||
42 | */ |
||
43 | |||
44 | /* |
||
45 | * Example of tracer initialization. |
||
46 | */ |
||
47 | |||
48 | #include <ll/i386/cons.h> |
||
49 | |||
50 | #include <kernel/func.h> |
||
51 | #include <kernel/trace.h> |
||
52 | |||
53 | #include <fs/bdevinit.h> |
||
54 | #include <fs/fsinit.h> |
||
55 | #include <fs/bdev.h> |
||
56 | |||
57 | #include <drivers/keyb.h> |
||
58 | |||
59 | #include <trace/trace.h> |
||
60 | #include <trace/queues.h> |
||
61 | |||
62 | #include <sys/mount.h> |
||
63 | #include <stddef.h> |
||
64 | |||
65 | /* |
||
66 | this example use initfs.c to initialize the system; this file define |
||
67 | the following two function. |
||
68 | |||
69 | __kernel_register_levels__(), must initialize all kernel modules, |
||
70 | it has this structure: |
||
71 | |||
72 | { |
||
73 | __register_sub_init_prologue(); |
||
74 | |||
75 | ... modules initialization.... |
||
76 | |||
77 | __register_sub_init(); |
||
78 | } |
||
79 | |||
80 | __init__(void *arg) is called when the first task is created |
||
81 | and must call the main(): |
||
82 | |||
83 | { |
||
84 | |||
85 | ... drivers initialization .... |
||
86 | |||
87 | __bdev_sub_init(); |
||
88 | __fs_sub_init(); |
||
89 | |||
90 | call_main() |
||
91 | |||
92 | } |
||
93 | |||
94 | */ |
||
95 | |||
96 | /* |
||
97 | * This function is called before all other modules initialization because |
||
98 | * all modules that need the tracer must follow tracer initialization. |
||
99 | */ |
||
100 | int __register_sub_init_prologue(void) |
||
101 | { |
||
102 | /* the first functions to call... parameters can be passed */ |
||
103 | TRC_init_phase1(NULL); |
||
104 | /* all the tracer queues must be registrated (in this case only */ |
||
105 | /* a dummy queue is initialized) */ |
||
106 | trc_register_dummy_queue(); |
||
107 | /* the queues must be created (only one in this example) */ |
||
108 | trc_create_queue(TRC_DUMMY_QUEUE,NULL); |
||
109 | /* events can be dispatch to a queue (nothing in this case) */ |
||
110 | return 0; |
||
111 | } |
||
112 | |||
113 | /* |
||
114 | * This function is called after all other modules initialization |
||
115 | * functions... notjing to do. |
||
116 | */ |
||
117 | int __register_sub_init(void) |
||
118 | { |
||
119 | return 0; |
||
120 | } |
||
121 | |||
122 | __dev_t root_device; |
||
123 | __dev_t temp_device; |
||
124 | |||
125 | /* |
||
126 | * Now the system is running... we have to initialize the block device |
||
127 | * drivers |
||
128 | */ |
||
129 | int __bdev_sub_init(void) |
||
130 | { |
||
131 | BDEV_PARMS bdev=BASE_BDEV; |
||
132 | |||
133 | /* This to initialize the block device drivers... a NULL can be passed */ |
||
134 | /* to the bdev_init() functions */ |
||
135 | bdev_def_showinfo(bdev,FALSE); |
||
136 | bdev_init(&bdev); |
||
137 | |||
138 | /* The following phase ca be made in several way: we must decide the */ |
||
139 | /* device that we want mount as root... we use the bdev_find_byname() */ |
||
140 | /* functions to find a specific device */ |
||
141 | root_device=bdev_find_byname("ide/hda1"); |
||
142 | if (root_device<0) { |
||
143 | cprintf("can't find root device to mount on /!!!\n"); |
||
144 | sys_end(); |
||
145 | return -1; |
||
146 | } |
||
147 | |||
148 | /* Well, we want a device to mount into /TEMP */ |
||
149 | temp_device=bdev_find_byname("ide/hdb3"); |
||
150 | if (temp_device<0) { |
||
151 | cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
||
152 | sys_end(); |
||
153 | return -1; |
||
154 | } |
||
155 | |||
156 | return 0; |
||
157 | } |
||
158 | |||
159 | |||
160 | /* |
||
161 | * This is the real filesystem initialization! |
||
162 | */ |
||
163 | int __fs_sub_init(void) |
||
164 | { |
||
165 | FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
||
166 | extern int libc_initialize(void); |
||
167 | int res; |
||
168 | struct mount_opts opts; |
||
169 | |||
170 | /* We set the root device and call the filesystem_init() function */ |
||
171 | filesystem_def_rootdevice(fs,root_device); |
||
172 | filesystem_def_fs(fs,FS_MSDOS); |
||
173 | filesystem_def_showinfo(fs,FALSE); |
||
174 | filesystem_init(&fs); |
||
175 | |||
176 | /* We must initialize the libC if we use it */ |
||
177 | libc_initialize(); |
||
178 | |||
179 | /* We have choose to mount the second partiotion into the /TEMP */ |
||
180 | /* directory with read/write privilegies (this step is not required) */ |
||
181 | if (temp_device>=0) { |
||
182 | memset(&opts,0,sizeof(struct mount_opts)); |
||
183 | opts.flags=MOUNT_FLAG_RW; |
||
184 | res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
||
185 | if (res!=0) { |
||
186 | cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
||
187 | } |
||
188 | } |
||
189 | |||
190 | /* NOW we call the tracer initialization phase 2!!! */ |
||
191 | /* It must FOLLOW the filesystem initialization... (this function */ |
||
192 | /* can be called after the call to filesystem_init() functions but */ |
||
193 | /* we do it here because we want be able to write into the /TEMP */ |
||
194 | /* directory! */ |
||
195 | TRC_init_phase2(); |
||
196 | |||
197 | return 0; |
||
198 | } |
||
199 | |||
200 | void ctrlc_exit(KEY_EVT *k) |
||
201 | { |
||
202 | sys_end(); |
||
203 | } |
||
204 | |||
205 | int main(int argc,char *argv[]) |
||
206 | { |
||
207 | cprintf("\nHello, world!\n"); |
||
208 | return 0; |
||
209 | } |