diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/v86/scaffold | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to '')
21 files changed, 3443 insertions, 0 deletions
diff --git a/private/mvdm/v86/scaffold/i386/fakebop.c b/private/mvdm/v86/scaffold/i386/fakebop.c new file mode 100644 index 000000000..b9430dd30 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/fakebop.c @@ -0,0 +1,502 @@ +#include <windows.h> +#include <stdio.h> +#include <conio.h> +#include "demexp.h" +#include "cmdsvc.h" +#include "rdrexp.h" +#include "dbgexp.h" +#include "softpc.h" +#include "fun.h" +// +// This module contains the fake function definitions for bop functions +// + +extern CONTEXT IntelRegisters; +extern VOID switch_to_real_mode(); +extern VOID host_unsimulate(); + + +HANDLE hWOWDll; + +FARPROC WOWDispatchEntry; +FARPROC WOWInitEntry; + +void DBGDispatch( void ); + +void reset(){} +void dummy_int(){} +void unexpected_int(){} +void illegal_bop(){} +void print_screen(){} +void time_int(){} +void keyboard_int(){} +void diskette_int(){} +void video_io(){} +void equipment(){} +void memory_size(){} +void disk_io(){} +void rs232_io(){} +void cassette_io(){} +void keyboard_io(){} +void printer_io(){} +void rom_basic(){} +void bootstrap(){} +void time_of_day(){} +void critical_region(){} +void cmd_install(){} +void cmd_load(){} +void redirector(){} +void ega_video_io(){} +void MsBop0(){ + + DemDispatch((ULONG)(*Sim32GetVDMPointer( + ((ULONG)getCS() << 16) + (getIP()), 1, FALSE))); + setIP(getIP() + 1); + +} +void MsBop1(){ + + + static WowModeInitialized = FALSE; + + if (!WowModeInitialized) { + + // Load the WOW DLL + if ((hWOWDll = LoadLibrary ("WOW32")) == NULL){ + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing WOW\n") + ); + TerminateVDM(); + return; + } + + // Get the init entry point and dispatch entry point + if ((WOWInitEntry = GetProcAddress (hWOWDll, "W32Init")) == NULL) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing WOW\n") + ); + FreeLibrary (hWOWDll); + TerminateVDM(); + return; + } + + if ((WOWDispatchEntry = GetProcAddress (hWOWDll, "W32Dispatch")) == NULL) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing WOW\n") + ); + FreeLibrary (hWOWDll); + TerminateVDM(); + return; + } + + // Call the Init Routine + if ((*WOWInitEntry)() == FALSE) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing WOW\n") + ); + TerminateVDM(); + return; + } + + WowModeInitialized = TRUE; + } + + (*WOWDispatchEntry)(); +} + +void MsBop2(){ + + XMSDispatch((ULONG)(*Sim32GetVDMPointer( + ((ULONG)getCS() << 16) + (getIP()), 1, FALSE))); + setIP(getIP() + 1); + +} +void MsBop3(){ + DpmiDispatch(); +} + + + +void MsBop4(){ + CmdDispatch((ULONG)(*Sim32GetVDMPointer( + ((ULONG)getCS() << 16) + (getIP()), 1, FALSE))); + setIP(getIP() + 1); +} + + + +// +// MsBop5 - used to dispatch to Vdm Redir (Vr) support functions +// + +void MsBop5() +{ +#ifdef NTVDM_NET_SUPPORT + VrDispatch((ULONG)(*Sim32GetVDMPointer( + ((ULONG)getCS() << 16) + (getIP()), 1, FALSE))); + setIP(getIP() + 1); +#endif +} + +// +// MsBop6 - used to dispatch to debugger support functions +// + +void MsBop6() +{ + /* + ** All of the parameters for the debugger support + ** should be on the VDMs stack. + */ + DBGDispatch(); +} +void MsBop7(){} +void MsBop8(){} +void MsBop9(){} +void MsBopA(){} +void MsBopB(){ + + switch (getAH()) { + + case 0 : + setAH(0); + while (!tkbhit()); + setAL((BYTE)tgetch()); + break; + + case 1 : + tputch(getAL()); + break; + } +} +void MsBopC(){ + + BiosKbd(); + +} +void MsBopD(){ + + BiosVid(); + +} +void MsBopE(){} + + +void MsBopF(){ + UCHAR *Instruction; + USHORT i; + + // Unimplemented interrupt bop + + Instruction = RMSEGOFFTOLIN(getSS(), getSP()); + Instruction = RMSEGOFFTOLIN(*((PWORD)Instruction + 1), + *(PWORD)(Instruction)); + i = (USHORT)(*(Instruction - 1)); + VDprint( + VDP_LEVEL_WARNING, + ("SoftPC Bop Support: Unimplemented Interrupt %x\n", + i) + ); + +} +void emm_init(){} +void emm_io(){} +void return_from_call(){} +void rtc_int(){} +void re_direct(){} +void D11_int(){} +void int_287(){} +void worm_init(){} +void worm_io(){} +void ps_private_1(){} +void ps_private_2(){} +void ps_private_3(){} +void ps_private_4(){} +void ps_private_5(){} +void ps_private_6(){} +void ps_private_7(){} +void ps_private_8(){} +void ps_private_9(){} +void ps_private_10(){} +void ps_private_11(){} +void ps_private_12(){} +void ps_private_13(){} +void ps_private_14(){} +void ps_private_15(){} +void bootstrap1(){} +void bootstrap2(){} +void bootstrap3(){} +void ms_windows(){} +void msw_mouse(){} +void mouse_install1(){} +void mouse_install2(){} +void mouse_int1(){} +void mouse_int2(){} +void mouse_io_language(){} +void mouse_io_interrupt(){} +void mouse_video_io(){} +void control_bop(){} +void diskette_io(){} +void illegal_op_int(){} + +VOID (*BIOS[])(VOID) = { reset, + dummy_int, + unexpected_int, + illegal_bop, + illegal_bop, + print_screen, + illegal_op_int, + illegal_bop, + time_int, + keyboard_int, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + diskette_int, + illegal_bop, + video_io, + equipment, + memory_size, + disk_io, + rs232_io, + cassette_io, + keyboard_io, + printer_io, + rom_basic, + bootstrap, + time_of_day, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + critical_region, + cmd_install, + cmd_load, + illegal_bop, + illegal_bop, + redirector, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + diskette_io, + illegal_bop, + ega_video_io, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + MsBop0, + MsBop1, + MsBop2, + MsBop3, + MsBop4, + MsBop5, + MsBop6, + MsBop7, + MsBop8, + MsBop9, + MsBopA, + MsBopB, + MsBopC, + MsBopD, + MsBopE, + MsBopF, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + emm_init, + emm_io, + return_from_call, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + rtc_int, + re_direct, + D11_int, + D11_int, + D11_int, + int_287, + D11_int, + D11_int, + worm_init, + worm_io, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + ps_private_1, + ps_private_2, + ps_private_3, + ps_private_4, + ps_private_5, + ps_private_6, + ps_private_7, + ps_private_8, + ps_private_9, + ps_private_10, + ps_private_11, + ps_private_12, + ps_private_13, + ps_private_14, + ps_private_15, + illegal_bop, + bootstrap1, + bootstrap2, + bootstrap3, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + ms_windows, + msw_mouse, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + mouse_install1, + mouse_install2, + mouse_int1, + mouse_int2, + mouse_io_language, + mouse_io_interrupt, + mouse_video_io, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + illegal_bop, + switch_to_real_mode, + host_unsimulate, + control_bop }; + diff --git a/private/mvdm/v86/scaffold/i386/fakeinit.c b/private/mvdm/v86/scaffold/i386/fakeinit.c new file mode 100644 index 000000000..ae5d586de --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/fakeinit.c @@ -0,0 +1,123 @@ +// +// Fake Bios support initialization. +// +// This file provides interrim support for rom bios services initialization. +// It is only intended for use until Insignia produces proper rom support +// for NTVDM +// + +#include <windows.h> +#include <stdio.h> +#include <conio.h> +#include <string.h> +#include "softpc.h" +#include "bop.h" +#include "xguest.h" +#include "xbios.h" +#include "xbiosdsk.h" +#include "fun.h" + +#define SERVICE_LENGTH 4 +static BYTE ServiceRoutine[] = { 0xC4 , 0xC4, BOP_UNIMPINT, 0xCF }; + +#define RESET_LENGTH 16 +static BYTE ResetRoutine[] = { 0xEA, 0x00, 0x00, 0x00, 0xE0, // jmpf E000:0 + BIOSDATE_MINE, + 0, 0xFE, 0 }; + +static BYTE WarmBoot[] = { + OPX_MOVAX, BYTESOFFSET(0x30), + OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_SS,REG_AX), + OPX_MOVSP, BYTESOFFSET(0x100), + OPX_MOVAX, 0x00, 0x00, + OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_DS,REG_AX), + OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_ES,REG_AX), + OPX_MOVDX, DRIVE_FD0, 0x00, // WARNING: sync with BIOSBOOT_DRIVE + OPX_MOVCX, 0x01, 0x00, + OPX_MOVBX, BYTESOFFSET(BIOSDATA_BOOT), + OPX_MOVAX, 0x01, DSKFUNC_READSECTORS, + OPX_INT, BIOSINT_DSK, + OPX_JB, -7, + OPX_JMPF, BYTESCOMPOSITE(0, BIOSDATA_BOOT) +}; +#define WARMBOOT_LENGTH sizeof(WarmBoot) + +static BYTE EquipmentRoutine[] = { // INT 11h code + OPX_PUSHDS, + OPX_MOVAX, 0x00, 0x00, + OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_DS,REG_AX), + OPX_MOVAXOFF, BYTESOFFSET(BIOSDATA_EQUIP_FLAG), + OPX_POPDS, + OPX_IRET +}; +#define EQUIPMENT_LENGTH sizeof(EquipmentRoutine) + +static BYTE MemoryRoutine[] = { // INT 12h code + OPX_PUSHDS, + OPX_MOVAX, 0x00, 0x00, + OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_DS,REG_AX), + OPX_MOVAXOFF, BYTESOFFSET(BIOSDATA_MEMORY_SIZE), + OPX_POPDS, + OPX_IRET +}; +#define MEMORY_LENGTH sizeof(MemoryRoutine) + + +VOID BiosInit(int argc, char *argv[]) { + + PVOID Address, RomAddress; + + // set up IVT with unimplemented interrupt handler + + for (Address = NULL; Address < (PVOID)(0x1D * 4); (PCHAR)Address += 4) { + *(PWORD)Address = 0x100; + *(((PWORD)Address) + 1) = 0xF000; + } + + RomAddress = (PVOID)(0xE000 << 4); + + // set up warm boot handler + memcpy(RomAddress, WarmBoot, WARMBOOT_LENGTH); + Address = RMSEGOFFTOLIN(0, BIOSINT_WBOOT * 4); + *((PWORD)Address) = 0; + *((PWORD)Address + 1) = 0xE000; + (PCHAR)RomAddress += WARMBOOT_LENGTH; + + // set up equipment interrupt handler + memcpy(RomAddress, EquipmentRoutine, EQUIPMENT_LENGTH); + Address = RMSEGOFFTOLIN(0, BIOSINT_EQUIP * 4); + *((PWORD)Address) = RMOFF(RomAddress); + *((PWORD)Address + 1) = RMSEG(RomAddress); + (PCHAR)RomAddress += EQUIPMENT_LENGTH; + + // set up memory size interrupt handler + memcpy(RomAddress, MemoryRoutine, MEMORY_LENGTH); + Address = RMSEGOFFTOLIN(0, BIOSINT_MEMORY * 4); + *((PWORD)Address) = RMOFF(RomAddress); + *((PWORD)Address + 1) = RMSEG(RomAddress); + + RomAddress = (PVOID)((0xF000 << 4) + 0x100); + + Address = (PBYTE)RomAddress + 0xFE53; + *(PCHAR)Address = 0xCF; // IRET at f000:ff53 + + // set up unimplemented interrupt handler + + memcpy(RomAddress, ServiceRoutine, SERVICE_LENGTH); + (PCHAR)RomAddress += SERVICE_LENGTH; + + // set up reset code + memcpy(RMSEGOFFTOLIN(BIOSROM_SEG, BIOSROM_RESET), ResetRoutine, RESET_LENGTH); + + // set up equipment byte and memory size + + *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_EQUIP_FLAG) = + BIOSEQUIP_32KPLANAR; + *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_MEMORY_SIZE) = + 640; + + // Initialize individual rom modules + + BiosKbdInit(argc, argv, &RomAddress); + BiosVidInit(argc, argv, &RomAddress); +} diff --git a/private/mvdm/v86/scaffold/i386/fakekbd.c b/private/mvdm/v86/scaffold/i386/fakekbd.c new file mode 100644 index 000000000..8e807548e --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/fakekbd.c @@ -0,0 +1,281 @@ + +// +// Fake Keyboard rom support +// +// This file provides interrim support for keyboard rom bios services. +// It is only intended for use until Insignia produces proper rom support +// for NTVDM +// +// Note: portions of this code were lifted from the following source. + +/* x86 v1.0 + * + * XBIOSKBD.C + * Guest ROM BIOS keyboard emulation + * + * History + * Created 20-Oct-90 by Jeff Parsons + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + +#include <windows.h> +#include <stdio.h> +#include <conio.h> +#include <string.h> +#include "softpc.h" +#include "bop.h" +#include "xbios.h" +#include "xbioskbd.h" +#include "xwincon.h" +#include "fun.h" +#include <conapi.h> + +extern HANDLE InputHandle; + +#define MAX_KBD_BUFFER 256 +CHAR KbdBuffer[MAX_KBD_BUFFER]; +ULONG Head=0,Tail=0; +HANDLE KbdSyncEvent; +CRITICAL_SECTION csKbd; +CRITICAL_SECTION csConsole; +CRITICAL_SECTION csCtrlc; +BOOL fEventThreadBlock = FALSE; +HANDLE hConsoleWait; +ULONG nCtrlc=0; + +HANDLE StdIn; + +static BYTE ServiceRoutine[] = { 0xC4, 0xC4, BOP_KBD, 0x50, 0x55, 0x8B, + 0xEC, 0x9C, 0x58, 0x89, 0x46, 0x08, 0x5d, 0x58, 0xCF }; +#define SERVICE_LENGTH sizeof(ServiceRoutine) + +/* BiosKbdInit - Initialize ROM BIOS keyboard support + * + * ENTRY + * argc - # of command-line options + * argv - pointer to first option pointer + * ServiceAddress - linear address to put service routine at + * + * EXIT + * TRUE if successful, FALSE if not + */ + +BOOL BiosKbdInit(int argc, char *argv[], PVOID *ServiceAddress) +{ + PVOID Address; + + argc, argv; + + memcpy(*ServiceAddress, ServiceRoutine, SERVICE_LENGTH); + + Address = (PVOID)(BIOSINT_KBD * 4); + *((PWORD)Address) = RMOFF(*ServiceAddress); + *(((PWORD)Address) + 1) = RMSEG(*ServiceAddress); + (PCHAR)*ServiceAddress += SERVICE_LENGTH; + + StdIn = GetStdHandle(STD_INPUT_HANDLE); + + KbdSyncEvent = CreateEvent( NULL, TRUE, FALSE,NULL ); + + InitializeCriticalSection (&csKbd); + InitializeCriticalSection(&csConsole); + InitializeCriticalSection(&csCtrlc); + + hConsoleWait = CreateEvent (NULL,TRUE,FALSE,NULL); + + return TRUE; +} + + +/* BiosKbd - Emulate ROM BIOS keyboard functions + * + * ENTRY + * None (x86 registers contain parameters) + * + * EXIT + * None (x86 registers/memory updated appropriately) + * + * This function receives control on INT 16h, routes control to the + * appropriate subfunction based on the function # in AH, and + * then simulates an IRET and returns back to the instruction emulator. + */ + +VOID BiosKbdReadLoop (VOID) +{ +ULONG Temp; + + while (1) { + + Temp = Head + 1; + if(Temp >= MAX_KBD_BUFFER) + Temp =0; + if(Temp == Tail){ + Sleep (20); + continue; + } + + KbdBuffer[Head] = getche(); + + EnterCriticalSection(&csConsole); + if(fEventThreadBlock == TRUE){ + LeaveCriticalSection(&csConsole); + WaitForSingleObject(hConsoleWait,-1); + ResetEvent(hConsoleWait); + continue; + } + else{ + LeaveCriticalSection(&csConsole); + } + + EnterCriticalSection(&csKbd); + Head = Temp; + LeaveCriticalSection(&csKbd); + SetEvent(KbdSyncEvent); + } +} + +BOOL tkbhit(VOID) +{ + + if (Tail != Head || nCtrlc) + return TRUE; + return FALSE; +} + + +CHAR tgetch(VOID) +{ +CHAR ch; + + while(TRUE) { + EnterCriticalSection(&csCtrlc); + if (nCtrlc){ + nCtrlc--; + LeaveCriticalSection(&csCtrlc); + return (CHAR)0x3; // return ctrlc + } + LeaveCriticalSection(&csCtrlc); + + if (Tail != Head) { + EnterCriticalSection(&csKbd); + ch = KbdBuffer[Tail++]; + if (Tail >= MAX_KBD_BUFFER) + Tail = 0; + LeaveCriticalSection(&csKbd); + return ch; + } + WaitForSingleObject(KbdSyncEvent, -1); + ResetEvent(KbdSyncEvent); + } +} + + + + +VOID BiosKbd() +{ + static ULONG ulch; + DWORD nRead=0; + + switch(getAH()) { + + case KBDFUNC_READCHAR: + if (ulch) { + setAL(ulch & 0xff); + setAH(ulch & 0xFF00); + ulch = 0; + } + else { + setAH(0); // zero scan code field for now + setAL((BYTE)tgetch()); + if (getAL() == 0 || getAL() == 0xE0) { + setAL(0); + setAH((BYTE)tgetch()); + } + } + break; + + case KBDFUNC_PEEKCHAR: + setZF(1); + if (ulch) { + setAL(ulch & 0xFF); + setAH(ulch & 0xFF00); + setZF(0); + } + else if(tkbhit()) { + setAH(0); // zero scan code field for now + setAL((BYTE)tgetch()); + if (getAL() == 0 || getAL() == 0xE0) { + setAL(0); + setAH((BYTE)tgetch()); + } + ulch = getAL() | getAH()<<8 | 0x10000; + setZF(0); + } + break; + } +} + + +void nt_block_event_thread(void) +{ + INPUT_RECORD InputRecord; + DWORD nRecordsWritten; + + InputRecord.EventType = 1; + InputRecord.Event.KeyEvent.bKeyDown = 1; + InputRecord.Event.KeyEvent.wRepeatCount = 1; + InputRecord.Event.KeyEvent.wVirtualKeyCode = 32; + InputRecord.Event.KeyEvent.wVirtualScanCode = 41; + InputRecord.Event.KeyEvent.uChar.AsciiChar = ' '; + InputRecord.Event.KeyEvent.dwControlKeyState = 32; + EnterCriticalSection(&csConsole); + WriteConsoleInput(InputHandle,&InputRecord,1,&nRecordsWritten); + InputRecord.EventType = 1; + InputRecord.Event.KeyEvent.bKeyDown = 0; + InputRecord.Event.KeyEvent.wRepeatCount = 1; + InputRecord.Event.KeyEvent.wVirtualKeyCode = 32; + InputRecord.Event.KeyEvent.wVirtualScanCode = 41; + InputRecord.Event.KeyEvent.uChar.AsciiChar = ' '; + InputRecord.Event.KeyEvent.dwControlKeyState = 32; + WriteConsoleInput(InputHandle,&InputRecord,1,&nRecordsWritten); + fEventThreadBlock = TRUE; + LeaveCriticalSection(&csConsole); + return; + +} + +void nt_resume_event_thread(void) +{ + fEventThreadBlock = FALSE; + SetEvent (hConsoleWait); + return; +} + +// TEMP Till we have proper multitasking in WOW +extern BOOL VDMForWOW; +extern ULONG iWOWTaskId; + + +VOID VDMCtrlCHandler(ULONG ulCtrlType) +{ +// DebugBreak(); + if(ulCtrlType == SYSTEM_ROOT_CONSOLE_EVENT) { + if(VDMForWOW) + // Kill everything for WOW VDM + ExitVDM(VDMForWOW,(ULONG)-1); + else + ExitVDM(FALSE,0); + ExitProcess(0); + return; + } + EnterCriticalSection(&csCtrlc); + nCtrlc++; + LeaveCriticalSection(&csCtrlc); + SetEvent(KbdSyncEvent); +} diff --git a/private/mvdm/v86/scaffold/i386/fakevid.c b/private/mvdm/v86/scaffold/i386/fakevid.c new file mode 100644 index 000000000..450737c80 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/fakevid.c @@ -0,0 +1,175 @@ + +// +// Fake video rom support +// +// This file provides interrim support for video rom bios services. +// It is only intended for use until Insignia produces proper rom support +// for NTVDM +// +// Note: portions of this code were lifted from the following source. + + +/* x86 v1.0 + * + * XBIOSVID.C + * Guest ROM BIOS video emulation + * + * History + * Created 20-Oct-90 by Jeff Parsons + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + +#include <windows.h> +#include <stdio.h> +#include <string.h> +#include <conio.h> +#include "softpc.h" +#include "bop.h" +#include "xbios.h" +#include "xbiosvid.h" +#include "xwincon.h" +#include "fun.h" +#include "cmdsvc.h" + +static BYTE ServiceRoutine[] = { 0xC4, 0xC4, BOP_VIDEO, 0x50, 0x55, 0x8B, + 0xEC, 0x9C, 0x58, 0x89, 0x46, 0x08, 0x5d, 0x58, 0xCF }; +#define SERVICE_LENGTH sizeof(ServiceRoutine) + +extern HANDLE OutputHandle; +extern HANDLE InputHandle; + +/* BiosVidInit - Initialize ROM BIOS video support + * + * ENTRY + * argc - # of command-line options + * argv - pointer to first option pointer + * ServicAddress - pointer to linear address to put interrupt service + * routine at + * + * EXIT + * TRUE if successful, FALSE if not + */ + +BOOL BiosVidInit(int argc, char *argv[], PVOID *ServiceAddress) +{ + USHORT usEquip; + + static BYTE abVidInit[] = {VIDMODE_MONO, // VIDDATA_CRT_MODE + 0x80, 0, // VIDDATA_CRT_COLS + 00, 0x10, // VIDDATA_CRT_LEN + 0, 0, // VIDDATA_CRT_START + 0,0,0,0,0,0,0,0, // VIDDATA_CURSOR_POSN + 0,0,0,0,0,0,0,0, // + 7, 6, // VIDDATA_CURSOR_MODE + 0, // VIDDATA_ACTIVE_PAGE + 0xD4, 0x03, // VIDDATA_ADDR_6845 + 0, // VIDDATA_CRT_MODE_SET + 0, // VIDDATA_CRT_PALETTE + }; + PVOID Address; + + argv, argc; + memcpy(*ServiceAddress, ServiceRoutine, SERVICE_LENGTH); + + Address = (PVOID)(BIOSINT_VID * 4); + *((PWORD)Address) = RMOFF(*ServiceAddress); + *(((PWORD)Address) + 1) = RMSEG(*ServiceAddress); + (PCHAR)*ServiceAddress += SERVICE_LENGTH; + + usEquip = *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_EQUIP_FLAG); + usEquip |= BIOSEQUIP_MONOVIDEO; + *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_EQUIP_FLAG) = usEquip; + + // Initialize ROM BIOS video data to defaults + Address = RMSEGOFFTOLIN(BIOSDATA_SEG, VIDDATA_CRT_MODE); + memcpy(Address, abVidInit, sizeof(abVidInit)); + +#if 0 +#ifdef WIN + clearconsole(hwndGuest); +#endif +#endif + return TRUE; +} + + +/* BiosVid - Emulate ROM BIOS video functions + * + * ENTRY + * None (x86 registers contain parameters) + * + * EXIT + * None (x86 registers/memory updated appropriately) + * + * This function receives control on INT 10h, routes control to the + * appropriate subfunction based on the function # in AH, and + * then simulates an IRET and returns back to the instruction emulator. + */ + +VOID BiosVid() +{ +COORD coord; +CHAR ch; + + if (fEnableInt10 == FALSE) + return; + + switch(getAH()) { + case VIDFUNC_SETCURSORPOS: + coord.X = getDL(); + coord.Y = getDH(); + if(SetConsoleCursorPosition(OutputHandle, coord) == FALSE) + VDprint( + VDP_LEVEL_WARNING, + ("SetCursorPosition Failed X=%d Y=%d\n", + coord.X,coord.Y) + ); + break; + case VIDFUNC_QUERYCURSORPOS: + VDprint( + VDP_LEVEL_WARNING, + ("Query Cursor Position Not Yet Implemented\n") + ); + break; + case VIDFUNC_SCROLLUP: + VDprint( + VDP_LEVEL_WARNING, + ("ScrollUp Not Yet Implemented\n") + ); + break; + case VIDFUNC_WRITECHARATTR: + VDprint( + VDP_LEVEL_WARNING, + ("WRITECHARATTR Not Yet Implemented\n") + ); + break; + case VIDFUNC_WRITETTY: + ch = getAL(); + putch(ch); + break; + + case VIDFUNC_QUERYMODE: + setAX(*(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, VIDDATA_CRT_MODE)); + setBX(*(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, VIDDATA_ACTIVE_PAGE)); + break; + + default: + VDprint( + VDP_LEVEL_WARNING, + ("SoftPC Video Support: Unimplemented function %x\n", + getAX()) + ); + } +} + + +INT tputch(INT i) +{ + putch((CHAR)i); + return i; +} diff --git a/private/mvdm/v86/scaffold/i386/fun.h b/private/mvdm/v86/scaffold/i386/fun.h new file mode 100644 index 000000000..d83a72a0c --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/fun.h @@ -0,0 +1,24 @@ +// +// function definitions for scaffolding code +// + +VOID BiosInit(int argc, char *argv[]); +BOOL WinInit(); +VOID DbgPrint(); +VOID DbgBreakPoint(); +BOOL W32Init(); +VOID main(); +VOID exit(); +BOOL BiosKbdInit(int argc, char *argv[], PVOID *ServiceAddress); +BOOL BiosDskInit(int argc, char *argv[], PVOID *ServiceAddress); +BOOL BiosVidInit(int argc, char *argv[], PVOID *ServiceAddress); +VOID W32Dispatch(); +VOID XMSDispatch(); +VOID BiosVid(); +VOID BiosKbd(); +VOID BiosDsk(); +VOID BiosKbdReadLoop (VOID); +BOOL tkbhit(VOID); +CHAR tgetch(VOID); +INT tputch(INT); +VOID FixConfigFile (PSZ,BOOL); diff --git a/private/mvdm/v86/scaffold/i386/softpc.c b/private/mvdm/v86/scaffold/i386/softpc.c new file mode 100644 index 000000000..b97ee53a9 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/softpc.c @@ -0,0 +1,442 @@ +#include <windows.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <malloc.h> +#include <ctype.h> +#include "demexp.h" +#include "softpc.h" +#include <cmdsvc.h> +#include <xmssvc.h> +#include <dbgexp.h> +#include "xwincon.h" +#include "fun.h" +#include <conapi.h> + +#define VDM_VIRTUAL_INTERRUPTS 0x00000200L +extern CONTEXT IntelRegisters; + +VOID DumpIntelRegs(); +VOID ParseSwitches( int, char**); +VOID usage(); +BOOL ConInit (VOID); +extern VOID VDMCtrlCHandler(ULONG); + +INT flOptions; + +HANDLE OutputHandle; +HANDLE InputHandle; +HANDLE SCSCreateEvent; +char *EmDirectory; +BOOL scaffMin = FALSE; +BOOL scaffWow = FALSE; +BOOL VDMForWOW = FALSE; +CHAR BootLetter; + + +void main (argc, argv) +int argc; +char *argv[]; +{ + + PSZ psz,pszNULL; + HANDLE hfile; + DWORD BytesRead; + int i; + PCHAR FileAddress; + BOOL IsFirst; + int temp_argc = argc; + char **temp_argv = argv; + +// DebugBreak(); + + if(SetConsoleCtrlHandler((PHANDLER_ROUTINE)VDMCtrlCHandler,TRUE) + == FALSE) { + VDprint( + VDP_LEVEL_INFO, + ("CtrlC Handler Could'nt be installed\n") + ); + } + + // Tell the console that we want the last event (i.e when the + // window is just to be destroyed. + SetLastConsoleEventActive(); + + // Check if the VDM Is for WOW + while (--temp_argc > 0) { + psz = *++temp_argv; + if (*psz == '-' || *psz == '/') { + psz++; + if(tolower(*psz) == 'w'){ + VDMForWOW = TRUE; + break; + } + } + } + + // This following API is required for recovery purposes. This + // tells the basesrv that VDM has hooked ctrlc event. After + // this it will always get the termination notification. If + // the window is killed before we hook ctrl-c then basesrv + // will know that data structures for this VDM has to be + // freed. This should be the first call to base.dll. + + VDMOperationStarted (VDMForWOW); + + EmDirectory = NULL; + + // Hide the cmd window of WOWVDM + if(VDMForWOW) + VDMConsoleOperation((DWORD)VDM_HIDE_WINDOW); + + ParseSwitches( argc, argv ); + + IsFirst = GetNextVDMCommand(NULL); + + for (i = 0; i < argc; i++) { + VDprint( + VDP_LEVEL_INFO, + ("%s\n", argv[i]) + ); + } + + VDbreak(VDB_LEVEL_INFO); + + if (EmDirectory == NULL) { + usage(); + TerminateVDM(); + } + + // Sudeepb 26-Dec-1991 Temporary code to make + // the life easy for WOW's internal users such that they dont have + // to change the config.sys as per their setup. + + FixConfigFile (EmDirectory,IsFirst); + + pszNULL = strchr(EmDirectory,'\0'); + psz = EmDirectory; + while(*psz == ' ' || *psz == '\t') + psz++; + + BootLetter = *psz; + + host_cpu_init(); + sas_init(1024L * 1024L + 64L * 1024L); + + // Initialize ROM support + + BiosInit(argc, argv); + + // Initialize console support + + if (!ConInit()) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing console\n") + ); + TerminateVDM(); + } + + // Initialize WOW + + + CMDInit (argc,argv); + + // Initialize DOSEm + + if(!DemInit (argc,argv,EmDirectory)) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing DOSEm\n") + ); + TerminateVDM(); + } + + // Initialize XMS + + if(!XMSInit (argc,argv)) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing XMS\n") + ); + TerminateVDM(); + } + + // Initialize DBG + + if(!DBGInit (argc,argv)) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: error initializing DBG\n") + ); + TerminateVDM(); + } + + // Prepare to load ntio.sys + strcat (EmDirectory,"\\ntio.sys"); + hfile = CreateFile(EmDirectory, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL ); + + if (hfile == (HANDLE)0xffffffff) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: could not open file %s. Error %d\n", + EmDirectory, + GetLastError()) + ); + TerminateVDM(); + } + + FileAddress = (PCHAR)0x700; + BytesRead = 1; + while (BytesRead) { + if (!ReadFile(hfile, FileAddress, 16384, &BytesRead, NULL)) { + VDprint( + VDP_LEVEL_ERROR, + ("SoftPC: read failure on file %s. Error %d\n", + EmDirectory, + GetLastError()) + ); + TerminateVDM(); + } + + VDprint(VDP_LEVEL_INFO, + ("SoftPC: read a block of file %s\n", + EmDirectory) + ); + FileAddress = (PCHAR)FileAddress + BytesRead; + } + + VDprint(VDP_LEVEL_WARNING, + ("SoftPC: using Emulation file %s\n", + EmDirectory) + ); + + VDbreak(VDB_LEVEL_INFO); + + CloseHandle (hfile); + + // restore the emulation directory + *pszNULL = 0; + + + IntelRegisters.Eip = 0x0; + IntelRegisters.SegCs = 0x70; + IntelRegisters.EFlags = VDM_VIRTUAL_INTERRUPTS; + + host_simulate(); + + if (IntelRegisters.EFlags & VDM_VIRTUAL_INTERRUPTS) { + VDprint(VDP_LEVEL_INFO, ("Virtual ints enabled\n")); + } else { + VDprint(VDP_LEVEL_INFO, ("Virtual ints disabled\n")); + } + + DumpIntelRegs(); +} + +#define MAX_CONFIG_SIZE 1024 + +VOID FixConfigFile (pszBin86Dir,IsFirstVDM) +PSZ pszBin86Dir; +BOOL IsFirstVDM; +{ + + // Temporary code. To be thrown out once we have full configuration + // and installation. + +CHAR ConfigFile[]="?:\\config.vdm"; +CHAR Buffer [MAX_CONFIG_SIZE]; +DWORD len,i; +DWORD BytesRead,BytesWritten; +HANDLE hfile; + + if (IsFirstVDM == FALSE) + return; + + ConfigFile[0] = *pszBin86Dir; + hfile = CreateFile( ConfigFile, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL ); + if (hfile == (HANDLE)0xffffffff) { + DbgPrint ("config.vdm is'nt found on the root drive of yout NT trre\n"); + return; + } + + + if (!ReadFile(hfile, Buffer, MAX_CONFIG_SIZE, &BytesRead, NULL)){ + DbgPrint ("config.vdm could'nt be read\n, %x\n",GetLastError ()); + CloseHandle (hfile); + return; + } + + if (BytesRead == MAX_CONFIG_SIZE) { + DbgPrint ("config.vdm is too big, could'nt perform macro substitution\n"); + CloseHandle (hfile); + return; + } + + SetFilePointer (hfile, + 0, + NULL, + FILE_BEGIN); + + len = strlen (pszBin86Dir); + + for (i=0; i < BytesRead; i++) { + if (Buffer [i] != '@'){ + WriteFile (hfile, + &Buffer[i], + 1, + &BytesWritten, + NULL); + } + else { + WriteFile (hfile, + pszBin86Dir, + len, + &BytesWritten, + NULL); + } + } + + CloseHandle (hfile); + return; +} + +VOID DumpIntelRegs() +{ + + VDprint(VDP_LEVEL_ERROR,("EAX = %lx\n",IntelRegisters.Eax)); + VDprint(VDP_LEVEL_ERROR,("Ebx = %lx\n",IntelRegisters.Ebx)); + VDprint(VDP_LEVEL_ERROR,("Ecx = %lx\n",IntelRegisters.Ecx)); + VDprint(VDP_LEVEL_ERROR,("Edx = %lx\n",IntelRegisters.Edx)); + VDprint(VDP_LEVEL_ERROR,("Esi = %lx\n",IntelRegisters.Esi)); + VDprint(VDP_LEVEL_ERROR,("Edi = %lx\n",IntelRegisters.Edi)); + VDprint(VDP_LEVEL_ERROR,("Ebp = %lx\n",IntelRegisters.Ebp)); + VDprint(VDP_LEVEL_ERROR,("SegDs = %lx\n",IntelRegisters.SegDs)); + VDprint(VDP_LEVEL_ERROR,("SegEs = %lx\n",IntelRegisters.SegEs)); + VDprint(VDP_LEVEL_ERROR,("SegFs = %lx\n",IntelRegisters.SegFs)); + VDprint(VDP_LEVEL_ERROR,("SegGs = %lx\n",IntelRegisters.SegGs)); + VDprint(VDP_LEVEL_ERROR,("EFlags = %lx\n",IntelRegisters.EFlags)); + VDprint(VDP_LEVEL_ERROR,("SS:Esp = %lx:",IntelRegisters.SegSs)); + VDprint(VDP_LEVEL_ERROR,("%lx\n",IntelRegisters.Esp)); + VDprint(VDP_LEVEL_ERROR,("CS:Eip = %lx:",IntelRegisters.SegCs)); + VDprint(VDP_LEVEL_ERROR,("%lx\n",IntelRegisters.Eip)); +} + +VOID ParseSwitches( + int argc, + char **argv + ) +{ + int i; + + for (i = 1; i < argc; i++){ + if ((argv[i][0] == '-') || (argv[i][0] == '/')) { + + switch (argv[i][1]) { + + case 's' : + case 'S' : + sscanf(&argv[i][2], "%x", &VdmDebugLevel); + VDprint( + VDP_LEVEL_WARNING, + ("VdmDebugLevel = %x\n", + VdmDebugLevel) + ); + break; + + case 'f' : + case 'F' : + // Note this memory is freed by DEM. + if((EmDirectory = (PCHAR)malloc (strlen (&argv[i][2]) + + 1 + + sizeof("\\ntdos.sys") + + 1 + )) == NULL){ + DbgPrint("SoftPC: Not Enough Memory \n"); + TerminateVDM(); + } + strcpy(EmDirectory,&argv[i][2]); + break; + + case 't' : + case 'T' : + flOptions |= OPT_TERMINAL; + break; + case 'm' : + case 'M' : + scaffMin = TRUE; + break; + case 'w' : + case 'W' : + scaffWow = TRUE; + } + } else { + break; + } + } +} + +VOID usage() +{ + DbgPrint("SoftPC Usage: softpc -F<emulation file> [-D#] [<drive>:=<virtual disk>] [dos command line]\n"); +} + + +VOID TerminateVDM(void) +{ + + if(VDMForWOW) + // Kill everything for WOW VDM + ExitVDM(VDMForWOW,(ULONG)-1); + else + ExitVDM(FALSE,0); + ExitProcess (0); +} + + +DWORD SCSConsoleThread(LPVOID lp) +{ + + + SetEvent(SCSCreateEvent); + BiosKbdReadLoop(); + return TRUE; +} + + +BOOL ConInit (VOID) +{ + DWORD SCSThreadId; + HANDLE InputThread; + OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE); + InputHandle = GetStdHandle(STD_INPUT_HANDLE); + + SCSCreateEvent = CreateEvent( NULL, TRUE, FALSE,NULL ); + + InputThread = CreateThread( + (LPSECURITY_ATTRIBUTES)0, + 8192, + (LPTHREAD_START_ROUTINE)SCSConsoleThread, + (LPVOID)0, + STANDARD_RIGHTS_REQUIRED, + &SCSThreadId + ); + + WaitForSingleObject(SCSCreateEvent, -1); + + CloseHandle(SCSCreateEvent); + + return TRUE; +} diff --git a/private/mvdm/v86/scaffold/i386/sources b/private/mvdm/v86/scaffold/i386/sources new file mode 100644 index 000000000..af03d8fa3 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/sources @@ -0,0 +1,6 @@ +i386_SOURCES=i386\softpc.c \ + i386\fakeinit.c \ + i386\fakekbd.c \ + i386\fakevid.c \ + i386\fakebop.c \ + i386\stubs.c diff --git a/private/mvdm/v86/scaffold/i386/stubs.c b/private/mvdm/v86/scaffold/i386/stubs.c new file mode 100644 index 000000000..4ba53b52e --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/stubs.c @@ -0,0 +1,46 @@ +void check_I(){ +} + +void copyROM(){ +} + +void generic_insb(){ +} +void generic_insw(){ +} +void generic_outsb(){ +} +void generic_outsw(){ +} + +void host_timer_event(){ +} +int ica_intack(){ + return 7; +} +void inb(){ +} +void inw(){ +} +void outb(){ +} +void outw(){ +} +unsigned long *read_pointers; + +void rom_checksum(){ +} + +void rom_init(){ +} + + +host_simulate(){ + cpu_simulate(); +} + +host_cpu_init(){ + cpu_init(); +} + +void (*ica_hw_interrupt_func)() = rom_init; diff --git a/private/mvdm/v86/scaffold/i386/x86.h b/private/mvdm/v86/scaffold/i386/x86.h new file mode 100644 index 000000000..eb4772e82 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/x86.h @@ -0,0 +1,418 @@ +// +// This is temporary code, and should be removed when Insignia supplies rom +// support +// + +/* x86 v1.0 + * + * X86.H + * Constants, macros, and common types + * for the x86 emulator and related components + * + * History + * Created 19-Oct-90 by Jeff Parsons + * 17-Apr-91 by Dave Hastings trimmed for use in softpc (temprorary) + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + +#ifdef DOS +#define SIGNALS +#endif + +#ifdef OS2_16 +#define OS2 +#define SIGNALS +#endif + +#ifdef OS2_32 +#define OS2 +#define FLAT_32 +#endif + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <malloc.h> +#include <process.h> + +#ifdef WIN_16 +#define WIN +#define API16 +#endif + +#ifdef WIN_32 +#ifndef WIN +#define WIN +#endif +#define FLAT_32 +#define TRUE_IF_WIN32 1 +#define FIXHWND(h) ((HWND)((INT)(h) & 0x00ffffff)) +#include <nt.h> +#include <ntrtl.h> +#include <nturtl.h> +#else +#define TRUE_IF_WIN32 0 +#define FIXHWND(h) (h) +#endif + +#ifdef FLAT_32 +#ifndef i386 +#define ALIGN_32 +#else +#define NOALIGN_32 +#endif +#endif + +#ifdef WIN +#define _WINDOWS +#include <windows.h> +#endif + +#ifdef SIGNALS +#include <conio.h> +#include <signal.h> +#endif + +#ifdef OS2_32 +#include <excpt.h> +#define XCPT_SIGNAL 0xC0010003 +#endif +#define SIGHIT(flChk) ((iSigCheck++ & 0x7FF)?(flSignals & (flChk)):(kbhit(),(flSignals & (flChk)))) + +#ifndef CONST +#define CONST const +#endif +#ifndef CDECL +#define CDECL _cdecl +#endif +#ifndef PASCAL +#define PASCAL +#endif + +#ifdef FLAT_32 +#ifndef WIN +#define FAR +#endif +#define HUGE +#define HALLOC(n,s) malloc((n)*(s)) +#define HLOCK(h) h +#define HUNLOCK(h) 0 +#define HFREE(h) free(h) +#else +#ifndef WIN +#define FAR _far +#define HUGE _huge +#define HALLOC(n,s) halloc(n,s) +#define HLOCK(h) h +#define HUNLOCK(h) 0 +#define HFREE(h) hfree(h) +#else +#define HUGE _huge +#define HALLOC(n,s) GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,(n)*(s)) +#define HLOCK(h) (HPVOID)GlobalLock(h) +#define HUNLOCK(h) GlobalUnlock(h) +#define HFREE(h) GlobalFree(h) +#endif +#endif + +#define BYTEOF(i,n) (((PBYTE)&(i))[n]) +#define LOB(i) BYTEOF(i,0) +#define HIB(i) BYTEOF(i,1) +#define WORDOF(i,n) (((PWORD)&(i))[n]) +#define LOW(l) WORDOF(l,0) +#define HIW(l) WORDOF(l,1) +#define INTOF(i,n) (((PINT)&(i))[n]) +#define UINTOF(i,n) (((PUINT)&(i))[n]) +#ifndef WIN +#define LOWORD(l) ((WORD)(l)) +#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF)) +#define LOBYTE(w) ((BYTE)(w)) +#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF)) +#endif +#ifndef MAKEWORD +#define MAKEWORD(l,h) ((WORD)((BYTE)(l)|((BYTE)(h)<<8))) +#endif +#define MAKEDWORD(l0,h0,l1,h1) ((DWORD)MAKEWORD(l0,h0)|((DWORD)MAKEWORD(l1,h1)<<16)) +#define GETBYTE(p) *((PBYTE)p)++ +#define GETBYTEPTR(p) ((PBYTE)p)++ +#define GETWORDPTR(pb) ((PWORD)pb)++ +#define GETDWORDPTR(pb) ((PDWORD)pb)++ +#ifndef ALIGN_32 +#define GETWORD(pb) (*((PWORD)pb)++) +#define GETDWORD(pb) (*((PDWORD)pb)++) +#define FETCHWORD(s) ((WORD)(s)) +#define FETCHDWORD(s) ((DWORD)(s)) +#define STOREWORD(d,s) (WORD)d=(WORD)s +#define STOREDWORD(d,s) (DWORD)d=(DWORD)s +#else +#define GETWORD(pb) (pb+=2,MAKEWORD(*(pb-2),*(pb-1))) +#define GETDWORD(pb) (pb+=4,MAKEDWORD(*(pb-4),*(pb-3),*(pb-2),*(pb-1))) +#define FETCHWORD(s) MAKEWORD(LOB(s),HIB(s)) +#define FETCHDWORD(s) MAKEDWORD(BYTEOF(s,0),BYTEOF(s,1),BYTEOF(s,2),BYTEOF(s,3)) +#define STOREWORD(d,s) {BYTEOF(d,0)=LOBYTE(s);BYTEOF(d,1)=HIBYTE(s);} +#define STOREDWORD(d,s) {BYTEOF(d,0)=LOBYTE(LOWORD(s));BYTEOF(d,1)=HIBYTE(LOWORD(s));BYTEOF(d,2)=LOBYTE(HIWORD(s));BYTEOF(d,3)=HIBYTE(HIWORD(s));} +#endif +#define SWAP(x,y) {INT t; t=y; y=x; x=t;} +#define SWAPS(x,y) {SHORT t; t=y; y=x; x=t;} +#define SWAPL(x,y) {LONG t; t=y; y=x; x=t;} +#define SWAPBYTE(x,y) {BYTE t; t=y; y=x; x=t;} +#define SWAPWORD(x,y) {WORD t; t=FETCHWORD(y); STOREWORD(y,FETCHWORD(x)); STOREWORD(x,t);} +#define SWAPDWORD(x,y) {DWORD t; t=FETCHDWORD(y); STOREDWORD(y,FETCHDWORD(x)); STOREDWORD(x,t);} +#define NUMEL(a) ((sizeof a)/(sizeof a[0])) + +#define SXBYTE(i) ((LONG)(SBYTE)(i)) +#define SXWORD(i) ((LONG)(SHORT)(i)) +#define SXSHORT(i) ((LONG)(SHORT)(i)) +#define ZXBYTE(i) ((ULONG)(BYTE)(i)) +#define ZXWORD(i) ((ULONG)(USHORT)(i)) +#define ZXSHORT(i) ((ULONG)(USHORT)(i)) + +#define _Z2(m) ((m)&1?0:(m)&2?1:2) +#define _Z4(m) ((m)&3?_Z2(m):_Z2((m)>>2)+2) +#define _Z8(m) ((m)&15?_Z4(m):_Z4((m)>>4)+4) +#define _Z16(m) ((m)&255?_Z8(m):_Z8((m)>>8)+8) +#define _Z32(m) ((m)&65535?_Z16(m):_Z16((m)>>16)+16) +#define SHIFTLEFT(i,m) (((i)<<_Z32(m))&(m)) +#define SHIFTRIGHT(i,m) (((i)&(m))>>_Z32(m)) + +#define OFFSETOF(t,f) ((INT)&(((t *)0)->f)) + + +/* Universal constants + */ +#define K 1024L +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif +#ifndef NULL +#define NULL 0 +#endif +#define UNDEFINED -1 + +#define CTRL_A 1 // used by gets to repeat last line +#define CTRL_C 3 // break in debug window +#define CTRL_Q 17 // flow control +#define CTRL_S 19 // flow control +#define BELL 7 // +#define BS 8 // backspace +#define TAB 9 // +#define LF 10 // linefeed +#define CR 13 // return +#define ESCAPE 27 // + + +/* Program options + */ +#define OPT_FONT 0x0004 // use small OEM font if available (/s) +#define OPT_DOUBLE 0x0020 // use 50-line debug window w/small font (/50) +#define OPT_CAPS 0x0002 // map ctrl keys to caps-lock (/c) +#define OPT_TERMINAL 0x0010 // redirect all window output to terminal (/t) +#define OPT_FLUSH 0x0100 // flush prefetch after every jump (/f) +#define OPT_NOXLATE 0x0200 // disable built-in translations (/n) +#define OPT_DEBUG 0x0008 // shadow all log output on debug terminal (/d) +#define OPT_GO 0x0001 // do an initial "go" (/g) + + +/* Signal flags + */ +#define SIGNAL_BREAK 0x0001 // set whenever break has occurred +#define SIGNAL_UNWIND 0x0002 // set whenever unwind has occurred +#define SIGNAL_REBOOT 0x0004 // set whenever reboot has occurred +#define SIGNAL_RUN 0x0008 // set whenever emulator is "running" +#define SIGNAL_TRACE 0x0010 // set whenever debugger tracing +#define SIGNAL_BRKPT 0x0020 // set whenever debugger breakpoints enabled +#define SIGNAL_SSTEP 0x0040 // set whenever emulator single-step on + +#undef SIG_IGN // fix broken definition in (old) signal.h +#define SIG_IGN (VOID (CDECL *)())1 + + +/* Exec flags (for HostInput/GuestInput) + */ +#define EXEC_INPUT 0x0000 // wait for input +#define EXEC_GO 0x0001 // execute immediately +#define EXEC_FREEZE 0x0002 // execution frozen (guest only) + + +/* Standard types + */ +#ifndef WIN +typedef void VOID; +typedef unsigned char BYTE; +typedef unsigned short WORD; // confusing - use where 16-bit req. only +typedef unsigned long DWORD; // confusing - use where 32-bit req. only +typedef long LONG; // use where 32-bit req. only +typedef int BOOL; +#endif +typedef char CHAR; +typedef signed char SBYTE; +typedef short SHORT; // use where 16-bit req. only +typedef unsigned short USHORT; // use where 16-bit req. only +typedef int INT; // ints preferred +typedef unsigned int UINT; // ints preferred +typedef unsigned long ULONG; // use where 32-bit req. only + +#ifndef WIN +typedef BYTE *PBYTE; // native pointers +typedef WORD *PWORD; +typedef DWORD *PDWORD; +typedef INT *PINT; +typedef LONG *PLONG; +typedef CHAR *PSTR; +#endif +typedef PBYTE *PPBYTE; +typedef PWORD *PPWORD; +typedef PDWORD *PPDWORD; +typedef CHAR SZ[]; +typedef VOID *PVOID; +typedef CHAR *PCHAR; +typedef SHORT *PSHORT; +typedef USHORT *PUSHORT; +typedef PUSHORT *PPUSHORT; +typedef UINT *PUINT; +typedef ULONG *PULONG; +typedef PULONG *PPULONG; +typedef BOOL *PBOOL; +typedef CHAR *PSZ; +typedef PSZ *PPSZ; + +typedef VOID FAR *FPVOID; // "far" (or "long" in Windows) pointers +typedef CHAR FAR *FPCHAR; +typedef BYTE FAR *FPBYTE; +typedef SHORT FAR *FPSHORT; +typedef USHORT FAR *FPUSHORT; +typedef LONG FAR *FPLONG; +typedef ULONG FAR *FPULONG; +typedef CHAR FAR *FPSTR; +typedef CHAR FAR *FPSZ; + +typedef VOID HUGE *HPVOID; // "huge" pointers +typedef CHAR HUGE *HPCHAR; +typedef BYTE HUGE *HPBYTE; +typedef SHORT HUGE *HPSHORT; +typedef USHORT HUGE *HPUSHORT; +typedef LONG HUGE *HPLONG; +typedef ULONG HUGE *HPULONG; +typedef CHAR HUGE *HPSTR; +typedef CHAR HUGE *HPSZ; + +#ifndef WIN +typedef HPVOID HANDLE; +#endif + +#ifdef WIN +typedef INT (FAR PASCAL *INTPROC)(HWND, UINT, UINT, LONG); +#endif +#ifdef WIN_16 +typedef LONG (FAR PASCAL *WNDPROC)(HWND, WORD, UINT, LONG); +#endif + + +/* Global data + */ +extern FILE *hfLog; +extern INT flOptions; // command-line options (see OPT_*) +extern INT flSignals; // signal flags (see SIGNAL_*) +extern INT iSigCheck; // counter indicating when to make next check +extern INT iSigLevel; // counter indicating whether to take default action +extern INT iLogLevel; // logging level; 0 implies none +extern BOOL fReinit; // set once first initialization has completed + + +/* String macros + */ +#define STRSKIP(psz,sz) psz += strspn(psz, sz) +#define STRSKIPTO(psz,sz) psz += strcspn(psz, sz) +#define STRSKIPNEXT(psz,sz) psz += strspn(psz+=strcspn(psz, sz), sz) + +#define ATOI(psz) (INT)szTOul(psz, 10, -1) + + +/* Logging macros + */ +#define IFLOG(l) if (l==iLogLevel && (iLogLevel&1) || l<=iLogLevel && !(iLogLevel&1)) + +#define OPENLOG() (hfLog?hfLog:(hfLog=fopen("log", "w"))) +#define APPENDLOG() (hfLog?hfLog:(hfLog=fopen("log", "a"))) +#define CLOSELOG() if (hfLog) {fclose(hfLog); hfLog=NULL;} + +#ifdef NOLOG +#define LOG(l,args) +#else +#define LOG(l,args) IFLOG(l) logprintf args; else +#endif + + +/* Debugging macros + */ +#define MODNAME(module) static char szModule[] = __FILE__ +#define X86ERROR() terminate(ERR_ASSERT, szModule, __LINE__) + +#ifdef DEBUG + +#define STATIC +#define INT3() _asm int 3 +#define IFDEBUG(f) if (f) +#define ELSEDEBUG else +#define LOGDEBUG(l,args) LOG(l,args) +#define X86ASSERT(exp) if (!(exp)) X86ERROR() + +#else + +#define STATIC static +#define INT3() +#define IFDEBUG(f) +#define ELSEDEBUG +#define LOGDEBUG(l,args) +#define X86ASSERT(exp) + +#endif // DEBUG + + +/* Other common local include files + */ +#ifdef X86 +#include "xerr.h" +#include "xlib.h" +#endif + + +/* Windows goop + */ +#define SZ_APP "x86" +#define SZ_TITLE "x86 emulator v0.17" +#define SZ_AUTHOR "by Jeff Parsons, (C) 1991" +#define SZ_PCTITLE "x86 pc" + +#define IDM_DBBRK 100 +#define IDM_ABOUT 101 + +/* Standard color definitions + */ +#define CLR_BLACK 0x00000000 +#define CLR_RED 0x007F0000 +#define CLR_GREEN 0x00007F00 +#define CLR_BROWN 0x007F7F00 +#define CLR_BLUE 0x0000007F +#define CLR_MAGENTA 0x007F007F +#define CLR_CYAN 0x00007F7F +#define CLR_LT_GRAY 0x00BFBFBF + +#define CLR_DK_GRAY 0x007F7F7F +#define CLR_BR_RED 0x00FF0000 +#define CLR_BR_GREEN 0x0000FF00 +#define CLR_YELLOW 0x00FFFF00 +#define CLR_BR_BLUE 0x000000FF +#define CLR_BR_MAGENTA 0x00FF00FF +#define CLR_BR_CYAN 0x0000FFFF +#define CLR_WHITE 0x00FFFFFF + + +extern HANDLE hHostInstance; diff --git a/private/mvdm/v86/scaffold/i386/xbios.h b/private/mvdm/v86/scaffold/i386/xbios.h new file mode 100644 index 000000000..253f6e1e3 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/xbios.h @@ -0,0 +1,123 @@ +// +// This code is temporary. When Insignia supplies rom support, it should +// be removed. +// + +/* x86 v1.0 + * + * XBIOS.H + * Guest ROM BIOS support + * + * History + * Created 20-Oct-90 by Jeff Parsons + * 17-Apr-91 Trimmed by Dave Hastings for use in temp. softpc + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + + +/* BIOS interrupts + */ +#define BIOSINT_DIVZERO 0x00 // +#define BIOSINT_SSTEP 0x01 // +#define BIOSINT_NMI 0x02 // for parity errors, too +#define BIOSINT_BRKPT 0x03 // +#define BIOSINT_OVFL 0x04 // +#define BIOSINT_PRTSC 0x05 // +#define BIOSINT_TMRINT 0x08 // +#define BIOSINT_KBDINT 0x09 // +#define BIOSINT_COM2INT 0x0B // +#define BIOSINT_COM1INT 0x0C // +#define BIOSINT_LPT2INT 0x0D // +#define BIOSINT_FLPYINT 0x0E // +#define BIOSINT_LPT1INT 0x0F // +#define BIOSINT_VID 0x10 // +#define BIOSINT_EQUIP 0x11 // +#define BIOSINT_MEMORY 0x12 // +#define BIOSINT_DSK 0x13 // +#define BIOSINT_COM 0x14 // +#define BIOSINT_OSHOOK 0x15 // +#define BIOSINT_KBD 0x16 // +#define BIOSINT_PRT 0x17 // +#define BIOSINT_BASIC 0x18 // +#define BIOSINT_WBOOT 0x19 // +#define BIOSINT_TIME 0x1A // +#define BIOSINT_CTRLBRK 0x1B // +#define BIOSINT_TICK 0x1C // +#define BIOSINT_VIDPARMS 0x1D // +#define BIOSINT_FDSKPARMS 0x1E // +#define BIOSINT_VIDGRAPH 0x1F // +#define BIOSINT_OLDDISKIO 0x40 // +#define BIOSINT_HDSK1PARMS 0x41 // +#define BIOSINT_OLDVID 0x42 // +#define BIOSINT_EXTVIDGRAPH 0x43 // +#define BIOSINT_HDSK2PARMS 0x46 // + + +/* BIOS Data Area locations + * + * So that all low-memory references are relative to the same segment + * (ie, 0), we use 0:400 instead of 40:0 as the base address of this area. + * + * Note that as more individual BIOS modules are created (eg, xbiosvid, + * xbiosdsk, etc), many of these BIOS data definitions should be moved to the + * appropriate individual header file. + */ +#define BIOSDATA_SEG 0 + +#define BIOSDATA_BEGIN 0x400 +#define BIOSDATA_RS232_BASE 0x400 // 4 COM adapter addresses +#define BIOSDATA_PRINTER_BASE 0x408 // 4 LPT adapter addresses +#define BIOSDATA_EQUIP_FLAG 0x410 // equipment flag (1 word) + +#define BIOSEQUIP_FLOPPY 0x0001 // machine has a floppy +#define BIOSEQUIP_X87 0x0002 // X87=1 if coprocessor installed +#define BIOSEQUIP_16KPLANAR 0x0000 // +#define BIOSEQUIP_32KPLANAR 0x0004 // +#define BIOSEQUIP_48KPLANAR 0x0008 // +#define BIOSEQUIP_64KPLANAR 0x000C // +#define BIOSEQUIP_PLANARMASK 0x000C // +#define BIOSEQUIP_VIDEOMASK 0x0030 // video configuration bits +#define BIOSEQUIP_COLOR40VIDEO 0x0010 // +#define BIOSEQUIP_COLOR80VIDEO 0x0020 // +#define BIOSEQUIP_MONOVIDEO 0x0030 // +#define BIOSEQUIP_FLOPPYMASK 0x00C0 // # floppies-1 (if FLOPPY=1) +#define BIOSEQUIP_COMMASK 0x0E00 // # COM ports +#define BIOSEQUIP_PRINTERMASK 0xC000 // # LPT ports + +#define BIOSDATA_MFG_TST 0x412 // initialization flag (1 byte) +#define BIOSDATA_MEMORY_SIZE 0x413 // memory size in K bytes (1 word) +#define BIOSDATA_MFG_ERR_FLG 0x415 // mfg error codes (2 bytes) + +#define BIOSDATA_END 0x4FF + +#define BIOSDATA_BOOT 0x7C00 + + +/* BIOS ROM locations (assumed segment BIOSROM_SEG) + */ +#define BIOSROM_SEG 0xF000 + +#define BIOSROM_WBOOT 0xE6F2 +#define BIOSROM_DSK 0xEC59 +#define BIOSROM_MEMORY 0xF841 +#define BIOSROM_EQUIP 0xF84D +#define BIOSROM_IRET 0xFF53 // 1 byte IRET +#define BIOSROM_RESET 0xFFF0 // 5 byte jmp +#define BIOSROM_DATE 0xFFF5 // 8 byte date (eg, 04/24/81) +#define BIOSROM_UNUSED1 0xFFFD +#define BIOSROM_SIG 0xFFFE // PC ID byte +#define BIOSROM_GBP 0xFFFF // location of GBP opcode (non-standard) + +#define BIOSSIG_PC 0xFF +#define BIOSSIG_XT 0xFE +#define BIOSSIG_JR 0xFD +#define BIOSSIG_AT 0xFC // and many more... + +#define BIOSDATE_MINE '0','4','/','1','7','/','9','1' + + diff --git a/private/mvdm/v86/scaffold/i386/xbiosdsk.h b/private/mvdm/v86/scaffold/i386/xbiosdsk.h new file mode 100644 index 000000000..ecfa6540b --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/xbiosdsk.h @@ -0,0 +1,244 @@ +// +// This code is temporary. When Insignia supplies rom support, it should +// be removed. +// + +/* x86 v1.0 + * + * XBIOSDSK.H + * Guest ROM BIOS disk emulation + * + * History + * Created 20-Oct-90 by Jeff Parsons + * 17-Apr-91 Trimmed by Dave Hastings for use in temp. softpc + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + + +#define MAX_FD 2 // # supported floppy drives +#define MAX_HD 2 // # supported hard disk drives +#define MAX_DRIVES (MAX_FD+MAX_HD) + +#define DRIVE_FD0 0x00 // first floppy disk drive # +#define DRIVE_FD1 0x01 // +#define DRIVE_HD0 0x80 // first hard disk drive # +#define DRIVE_HD1 0x81 // + + +/* Drive types for QUERYDRVPARMS + */ +#define DRVTYPE_360KB 1 +#define DRVTYPE_1200KB 2 +#define DRVTYPE_720KB 3 +#define DRVTYPE_1440KB 4 + + +/* BIOS disk functions + */ +#define DSKFUNC_DISKRESET 0x00 +#define DSKFUNC_DISKSTATUS 0x01 +#define DSKFUNC_READSECTORS 0x02 +#define DSKFUNC_WRITESECTORS 0x03 +#define DSKFUNC_VERIFYSECTORS 0x04 +#define DSKFUNC_FORMATTRACK 0x05 +#define DSKFUNC_QUERYDRVPARMS 0x08 +#define DSKFUNC_QUERYDASDTYPE 0x15 +#define DSKFUNC_QUERYCHANGE 0x16 +#define DSKFUNC_SETDISKTYPE 0x17 +#define DSKFUNC_SETMEDIATYPE 0x18 + + +/* BIOS disk status codes + */ +#define DSKSTAT_SUCCESS 0x00 // successful completion +#define DSKSTAT_BADCMD 0x01 // bad command +#define DSKSTAT_BADADDRMARK 0x02 // address mark not found +#define DSKSTAT_WRITEPROTECT 0x03 // write on write-protected disk +#define DSKSTAT_RECNOTFOUND 0x04 // sector not found +#define DSKSTAT_BADRESET 0x05 // reset failed (HD) +#define DSKSTAT_MEDIACHANGE 0x06 // media changed +#define DSKSTAT_INITFAIL 0x07 // parm. act. failed (HD) +#define DSKSTAT_BADDMA 0x08 // DMA overrun +#define DSKSTAT_DMABOUNDARY 0x09 // DMA across 64K boundary +#define DSKSTAT_BADSECTOR 0x0A // bad sector detected (HD) +#define DSKSTAT_BADTRACK 0x0B // bad track detected (HD) +#define DSKSTAT_BADMEDIATYPE 0x0C // unsupported track (HD) +#define DSKSTAT_BADFMTSECNUM 0x0D // bad # of sectors on format (HD) +#define DSKSTAT_ADDRMARKDET 0x0E // ctrl data addr mark detected (HD +#define DSKSTAT_DMAARBERR 0x0F // DMA arbitration error (HD) +#define DSKSTAT_BADCRCECC 0x10 // bad CRC/ECC +#define DSKSTAT_DATACORRECT 0x11 // data ECC corrected +#define DSKSTAT_BADCNTLR 0x20 // controller failure +#define DSKSTAT_BADSEEK 0x40 // seek failed +#define DSKSTAT_TIMEOUT 0x80 // time out +#define DSKSTAT_DRVNOTREADY 0xAA // drive not ready (HD) +#define DSKSTAT_UNDEFERR 0xBB // undefined error (HD) +#define DSKSTAT_WRITEFAULT 0xCC // write fault (HD) +#define DSKSTAT_STATUSERROR 0xE0 // status register error (HD) +#define DSKSTAT_SENSEFAIL 0xFF // sense operation failed (HD) + + +/* BIOS Data Area disk locations + */ +#define DSKDATA_SEEKSTATUS 0x43E // drive recal. status (1 byte) +#define DSKDATA_MOTORSTATUS 0x43F // motor status (1 byte) +#define DSKDATA_MOTORCOUNT 0x440 // time-out count for motor (1 byte) +#define DSKDATA_DISKETTESTATUS 0x441 // return code status (1 byte) +#define DSKDATA_NECSTATUS 0x442 // controller status bytes (7 bytes) + +#define DSKDATA_DISKSTATUS1 0x474 // return code status (1 byte) + + +/* Floppy Diskette Parameter Table + * (pointed by vector BIOSINT_FDSKPARMS (1Eh)) + */ +typedef struct fdp_s { + BYTE bSpecify1; // step-rate, head-unload + BYTE bSpecify2; // head-load, DMA mode + BYTE bMotorOff; // motor-off delay + BYTE bSectorSize; // bytes/sec (0=128,1=256,2=512,3=1024) + BYTE nLastSector; // (or think of it as # sectors/track) + BYTE lenGapRW; // + BYTE lenData; // + BYTE lenGapFormat; // + BYTE bFormatData; // format initialization byte + BYTE bSettle; // head settle time + BYTE bMotorOn; // motor start-up time +} FDP; +typedef FDP *PFDP; // pointer to diskette parameter table + + +/* Hard Disk Parameter Table + */ +typedef struct hdp_s { + USHORT usMaxCylinders; // maximum number of cylinders + BYTE bMaxHeads; // maximum number of heads + USHORT usReserve1; // reserved (not used) + USHORT usWritePrecompCyl; // starting write precompensation cyl. + BYTE bMaxECCDataBurstLen; // maximum ECC data burst length + BYTE bControl; // control byte + BYTE abReserve2[3]; // reserved (not used) + USHORT usLandingZone; // landing zone for head parking + BYTE bSectorsPerTrack; // number of sectors per track + BYTE bReserve3; // reserved for future use +} HDP; +typedef HDP *PHDP; // pointer to hard disk parameter table + + +/* Hard Disk Parameter Table control byte bit definitions + */ +#define HDPCTRL_DISABLERETRY 0xC0 // disable retries +#define HDPCTRL_EXCEED8HEADS 0x08 // more than 8 heads + + +/* Boot sector structures (more DOS-defined than BIOS-defined however -JTP) + */ +#define PARTITION_ACTIVE 0x80 // status values + +#define PARTITION_12BITFAT 1 // type valus +#define PARTITION_16BITFAT 4 +#define PARTITION_LARGEFAT 6 + +typedef struct mbr_s { // Master Boot Record + BYTE boot_code[0x1BE]; + BYTE partition_status; + BYTE starting_head; + USHORT starting_sec_cyl; + BYTE partition_type; + BYTE ending_head; + USHORT ending_sec_cyl; + ULONG starting_abs_sector; + ULONG total_sectors; +} MBR; +typedef MBR *PMBR; + +typedef struct bpb_s { // BIOS Parameter Block (from sysbloks.h) + BYTE boot_code[0x0B]; + USHORT bytes_per_sector; // sector size + BYTE sectors_per_cluster; // sectors per allocation unit + USHORT reserved_sectors; // number of reserved sectors + BYTE nbr_fats; // number of fats + USHORT root_entries; // number of directory entries + USHORT total_sectors; // number of sectors + BYTE media_type; // fatid byte + USHORT sectors_per_fat; // sectors in a copy of the FAT + USHORT sectors_per_track; // number of sectors per track + USHORT number_of_heads; // number of heads + ULONG hidden_sectors; // number of hidden sectors + ULONG large_total_sectors; // large total sectors + BYTE reserved[6]; // 6 reserved bytes +} BPB; +typedef BPB *PBPB; + + +/* Virtual disk mapping info + * + * VIRTDISK is the header of a virtual disk file. Following the header + * is an optional track table, and TRACKINFO is the format of each entry + * in that table. The track table is only present if the last two + * fields in the header (nsecTrack and nbSector) are zero, indicating a + * non-homogeneous disk structure. + * + * Currently, a max of 4 DRIVEMAP structures are supported. The first two + * entries are for physical drives 0 and 1 (specified in the command-line + * options as drives A: and B:), and subsequent entries are for physical + * hard drives 0x80 and up (specified as drives C: and up). Each DRIVEMAP + * describes the remapping that should occur, if any, and for virtual disk + * files, it also contains the virtual disk file header (which is read in + * during initialization). + * + * When a request comes in for one of those drives, we check the flags in + * corresponding DRIVEMAP structure. If no flags are set, no remapping + * or virtualization occurs (drive behaves normally). This is the default. + * If the drive is disabled (eg, "A:=*"), then all requests are returned + * with an error. If the drive is remapped to another physical drive (eg, + * "A:=B:") then the request is routed to the mapped drive. Finally, if + * the drive is remapped to a virtual disk file, the appropriate file I/O + * is performed. + * + * NOTE: Contrary to comments above, access to physical drives is not + * currently supported, so mapping to a virtual drive is all you can do + * right now.... (24-Nov-90 JTP) + */ + +#define VDFLAGS_WRITEPROTECT 0x01 // virtual disk is "write-protected" + +typedef struct virtdisk_s { + BYTE fbVirt; // flags + BYTE nHeads; // # heads + USHORT nCyls; // # cylinders + USHORT nsecTrack; // # sectors per track + USHORT nbSector; // # bytes per sector +} VIRTDISK; +typedef VIRTDISK *PVIRTDISK; + +typedef struct trackinfo_s { + USHORT nsecTrack; // # sectors per track + USHORT nbSector; // # bytes per sector + ULONG offVirtDisk; // offset within virtual disk file +} TRACKINFO; +typedef TRACKINFO *PTRACKINFO; + +#define DMFLAGS_VIRTUAL 0x01 // physical remapped to virtual +#define DMFLAGS_DISABLED 0x02 // physical remapped to disabled +#define DMFLAGS_PHYSICAL 0x04 // physical remapped to physical +#define DMFLAGS_LOGICAL 0x08 // physical remapped to logical + +typedef struct drivemap_s { + BYTE fbMap; // flags + BYTE iPhysical; // # of remapped drive, if any + FILE *hfVirtDisk; // handle to virtual disk, if any + VIRTDISK vdInfo; // virtual disk info, if any + #ifdef LOGICAL_DRIVE_SUPPORT + ULONG nsecHidden; // from BPB, if any (logical disks only) + BYTE type; // disk type, if any (logical disks only) + #endif +} DRIVEMAP; +typedef DRIVEMAP *PDRIVEMAP; + + diff --git a/private/mvdm/v86/scaffold/i386/xbioskbd.h b/private/mvdm/v86/scaffold/i386/xbioskbd.h new file mode 100644 index 000000000..d416b4069 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/xbioskbd.h @@ -0,0 +1,39 @@ +// +// This code is temporary. When Insignia supplies rom support, it should +// be removed. +// + +/* x86 v1.0 + * + * XBIOSKBD.H + * Guest ROM BIOS keyboard emulation + * + * History + * Created 20-Oct-90 by Jeff Parsons + * 17-Apr-91 Trimmed by Dave Hastings for use in temp. softpc + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + + +/* BIOS keyboard functions + */ +#define KBDFUNC_READCHAR 0x00 +#define KBDFUNC_PEEKCHAR 0x01 +#define KBDFUNC_QUERYSHIFT 0x02 +#define KBDFUNC_SETDELAYS 0x03 +#define KBDFUNC_WRITECHAR 0x05 +#define KBDFUNC_READEXTCHAR 0x10 +#define KBDFUNC_PEEKEXTCHAR 0x11 +#define KBDFUNC_QUERYEXTSHIFT 0x12 + + +/* BIOS Data Area keyboard locations + */ +#define KBDDATA_KBDSHIFT 0x417 + + diff --git a/private/mvdm/v86/scaffold/i386/xbiosvid.h b/private/mvdm/v86/scaffold/i386/xbiosvid.h new file mode 100644 index 000000000..8a8a64ddb --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/xbiosvid.h @@ -0,0 +1,65 @@ +// +// This code is temporary. When Insignia supplies rom support, it should +// be removed. +// + +/* x86 v1.0 + * + * XBIOSVID.H + * Guest ROM BIOS video emulation + * + * History + * Created 20-Oct-90 by Jeff Parsons + * 17-Apr-91 Trimmed by Dave Hastings for use in temp. softpc + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + + +/* BIOS video functions + */ +#define VIDFUNC_SETMODE 0x00 +#define VIDFUNC_SETCURSORTYPE 0x01 +#define VIDFUNC_SETCURSORPOS 0x02 +#define VIDFUNC_QUERYCURSORPOS 0x03 +#define VIDFUNC_QUERYLPEN 0x04 +#define VIDFUNC_SETACTIVEPAGE 0x05 +#define VIDFUNC_SCROLLUP 0x06 +#define VIDFUNC_SCROLLDOWN 0x07 +#define VIDFUNC_READCHARATTR 0x08 +#define VIDFUNC_WRITECHARATTR 0x09 +#define VIDFUNC_WRITECHAR 0x0A +#define VIDFUNC_SETPALETTE 0x0B +#define VIDFUNC_WRITEPIXEL 0x0C +#define VIDFUNC_READPIXEL 0x0D +#define VIDFUNC_WRITETTY 0x0E +#define VIDFUNC_QUERYMODE 0x0F +#define VIDFUNC_EGASETPALETTE 0x10 +#define VIDFUNC_EGASELECTFONT 0x11 +#define VIDFUNC_EGASELECTMISC 0x12 +#define VIDFUNC_EGAWRITESTRING 0x13 +#define VIDFUNC_VGADISPLAYCODES 0x1A +#define VIDFUNC_VGAQUERYSTATE 0x1B +#define VIDFUNC_VGASAVERESTORE 0x1C + +#define VIDMODE_MONO 7 + + +/* BIOS Data Area video locations + */ +#define VIDDATA_CRT_MODE 0x449 +#define VIDDATA_CRT_COLS 0x44A +#define VIDDATA_CRT_LEN 0x44C +#define VIDDATA_CRT_START 0x44E +#define VIDDATA_CURSOR_POSN 0x450 +#define VIDDATA_CURSOR_MODE 0x460 +#define VIDDATA_ACTIVE_PAGE 0x462 +#define VIDDATA_ADDR_6845 0x463 +#define VIDDATA_CRT_MODE_SET 0x465 +#define VIDDATA_CRT_PALETTE 0x466 + + diff --git a/private/mvdm/v86/scaffold/i386/xguest.h b/private/mvdm/v86/scaffold/i386/xguest.h new file mode 100644 index 000000000..38e963365 --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/xguest.h @@ -0,0 +1,459 @@ +/* x86 v1.0 + * + * XGUEST.H + * Guest processor definitions/conventions + * + * History + * Created 20-Oct-90 by Jeff Parsons + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + + +#define GUESTMEM_SIZE (640*K) + +#define GUESTMEM_MIN (32*K) // smallest PC size ever +#define GUESTMEM_MAX (960*K) // uses all but the last 64k ROM block + +#define GUESTVID_SIZE (4*K) // for MONO emulation +#define GUESTVID_SEG (USHORT)0xB000 + +#define GUESTROM_SIZE (64*K) +#define GUESTROM_SEG (USHORT)0xF000 + +#define FLATMEM_SIZE ((1024+64)*K) + + +/* Processor-defined stuff + */ +#define IVT_BEGIN 0x0000 // IVT table +#define IVT_END 0x03FF + +#define RESET_SEG (USHORT)0xFFFF // processor reset address +#define RESET_OFF 0x0000 + + +/* Useful macros + */ +#define LINEAR(seg,off) (((((ULONG)(seg)<<4)+(off))) & ulWrapMask) +#define LINEAR2(seg,off) (((ULONG)(seg)<<4)+(off)) +#define COMPOSITE(seg,off) (((ULONG)(seg)<<16)|(off)) +#define OFFCOMPOSITE(ul) WORDOF(ul,0) +#define SEGCOMPOSITE(ul) WORDOF(ul,1) + +#define BYTESOFFSET(off) LOBYTE(off), HIBYTE(off) +#define BYTESCOMPOSITE(seg,off) LOBYTE(off), HIBYTE(off), LOBYTE(seg), HIBYTE(seg) + +/* x86 opcodes (the really useful ones anyway) + */ +#define OPX_ADDAXI 0x05 +#define OPX_PUSHDS 0x1E +#define OPX_POPDS 0x1F +#define OPX_ES 0x26 +#define OPX_CS 0x2E +#define OPX_SS 0x36 +#define OPX_DS 0x3E +#define OPX_PUSHAX 0x50 +#define OPX_POPAX 0x58 +#define OPX_JO 0x70 +#define OPX_JNO 0x71 +#define OPX_JB 0x72 +#define OPX_JNB 0x73 +#define OPX_JZ 0x74 +#define OPX_JNZ 0x75 +#define OPX_JBE 0x76 +#define OPX_JNBE 0x77 +#define OPX_JS 0x78 +#define OPX_JNS 0x79 +#define OPX_JP 0x7A +#define OPX_JNP 0x7B +#define OPX_JL 0x7C +#define OPX_JGE 0x7D +#define OPX_JLE 0x7E +#define OPX_JG 0x7F +#define OPX_MOVSEG2 0x8C +#define OPX_LEA 0x8D +#define OPX_MOV2SEG 0x8E +#define OPX_CBW 0x98 +#define OPX_CWD 0x99 +#define OPX_MOVALOFF 0xA0 +#define OPX_MOVAXOFF 0xA1 +#define OPX_MOVSB 0xA4 +#define OPX_MOVSW 0xA5 +#define OPX_MOVAL 0xB0 +#define OPX_MOVCL 0xB1 +#define OPX_MOVDL 0xB2 +#define OPX_MOVBL 0xB3 +#define OPX_MOVAH 0xB4 +#define OPX_MOVCH 0xB5 +#define OPX_MOVDH 0xB6 +#define OPX_MOVBH 0xB7 +#define OPX_MOVAX 0xB8 +#define OPX_MOVCX 0xB9 +#define OPX_MOVDX 0xBA +#define OPX_MOVBX 0xBB +#define OPX_MOVSP 0xBC +#define OPX_MOVBP 0xBD +#define OPX_MOVSI 0xBE +#define OPX_MOVDI 0xBF +#define OPX_RETNV 0xC2 +#define OPX_RETN 0xC3 +#define OPX_LES 0xC4 +#define OPX_LDS 0xC5 +#define OPX_RETFV 0xCA +#define OPX_RETF 0xCB +#define OPX_INT3 0xCC +#define OPX_INT 0xCD +#define OPX_INTO 0xCE +#define OPX_IRET 0xCF +#define OPX_GBP 0xD6 // invalid opcode used for guest breakpoints +#define OPX_XLAT 0xD7 +#define OPX_JCXZ 0xE3 +#define OPX_JMPR16 0xE9 +#define OPX_JMPF 0xEA +#define OPX_JMPR8 0xEB +#define OPX_LOCK 0xF0 +#define OPX_REPNZ 0xF2 +#define OPX_REPZ 0xF3 +#define OPX_CLC 0xF8 +#define OPX_STC 0xF9 +#define OPX_CLI 0xFA +#define OPX_STI 0xFB +#define OPX_GRP5 0xFF + +/* Mnemonic ordinals (indexes into apszMnemonic) + */ +#define M_NONE 0 +#define M_AAA 1 +#define M_AAD 2 +#define M_AAM 3 +#define M_AAS 4 +#define M_ADC 5 +#define M_ADD 6 +#define M_AND 7 +#define M_ARPL 8 +#define M_ASIZE 9 +#define M_BOUND 10 +#define M_BSF 11 +#define M_BSR 12 +#define M_BT 13 +#define M_BTC 14 +#define M_BTR 15 +#define M_BTS 16 +#define M_CALL 17 +#define M_CBW 18 +#define M_CLC 19 +#define M_CLD 20 +#define M_CLI 21 +#define M_CLTS 22 +#define M_CMC 23 +#define M_CMP 24 +#define M_CMPSB 25 +#define M_CMPSW 26 +#define M_CS 27 +#define M_CWD 28 +#define M_DAA 29 +#define M_DAS 30 +#define M_DEC 31 +#define M_DIV 32 +#define M_DS 33 +#define M_ENTER 34 +#define M_ES 35 +#define M_ESC 36 +#define M_FADD 37 +#define M_FBLD 38 +#define M_FBSTP 39 +#define M_FCOM 40 +#define M_FCOMP 41 +#define M_FDIV 42 +#define M_FDIVR 43 +#define M_FIADD 44 +#define M_FICOM 45 +#define M_FICOMP 46 +#define M_FIDIV 47 +#define M_FIDIVR 48 +#define M_FILD 49 +#define M_FIMUL 50 +#define M_FIST 51 +#define M_FISTP 52 +#define M_FISUB 53 +#define M_FISUBR 54 +#define M_FLD 55 +#define M_FLDCW 56 +#define M_FLDENV 57 +#define M_FMUL 58 +#define M_FNSAVE 59 +#define M_FNSTCW 60 +#define M_FNSTENV 61 +#define M_FNSTSW 62 +#define M_FRSTOR 63 +#define M_FS 64 +#define M_FST 65 +#define M_FSTP 66 +#define M_FSUB 67 +#define M_FSUBR 68 +#define M_GBP 69 +#define M_GS 70 +#define M_HLT 71 +#define M_IDIV 72 +#define M_IMUL 73 +#define M_IN 74 +#define M_INC 75 +#define M_INS 76 +#define M_INT 77 +#define M_INT3 78 +#define M_INTO 79 +#define M_IRET 80 +#define M_JBE 81 +#define M_JB 82 +#define M_JCXZ 83 +#define M_JG 84 +#define M_JGE 85 +#define M_JL 86 +#define M_JLE 87 +#define M_JMP 88 +#define M_JNBE 89 +#define M_JNB 90 +#define M_JNO 91 +#define M_JNP 92 +#define M_JNS 93 +#define M_JNZ 94 +#define M_JO 95 +#define M_JP 96 +#define M_JS 97 +#define M_JZ 98 +#define M_LAHF 99 +#define M_LAR 100 +#define M_LDS 101 +#define M_LEA 102 +#define M_LEAVE 103 +#define M_LES 104 +#define M_LFS 105 +#define M_LGDT 106 +#define M_LGS 107 +#define M_LIDT 108 +#define M_LLDT 109 +#define M_LMSW 110 +#define M_LOCK 111 +#define M_LODSB 112 +#define M_LODSW 113 +#define M_LOOP 114 +#define M_LOOPNZ 115 +#define M_LOOPZ 116 +#define M_LSL 117 +#define M_LSS 118 +#define M_LTR 119 +#define M_MOV 120 +#define M_MOVSB 121 +#define M_MOVSW 122 +#define M_MOVSX 123 +#define M_MOVZX 124 +#define M_MUL 125 +#define M_NEG 126 +#define M_NOP 127 +#define M_NOT 128 +#define M_OR 129 +#define M_OSIZE 130 +#define M_OUT 131 +#define M_OUTS 132 +#define M_POP 133 +#define M_POPA 134 +#define M_POPF 135 +#define M_PUSH 136 +#define M_PUSHA 137 +#define M_PUSHF 138 +#define M_RCL 139 +#define M_RCR 140 +#define M_REPNZ 141 +#define M_REPZ 142 +#define M_RET 143 +#define M_RETF 144 +#define M_ROL 145 +#define M_ROR 146 +#define M_SAHF 147 +#define M_SAR 148 +#define M_SBB 149 +#define M_SCASB 150 +#define M_SCASW 151 +#define M_SETBE 152 +#define M_SETC 153 +#define M_SETG 154 +#define M_SETGE 155 +#define M_SETL 156 +#define M_SETLE 157 +#define M_SETNBE 158 +#define M_SETNC 159 +#define M_SETNO 160 +#define M_SETNP 161 +#define M_SETNS 162 +#define M_SETNZ 163 +#define M_SETO 164 +#define M_SETP 165 +#define M_SETS 166 +#define M_SETZ 167 +#define M_SGDT 156 +#define M_SHL 169 +#define M_SHLD 170 +#define M_SHR 171 +#define M_SHRD 172 +#define M_SIDT 173 +#define M_SLDT 174 +#define M_SMSW 175 +#define M_SS 176 +#define M_STC 177 +#define M_STD 178 +#define M_STI 179 +#define M_STOSB 180 +#define M_STOSW 181 +#define M_STR 182 +#define M_SUB 183 +#define M_TEST 184 +#define M_VERR 185 +#define M_VERW 186 +#define M_WAIT 187 +#define M_XCHG 188 +#define M_XLAT 189 +#define M_XOR 190 +#define MTOTAL 191 + + +/* ModRegRM masks and definitions + */ +#define REG_AL 0x00 // bits 0-2 are standard Reg encodings +#define REG_CL 0x01 // +#define REG_DL 0x02 // +#define REG_BL 0x03 // +#define REG_AH 0x04 // +#define REG_CH 0x05 // +#define REG_DH 0x06 // +#define REG_BH 0x07 // +#define REG_AX 0x08 // +#define REG_CX 0x09 // +#define REG_DX 0x0A // +#define REG_BX 0x0B // +#define REG_SP 0x0C // +#define REG_BP 0x0D // +#define REG_SI 0x0E // +#define REG_DI 0x0F // + +#define REG_ES 0x00 // bits 0-1 are standard SegReg encodings +#define REG_CS 0x01 // +#define REG_SS 0x02 // +#define REG_DS 0x03 // +#define REG_FS 0x04 // +#define REG_GS 0x05 // + +#define MODMASK 0xC0 // mod/reg/rm definitions +#define MODSHIFT 6 // +#define MOD(m) (((m)&MODMASK)>>MODSHIFT) +#define REGMASK 0x38 // +#define REGSHIFT 3 // +#define REG(r) (((r)®MASK)>>REGSHIFT) +#define RMMASK 0x07 // +#define RMSHIFT 0 // +#define RM(b) (((b)&RMMASK)>>RMSHIFT) +#define MODREGRM(m,r,b) ((BYTE)((((m)<<MODSHIFT)&MODMASK) | \ + (((r)<<REGSHIFT)®MASK) | \ + (((b)<<RMSHIFT )&RMMASK ))) + +#define MOD_NODISP 0x00 // use RM below, no displacement +#define MOD_DISP8 0x01 // use RM below + 8-bit displacement +#define MOD_DISP16 0x02 // use RM below + 16-bit displacement +#define MOD_REGISTER 0x03 // use REG above + +#define RM_BXSI 0x00 // +#define RM_BXDI 0x01 // +#define RM_BPSI 0x02 // +#define RM_BPDI 0x03 // +#define RM_SI 0x04 // +#define RM_DI 0x05 // +#define RM_BP 0x06 // note: if MOD_NODISP, this is IMMOFF +#define RM_BX 0x07 // + + +/* Operand type descriptor masks and definitions + * + * Note that the letters in () in the comments refer to Intel's + * nomenclature used in Appendix A of the 80386 Prog. Reference Manual. + */ +#define TYPE_SIZE 0x000F // size field +#define TYPE_TYPE 0x00F0 // type field +#define TYPE_IREG 0x0F00 // implied register field +#define TYPE_OTHER 0xF000 // "other" field + +// TYPE_SIZE values. Note that some of the values (eg, TYPE_WORDIB +// and TYPE_WORDIW) imply the presence of a third operand, for those +// wierd cases.... + +#define TYPE_NONE 0x0000 // (all other TYPE fields ignored) +#define TYPE_BYTE 0x0001 // (b) byte, regardless of operand size +#define TYPE_SBYTE 0x0002 // same as above, but sign-extended +#define TYPE_WORD 0x0003 // (w) word, regardless... +#define TYPE_WORDD 0x0004 // (v) word or double-word, depending... +#define TYPE_DWORD 0x0005 // (d) double-word, regardless... +#define TYPE_FARP 0x0006 // (p) 32-bit or 48-bit pointer, depending +#define TYPE_2WORDD 0x0007 // (a) two memory operands (BOUND only) +#define TYPE_DESC 0x0008 // (s) 6 byte pseudo-descriptor +#define TYPE_WORDIB 0x0009 // two source operands (eg, IMUL) +#define TYPE_WORDIW 0x000A // two source operands (eg, IMUL) + +// TYPE_TYPE values. Note that all values implying +// the presence of a ModRegRM byte are >= TYPE_MODRM (clever, eh?) + +#define TYPE_IMM 0x0000 // (I) immediate data +#define TYPE_ONE 0x0010 // implicit 1 (eg, shifts/rotates) +#define TYPE_IMMOFF 0x0020 // (A) immediate offset +#define TYPE_IMMREL 0x0030 // (J) immediate relative +#define TYPE_DSSI 0x0040 // (X) memory addressed by DS:SI +#define TYPE_ESDI 0x0050 // (Y) memory addressed by ES:DI +#define TYPE_IMPREG 0x0060 // implicit register in TYPE_IREG +#define TYPE_IMPSEG 0x0070 // implicit seg. register in TYPE_IREG +#define TYPE_MODRM 0x0080 // (E) standard ModRM decoding +#define TYPE_MEM 0x0090 // (M) ModRM refers to memory only +#define TYPE_REG 0x00A0 // (G) standard Reg decoding +#define TYPE_SEGREG 0x00B0 // (S) Reg selects segment register +#define TYPE_MODREG 0x00C0 // (R) Mod refers to register only +#define TYPE_CTLREG 0x00D0 // (C) Reg selects control register +#define TYPE_DBGREG 0x00E0 // (D) Reg selects debug register +#define TYPE_TSTREG 0x00F0 // (T) Reg selects test register + +// TYPE_IREG values, based on the REG_* constants. +// For convenience, they include TYPE_IMPREG or TYPE_IMPSEG as appropriate. + +#define TYPE_AL (REG_AL<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_CL (REG_CL<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_DL (REG_DL<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_BL (REG_BL<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_AH (REG_AH<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_CH (REG_CH<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_DH (REG_DH<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_BH (REG_BH<<8|TYPE_IMPREG|TYPE_BYTE) +#define TYPE_AX (REG_AX<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_CX (REG_CX<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_DX (REG_DX<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_BX (REG_BX<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_SP (REG_SP<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_BP (REG_BP<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_SI (REG_SI<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_DI (REG_DI<<8|TYPE_IMPREG|TYPE_WORD) +#define TYPE_ES (REG_ES<<8|TYPE_IMPSEG|TYPE_WORD) +#define TYPE_CS (REG_CS<<8|TYPE_IMPSEG|TYPE_WORD) +#define TYPE_SS (REG_SS<<8|TYPE_IMPSEG|TYPE_WORD) +#define TYPE_DS (REG_DS<<8|TYPE_IMPSEG|TYPE_WORD) +#define TYPE_FS (REG_FS<<8|TYPE_IMPSEG|TYPE_WORD) +#define TYPE_GS (REG_GS<<8|TYPE_IMPSEG|TYPE_WORD) + +// TYPE_OTHER bit definitions + +#define TYPE_IN 0x1000 // operand is input +#define TYPE_OUT 0x2000 // operand is output +#define TYPE_BOTH (TYPE_IN|TYPE_OUT) +#define TYPE_86 (CPU_86 << 14) +#define TYPE_186 (CPU_186 << 14) +#define TYPE_286 (CPU_286 << 14) +#define TYPE_386 (CPU_386 << 14) + diff --git a/private/mvdm/v86/scaffold/i386/xwincon.h b/private/mvdm/v86/scaffold/i386/xwincon.h new file mode 100644 index 000000000..c3880146d --- /dev/null +++ b/private/mvdm/v86/scaffold/i386/xwincon.h @@ -0,0 +1,186 @@ +// +// borrowed for temprorary softpc console support +// + + +/*++ BUILD Version: 0001 + * + * x86 v1.0 + * + * XWINCON.H + * Windows support functions for console windows + * + * History + * Created 27-Dec-90 by Jeff Parsons + * + * COPYRIGHT NOTICE + * This source file may not be distributed, modified or incorporated into + * another product without prior approval from the author, Jeff Parsons. + * This file may be copied to designated servers and machines authorized to + * access those servers, but that does not imply any form of approval. + */ + + +typedef unsigned int UINT; // ints preferred +typedef int INT; // ints preferred +typedef CHAR *NPSZ; +typedef INT (FAR PASCAL *INTPROC)(HWND, UINT, UINT, LONG); + +#define DEF_CCHIN 16 // default input buffer size +#define DEF_CCHXOUT 80 // default output buffer width +#define DEF_CCHYOUT 25 // default output buffer height + +#define CON_SCROLL_LOCK 0x0010 // console has SCROLL-LOCK set +#define CON_NUM_LOCK 0x0020 // console has NUM-LOCK set +#define CON_CAPS_LOCK 0x0040 // console has CAPS-LOCK set +#define CON_LEDS_MASK 0x0070 // +#define CON_FOCUS 0x0100 // console has focus + +#ifndef VK_OEM_SCROLL +#define VK_OEM_SCROLL 0x91 // left out of windows.h for some reason... +#endif + +#define INVALIDATE_SCROLL 2 + +#define IDM_DBBRK 100 +#define IDM_ABOUT 101 + +#define CLR_BLACK 0x00000000 +#define CLR_RED 0x007F0000 +#define CLR_GREEN 0x00007F00 +#define CLR_BROWN 0x007F7F00 +#define CLR_BLUE 0x0000007F +#define CLR_MAGENTA 0x007F007F +#define CLR_CYAN 0x00007F7F +#define CLR_LT_GRAY 0x00BFBFBF + +#define CLR_DK_GRAY 0x007F7F7F +#define CLR_BR_RED 0x00FF0000 +#define CLR_BR_GREEN 0x0000FF00 +#define CLR_YELLOW 0x00FFFF00 +#define CLR_BR_BLUE 0x000000FF +#define CLR_BR_MAGENTA 0x00FF00FF +#define CLR_BR_CYAN 0x0000FFFF +#define CLR_WHITE 0x00FFFFFF + +#define OPT_FONT 0x0004 // use small OEM font if available (/s) +#define OPT_DOUBLE 0x0020 // use 50-line debug window w/small font (/50) +#define OPT_CAPS 0x0002 // map ctrl keys to caps-lock (/c) +#define OPT_TERMINAL 0x0010 // redirect all window output to terminal (/t) +#define OPT_FLUSH 0x0100 // flush prefetch after every jump (/f) +#define OPT_NOXLATE 0x0200 // disable built-in translations (/n) +#define OPT_DEBUG 0x0008 // shadow all log output on debug terminal (/d) +#define OPT_GO 0x0001 // do an initial "go" (/g) + +#define CTRL_A 1 // used by gets to repeat last line +#define CTRL_C 3 // break in debug window +#define CTRL_Q 17 // flow control +#define CTRL_S 19 // flow control +#define BELL 7 // +#define BS 8 // backspace +#define TAB 9 // +#define LF 10 // linefeed +#define CR 13 // return +#define ESCAPE 27 // + +#define SIGNAL_EMULATE 1 +#define ERR_NONE 0x0 + +#define TRUE_IF_WIN32 1 + +/* Per-window information + */ +#ifdef WIN_16 +#define GETPCONSOLE(hwnd) (PCONSOLE)GetWindowWord(hwnd,0) +#define SETPCONSOLE(hwnd,p) (PCONSOLE)SetWindowWord(hwnd,0,(INT)p) +#endif +#ifdef WIN_32 +#define GETPCONSOLE(hwnd) (PCONSOLE)GetWindowLong(hwnd,0) +#define SETPCONSOLE(hwnd,p) (PCONSOLE)SetWindowLong(hwnd,0,(LONG)p) +#endif +#ifdef PM +#define GETPCONSOLE(hwnd) (PCONSOLE)WinQueryWindowUShort(hwnd,0) +#define SETPCONSOLE(hwnd,p) (PCONSOLE)WinSetWindowUShort(hwnd,0,(USHORT)p) +#endif + +#define GETICARET(pcon) (pcon->chyCaret*pcon->cchxOut+pcon->chxCaret) +#define GETPCARET(pcon) (pcon->pchOut+GETICARET(pcon)) +#define GETXCARET(pcon) (pcon->chxCaret*pcon->cxChar) +#ifdef WIN +#define GETYCARET(pcon) (pcon->chyCaret*pcon->cyChar) +#else +#define GETYCARET(pcon) (pcon->cyOut - pcon->chyCaret*pcon->cyChar) +#endif + +#define GETILINE(pcon,chy) ((chy)*pcon->cchxOut) +#define GETPLINE(pcon,chy) (pcon->pchOut+GETILINE(pcon,chy)) + +#define GETICHAR(pcon,chx,chy) ((chy)*pcon->cchxOut+(chx)) +#define GETPCHAR(pcon,chx,chy) (pcon->pchOut+GETICHAR(pcon,chx,chy)) +#define GETXCHAR(pcon,chx) (pcon->cxChar*(chx)) +#ifdef WIN +#define GETYCHAR(pcon,chy) (pcon->cyChar*(chy)) +#else +#define GETYCHAR(pcon,chy) (pcon->cyOut - pcon->cyChar*(chy)) +#endif + +#define WORDOF(i,n) (((PWORD)&(i))[n]) +#define LOW(l) WORDOF(l,0) +#define NPVOID(p) ((VOID *)(p)) + +typedef struct key_s { + INT iKey; + LONG lKeyType; +} KEY, *PKEY; + +typedef struct console_s { + INT flCon; // console flags (see CON_*) + PKEY pkIn; // pointer to input buffer + HANDLE hkEvent; // handle to key event + INT ikHead; // input head (where to store next key) + INT ikTail; // input tail (where to retrieve next key) + INT ikMax; // maximum input index + HFONT hFont; // font identifier + INT cxChar; // character width, in pixels + INT cyChar; // character height, in pixels + INT cxOut; // buffer width, in pixels + INT cyOut; // buffer height, in pixels + INT cchxOut; // buffer width, in chars + INT cchyOut; // buffer height, in chars + UINT cbOut; // buffer size, in bytes + PCHAR pchOut; // pointer to output buffer + INT chxCaret; // caret x location, in char coordinates + INT chyCaret; // caret y location, in char coordinates +} CONSOLE, *PCONSOLE; + + +/* Function prototypes + */ +PCONSOLE initconsole(HWND hwnd, INT cchIn, INT cchxOut, INT cchyOut, INT iFont); +VOID freeconsole(HWND hwnd); +VOID clearconsole(HWND hwnd); +VOID invalidateconsole(HWND hwnd, PRECT prc, BOOL fUpdate); + +INT wprint(HWND hwnd, NPSZ psz, INT n); +INT wgetch(HWND hwnd); +BOOL wkbhit(HWND hwnd); +VOID wyield(HANDLE); +INT wputch(HWND hwnd, INT i); + +VOID setcaret(HWND hwnd, INT x, INT y); +VOID getcaret(HWND hwnd, PINT px, PINT py); +VOID writechar(HWND hwnd, CHAR ch, INT n); +VOID scrollrect(HWND hwndGuest, PRECT prc, INT n); + +extern HWND hwndGuest; +extern HANDLE hHostInstance; +extern INT flOptions; // command-line options (see OPT_*) +extern INT flSignals; // signal flags (see SIGNAL_*) + +LONG FAR PASCAL VDMWndProc(HWND hwnd, UINT wMsg, UINT uParam, LONG lParam); +BOOL FAR PASCAL VDMAbout(HWND hDlg, UINT wMsg, UINT uParam, LONG lParam); + +VOID processmessages(HWND hwnd); +INT getkbdleds(VOID); +VOID setkbdleds(INT flCon); +VOID mapkbdkeys(PCONSOLE pcon, UINT iParam, BOOL fDown); diff --git a/private/mvdm/v86/scaffold/makefile b/private/mvdm/v86/scaffold/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/mvdm/v86/scaffold/makefile @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/private/mvdm/v86/scaffold/ntvdm.def b/private/mvdm/v86/scaffold/ntvdm.def new file mode 100644 index 000000000..6cc3fd979 --- /dev/null +++ b/private/mvdm/v86/scaffold/ntvdm.def @@ -0,0 +1,90 @@ +NAME ntvdm.exe + +EXPORTS + getEAX + getAX + getAL + getAH + getEBX + getBX + getBL + getBH + getECX + getCX + getCL + getCH + getEDX + getDX + getDL + getDH + getESP + getSP + getEBP + getBP + getESI + getSI + getEDI + getDI + getEIP + getIP + getCS + getSS + getDS + getES + getFS + getGS + getCF + getPF + getAF + getZF + getSF + getIF + getDF + getOF + getMSW + setEAX + setAX + setAH + setAL + setEBX + setBX + setBH + setBL + setECX + setCX + setCH + setCL + setEDX + setDX + setDH + setDL + setESP + setSP + setEBP + setBP + setESI + setSI + setEDI + setDI + setEIP + setIP + setCS + setSS + setDS + setES + setFS + setGS + setCF + setPF + setAF + setZF + setSF + setIF + setDF + setOF + setMSW + MGetVdmPointer + host_simulate + EnterIdle + LeaveIdle + getIntelRegistersPointer diff --git a/private/mvdm/v86/scaffold/sources b/private/mvdm/v86/scaffold/sources new file mode 100644 index 000000000..d0cde5f5b --- /dev/null +++ b/private/mvdm/v86/scaffold/sources @@ -0,0 +1,157 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Steve Wood (stevewo) 12-Apr-1990 + Dave Hastings (daveh) 24-Apr-1991 + Sudeep Bharati (sudeepb) 31-Dec-1991 - deleted wow32 related stuff and + converted .EXE to (.EXE/.EXP/.LIB) + +NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl + +!ENDIF + + +# +# The MAJORCOMP and MINORCOMP variables are defined +# so that $(MAJORCOMP)$(MINORCOMP)filename can be used in +# cross compiling to provide unique filenames in a flat namespace. +# + +MAJORCOMP=v86 +MINORCOMP=scaffold + +# +# The TARGETNAME variable is defined by the developer. It is the name of +# the target (component) that is being built by this makefile. It +# should NOT include any path or file extension information. +# + +TARGETNAME=ntvdm + + +# +# The TARGETPATH and TARGETTYPE variables are defined by the developer. +# The first specifies where the target is to be build. The second specifies +# the type of target (either PROGRAM, DYNLINK, LIBRARY, UMAPPL_NOLIB or +# BOOTPGM). UMAPPL_NOLIB is used when you're only building user-mode +# apps and don't need to build a library. +# + +TARGETPATH=\nt\public\sdk\lib + +# PROGLIB is a new target type which allows ntvdm to be an exe and +# at the same time exports interfaces like a dll. +TARGETTYPE=PROGLIB + + +# +# The TARGETLIBS specifies additional libraries to link with you target +# image. Each library path specification should contain an asterisk (*) +# where the machine specific subdirectory name should go. +# + +!IFNDEF NTVDM_NET_PATH +NTVDM_NET_PATH=..\..\..\net +!ENDIF + +!IFDEF NTLIBPATH +TARGETLIBS=\nt\public\sdk\lib\*\monitor.lib \ + \nt\public\sdk\lib\*\xms.lib \ + \nt\public\sdk\lib\*\dbg.lib \ + \nt\public\sdk\lib\*\dem.lib \ + \nt\public\sdk\lib\*\command.lib \ +!IFDEF NTVDM_NET_SUPPORT + ..\..\dos\command\obj\*\command.lib \ + ..\..\vdmredir\obj\*\vdmredir.lib +!ELSE + ..\..\dos\command\obj\*\command.lib +!ENDIF +!ELSE +TARGETLIBS=\nt\public\sdk\lib\*\monitor.lib \ + \nt\public\sdk\lib\*\dem.lib \ + \nt\public\sdk\lib\*\xms.lib \ + \nt\public\sdk\lib\*\dbg.lib \ + \nt\public\sdk\lib\*\command.lib \ +!IFDEF NTVDM_NET_SUPPORT + ..\..\vdmredir\obj\*\vdmredir.lib \ + \nt\public\sdk\lib\*\netapi32.lib \ + \nt\public\sdk\lib\*\xactsrv.lib \ + $(BASEDIR)\Public\SDK\Lib\*\rxcommon.lib \ + $(NTVDM_NET_PATH)\netlib\obj\*\netlib.lib \ +!ENDIF + \nt\public\sdk\lib\*\gdi32.lib \ +!ENDIF + +# +# The INCLUDES variable specifies any include paths that are specific to +# this source directory. Separate multiple directory paths with single +# semicolons. Relative path specifications are okay. +# + +INCLUDES=..\..\inc;..\..\..\windows\inc + + +# +# The SOURCES variable is defined by the developer. It is a list of all the +# source files for this component. Each source file should be on a separate +# line using the line continuation character. This will minimize merge +# conflicts if two developers adding source files to the same component. +# + +SOURCES=vdm.rc + +# +# Next specify options for the compiler. +# + +!IFDEF NTVDM_NET_SUPPORT +C_DEFINES=-DWIN_32 -DWOW -DNTVDM_NET_SUPPORT +!ELSE +C_DEFINES=-DWIN_32 -DWOW +!ENDIF + +# +# Next specify a kernel mode test (valid only in NTOS tree) +# + +NTTEST= + +# +# Next specify one or more user mode test programs and their type +# UMTEST is used for optional test programs. UMAPPL is used for +# programs that always get built when the directory is built. +# + +UMTYPE=console +UMTEST= +UMAPPL= +UMBASE=0x1000000 +UMLIBS= + +# +# Defining either (or both) the variables NTTARGETFILE0 and/or NTTARGETFILES +# will cause MAKEFILE.DEF to include .\makefile.inc immediately after it +# specifies the top level targets (all, clean and loc) and their dependencies. +# MAKEFILE.DEF also expands NTTARGETFILE0 as the first dependent for the +# "all" target and NTTARGETFILES as the last dependent for the "all" target. +# Useful for specifying additional targets and dependencies that don't fit the +# general case covered by MAKEFILE.DEF +# + +# NTTARGETFILE0= +# NTTARGETFILES= diff --git a/private/mvdm/v86/scaffold/vdm.ico b/private/mvdm/v86/scaffold/vdm.ico Binary files differnew file mode 100644 index 000000000..6b2416d64 --- /dev/null +++ b/private/mvdm/v86/scaffold/vdm.ico diff --git a/private/mvdm/v86/scaffold/vdm.rc b/private/mvdm/v86/scaffold/vdm.rc new file mode 100644 index 000000000..1d354879c --- /dev/null +++ b/private/mvdm/v86/scaffold/vdm.rc @@ -0,0 +1,57 @@ +#ifndef DOS // Gross hack to account for the +#ifndef OS2_16 // fact that C_DEFINES in "sources" isn't +#ifndef OS2_32 // passed to the resource compiler when building +#ifndef WIN_16 // for MIPS. Since MIPS is a WIN_32 build, +#ifndef WIN_32 // I try to innocuously define WIN_32 here... -JTP +#define WIN_32 +#endif +#endif +#endif +#endif +#endif + +#define _NTIMAGE_ // This will force ntimage not to include nt.h +#define _NTXCAPI_ // forces ntxcapi.h unincluded +#include "i386\x86.h" + +VDMIcon ICON vdm.ico + + +SoftPC MENU +BEGIN + POPUP "&Help" + BEGIN + MENUITEM "&DebugBreak", IDM_DBBRK + MENUITEM "&About NT VDM...", IDM_ABOUT + END +END + + +VDMAbout DIALOG 22, 17, 131, 83 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About NT VDM" +BEGIN + CTEXT "NT VDMs are " -1, 32, 5, 65, 12 + CTEXT "Brought to you by the NTVDM Team" -1, 0, 19, 131, 10 + CTEXT "Some code adapted from:" -1, 0, 27, 131, 9 + CTEXT "x86 emulator v0.17" -1, 0, 38, 131, 8 + CTEXT "by Jeff Parsons, (C) 1991" -1, 0, 45, 131, 8 + CONTROL "Text", -1, "static", SS_BLACKFRAME | WS_CHILD, 17, 36, 99, 27 + DEFPUSHBUTTON "OK" IDOK, 51, 66, 32, 14, WS_GROUP +END + + +#ifdef WOW + +WOW32About DIALOG 22, 17, 144, 55 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About WOW" +BEGIN + CTEXT "Just say WOW!" -1, 0, 5, 144, 8 + CTEXT "This Win16-on-Win32 app" -1, 0, 18, 144, 8 + CTEXT "brought to you by the MVDM Team" -1, 0, 27, 144, 8 + DEFPUSHBUTTON "OK" IDOK, 32, 39, 32, 14, WS_GROUP + PUSHBUTTON "Debug" 100, 80, 39, 32, 14, WS_GROUP +END + +#endif diff --git a/private/mvdm/v86/scaffold/wow.ico b/private/mvdm/v86/scaffold/wow.ico Binary files differnew file mode 100644 index 000000000..936ab5c5e --- /dev/null +++ b/private/mvdm/v86/scaffold/wow.ico |