4 * Copyright (C) 2004 Eric Kohl
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 BOOLEAN AcpiPresent
= FALSE
;
26 static PRSDP_DESCRIPTOR
31 /* Find the 'Root System Descriptor Table Pointer' */
32 Ptr
= (PUCHAR
)0xE0000;
33 while ((ULONG_PTR
)Ptr
< 0x100000)
35 if (!memcmp(Ptr
, "RSD PTR ", 8))
37 DPRINTM(DPRINT_HWDETECT
, "ACPI supported\n");
39 return (PRSDP_DESCRIPTOR
)Ptr
;
42 Ptr
= (PUCHAR
)((ULONG_PTR
)Ptr
+ 0x10);
45 DPRINTM(DPRINT_HWDETECT
, "ACPI not supported\n");
52 DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey
, ULONG
*BusNumber
)
54 PCONFIGURATION_COMPONENT_DATA BiosKey
;
55 PCM_PARTIAL_RESOURCE_LIST PartialResourceList
;
56 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
57 PRSDP_DESCRIPTOR Rsdp
;
58 PACPI_BIOS_DATA AcpiBiosData
;
59 BIOS_MEMORY_MAP BiosMemoryMap
[32];
60 ULONG BiosMemoryMapEntryCount
, TableSize
;
62 Rsdp
= FindAcpiBios();
66 /* Set up the flag in the loader block */
69 /* Get BIOS memory map */
70 RtlZeroMemory(BiosMemoryMap
, sizeof(BiosMemoryMap
));
71 BiosMemoryMapEntryCount
= PcMemGetMemoryMap(BiosMemoryMap
,
72 sizeof(BiosMemoryMap
) / sizeof(BIOS_MEMORY_MAP
));
74 /* Calculate the table size */
75 TableSize
= BiosMemoryMapEntryCount
* sizeof(BIOS_MEMORY_MAP
) +
76 sizeof(ACPI_BIOS_DATA
) - sizeof(BIOS_MEMORY_MAP
);
78 /* Set 'Configuration Data' value */
80 MmHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST
) + TableSize
);
82 if (PartialResourceList
== NULL
)
84 DPRINTM(DPRINT_HWDETECT
,
85 "Failed to allocate resource descriptor\n");
89 memset(PartialResourceList
, 0, sizeof(CM_PARTIAL_RESOURCE_LIST
) + TableSize
);
90 PartialResourceList
->Version
= 0;
91 PartialResourceList
->Revision
= 0;
92 PartialResourceList
->Count
= 1;
94 PartialDescriptor
= &PartialResourceList
->PartialDescriptors
[0];
95 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
96 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
97 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= TableSize
;
100 AcpiBiosData
= (PACPI_BIOS_DATA
)&PartialResourceList
->PartialDescriptors
[1];
101 AcpiBiosData
->RSDTAddress
.LowPart
= Rsdp
->rsdt_physical_address
;
102 AcpiBiosData
->Count
= BiosMemoryMapEntryCount
;
103 memcpy(AcpiBiosData
->MemoryMap
, BiosMemoryMap
,
104 BiosMemoryMapEntryCount
* sizeof(BIOS_MEMORY_MAP
));
106 DPRINTM(DPRINT_HWDETECT
, "RSDT %p, data size %x\n", Rsdp
->rsdt_physical_address
,
109 /* Create new bus key */
110 FldrCreateComponentKey(SystemKey
,
112 MultiFunctionAdapter
,
118 sizeof(CM_PARTIAL_RESOURCE_LIST
) + TableSize
,
121 /* Increment bus number */
124 MmHeapFree(PartialResourceList
);