I wrote two bootloaders, one is sblold.bin, the newer sbl.bin. With the first all is perfect, with the other one, something doesn't work. To build a floppy and test what I'm saying, you have simply to run the auto.bat file.
So, where is the problem? I suppose it is here in the asm stub of the kernel. I should write that it crashes here, because the problem is surely before.
Code: Select all
[BITS 32]
global start
start:
jmp afterLabel
db "_sys_"
db "kernel",0
afterLabel:
cli
mov ax,0x10
mov ds,ax
mov es,ax
mov fs,ax
mov ss,ax
mov gs,ax
mov esp, 0x7ffff ; This points the stack to our new stack area
jmp stublet
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
dd mboot
dd code
dd bss
dd end
dd start
stublet:
extern start_ctors, end_ctors, start_dtors, end_dtors, _kernel
loader:
; Possibly set up a stack here: mov esp, stack STACKSIZE
push eax ; Multiboot magic number
push ebx ; Multiboot info structure
static_ctors_loop:
mov ebx, start_ctors
jmp .test
.body:
call [ebx]
add ebx,4
.test:
cmp ebx, end_ctors
jb .body
jmp short cr ;I tried everything but it doesn't work
cr:
call _kernel ; HEREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!
static_dtors_loop:
mov ebx, start_dtors
jmp .test
.body:
call [ebx]
add ebx,4
.test:
cmp ebx, end_dtors
jb .body
jmp $
Code: Select all
[org 0x7c00]
[bits 16]
sti
cli
jmp l
l:
lgdt [gdtinfo]
mov eax,cr0
or eax,1
mov cr0,eax
;After it set registers and do a far jump to kernel. If data selector is 10h, code selector is 8 and kernel offset is 100000h do:
mov ax,0x10
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
jmp dword 0x8:0x100000
hlt
gdtinfo:
dw gdt_end - gdt - 1 ;last byte in table
dd gdt ;start of table
gdt dd 0,0 ; entry 0 is always unused
; gdt code: ; code descriptor
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0 ; base high
; gdt data: ; data descriptor
dw 0FFFFh ; limit low (Same as code)
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0 ; base high
gdt_end:
All this code works when I load and lauch it from the old version of sbl but not with the newest.
SBL works in real mode with 32bit access data (unreal mode). For any question I'm here. Please help me. I'm getting crazy (more than much I am).