exception when calling an int

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Realtime
Posts: 13
Joined: Mon Sep 22, 2014 10:38 am

exception when calling an int

Post by Realtime »

I was trying to develop an os in nasm but i got stuck in IDT:

The exception:

Code: Select all

Booting from 0000:7c00
00015496180e[CPU0  ] interrupt(): gate descriptor is not valid sys seg (vector=0x12)
00015496180e[CPU0  ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00015496180e[CPU0  ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
00015496180i[CPU0  ] CPU is in protected mode (active)
00015496180i[CPU0  ] CS.mode = 32 bit
00015496180i[CPU0  ] SS.mode = 32 bit
00015496180i[CPU0  ] EFER   = 0x00000000
00015496180i[CPU0  ] | EAX=00008e00  EBX=000003fc  ECX=00090000  EDX=00000000
00015496180i[CPU0  ] | ESP=00007bff  EBP=00000000  ESI=000e055d  EDI=0000ffac
00015496180i[CPU0  ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af pf cf
00015496180i[CPU0  ] | SEG sltr(index|ti|rpl)     base    limit G D
00015496180i[CPU0  ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 0 1
00015496180i[CPU0  ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 0 1
00015496180i[CPU0  ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 0 1
00015496180i[CPU0  ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 0 1
00015496180i[CPU0  ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 0 1
00015496180i[CPU0  ] |  GS:0010( 0002| 0|  0) 00000000 000fffff 0 1
00015496180i[CPU0  ] | EIP=00007e2f (00007e2f)
00015496180i[CPU0  ] | CR0=0x60000011 CR2=0x00000000
00015496180i[CPU0  ] | CR3=0x00000000 CR4=0x00000000
00015496180i[CPU0  ] 0x0000000000007e2f>> int 0x12 : CD12
00015496180e[CPU0  ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00015496180i[SYS   ] bx_pc_system_c::Reset(HARDWARE) called
00015496180i[CPU0  ] cpu hardware reset
My Codes:

Code: Select all

bits 32
org 0x7e00
%include "preproc.asm"

mov dword[MMNGR_TableBegin],0x7c00
mov dword[MMNGR_MinVal],0x100000
mov dword[MMNGR_MaxEntries],0x100

mov al,0x0c
call SetColor
call ClrScr

call IDT_Init
int 0x12

cli
hlt
%include "print32.asm"
%include "MMNGR.asm"
%include "IDT.asm"
And:

Code: Select all

%ifndef IDT_asm
%define IDT_asm
%include "preproc.asm"

bits 32

struc IDT_interrupt
	.baseLow resw 1
	.selector resw 1
	.reserved resb 1
	.flags resb 1
	.baseHi resw 1
endstruc

%define IDT_IDTBegin 0x7400

IDT_IDTPTR:
	.limit dw 0x800
	.base  dd IDT_IDTBegin

IDT_InvalidInt:
	call ClrScr
	ldstr ebx,"Invalid Interrupt Call"
	call Puts
	jmp $
	
IDT_SetInt:
	push eax
	push ebx
	push ecx
	lea eax,[ebx*8+IDT_IDTBegin]
	mov word[eax],cx
	inc eax
	inc eax
	mov word[eax],0x8
	inc eax
	mov byte[eax],0
	inc eax
	mov byte[eax],010001110b
	inc eax
	shr ecx,16
	mov word[eax],cx
	pop ecx
	pop ebx
	pop eax
	ret
	
IDT_Init:
	push ebx
	push ecx
	xor ebx,ebx
	mov ecx,IDT_InvalidInt
	_loop:
		call IDT_SetInt
		inc ebx
		cmp ebx,0x100
		jl _loop
	lidt [IDT_IDTPTR]
	pop ecx
	pop ebx
	ret

	
%include "print32.asm"

%endif
Can anyone see the problem? Thanks in advance.
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: exception when calling an int

Post by iansjack »

interrupt(): gate descriptor is not valid sys seg (vector=0x12)
interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
interrupt(): gate descriptor is not valid sys seg (vector=0x08)
Realtime
Posts: 13
Joined: Mon Sep 22, 2014 10:38 am

Re: exception when calling an int

Post by Realtime »

iansjack wrote:
interrupt(): gate descriptor is not valid sys seg (vector=0x12)
interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
interrupt(): gate descriptor is not valid sys seg (vector=0x08)
Well , i thought that had something to do with it but .. I have no idea what it means :(
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: exception when calling an int

Post by iansjack »

Have you read about descriptors and descriptor tables in the Intel Programmer's Manuals? That should tell you all you need to know.
Realtime
Posts: 13
Joined: Mon Sep 22, 2014 10:38 am

Re: exception when calling an int

Post by Realtime »

Ok i found the problem .. IDT_SetInt function doesn't set the Ints right .. When i defined the idt in the file with everything in place it worked ... Now i have to find what's IDT_SetInt's problem .. Can anyone help me again :D pretty pleaaase ??
User avatar
eryjus
Member
Member
Posts: 286
Joined: Fri Oct 21, 2011 9:47 pm
Libera.chat IRC: eryjus
Location: Tustin, CA USA

Re: exception when calling an int

Post by eryjus »

iansjack wrote:Have you read about descriptors and descriptor tables in the Intel Programmer's Manuals? That should tell you all you need to know.
Go get the Intel manuals. You are not setting up the IDT entry (flags) correctly.
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
Realtime
Posts: 13
Joined: Mon Sep 22, 2014 10:38 am

Re: exception when calling an int

Post by Realtime »

Thank you all guys I finally fixed it .. My interrupts work just fine now :)
Post Reply