Revert "[FREELDR] Pass the correct ACPI table for Windows (#7486)"

Sorry this is something I had to do, I should have investigated deeper
before approving it and that's on me so ill take this over and get this
done. and credit you once again. Thank you @ILauncherDev
This reverts commit 185225a5fc.
This commit is contained in:
Justin Miller 2025-03-28 07:16:46 +01:00
parent b6562a664b
commit 177cbd81af
8 changed files with 36 additions and 106 deletions

View file

@ -54,20 +54,6 @@ FindAcpiBios(VOID)
return NULL;
}
PVOID
FindAcpiTable(VOID)
{
PRSDP_DESCRIPTOR Rsdp = FindAcpiBios();
if (!Rsdp)
return NULL;
PVOID OutputPointer = (Rsdp->revision > 1 && Rsdp->xsdt_physical_address) ?
(PVOID)((ULONG_PTR)Rsdp->xsdt_physical_address) :
(PVOID)((ULONG_PTR)Rsdp->rsdt_physical_address);
TRACE("ACPI table at 0x%p\n", OutputPointer);
return OutputPointer;
}
VOID
DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
@ -113,11 +99,16 @@ DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
/* Fill the table */
AcpiBiosData = (PACPI_BIOS_DATA)&PartialResourceList->PartialDescriptors[1];
TRACE("ACPI %s1.0, using %cSDT address\n", Rsdp->revision > 1 ? ">" : "", Rsdp->revision > 1 ? 'X' : 'R');
if (Rsdp->revision > 1 && Rsdp->xsdt_physical_address)
if (Rsdp->revision > 0)
{
TRACE("ACPI >1.0, using XSDT address\n");
AcpiBiosData->RSDTAddress.QuadPart = Rsdp->xsdt_physical_address;
}
else
{
TRACE("ACPI 1.0, using RSDT address\n");
AcpiBiosData->RSDTAddress.LowPart = Rsdp->rsdt_physical_address;
}
AcpiBiosData->Count = PcBiosMapCount;
memcpy(AcpiBiosData->MemoryMap, PcBiosMemoryMap,

View file

@ -50,21 +50,6 @@ FindAcpiBios(VOID)
return rsdp;
}
PVOID
FindAcpiTable(VOID)
{
PRSDP_DESCRIPTOR Rsdp = FindAcpiBios();
if (!Rsdp)
return NULL;
PVOID OutputPointer = (Rsdp->revision > 1 && Rsdp->xsdt_physical_address) ?
(PVOID)((ULONG_PTR)Rsdp->xsdt_physical_address) :
(PVOID)((ULONG_PTR)Rsdp->rsdt_physical_address);
TRACE("ACPI table at 0x%p\n", OutputPointer);
return OutputPointer;
}
VOID
DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
{
@ -108,11 +93,16 @@ DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
/* Fill the table */
AcpiBiosData = (PACPI_BIOS_DATA)&PartialResourceList->PartialDescriptors[1];
TRACE("ACPI %s1.0, using %cSDT address\n", Rsdp->revision > 1 ? ">" : "", Rsdp->revision > 1 ? 'X' : 'R');
if (Rsdp->revision > 1 && Rsdp->xsdt_physical_address)
if (Rsdp->revision > 0)
{
TRACE("ACPI >1.0, using XSDT address\n");
AcpiBiosData->RSDTAddress.QuadPart = Rsdp->xsdt_physical_address;
}
else
{
TRACE("ACPI 1.0, using RSDT address\n");
AcpiBiosData->RSDTAddress.LowPart = Rsdp->rsdt_physical_address;
}
AcpiBiosData->Count = FreeldrDescCount;
memcpy(AcpiBiosData->MemoryMap, EfiMemoryMap,

View file

@ -108,7 +108,6 @@
@ cdecl GetArgumentValue()
@ cdecl GetBootMgrInfo()
@ cdecl IsAcpiPresent()
@ cdecl FindAcpiTable()
@ cdecl LoadSettings()
@ cdecl MachHwDetect()
@ cdecl MachPrepareForReactOS()

View file

@ -84,7 +84,6 @@ DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
PCONFIGURATION_COMPONENT_DATA BusKey);
/* hwacpi.c */
PVOID FindAcpiTable(VOID);
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber);
/* hwapm.c */

View file

