SayoriOS 0.3.3

initrd.c
См. документацию.
1
10 #include <io/ports.h>
11 #include <fs/fsm.h>
12 #include <fs/tarfs.h>
13 #include "drv/disk/dpm.h"
14 #include "mem/vmm.h"
15
16
17
18 int initrd_tarfs(uint32_t start, uint32_t end) {
19 qemu_log("[TarFS] Init...\n * Start: %x\n * End: %x\n * Size: %d",start,end,end-start);
20
21 size_t initrd_size = end - start;
22 if (start > end)
23 return 0;
24
25 void* initrd_data = (void*)start;
26
27 qemu_warn("Initrd occupies %d pages", ALIGN(initrd_size, 4096) / 4096);
28
29 TarFS_ROOT* l_initrd = fs_tarfs_init((uint32_t) initrd_data, initrd_size, 1);
30
31 if (l_initrd->Ready == 0)
32 return 0;
33
34 // qemu_log("dpm_metadata_read:%x ",dpm_metadata_read('R'));
35 //
36 dpm_reg('R', "RamDisk", "TARFS", 2, initrd_size, 0, 0, 2, "TAR0-FSV1", initrd_data);
37 dpm_metadata_write('R', (uint32_t) l_initrd);
38
39
40 //dpm_metadata_write('R',l_initrd);
41
42 //fs_smfs_format('T');
43
44 // qemu_log("dpm_metadata_read:%x ",dpm_metadata_read('R'));
45 // qemu_log("l_initrd:%x ",l_initrd);
46 //
47 // FSM_FILE file = fsm_info(fsm_getIDbyName("TARFS"),'R',"main.c");
49 // qemu_log("[FF Test] Name: %s",file.Name);
50 // qemu_log("[FF Test] Size: %d",file.Size);
51 // qemu_log("[FF Test] Type: %d",file.Type);
52 // qemu_log("[FF Test] Mode: %d",file.Mode);
53 //
54 //
55 // char* b_mainc = kmalloc(file.Size);
56 // size_t r_mainc = fsm_read(fsm_getIDbyName("TARFS"),'R',"main.c",10,5,b_mainc);
57 // qemu_log("[TEST] [TarFS] Content:\n%s\n",b_mainc);
58 //
59 // qemu_log("TARFS:%d|%d",fsm_getIDbyName("TARFS"),fsm_getIDbyName("TarFS"));
60 return 1;
61 }
62
dpm_reg
int dpm_reg(char Letter, char *Name, char *FS, int Status, size_t Size, size_t Sectors, size_t SectorSize, int AddrMode, char *Serial, void *Point)
[DPM] Регистрация дискового раздела
Definition: dpm.c:187