ReactOS  0.4.14-dev-593-g1793dcc
condrv.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "dos.h"
#include "dos/dem.h"
#include "bios/bios.h"
Include dependency graph for condrv.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

WORD NTAPI ConDrvReadInput (PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
 
WORD NTAPI ConDrvInputStatus (PDOS_DEVICE_NODE Device)
 
WORD NTAPI ConDrvWriteOutput (PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
 
WORD NTAPI ConDrvOpen (PDOS_DEVICE_NODE Device)
 
WORD NTAPI ConDrvClose (PDOS_DEVICE_NODE Device)
 
VOID ConDrvInitialize (VOID)
 
VOID ConDrvCleanup (VOID)
 

Variables

PDOS_DEVICE_NODE Con = NULL
 
BYTE ExtendedCode = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file condrv.c.

Function Documentation

◆ ConDrvCleanup()

VOID ConDrvCleanup ( VOID  )

Definition at line 147 of file condrv.c.

148 {
149  if (Con) DosDeleteDevice(Con);
150 }
VOID DosDeleteDevice(PDOS_DEVICE_NODE DeviceNode)
Definition: device.c:419
PDOS_DEVICE_NODE Con
Definition: condrv.c:26

◆ ConDrvClose()

WORD NTAPI ConDrvClose ( PDOS_DEVICE_NODE  Device)

Definition at line 124 of file condrv.c.

125 {
126  DPRINT("Handle to %Z closed\n", &Device->Name);
127  return DOS_DEVSTAT_DONE;
128 }
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
void DPRINT(...)
Definition: polytest.cpp:61
#define DOS_DEVSTAT_DONE
Definition: device.h:49

Referenced by ConDrvInitialize(), and DriverEntry().

◆ ConDrvInitialize()

VOID ConDrvInitialize ( VOID  )

Definition at line 132 of file condrv.c.

133 {
138  "CON");
139 
145 }
#define DOS_DEVATTR_CON
Definition: device.h:25
WORD NTAPI ConDrvInputStatus(PDOS_DEVICE_NODE Device)
Definition: condrv.c:79
WORD NTAPI ConDrvClose(PDOS_DEVICE_NODE Device)
Definition: condrv.c:124
PDOS_DEVICE_NODE DosCreateDevice(WORD Attributes, PCHAR DeviceName)
Definition: device.c:413
PDOS_DEVICE_GENERIC_ROUTINE OpenRoutine
Definition: device.h:101
PDOS_DEVICE_IO_ROUTINE WriteRoutine
Definition: device.h:98
WORD NTAPI ConDrvReadInput(PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
Definition: condrv.c:31
PDOS_DEVICE_NODE Con
Definition: condrv.c:26
PDOS_DEVICE_GENERIC_ROUTINE CloseRoutine
Definition: device.h:102
WORD NTAPI ConDrvWriteOutput(PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
Definition: condrv.c:96
#define DOS_DEVATTR_CHARACTER
Definition: device.h:29
WORD NTAPI ConDrvOpen(PDOS_DEVICE_NODE Device)
Definition: condrv.c:118
PDOS_DEVICE_GENERIC_ROUTINE InputStatusRoutine
Definition: device.h:95
PDOS_DEVICE_IO_ROUTINE ReadRoutine
Definition: device.h:93
#define DOS_DEVATTR_STDOUT
Definition: device.h:22
#define DOS_DEVATTR_STDIN
Definition: device.h:21

Referenced by DosKRNLInitialize().

◆ ConDrvInputStatus()

WORD NTAPI ConDrvInputStatus ( PDOS_DEVICE_NODE  Device)

Definition at line 79 of file condrv.c.

80 {
81  /* Save AX */
82  USHORT AX = getAX();
83 
84  /* Call the BIOS */
85  setAH(0x01); // or 0x11 for enhanced, but what to choose?
87 
88  /* Restore AX */
89  setAX(AX);
90 
91  /* If ZF is set, set the busy bit */
92  if (getZF() && !ExtendedCode) return DOS_DEVSTAT_BUSY;
93  else return DOS_DEVSTAT_DONE;
94 }
VOID WINAPI setAH(UCHAR)
Definition: registers.c:135
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
#define AX
Definition: i386-dis.c:415
BYTE ExtendedCode
Definition: condrv.c:27
ULONG WINAPI getZF(VOID)
Definition: registers.c:608
CALLBACK16 DosContext
Definition: dos.c:40
USHORT WINAPI getAX(VOID)
Definition: registers.c:114
#define DOS_DEVSTAT_DONE
Definition: device.h:49
#define DOS_DEVSTAT_BUSY
Definition: device.h:50
unsigned short USHORT
Definition: pedump.c:61
#define BIOS_KBD_INTERRUPT
Definition: kbdbios.h:14

Referenced by ConDrvInitialize().

◆ ConDrvOpen()

WORD NTAPI ConDrvOpen ( PDOS_DEVICE_NODE  Device)

Definition at line 118 of file condrv.c.

119 {
120  DPRINT("Handle to %Z opened\n", &Device->Name);
121  return DOS_DEVSTAT_DONE;
122 }
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
void DPRINT(...)
Definition: polytest.cpp:61
#define DOS_DEVSTAT_DONE
Definition: device.h:49

Referenced by ConDrvInitialize().

◆ ConDrvReadInput()

WORD NTAPI ConDrvReadInput ( PDOS_DEVICE_NODE  Device,
DWORD  Buffer,
PWORD  Length 
)

Definition at line 31 of file condrv.c.

32 {
33  CHAR Character;
34  WORD BytesRead = 0;
35  PCHAR Pointer = (PCHAR)FAR_POINTER(Buffer);
36 
37  /* Save AX */
38  USHORT AX = getAX();
39 
40  /*
41  * Use BIOS Get Keystroke function
42  */
43  while (BytesRead < *Length)
44  {
45  if (!ExtendedCode)
46  {
47  /* Call the BIOS INT 16h, AH=00h "Get Keystroke" */
48  setAH(0x00);
50 
51  /* Retrieve the character in AL (scan code is in AH) */
52  Character = getAL();
53  }
54  else
55  {
56  /* Return the extended code */
57  Character = ExtendedCode;
58 
59  /* And then clear it */
60  ExtendedCode = 0;
61  }
62 
63  /* Check if this is a special character */
64  if (Character == 0) ExtendedCode = getAH();
65 
66  Pointer[BytesRead++] = Character;
67 
68  /* Stop on first carriage return */
69  if (Character == '\r') break;
70  }
71 
72  *Length = BytesRead;
73 
74  /* Restore AX */
75  setAX(AX);
76  return DOS_DEVSTAT_DONE;
77 }
signed char * PCHAR
Definition: retypes.h:7
VOID WINAPI setAH(UCHAR)
Definition: registers.c:135
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
char CHAR
Definition: xmlstorage.h:175
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
#define AX
Definition: i386-dis.c:415
UCHAR WINAPI getAH(VOID)
Definition: registers.c:128
BYTE ExtendedCode
Definition: condrv.c:27
UCHAR WINAPI getAL(VOID)
Definition: registers.c:142
CALLBACK16 DosContext
Definition: dos.c:40
Definition: bufpool.h:45
#define FAR_POINTER(x)
Definition: emulator.h:31
#define PCHAR
Definition: match.c:90
unsigned short WORD
Definition: ntddk_ex.h:93
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
USHORT WINAPI getAX(VOID)
Definition: registers.c:114
#define DOS_DEVSTAT_DONE
Definition: device.h:49
unsigned short USHORT
Definition: pedump.c:61
#define BIOS_KBD_INTERRUPT
Definition: kbdbios.h:14
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

Referenced by ConDrvInitialize().

◆ ConDrvWriteOutput()

WORD NTAPI ConDrvWriteOutput ( PDOS_DEVICE_NODE  Device,
DWORD  Buffer,
PWORD  Length 
)

Definition at line 96 of file condrv.c.

97 {
99  PCHAR Pointer = (PCHAR)FAR_POINTER(Buffer);
100 
101  /* Save AX */
102  USHORT AX = getAX();
103 
105  {
106  /* Set the character */
107  setAL(Pointer[BytesWritten]);
108 
109  /* Call the BIOS INT 29h "Fast Console Output" function */
110  Int32Call(&DosContext, 0x29);
111  }
112 
113  /* Restore AX */
114  setAX(AX);
115  return DOS_DEVSTAT_DONE;
116 }
signed char * PCHAR
Definition: retypes.h:7
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
VOID WINAPI setAX(USHORT)
Definition: registers.c:121
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
VOID WINAPI setAL(UCHAR)
Definition: registers.c:149
#define AX
Definition: i386-dis.c:415
CALLBACK16 DosContext
Definition: dos.c:40
Definition: bufpool.h:45
#define FAR_POINTER(x)
Definition: emulator.h:31
#define PCHAR
Definition: match.c:90
unsigned short WORD
Definition: ntddk_ex.h:93
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
USHORT WINAPI getAX(VOID)
Definition: registers.c:114
#define DOS_DEVSTAT_DONE
Definition: device.h:49
unsigned short USHORT
Definition: pedump.c:61

Referenced by ConDrvInitialize().

Variable Documentation

◆ Con

◆ ExtendedCode

BYTE ExtendedCode = 0

Definition at line 27 of file condrv.c.

Referenced by ConDrvInputStatus(), and ConDrvReadInput().