2013-06-26 22:58:41 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: GPL - See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Virtual DOS Machine
|
|
|
|
* FILE: dos.h
|
|
|
|
* PURPOSE: VDM DOS Kernel (header file)
|
|
|
|
* PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DOS_H_
|
|
|
|
#define _DOS_H_
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
|
|
|
#include "ntvdm.h"
|
|
|
|
|
|
|
|
/* DEFINES ********************************************************************/
|
|
|
|
|
2013-10-27 22:31:53 +00:00
|
|
|
//
|
|
|
|
// We are DOS 6.00
|
|
|
|
//
|
2013-06-28 20:52:40 +00:00
|
|
|
#define DOS_VERSION MAKEWORD(6, 0)
|
2013-10-27 22:31:53 +00:00
|
|
|
|
2013-06-26 22:58:41 +00:00
|
|
|
#define DOS_CONFIG_PATH L"%SystemRoot%\\system32\\CONFIG.NT"
|
|
|
|
#define DOS_COMMAND_INTERPRETER L"%SystemRoot%\\system32\\COMMAND.COM /k %SystemRoot%\\system32\\AUTOEXEC.NT"
|
|
|
|
#define FIRST_MCB_SEGMENT 0x1000
|
2013-07-18 12:31:11 +00:00
|
|
|
#define USER_MEMORY_SIZE 0x8FFE
|
2013-06-26 22:58:41 +00:00
|
|
|
#define SYSTEM_PSP 0x08
|
|
|
|
#define SYSTEM_ENV_BLOCK 0x800
|
2013-07-01 02:29:29 +00:00
|
|
|
#define INVALID_DOS_HANDLE 0xFFFF
|
2013-07-02 02:08:30 +00:00
|
|
|
#define DOS_INPUT_HANDLE 0
|
|
|
|
#define DOS_OUTPUT_HANDLE 1
|
|
|
|
#define DOS_ERROR_HANDLE 2
|
2013-07-01 02:29:29 +00:00
|
|
|
#define DOS_SFT_SIZE 255
|
2013-06-26 22:58:41 +00:00
|
|
|
#define SEGMENT_TO_MCB(seg) ((PDOS_MCB)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
|
|
|
|
#define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0)))
|
2013-07-18 11:44:06 +00:00
|
|
|
#define UMB_START_SEGMENT 0xC000
|
|
|
|
#define UMB_END_SEGMENT 0xDFFF
|
2013-07-20 06:14:13 +00:00
|
|
|
#define DOS_ALLOC_HIGH 0x40
|
|
|
|
#define DOS_ALLOC_HIGH_LOW 0x80
|
2013-08-07 19:56:28 +00:00
|
|
|
#define DOS_CMDLINE_LENGTH 127
|
2013-08-11 20:54:07 +00:00
|
|
|
#define DOS_DIR_LENGTH 64
|
|
|
|
#define NUM_DRIVES ('Z' - 'A' + 1)
|
2013-08-15 01:40:50 +00:00
|
|
|
#define DOS_CHAR_ATTRIBUTE 0x07
|
2013-07-20 06:14:13 +00:00
|
|
|
|
|
|
|
enum DOS_ALLOC_STRATEGY
|
|
|
|
{
|
|
|
|
DOS_ALLOC_FIRST_FIT,
|
|
|
|
DOS_ALLOC_BEST_FIT,
|
|
|
|
DOS_ALLOC_LAST_FIT
|
|
|
|
};
|
2013-06-26 22:58:41 +00:00
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
typedef struct _DOS_MCB
|
|
|
|
{
|
|
|
|
CHAR BlockType;
|
|
|
|
WORD OwnerPsp;
|
|
|
|
WORD Size;
|
|
|
|
BYTE Unused[3];
|
|
|
|
CHAR Name[8];
|
|
|
|
} DOS_MCB, *PDOS_MCB;
|
|
|
|
|
|
|
|
typedef struct _DOS_FCB
|
|
|
|
{
|
|
|
|
BYTE DriveNumber;
|
|
|
|
CHAR FileName[8];
|
|
|
|
CHAR FileExt[3];
|
|
|
|
WORD BlockNumber;
|
|
|
|
WORD RecordSize;
|
|
|
|
DWORD FileSize;
|
|
|
|
WORD LastWriteDate;
|
|
|
|
WORD LastWriteTime;
|
|
|
|
BYTE Reserved[8];
|
|
|
|
BYTE BlockRecord;
|
|
|
|
BYTE RecordNumber[3];
|
|
|
|
} DOS_FCB, *PDOS_FCB;
|
|
|
|
|
|
|
|
typedef struct _DOS_PSP
|
|
|
|
{
|
|
|
|
BYTE Exit[2];
|
2013-07-02 02:08:30 +00:00
|
|
|
WORD LastParagraph;
|
2013-06-26 22:58:41 +00:00
|
|
|
BYTE Reserved0[6];
|
|
|
|
DWORD TerminateAddress;
|
|
|
|
DWORD BreakAddress;
|
|
|
|
DWORD CriticalAddress;
|
|
|
|
WORD ParentPsp;
|
|
|
|
BYTE HandleTable[20];
|
|
|
|
WORD EnvBlock;
|
|
|
|
DWORD LastStack;
|
|
|
|
WORD HandleTableSize;
|
|
|
|
DWORD HandleTablePtr;
|
|
|
|
DWORD PreviousPsp;
|
|
|
|
DWORD Reserved1;
|
|
|
|
WORD DosVersion;
|
|
|
|
BYTE Reserved2[14];
|
|
|
|
BYTE FarCall[3];
|
|
|
|
BYTE Reserved3[9];
|
|
|
|
DOS_FCB Fcb;
|
|
|
|
BYTE CommandLineSize;
|
2013-08-07 19:56:28 +00:00
|
|
|
CHAR CommandLine[DOS_CMDLINE_LENGTH];
|
2013-06-26 22:58:41 +00:00
|
|
|
} DOS_PSP, *PDOS_PSP;
|
|
|
|
|
|
|
|
typedef struct _DOS_INPUT_BUFFER
|
|
|
|
{
|
[NTVDM]: DOS:
- The DosErrorLevel is stored as a WORD: its LOWORD is the return code and the HIWORD is the termination code.
- When copying CurrentDirectories[...], be sure that we copy maximum DOS_DIR_LENGTH chars.
- Implement (or stubplement) bunch of INT 21h functions: 0x03, 0x04, 0x05, 0x0C, 0x0D, 0x26, 0x37, 0x47, 0x4D and 0x50. Functions 0x18, 0x1D, 0x1E and 0x20 are NULL functions present in DOS for CP/M compatibility only.
- Fix DOS version querying.
- Use set/getAX() instead of EmulatorSet/GetRegister, and use setCF instead of EmulatorSetFlag.
svn path=/branches/ntvdm/; revision=60790
2013-10-29 01:55:54 +00:00
|
|
|
BYTE MaxLength;
|
|
|
|
BYTE Length;
|
2013-06-26 22:58:41 +00:00
|
|
|
CHAR Buffer[ANYSIZE_ARRAY];
|
|
|
|
} DOS_INPUT_BUFFER, *PDOS_INPUT_BUFFER;
|
|
|
|
|
2013-08-05 23:20:25 +00:00
|
|
|
typedef struct _DOS_DRIVER_HEADER
|
|
|
|
{
|
|
|
|
DWORD NextDriver;
|
|
|
|
WORD Attributes;
|
|
|
|
WORD StrategyEntry;
|
|
|
|
WORD InterruptEntry;
|
|
|
|
CHAR DeviceName[8];
|
|
|
|
} DOS_DRIVER_HEADER, *PDOS_DRIVER_HEADER;
|
|
|
|
|
2013-06-26 22:58:41 +00:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
|
|
|
WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable);
|
|
|
|
BOOLEAN DosResizeMemory(WORD BlockData, WORD NewSize, WORD *MaxAvailable);
|
|
|
|
BOOLEAN DosFreeMemory(WORD BlockData);
|
2013-07-01 02:29:29 +00:00
|
|
|
WORD DosCreateFile(LPWORD Handle, LPCSTR FilePath, WORD Attributes);
|
|
|
|
WORD DosOpenFile(LPWORD Handle, LPCSTR FilePath, BYTE AccessMode);
|
|
|
|
WORD DosReadFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesRead);
|
|
|
|
WORD DosWriteFile(WORD FileHandle, LPVOID Buffer, WORD Count, LPWORD BytesWritten);
|
2013-07-23 14:43:03 +00:00
|
|
|
WORD DosSeekFile(WORD FileHandle, LONG Offset, BYTE Origin, LPDWORD NewOffset);
|
|
|
|
BOOLEAN DosDuplicateHandle(WORD OldHandle, WORD NewHandle);
|
|
|
|
BOOLEAN DosCloseHandle(WORD DosHandle);
|
2013-06-26 22:58:41 +00:00
|
|
|
VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD Environment);
|
|
|
|
BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock);
|
|
|
|
VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode);
|
2013-07-18 12:31:11 +00:00
|
|
|
CHAR DosReadCharacter(VOID);
|
2013-06-26 22:58:41 +00:00
|
|
|
VOID DosPrintCharacter(CHAR Character);
|
2013-07-23 21:43:57 +00:00
|
|
|
BOOLEAN DosHandleIoctl(BYTE ControlCode, WORD FileHandle);
|
|
|
|
VOID DosInt20h(LPWORD Stack);
|
|
|
|
VOID DosInt21h(LPWORD Stack);
|
|
|
|
VOID DosBreakInterrupt(LPWORD Stack);
|
2013-07-18 12:31:11 +00:00
|
|
|
BOOLEAN DosInitialize(VOID);
|
2013-06-26 22:58:41 +00:00
|
|
|
|
2013-08-09 18:55:35 +00:00
|
|
|
#endif // _DOS_H_
|
2013-06-26 22:58:41 +00:00
|
|
|
|
|
|
|
/* EOF */
|