MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Initialize

Function Initialize

Kernel/src/fs/initrd.cpp:39–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 InitrdVolume* vol;
38
39 void Initialize(uintptr_t address, uint32_t size) {
40 #ifdef Lemon32
41 void* virtual_address = (void*)Memory::KernelAllocateVirtualPages(size / PAGE_SIZE + 1);
42 Memory::MapVirtualPages(address, (uint32_t)virtual_address, size / PAGE_SIZE + 1);
43 initrd_address = virtual_address;
44 #endif
45 #ifdef Lemon64
46 initrd_address = (void*)address;
47 #endif
48 Log::Info("Initrd address: ");
49 Log::Info(address);
50 Log::Info("Size:");
51 Log::Info(size, false);
52 Log::Info("File Count:");
53 Log::Info(*((uint32_t*)initrd_address), false);
54 Log::Write("files\r\n");
55 initrdHeader = *(lemoninitfs_header_t*)initrd_address;
56 nodes = (lemoninitfs_node_t*)(initrd_address + sizeof(lemoninitfs_header_t));
57 fsNodes = (fs_node_t*)kmalloc(sizeof(fs_node_t)*initrdHeader.fileCount);
58
59 for(int i = 0; i < initrdHeader.fileCount; i++){
60 fs_node_t* node = &(fsNodes[i]);
61 strcpy(node->name,nodes[i].filename);
62 node->inode = i;
63 node->flags = FS_NODE_FILE;
64 node->read = Initrd::Read;
65 node->write = Initrd::Write;
66 node->open = Initrd::Open;
67 node->close = Initrd::Close;
68 node->size = nodes[i].size;
69 }
70
71 vol = new InitrdVolume();
72
73 fs::volumes->add_back(vol);
74
75 InitrdVolume* vol2 = new InitrdVolume(); // Very Cheap Workaround
76 strcpy(vol2->mountPoint.name, "lib");
77 strcpy(vol2->mountPointDirent.name, "lib");
78
79 fs::volumes->add_back(vol2);
80 }
81
82 size_t Read(fs_node_t* node, size_t offset, size_t size, uint8_t *buffer){
83 lemoninitfs_node_t inode = nodes[node->inode];

Callers

nothing calls this directly

Calls 5

InfoFunction · 0.85
kmallocFunction · 0.85
strcpyFunction · 0.85
WriteFunction · 0.70
add_backMethod · 0.45

Tested by

no test coverage detected