github.com/icexin/eggos@v0.4.2-0.20220216025428-78b167e4f349/boot/multiboot_header.S (about)

     1  #define ASM_FILE        1
     2  #include "multiboot.h"
     3  
     4  /* The size of our stack (16KB). */
     5  #define STACK_SIZE                      0x4000
     6  #define MULTIBOOT_HEADER_FLAGS  MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE | MULTIBOOT_INFO_CMDLINE
     7  // #define MULTIBOOT_HEADER_FLAGS  MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
     8  
     9  .align  4
    10  .global multiboot_header
    11  multiboot_header:
    12    .long MULTIBOOT_HEADER_MAGIC
    13    .long MULTIBOOT_HEADER_FLAGS
    14    .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
    15    .long   0
    16    .long   0
    17    .long   0
    18    .long   0
    19    .long   0 
    20    .long 0
    21    .long 640
    22    .long 480
    23    .long 32
    24  
    25  .global _start
    26  _start:
    27    jmp     multiboot_entry
    28  
    29  multiboot_entry:
    30    /* Initialize the stack pointer. */
    31    movl    $(stack + STACK_SIZE), %esp
    32  
    33    /* Reset EFLAGS. */
    34    pushl   $0
    35    popf
    36  
    37    /* Push the pointer to the Multiboot information structure. */
    38    pushl   %ebx
    39    /* Push the magic value. */
    40    pushl   %eax
    41  
    42    /* Now enter the C main function... */
    43    call    multibootmain
    44  
    45    /* Our stack area. */
    46  .comm   stack, STACK_SIZE