ReactOS  0.4.14-dev-114-gc8cbd56
io.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "io.h"
Include dependency graph for io.c:

Go to the source code of this file.

Classes

struct  _EMULATOR_IO_HANDLERS
 
struct  _EMULATOR_IOPORT_HANDLERS
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _EMULATOR_IO_HANDLERS EMULATOR_IO_HANDLERS
 
typedef struct _EMULATOR_IO_HANDLERSPEMULATOR_IO_HANDLERS
 
typedef struct _EMULATOR_IOPORT_HANDLERS EMULATOR_IOPORT_HANDLERS
 
typedef struct _EMULATOR_IOPORT_HANDLERSPEMULATOR_IOPORT_HANDLERS
 

Functions

UCHAR IOReadB (USHORT Port)
 
VOID IOReadStrB (USHORT Port, PUCHAR Buffer, ULONG Count)
 
VOID IOWriteB (USHORT Port, UCHAR Buffer)
 
VOID IOWriteStrB (USHORT Port, PUCHAR Buffer, ULONG Count)
 
USHORT IOReadW (USHORT Port)
 
VOID IOReadStrW (USHORT Port, PUSHORT Buffer, ULONG Count)
 
VOID IOWriteW (USHORT Port, USHORT Buffer)
 
VOID IOWriteStrW (USHORT Port, PUSHORT Buffer, ULONG Count)
 
ULONG IOReadD (USHORT Port)
 
VOID IOReadStrD (USHORT Port, PULONG Buffer, ULONG Count)
 
VOID IOWriteD (USHORT Port, ULONG Buffer)
 
VOID IOWriteStrD (USHORT Port, PULONG Buffer, ULONG Count)
 
VOID RegisterIoPort (USHORT Port, EMULATOR_INB_PROC InHandler, EMULATOR_OUTB_PROC OutHandler)
 
VOID UnregisterIoPort (USHORT Port)
 
