mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
- Because we'll need to pass the ARC hardware information to the kernel, we need to use the usual FreeLDR trick of using a static buffer where to store the data instead of allocating memory. But, unlike our other data, this kind of information is variably-sized, and it's not possible to make arrays of arrays and start assuming upper bounds. Therefore, give us a large 16KB stash buffer, and implement a very simple array-based heap allocator so that all the ARC hardware memory will be contiguous and static as the kernel will expect it.
- Copy all configuration data, identifiers and other data passed to the arc hardware routines into a new location. This is because the caller will free this information, and we want to keep it in memory. We also want it to be contiguous and part of our stash buffer, so allocate the copies from the stash buffer described above. - Store the root of the hardware tree in the ArchExtra ReactOS Loader Parameter Block, the kernel's freeldr->ntldr conversion routines will later deal with this data. svn path=/trunk/; revision=31116
This commit is contained in:
parent
4fa42fad47
commit
222172277b
3 changed files with 57 additions and 10 deletions
|
@ -28,6 +28,13 @@
|
||||||
#define CONFIG_CMD(bus, dev_fn, where) \
|
#define CONFIG_CMD(bus, dev_fn, where) \
|
||||||
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
|
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Static heap for ARC Hardware Component Tree
|
||||||
|
// 16KB oughta be enough for anyone.
|
||||||
|
//
|
||||||
|
#define HW_MAX_ARC_HEAP_SIZE 16 * 1024
|
||||||
|
|
||||||
//
|
//
|
||||||
// ARC Component Configuration Routines
|
// ARC Component Configuration Routines
|
||||||
//
|
//
|
||||||
|
|
|
@ -14,10 +14,29 @@
|
||||||
|
|
||||||
/* GLOBALS ********************************************************************/
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
|
extern CHAR reactos_arc_hardware_data[];
|
||||||
|
ULONG FldrpHwHeapLocation;
|
||||||
PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot;
|
PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot;
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
PVOID
|
||||||
|
NTAPI
|
||||||
|
FldrpHwHeapAlloc(IN ULONG Size)
|
||||||
|
{
|
||||||
|
PVOID Buffer;
|
||||||
|
|
||||||
|
/* Return a block of memory from the ARC Hardware Heap */
|
||||||
|
Buffer = &reactos_arc_hardware_data[FldrpHwHeapLocation];
|
||||||
|
|
||||||
|
/* Increment the heap location */
|
||||||
|
FldrpHwHeapLocation += Size;
|
||||||
|
if (FldrpHwHeapLocation > HW_MAX_ARC_HEAP_SIZE) Buffer = NULL;
|
||||||
|
|
||||||
|
/* Return the buffer */
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
FldrSetComponentInformation(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
FldrSetComponentInformation(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
||||||
|
@ -51,21 +70,31 @@ FldrSetComponentInformation(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
||||||
IN PWCHAR Identifier)
|
IN PWCHAR IdentifierString)
|
||||||
{
|
{
|
||||||
LONG Error;
|
LONG Error;
|
||||||
ULONG IdentifierLength = (wcslen(Identifier) + 1) * sizeof(WCHAR);
|
ULONG IdentifierLength;
|
||||||
PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
|
PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
|
||||||
|
PCHAR Identifier;
|
||||||
|
|
||||||
|
/* Allocate memory for the identifier */
|
||||||
|
/* WARNING: This should be ASCII data */
|
||||||
|
IdentifierLength = (wcslen(IdentifierString) + 1) * sizeof(WCHAR);
|
||||||
|
Identifier = FldrpHwHeapAlloc(IdentifierLength);
|
||||||
|
if (!Identifier) return;
|
||||||
|
|
||||||
|
/* Copy the identifier */
|
||||||
|
RtlCopyMemory(Identifier, IdentifierString, IdentifierLength);
|
||||||
|
|
||||||
/* Set component information */
|
/* Set component information */
|
||||||
Component->IdentifierLength = IdentifierLength;
|
Component->IdentifierLength = IdentifierLength;
|
||||||
Component->Identifier = (PCHAR)Identifier; // We need to use ASCII instead
|
Component->Identifier = Identifier;
|
||||||
|
|
||||||
/* Set the key */
|
/* Set the key */
|
||||||
Error = RegSetValue((FRLDRHKEY)Component->Key,
|
Error = RegSetValue((FRLDRHKEY)Component->Key,
|
||||||
L"Identifier",
|
L"Identifier",
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
(PCHAR)Identifier,
|
(PCHAR)IdentifierString,
|
||||||
IdentifierLength);
|
IdentifierLength);
|
||||||
if (Error != ERROR_SUCCESS)
|
if (Error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +111,7 @@ FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
|
||||||
PCONFIGURATION_COMPONENT Component;
|
PCONFIGURATION_COMPONENT Component;
|
||||||
|
|
||||||
/* Allocate the root */
|
/* Allocate the root */
|
||||||
FldrArcHwTreeRoot = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA));
|
FldrArcHwTreeRoot = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA));
|
||||||
if (!FldrArcHwTreeRoot) return;
|
if (!FldrArcHwTreeRoot) return;
|
||||||
|
|
||||||
/* Set it up */
|
/* Set it up */
|
||||||
|
@ -125,7 +154,7 @@ FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode,
|
||||||
PCONFIGURATION_COMPONENT Component;
|
PCONFIGURATION_COMPONENT Component;
|
||||||
|
|
||||||
/* Allocate the node for this component */
|
/* Allocate the node for this component */
|
||||||
ComponentData = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA));
|
ComponentData = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA));
|
||||||
if (!ComponentData) return;
|
if (!ComponentData) return;
|
||||||
|
|
||||||
/* Now save our parent */
|
/* Now save our parent */
|
||||||
|
@ -168,11 +197,19 @@ FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode,
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
||||||
IN PVOID ConfigurationData,
|
IN PVOID Data,
|
||||||
IN ULONG Size)
|
IN ULONG Size)
|
||||||
{
|
{
|
||||||
LONG Error;
|
LONG Error;
|
||||||
PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
|
PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
|
||||||
|
PVOID ConfigurationData;
|
||||||
|
|
||||||
|
/* Allocate a buffer from the hardware heap */
|
||||||
|
ConfigurationData = FldrpHwHeapAlloc(Size);
|
||||||
|
if (!ConfigurationData) return;
|
||||||
|
|
||||||
|
/* Copy component information */
|
||||||
|
RtlCopyMemory(ConfigurationData, Data, Size);
|
||||||
|
|
||||||
/* Set component information */
|
/* Set component information */
|
||||||
ComponentData->ConfigurationData = ConfigurationData;
|
ComponentData->ConfigurationData = ConfigurationData;
|
||||||
|
@ -182,7 +219,7 @@ FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
||||||
Error = RegSetValue((FRLDRHKEY)Component->Key,
|
Error = RegSetValue((FRLDRHKEY)Component->Key,
|
||||||
L"Configuration Data",
|
L"Configuration Data",
|
||||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||||
ConfigurationData,
|
Data,
|
||||||
Size);
|
Size);
|
||||||
if (Error != ERROR_SUCCESS)
|
if (Error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,8 @@ reactos_mem_data_t reactos_mem_data;
|
||||||
ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information
|
ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information
|
||||||
char reactos_arc_strings[32][256];
|
char reactos_arc_strings[32][256];
|
||||||
unsigned long reactos_disk_count = 0;
|
unsigned long reactos_disk_count = 0;
|
||||||
|
char reactos_arc_hardware_data[HW_MAX_ARC_HEAP_SIZE] = {0};
|
||||||
|
|
||||||
CHAR szHalName[255];
|
CHAR szHalName[255];
|
||||||
CHAR szBootPath[255];
|
CHAR szBootPath[255];
|
||||||
CHAR SystemRoot[255];
|
CHAR SystemRoot[255];
|
||||||
|
@ -601,6 +603,7 @@ LoadAndBootReactOS(PCSTR OperatingSystemName)
|
||||||
LoaderBlock.ModsCount = 0;
|
LoaderBlock.ModsCount = 0;
|
||||||
LoaderBlock.ModsAddr = reactos_modules;
|
LoaderBlock.ModsAddr = reactos_modules;
|
||||||
LoaderBlock.DrivesAddr = reactos_arc_disk_info;
|
LoaderBlock.DrivesAddr = reactos_arc_disk_info;
|
||||||
|
LoaderBlock.ArchExtra = (ULONG)reactos_arc_hardware_data;
|
||||||
LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)reactos_memory_map, 32) * sizeof(memory_map_t);
|
LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)reactos_memory_map, 32) * sizeof(memory_map_t);
|
||||||
if (LoaderBlock.MmapLength)
|
if (LoaderBlock.MmapLength)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue