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>
12 /* INCLUDES *******************************************************************/
16 /**/ #include "int32.h" /**/
18 /* DEFINES ********************************************************************/
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
24 #define DOS_VERSION MAKEWORD(5, 00)
25 #define NTDOS_VERSION MAKEWORD(5, 50)
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
36 #define DOS_DATA_OFFSET(x) FIELD_OFFSET(DOS_DATA, x)
38 #define INVALID_DOS_HANDLE 0xFFFF
39 #define DOS_INPUT_HANDLE 0
40 #define DOS_OUTPUT_HANDLE 1
41 #define DOS_ERROR_HANDLE 2
43 #define DOS_SFT_SIZE 255
44 #define UMB_START_SEGMENT 0xC000
45 #define UMB_END_SEGMENT 0xDFFF
46 #define DOS_ALLOC_HIGH 0x40
47 #define DOS_ALLOC_HIGH_LOW 0x80
48 #define DOS_DIR_LENGTH 64
49 #define NUM_DRIVES ('Z' - 'A' + 1)
50 #define DOS_CHAR_ATTRIBUTE 0x07
52 /* 16 MB of EMS memory */
53 #define EMS_TOTAL_PAGES 1024
57 typedef struct _DOS_FCB
72 typedef struct _DOS_SYSVARS
82 /* This is where the SYSVARS really start */
91 BYTE NumLocalDrives
; // Set by LASTDRIVE
92 DOS_DRIVER NullDevice
;
93 BYTE NullDriverRoutine
[7];
98 } DOS_SYSVARS
, *PDOS_SYSVARS
;
100 typedef struct _DOS_CLOCK_TRANSFER_RECORD
107 } DOS_CLOCK_TRANSFER_RECORD
, *PDOS_CLOCK_TRANSFER_RECORD
;
109 typedef struct _DOS_INPUT_BUFFER
113 CHAR Buffer
[ANYSIZE_ARRAY
];
114 } DOS_INPUT_BUFFER
, *PDOS_INPUT_BUFFER
;
116 typedef struct _DOS_FIND_FILE_BLOCK
124 /* The following part of the structure is documented */
130 } DOS_FIND_FILE_BLOCK
, *PDOS_FIND_FILE_BLOCK
;
132 typedef struct _DOS_SDA
134 BYTE PrinterEchoFlag
;
135 CHAR CurrentSwitchChar
;
139 /* This is where the SDA really starts */
145 BYTE LastErrorAction
;
147 DWORD LastErrorPointer
;
148 DWORD DiskTransferArea
;
150 WORD Int23StackPointer
;
153 BYTE ExtendedBreakFlag
;
155 /* This part is only valid while in DOS */
158 WORD NetworkMachineNumber
;
163 WORD LastSearchDirEntry
;
174 BYTE ConsoleSwappedFlag
;
177 DOS_RW_REQUEST Request
;
178 DWORD DriverEntryPoint
;
185 DOS_CLOCK_TRANSFER_RECORD ClockTransferRecord
;
188 CHAR FileNameBuffer
[256];
190 CHAR CurrentDirectory
[81];
191 CHAR FcbFilename
[12];
192 CHAR FcbRenameDest
[12];
194 BYTE ExtendedAttribute
;
196 BYTE DirSearchAttributes
;
199 BYTE DeviceNameFound
;
204 BYTE ParsedFcbExists
;
206 BYTE TerminationType
;
208 BYTE FileDeletedChar
;
209 DWORD CriticalErrorDpb
;
210 DWORD UserRegistersStack
;
211 WORD Int24StackPointer
;
215 DWORD CurrentDirPointer
;
230 } DOS_SDA
, *PDOS_SDA
;
232 typedef struct _DOS_DATA
236 CHAR CurrentDirectories
[NUM_DRIVES
][DOS_DIR_LENGTH
];
237 BYTE Sft
[ANYSIZE_ARRAY
];
238 } DOS_DATA
, *PDOS_DATA
;
242 /* VARIABLES ******************************************************************/
244 extern BOOLEAN DoEcho
;
245 extern WORD DosErrorLevel
;
246 extern WORD DosLastError
;
247 extern PDOS_SYSVARS SysVars
;
250 /* FUNCTIONS ******************************************************************/
252 extern CALLBACK16 DosContext
;
253 #define RegisterDosInt32(IntNumber, IntHandler) \
255 DosContext.NextOffset += RegisterInt32(MAKELONG(DosContext.NextOffset, \
256 DosContext.Segment), \
257 (IntNumber), (IntHandler), NULL); \
264 CHAR
DosReadCharacter(WORD FileHandle
);
265 BOOLEAN
DosCheckInput(VOID
);
266 VOID
DosPrintCharacter(WORD FileHandle
, CHAR Character
);
268 BOOLEAN
DosBIOSInitialize(VOID
);
269 VOID
ConDrvInitialize(VOID
);
270 VOID
ConDrvCleanup(VOID
);
273 * DOS Kernel Functions
277 BOOLEAN
DosKRNLInitialize(VOID
);