VOID FASTCALL EmulatorReadIo (PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
 
VOID FASTCALL EmulatorWriteIo (PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
 
BOOL WINAPI VDDInstallIOHook (IN HANDLE hVdd, IN WORD cPortRange, IN PVDD_IO_PORTRANGE pPortRange, IN PVDD_IO_HANDLERS IoHandlers)
 
VOID WINAPI VDDDeInstallIOHook (IN HANDLE hVdd, IN WORD cPortRange, IN PVDD_IO_PORTRANGE pPortRange)
 

Variables

EMULATOR_IOPORT_HANDLERS IoPortProc [EMULATOR_MAX_IOPORTS_NUM] = {{NULL}}
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file io.c.

Typedef Documentation

◆ EMULATOR_IO_HANDLERS

◆ EMULATOR_IOPORT_HANDLERS

◆ PEMULATOR_IO_HANDLERS

◆ PEMULATOR_IOPORT_HANDLERS

Function Documentation

◆ EmulatorReadIo()

VOID FASTCALL EmulatorReadIo ( PFAST486_STATE  State,
USHORT  Port,
PVOID  Buffer,
ULONG  DataCount,
UCHAR  DataSize 
)

Definition at line 349 of file io.c.

354 {
356 
357  if (DataSize == 0 || DataCount == 0) return;
358 
359  if (DataSize == sizeof(UCHAR))
360  {
361  if (DataCount == 1)
362  *(PUCHAR)Buffer = IOReadB(Port);
363  else
364  IOReadStrB(Port, Buffer, DataCount);
365  }
366  else if (DataSize == sizeof(USHORT))
367  {
368  if (DataCount == 1)
369  *(PUSHORT)Buffer = IOReadW(Port);
370  else
371  IOReadStrW(Port, Buffer, DataCount);
372  }
373  else if (DataSize == sizeof(ULONG))
374  {
375  if (DataCount == 1)
376  *(PULONG)Buffer = IOReadD(Port);
377  else
378  IOReadStrD(Port, Buffer, DataCount);
379  }
380  else
381  {
383 
384  while (DataCount--)
385  {
386  ULONG CurrentPort = Port;
387  ULONG Count;
388  UCHAR NewDataSize = DataSize;
389 
390  /* Read dword */
391  Count = NewDataSize >> 2; // NewDataSize / sizeof(ULONG);
392  NewDataSize = NewDataSize & 3; // NewDataSize % sizeof(ULONG);
393  while (Count--)
394  {
395  *(PULONG)Address = IOReadD(CurrentPort);
396  CurrentPort += sizeof(ULONG);
397  Address += sizeof(ULONG);
398  }
399 
400  /* Read word */
401  Count = NewDataSize >> 1; // NewDataSize / sizeof(USHORT);
402  NewDataSize = NewDataSize & 1; // NewDataSize % sizeof(USHORT);
403  while (Count--)
404  {
405  *(PUSHORT)Address = IOReadW(CurrentPort);
406  CurrentPort += sizeof(USHORT);
407  Address += sizeof(USHORT);
408  }
409 
410  /* Read byte */
411  Count = NewDataSize; // NewDataSize / sizeof(UCHAR);
412  // NewDataSize = NewDataSize % sizeof(UCHAR);
413  while (Count--)
414  {
415  *(PUCHAR)Address = IOReadB(CurrentPort);
416  CurrentPort += sizeof(UCHAR);
417  Address += sizeof(UCHAR);
418  }
419  }
420  }
421 }
CPPORT Port[4]
Definition: headless.c:34
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
unsigned char * PUCHAR
Definition: retypes.h:3
VOID IOReadStrB(USHORT Port, PUCHAR Buffer, ULONG Count)
Definition: io.c:88
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
VOID IOReadStrW(USHORT Port, PUSHORT Buffer, ULONG Count)
Definition: io.c:183
ULONG IOReadD(USHORT Port)
Definition: io.c:252
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
USHORT IOReadW(USHORT Port)
Definition: io.c:156
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
unsigned short * PUSHORT
Definition: retypes.h:2
VOID IOReadStrD(USHORT Port, PULONG Buffer, ULONG Count)
Definition: io.c:271

Referenced by CpuInitialize().

◆ EmulatorWriteIo()

VOID FASTCALL EmulatorWriteIo ( PFAST486_STATE  State,
USHORT  Port,
PVOID  Buffer,
ULONG  DataCount,
UCHAR  DataSize 
)

Definition at line 424 of file io.c.

429 {
431 
432  if (DataSize == 0 || DataCount == 0) return;
433 
434  if (DataSize == sizeof(UCHAR))
435  {
436  if (DataCount == 1)
438  else
439  IOWriteStrB(Port, Buffer, DataCount);
440  }
441  else if (DataSize == sizeof(USHORT))
442  {
443  if (DataCount == 1)
445  else
446  IOWriteStrW(Port, Buffer, DataCount);
447  }
448  else if (DataSize == sizeof(ULONG))
449  {
450  if (DataCount == 1)
452  else
453  IOWriteStrD(Port, Buffer, DataCount);
454  }
455  else
456  {
458 
459  while (DataCount--)
460  {
461  ULONG CurrentPort = Port;
462  ULONG Count;
463  UCHAR NewDataSize = DataSize;
464 
465  /* Write dword */
466  Count = NewDataSize >> 2; // NewDataSize / sizeof(ULONG);
467  NewDataSize = NewDataSize & 3; // NewDataSize % sizeof(ULONG);
468  while (Count--)
469  {
470  IOWriteD(CurrentPort, *(PULONG)Address);
471  CurrentPort += sizeof(ULONG);
472  Address += sizeof(ULONG);
473  }
474 
475  /* Write word */
476  Count = NewDataSize >> 1; // NewDataSize / sizeof(USHORT);
477  NewDataSize = NewDataSize & 1; // NewDataSize % sizeof(USHORT);
478  while (Count--)
479  {
480  IOWriteW(CurrentPort, *(PUSHORT)Address);
481  CurrentPort += sizeof(USHORT);
482  Address += sizeof(USHORT);
483  }
484 
485  /* Write byte */
486  Count = NewDataSize; // NewDataSize / sizeof(UCHAR);
487  // NewDataSize = NewDataSize % sizeof(UCHAR);
488  while (Count--)
489  {
490  IOWriteB(CurrentPort, *(PUCHAR)Address);
491  CurrentPort += sizeof(UCHAR);
492  Address += sizeof(UCHAR);
493  }
494  }
495  }
496 }
VOID IOWriteStrD(USHORT Port, PULONG Buffer, ULONG Count)
Definition: io.c:304
CPPORT Port[4]
Definition: headless.c:34
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
unsigned char * PUCHAR
Definition: retypes.h:3
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
VOID IOWriteW(USHORT Port, USHORT Buffer)
Definition: io.c:206
VOID IOWriteStrW(USHORT Port, PUSHORT Buffer, ULONG Count)
Definition: io.c:229
VOID IOWriteD(USHORT Port, ULONG Buffer)
Definition: io.c:287
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
VOID IOWriteStrB(USHORT Port, PUCHAR Buffer, ULONG Count)
Definition: io.c:133
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
unsigned short * PUSHORT
Definition: retypes.h:2

Referenced by CpuInitialize().

◆ IOReadB()

UCHAR IOReadB ( USHORT  Port)

Definition at line 64 of file io.c.

65 {
67  IoPortProc[Port].IoHandlers.InB)
68  {
70  }
72  IoPortProc[Port].VddIoHandlers.inb_handler)
73  {
74  UCHAR Data;
75  ASSERT(Port <= MAXWORD);
77  return Data;
78  }
79  else
80  {
81  /* Return an empty port byte value */
82  DPRINT("Read from unknown port: 0x%X\n", Port);
83  return 0xFF;
84  }
85 }
CPPORT Port[4]
Definition: headless.c:34
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
PFNVDD_INB inb_handler
Definition: nt_vdd.h:145
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
void DPRINT(...)
Definition: polytest.cpp:61
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
EMULATOR_INB_PROC InB
Definition: io.c:24
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by Bios32Post(), BiosBootstrapLoader(), BiosHandleMasterPicIRQ(), BiosHandleSlavePicIRQ(), BiosKeyboardIrq(), BiosMiscService(), BiosTimeService(), DisableMouseInt(), DosMouseIrq(), EmulatorReadIo(), EnableMouseInt(), EraseMouseCursor(), InitializeBiosData(), IOReadStrB(), IOReadW(), PaintMouseCursor(), PicSetIRQMask(), ReadMouseData(), VbeInitialize(), VbeResetExtendedRegisters(), VbeService(), VbeSetExtendedRegisters(), VgaSetRegisters(), VgaSetSinglePaletteRegister(), VidBiosClearScreen(), VidBiosDrawGlyph(), VidBiosSyncCursorPosition(), and VidBiosVideoService().

