Hi, this is a (slightly reduced) copy of my bootloader... after the sti... bochs fails with the error "3rd (13) exception with no handler". Any help or insight into my idt errors would be much appreciated. thankyou
;------------------------------------------------------------------
; COMPILE TIME DEFINITIONS & MACROS:
;------------------------------------------------------------------
%macro outb 2
mov al, %2
out %1, al
%endmacro
;------------------------------------------------------------------
; CODE ENTRY POINT:
;------------------------------------------------------------------
BITS 16
[org 1000h] ;this was loaded from the bootsector !
Start:
mov ax, 9000h
mov ss, ax
mov sp, 0FFFFh ;Set stack
cli
call enable_A20
call remap_PIC
lgdt [gdt_desc]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp gdt_kernel_code : Protected_Mode_Start
;------------------------------------------------------------------
; BOOT LOADER 16 bit FUNCTIONS:
;------------------------------------------------------------------
enable_A20:
cli
.A20_1:
in al, 64h
test al, 2
jnz .A20_1
outb 64h, 0d1h
.A20_2:
in al, 64h
and ax, byte 2
jnz .A20_2
outb 60h, 0dfh
ret
remap_PIC:
cli
in al, 21h
push ax
in al, 0A1h
push ax
outb 20h, 11h
outb 0A0h, 11h
outb 21h, 20h
outb 0A1h, 28h
outb 21h, 4
outb 0A1h, 2
outb 21h, 01h
outb 0A1h, 01h
pop ax
outb 0A1h, al
pop ax
outb 21h, al
ret
;------------------------------------------------------------------
; 32 BIT PROTECTED MODE START:
;------------------------------------------------------------------
[BITS 32]
Protected_Mode_Start:
mov ax, gdt_kernel_data
mov ds, ax
mov ss, ax
mov esp, 090000h
mov ax, gdt_video_memory
mov es, ax
lidt [idt_desc]
sti
hang:
jmp hang
;------------------------------------------------------------------
; INTERRUPT HANDLERS:
;------------------------------------------------------------------
ISR:
pusha
push gs
push fs
push ds
push es
pop es
pop ds
pop fs
pop gs
popa
iret
;-------------------------------------------------------------------------------------
; GENERAL DESCRIPTOR TABLE:
;-------------------------------------------------------------------------------------
gdt:
gdt_null:
dd 0
dd 0
gdt_kernel_code equ $-gdt
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_kernel_data equ $-gdt
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_video_memory equ $-gdt
dw 1000h
dw 8000h
db 0bh
db 10010010b
db 11001111b
db 0
gdt_end:
gdt_desc:
dw gdt_end - gdt - 1
dd gdt
;-------------------------------------------------------------------------------------
; INTERRUPT DESCRIPTOR TABLE:
;-------------------------------------------------------------------------------------
idt:
%rep 256
dw ISR
dw gdt_kernel_code
db 0x00
db 0x8E
dw 0x0000
%endrep
idt_end:
idt_desc:
dw idt_end - idt - 1
dd idt
help.. idt troubles
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:help.. idt troubles
what is the CS value after the bootloader started your program ? if CS!=0, it means you cannot use the same in real and protected mode ...
Re:help.. idt troubles
Okay, so then the offset of my IRS is wrong because nasm gives it the offset from real mode yet it should have the offset from the cs in protmode.... does that make sense? thanks for the help
Re:help.. idt troubles
Hi all, I'm sorry for wasting space on this board.. I found my problem and it was quite a stupid one... I was not loading enough sectors off the disk and susequently not loading my idt correctly... so embarrassed.