forked from PoliEcho-holding-org/kern
Changed camelCase to snake_case
This commit is contained in:
+20
-10
@@ -8,26 +8,36 @@ struct boot_info bootloader;
|
||||
|
||||
// TODO:
|
||||
int boot_init(int type, ...) {
|
||||
va_list va;
|
||||
va_start(va, type);
|
||||
|
||||
void* ptr = va_arg(va, void*);
|
||||
uint32_t magic = va_arg(va, uint32_t);
|
||||
|
||||
switch (type) {
|
||||
case BOOT_MB1: return boot_init_mb1(ptr, magic);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int boot_initMB1(void* ptr, uint32_t magic) {
|
||||
int boot_init_mb1(void* ptr, uint32_t magic) {
|
||||
multiboot_info_t* mbi = ptr;
|
||||
|
||||
if (magic != MULTIBOOT_BOOTLOADER_MAGIC) return 1;
|
||||
|
||||
// mem_* fields are valid
|
||||
if (mbi->flags & MULTIBOOT_INFO_MEMORY) {
|
||||
bootloader.memLower = mbi->mem_lower;
|
||||
bootloader.memUpper = mbi->mem_upper;
|
||||
bootloader.mem_lower = mbi->mem_lower;
|
||||
bootloader.mem_upper = mbi->mem_upper;
|
||||
}
|
||||
|
||||
// boot_device is valid
|
||||
if (mbi->flags & MULTIBOOT_INFO_BOOTDEV) {
|
||||
bootloader.bootDrive = (mbi->boot_device & 0xff000000) >> 24;
|
||||
bootloader.bootPart1 = (mbi->boot_device & 0x00ff0000) >> 16;
|
||||
bootloader.bootPart2 = (mbi->boot_device & 0x0000ff00) >> 8;
|
||||
bootloader.bootPart3 = (mbi->boot_device & 0x000000ff);
|
||||
bootloader.boot_drive = (mbi->boot_device & 0xff000000) >> 24;
|
||||
bootloader.boot_part1 = (mbi->boot_device & 0x00ff0000) >> 16;
|
||||
bootloader.boot_part2 = (mbi->boot_device & 0x0000ff00) >> 8;
|
||||
bootloader.boot_part3 = (mbi->boot_device & 0x000000ff);
|
||||
}
|
||||
|
||||
// cmdline is valid
|
||||
@@ -45,9 +55,9 @@ int boot_initMB1(void* ptr, uint32_t magic) {
|
||||
|
||||
size_t i = 0;
|
||||
multiboot_memory_map_t* entry = (multiboot_memory_map_t*)mbi->mmap_addr;
|
||||
uint32_t mapLim = mbi->mmap_addr + mbi->mmap_length;
|
||||
uint32_t limit = mbi->mmap_addr + mbi->mmap_length;
|
||||
|
||||
while ((uint32_t)entry < mapLim) {
|
||||
while ((uint32_t)entry < limit) {
|
||||
bootloader.memmap[i].base = entry->addr;
|
||||
bootloader.memmap[i].size = entry->len;
|
||||
bootloader.memmap[i].type = (uint8_t)entry->type;
|
||||
@@ -55,7 +65,7 @@ int boot_initMB1(void* ptr, uint32_t magic) {
|
||||
entry++;
|
||||
i++;
|
||||
}
|
||||
bootloader.memmapLen = i;
|
||||
bootloader.memmap_size = i;
|
||||
}
|
||||
|
||||
// TODO: drives_*
|
||||
|
||||
Reference in New Issue
Block a user