Error booting with GRUB
Posted: Fri Sep 08, 2006 7:12 pm
I've been having trouble getting my OS to boot with GRUB - it's giving me error #7 (loading below 1 mb) with all of the linker scripts I've tried. Here's my linker script:
Here's my boot.asm:
(yes, thrown together from tutorials, but that's why I'm using c++ for the rest )
Anyone have any idea why it's doing this?
Code: Select all
OUTPUT_FORMAT(binary)
ENTRY(start)
phys = 0x100000; /* 1 meg */
SECTIONS
{
. = 0x100000;
.data phys :
{ data = .;
*(.data)
. = ALIGN(4096);
}
.text . :
{ code = .;
*(.text)
. = ALIGN(4096);
}
.bss . :
{ bss = .;
*(.bss)
. = ALIGN(4096);
}
.rodata . :
{ rodata = .;
*(.rodata)
. = ALIGN(4096);
}
end = .;
}
Code: Select all
; Boot.asm
; OS loader
[BITS 32]
[global start]
start:
mov esp, _sys_stack ; This points the stack to our new stack area
jmp stublet
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
; The Multiboot header
align 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd CHECKSUM
; fields used if MULTIBOOT_AOUT_KLUDGE is set in MULTIBOOT_HEADER_FLAGS
dd mboot ; these are PHYSICAL addresses
dd code ; start of kernel .text (code) section
dd bss ; end of kernel .data section
dd end ; end of kernel BSS
dd start ; kernel entry point (initial EIP)
[global _mbinfo]
[global _mbmagic]
[extern code]
[extern bss]
[extern end]
; align 4
;mboot:
; dd MULTIBOOT_HEADER_MAGIC
; dd MULTIBOOT_HEADER_FLAGS
; dd MULTIBOOT_CHECKSUM
; dd mboot
; dd code
; dd bss
; dd end
; dd start
;dd _mboot ; Location of this descriptor
;dd code ; Start of kernel '.text' (code) section.
;dd bss ; End of kernel '.data' section.
;dd end ; End of kernel.
;dd start ; Kernel entry point (initial EIP).
;_mbinfo:
; dd 0
;_mbmagic:
; dd 0
extern _main ; located in Kernel.cpp
call _main ; call int main(void) in Kernel.cpp
cli ; interrupts could disturb the halt
hlt ; halt the CPU
stublet:
jmp $
global _gdt_flush ; Allows the C code to link to this
;extern _gp
extern _gp ; Says that '_gp' is in another file
_gdt_flush:
lgdt [_gp] ; Load the GDT with our '_gp' which is a special pointer
mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:flush2 ; 0x08 is the offset to our code segment: Far jump!
flush2:
ret ; Returns back to the C++ code
global _idt_load
extern _idtp
_idt_load:
lidt [_idtp]
ret
;really long IRQ/ISR section removed
;bss:
SECTION .bss
resb 8192
_sys_stack:
Anyone have any idea why it's doing this?