b88dadb397ee65968f2f42ee0419a2aac9632fdd
[reactos.git] / subsystems / ntvdm / dos.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: dos.h
5 * PURPOSE: VDM DOS Kernel (header file)
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 "ntvdm.h"
15
16 /* DEFINES ********************************************************************/
17
18 #define DOS_VERSION 0x0600
19 #define DOS_CONFIG_PATH L"%SystemRoot%\\system32\\CONFIG.NT"
20 #define DOS_COMMAND_INTERPRETER L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"
21 #define FIRST_MCB_SEGMENT 0x1000
22 #define USER_MEMORY_SIZE 0x8FFFF
23 #define SYSTEM_PSP 0x08
24 #define SYSTEM_ENV_BLOCK 0x800
25 #define SEGMENT_TO_MCB(seg) ((PDOS_MCB)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
26 #define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
27
28 #pragma pack(push, 1)
29
30 typedef struct _DOS_MCB
31 {
32 CHAR BlockType;
33 WORD OwnerPsp;
34 WORD Size;
35 BYTE Unused[3];
36 CHAR Name[8];
37 } DOS_MCB, *PDOS_MCB;
38
39 typedef struct _DOS_FCB
40 {
41 BYTE DriveNumber;
42 CHAR FileName[8];
43 CHAR FileExt[3];
44 WORD BlockNumber;
45 WORD RecordSize;
46 DWORD FileSize;
47 WORD LastWriteDate;
48 WORD LastWriteTime;
49 BYTE Reserved[8];
50 BYTE BlockRecord;
51 BYTE RecordNumber[3];
52 } DOS_FCB, *PDOS_FCB;
53
54 typedef struct _DOS_PSP
55 {
56 BYTE Exit[2];
57 WORD MemSize;
58 BYTE Reserved0[6];
59 DWORD TerminateAddress;
60 DWORD BreakAddress;
61 DWORD CriticalAddress;
62 WORD ParentPsp;
63 BYTE HandleTable[20];
64 WORD EnvBlock;
65 DWORD LastStack;
66 WORD HandleTableSize;
67 DWORD HandleTablePtr;
68 DWORD PreviousPsp;
69 DWORD Reserved1;
70 WORD DosVersion;
71 BYTE Reserved2[14];
72 BYTE FarCall[3];
73 BYTE Reserved3[9];
74 DOS_FCB Fcb;
75 BYTE CommandLineSize;
76 CHAR CommandLine[127];
77 } DOS_PSP, *PDOS_PSP;
78
79 typedef struct _DOS_SFT_ENTRY
80 {
81 WORD ReferenceCount;
82 WORD Mode;
83 BYTE Attribute;
84 WORD DeviceInfo;
85 DWORD DriveParamBlock;
86 WORD FirstCluster;
87 WORD FileTime;
88 WORD FileDate;
89 DWORD FileSize;
90 DWORD CurrentOffset;
91 WORD LastClusterAccessed;
92 DWORD DirEntSector;
93 BYTE DirEntryIndex;
94 CHAR FileName[11];
95 BYTE Reserved0[6];
96 WORD OwnerPsp;
97 BYTE Reserved1[8];
98 } DOS_SFT_ENTRY, *PDOS_SFT_ENTRY;
99
100 typedef struct _DOS_SFT
101 {
102 DWORD NextTablePtr;
103 WORD FileCount;
104 DOS_SFT_ENTRY Entry[ANYSIZE_ARRAY];
105 } DOS_SFT, *PDOS_SFT;
106
107 typedef struct _DOS_INPUT_BUFFER
108 {
109 BYTE MaxLength, Length;
110 CHAR Buffer[ANYSIZE_ARRAY];
111 } DOS_INPUT_BUFFER, *PDOS_INPUT_BUFFER;
112
113 #pragma pack(pop)
114
115 /* FUNCTIONS ******************************************************************/
116
117 WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable);
118 BOOLEAN DosResizeMemory(WORD BlockData, WORD NewSize, WORD *MaxAvailable);
119 BOOLEAN DosFreeMemory(WORD BlockData);
120 VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD Environment);
121 BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock);
122 VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode);
123 CHAR DosReadCharacter();
124 VOID DosPrintCharacter(CHAR Character);
125 VOID DosInt20h(WORD CodeSegment);
126 VOID DosInt21h(WORD CodeSegment);
127 VOID DosBreakInterrupt();
128 BOOLEAN DosInitialize();
129
130 #endif
131
132 /* EOF */
133