OSDev.org https://forum.osdev.org/ |
|
Booting OS with GRUB https://forum.osdev.org/viewtopic.php?f=1&t=35975 |
Page 1 of 1 |
Author: | vt [ Mon Nov 04, 2019 10:20 am ] |
Post subject: | Booting OS with GRUB |
We are developing 32-bit OS. I used to run it like this: Code: qemu-system-i386 -kernel os.bin . Today I wanted to make ISO image: Code: grub-mkrescue -o bootable.iso iso When I start Code: qemu-system-i386 -cdrom bootable.iso it shows grub. Next, I press enter to boot OS. The OS started up, but in less than a second it returns to GRUB.Grub config: Code: menuentry "OS" { multiboot /os.bin } linker.ld: Code: ENTRY(_start) SECTIONS { . = 1M; kernel_phys_start = .; .text BLOCK(4K) : ALIGN(4K) { *(.multiboot) *(.text) } .rodata BLOCK(4K) : ALIGN(4K) { *(.rodata) } .data BLOCK(4K) : ALIGN(4K) { *(.rodata) } .bss BLOCK(4K) : ALIGN(4K) { *(COMMON) *(.bss) } kernel_phys_end = .; } boot.s: Code: .set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map .set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field .set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header .set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot # Declare a header as in the Multiboot Standard. .section .multiboot .align 4 .long MAGIC .long FLAGS .long CHECKSUM # Reserve a stack for the initial thread. .section .bss .align 16 stack_bottom: .skip 16384 # 16 KiB stack_top: # The kernel entry point. .section .text .global _start .type _start, @function _start: movl $stack_top, %esp # Call the global constructors. #call _init # Transfer control to the main kernel. call init # Hang if kernel_main unexpectedly returns. cli 1: hlt jmp 1b .size _start, . - _start |
Author: | Ethin [ Mon Nov 04, 2019 2:31 pm ] |
Post subject: | Re: Booting OS with GRUB |
If your description is accurate, then your OS is probably triple faulting. Once grub has loaded your kernel it is impossible for the system to "return" to it without a processor reset being initiated. Ensure you've set up a double fault handler to catch any errors that are not caught by any other IDT entries -- that should solve your problem. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |