China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 00:03
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Question about hooking interrupts under DJGPP. View 1,530 Replies 1
Original Poster Posted 2003-06-12 00:00 ·  中国 陕西 西安 教育网
初级用户
Credits 109
Posts 1
Joined 2003-06-11 00:00
23-year member
UID 4843
Gender Male
Status Offline
How do you use __dpmi_set_protected_mode_interrupt_vector? It seems you also have to lock memory? Is it very cumbersome?
What is the difference between this function and __go32_dpmi_chain_protected_mode_interrupt_vector? My program has two interrupts, and using the chain function causes problems.

Could some expert please give me a few pointers!
Thanks!
Floor 2 Posted 2003-07-09 00:00 ·  新加坡 星和视界(StarHub)宽带
初级用户
Credits 169
Posts 29
Joined 2003-07-09 00:00
23-year member
UID 6654
Gender Male
Status Offline
I suggest using functions like _go32_xxx to handle interrupt ISRs written in C. The DJGPP FAQ explains it very clearly.
As for chain, it should be avoided, because it will call the old ISR. If there are real mode instructions in it, a mode switch will occur, which greatly affects efficiency.
The variables in the ISR and the code segment of the ISR itself should both be locked. Usually there are macros like these:
#define END_FUNCTION(x) void x##_end(){}
#define LOCK_VARIABLE(x) _go32_dpmi_lock_data((void *)&x, (long)sizeof(x));
#define LOCK_FUNCTION(x) _go32_dpmi_lock_code(x, (long)x##_end - (long)x);
...
void my_isr(void)
{
...
outp(0x20, 0x20);
}
END_FUNCTION(my_isr);
...
Interrupt initialization part:
_go32_dpmi_seginfo OldISR, NewISR;
LOCK_FUNCTION(my_isr);
LOCK_VARIABLE(my_variable);
...
_go32_dpmi_get_protected_mode_interrupt_vector(IRQNum, &OldISR);
NewISR.pm_offset = (int)my_isr;
NewISR.pm_selector = _go32_my_cs();
_go32_dpmi_set_protected_mode_interrupt_vector(IRQNum,&NewISR);
//also set the interrupt mask, outp(0x21, inp(0x21) & xxH);
...
// main loop here
...
_go32_dpmi_set_protected_mode_interrupt_vector(IRQNum, &OldISR);

You should avoid mode switching as much as possible, so avoid directly or indirectly calling DOS/BIOS functions.


Forum Jump: