Mail Archives: djgpp/2000/06/18/08:56:50
On Sun, 18 Jun 2000, Alvin Lau wrote:
> When I run this program, I got a message "General Protection Fault".
> I tried to run this program step by step in RHIDE, it returns a message
> "Program has received signal: SIGABRT, Aborted" while running the statement
> asm("iret\n");
This program has at least two grave bugs:
1) You don't lock all the code and data touched by the interrupt handler;
2) You register your function as an interrupt handler directly, without
going through an iret wrapper first.
The second problem is probably the most serious one: it is not enough to
put asm("iret") into a normal C function to make it a valid interrupt
handler. You need to create a run-time environment expected by the code
produced by GCC; without that, the segment registers will not be set up
correctly, and the code will surely GP Fault.
I suggest to take a look at section 18.9 of the DJGPP FAQ, it explains
the necessary steps for hooking a hardware interrupt at some length. If
something there is unclear, please ask specific questions.
- Raw text -