Hallo,
ich wollte heute eigentlich einfach IDTs und ISRs in Assembler implementieren, habe aber ein seltsames Problem.
Hier erstmal der Code:
Es passiert nur leider nichts, also habe ich mir mal die Bochslogs angeschaut. Es gibt tatsächlich die exception 0, aber der Rest sieht nicht gut aus:
Dann habe ich den Code in QEMU debugged und die Funktion IDT_installieren besteht nur aus Nullen. Ich weiß nicht, was am Code falsch sein sollte und kann mir auch nicht erklären, dass alles ab der Funktion IDT_installieren leer ist.
Auch kann ich mir die seltsame Position im Code nicht erklären, an der Bochs abbricht.
Danke schon mal für jede Hilfe.
EDIT:
Das Makro IDT_setzen:
ich wollte heute eigentlich einfach IDTs und ISRs in Assembler implementieren, habe aber ein seltsames Problem.
Hier erstmal der Code:
Code: [Auswählen]
IDT_Zeiger:
dw 256*8-1
dd IDT
IDT:
times 256*8 db 0 ; Platzhalter für 256 IDTs mit jeweils 8 Bytes
_IDT_setzen:
; ebp+8 -> Typ und Attribute
; ebp+12 -> Selektor
; ebp+16 -> Adresse der Bahandlungsfunktion
; ebp+20 -> Nummer der IDT
push ebp
mov ebp, esp
push eax
push ebx
push ecx
mov ebx, IDT ; die Adresse der IDTs in ebx speichern
mov eax, [ebp+20] ; die Nummer der IDT in eax speichern
mov cx, 8
mul cx
add ebx, eax ; ebx ist jetzt die Startadresse der IDT
mov eax, [ebp+16]
and eax, 0xFFFF
mov [ebx], word ax ; den ersten Teil der Adresse speichern
mov ax, [ebp+12]
mov [ebx+2], word ax
mov [ebx+4], byte 0
mov al, [ebp+8]
mov [ebx+5], byte al
mov eax, [ebp+16]
rol eax, 8
and eax, 0xFFFF
mov [ebx+6], word ax
pop ecx
pop eax
pop ebx
mov esp, ebp
pop ebp
ret 16
IDT_installieren:
IDT_setzen 0, ISR0, 0x08, 0x8E
lidt [IDT_Zeiger]
ret
ISR0:
Text_schreiben "Funktioniert! :)", 0, 1, 0xF
ret
und in der main.asmCode: [Auswählen]
mov ax, 1
mov dx, 0
div dx
Es passiert nur leider nichts, also habe ich mir mal die Bochslogs angeschaut. Es gibt tatsächlich die exception 0, aber der Rest sieht nicht gut aus:
Code: [Auswählen]
03471086138d[CPU0 ] protected mode activated
03471086157d[MEM0 ] allocate_block: used_blocks=0x3 of 0x20
03471152232d[CPU0 ] exception(0x00): error_code=0000
03471152232d[CPU0 ] interrupt(): vector = 00, TYPE = 3, EXT = 1
03471152232d[CPU0 ] interrupt(): INTERRUPT TO SAME PRIVILEGE
03471152235d[CPU0 ] BxError: Encountered an unknown instruction b1=0xff (signalling #UD)
03471152235d[CPU0 ] modrm was 0xff, nnn was 7, rm was 7
03471152235i[CPU0 ] 0x00000000d20009d2>> (invalid) : FFFF
03471152235d[CPU0 ] exception(0x06): error_code=0000
03471152235d[CPU0 ] interrupt(): vector = 06, TYPE = 3, EXT = 1
03471152235e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x06)
03471152235d[CPU0 ] exception(0x0d): error_code=0032
03471152235d[CPU0 ] interrupt(): vector = 0d, TYPE = 3, EXT = 1
03471152235e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
03471152235d[CPU0 ] exception(0x0d): error_code=006a
03471152235d[CPU0 ] exception(0x08): error_code=0000
03471152235d[CPU0 ] interrupt(): vector = 08, TYPE = 3, EXT = 1
03471152235e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
03471152235d[CPU0 ] exception(0x0d): error_code=0042
03471152235i[CPU0 ] CPU is in protected mode (active)
03471152235i[CPU0 ] CS.mode = 32 bit
03471152235i[CPU0 ] SS.mode = 32 bit
03471152235i[CPU0 ] | EAX=00000001 EBX=00000000 ECX=00090002 EDX=000f0000
03471152235i[CPU0 ] | ESP=001fffef EBP=00000000 ESI=000e93f2 EDI=0000ffac
03471152235i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
03471152235i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
03471152235i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
03471152235i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
03471152235i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
03471152235i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
03471152235i[CPU0 ] | FS:0000( 0000| 0| 0) 00000000 00000000 0 0
03471152235i[CPU0 ] | GS:0000( 0000| 0| 0) 00000000 00000000 0 0
03471152235i[CPU0 ] | EIP=d20009d2 (d20009d2)
03471152235i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
03471152235i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
03471152235i[CPU0 ] 0x00000000d20009d2>> (invalid) : FFFF
03471152235d[CTRL ] searching for component 'cpu' in list 'bochs'
03471152235d[CTRL ] searching for component 'reset_on_triple_fault' in list 'cpu'
03471152235p[CPU0 ] >>PANIC<< exception(): 3rd (13) exception with no resolution
03471152235e[CPU0 ] WARNING: Any simulation after this point is completely bogus !
03471152235p[CPU0 ] >>PANIC<< Entering to shutdown state still not implemented
Dann habe ich den Code in QEMU debugged und die Funktion IDT_installieren besteht nur aus Nullen. Ich weiß nicht, was am Code falsch sein sollte und kann mir auch nicht erklären, dass alles ab der Funktion IDT_installieren leer ist.
Auch kann ich mir die seltsame Position im Code nicht erklären, an der Bochs abbricht.
Danke schon mal für jede Hilfe.

EDIT:
Das Makro IDT_setzen:
Code: [Auswählen]
%macro IDT_setzen 4
push dword %1
push dword %2
push dword %3
push dword %4
call _IDT_setzen
%endmacro

Übersicht
Wiki
Hilfe
Suche
Einloggen
Registrieren
Drucken

Gespeichert