diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:39:52 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:39:52 +0000 |
commit | 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc (patch) | |
tree | 68c3dbf3f2c6fd5d49777def9914d77b5cd4589d /newlib/libc/sys/go32/go32func.c | |
parent | 1fd5e000ace55b323124c7e556a7a864b972a5c4 (diff) | |
download | cygnal-8a0efa53e44919bcf5ccb1d3353618a82afdf8bc.tar.gz cygnal-8a0efa53e44919bcf5ccb1d3353618a82afdf8bc.tar.bz2 cygnal-8a0efa53e44919bcf5ccb1d3353618a82afdf8bc.zip |
import newlib-2000-02-17 snapshot
Diffstat (limited to 'newlib/libc/sys/go32/go32func.c')
-rw-r--r-- | newlib/libc/sys/go32/go32func.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/newlib/libc/sys/go32/go32func.c b/newlib/libc/sys/go32/go32func.c new file mode 100644 index 000000000..ec3853ba1 --- /dev/null +++ b/newlib/libc/sys/go32/go32func.c @@ -0,0 +1,69 @@ +#include <sys/types.h> +#include "go32.h" +#include "dpmi.h" +#include "dos.h" + +u_short _go32_my_cs() +{ + asm("movw %cs,%ax"); +} + +u_short _go32_my_ds() +{ + asm("movw %ds,%ax"); +} + +u_short _go32_my_ss() +{ + asm("movw %ss,%ax"); +} + +u_short _go32_conventional_mem_selector() +{ + return _go32_info_block.selector_for_linear_memory; +} + +static _go32_dpmi_registers regs; +static volatile u_long ctrl_break_count = 0; +static int ctrl_break_hooked = 0; +static _go32_dpmi_seginfo old_vector; +static _go32_dpmi_seginfo new_vector; + +static ctrl_break_isr(_go32_dpmi_registers *regs) +{ + ctrl_break_count ++; +} + +u_long _go32_was_ctrl_break_hit() +{ + u_long cnt; + _go32_want_ctrl_break(1); + cnt = ctrl_break_count; + ctrl_break_count = 0; + return cnt; +} + +void _go32_want_ctrl_break(int yes) +{ + if (yes) + { + if (ctrl_break_hooked) + return; + _go32_dpmi_get_real_mode_interrupt_vector(0x1b, &old_vector); + + new_vector.pm_offset = (int)ctrl_break_isr; + _go32_dpmi_allocate_real_mode_callback_iret(&new_vector, ®s); + _go32_dpmi_set_real_mode_interrupt_vector(0x1b, &new_vector); + ctrl_break_count = 0; + ctrl_break_hooked = 1; + } + else + { + if (!ctrl_break_hooked) + return; + _go32_dpmi_set_real_mode_interrupt_vector(0x1b, &old_vector); + _go32_dpmi_free_real_mode_callback(&new_vector); + ctrl_break_count = 0; + ctrl_break_hooked = 0; + } +} |