◆ IOReadD()

ULONG IOReadD ( USHORT  Port)

Definition at line 252 of file io.c.

253 {
255  IoPortProc[Port].IoHandlers.InD)
256  {
257  return IoPortProc[Port].IoHandlers.InD(Port);
258  }
259  else
260  {
261  USHORT Low, High;
262 
263  // FIXME: Is it ok on Little endian and Big endian ??
264  Low = IOReadW(Port);
265  High = IOReadW(Port + sizeof(USHORT));
266  return MAKELONG(Low, High);
267  }
268 }
CPPORT Port[4]
Definition: headless.c:34
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
Definition: strmini.h:380
#define MAKELONG(a, b)
Definition: typedefs.h:248
EMULATOR_IND_PROC InD
Definition: io.c:26
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
USHORT IOReadW(USHORT Port)
Definition: io.c:156
Definition: strmini.h:378
unsigned short USHORT
Definition: pedump.c:61
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorReadIo(), and IOReadStrD().

◆ IOReadStrB()

VOID IOReadStrB ( USHORT  Port,
PUCHAR  Buffer,
ULONG  Count 
)

Definition at line 88 of file io.c.

91 {
93  IoPortProc[Port].IoHandlers.InsB)
94  {
96  }
98  IoPortProc[Port].VddIoHandlers.insb_handler)
99  {
100  ASSERT(Port <= MAXWORD);
101  ASSERT(Count <= MAXWORD);
103  }
104  else
105  {
106  while (Count--) *Buffer++ = IOReadB(Port);
107  }
108 }
CPPORT Port[4]
Definition: headless.c:34
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
EMULATOR_INSB_PROC InsB
Definition: io.c:28
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
PFNVDD_INSB insb_handler
Definition: nt_vdd.h:147
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorReadIo().

