ok, apparently you can't write interrupt handlers in C with djgpp, so i wrote a simple timer interrupt in asm that looks something like this:
_isra_timer:
pusha
push es
push ds
call _isr_timer ;in the main C kernel file
pop ds
pop es
popa
iret
where _isr_timer is externally referenced to my C kernel file which simply puts a '!' character to the screen. calling this function from my main C kernel works great. i have a setInterruptHandler function which creates an idt entry to point to a function. i have my PICs remapped to 0x20 and 0x28. when i do a setInterruptHandler(0x20, isr_timer) the idt points directly to the C function, i enable ints and on the timer interrupt the '!' is displayed and then it crashes, because the isr_timer function is just a normal function, it doesn't end with an iret. so i tried doing setInterruptHandler(0x20, _isra_timer) (i made _isra_timer global in my assembly file, linked with ld, output format aout) and that compiled fine, but when i ran it it just crashed without displaying a '!'. is there something i am doing wrong between C and asm or is the assembly code not right or what?
thanks for the help!
OSNewbie
djgpp C kernel interrupt handler
RE:djgpp C kernel interrupt handler
if u r setting up IDT structure in DJGPP C , then before defining stuct, type this :
#pragma pack (push,1)
struct .....
#pragma pop()
I am not sure , but this should work.
Well,I am facing similar problems at this moment. Instead of IRQ interrupts, I tried with software interrupt.
#pragma pack (push,1)
struct .....
#pragma pop()
I am not sure , but this should work.
Well,I am facing similar problems at this moment. Instead of IRQ interrupts, I tried with software interrupt.
RE:djgpp C kernel interrupt handler
i dont think djgpp (gcc) supports pragma
you'd need the __attribute__ ((__packed__)) or whatever the syntax is.
you'd need the __attribute__ ((__packed__)) or whatever the syntax is.
-- Stu --