ReactOS 0.4.15-dev-8236-g99f0937
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(
77);
78
80(
82 PBYTE Character
83);
84
86{
104};
105
106#pragma pack(push, 1)
107
108typedef 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 };
126C_ASSERT(sizeof(DOS_DRIVER) == 0x12);
127
129{
131 IN BYTE UnitNumber OPTIONAL;
134
137
138typedef 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
159{
161
162 IN BYTE MediaDescriptorByte OPTIONAL;
165 IN WORD StartingBlock OPTIONAL;
167
168typedef struct _DOS_RW_REQUEST
169{
171
172 IN BYTE MediaDescriptorByte OPTIONAL;
175 IN WORD StartingBlock OPTIONAL;
176 OUT DWORD VolumeLabelPtr OPTIONAL;
178
179typedef struct _DOS_PEEK_REQUEST
180{
184
186{
188
192
193#pragma pack(pop)
194
195/* FUNCTIONS ******************************************************************/
196
201(
204 WORD PrivateDataSize
205);
209DWORD DosLoadDriver(LPCSTR DriverFile);
210
211#endif /* _DEVICE_H_ */
@ DeviceNode
Definition: Node.h:9
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
#define C_ASSERT(e)
Definition: intsafe.h:73
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
WORD * PWORD
Definition: pedump.c:67
BYTE * PBYTE
Definition: pedump.c:66
PDOS_DEVICE_PEEK_ROUTINE PeekRoutine
Definition: device.h:94
PDOS_DEVICE_GENERIC_ROUTINE OpenRoutine
Definition: device.h:101
WORD DeviceAttributes
Definition: device.h:89
PDOS_DEVICE_IO_ROUTINE WriteRoutine
Definition: device.h:98
PDOS_DEVICE_IO_ROUTINE ReadRoutine
Definition: device.h:93
PDOS_DEVICE_IO_ROUTINE IoctlWriteRoutine
Definition: device.h:97
PDOS_DEVICE_IO_ROUTINE IoctlReadRoutine
Definition: device.h:92
CHAR NameBuffer[MAX_DEVICE_NAME]
Definition: device.h:91
PDOS_DEVICE_GENERIC_ROUTINE CloseRoutine
Definition: device.h:102
PDOS_DEVICE_IO_ROUTINE OutputUntilBusyRoutine
Definition: device.h:103
DWORD Driver
Definition: device.h:88
PDOS_DEVICE_GENERIC_ROUTINE OutputStatusRoutine
Definition: device.h:99
PDOS_DEVICE_GENERIC_ROUTINE InputStatusRoutine
Definition: device.h:95
PDOS_DEVICE_GENERIC_ROUTINE FlushOutputRoutine
Definition: device.h:100
ANSI_STRING Name
Definition: device.h:90
PDOS_DEVICE_GENERIC_ROUTINE FlushInputRoutine
Definition: device.h:96
LIST_ENTRY Entry
Definition: device.h:87
BYTE UnitCount
Definition: device.h:121
DWORD Link
Definition: device.h:110
WORD StrategyRoutine
Definition: device.h:112
WORD DeviceAttributes
Definition: device.h:111
WORD InterruptRoutine
Definition: device.h:113
OUT BYTE UnitsInitialized
Definition: device.h:142
OUT DWORD ReturnBreakAddress
Definition: device.h:143
DOS_REQUEST_HEADER Header
Definition: device.h:140
OUT DWORD BpbPointer
Definition: device.h:152
IN BYTE FirstDriveLetter
Definition: device.h:151
IN DWORD DeviceString
Definition: device.h:147
IN OUT WORD Length
Definition: device.h:164
IN DWORD BufferPointer
Definition: device.h:163
IN WORD StartingBlock OPTIONAL
Definition: device.h:165
IN BYTE MediaDescriptorByte OPTIONAL
Definition: device.h:162
DOS_REQUEST_HEADER Header
Definition: device.h:160
DOS_REQUEST_HEADER Header
Definition: device.h:187
IN OUT WORD Length
Definition: device.h:190
IN DWORD BufferPointer
Definition: device.h:189
DOS_REQUEST_HEADER Header
Definition: device.h:181
OUT BYTE Character
Definition: device.h:182
IN BYTE UnitNumber OPTIONAL
Definition: device.h:131
IN BYTE RequestLength
Definition: device.h:130
OUT WORD Status
Definition: device.h:133
IN BYTE CommandCode
Definition: device.h:132
IN BYTE MediaDescriptorByte OPTIONAL
Definition: device.h:172
IN DWORD BufferPointer
Definition: device.h:173
IN WORD StartingBlock OPTIONAL
Definition: device.h:175
OUT DWORD VolumeLabelPtr OPTIONAL
Definition: device.h:176
DOS_REQUEST_HEADER Header
Definition: device.h:170
IN OUT WORD Length
Definition: device.h:174
Definition: typedefs.h:120
struct _DOS_OUTPUT_BUSY_REQUEST DOS_OUTPUT_BUSY_REQUEST
PDOS_DEVICE_NODE DosGetDevice(LPCSTR DeviceName)
Definition: device.c:342
struct _DOS_IOCTL_RW_REQUEST DOS_IOCTL_RW_REQUEST
PDOS_DEVICE_NODE DosCreateDevice(WORD Attributes, PCHAR DeviceName)
Definition: device.c:413
struct _DOS_OUTPUT_BUSY_REQUEST * PDOS_OUTPUT_BUSY_REQUEST
#define MAX_DEVICE_NAME
Definition: device.h:14
VOID DosDeleteDevice(PDOS_DEVICE_NODE DeviceNode)
Definition: device.c:419
struct _DOS_INIT_REQUEST DOS_INIT_REQUEST
struct _DOS_IOCTL_RW_REQUEST * PDOS_IOCTL_RW_REQUEST
struct _DOS_PEEK_REQUEST DOS_PEEK_REQUEST
WORD(NTAPI * PDOS_DEVICE_GENERIC_ROUTINE)(PDOS_DEVICE_NODE DeviceNode)
Definition: device.h:70
WORD(NTAPI * PDOS_DEVICE_IO_ROUTINE)(PDOS_DEVICE_NODE DeviceNode, DWORD Buffer, PWORD Length)
Definition: device.h:73
PDOS_DEVICE_NODE DosCreateDeviceEx(WORD Attributes, PCHAR DeviceName, WORD PrivateDataSize)
Definition: device.c:361
struct _DOS_INIT_REQUEST * PDOS_INIT_REQUEST
struct _DOS_PEEK_REQUEST * PDOS_PEEK_REQUEST
struct _DOS_DRIVER DOS_DRIVER
struct _DOS_RW_REQUEST DOS_RW_REQUEST
WORD(NTAPI * PDOS_DEVICE_PEEK_ROUTINE)(PDOS_DEVICE_NODE DeviceNode, PBYTE Character)
Definition: device.h:80
struct _DOS_REQUEST_HEADER * PDOS_REQUEST_HEADER
struct _DOS_RW_REQUEST * PDOS_RW_REQUEST
VOID DeviceInterruptBop(VOID)
Definition: device.c:436
DWORD DosLoadDriver(LPCSTR DriverFile)
Definition: device.c:571
struct _DOS_DEVICE_NODE * PDOS_DEVICE_NODE
Definition: device.h:68
struct _DOS_REQUEST_HEADER DOS_REQUEST_HEADER
PDOS_DEVICE_NODE DosGetDriverNode(DWORD Driver)
Definition: device.c:305
VOID DeviceStrategyBop(VOID)
Definition: device.c:430
struct _DOS_DRIVER * PDOS_DRIVER
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
const char * LPCSTR
Definition: xmlstorage.h:183
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193