◆ IOReadStrD()

VOID IOReadStrD ( USHORT  Port,
PULONG  Buffer,
ULONG  Count 
)

Definition at line 271 of file io.c.

274 {
276  IoPortProc[Port].IoHandlers.InsD)
277  {
279  }
280  else
281  {
282  while (Count--) *Buffer++ = IOReadD(Port);
283  }
284 }
CPPORT Port[4]
Definition: headless.c:34
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
ULONG IOReadD(USHORT Port)
Definition: io.c:252
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
EMULATOR_INSD_PROC InsD
Definition: io.c:30
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorReadIo().

◆ IOReadStrW()

VOID IOReadStrW ( USHORT  Port,
PUSHORT  Buffer,
ULONG  Count 
)

Definition at line 183 of file io.c.

186 {
188  IoPortProc[Port].IoHandlers.InsW)
189  {
191  }
193  IoPortProc[Port].VddIoHandlers.insw_handler)
194  {
195  ASSERT(Port <= MAXWORD);
196  ASSERT(Count <= MAXWORD);
198  }
199  else
200  {
201  while (Count--) *Buffer++ = IOReadW(Port);
202  }
203 }
CPPORT Port[4]
Definition: headless.c:34
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
PFNVDD_INSW insw_handler
Definition: nt_vdd.h:148
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
unsigned short WORD
Definition: ntddk_ex.h:93
USHORT IOReadW(USHORT Port)
Definition: io.c:156
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
EMULATOR_INSW_PROC InsW
Definition: io.c:29
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorReadIo().

◆ IOReadW()

USHORT IOReadW ( USHORT  Port)

Definition at line 156 of file io.c.

157 {
159  IoPortProc[Port].IoHandlers.InW)
160  {
161  return IoPortProc[Port].IoHandlers.InW(Port);
162  }
164  IoPortProc[Port].VddIoHandlers.inw_handler)
165  {
166  USHORT Data;
167  ASSERT(Port <= MAXWORD);
169  return Data;
170  }
171  else
172  {
173  UCHAR Low, High;
174 
175  // FIXME: Is it ok on Little endian and Big endian ??
176  Low = IOReadB(Port);
177  High = IOReadB(Port + sizeof(UCHAR));
178  return MAKEWORD(Low, High);
179  }
180 }
CPPORT Port[4]
Definition: headless.c:34
PFNVDD_INW inw_handler
Definition: nt_vdd.h:146
#define MAKEWORD(a, b)
Definition: typedefs.h:247
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
Definition: strmini.h:380
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
EMULATOR_INW_PROC InW
Definition: io.c:25
UCHAR IOReadB(USHORT Port)
Definition: io.c:64
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
Definition: strmini.h:378
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorReadIo(), IOReadD(), and IOReadStrW().

◆ IOWriteB()

VOID IOWriteB ( USHORT  Port,
UCHAR  Buffer 
)

Definition at line 111 of file io.c.

