Guest User

Untitled

a guest
May 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. MBOOT_PAGE_ALIGN equ 1 << 0 ; Load kernel and modules on a page boundary
  2. MBOOT_MEM_INFO equ 1 << 1 ; Provide your kernel with memory info
  3. MBOOT_HEADER_MAGIC equ 0x1BADB002 ; Multiboot Magic value
  4. ; NOTE: We do not use MBOOT_AOUT_KLUDGE. It means that GRUB does not
  5. ; pass us a symbol table.
  6. MBOOT_HEADER_FLAGS equ MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO
  7. MBOOT_CHECKSUM equ -(MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS)
  8.  
  9.  
  10. [BITS 32] ; All instructions should be 32-bit.
  11.  
  12. [SECTION .text]
  13. [GLOBAL mboot] ; Make 'mboot' accessible from C.
  14. [EXTERN code] ; Start of the '.text' section.
  15. [EXTERN bss] ; Start of the .bss section.
  16. [EXTERN end] ; End of the last loadable section.
  17.  
  18. mboot:
  19. dd MBOOT_HEADER_MAGIC ; GRUB will search for this value on each
  20. ; 4-byte boundary in your kernel file
  21. dd MBOOT_HEADER_FLAGS ; How GRUB should load your file / settings
  22. dd MBOOT_CHECKSUM ; To ensure that the above values are correct
  23.  
  24. dd mboot ; Location of this descriptor
  25. dd code ; Start of kernel '.text' (code) section.
  26. dd bss ; End of kernel '.data' section.
  27. dd end ; End of kernel.
  28. dd start ; Kernel entry point (initial EIP).
  29.  
  30. [EXTERN kmain] ; This is the entry point of our C code
  31. [GLOBAL start] ; Kernel entry point.
  32. start:
  33. push ebx ; Load multiboot header location
  34.  
  35. ; Execute the kernel:
  36. cli ; Disable interrupts.
  37. call kmain ; call our main() function.
  38. jmp $ ; Enter an infinite loop, to stop the processor
  39. ; executing whatever rubbish is in the memory
  40. ; after our kernel!
Add Comment
Please, Sign In to add comment