Welcome to mirror list, hosted at ThFree Co, Russian Federation.

go32func.c « go32 « sys « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec3853ba1ca2c9d8a985d14fa7e0eb4baedaa3f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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, &regs);
    _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;
  }
}