Bona Fide OS Developer
View unanswered posts | View active topics It is currently Thu Mar 28, 2024 6:14 pm



Post new topic Reply to topic  [ 4 posts ] 
 Kernel Wont Execute? 
Author Message

Joined: Mon Aug 16, 2010 7:42 pm
Posts: 2
Post Kernel Wont Execute?
Hey,

I've written a bootloader that sets up an enviroment for a kernel, but when i jump to the 32b kernel it dies? The 32bit sections in the BL itself execute perfectly but if i jump outside the BL it crashes!

I've tried two differnt kernels including a VERY basic ASM kernel which consited of about 3 lines. I'm positive I've messed something up, but i just can't see it!


the exact boch error message is

00000578368p[CPU ] >>PANIC<< exception(): 3rd (13) exception with no resolution

I can't seem to google my answer this time =(

Code:
[BITS 16]     ; We need 16-bit intructions for Real mode

[ORG 0x7C00]    ; The BIOS loads the boot sector into memory location 0x7C00

words db 'S O M E   T E X T ',0000

loadkernel:
     mov bx, 0x8000  ; segment
     mov es, bx
     mov bx, 0x0000  ; offset

   mov ah, 0x02  ; read function
   mov al, 0x25; sectors
   mov ch, 0x00  ; cylinder
     mov cl, 0x02  ; sector
     mov dh, 0x00  ; head
     mov dl, 0x00  ; drive
     int 0x13   ; disk int

     jc loadkernel;



        cli                     ; Disable interrupts
        xor ax, ax
        mov ds, ax              ; Set DS-register to 0 - used by lgdt

        lgdt [gdt_desc]         ; Load the GDT descriptor

        mov eax, cr0            ; Copy the contents of CR0 into EAX
        or eax, 1               ; Set bit 0
        mov cr0, eax            ; Copy the contents of EAX into CR0

       jmp 08h:clear_pipe      ; Jump to code segment, offset clear_pipe
      
      ;db 0eah
      ;dw 00000h ; offset
      ;dw 08000h ; segment

[BITS 32]                      ; We now need 32-bit instructions
clear_pipe:
        mov ax, 10h             ; Save data segment identifyer
        mov ds, ax              ; Move a valid data segment into the data segment register
        mov ss, ax              ; Move a valid data segment into the stack segment register
        mov esp, 090000h        ; Move the stack pointer to 090000h
   mov esi,words
   xor edx,edx
   loop0:    ;put message to screen
     mov word cx,[esi]
     mov word [ds:0B8000h+1920d+edx],cx    ; M
     inc edx
     inc esi
     cmp byte [esi],0
     jnz loop0
   ;mov byte [ds:0B8001h], 1Bh      ; Assign a color code
   
   ;execute kernel
   call 08000h
   
   
gdt:                    ; Address for the GDT

gdt_null:               ; Null Segment
        dd 0
        dd 0

gdt_code:               ; Code segment, read/execute, nonconforming
        dw 0FFFFh
        dw 0
        db 0
        db 10011010b
        db 11001111b
        db 0

gdt_data:               ; Data segment, read/write, expand down
        dw 0FFFFh
        dw 0
        db 0
        db 10010010b
        db 11001111b
        db 0

gdt_end:                ; Used to calculate the size of the GDT



gdt_desc:                       ; The GDT descriptor
        dw gdt_end - gdt - 1    ; Limit (size)
        dd gdt                  ; Address of the GDT
       

times 510-($-$$) db 0           ; Fill up the file with zeros

        dw 0AA55h                ; Boot sector identifyer


I've also tried different jump methods to the kernel using CALL, JMP &

Code:
db 0eah
dw 00000h ; offset
dw 08000h ; segment


Mon Aug 16, 2010 7:49 pm
Profile

Joined: Wed Oct 14, 2009 9:39 am
Posts: 198
Location: United States
Post Re: Kernel Wont Execute?
I think, but I am not sure since I haven't done this before, but have you told the CPU to switch from 16-bit to 32-bit?

_________________
Charles Timko
push %esp ;Musings of a computer addict


Tue Aug 17, 2010 4:49 pm
Profile WWW

Joined: Mon Aug 16, 2010 7:42 pm
Posts: 2
Post Re: Kernel Wont Execute?
I found the problem - I'm a bit of an idiot actually =)

I have it jumping to 08000h but in the linker scripts i set it to 01000h.


Wed Aug 18, 2010 6:42 am
Profile

Joined: Wed Oct 14, 2009 9:39 am
Posts: 198
Location: United States
Post Re: Kernel Wont Execute?
That would do it!

_________________
Charles Timko
push %esp ;Musings of a computer addict


Sat Aug 21, 2010 10:53 am
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin and tweaked by the BF Team.