Multiboot disabling interrupts
Posted: Sun Jun 23, 2013 5:47 am
Hi guys,
I changed the multiboot code of my project but interrupts aren't called anymore.
If I replace the new multiboot code with an old one then interrupts are called again.
I wasn't versed in asm for years so I suspect I made an obvious error but I'm not seeing it.
The original multicode is here: https://github.com/narke/Versatile/blob ... ultiboot.S
The linker script is this one: https://github.com/narke/Versatile/blob ... script.lds
Can someone tell what I messed up please?
The new one written in NASM is this:
I changed the multiboot code of my project but interrupts aren't called anymore.
If I replace the new multiboot code with an old one then interrupts are called again.
I wasn't versed in asm for years so I suspect I made an obvious error but I'm not seeing it.
The original multicode is here: https://github.com/narke/Versatile/blob ... ultiboot.S
The linker script is this one: https://github.com/narke/Versatile/blob ... script.lds
Can someone tell what I messed up please?
The new one written in NASM is this:
Code: Select all
; Declare constants used for creating a multiboot header.
PAGE_ALIGN equ 1<<0 ; align loaded modules on page boundaries
MEMORY_INFO equ 1<<1 ; provide memory map
HEADER_FLAGS equ PAGE_ALIGN | MEMORY_INFO ; this is the Multiboot 'flag' field
HEADER_MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
CHECKSUM equ -(HEADER_MAGIC + HEADER_FLAGS) ; checksum of above, to prove we are multiboot
STACK_SIZE equ 0x4000 ; the size of the stack is 16KB
struc multiboot_header
.magic: resb 64
.flags: resb 64
.checksum: resb 64
.header_addr: resb 64
.load_addr: resb 64
.load_end_addr: resb 64
.bss_end_addr: resb 64
.entry_addr: resb 64
endstruc
; Declare a header as in the Multiboot Standard.
section .multiboot
align 4
dd HEADER_MAGIC
dd HEADER_FLAGS
dd CHECKSUM
dd multiboot_header
dd multiboot_entry
; The stack is defined here
[section .init_stack nobits alloc noexec write align=4]
stack_bottom:
resb STACK_SIZE
stack_top:
; The linker script specifies _start as the entry point to the kernel and the
; bootloader will jump to this position once the kernel has been loaded. It
; doesn't make sense to return from this function as the bootloader is gone.
section .text
global _start
_start:
multiboot_entry:
; Set up a stack
mov ebp, stack_top
mov esp, ebp
; Set EFLAGS to 0
push 0
; pop stack into the EFLAGS register
popf
; Push the magic and the address on the stack, so that they
; will be the parameters of the C main function
push ebx
push eax
; Calling kernel's entry point.
extern versatile_main
call versatile_main
; In case the function returns, we'll want to put the computer into an
; infinite loop. To do that, we use the clear interrupt ('cli') instruction
; to disable interrupts, the halt instruction ('hlt') to stop the CPU until
; the next interrupt arrives, and jumping to the halt instruction if it ever
; continues execution, just to be safe.
cli
.hang:
hlt
jmp .hang