3 * Test program: DOS memory map awareness library
4 * (C) 2011-2012 Jonathan Campbell.
5 * Hackipedia DOS library.
7 * This code is licensed under the LGPL.
8 * <insert LGPL legal text here>
19 #include <hw/cpu/cpu.h>
20 #include <hw/dos/dos.h>
21 #include <hw/dos/dosbox.h>
22 #include <hw/dos/doswin.h>
24 #if TARGET_MSDOS == 32
25 uint16_t cpu_read_my_cs() {
39 #if TARGET_MSDOS == 32
45 printf("DOS version %x.%02u\n",dos_version>>8,dos_version&0xFF);
46 if (detect_windows()) {
47 printf("I am running under Windows.\n");
48 printf(" Mode: %s\n",windows_mode_str(windows_mode));
49 printf(" Ver: %x.%02u\n",windows_version>>8,windows_version&0xFF);
52 printf("Not running under Windows or OS/2\n");
55 if (detect_dosbox_emu())
56 printf("I am also running under DOSBox\n");
58 #if TARGET_MSDOS == 16
59 /* TODO: Someday the dos_ltp() code will work in 16-bit mode, for environments like EMM386.EXE v86 or from within
60 * the 16-bit Windows 3.1 world */
61 printf("This program is intended to test memory mapping under 32-bit protected mode and does not apply to 16-bit real mode\n");
63 if (!dos_ltp_probe()) {
64 printf("DOS linear->physical translation probe failed\n");
68 sg = cpu_read_my_cs();
70 printf(" Paging: %u (CPU paging enabled)\n",dos_ltp_info.paging);
71 printf(" DOS remap: %u (memory below 1MB is remapped, not 1:1)\n",dos_ltp_info.dos_remap);
72 printf(" Should lock pages: %u (Extender may page to disk or move pages)\n",dos_ltp_info.should_lock_pages);
73 printf(" Can't xlate: %u (No way to determine physical mem addr)\n",dos_ltp_info.cant_xlate);
74 printf(" Using PAE: %u (DOS extender is using PAE)\n",dos_ltp_info.using_pae);
75 printf(" DMA DOS xlate: %u (DMA is translated too, virtualized)\n",dos_ltp_info.dma_dos_xlate);
76 printf(" use VCPI xlate: %u (VCPI server can provide translation)\n",dos_ltp_info.vcpi_xlate);
77 printf(" CR0: 0x%08lx\n",dos_ltp_info.cr0);
78 printf(" CR3: 0x%08lx\n",dos_ltp_info.cr3);
79 printf(" CR4: 0x%08lx\n",dos_ltp_info.cr4);
80 printf(" CS: 0x%04x %s CPL=%u\n",(unsigned int)sg,sg & 4 ? "LDT" : "GDT",sg&3);
82 while ((c=getch()) != 13) {
83 if (c == 27) return 1;
91 printf("Map test (32MB):\n");
92 for (l=0;l < (32UL << 20UL);l += 4096) {
93 printf("0x%08lX: ",l); fflush(stdout);
94 p = dos_linear_to_phys(l);
95 if (p == DOS_LTP_FAILED) printf("N/A\n");
96 else printf("0x%08llX\n",p);
100 while ((c=getch()) != 13) {
101 if (c == 27) return 1;