[NTVDM]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 28 Sep 2015 22:15:06 +0000 (22:15 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 28 Sep 2015 22:15:06 +0000 (22:15 +0000)
- Add floppy image automount support from the registry, as it was done for HDDs in r69390 (it's really copy-paste & adaptation of the existing code).
- Increase HDD number support from 1 to 4 (maximum) for INT 13h.

svn path=/trunk/; revision=69411

reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c
reactos/subsystems/mvdm/ntvdm/emulator.c
reactos/subsystems/mvdm/ntvdm/ntvdm.c
reactos/subsystems/mvdm/ntvdm/ntvdm.h

index 0ceada9..f2a1533 100644 (file)
@@ -32,7 +32,7 @@
 // they will be arrays of objects containing disk information needed by
 // the BIOS only.
 static PDISK_IMAGE FloppyDrive[2] = {NULL};
-static PDISK_IMAGE HardDrive[1]   = {NULL};
+static PDISK_IMAGE HardDrive[4]   = {NULL};
 
 #pragma pack(push, 1)
 
@@ -689,6 +689,9 @@ BOOLEAN DiskBios32Initialize(VOID)
     FloppyDrive[0] = RetrieveDisk(FLOPPY_DISK, 0);
     FloppyDrive[1] = RetrieveDisk(FLOPPY_DISK, 1);
     HardDrive[0]   = RetrieveDisk(HARD_DISK, 0);
+    HardDrive[1]   = RetrieveDisk(HARD_DISK, 1);
+    HardDrive[2]   = RetrieveDisk(HARD_DISK, 2);
+    HardDrive[3]   = RetrieveDisk(HARD_DISK, 3);
 
     return TRUE;
 }
index 5ff78d8..344f64e 100644 (file)
@@ -553,6 +553,17 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
         return FALSE;
     }
 
+    /* Mount the available floppy disks */
+    for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
+    {
+        if (GlobalSettings.FloppyDisks[i].Length != 0 &&
+            GlobalSettings.FloppyDisks[i].Buffer      &&
+            GlobalSettings.FloppyDisks[i].Buffer != '\0')
+        {
+            MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE);
+        }
+    }
+
     /* Mount the available hard disks */
     for (i = 0; i < ARRAYSIZE(GlobalSettings.HardDisks); ++i)
     {
index 709c92a..7094807 100644 (file)
@@ -333,6 +333,43 @@ NtVdmConfigureRom(IN PWSTR ValueName,
     return STATUS_SUCCESS;
 }
 
+static NTSTATUS
+NTAPI
+NtVdmConfigureFloppy(IN PWSTR ValueName,
+                     IN ULONG ValueType,
+                     IN PVOID ValueData,
+                     IN ULONG ValueLength,
+                     IN PVOID Context,
+                     IN PVOID EntryContext)
+{
+    PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
+    UNICODE_STRING ValueString;
+    ULONG DiskNumber = (ULONG)EntryContext;
+
+    ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
+
+    /* Check whether the Hard Disk entry was not already configured */
+    if (Settings->FloppyDisks[DiskNumber].Buffer != NULL)
+    {
+        DPRINT1("Floppy Disk %d -- '%Z' already configured\n", DiskNumber, &Settings->FloppyDisks[DiskNumber]);
+        return STATUS_SUCCESS;
+    }
+
+    /* Check for the type of the value */
+    if (ValueType != REG_SZ)
+    {
+        RtlInitEmptyAnsiString(&Settings->FloppyDisks[DiskNumber], NULL, 0);
+        return STATUS_SUCCESS;
+    }
+
+    /* Convert the UNICODE string to ANSI and store it */
+    RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
+    ValueString.Length = ValueString.MaximumLength;
+    RtlUnicodeStringToAnsiString(&Settings->FloppyDisks[DiskNumber], &ValueString, TRUE);
+
+    return STATUS_SUCCESS;
+}
+
 static NTSTATUS
 NTAPI
 NtVdmConfigureHDD(IN PWSTR ValueName,
@@ -393,6 +430,26 @@ NtVdmConfigurationTable[] =
         0
     },
 
+    {
+        NtVdmConfigureFloppy,
+        0,
+        L"FloppyDisk0",
+        (PVOID)0,
+        REG_NONE,
+        NULL,
+        0
+    },
+
+    {
+        NtVdmConfigureFloppy,
+        0,
+        L"FloppyDisk1",
+        (PVOID)1,
+        REG_NONE,
+        NULL,
+        0
+    },
+
     {
         NtVdmConfigureHDD,
         0,
@@ -480,6 +537,12 @@ FreeGlobalSettings(IN PNTVDM_SETTINGS Settings)
     if (Settings->RomFiles.Buffer)
         RtlFreeAnsiString(&Settings->RomFiles);
 
+    for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i)
+    {
+        if (Settings->FloppyDisks[i].Buffer)
+            RtlFreeAnsiString(&Settings->FloppyDisks[i]);
+    }
+
     for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i)
     {
         if (Settings->HardDisks[i].Buffer)
index d50c854..d43a26e 100644 (file)
@@ -76,6 +76,7 @@ typedef struct _NTVDM_SETTINGS
 {
     ANSI_STRING BiosFileName;
     ANSI_STRING RomFiles;
+    ANSI_STRING FloppyDisks[2];
     ANSI_STRING HardDisks[4];
 } NTVDM_SETTINGS, *PNTVDM_SETTINGS;