ReactOS  0.4.14-dev-297-g23e575c
device.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: GPLv2+ - See COPYING in the top level directory
3  * PROJECT: ReactOS Virtual DOS Machine
4  * FILE: subsystems/mvdm/ntvdm/dos/dos32krnl/device.h
5  * PURPOSE: DOS Device Support
6  * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7  */
8 
9 #ifndef _DEVICE_H_
10 #define _DEVICE_H_
11 
12 /* DEFINITIONS ****************************************************************/
13 
14 #define MAX_DEVICE_NAME 8
15 #define DEVICE_CODE_SIZE 10
16 #define DEVICE_PRIVATE_AREA(Driver) (Driver + sizeof(DOS_DRIVER) + DEVICE_CODE_SIZE)
17 
18 #define BOP_DRV_STRATEGY 0x42
19 #define BOP_DRV_INTERRUPT 0x43
20 
21 #define DOS_DEVATTR_STDIN (1 << 0)
22 #define DOS_DEVATTR_STDOUT (1 << 1)
23 #define DOS_DEVATTR_NUL (1 << 2)
24 #define DOS_DEVATTR_CLOCK (1 << 3)
25 #define DOS_DEVATTR_CON (1 << 4)
26 #define DOS_DEVATTR_OPENCLOSE (1 << 11)
27 #define DOS_DEVATTR_SPECIAL (1 << 13)
28 #define DOS_DEVATTR_IOCTL (1 << 14)
29 #define DOS_DEVATTR_CHARACTER (1 << 15)
30 
31 #define DOS_DEVCMD_INIT 0
32 #define DOS_DEVCMD_MEDIACHK 1
33 #define DOS_DEVCMD_BUILDBPB 2
34 #define DOS_DEVCMD_IOCTL_READ 3
35 #define DOS_DEVCMD_READ 4
36 #define DOS_DEVCMD_PEEK 5
37 #define DOS_DEVCMD_INSTAT 6
38 #define DOS_DEVCMD_FLUSH_INPUT 7
39 #define DOS_DEVCMD_WRITE 8
40 #define DOS_DEVCMD_WRITE_VERIFY 9
41 #define DOS_DEVCMD_OUTSTAT 10
42 #define DOS_DEVCMD_FLUSH_OUTPUT 11
43 #define DOS_DEVCMD_IOCTL_WRITE 12
44 #define DOS_DEVCMD_OPEN 13
45 #define DOS_DEVCMD_CLOSE 14
46 #define DOS_DEVCMD_REMOVABLE 15
47 #define DOS_DEVCMD_OUTPUT_BUSY 16
48 
49 #define DOS_DEVSTAT_DONE (1 << 8)
50 #define DOS_DEVSTAT_BUSY (1 << 9)
51 #define DOS_DEVSTAT_ERROR (1 << 15)
52 
53 #define DOS_DEVERR_WRITE_PROTECT 0
54 #define DOS_DEVERR_UNKNOWN_UNIT 1
55 #define DOS_DEVERR_NOT_READY 2
56 #define DOS_DEVERR_UNKNOWN_COMMAND 3
57 #define DOS_DEVERR_BAD_DATA_CRC 4
58 #define DOS_DEVERR_BAD_REQUEST 5
59 #define DOS_DEVERR_INVALID_SEEK 6
60 #define DOS_DEVERR_UNKNOWN_MEDIUM 7
61 #define DOS_DEVERR_BAD_BLOCK 8
62 #define DOS_DEVERR_OUT_OF_PAPER 9
63 #define DOS_DEVERR_WRITE_FAULT 10
64 #define DOS_DEVERR_READ_FAULT 11
65 #define DOS_DEVERR_GENERAL 12
66 #define DOS_DEVERR_BAD_MEDIA_CHANGE 15
67 
69 
71 
73 (
75  DWORD Buffer,
77 );
78 
80 (
82  PBYTE Character
83 );
84 
86 {
104 };
105 
106 #pragma pack(push, 1)
107 
108 typedef struct _DOS_DRIVER
109 {
114 
115  union
116  {
117  CHAR DeviceName[MAX_DEVICE_NAME]; // for character devices
118 
119  struct // for block devices
120  {
123  };
124  };
126 C_ASSERT(sizeof(DOS_DRIVER) == 0x12);
127 
128 typedef struct _DOS_REQUEST_HEADER
129 {
131  IN BYTE UnitNumber OPTIONAL;
134 
137 
138 typedef struct _DOS_INIT_REQUEST
139 {
141 
144 
145  union
146  {
147  IN DWORD DeviceString; // for character devices
148 
149  struct // for block devices
150  {
153  };
154  };
155 
157 
158 typedef struct _DOS_IOCTL_RW_REQUEST
159 {
161 
162  IN BYTE MediaDescriptorByte OPTIONAL;
165  IN WORD StartingBlock OPTIONAL;
167 
168 typedef struct _DOS_RW_REQUEST
169 {
171 
172  IN BYTE MediaDescriptorByte OPTIONAL;
175  IN WORD StartingBlock OPTIONAL;
176  OUT DWORD VolumeLabelPtr OPTIONAL;
178 
179 typedef struct _DOS_PEEK_REQUEST
180 {
184 
186 {
188 
192 
193 #pragma pack(pop)
194 
195 /* FUNCTIONS ******************************************************************/
196 
201 (
204  WORD PrivateDataSize
205 );
209 DWORD DosLoadDriver(LPCSTR DriverFile);
210 
211 #endif /* _DEVICE_H_ */
struct _DOS_DRIVER * PDOS_DRIVER
signed char * PCHAR
Definition: retypes.h:7
OUT BYTE Character
Definition: device.h:182
IN BYTE MediaDescriptorByte OPTIONAL
Definition: device.h:162
#define IN
Definition: typedefs.h:38
BYTE UnitCount
Definition: device.h:121
struct _DOS_OUTPUT_BUSY_REQUEST * PDOS_OUTPUT_BUSY_REQUEST
OUT DWORD BpbPointer
Definition: device.h:152
DWORD Link
Definition: device.h:110
OUT BYTE UnitsInitialized
Definition: device.h:142
CHAR DeviceName[MAX_DEVICE_NAME]
Definition: device.h:117
ANSI_STRING Name
Definition: device.h:90
PDOS_DEVICE_PEEK_ROUTINE PeekRoutine
Definition: device.h:94
#define MAX_DEVICE_NAME
Definition: device.h:14
char CHAR
Definition: xmlstorage.h:175
IN DWORD BufferPointer
Definition: device.h:173
PDOS_DEVICE_IO_ROUTINE IoctlReadRoutine
Definition: device.h:92
WORD(NTAPI * PDOS_DEVICE_IO_ROUTINE)(PDOS_DEVICE_NODE DeviceNode, DWORD Buffer, PWORD Length)
Definition: device.h:73
PDOS_DEVICE_NODE DosGetDevice(LPCSTR DeviceName)
Definition: device.c:342
struct _DOS_PEEK_REQUEST DOS_PEEK_REQUEST
PDOS_DEVICE_GENERIC_ROUTINE FlushOutputRoutine
Definition: device.h:100
WCHAR DeviceName[]
Definition: adapter.cpp:21
DOS_REQUEST_HEADER Header
Definition: device.h:140
struct _DOS_RW_REQUEST * PDOS_RW_REQUEST
PDOS_DEVICE_NODE DosCreateDeviceEx(WORD Attributes, PCHAR DeviceName, WORD PrivateDataSize)
Definition: device.c:361
struct _DOS_REQUEST_HEADER DOS_REQUEST_HEADER
IN BYTE UnitNumber OPTIONAL
Definition: device.h:131
VOID DeviceStrategyBop(VOID)
Definition: device.c:430
struct _DOS_DRIVER DOS_DRIVER
WORD DeviceAttributes
Definition: device.h:89
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _DOS_RW_REQUEST DOS_RW_REQUEST
WORD InterruptRoutine
Definition: device.h:113
DOS_REQUEST_HEADER Header
Definition: device.h:170
IN DWORD BufferPointer
Definition: device.h:163
DOS_REQUEST_HEADER Header
Definition: device.h:181
IN WORD StartingBlock OPTIONAL
Definition: device.h:175
IN OUT WORD Length
Definition: device.h:174
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
PDOS_DEVICE_GENERIC_ROUTINE OpenRoutine
Definition: device.h:101
PDOS_DEVICE_IO_ROUTINE OutputUntilBusyRoutine
Definition: device.h:103
const char * LPCSTR
Definition: xmlstorage.h:183
IN DWORD BufferPointer
Definition: device.h:189
_In_ PCUNICODE_STRING _In_ PVOID Driver
Definition: cmfuncs.h:32
OUT DWORD ReturnBreakAddress
Definition: device.h:143
PDOS_DEVICE_IO_ROUTINE WriteRoutine
Definition: device.h:98
struct _DOS_REQUEST_HEADER * PDOS_REQUEST_HEADER
WORD * PWORD
Definition: pedump.c:67
WORD(NTAPI * PDOS_DEVICE_PEEK_ROUTINE)(PDOS_DEVICE_NODE DeviceNode, PBYTE Character)
Definition: device.h:80
DOS_REQUEST_HEADER Header
Definition: device.h:187
struct _DOS_IOCTL_RW_REQUEST * PDOS_IOCTL_RW_REQUEST
DWORD DosLoadDriver(LPCSTR DriverFile)
Definition: device.c:571
LIST_ENTRY Entry
Definition: device.h:87
VOID DosDeleteDevice(PDOS_DEVICE_NODE DeviceNode)
Definition: device.c:419
IN BYTE RequestLength
Definition: device.h:130
PDOS_DEVICE_GENERIC_ROUTINE OutputStatusRoutine
Definition: device.h:99
DWORD Driver
Definition: device.h:88
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN BYTE CommandCode
Definition: device.h:132
OUT WORD Status
Definition: device.h:133
Definition: Node.h:9
IN BYTE MediaDescriptorByte OPTIONAL
Definition: device.h:172
struct _DOS_INIT_REQUEST DOS_INIT_REQUEST
struct _DOS_OUTPUT_BUSY_REQUEST DOS_OUTPUT_BUSY_REQUEST
DOS_REQUEST_HEADER Header
Definition: device.h:160
WORD(NTAPI * PDOS_DEVICE_GENERIC_ROUTINE)(PDOS_DEVICE_NODE DeviceNode)
Definition: device.h:70
PDOS_DEVICE_NODE DosCreateDevice(WORD Attributes, PCHAR DeviceName)
Definition: device.c:413
unsigned char BYTE
Definition: mem.h:68
IN OUT WORD Length
Definition: device.h:190
PDOS_DEVICE_GENERIC_ROUTINE CloseRoutine
Definition: device.h:102
Definition: typedefs.h:117
PDOS_DEVICE_GENERIC_ROUTINE FlushInputRoutine
Definition: device.h:96
WORD DeviceAttributes
Definition: device.h:111
struct _DOS_PEEK_REQUEST * PDOS_PEEK_REQUEST
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
CHAR NameBuffer[MAX_DEVICE_NAME]
Definition: device.h:91
OUT DWORD VolumeLabelPtr OPTIONAL
Definition: device.h:176
IN OUT WORD Length
Definition: device.h:164
PDOS_DEVICE_GENERIC_ROUTINE InputStatusRoutine
Definition: device.h:95
IN DWORD DeviceString
Definition: device.h:147
PDOS_DEVICE_NODE DosGetDriverNode(DWORD Driver)
Definition: device.c:305
struct _DOS_DEVICE_NODE * PDOS_DEVICE_NODE
Definition: device.h:68
#define OUT
Definition: typedefs.h:39
PDOS_DEVICE_IO_ROUTINE IoctlWriteRoutine
Definition: device.h:97
PDOS_DEVICE_IO_ROUTINE ReadRoutine
Definition: device.h:93
C_ASSERT(sizeof(DOS_DRIVER)==0x12)
IN WORD StartingBlock OPTIONAL
Definition: device.h:165
WORD StrategyRoutine
Definition: device.h:112
struct _DOS_IOCTL_RW_REQUEST DOS_IOCTL_RW_REQUEST
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
IN BYTE FirstDriveLetter
Definition: device.h:151
BYTE * PBYTE
Definition: pedump.c:66
struct _DOS_INIT_REQUEST * PDOS_INIT_REQUEST
VOID DeviceInterruptBop(VOID)
Definition: device.c:436