Author: aandrejevic
Date: Mon May 11 02:54:46 2015
New Revision: 67649
URL:
http://svn.reactos.org/svn/reactos?rev=67649&view=rev
Log:
[NTVDM]
Move various private DOS variables into the Swappable Data Area.
It's still mostly unused though.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -43,16 +43,18 @@
CHAR DosReadCharacter(WORD FileHandle)
{
- PCHAR Character = (PCHAR)FAR_POINTER(CHARACTER_ADDRESS);
WORD BytesRead;
- *Character = '\0';
+ Sda->ByteBuffer = '\0';
DPRINT("DosReadCharacter\n");
/* Use the file reading function */
- DosReadFile(FileHandle, CHARACTER_ADDRESS, 1, &BytesRead);
-
- return *Character;
+ DosReadFile(FileHandle,
+ MAKELONG(DOS_DATA_OFFSET(Sda.ByteBuffer), DOS_DATA_SEGMENT),
+ 1,
+ &BytesRead);
+
+ return Sda->ByteBuffer;
}
BOOLEAN DosCheckInput(VOID)
@@ -62,7 +64,7 @@
if (Descriptor == NULL)
{
/* Invalid handle */
- DosLastError = ERROR_INVALID_HANDLE; // ERROR_FILE_NOT_FOUND
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE; // ERROR_FILE_NOT_FOUND
return FALSE;
}
@@ -90,10 +92,14 @@
VOID DosPrintCharacter(WORD FileHandle, CHAR Character)
{
WORD BytesWritten;
- *((PCHAR)FAR_POINTER(CHARACTER_ADDRESS)) = Character;
+
+ Sda->ByteBuffer = Character;
/* Use the file writing function */
- DosWriteFile(FileHandle, CHARACTER_ADDRESS, 1, &BytesWritten);
+ DosWriteFile(FileHandle,
+ MAKELONG(DOS_DATA_OFFSET(Sda.ByteBuffer), DOS_DATA_SEGMENT),
+ 1,
+ &BytesWritten);
}
BOOLEAN DosBIOSInitialize(VOID)
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -587,7 +587,7 @@
Segment = DosAllocateMemory(FileSize >> 4, NULL);
if (Segment == 0)
{
- Result = DosLastError;
+ Result = Sda->LastErrorCode;
goto Cleanup;
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -34,25 +34,19 @@
/* PRIVATE VARIABLES **********************************************************/
-#define INDOS_POINTER MAKELONG(0x00FE, 0x0070)
-
CALLBACK16 DosContext;
/*static*/ BYTE CurrentDrive = 0x00;
static CHAR LastDrive = 'Z'; // The last drive can be redefined with the
LASTDRIVE command. At the moment, set the real maximum possible, 'Z'.
-static CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH];
-static PBYTE InDos;
+static PCHAR CurrentDirectories;
/* PUBLIC VARIABLES ***********************************************************/
PDOS_SYSVARS SysVars;
+PDOS_SDA Sda;
/* Echo state for INT 21h, AH = 01h and AH = 3Fh */
BOOLEAN DoEcho = FALSE;
-
-DWORD DiskTransferArea;
-WORD DosErrorLevel = 0x0000;
-WORD DosLastError = 0;
/* PRIVATE FUNCTIONS **********************************************************/
@@ -64,7 +58,7 @@
if (Drive > (LastDrive - 'A')) return FALSE;
/* Find the path to the new current directory */
- swprintf(DirectoryPath, L"%c\\%S", Drive + 'A',
CurrentDirectories[Drive]);
+ swprintf(DirectoryPath, L"%c\\%S", Drive + 'A',
&CurrentDirectories[Drive * DOS_DIR_LENGTH]);
/* Change the current directory of the process */
if (!SetCurrentDirectory(DirectoryPath)) return FALSE;
@@ -87,7 +81,7 @@
/* Make sure the directory path is not too long */
if (strlen(Directory) >= DOS_DIR_LENGTH)
{
- DosLastError = ERROR_PATH_NOT_FOUND;
+ Sda->LastErrorCode = ERROR_PATH_NOT_FOUND;
return FALSE;
}
@@ -100,7 +94,7 @@
/* Make sure the drive exists */
if (DriveNumber > (LastDrive - 'A'))
{
- DosLastError = ERROR_PATH_NOT_FOUND;
+ Sda->LastErrorCode = ERROR_PATH_NOT_FOUND;
return FALSE;
}
}
@@ -117,7 +111,7 @@
if ((Attributes == INVALID_FILE_ATTRIBUTES)
|| !(Attributes & FILE_ATTRIBUTE_DIRECTORY))
{
- DosLastError = ERROR_PATH_NOT_FOUND;
+ Sda->LastErrorCode = ERROR_PATH_NOT_FOUND;
return FALSE;
}
@@ -127,7 +121,7 @@
/* Change the directory */
if (!SetCurrentDirectoryA(Directory))
{
- DosLastError = LOWORD(GetLastError());
+ Sda->LastErrorCode = LOWORD(GetLastError());
return FALSE;
}
}
@@ -157,11 +151,11 @@
/* Set the directory for the drive */
if (Path != NULL)
{
- strncpy(CurrentDirectories[DriveNumber], Path, DOS_DIR_LENGTH);
+ strncpy(&CurrentDirectories[DriveNumber * DOS_DIR_LENGTH], Path,
DOS_DIR_LENGTH);
}
else
{
- CurrentDirectories[DriveNumber][0] = '\0';
+ CurrentDirectories[DriveNumber * DOS_DIR_LENGTH] = '\0';
}
/* Return success */
@@ -177,7 +171,7 @@
if (getCF())
{
- DosTerminateProcess(CurrentPsp, 0, 0);
+ DosTerminateProcess(Sda->CurrentPsp, 0, 0);
return TRUE;
}
@@ -201,10 +195,10 @@
PDOS_COUNTRY_CODE_BUFFER CountryCodeBuffer;
INT Return;
- (*InDos)++;
+ Sda->InDos++;
/* Save the value of SS:SP on entry in the PSP */
- SEGMENT_TO_PSP(CurrentPsp)->LastStack =
+ SEGMENT_TO_PSP(Sda->CurrentPsp)->LastStack =
MAKELONG(getSP() + (STACK_FLAGS + 1) * 2, getSS());
/* Check the value in the AH register */
@@ -471,7 +465,7 @@
/* Disk Reset */
case 0x0D:
{
- PDOS_PSP PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PDOS_PSP PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
// TODO: Flush what's needed.
DPRINT1("INT 21h, 0Dh is UNIMPLEMENTED\n");
@@ -517,7 +511,7 @@
/* Set Disk Transfer Area */
case 0x1A:
{
- DiskTransferArea = MAKELONG(getDX(), getDS());
+ Sda->DiskTransferArea = MAKELONG(getDX(), getDS());
break;
}
@@ -697,15 +691,15 @@
/* Get Disk Transfer Area */
case 0x2F:
{
- setES(HIWORD(DiskTransferArea));
- setBX(LOWORD(DiskTransferArea));
+ setES(HIWORD(Sda->DiskTransferArea));
+ setBX(LOWORD(Sda->DiskTransferArea));
break;
}
/* Get DOS Version */
case 0x30:
{
- PDOS_PSP PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PDOS_PSP PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
/*
* DOS 2+ - GET DOS VERSION
@@ -751,7 +745,7 @@
case 0x31:
{
DPRINT1("Process going resident: %u paragraphs kept\n", getDX());
- DosTerminateProcess(CurrentPsp, getAL(), getDX());
+ DosTerminateProcess(Sda->CurrentPsp, getAL(), getDX());
break;
}
@@ -792,8 +786,8 @@
/* Get Address of InDOS flag */
case 0x34:
{
- setES(HIWORD(INDOS_POINTER));
- setBX(LOWORD(INDOS_POINTER));
+ setES(DOS_DATA_SEGMENT);
+ setBX(DOS_DATA_OFFSET(Sda.InDos));
break;
}
@@ -1002,7 +996,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
}
break;
@@ -1228,7 +1222,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
}
break;
@@ -1247,7 +1241,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
}
break;
@@ -1292,7 +1286,7 @@
* Copy the current directory into the target buffer.
* It doesn't contain the drive letter and the backslash.
*/
- strncpy(String, CurrentDirectories[DriveNumber], DOS_DIR_LENGTH);
+ strncpy(String, &CurrentDirectories[DriveNumber * DOS_DIR_LENGTH],
DOS_DIR_LENGTH);
Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
setAX(0x0100); // Undocumented, see Ralf Brown:
http://www.ctyme.com/intr/rb-2933.htm
}
@@ -1319,7 +1313,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
setBX(MaxAvailable);
}
@@ -1354,7 +1348,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
setBX(Size);
}
@@ -1417,7 +1411,7 @@
/* Terminate With Return Code */
case 0x4C:
{
- DosTerminateProcess(CurrentPsp, getAL(), 0);
+ DosTerminateProcess(Sda->CurrentPsp, getAL(), 0);
break;
}
@@ -1429,15 +1423,15 @@
* DosErrorLevel is cleared after being read by this function.
*/
Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
- setAX(DosErrorLevel);
- DosErrorLevel = 0x0000; // Clear it
+ setAX(Sda->ErrorLevel);
+ Sda->ErrorLevel = 0x0000; // Clear it
break;
}
/* Find First File */
case 0x4E:
{
- WORD Result = (WORD)demFileFindFirst(FAR_POINTER(DiskTransferArea),
+ WORD Result = (WORD)demFileFindFirst(FAR_POINTER(Sda->DiskTransferArea),
SEG_OFF_TO_PTR(getDS(), getDX()),
getCX());
@@ -1454,7 +1448,7 @@
/* Find Next File */
case 0x4F:
{
- WORD Result = (WORD)demFileFindNext(FAR_POINTER(DiskTransferArea));
+ WORD Result = (WORD)demFileFindNext(FAR_POINTER(Sda->DiskTransferArea));
setAX(Result);
@@ -1484,7 +1478,7 @@
* and
http://www.ctyme.com/intr/rb-3140.htm
* for more information.
*/
- setBX(CurrentPsp);
+ setBX(Sda->CurrentPsp);
break;
}
@@ -1542,7 +1536,7 @@
{
/* Get allocation strategy */
Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
- setAX(DosAllocStrategy);
+ setAX(Sda->AllocStrategy);
}
else if (getAL() == 0x01)
{
@@ -1565,7 +1559,7 @@
break;
}
- DosAllocStrategy = getBL();
+ Sda->AllocStrategy = getBL();
Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
}
else if (getAL() == 0x02)
@@ -1678,7 +1672,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
}
}
else if (getAL() == 0x01)
@@ -1691,7 +1685,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
}
}
else
@@ -1740,13 +1734,40 @@
break;
}
+ /* Miscellaneous Internal Functions */
+ case 0x5D:
+ {
+ switch (getAL())
+ {
+ /* Get Swappable Data Area */
+ case 0x06:
+ {
+ setDS(DOS_DATA_SEGMENT);
+ setSI(DOS_DATA_OFFSET(Sda.ErrorMode));
+ setCX(sizeof(DOS_SDA));
+ setDX(FIELD_OFFSET(DOS_SDA, LastAX));
+
+ Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
+ break;
+ }
+
+ default:
+ {
+ DPRINT1("INT 21h, AH = 5Dh, subfunction AL = %Xh NOT
IMPLEMENTED\n",
+ getAL());
+ }
+ }
+
+ break;
+ }
+
/* Set Handle Count */
case 0x67:
{
if (!DosResizeHandleTable(getBX()))
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(DosLastError);
+ setAX(Sda->LastErrorCode);
}
else Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
@@ -1833,7 +1854,7 @@
}
}
- (*InDos)--;
+ Sda->InDos--;
}
VOID WINAPI DosBreakInterrupt(LPWORD Stack)
@@ -1942,9 +1963,9 @@
FILE *Stream;
WCHAR Buffer[256];
- /* Setup the InDOS flag */
- InDos = (PBYTE)FAR_POINTER(INDOS_POINTER);
- *InDos = 0;
+ /* Get a pointer to the current directory buffer */
+ CurrentDirectories = (PCHAR)SEG_OFF_TO_PTR(DOS_DATA_SEGMENT,
+ DOS_DATA_OFFSET(CurrentDirectories));
/* Clear the current directory buffer */
RtlZeroMemory(CurrentDirectories, sizeof(CurrentDirectories));
@@ -1977,7 +1998,7 @@
/* Set the directory */
if (Path != NULL)
{
- strncpy(CurrentDirectories[CurrentDrive], Path, DOS_DIR_LENGTH);
+ strncpy(&CurrentDirectories[CurrentDrive * DOS_DIR_LENGTH], Path,
DOS_DIR_LENGTH);
}
/* Read CONFIG.SYS */
@@ -1995,7 +2016,9 @@
SysVars = (PDOS_SYSVARS)SEG_OFF_TO_PTR(DOS_DATA_SEGMENT, 0);
RtlZeroMemory(SysVars, sizeof(DOS_SYSVARS));
SysVars->FirstMcb = FIRST_MCB_SEGMENT;
- SysVars->FirstSft = MAKELONG(MASTER_SFT_OFFSET, DOS_DATA_SEGMENT);
+ SysVars->FirstSft = MAKELONG(DOS_DATA_OFFSET(Sft), DOS_DATA_SEGMENT);
+ SysVars->CurrentDirs = MAKELONG(DOS_DATA_OFFSET(CurrentDirectories),
+ DOS_DATA_SEGMENT);
/* Initialize the NUL device driver */
SysVars->NullDevice.Link = 0xFFFFFFFF;
@@ -2010,6 +2033,16 @@
NullDriverRoutine,
sizeof(NullDriverRoutine));
+ /* Initialize the swappable data area */
+ Sda = (PDOS_SDA)SEG_OFF_TO_PTR(DOS_DATA_SEGMENT, sizeof(DOS_SYSVARS));
+ RtlZeroMemory(Sda, sizeof(DOS_SDA));
+
+ /* Set the current PSP to the system PSP */
+ Sda->CurrentPsp = SYSTEM_PSP;
+
+ /* Set the initial allocation strategy to "best fit" */
+ Sda->AllocStrategy = DOS_ALLOC_BEST_FIT;
+
/* Initialize the SFT */
Sft = (PDOS_SFT)FAR_POINTER(SysVars->FirstSft);
Sft->Link = 0xFFFFFFFF;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] Mon May 11
02:54:46 2015
@@ -32,7 +32,8 @@
#define SYSTEM_ENV_BLOCK 0x800
#define DOS_CODE_SEGMENT 0x70
#define DOS_DATA_SEGMENT 0xA0
-#define MASTER_SFT_OFFSET 0x100
+
+#define DOS_DATA_OFFSET(x) FIELD_OFFSET(DOS_DATA, x)
#define INVALID_DOS_HANDLE 0xFFFF
#define DOS_INPUT_HANDLE 0
@@ -92,6 +93,15 @@
BYTE NullDriverRoutine[7];
} DOS_SYSVARS, *PDOS_SYSVARS;
+typedef struct _DOS_CLOCK_TRANSFER_RECORD
+{
+ WORD NumberOfDays;
+ BYTE Minutes;
+ BYTE Hours;
+ BYTE Hundredths;
+ BYTE Seconds;
+} DOS_CLOCK_TRANSFER_RECORD, *PDOS_CLOCK_TRANSFER_RECORD;
+
typedef struct _DOS_INPUT_BUFFER
{
BYTE MaxLength;
@@ -123,15 +133,127 @@
WORD DecimalSep;
} DOS_COUNTRY_CODE_BUFFER, *PDOS_COUNTRY_CODE_BUFFER;
+typedef struct _DOS_SDA
+{
+ BYTE PrinterEchoFlag;
+ CHAR CurrentSwitchChar;
+ BYTE AllocStrategy;
+ BYTE Unused0[28];
+
+ /* This is where the SDA really starts */
+ BYTE ErrorMode;
+ BYTE InDos;
+ BYTE ErrorDrive;
+ BYTE LastErrorLocus;
+ WORD LastErrorCode;
+ BYTE LastErrorAction;
+ BYTE LastErrorClass;
+ DWORD LastErrorPointer;
+ DWORD DiskTransferArea;
+ WORD CurrentPsp;
+ WORD Int23StackPointer;
+ WORD ErrorLevel;
+ BYTE CurrentDrive;
+ BYTE ExtendedBreakFlag;
+
+ /* This part is only valid while in DOS */
+ WORD LastAX;
+ WORD NetworkPsp;
+ WORD NetworkMachineNumber;
+ WORD FirstFreeMcb;
+ WORD BestFreeMcb;
+ WORD LastFreeMcb;
+ WORD MemorySize;
+ WORD LastSearchDirEntry;
+ BYTE Int24FailFlag;
+ BYTE DirectoryFlag;
+ BYTE CtrlBreakFlag;
+ BYTE AllowFcbBlanks;
+ BYTE Unused1;
+ BYTE DayOfMonth;
+ BYTE Month;
+ WORD Year;
+ WORD NumDays;
+ BYTE DayOfWeek;
+ BYTE ConsoleSwappedFlag;
+ BYTE Int28CallOk;
+ BYTE Int24AbortFlag;
+ DOS_RW_REQUEST ReadWriteRequest;
+ DWORD DriverEntryPoint;
+ DOS_IOCTL_RW_REQUEST IoctlRequest;
+ DOS_PEEK_REQUEST StatusRequest;
+ DWORD DeviceIoBuffer;
+ DWORD Unused2;
+ BYTE PspCopyType;
+ BYTE Unused3;
+ BYTE UserNumber[3];
+ BYTE OemNumber;
+ WORD ErrorCodeTable;
+ DOS_CLOCK_TRANSFER_RECORD ClockTransferRecord;
+ BYTE ByteBuffer;
+ BYTE Unused4;
+ CHAR FileNameBuffer[256];
+ BYTE Unused5[53];
+ CHAR CurrentDirectory[81];
+ CHAR FcbFilename[12];
+ CHAR FcbRenameDest[12];
+ BYTE Unused6[8];
+ BYTE ExtendedAttribute;
+ BYTE FcbType;
+ BYTE DirSearchAttributes;
+ BYTE FileOpenMode;
+ BYTE FileFound;
+ BYTE DeviceNameFound;
+ BYTE SpliceFlag;
+ BYTE DosCallFlag;
+ BYTE Unused7[5];
+ BYTE InsertMode;
+ BYTE ParsedFcbExists;
+ BYTE VolumeIDFlag;
+ BYTE TerminationType;
+ BYTE CreateFileFlag;
+ BYTE FileDeletedChar;
+ DWORD CriticalErrorDpb;
+ DWORD UserRegistersStack;
+ WORD Int24StackPointer;
+ BYTE Unused8[14];
+ DWORD DeviceHeader;
+ DWORD CurrentSft;
+ DWORD CurrentDirPointer;
+ DWORD CallerFcb;
+ WORD SftNumber;
+ WORD TempFileHandle;
+ DWORD JftEntry;
+ WORD FirstArgument;
+ WORD SecondArgument;
+ WORD LastComponent;
+ WORD TransferOffset;
+ BYTE Unused9[38];
+ DWORD WorkingSft;
+ WORD Int21CallerBX;
+ WORD Int21CallerDS;
+ WORD Unused10;
+ DWORD PrevCallFrame;
+} DOS_SDA, *PDOS_SDA;
+
+/* This structure is only used for DOS_DATA_OFFSET calculations */
+typedef struct _DOS_DATA
+{
+ DOS_SYSVARS SysVars;
+ DOS_SDA Sda;
+ CHAR CurrentDirectories[NUM_DRIVES * DOS_DIR_LENGTH];
+ BYTE Sft[ANYSIZE_ARRAY];
+} DOS_DATA, *PDOS_DATA;
+
#pragma pack(pop)
/* VARIABLES ******************************************************************/
extern BOOLEAN DoEcho;
-extern DWORD DiskTransferArea;
extern WORD DosErrorLevel;
extern WORD DosLastError;
extern PDOS_SYSVARS SysVars;
+extern PDOS_SDA Sda;
/* FUNCTIONS ******************************************************************/
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -376,7 +376,7 @@
Descriptor->OpenMode = AccessShareModes;
Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = CurrentPsp;
+ Descriptor->OwnerPsp = Sda->CurrentPsp;
Descriptor->Win32Handle = FileHandle;
}
@@ -451,7 +451,7 @@
{
Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = CurrentPsp;
+ Descriptor->OwnerPsp = Sda->CurrentPsp;
Descriptor->Win32Handle = FileHandle;
}
@@ -600,7 +600,7 @@
Descriptor->OpenMode = AccessShareModes;
Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = CurrentPsp;
+ Descriptor->OwnerPsp = Sda->CurrentPsp;
Descriptor->Win32Handle = FileHandle;
}
@@ -793,7 +793,7 @@
if (Descriptor == NULL)
{
/* Invalid handle */
- DosLastError = ERROR_INVALID_HANDLE;
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE;
return FALSE;
}
@@ -819,7 +819,7 @@
if (Descriptor == NULL)
{
/* Invalid handle */
- DosLastError = ERROR_INVALID_HANDLE;
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE;
return FALSE;
}
@@ -828,7 +828,7 @@
if (!LockFile(Descriptor->Win32Handle, Offset, 0, Size, 0))
{
- DosLastError = GetLastError();
+ Sda->LastErrorCode = GetLastError();
return FALSE;
}
@@ -842,7 +842,7 @@
if (Descriptor == NULL)
{
/* Invalid handle */
- DosLastError = ERROR_INVALID_HANDLE;
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE;
return FALSE;
}
@@ -851,7 +851,7 @@
if (!UnlockFile(Descriptor->Win32Handle, Offset, 0, Size, 0))
{
- DosLastError = GetLastError();
+ Sda->LastErrorCode = GetLastError();
return FALSE;
}
@@ -865,7 +865,7 @@
if (!Descriptor)
{
- DosLastError = ERROR_INVALID_HANDLE;
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE;
return FALSE;
}
@@ -901,7 +901,7 @@
{
if (Node == NULL || !(Node->DeviceAttributes & DOS_DEVATTR_IOCTL))
{
- DosLastError = ERROR_INVALID_FUNCTION;
+ Sda->LastErrorCode = ERROR_INVALID_FUNCTION;
return FALSE;
}
@@ -921,7 +921,7 @@
{
if (Node == NULL || !(Node->DeviceAttributes & DOS_DEVATTR_IOCTL))
{
- DosLastError = ERROR_INVALID_FUNCTION;
+ Sda->LastErrorCode = ERROR_INVALID_FUNCTION;
return FALSE;
}
@@ -941,7 +941,7 @@
{
DPRINT1("Unsupported IOCTL: 0x%02X\n", ControlCode);
- DosLastError = ERROR_INVALID_PARAMETER;
+ Sda->LastErrorCode = ERROR_INVALID_PARAMETER;
return FALSE;
}
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -59,7 +59,7 @@
for (i = 0; i < DEFAULT_JFT_SIZE; i++) DestinationTable[i] = 0xFF;
/* Check if this is the initial process */
- if (CurrentPsp == SYSTEM_PSP)
+ if (Sda->CurrentPsp == SYSTEM_PSP)
{
BYTE DescriptorId;
HANDLE StandardHandles[3];
@@ -122,7 +122,7 @@
else
{
/* Get the parent PSP block and handle table */
- PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
SourceTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr);
/* Copy the first 20 handles into the new table */
@@ -144,7 +144,7 @@
WORD Segment;
/* Get the PSP block */
- PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
if (NewSize == PspBlock->HandleTableSize)
{
@@ -170,7 +170,7 @@
/* Update the handle table pointer and size */
PspBlock->HandleTableSize = NewSize;
- PspBlock->HandleTablePtr = MAKELONG(0x18, CurrentPsp);
+ PspBlock->HandleTablePtr = MAKELONG(0x18, Sda->CurrentPsp);
}
else
{
@@ -232,10 +232,10 @@
if (Descriptor == NULL) return INVALID_DOS_HANDLE;
/* The system PSP has no handle table */
- if (CurrentPsp == SYSTEM_PSP) return INVALID_DOS_HANDLE;
+ if (Sda->CurrentPsp == SYSTEM_PSP) return INVALID_DOS_HANDLE;
/* Get a pointer to the handle table */
- PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr);
/* Find a free entry in the JFT */
@@ -265,10 +265,10 @@
DPRINT("DosQueryHandle: DosHandle 0x%04X\n", DosHandle);
/* The system PSP has no handle table */
- if (CurrentPsp == SYSTEM_PSP) return 0xFF;
+ if (Sda->CurrentPsp == SYSTEM_PSP) return 0xFF;
/* Get a pointer to the handle table */
- PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr);
/* Return the descriptor ID */
@@ -281,7 +281,7 @@
if (DescriptorId == 0xFF)
{
- DosLastError = ERROR_INVALID_HANDLE;
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE;
return INVALID_DOS_HANDLE;
}
@@ -300,10 +300,10 @@
NewHandle);
/* The system PSP has no handle table */
- if (CurrentPsp == SYSTEM_PSP) return FALSE;
+ if (Sda->CurrentPsp == SYSTEM_PSP) return FALSE;
/* Get a pointer to the handle table */
- PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr);
/* Make sure the old handle is open */
@@ -339,10 +339,10 @@
DPRINT("DosCloseHandle: DosHandle 0x%04X\n", DosHandle);
/* The system PSP has no handle table */
- if (CurrentPsp == SYSTEM_PSP) return FALSE;
+ if (Sda->CurrentPsp == SYSTEM_PSP) return FALSE;
/* Get a pointer to the handle table */
- PspBlock = SEGMENT_TO_PSP(CurrentPsp);
+ PspBlock = SEGMENT_TO_PSP(Sda->CurrentPsp);
HandleTable = (LPBYTE)FAR_POINTER(PspBlock->HandleTablePtr);
/* Make sure the handle is open */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -20,7 +20,6 @@
/* PUBLIC VARIABLES ***********************************************************/
-BYTE DosAllocStrategy = DOS_ALLOC_BEST_FIT;
BOOLEAN DosUmbLinked = FALSE;
/* PRIVATE FUNCTIONS **********************************************************/
@@ -63,7 +62,7 @@
DPRINT("DosAllocateMemory: Size 0x%04X\n", Size);
- if (DosUmbLinked && (DosAllocStrategy & (DOS_ALLOC_HIGH |
DOS_ALLOC_HIGH_LOW)))
+ if (DosUmbLinked && (Sda->AllocStrategy & (DOS_ALLOC_HIGH |
DOS_ALLOC_HIGH_LOW)))
{
/* Search UMB first */
Segment = UMB_START_SEGMENT;
@@ -79,7 +78,7 @@
if (CurrentMcb->BlockType != 'M' && CurrentMcb->BlockType
!= 'Z')
{
DPRINT("The DOS memory arena is corrupted!\n");
- DosLastError = ERROR_ARENA_TRASHED;
+ Sda->LastErrorCode = ERROR_ARENA_TRASHED;
return 0;
}
@@ -95,7 +94,7 @@
/* Check if this block is big enough */
if (CurrentMcb->Size < Size) goto Next;
- switch (DosAllocStrategy & 0x3F)
+ switch (Sda->AllocStrategy & 0x3F)
{
case DOS_ALLOC_FIRST_FIT:
{
@@ -128,7 +127,7 @@
if (CurrentMcb->BlockType == 'Z')
{
/* Check if nothing was found while searching through UMBs */
- if ((Result == 0) && SearchUmb && (DosAllocStrategy &
DOS_ALLOC_HIGH_LOW))
+ if ((Result == 0) && SearchUmb && (Sda->AllocStrategy
& DOS_ALLOC_HIGH_LOW))
{
/* Search low memory */
Segment = FIRST_MCB_SEGMENT;
@@ -148,7 +147,7 @@
/* If we didn't find a free block, return 0 */
if (Result == 0)
{
- DosLastError = ERROR_NOT_ENOUGH_MEMORY;
+ Sda->LastErrorCode = ERROR_NOT_ENOUGH_MEMORY;
if (MaxAvailable) *MaxAvailable = MaxSize;
return 0;
}
@@ -160,7 +159,7 @@
if (CurrentMcb->Size > Size)
{
/* It is, split it into two blocks */
- if ((DosAllocStrategy & 0x3F) != DOS_ALLOC_LAST_FIT)
+ if ((Sda->AllocStrategy & 0x3F) != DOS_ALLOC_LAST_FIT)
{
PDOS_MCB NextMcb = SEGMENT_TO_MCB(Result + Size + 1);
@@ -194,7 +193,7 @@
}
/* Take ownership of the block */
- CurrentMcb->OwnerPsp = CurrentPsp;
+ CurrentMcb->OwnerPsp = Sda->CurrentPsp;
/* Return the segment of the data portion of the block */
return Result + 1;
@@ -216,7 +215,7 @@
|| Mcb->OwnerPsp == 0)
{
Success = FALSE;
- DosLastError = ERROR_INVALID_HANDLE;
+ Sda->LastErrorCode = ERROR_INVALID_HANDLE;
goto Done;
}
@@ -240,7 +239,7 @@
if (NextMcb->OwnerPsp != 0)
{
DPRINT("Cannot expand memory block: next segment is not free!\n");
- DosLastError = ERROR_NOT_ENOUGH_MEMORY;
+ Sda->LastErrorCode = ERROR_NOT_ENOUGH_MEMORY;
Success = FALSE;
goto Done;
}
@@ -254,7 +253,7 @@
if (ReturnSize < NewSize)
{
DPRINT("Cannot expand memory block: insufficient free segments
available!\n");
- DosLastError = ERROR_NOT_ENOUGH_MEMORY;
+ Sda->LastErrorCode = ERROR_NOT_ENOUGH_MEMORY;
Success = FALSE;
goto Done;
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c [iso-8859-1] Mon May 11
02:54:46 2015
@@ -26,10 +26,6 @@
#include "io.h"
#include "hardware/ps2.h"
-
-/* PUBLIC VARIABLES ***********************************************************/
-
-WORD CurrentPsp = SYSTEM_PSP;
/* PRIVATE FUNCTIONS **********************************************************/
@@ -212,7 +208,7 @@
PspBlock->CriticalAddress = IntVecTable[0x24];
/* Set the parent PSP */
- PspBlock->ParentPsp = CurrentPsp;
+ PspBlock->ParentPsp = Sda->CurrentPsp;
/* No environment block yet */
PspBlock->EnvBlock = 0;
@@ -235,8 +231,8 @@
VOID DosSetProcessContext(WORD Segment)
{
- CurrentPsp = Segment;
- DiskTransferArea = MAKELONG(0x80, Segment);
+ Sda->CurrentPsp = Segment;
+ Sda->DiskTransferArea = MAKELONG(0x80, Segment);
}
DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
@@ -439,7 +435,7 @@
/* Check if there's at least enough memory for the minimum size */
if (MaxAllocSize < (BaseSize + (sizeof(DOS_PSP) >> 4) +
Header->e_minalloc))
{
- Result = DosLastError;
+ Result = Sda->LastErrorCode;
goto Cleanup;
}
@@ -496,13 +492,13 @@
if (LoadType == DOS_LOAD_AND_EXECUTE)
{
/* Save the program state */
- if (CurrentPsp != SYSTEM_PSP)
+ if (Sda->CurrentPsp != SYSTEM_PSP)
{
/* Push the task state */
DosSaveState();
/* Update the last stack in the PSP */
- SEGMENT_TO_PSP(CurrentPsp)->LastStack = MAKELONG(getSP(), getSS());
+ SEGMENT_TO_PSP(Sda->CurrentPsp)->LastStack = MAKELONG(getSP(),
getSS());
}
/* Set the initial segment registers */
@@ -544,7 +540,7 @@
Segment = DosAllocateMemory(MaxAllocSize, NULL);
if (Segment == 0)
{
- Result = DosLastError;
+ Result = Sda->LastErrorCode;
goto Cleanup;
}
@@ -577,13 +573,13 @@
if (LoadType == DOS_LOAD_AND_EXECUTE)
{
/* Save the program state */
- if (CurrentPsp != SYSTEM_PSP)
+ if (Sda->CurrentPsp != SYSTEM_PSP)
{
/* Push the task state */
DosSaveState();
/* Update the last stack in the PSP */
- SEGMENT_TO_PSP(CurrentPsp)->LastStack = MAKELONG(getSP(), getSS());
+ SEGMENT_TO_PSP(Sda->CurrentPsp)->LastStack = MAKELONG(getSP(),
getSS());
}
/* Set the initial segment registers */
@@ -906,10 +902,10 @@
IntVecTable[0x24] = PspBlock->CriticalAddress;
/* Update the current PSP */
- if (Psp == CurrentPsp)
- {
- CurrentPsp = PspBlock->ParentPsp;
- if (CurrentPsp == SYSTEM_PSP)
+ if (Psp == Sda->CurrentPsp)
+ {
+ Sda->CurrentPsp = PspBlock->ParentPsp;
+ if (Sda->CurrentPsp == SYSTEM_PSP)
{
ResetEvent(VdmTaskEvent);
CpuUnsimulate();
@@ -935,11 +931,11 @@
#endif
/* Save the return code - Normal termination */
- DosErrorLevel = MAKEWORD(ReturnCode, 0x00);
+ Sda->ErrorLevel = MAKEWORD(ReturnCode, 0x00);
/* Restore the old stack */
- setSS(HIWORD(SEGMENT_TO_PSP(CurrentPsp)->LastStack));
- setSP(LOWORD(SEGMENT_TO_PSP(CurrentPsp)->LastStack));
+ setSS(HIWORD(SEGMENT_TO_PSP(Sda->CurrentPsp)->LastStack));
+ setSP(LOWORD(SEGMENT_TO_PSP(Sda->CurrentPsp)->LastStack));
/* Are we returning to DOS code? */
if (HIWORD(PspBlock->TerminateAddress) == DOS_CODE_SEGMENT)