113 {
115  IoPortProc[Port].IoHandlers.OutB)
116  {
118  }
120  IoPortProc[Port].VddIoHandlers.outb_handler)
121  {
122  ASSERT(Port <= MAXWORD);
124  }
125  else
126  {
127  /* Do nothing */
128  DPRINT("Write to unknown port: 0x%X\n", Port);
129  }
130 }
CPPORT Port[4]
Definition: headless.c:34
EMULATOR_OUTB_PROC OutB
Definition: io.c:32
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PFNVDD_OUTB outb_handler
Definition: nt_vdd.h:149
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by Bios32Post(), BiosBootstrapLoader(), BiosHandleMasterPicIRQ(), BiosHandleSlavePicIRQ(), BiosHwSetup(), BiosMiscService(), BiosTimeService(), DisableMouseInt(), EmulatorWriteIo(), EnableMouseInt(), EraseMouseCursor(), InitializeBiosData(), IOWriteStrB(), IOWriteW(), MouseBios32Post(), PaintMouseCursor(), PicIRQComplete(), PicSetIRQMask(), SendMouseCommand(), VbeInitialize(), VbeResetExtendedRegisters(), VbeService(), VbeSetExtendedRegisters(), VgaSetPalette(), VgaSetRegisters(), VgaSetSinglePaletteRegister(), VidBiosClearScreen(), VidBiosDrawGlyph(), VidBiosSetCursorPosition(), VidBiosSetCursorShape(), VidBiosSetVideoMode(), VidBiosSetVideoPage(), VidBiosSyncCursorPosition(), and VidBiosVideoService().

◆ IOWriteD()

VOID IOWriteD ( USHORT  Port,
ULONG  Buffer 
)

Definition at line 287 of file io.c.

289 {
291  IoPortProc[Port].IoHandlers.OutD)
292  {
294  }
295  else
296  {
297  // FIXME: Is it ok on Little endian and Big endian ??
299  IOWriteW(Port + sizeof(USHORT), HIWORD(Buffer));
300  }
301 }
CPPORT Port[4]
Definition: headless.c:34
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VOID IOWriteW(USHORT Port, USHORT Buffer)
Definition: io.c:206
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
EMULATOR_OUTD_PROC OutD
Definition: io.c:34
unsigned short USHORT
Definition: pedump.c:61
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
#define HIWORD(l)
Definition: typedefs.h:246
#define LOWORD(l)
Definition: pedump.c:82
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorWriteIo(), and IOWriteStrD().

◆ IOWriteStrB()

VOID IOWriteStrB ( USHORT  Port,
PUCHAR  Buffer,
ULONG  Count 
)

Definition at line 133 of file io.c.

136 {
138  IoPortProc[Port].IoHandlers.OutsB)
139  {
141  }
143  IoPortProc[Port].VddIoHandlers.outsb_handler)
144  {
145  ASSERT(Port <= MAXWORD);
146  ASSERT(Count <= MAXWORD);
148  }
149  else
150  {
151  while (Count--) IOWriteB(Port, *Buffer++);
152  }
153 }
CPPORT Port[4]
Definition: headless.c:34
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
EMULATOR_OUTSB_PROC OutsB
Definition: io.c:36
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
PFNVDD_OUTSB outsb_handler
Definition: nt_vdd.h:151
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorWriteIo().

◆ IOWriteStrD()

VOID IOWriteStrD ( USHORT  Port,
PULONG  Buffer,
ULONG  Count 
)

Definition at line 304 of file io.c.

307 {
309  IoPortProc[Port].IoHandlers.OutsD)
310  {
312  }
313  else
314  {
315  while (Count--) IOWriteD(Port, *Buffer++);
316  }
317 }
CPPORT Port[4]
Definition: headless.c:34
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
VOID IOWriteD(USHORT Port, ULONG Buffer)
Definition: io.c:287
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
EMULATOR_OUTSD_PROC OutsD
Definition: io.c:38
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorWriteIo().

◆ IOWriteStrW()

VOID IOWriteStrW ( USHORT  Port,
PUSHORT  Buffer,
ULONG  Count 
)

Definition at line 229 of file io.c.