@ -1,51 +0,0 @@
/*
* PROJECT: FreeLoader
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Define ACPI Structures
* COPYRIGHT: Copyright 2006-2019 Aleksey Bragin <aleksey@reactos.org>
* Copyright 2024 Daniel Victor <ilauncherdeveloper@gmail.com>
*/
#pragma once
#include <pshpack1.h>
typedef struct /* ACPI Description Header */
{
CHAR Signature[4];
ULONG Length;
UCHAR Revision;
UCHAR Checksum;
CHAR OEMID[6];
CHAR OEMTableID[8];
ULONG OEMRevision;
ULONG CreatorID;
ULONG CreatorRev;
} DESCRIPTION_HEADER, *PDESCRIPTION_HEADER;
typedef struct /* Root System Descriptor Table */
{
DESCRIPTION_HEADER Header;
ULONG PointerToOtherSDT[];
} RSDT_DESCRIPTOR, *PRSDT_DESCRIPTOR;
typedef struct /* eXtended System Descriptor Table */
{
DESCRIPTION_HEADER Header;
ULONGLONG PointerToOtherSDT[];
} XSDT_DESCRIPTOR, *PXSDT_DESCRIPTOR;
typedef struct /* Root System Descriptor Pointer */
{
CHAR signature [8]; /* contains "RSD PTR " */
UCHAR checksum; /* to make sum of struct == 0 */
CHAR oem_id [6]; /* OEM identification */
UCHAR revision; /* Must be 0 for 1.0, 2 for 2.0 */
ULONG rsdt_physical_address; /* 32-bit physical address of RSDT */
ULONG length; /* XSDT Length in bytes including hdr */
ULONGLONG xsdt_physical_address; /* 64-bit physical address of XSDT */
UCHAR extended_checksum; /* Checksum of entire table */
CHAR reserved [3]; /* reserved field must be 0 */
} RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
#include <poppack.h>

View file

@ -8,13 +8,29 @@
#pragma once
#include <arc/setupblk.h>
#include <hwacpi.h>
// See freeldr/ntldr/winldr.h
#define TAG_WLDR_DTE 'eDlW'
#define TAG_WLDR_BDE 'dBlW'
#define TAG_WLDR_NAME 'mNlW'
// Some definitions
#include <pshpack1.h>
typedef struct /* Root System Descriptor Pointer */
{
CHAR signature [8]; /* contains "RSD PTR " */
UCHAR checksum; /* to make sum of struct == 0 */
CHAR oem_id [6]; /* OEM identification */
UCHAR revision; /* Must be 0 for 1.0, 2 for 2.0 */
ULONG rsdt_physical_address; /* 32-bit physical address of RSDT */
ULONG length; /* XSDT Length in bytes including hdr */
ULONGLONG xsdt_physical_address; /* 64-bit physical address of XSDT */
UCHAR extended_checksum; /* Checksum of entire table */
CHAR reserved [3]; /* reserved field must be 0 */
} RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
#include <poppack.h>
typedef struct _ARC_DISK_SIGNATURE_EX
{
ARC_DISK_SIGNATURE DiskSignature;

View file

@ -246,11 +246,12 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
/* FIXME! HACK value for docking profile */
Extension->Profile.Status = 2;
PDESCRIPTION_HEADER AcpiTable = FindAcpiTable();
if (AcpiTable)
/* Check if FreeLdr detected a ACPI table */
if (IsAcpiPresent())
{
Extension->AcpiTable = AcpiTable;
Extension->AcpiTableSize = AcpiTable->Length;
/* Set the pointer to something for compatibility */
Extension->AcpiTable = (PVOID)1;
// FIXME: Extension->AcpiTableSize;
}
if (VersionToBoot >= _WIN32_WINNT_VISTA)

View file

@ -173,7 +173,6 @@ MempSetupPagingForRegion(
BOOLEAN
WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
{
PLOADER_PARAMETER_EXTENSION Extension = VaToPa(LoaderBlock->Extension);
PFN_NUMBER i, PagesCount, MemoryMapSizeInPages, NoEntries;
PFN_NUMBER LastPageIndex, MemoryMapStartPage;
PPAGE_LOOKUP_TABLE_ITEM MemoryMap;
@ -232,20 +231,6 @@ WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
return FALSE;
}
// Always map the ACPI table if present, otherwise Windows will crash.
if (Extension->AcpiTable)
{
PVOID AcpiTableClone = MmAllocateMemoryWithType(Extension->AcpiTableSize, LoaderFirmwarePermanent);
if (!AcpiTableClone)
{
ERR("Cannot allocate ACPI table\n");
return FALSE;
}
RtlCopyMemory(AcpiTableClone, Extension->AcpiTable, Extension->AcpiTableSize);
Extension->AcpiTable = AcpiTableClone;
}
/* Before creating the map, we need to map pages to kernel mode */
LastPageIndex = 1;
LastPageType = MemoryMap[1].PageAllocated;