Mail Archives: djgpp/1996/09/30/21:35:12
In article <52kebp$3l4 AT mn5 DOT swip DOT net>,
Peter Nordlander <peter DOT nordlander AT mbox2 DOT swipnet DOT se> wrote:
>Hi!
>
>I've just coded a keyboard interrupt in DJGPP 2.0. The problem is that
>the handler is written in C (not in asm) so i can't lock the wrapper and
>messages like "Page fault" appears on the screen.
>I've heard that to solve this problem I could disable Virtual memory so
>that my handler wont page.
The best way to lock a handler is with the __dpmi_lock_linear_region()
when you install the handler. That way you still get the benefits
of paging for the rest of the program. The other alternative is to
use "_crt0_startup_flags |= _CRT0_FLAG_LOCK_MEMORY" which locks all
memory.
struct {
char data_used_by_handler[DATASIZE];
} lock_me;
_go32_dpmi_seginfo old_seg_info;
_go32_dpmi_seginfo handler_seg_info;
void handler()
{
/* do stuff with data_used_by_handler */
}
void end_of_handler() /* must be in same object file as handler() */
{
}
__dpmi_meminfo data_info, handler_info;
int install_handler()
{
data_info.address=&lock_me;
data_info.size=sizeof(lock_me);
handler_info.address=handler;
handler_info.size=(unsigned long)(end_of_handler-handler);
handler_seg_info.pm_offset=handler;
handler_seg_info.pm_selector=_go32_my_cs;
return (
(old_seg_info.pm_offset != NULL) /* don't do it twice */
__dpmi_lock_linear_region(&data_info) ||
__dpmi_lock_linear_region(&handler_info) ||
_go32_dpmi_allocate_iret_wrapper(&handler_seg_info) ||
_go32_dpmi_get_protected_mode_interrupt_vector(VECTOR,old_seg_info) ||
_go32_dpmi_set_protected_mode_interrupt_vector(VECTOR,handler_seg_info)
);
}
int uninstall_handler()
{
return (
_go32_dpmi_set_protected_mode_interrupt_vector(VECTOR,old_seg_info) ||
_go32_dpmi_free_iret_wrapper(&(lock_me.handler_seg_info)) ||
__dpmi_unlock_linear_region(&handler_info) ||
__dpmi_unlock_linear_region(&data_info)
);
}
Eric
--
Eric Korpela | An object at rest can never be
korpela AT ssl DOT berkeley DOT edu | stopped.
<a href="http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpela/w">
Click here for more info.</a>
- Raw text -