232 {
234  IoPortProc[Port].IoHandlers.OutsW)
235  {
237  }
239  IoPortProc[Port].VddIoHandlers.outsw_handler)
240  {
241  ASSERT(Port <= MAXWORD);
242  ASSERT(Count <= MAXWORD);
244  }
245  else
246  {
247  while (Count--) IOWriteW(Port, *Buffer++);
248  }
249 }
CPPORT Port[4]
Definition: headless.c:34
#define MAXWORD
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
PFNVDD_OUTSW outsw_handler
Definition: nt_vdd.h:152
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
VOID IOWriteW(USHORT Port, USHORT Buffer)
Definition: io.c:206
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
EMULATOR_OUTSW_PROC OutsW
Definition: io.c:37
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorWriteIo().

◆ IOWriteW()

VOID IOWriteW ( USHORT  Port,
USHORT  Buffer 
)

Definition at line 206 of file io.c.

208 {
210  IoPortProc[Port].IoHandlers.OutW)
211  {
213  }
215  IoPortProc[Port].VddIoHandlers.outw_handler)
216  {
217  ASSERT(Port <= MAXWORD);
219  }
220  else
221  {
222  // FIXME: Is it ok on Little endian and Big endian ??
224  IOWriteB(Port + sizeof(UCHAR), HIBYTE(Buffer));
225  }
226 }
CPPORT Port[4]
Definition: headless.c:34
#define LOBYTE(W)
Definition: jmemdos.c:487
#define MAXWORD
#define HIBYTE(W)
Definition: jmemdos.c:486
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
EMULATOR_OUTW_PROC OutW
Definition: io.c:33
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
Definition: bufpool.h:45
VOID IOWriteB(USHORT Port, UCHAR Buffer)
Definition: io.c:111
PFNVDD_OUTW outw_handler
Definition: nt_vdd.h:150
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
HANDLE hVdd
Definition: testvdd.c:87

Referenced by EmulatorWriteIo(), IOWriteD(), and IOWriteStrW().

◆ RegisterIoPort()

VOID RegisterIoPort ( USHORT  Port,
EMULATOR_INB_PROC  InHandler,
EMULATOR_OUTB_PROC  OutHandler 
)

Definition at line 320 of file io.c.

323 {
324  if (IoPortProc[Port].IoHandlers.InB == NULL)
325  IoPortProc[Port].IoHandlers.InB = InHandler;
326  else
327  DPRINT1("IoPortProc[0x%X].IoHandlers.InB already registered\n", Port);
328 
329  if (IoPortProc[Port].IoHandlers.OutB == NULL)
330  IoPortProc[Port].IoHandlers.OutB = OutHandler;
331  else
332  DPRINT1("IoPortProc[0x%X].IoHandlers.OutB already registered\n", Port);
333 
334  /* We hold the I/O port internally */
336 }
CPPORT Port[4]
Definition: headless.c:34
EMULATOR_OUTB_PROC OutB
Definition: io.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
EMULATOR_INB_PROC InB
Definition: io.c:24
#define DPRINT1
Definition: precomp.h:8
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59

Referenced by CmosInitialize(), DmaInitialize(), PicInitialize(), PitInitialize(), PpiInitialize(), PS2Initialize(), VgaInitialize(), and VgaWritePort().

◆ UnregisterIoPort()

VOID UnregisterIoPort ( USHORT  Port)

Definition at line 338 of file io.c.

339 {
340  /*
341  * Put automagically all the fields to zero:
342  * the hVdd gets unregistered as well as all the handlers.
343  */
344  // IoPortProc[Port] = {NULL};
346 }
CPPORT Port[4]
Definition: headless.c:34
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by VgaWritePort().

◆ VDDDeInstallIOHook()

VOID WINAPI VDDDeInstallIOHook ( IN HANDLE  hVdd,
IN WORD  cPortRange,
IN PVDD_IO_PORTRANGE  pPortRange 
)

Definition at line 565 of file io.c.

