![]() Is going to be a multiboot 2 header format. The first thing in boot.S is the multiboot header section. Ljmp $(KERNEL_GDT_ENTRY * GDT_ENTRY_SIZE), $_start64 Jne page_directory_table_loop // if not equal redo loop Movl %eax, high_page_directory_table(, %ecx, PAGE_DIRECTORY_ENTRY_SIZE) Movl %eax, low_page_directory_table(, %ecx, PAGE_DIRECTORY_ENTRY_SIZE) Or $(MMU_PRESENT | MMU_WRITABLE | MMU_PDE_TWO_MB), %eax Movl %eax, high_pdpt + (PDPT_ADDR_TO_ENTRY_INDEX(KERNEL_VIRTUAL_START) * PDPT_ENTRY_SIZE) Movl %eax, low_pdpt + (PDPT_ADDR_TO_ENTRY_INDEX(KERNEL_PHYSICAL_START) * PDPT_ENTRY_SIZE) Movl %eax, pml4 + (PML4_ADDR_TO_ENTRY_INDEX(KERNEL_VIRTUAL_START) * PML4_ENTRY_SIZE) Movl %eax, pml4 + (PML4_ADDR_TO_ENTRY_INDEX(KERNEL_PHYSICAL_START) * PML4_ENTRY_SIZE) type _start, $tmp_stack + KERNEL_BOOT_STACK_SIZE, %esp skip (GDT_TABLE_SIZE - (gdt_table_end - gdt_table)) comm tmp_stack, KERNEL_BOOT_STACK_SIZE, KERNEL_BOOT_STACK_ALIGNMENT comm high_page_directory_table, PAGE_DIRECTORY_SIZE, PAGE_DIRECTORY_ALIGNMENT comm low_page_directory_table, PAGE_DIRECTORY_SIZE, PAGE_DIRECTORY_ALIGNMENT comm high_pdpt, PDPT_SIZE, PDPT_ALIGNMENT comm low_pdpt, PDPT_SIZE, PDPT_ALIGNMENT long 8 // size, including itself (short + short + long) SET CHECKSUM, -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + HEADER_LENGTH) SET HEADER_LENGTH, header_end - header_start Post if you just need something quick and dirty that is also self-contained. I’ll put the output of the C preprocessor at the end of this Lot of macros to make it readable, self-documenting and to remove a bunch of S means the C preprocessor will be run first. The boot.S seenīelow has a lot of C macros, hence it’s boot.S instead of boot.s the capital It is also where the multiboot header is defined. Setting up the 64-bit paging data structures and 2) setting the CPU state for It is responsible for two main things: 1) #Locad iso in ram grub2 codeThe fact that we are jumping into C code isn’t that relevant and we could easily 1 Assembly Codeīoot.S is a bit of assembly that is going to get us into long mode and into C. Now that the memory layout for our little kernel is Identity mapped to low memory and everything else is loaded into low memory but The main take away from this linker script is that boot.o is Finally, _kernel_virtual_end and _kernel_physical_endĪre defined. #Locad iso in ram grub2 plusObject files is set at the location previous section plus the size of previous If you need moreįor your kernel you can decrease this number. The high virtual address space and it gives our kernel 2 GB. After all the sections for boot.o are specified theĬurrent output location is offset by 0xFFFFFFFF80000000. which is theĬurrent output location is set to four megabytes along with one variable So a couple things are going on in this linker script. _kernel_physical_end = (LOADADDR (.bss) + SIZEOF (.bss) + 0xFFF) & 0xFFFFFFFFFFFFF000 bss : AT ( (LOADADDR (.data) + SIZEOF (.data) + 0xFFF) & 0xFFFFFFFFFFFFF000 ) data : AT ( (LOADADDR (.rodata) + SIZEOF (.rodata) + 0xFFF) & 0xFFFFFFFFFFFFF000 ) ![]() So if you are using grub2 already consider adding an entry like the following to your grub config (/boot/grub/grub.cfg): menuentry "grml-rescue system from harddisk (ISO = grml-small_2008.11.rodata : AT ( (LOADADDR (.text) + SIZEOF (.text) + 0xFFF) & 0xFFFFFFFFFFFFF000 ) Linux (loop)/boot/grmlsmall/linux26 isofrom=/dev/sda1/grml/grml-small_2008.11.iso boot=live quiet vga=791 noeject noprompt You can boot it from the interactive grub shell using: loopback loop (hd0,1)/grml/grml-small_2008.11.iso In the following example the ISO file grml-small_2008.11.iso is available in directory grml on device /dev/sda1. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |