Ich entwickle ein Betriebssystem. Mein GDT hat drei Einträge. Ich habe den IDT erstellt und ISR und IQR implementiert. Ich habe auch den PIC neu zugeordnet. Das Problem ist, dass nach jedem Interrupt-Handler eine allgemeine Schutzverletzung folgt. Dies ist der Assembler-Code, der die Interrupts ruft:Jeder IRQ und ISR verursacht einen GPF
.extern fault_handler
isr_common_stub:
pusha
push %ds
push %es
push %fs
push %gs
movw $0x10,%ax # Load the Kernel Data Segment descriptor!
movw %ax,%ds
movw %ax,%es
movw %ax,%fs
movw %ax,%gs
movl %esp,%eax # Push us the stack
pushl %eax
movl $fault_handler, %eax
call *%eax # A special call, preserves the 'eip' register
popl %eax
popl %gs # I discovered that the error occures on this line
popl %fs
popl %es
popl %ds
popa
addl $8,%esp # Cleans up the pushed error code and pushed ISR number
iret # pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP!
.extern irq_handler
irq_common_stub:
pusha
push %ds
push %es
push %fs
push %gs
movw $0x10,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%fs
movw %ax,%gs
movl %esp,%eax
pushl %eax
movl $irq_handler, %eax
call *%eax
popl %eax
popl %gs # I discovered that the error occures on this line
popl %fs
popl %es
popl %ds
popa
addl $8,%esp
iret
ich seltsam etwas herausgefunden. Wenn ich das Betriebssystem mit QEMU als .iso
Disk-Image ausführen, funktioniert es nicht. Aber als ich es als Kernel nannte, indem ich die -kernel
Option anwendete, funktionierte es wie erwartet. Ich beschloss, den Code unten zu ändern:
popl %gs # I discovered that the error occures on this line
popl %fs
popl %es
popl %ds
ich oben dazu den Code geändert:
pop %gs
pop %fs
pop %es
pop %ds
Ich bin immer noch die GPF bekommen. Mache ich etwas falsch? Irgendwelche Vorschläge?
Eine seltsame Sache ist, dass Sie 'push' machen, aber dann' popl' ... generell sollten Sie das gleiche 'push' /' pop' oder 'pushl' /' popl' verwenden. – Buddy
Ist Ihre 'gs' richtig initialisiert? ? Wenn es im Real-Modus noch einen Restwert hat, führt das Zurückspringen zu einem GPF. PS: lernen, einen Debugger PS # 2 zu verwenden: 'spezieller Anruf, konserviert das 'eip' Register' LOL? – Jester