3 * Code to detect the surrounding DOS/Windows environment and support routines to work with it
4 * (C) 2009-2012 Jonathan Campbell.
5 * Hackipedia DOS library.
7 * This code is licensed under the LGPL.
8 * <insert LGPL legal text here>
16 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
26 #include <hw/cpu/cpu.h>
27 #include <hw/dos/dos.h>
28 #include <hw/dos/doswin.h>
29 #include <hw/dos/dosntvdm.h>
31 #if TARGET_MSDOS == 32 && !defined(TARGET_WINDOWS) && !defined(TARGET_OS2)
32 /* TODO: This should be moved into the hw/DOS library */
33 unsigned char nmi_32_hooked = 0;
34 int nmi_32_refcount = 0;
35 void (interrupt *nmi_32_old_vec)() = NULL;
38 #if TARGET_MSDOS == 32 && !defined(TARGET_WINDOWS) && !defined(TARGET_OS2)
39 /* NMI reflection (32-bit -> 16-bit)
40 This code is VITAL if we want to work with SBOS and MEGA-EM
41 from protected mode. */
42 static struct dpmi_realmode_call nmi_32_nr={0};
43 static void interrupt far nmi_32() {
44 /* trigger a real-mode INT 02h */
49 mov edi,offset nmi_32_nr ; we trust Watcom has left ES == DS
54 void do_nmi_32_unhook() {
55 if (nmi_32_refcount > 0)
58 if (nmi_32_refcount == 0) {
61 _dos_setvect(0x02,nmi_32_old_vec);
62 nmi_32_old_vec = NULL;
67 void do_nmi_32_hook() {
68 if (nmi_32_refcount == 0) {
71 nmi_32_old_vec = _dos_getvect(0x02);
72 _dos_setvect(0x02,nmi_32);