Ignore:
Timestamp:
Jun 21, 2017, 11:34:09 AM (5 years ago)
Author:
max@…
Message:

Update. Retrieve and parse the multiboot info, and dump the mmap. Some
more sanity checks could probably be added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/hal_init.c

    r31 r32  
    2222#include <hal_types.h>
    2323#include <hal_boot.h>
     24#include <hal_multiboot.h>
    2425#include <hal_segmentation.h>
    2526
     
    3940void cpu_attach();
    4041
    41 /* -------------------------------------------------------------------------- */
     42
     43struct multiboot_info mb_info __in_kdata;
     44char mb_loader_name[PAGE_SIZE] __in_kdata;
     45uint8_t mb_mmap[PAGE_SIZE] __in_kdata;
     46
     47#define offsetof(type, member) __builtin_offsetof(type, member)
     48
     49
     50/* -------------------------------------------------------------------------- */
     51
     52static void
     53dump_memmap()
     54{
     55        size_t mmap_length = mb_info.mi_mmap_length;
     56        uint8_t *mmap_addr = (uint8_t *)&mb_mmap;
     57        size_t i;
     58
     59        if (!(mb_info.mi_flags & MULTIBOOT_INFO_HAS_MMAP))
     60                x86_printf("SHIT!!\n");
     61
     62        i = 0;
     63        while (i < mmap_length) {
     64                struct multiboot_mmap *mm;
     65
     66                mm = (struct multiboot_mmap *)(mmap_addr + i);
     67
     68                x86_printf("-> [%Z, %Z] %s\n", mm->mm_base_addr,
     69                    mm->mm_base_addr + mm->mm_length,
     70                    (mm->mm_type == 1) ? "ram" : "rsv" );
     71
     72                i += mm->mm_size + 4;
     73        }
     74}
    4275
    4376void init_x86_64(paddr_t firstpa)
     
    4679
    4780        extern uint64_t __kernel_end;
    48         x86_printf("__kernel_end: %p\n", (void *)&__kernel_end);
     81        x86_printf("__kernel_end: %Z\n", (uint64_t)&__kernel_end);
    4982
    5083        /* Create the global structures */
     
    5891        cpu_attach();
    5992        x86_printf("[+] cpu_attach called\n");
     93
     94        x86_printf("[+] bootloader: %s\n", mb_loader_name);
     95
     96        dump_memmap();
     97
     98        x86_printf("[+] dump finished\n");
    6099
    61100        char *buf = NULL;
Note: See TracChangeset for help on using the changeset viewer.