https://git.reactos.org/?p=reactos.git;a=commitdiff;h=415c737cc3920ab2914158be19b810ecd96ca196

commit 415c737cc3920ab2914158be19b810ecd96ca196
Author:     Stanislav Motylkov <x86co...@gmail.com>
AuthorDate: Tue Jun 9 22:02:09 2020 +0300
Commit:     Stanislav Motylkov <x86co...@gmail.com>
CommitDate: Tue Jun 9 22:02:09 2020 +0300

    [FREELDR] Add display controller detection for Xbox
    
    Also add system identifier here.
    
    [BOOTDATA] Fix some typos
    
    CORE-16216
---
 boot/bootdata/txtsetup.sif                     |  4 +-
 boot/freeldr/freeldr/arch/i386/xbox/machxbox.c | 54 ++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/boot/bootdata/txtsetup.sif b/boot/bootdata/txtsetup.sif
index 9c1bcc410eb..f8a80842196 100644
--- a/boot/bootdata/txtsetup.sif
+++ b/boot/bootdata/txtsetup.sif
@@ -266,7 +266,7 @@ ntoskrnl.exe = 1,,,,,,,2,,,,1,2
 hal.dll      = 1,,,,,,,2,,,,1,2
 
 [Display]
-;<id> = <user friendly name>,<spare>,<service key name>,<height>,<width>,<bpp>
+;<id> = <user friendly name>,<spare>,<service key name>,<width>,<height>,<bpp>
 vga              = "VGA Display (640x480x4)",,Vga,640,480,4
 vbe_640x480x8    = "VESA Display (640x480x8)",,VBE,640,480,8
 vbe_640x480x16   = "VESA Display (640x480x16)",,VBE,640,480,16
@@ -298,7 +298,7 @@ xbox             = "Original Xbox NV2A Framebuffer 
(640x480x32)",,XboxVmp,640,48
 ;<id> = <pnp id string>
 vga = "VGA Display"
 vbe = "VBE Display"
-xboxvmp = "NV2A Framebuffer"
+xbox = "NV2A Framebuffer"
 
 [Keyboard]
 Default = "XT-, AT- or extended keyboard (83-105 keys)"
diff --git a/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c 
b/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
index 3735f18982b..6f54188e3f0 100644
--- a/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
+++ b/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
@@ -21,6 +21,8 @@
 #include <debug.h>
 DBG_DEFAULT_CHANNEL(HWDETECT);
 
+extern PVOID FrameBuffer;
+extern ULONG FrameBufferSize;
 
 BOOLEAN
 XboxFindPciBios(PPCI_REGISTRY_INFO BusData)
@@ -160,6 +162,56 @@ XboxGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* 
pSize)
     return PartialResourceList;
 }
 
+static VOID
+DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
+{
+    CHAR Buffer[80];
+    PCONFIGURATION_COMPONENT_DATA ControllerKey;
+    PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
+    PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
+    ULONG Size;
+
+    if (FrameBufferSize == 0)
+        return;
+
+    strcpy(Buffer, "NV2A Framebuffer");
+
+    Size = sizeof(CM_PARTIAL_RESOURCE_LIST);
+    PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
+    if (PartialResourceList == NULL)
+    {
+        ERR("Failed to allocate resource descriptor\n");
+        return;
+    }
+    memset(PartialResourceList, 0, Size);
+
+    /* Initialize resource descriptor */
+    PartialResourceList->Version = 1;
+    PartialResourceList->Revision = 1;
+    PartialResourceList->Count = 1;
+
+    /* Set Memory */
+    PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
+    PartialDescriptor->Type = CmResourceTypeMemory;
+    PartialDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+    PartialDescriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+    PartialDescriptor->u.Memory.Start.LowPart = (ULONG_PTR)FrameBuffer & 
0x0FFFFFFF;
+    PartialDescriptor->u.Memory.Length = FrameBufferSize;
+
+    FldrCreateComponentKey(BusKey,
+                           ControllerClass,
+                           DisplayController,
+                           0x0,
+                           0x0,
+                           0xFFFFFFFF,
+                           Buffer,
+                           PartialResourceList,
+                           Size,
+                           &ControllerKey);
+
+    TRACE("Created key: DisplayController\\0\n");
+}
+
 static
 VOID
 DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
@@ -202,6 +254,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, 
ULONG *BusNumber)
     /* Detect ISA/BIOS devices */
     DetectBiosDisks(SystemKey, BusKey);
     DetectSerialPorts(BusKey, XboxGetSerialPort, MAX_XBOX_COM_PORTS);
+    DetectDisplayController(BusKey);
 
     /* FIXME: Detect more ISA devices */
 }
@@ -232,6 +285,7 @@ XboxHwDetect(VOID)
 
     /* Create the 'System' key */
     FldrCreateSystemKey(&SystemKey);
+    FldrSetIdentifier(SystemKey, "Original Xbox (PC/AT like)");
 
     GetHarddiskConfigurationData = XboxGetHarddiskConfigurationData;
     FindPciBios = XboxFindPciBios;

Reply via email to