ReactOS 0.4.16-dev-320-g3bd9ddc
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}
PDOS_DEVICE_NODE Con
Definition: condrv.c:26
VOID DosDeleteDevice(PDOS_DEVICE_NODE DeviceNode)
Definition: device.c:419

◆ 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}
#define DPRINT
Definition: sndvol32.h:73
#define DOS_DEVSTAT_DONE
Definition: device.h:49
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

Referenced by ConDrvInitialize(), and DriverEntry().

◆ ConDrvInitialize()

VOID ConDrvInitialize ( VOID  )

Definition at line 132 of file condrv.c.

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

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}
CALLBACK16 DosContext
Definition: dos.c:40
#define AX
Definition: i386-dis.c:424
VOID Int32Call(IN PCALLBACK16 Context, IN BYTE IntNumber)
Definition: int32.c:151
#define BIOS_KBD_INTERRUPT
Definition: kbdbios.h:14
unsigned short USHORT
Definition: pedump.c:61
BYTE ExtendedCode
Definition: condrv.c:27
#define DOS_DEVSTAT_BUSY
Definition: device.h:50
ULONG WINAPI getZF(VOID)
Definition: registers.c:608
VOID WINAPI setAH(UCHAR)
Definition: registers.c:135
USHORT WINAPI getAX(VOID)
Definition: registers.c:114
VOID WINAPI setAX(USHORT)
Definition: registers.c:121

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}

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
73
74 /* Restore AX */
75 setAX(AX);
76 return DOS_DEVSTAT_DONE;
77}
Definition: bufpool.h:45
#define FAR_POINTER(x)
Definition: emulator.h:35
unsigned short WORD
Definition: ntddk_ex.h:93
#define PCHAR
Definition: match.c:90
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
char * PCHAR
Definition: typedefs.h:51
UCHAR WINAPI getAL(VOID)
Definition: registers.c:142
UCHAR WINAPI getAH(VOID)
Definition: registers.c:128
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
char CHAR
Definition: xmlstorage.h:175

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}
VOID WINAPI setAL(UCHAR)
Definition: registers.c:149
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960

Referenced by ConDrvInitialize().

Variable Documentation

◆ Con

◆ ExtendedCode

BYTE ExtendedCode = 0

Definition at line 27 of file condrv.c.

Referenced by ConDrvInputStatus(), and ConDrvReadInput().