mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
- Refactor creation of component data under the HARDWARE\DESCRIPTION node to use separate routines in a new ARC file, so that registry routines are factored out of the process. This allows 1) Better portability with PPC branch (which will need to do the same kind of hardware work) 2) Ability to eventually get rid of the registry calls and build a true ARC hardware device tree instead (which the kernel will have to parse during boot). The idea is to remove registry writing support from freeldr (because the code is old and freeldr shouldn't be touching the registry anyway). Patch by Alex.
svn path=/trunk/; revision=31113
This commit is contained in:
parent
a0da7760d4
commit
0e2f7faae4
7 changed files with 397 additions and 735 deletions
File diff suppressed because it is too large
Load diff
|
@ -51,49 +51,34 @@ FindAcpiBios(VOID)
|
|||
VOID
|
||||
DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
{
|
||||
WCHAR Buffer[80];
|
||||
FRLDRHKEY BiosKey;
|
||||
LONG Error;
|
||||
|
||||
|
||||
if (FindAcpiBios())
|
||||
{
|
||||
AcpiPresent = TRUE;
|
||||
|
||||
/* Create new bus key */
|
||||
swprintf(Buffer,
|
||||
L"MultifunctionAdapter\\%u", *BusNumber);
|
||||
Error = RegCreateKey(SystemKey,
|
||||
Buffer,
|
||||
&BiosKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
|
||||
FldrCreateComponentKey(SystemKey,
|
||||
L"MultifunctionAdapter",
|
||||
*BusNumber,
|
||||
&BiosKey);
|
||||
|
||||
#if 0
|
||||
/* Set 'Component Information' */
|
||||
SetComponentInformation(BiosKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
/* Set 'Component Information' */
|
||||
FldrSetComponentInformation(BiosKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
#endif
|
||||
|
||||
|
||||
/* Increment bus number */
|
||||
(*BusNumber)++;
|
||||
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
Error = RegSetValue(BiosKey,
|
||||
L"Identifier",
|
||||
REG_SZ,
|
||||
(PCHAR)L"ACPI BIOS",
|
||||
10 * sizeof(WCHAR));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
|
||||
FldrSetIdentifier(BiosKey, L"ACPI BIOS");
|
||||
}
|
||||
|
||||
/* FIXME: Add congiguration data */
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -56,50 +56,32 @@ FindApmBios(VOID)
|
|||
VOID
|
||||
DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
{
|
||||
WCHAR Buffer[80];
|
||||
FRLDRHKEY BiosKey;
|
||||
LONG Error;
|
||||
|
||||
if (FindApmBios())
|
||||
FRLDRHKEY BiosKey;
|
||||
|
||||
if (FindApmBios())
|
||||
{
|
||||
/* Create new bus key */
|
||||
swprintf(Buffer,
|
||||
L"MultifunctionAdapter\\%u", *BusNumber);
|
||||
Error = RegCreateKey(SystemKey,
|
||||
Buffer,
|
||||
&BiosKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create new bus key */
|
||||
FldrCreateComponentKey(SystemKey,
|
||||
L"MultifunctionAdapter",
|
||||
*BusNumber,
|
||||
&BiosKey);
|
||||
|
||||
#if 0
|
||||
/* Set 'Component Information' */
|
||||
SetComponentInformation(BiosKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
/* Set 'Component Information' */
|
||||
FldrSetComponentInformation(BiosKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
#endif
|
||||
|
||||
/* Increment bus number */
|
||||
(*BusNumber)++;
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
Error = RegSetValue(BiosKey,
|
||||
L"Identifier",
|
||||
REG_SZ,
|
||||
(PCHAR)L"APM",
|
||||
4 * sizeof(WCHAR));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Increment bus number */
|
||||
(*BusNumber)++;
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
FldrSetIdentifier(BiosKey, L"APM");
|
||||
}
|
||||
|
||||
/* FIXME: Add congiguration data */
|
||||
|
||||
/* FIXME: Add congiguration data */
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -147,39 +147,25 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
|
|||
PPCI_IRQ_ROUTING_TABLE Table;
|
||||
FRLDRHKEY TableKey;
|
||||
ULONG Size;
|
||||
LONG Error;
|
||||
|
||||
Table = GetPciIrqRoutingTable();
|
||||
if (Table != NULL)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "Table size: %u\n", Table->Size));
|
||||
|
||||
Error = RegCreateKey(BusKey,
|
||||
L"RealModeIrqRoutingTable\\0",
|
||||
&TableKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
FldrCreateComponentKey(BusKey,
|
||||
L"RealModeIrqRoutingTable",
|
||||
0,
|
||||
&TableKey);
|
||||
|
||||
/* Set 'Component Information' */
|
||||
SetComponentInformation(TableKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
FldrSetComponentInformation(TableKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
Error = RegSetValue(TableKey,
|
||||
L"Identifier",
|
||||
REG_SZ,
|
||||
(PCHAR)L"PCI Real-mode IRQ Routing Table",
|
||||
32 * sizeof(WCHAR));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
FldrSetIdentifier(TableKey, L"PCI Real-mode IRQ Routing Table");
|
||||
|
||||
/* Set 'Configuration Data' value */
|
||||
Size = FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) +
|
||||
|
@ -216,19 +202,8 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
|
|||
Table->Size);
|
||||
|
||||
/* Set 'Configuration Data' value */
|
||||
Error = RegSetValue(TableKey,
|
||||
L"Configuration Data",
|
||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||
(PCHAR) FullResourceDescriptor,
|
||||
Size);
|
||||
FldrSetConfigurationData(TableKey, FullResourceDescriptor, Size);
|
||||
MmFreeMemory(FullResourceDescriptor);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"RegSetValue(Configuration Data) failed (Error %u)\n",
|
||||
(int)Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,10 +213,8 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
|||
{
|
||||
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
|
||||
CM_PCI_BUS_DATA BusData;
|
||||
WCHAR Buffer[80];
|
||||
FRLDRHKEY BiosKey;
|
||||
ULONG Size;
|
||||
LONG Error;
|
||||
#if 0
|
||||
FRLDRHKEY BusKey;
|
||||
ULONG i;
|
||||
|
@ -252,37 +225,22 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
|||
if (FindPciBios(&BusData))
|
||||
{
|
||||
/* Create new bus key */
|
||||
swprintf(Buffer,
|
||||
L"MultifunctionAdapter\\%u", *BusNumber);
|
||||
Error = RegCreateKey(SystemKey,
|
||||
Buffer,
|
||||
&BiosKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
FldrCreateComponentKey(SystemKey,
|
||||
L"MultifunctionAdapter",
|
||||
*BusNumber,
|
||||
&BiosKey);
|
||||
|
||||
/* Set 'Component Information' */
|
||||
SetComponentInformation(BiosKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
FldrSetComponentInformation(BiosKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
|
||||
/* Increment bus number */
|
||||
(*BusNumber)++;
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
Error = RegSetValue(BiosKey,
|
||||
L"Identifier",
|
||||
REG_SZ,
|
||||
(PCHAR)L"PCI BIOS",
|
||||
9 * sizeof(WCHAR));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
FldrSetIdentifier(BiosKey, L"PCI BIOS");
|
||||
|
||||
/* Set 'Configuration Data' value */
|
||||
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR);
|
||||
|
@ -307,19 +265,8 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
|||
FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].u.BusNumber.Length = 1;
|
||||
|
||||
/* Set 'Configuration Data' value */
|
||||
Error = RegSetValue(BiosKey,
|
||||
L"Configuration Data",
|
||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||
(PCHAR) FullResourceDescriptor,
|
||||
Size);
|
||||
FldrSetConfigurationData(BiosKey, FullResourceDescriptor, Size);
|
||||
MmFreeMemory(FullResourceDescriptor);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"RegSetValue(Configuration Data) failed (Error %u)\n",
|
||||
(int)Error));
|
||||
return;
|
||||
}
|
||||
|
||||
DetectPciIrqRoutingTable(BiosKey);
|
||||
|
||||
|
@ -332,43 +279,25 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
|||
|
||||
/* Report PCI buses */
|
||||
for (i = 0; i < (ULONG)BusData.BusCount; i++)
|
||||
{
|
||||
swprintf(Buffer,
|
||||
L"MultifunctionAdapter\\%u", *BusNumber);
|
||||
Error = RegCreateKey(SystemKey,
|
||||
Buffer,
|
||||
&BusKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
|
||||
printf("RegCreateKey() failed (Error %u)\n", (int)Error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set 'Component Information' */
|
||||
SetComponentInformation(BusKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
|
||||
/* Increment bus number */
|
||||
(*BusNumber)++;
|
||||
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
Error = RegSetValue(BusKey,
|
||||
L"Identifier",
|
||||
REG_SZ,
|
||||
(PCSTR)szPci,
|
||||
sizeof(szPci));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
FldrCreateComponentKey(SystemKey,
|
||||
L"MultifunctionAdapter",
|
||||
*BusNumber,
|
||||
&BiosKey);
|
||||
|
||||
/* Set 'Component Information' */
|
||||
FldrSetComponentInformation(BusKey,
|
||||
0x0,
|
||||
0x0,
|
||||
0xFFFFFFFF);
|
||||
|
||||
/* Increment bus number */
|
||||
(*BusNumber)++;
|
||||
|
||||
/* Set 'Identifier' value */
|
||||
FldrSetIdentifier(BiosKey, szPci);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<directory name="reactos">
|
||||
<file>registry.c</file>
|
||||
<file>arcname.c</file>
|
||||
<file>archwsup.c</file>
|
||||
<file>binhive.c</file>
|
||||
<file>reactos.c</file>
|
||||
</directory>
|
||||
|
|
|
@ -25,34 +25,52 @@
|
|||
#include "../../reactos/registry.h"
|
||||
#endif
|
||||
|
||||
/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags */
|
||||
#define CM_RESOURCE_PORT_MEMORY 0x0000
|
||||
#define CM_RESOURCE_PORT_IO 0x0001
|
||||
|
||||
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
|
||||
#define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
|
||||
|
||||
typedef struct _CM_COMPONENT_INFORMATION
|
||||
{
|
||||
ULONG Flags;
|
||||
ULONG Version;
|
||||
ULONG Key;
|
||||
ULONG Affinity;
|
||||
} __attribute__((packed)) CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
|
||||
|
||||
|
||||
/* CM_COMPONENT_INFORMATION.Flags */
|
||||
#define Failed 0x00000001
|
||||
//#define ReadOnly 0x00000002
|
||||
#define Removable 0x00000004
|
||||
#define ConsoleIn 0x00000008
|
||||
#define ConsoleOut 0x00000010
|
||||
#define Input 0x00000020
|
||||
#define Output 0x00000040
|
||||
|
||||
#define CONFIG_CMD(bus, dev_fn, where) \
|
||||
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
|
||||
|
||||
//
|
||||
// ARC Component Configuration Routines
|
||||
//
|
||||
VOID
|
||||
NTAPI
|
||||
FldrSetComponentInformation(
|
||||
IN FRLDRHKEY ComponentKey,
|
||||
IN IDENTIFIER_FLAG Flags,
|
||||
IN ULONG Key,
|
||||
IN ULONG Affinity
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrSetIdentifier(
|
||||
IN FRLDRHKEY ComponentKey,
|
||||
IN PWCHAR Identifier
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrCreateSystemKey(
|
||||
OUT FRLDRHKEY *SystemKey
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrCreateComponentKey(
|
||||
IN FRLDRHKEY SystemKey,
|
||||
IN PWCHAR BusName,
|
||||
IN ULONG BusNumber,
|
||||
OUT FRLDRHKEY *ComponentKey
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrSetConfigurationData(
|
||||
IN FRLDRHKEY ComponentKey,
|
||||
IN PVOID ConfigurationData,
|
||||
IN ULONG Size
|
||||
);
|
||||
|
||||
|
||||
/* PROTOTYPES ***************************************************************/
|
||||
|
||||
/* hardware.c */
|
||||
|
@ -61,11 +79,6 @@ VOID StallExecutionProcessor(ULONG Microseconds);
|
|||
|
||||
VOID HalpCalibrateStallExecution(VOID);
|
||||
|
||||
VOID SetComponentInformation(FRLDRHKEY ComponentKey,
|
||||
ULONG Flags,
|
||||
ULONG Key,
|
||||
ULONG Affinity);
|
||||
|
||||
/* hwacpi.c */
|
||||
VOID DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
|
||||
|
||||
|
|
127
reactos/boot/freeldr/freeldr/reactos/archwsup.c
Normal file
127
reactos/boot/freeldr/freeldr/reactos/archwsup.c
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Boot Loader (FreeLDR)
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: boot/freeldr/freeldr/reactos/archwsup.c
|
||||
* PURPOSE: Routines for ARC Hardware Tree and Configuration Data
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <freeldr.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrSetComponentInformation(IN FRLDRHKEY ComponentKey,
|
||||
IN IDENTIFIER_FLAG Flags,
|
||||
IN ULONG Key,
|
||||
IN ULONG Affinity)
|
||||
{
|
||||
CONFIGURATION_COMPONENT ConfigurationComponent;
|
||||
LONG Error;
|
||||
|
||||
/* Build the component information */
|
||||
ConfigurationComponent.Flags = Flags;
|
||||
ConfigurationComponent.Version = 0;
|
||||
ConfigurationComponent.Revision = 0;
|
||||
ConfigurationComponent.Key = Key;
|
||||
ConfigurationComponent.AffinityMask = Affinity;
|
||||
|
||||
/* Set the value */
|
||||
Error = RegSetValue(ComponentKey,
|
||||
L"Component Information",
|
||||
REG_BINARY,
|
||||
(PVOID)&ConfigurationComponent.Flags,
|
||||
FIELD_OFFSET(CONFIGURATION_COMPONENT, ConfigurationDataLength) -
|
||||
FIELD_OFFSET(CONFIGURATION_COMPONENT, Flags));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", Error));
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrSetIdentifier(IN FRLDRHKEY ComponentKey,
|
||||
IN PWCHAR Identifier)
|
||||
{
|
||||
LONG Error;
|
||||
ULONG IdentifierLength = (wcslen(Identifier) + 1) * sizeof(WCHAR);
|
||||
|
||||
/* Set the key */
|
||||
Error = RegSetValue(ComponentKey,
|
||||
L"Identifier",
|
||||
REG_SZ,
|
||||
(PCHAR)Identifier,
|
||||
IdentifierLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrCreateSystemKey(OUT FRLDRHKEY *SystemKey)
|
||||
{
|
||||
LONG Error;
|
||||
|
||||
/* Create the key */
|
||||
Error = RegCreateKey(NULL,
|
||||
L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
|
||||
SystemKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrCreateComponentKey(IN FRLDRHKEY SystemKey,
|
||||
IN PWCHAR BusName,
|
||||
IN ULONG BusNumber,
|
||||
OUT FRLDRHKEY *ComponentKey)
|
||||
{
|
||||
LONG Error;
|
||||
WCHAR Buffer[80];
|
||||
|
||||
/* Build the key name */
|
||||
swprintf(Buffer, L"%s\\%u", BusName, BusNumber);
|
||||
|
||||
/* Create the key */
|
||||
Error = RegCreateKey(SystemKey, Buffer, ComponentKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
FldrSetConfigurationData(IN FRLDRHKEY ComponentKey,
|
||||
IN PVOID ConfigurationData,
|
||||
IN ULONG Size)
|
||||
{
|
||||
LONG Error;
|
||||
|
||||
/* Set 'Configuration Data' value */
|
||||
Error = RegSetValue(ComponentKey,
|
||||
L"Configuration Data",
|
||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||
ConfigurationData,
|
||||
Size);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"RegSetValue(Configuration Data) failed (Error %u)\n",
|
||||
Error));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue