fb:porticula NoPaste
core_idt.bi
Uploader: | ThePuppetMaster |
Datum/Zeit: | 26.08.2008 22:09:54 |
'###############################################################################################################
'###############################################################################################################
'### F B - C O R E
'###############################################################################################################
'###############################################################################################################
'### Version: 1.00.0
'### Revision: 0
'###############################################################################################################
'### (c) 2008 By.: /_\ DeltaLab's Germany [experimental computing]
'### Author: Martin Wiemann
'### Date of Idea: 2008.08.16 - 17:55:38
'###############################################################################################################
'### Copy('s) of this code or a part of this IS allowed!!!
'###############################################################################################################
'###############################################################################################################
Dim Shared IDT_Selector as Selector_Type
'###############################################################################################################
Type IDT_Type Field = 1
V_BaseAdr0 as UShort = 0
V_Seg as UShort = 0
V_Always0 as UByte = 0
V_Flags as UByte = 0
V_BaseAdr1 as UShort = 0
End Type
'--------------------------------------------------------------------------------------------------------------------
Dim Shared IDT(0 to 255) as IDT_Type
'###############################################################################################################
Type ISR_Info_Type Field = 1
V_gs as UInteger
V_fs as UInteger
V_es as UInteger
V_ds as UInteger
V_edi as UInteger
V_esi as UInteger
V_ebp as UInteger
V_esp as UInteger
V_ebx as UInteger
V_edx as UInteger
V_ecx as UInteger
V_eax as UInteger
V_int_no as UInteger
V_err_code as UInteger
V_eip as UInteger
V_cs as UInteger
V_eflags as UInteger
V_useresp as UInteger
V_ss as UInteger
End Type
'###############################################################################################################
Declare Sub _isr0()
Declare Sub _isr1()
Declare Sub _isr2()
Declare Sub _isr3()
Declare Sub _isr4()
Declare Sub _isr5()
Declare Sub _isr6()
Declare Sub _isr7()
Declare Sub _isr8()
Declare Sub _isr9()
Declare Sub _isr10()
Declare Sub _isr11()
Declare Sub _isr12()
Declare Sub _isr13()
Declare Sub _isr14()
Declare Sub _isr15()
Declare Sub _isr16()
Declare Sub _isr17()
Declare Sub _isr18()
Declare Sub _isr19()
Declare Sub _isr20()
Declare Sub _isr21()
Declare Sub _isr22()
Declare Sub _isr23()
Declare Sub _isr24()
Declare Sub _isr25()
Declare Sub _isr26()
Declare Sub _isr27()
Declare Sub _isr28()
Declare Sub _isr29()
Declare Sub _isr30()
Declare Sub _isr31()
Declare Sub IDT_Fault_Handler(V_Fault as ISR_Info_Type)
'###############################################################################################################
Private Sub IDT_Get_ErrDesc(V_InterruptID as UByte, ByRef B_Desc as String)
Select Case V_InterruptID
Case 0: B_Desc = "Division by Zero Exception"
Case 1: B_Desc = "Debug Exception"
Case 2: B_Desc = "Non Maskable Interrupt Exception"
Case 3: B_Desc = "Breakpoint Exception"
Case 4: B_Desc = "Into Detect Overflow Exception"
Case 5: B_Desc = "Out of Bounds Exception"
Case 6: B_Desc = "Invalid Opcode Exception"
Case 7: B_Desc = "No Coporocessor Exception"
Case 8: B_Desc = "Double Fault Exception"
Case 9: B_Desc = "Coprocessor Segemnt Overrun Exception"
Case 10: B_Desc = "Bad TSS Exception"
Case 11: B_Desc = "Segment Not Present Exception"
Case 12: B_Desc = "Stack Fault Exception"
Case 13: B_Desc = "General Protection Fault Exception"
Case 14: B_Desc = "Page Fault Exception"
Case 15: B_Desc = "Unknow Interrupt Exception"
Case 16: B_Desc = "Coprocessor Fault Exception"
Case 17: B_Desc = "Alignment Check Exception"
Case 18: B_Desc = "Machine Check Exception"
Case 19 to 32: B_Desc = "Reserved Exception"
Case Else: B_Desc = "[Unknow IDT Error]"
End Select
End Sub
'###############################################################################################################
Private Function IDT_Create_New(V_InterruptID as UByte, V_CallbackPtr as Any Ptr, V_Segment as UShort, V_Flags as UByte) as IDT_Type
Dim T as IDT_Type
With T
.V_BaseAdr0 = CUShort(Cast(UInteger, V_CallbackPtr) and &HFFFF)
.V_Seg = V_Segment
.V_Always0 = 0
.V_Flags = V_Flags
.V_BaseAdr1 = CUShort((Cast(UInteger, V_CallbackPtr) shr 16) and &HFFFF)
End With
Return T
End Function
'###############################################################################################################
Private Sub IDT_Init()
Dim XSeg as UShort = &H08
Dim XFlag as UByte = &H8E
IDT(0) = IDT_Create_New(0, @_isr0, XSeg, XFlag)
IDT(1) = IDT_Create_New(1, @_isr1, XSeg, XFlag)
IDT(2) = IDT_Create_New(2, @_isr2, XSeg, XFlag)
IDT(3) = IDT_Create_New(3, @_isr3, XSeg, XFlag)
IDT(4) = IDT_Create_New(4, @_isr4, XSeg, XFlag)
IDT(5) = IDT_Create_New(5, @_isr5, XSeg, XFlag)
IDT(6) = IDT_Create_New(6, @_isr6, XSeg, XFlag)
IDT(7) = IDT_Create_New(7, @_isr7, XSeg, XFlag)
IDT(8) = IDT_Create_New(8, @_isr8, XSeg, XFlag)
IDT(9) = IDT_Create_New(9, @_isr9, XSeg, XFlag)
IDT(10) = IDT_Create_New(10, @_isr10, XSeg, XFlag)
IDT(11) = IDT_Create_New(11, @_isr11, XSeg, XFlag)
IDT(12) = IDT_Create_New(12, @_isr12, XSeg, XFlag)
IDT(13) = IDT_Create_New(13, @_isr13, XSeg, XFlag)
IDT(14) = IDT_Create_New(14, @_isr14, XSeg, XFlag)
IDT(15) = IDT_Create_New(15, @_isr15, XSeg, XFlag)
IDT(16) = IDT_Create_New(16, @_isr16, XSeg, XFlag)
IDT(17) = IDT_Create_New(17, @_isr17, XSeg, XFlag)
IDT(18) = IDT_Create_New(18, @_isr18, XSeg, XFlag)
IDT(19) = IDT_Create_New(19, @_isr19, XSeg, XFlag)
IDT(10) = IDT_Create_New(10, @_isr20, XSeg, XFlag)
IDT(21) = IDT_Create_New(21, @_isr21, XSeg, XFlag)
IDT(22) = IDT_Create_New(22, @_isr22, XSeg, XFlag)
IDT(23) = IDT_Create_New(23, @_isr23, XSeg, XFlag)
IDT(24) = IDT_Create_New(24, @_isr24, XSeg, XFlag)
IDT(25) = IDT_Create_New(25, @_isr25, XSeg, XFlag)
IDT(26) = IDT_Create_New(26, @_isr26, XSeg, XFlag)
IDT(27) = IDT_Create_New(27, @_isr27, XSeg, XFlag)
IDT(28) = IDT_Create_New(28, @_isr28, XSeg, XFlag)
IDT(29) = IDT_Create_New(29, @_isr29, XSeg, XFlag)
IDT(30) = IDT_Create_New(30, @_isr30, XSeg, XFlag)
IDT(31) = IDT_Create_New(31, @_isr31, XSeg, XFlag)
IDT_Selector.V_Limit = SizeOf(IDT_Type) * 256 - 1
IDT_Selector.V_BaseAdr = Cast(UInteger, @IDT(0))
Asm
cli
lidt [IDT_Selector]
End Asm
End Sub
'###############################################################################################################
Public Sub IDT_Fault_Handler(V_Fault as ISR_Info_Type)
'cls
'With V_Fault
' Print .V_gs
' Print .V_fs
' Print .V_es
' Print .V_ds
' Print .V_edi
' Print .V_esi
' Print .V_ebp
' Print .V_esp
' Print .V_ebx
' Print .V_edx
' Print .V_ecx
' Print .V_eax
' Print .V_int_no
' Print .V_err_code
' Print .V_eip
' Print .V_cs
' Print .V_eflags
' Print .V_useresp
' Print .V_ss
'End With
'Do
'Loop
Dim T as String
IDT_Get_ErrDesc(V_Fault.V_int_no, T)
Core_GURU_Error(V_Fault.V_int_no, "IDT_FAULT_HANDLER", T, "", 1)
End Sub