Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1655 | giacomo | 1 | |
2 | #include <kernel/func.h> |
||
3 | #include <tracer.h> |
||
4 | |||
5 | #include <fs/bdevinit.h> |
||
6 | #include <fs/fsinit.h> |
||
7 | #include <fs/bdev.h> |
||
8 | |||
9 | #include <drivers/keyb.h> |
||
10 | |||
11 | #include <trace.h> |
||
12 | #include <queues.h> |
||
13 | |||
14 | #include <sys/mount.h> |
||
15 | |||
16 | #include <fcntl.h> |
||
17 | #include <unistd.h> |
||
18 | #include <errno.h> |
||
19 | |||
20 | int __register_sub_init(void) |
||
21 | { |
||
22 | return 0; |
||
23 | } |
||
24 | |||
25 | /* -- */ |
||
26 | |||
27 | __dev_t root_device; |
||
28 | __dev_t temp_device; |
||
29 | |||
30 | int choose_root_callback(__dev_t dev,__uint8_t fs) |
||
31 | { |
||
32 | if (fs==FS_MSDOS) return dev; |
||
33 | return -1; |
||
34 | } |
||
35 | |||
36 | int choose_temp_callback(__dev_t dev,__uint8_t fs) |
||
37 | { |
||
38 | static int flag=0; |
||
39 | if (fs==FS_MSDOS) { |
||
40 | if (flag) return dev; |
||
41 | flag=1; |
||
42 | } |
||
43 | return -1; |
||
44 | } |
||
45 | |||
46 | /* -- */ |
||
47 | |||
48 | extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t)); |
||
49 | |||
50 | int __bdev_sub_init(void) |
||
51 | { |
||
52 | BDEV_PARMS bdev=BASE_BDEV; |
||
53 | |||
54 | bdev_def_showinfo(bdev,FALSE); |
||
55 | bdev_init(&bdev); |
||
56 | |||
57 | root_device=bdev_scan_devices(choose_root_callback); |
||
58 | if (root_device<0) { |
||
59 | cprintf("can't find root device to mount on /!!!\n"); |
||
60 | sys_end(); |
||
61 | return -1; |
||
62 | } |
||
63 | |||
64 | temp_device=bdev_scan_devices(choose_temp_callback); |
||
65 | if (temp_device<0) { |
||
66 | cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
||
67 | } |
||
68 | |||
69 | return 0; |
||
70 | } |
||
71 | |||
72 | /* -- */ |
||
73 | |||
74 | extern int libc_initialize(void); |
||
75 | |||
76 | int __fs_sub_init(void) |
||
77 | { |
||
78 | FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
||
79 | struct mount_opts opts; |
||
80 | int res; |
||
81 | |||
82 | filesystem_def_rootdevice(fs,root_device); |
||
83 | filesystem_def_fs(fs,FS_MSDOS); |
||
84 | filesystem_def_showinfo(fs,FALSE); |
||
85 | |||
86 | |||
87 | //filesystem_init_prologue(); |
||
88 | filesystem_init(&fs); |
||
89 | |||
90 | libc_initialize(); |
||
91 | |||
92 | if (temp_device>=0) { |
||
93 | memset(&opts,0,sizeof(struct mount_opts)); |
||
94 | opts.flags=MOUNT_FLAG_RW; |
||
95 | res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
||
96 | if (res!=0) { |
||
97 | cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
||
98 | } |
||
99 | } |
||
100 | |||
101 | TRC_init_phase2(); |
||
102 | |||
103 | return 0; |
||
104 | } |
||
105 | |||
106 | /* -- */ |
||
107 | |||
108 | void ctrlc_exit(KEY_EVT *k) |
||
109 | { |
||
110 | extern void dump_sem_table(void); |
||
111 | extern void dump_nop_table(void); |
||
112 | //dump_sem_table(); |
||
113 | //dump_nop_table(); |
||
114 | sys_end(); |
||
115 | } |
||
116 | |||
117 | /* -- */ |
||
118 | |||
119 | void showmessage(char *s) |
||
120 | { |
||
121 | cputs(s); |
||
122 | cprintf("Press [x] to begin..."); |
||
123 | while (keyb_getchar()!='x'); |
||
124 | cprintf("\n"); |
||
125 | } |
||
126 | |||
127 | void waitend(void) |
||
128 | { |
||
129 | int c; |
||
130 | cprintf("Press [x] to exit..."); |
||
131 | while ((c=keyb_getchar())!='x'); |
||
132 | cprintf("\n"); |
||
133 | } |