3 * Test program: DPMI entry/exit functions
4 * (C) 2009-2012 Jonathan Campbell.
5 * Hackipedia DOS library.
7 * This code is licensed under the LGPL.
8 * <insert LGPL legal text here>
23 #include <hw/cpu/cpu.h>
24 #include <hw/dos/dos.h>
25 #include <hw/dos/dosbox.h>
26 #include <hw/dos/doswin.h>
32 int main(int argc,char **argv) {
33 unsigned char want = DPMI_ENTER_AUTO;
37 if (want < 16 || want > 32) return 1;
41 printf("DOS version %x.%02u\n",dos_version>>8,dos_version&0xFF);
42 printf(" Method: '%s'\n",dos_version_method);
43 if (detect_windows()) {
44 printf("I am running under Windows.\n");
45 printf(" Mode: %s\n",windows_mode_str(windows_mode));
46 printf(" Ver: %x.%02u\n",windows_version>>8,windows_version&0xFF);
47 printf(" Method: '%s'\n",windows_version_method);
50 printf("Not running under Windows or OS/2\n");
55 printf("This test requires DPMI\n");
59 printf("DPMI present:\n");
60 #if dpmi_no_0301h != 0
61 if (dpmi_no_0301h > 0) printf(" - DPMI function 0301H: Call real-mode far routine NOT AVAILABLE\n");
63 printf(" - Flags: 0x%04x\n",dpmi_flags);
64 printf(" - Entry: %04x:%04x (real mode)\n",(unsigned int)(dpmi_entry_point>>16UL),(unsigned int)(dpmi_entry_point & 0xFFFFUL));
65 printf(" - Processor type: %02x\n",dpmi_processor_type);
66 printf(" - Version: %u.%u\n",dpmi_version>>8,dpmi_version&0xFF);
67 printf(" - Private data length: %u paras\n",dpmi_private_data_length_paragraphs);
69 /* enter DPMI. the routine will briefly run in protected mode before finding it's way
70 * back to real mode where it can return back to this function */
71 if (!dpmi_enter(want)) {
72 printf("Unable to enter DPMI server\n");
75 printf("Allocated DPMI private segment: 0x%04x\n",dpmi_private_data_segment);
76 printf("DPMI entered as %u-bit.\n",dpmi_entered);
77 printf(" - PM CS:%04x DS:%04x ES:%04x SS:%04x\n",dpmi_pm_cs,dpmi_pm_ds,dpmi_pm_es,dpmi_pm_ss);
78 printf(" - Real to protected entry: %04x:%04x [rmode]\n",
79 (unsigned int)(dpmi_pm_entry>>16UL),(unsigned int)(dpmi_pm_entry&0xFFFFUL));
80 if (dpmi_entered == 32)
81 printf(" - Protected to real entry: %04x:%08lx [pmode]\n",
82 (unsigned int)((dpmi_rm_entry>>32ULL)&0xFFFFUL),(unsigned long)(dpmi_rm_entry&0xFFFFFFFFUL));
84 printf(" - Protected to real entry: %04x:%04x [pmode]\n",
85 (unsigned int)(dpmi_rm_entry>>16UL),(unsigned int)(dpmi_rm_entry&0xFFFFUL));