568 {
569  WORD i;
570 
571  /* Check validity of the VDD handle */
572  if (hVdd == NULL || hVdd == INVALID_HANDLE_VALUE)
573  {
575  return;
576  }
577 
578  /* Loop for each range of I/O ports */
579  while (cPortRange--)
580  {
581  /* Unregister the range of I/O ports */
582  for (i = pPortRange->First; i <= pPortRange->Last; ++i)
583  {
584  /*
585  * Don't do anything if we don't own the I/O port.
586  */
587  if (IoPortProc[i].hVdd != hVdd)
588  {
589  DPRINT1("IoPortProc[0x%X] owned by somebody else\n", i);
590  continue;
591  }
592 
593  /*
594  * Put automagically all the fields to zero:
595  * the hVdd gets unregistered as well as all the handlers.
596  */
597  // IoPortProc[i] = {NULL};
598  RtlZeroMemory(&IoPortProc[i], sizeof(IoPortProc[i]));
599  }
600 
601  /* Go to the next range */
602  ++pPortRange;
603  }
604 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
unsigned short WORD
Definition: ntddk_ex.h:93
#define SetLastError(x)
Definition: compat.h:409
#define DPRINT1
Definition: precomp.h:8
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
HANDLE hVdd
Definition: testvdd.c:87

◆ VDDInstallIOHook()

BOOL WINAPI VDDInstallIOHook ( IN HANDLE  hVdd,
IN WORD  cPortRange,
IN PVDD_IO_PORTRANGE  pPortRange,
IN PVDD_IO_HANDLERS  IoHandlers 
)

Definition at line 502 of file io.c.

506 {
507  WORD i;
508 
509  /* Check validity of the VDD handle */
510  if (hVdd == NULL || hVdd == INVALID_HANDLE_VALUE)
511  {
513  return FALSE;
514  }
515 
516  /* Loop for each range of I/O ports */
517  while (cPortRange--)
518  {
519  /* Register the range of I/O ports */
520  for (i = pPortRange->First; i <= pPortRange->Last; ++i)
521  {
522  /*
523  * Don't do anything if the I/O port is already
524  * handled internally or externally.
525  */
526  if (IoPortProc[i].hVdd != NULL)
527  {
528  DPRINT1("IoPortProc[0x%X] already registered\n", i);
529  continue;
530  }
531 
532  /* Register wrt. the VDD */
533  IoPortProc[i].hVdd = hVdd;
534 
535  /* Disable the internal handlers */
539 
543 
547 
551 
552  /* Save our handlers */
553  IoPortProc[i].VddIoHandlers = *IoHandlers;
554  }
555 
556  /* Go to the next range */
557  ++pPortRange;
558  }
559 
560  return TRUE;
561 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
EMULATOR_OUTB_PROC OutB
Definition: io.c:32
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VDD_IO_HANDLERS VddIoHandlers
Definition: io.c:49
EMULATOR_INW_PROC InW
Definition: io.c:25
EMULATOR_INSB_PROC InsB
Definition: io.c:28
EMULATOR_OUTW_PROC OutW
Definition: io.c:33
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
EMULATOR_OUTSB_PROC OutsB
Definition: io.c:36
smooth NULL
Definition: ftsmooth.c:416
EMULATOR_IND_PROC InD
Definition: io.c:26
EMULATOR_IO_HANDLERS IoHandlers
Definition: io.c:52
EMULATOR_OUTD_PROC OutD
Definition: io.c:34
unsigned short WORD
Definition: ntddk_ex.h:93
#define SetLastError(x)
Definition: compat.h:409
EMULATOR_OUTSW_PROC OutsW
Definition: io.c:37
EMULATOR_INB_PROC InB
Definition: io.c:24
EMULATOR_INSD_PROC InsD
Definition: io.c:30
#define DPRINT1
Definition: precomp.h:8
EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM]
Definition: io.c:59
EMULATOR_INSW_PROC InsW
Definition: io.c:29
EMULATOR_OUTSD_PROC OutsD
Definition: io.c:38
HANDLE hVdd
Definition: testvdd.c:87

Variable Documentation

◆ IoPortProc