|
9 | 9 | #include <kern_task.h>
|
10 | 10 | #include <shell_init.h>
|
11 | 11 | #include <uptime_init.h>
|
| 12 | +#include <list.h> |
| 13 | +#include <queue.h> |
12 | 14 |
|
13 | 15 | #define GDT_IDX_OFS 3
|
14 | 16 | #define APP_ENTRY_POINT 0x20000020
|
15 | 17 | #define APP_STACK_BASE 0x20002000
|
16 | 18 |
|
| 19 | +struct file_head { |
| 20 | + struct list lst; |
| 21 | + unsigned char num_files; |
| 22 | +} fhead; |
| 23 | + |
| 24 | +struct file { |
| 25 | + struct list lst; |
| 26 | + unsigned int fid; |
| 27 | + char *name; |
| 28 | + void *data_base_addr; |
| 29 | +} fshell, fuptime; |
| 30 | + |
17 | 31 | void kern_lock(unsigned char *if_bit)
|
18 | 32 | {
|
19 | 33 | /* Save EFlags.IF */
|
@@ -168,6 +182,38 @@ static void task_init(unsigned short task_id, unsigned int phys_binary_base)
|
168 | 182 | sched_runq_enq(new_task);
|
169 | 183 | }
|
170 | 184 |
|
| 185 | +void fs_init(void *fs_base_addr) |
| 186 | +{ |
| 187 | + queue_init((struct list *)&fhead); |
| 188 | + fhead.num_files = *(unsigned char *)fs_base_addr; |
| 189 | + |
| 190 | + fshell.fid = 1; |
| 191 | + fshell.name = (char *)fs_base_addr + PAGE_SIZE; |
| 192 | + fshell.data_base_addr = (char *)fs_base_addr + PAGE_SIZE + 32; |
| 193 | + queue_enq((struct list *)&fshell, (struct list *)&fhead); |
| 194 | + |
| 195 | + fuptime.fid = 2; |
| 196 | + fuptime.name = (char *)fs_base_addr + (PAGE_SIZE * 2); |
| 197 | + fuptime.data_base_addr = (char *)fs_base_addr + (PAGE_SIZE * 2) + 32; |
| 198 | + queue_enq((struct list *)&fuptime, (struct list *)&fhead); |
| 199 | +} |
| 200 | + |
| 201 | +int fs_open(const char *name) |
| 202 | +{ |
| 203 | + /* 将来的には、struct fileのtask_idメンバにopenしたタスクの |
| 204 | + * TASK_IDを入れるようにする。そして、openしようとしているファ |
| 205 | + * イルのtask_idが既に設定されていれば、fs_openはエラーを返す |
| 206 | + * ようにする */ |
| 207 | + return 0; |
| 208 | +} |
| 209 | + |
| 210 | +int fs_close(unsigned int fid) |
| 211 | +{ |
| 212 | + /* 将来的には、fidに対応するstruct fileのtask_idメンバーを設定 |
| 213 | + * なし(0)にする。 */ |
| 214 | + return 0; |
| 215 | +} |
| 216 | + |
171 | 217 | int main(void)
|
172 | 218 | {
|
173 | 219 | extern unsigned char syscall_handler;
|
@@ -208,10 +254,13 @@ int main(void)
|
208 | 254 | timer_init();
|
209 | 255 | mem_init();
|
210 | 256 |
|
| 257 | + /* Setup File System */ |
| 258 | + fs_init((void *)0x00011000); |
| 259 | + |
211 | 260 | /* Setup tasks */
|
212 | 261 | kern_task_init();
|
213 |
| - task_init(SHELL_ID, 0x00012000); |
214 |
| - task_init(UPTIME_ID, 0x00013000); |
| 262 | + task_init(SHELL_ID, (unsigned int)fshell.name); |
| 263 | + task_init(UPTIME_ID, (unsigned int)fuptime.name); |
215 | 264 |
|
216 | 265 | /* Start paging */
|
217 | 266 | mem_page_start();
|
|
0 commit comments