Ignore:
Timestamp:
Jun 21, 2017, 11:34:09 AM (7 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_boot.S

    r29 r32  
    2424#define x86_ASM
    2525#include <hal_boot.h>
     26#include <hal_multiboot.h>
    2627#include <hal_register.h>
    2728#include <hal_segmentation.h>
     
    181182        /* Warm boot */
    182183        movw    $0x1234,0x472
     184        cld
    183185
    184186        /* Make sure it is a multiboot-compliant bootloader. */
    185 //      cmpl    $MULTIBOOT_INFO_MAGIC,%eax
    186 //      jne     boot_panic
     187        cmpl    $MULTIBOOT_INFO_MAGIC,%eax
     188        je      1f
     189        ret     /* what to do? */
     1901:
    187191
    188192        movl    $RELOC(tmpstk),%esp
     
    192196        popfl
    193197
     198        /*
     199         * Copy the various multiboot structures
     200         */
     201        movl    %ebx,%esi                       /* src */
     202        movl    $RELOC(mb_info),%edi            /* dst */
     203        movl    $MULTIBOOT_INFO_SIZE,%ecx       /* len */
     204        rep
     205        movsb   /* copy esi -> edi */
     206
     207        testl   $MULTIBOOT_INFO_HAS_LOADER_NAME,MB_MI_FLAGS(%ebx)
     208        jz      1f
     209        movl    MB_MI_LOADER_NAME(%ebx),%esi    /* src */
     210        movl    $RELOC(mb_loader_name),%edi     /* dst */
     211copy_loop:
     212        cmpb    $0,(%esi)
     213        je      copy_end
     214        movsb   /* copy esi -> edi */
     215        jmp     copy_loop
     216copy_end:
     217        movsb   /* copy esi -> edi */
     2181:
     219
     220        testl   $MULTIBOOT_INFO_HAS_MMAP,MB_MI_FLAGS(%ebx)
     221        jz      1f
     222        movl    MB_MI_MMAP_ADDR(%ebx),%esi      /* src */
     223        movl    $RELOC(mb_mmap),%edi            /* dst */
     224        movl    MB_MI_MMAP_LENGTH(%ebx),%ecx    /* len */
     225
     226        rep
     227        movsb   /* copy esi -> edi */
     2281:
     229
    194230/*
    195231 * There are four levels of pages in amd64: PML4 -> PDP -> PD -> PT. They will
     
    197233 *
    198234 * Virtual address space of the kernel:
    199  * +---------------+------------+-----------------------------------+---
    200  * | TEXT + RODATA | DATA + BSS | L4 -> PROC0 STK -> L3 -> L2 -> L1 |
    201  * +---------------+------------+-----------------------------------+---
    202  *                             (1)
    203  *
    204  * ---+-------------+
    205  *    | ISA I/O MEM |
    206  * ---+-------------+
    207  *   (2)
     235 * +---------------+------+-----------------------------------+-------------+
     236 * | TEXT + RODATA | DATA | L4 -> PROC0 STK -> L3 -> L2 -> L1 | ISA I/O MEM |
     237 * +---------------+------+-----------------------------------+-------------+
     238 *                       (1)                                 (2)
    208239 *
    209240 * PROC0 STK is obviously not linked as a page level. It just happens to be
     
    215246 *
    216247 * Important note: the kernel segments are properly 4k-aligned
    217  * (see kern.ldscript), so there's no need to enforce alignment.
     248 * (see kernel_x86.ld), so there's no need to enforce alignment.
    218249 */
    219250
     
    430461        killkpt
    431462
    432         /* Relocate atdevbase. */
     463        /* Save the virtual address of ISA I/O MEM. */
    433464        movq    $(TABLESIZE+KERNBASE),%rdx
    434465        addq    %rsi,%rdx
Note: See TracChangeset for help on using the changeset viewer.