[NTVDM]
[reactos.git] / reactos / subsystems / mvdm / ntvdm / dos / dos32krnl / dos.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: dos/dos32krnl/dos.h
5 * PURPOSE: DOS32 Kernel
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 #ifndef _DOS_H_
10 #define _DOS_H_
11
12 /* INCLUDES *******************************************************************/
13
14 #include "device.h"
15
16 /**/ #include "int32.h" /**/
17
18 /* DEFINES ********************************************************************/
19
20 //
21 // We are DOS 5.00 (reported by INT 21h, AH=30h)
22 // and DOS 5.50 (reported by INT 21h, AX=3306h) for Windows NT Compatibility
23 //
24 #define DOS_VERSION MAKEWORD(5, 00)
25 #define NTDOS_VERSION MAKEWORD(5, 50)
26
27 #define DOS_CONFIG_PATH L"%SystemRoot%\\system32\\CONFIG.NT"
28 #define DOS_COMMAND_INTERPRETER L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"
29 #define FIRST_MCB_SEGMENT 0x1000
30 #define USER_MEMORY_SIZE (0x9FFE - FIRST_MCB_SEGMENT)
31 #define SYSTEM_PSP 0x08
32 #define SYSTEM_ENV_BLOCK 0x800
33 #define DOS_CODE_SEGMENT 0x70
34 #define DOS_DATA_SEGMENT 0xA0
35 #define MASTER_SFT_OFFSET 0x100
36
37 #define INVALID_DOS_HANDLE 0xFFFF
38 #define DOS_INPUT_HANDLE 0
39 #define DOS_OUTPUT_HANDLE 1
40 #define DOS_ERROR_HANDLE 2
41
42 #define DOS_SFT_SIZE 255
43 #define UMB_START_SEGMENT 0xC000
44 #define UMB_END_SEGMENT 0xDFFF
45 #define DOS_ALLOC_HIGH 0x40
46 #define DOS_ALLOC_HIGH_LOW 0x80
47 #define DOS_DIR_LENGTH 64
48 #define NUM_DRIVES ('Z' - 'A' + 1)
49 #define DOS_CHAR_ATTRIBUTE 0x07
50
51 /* 16 MB of EMS memory */
52 #define EMS_TOTAL_PAGES 1024
53
54 #pragma pack(push, 1)
55
56 typedef struct _DOS_FCB
57 {
58 BYTE DriveNumber;
59 CHAR FileName[8];
60 CHAR FileExt[3];
61 WORD BlockNumber;
62 WORD RecordSize;
63 DWORD FileSize;
64 WORD LastWriteDate;
65 WORD LastWriteTime;
66 BYTE Reserved[8];
67 BYTE BlockRecord;
68 BYTE RecordNumber[3];
69 } DOS_FCB, *PDOS_FCB;
70
71 typedef struct _DOS_SYSVARS
72 {
73 DWORD OemHandler;
74 WORD Int21hReturn;
75 WORD ShareRetryCount;
76 WORD ShareRetryDelay;
77 DWORD DiskBuffer;
78 WORD UnreadConInput;
79 WORD FirstMcb;
80
81 /* This is where the SYSVARS really start */
82 DWORD FirstDpb;
83 DWORD FirstSft;
84 DWORD ActiveClock;
85 DWORD ActiveCon;
86 BYTE Reserved0[6];
87 DWORD CurrentDirs;
88 BYTE Reserved1[6];
89 BYTE NumBlockDevices;
90 BYTE NumLocalDrives;
91 DOS_DRIVER NullDevice;
92 BYTE NullDriverRoutine[7];
93 } DOS_SYSVARS, *PDOS_SYSVARS;
94
95 typedef struct _DOS_INPUT_BUFFER
96 {
97 BYTE MaxLength;
98 BYTE Length;
99 CHAR Buffer[ANYSIZE_ARRAY];
100 } DOS_INPUT_BUFFER, *PDOS_INPUT_BUFFER;
101
102 typedef struct _DOS_FIND_FILE_BLOCK
103 {
104 CHAR DriveLetter;
105 CHAR Pattern[11];
106 UCHAR AttribMask;
107 DWORD Unused;
108 HANDLE SearchHandle;
109
110 /* The following part of the structure is documented */
111 UCHAR Attributes;
112 WORD FileTime;
113 WORD FileDate;
114 DWORD FileSize;
115 CHAR FileName[13];
116 } DOS_FIND_FILE_BLOCK, *PDOS_FIND_FILE_BLOCK;
117
118 typedef struct _DOS_COUNTRY_CODE_BUFFER
119 {
120 WORD TimeFormat;
121 WORD CurrencySymbol;
122 WORD ThousandSep;
123 WORD DecimalSep;
124 } DOS_COUNTRY_CODE_BUFFER, *PDOS_COUNTRY_CODE_BUFFER;
125
126 #pragma pack(pop)
127
128 /* VARIABLES ******************************************************************/
129
130 extern BOOLEAN DoEcho;
131 extern DWORD DiskTransferArea;
132 extern WORD DosErrorLevel;
133 extern WORD DosLastError;
134 extern PDOS_SYSVARS SysVars;
135
136 /* FUNCTIONS ******************************************************************/
137
138 extern CALLBACK16 DosContext;
139 #define RegisterDosInt32(IntNumber, IntHandler) \
140 do { \
141 DosContext.NextOffset += RegisterInt32(MAKELONG(DosContext.NextOffset, \
142 DosContext.Segment), \
143 (IntNumber), (IntHandler), NULL); \
144 } while(0);
145
146 /*
147 * DOS BIOS Functions
148 * See bios.c
149 */
150 CHAR DosReadCharacter(WORD FileHandle);
151 BOOLEAN DosCheckInput(VOID);
152 VOID DosPrintCharacter(WORD FileHandle, CHAR Character);
153
154 BOOLEAN DosBIOSInitialize(VOID);
155 VOID ConDrvInitialize(VOID);
156 VOID ConDrvCleanup(VOID);
157
158 /*
159 * DOS Kernel Functions
160 * See dos.c
161 */
162
163 BOOLEAN DosKRNLInitialize(VOID);
164
165 #endif // _DOS_H_
166
167 /* EOF */