diff --git a/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h b/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h index 68d98bb3c4d..c365041f774 100644 --- a/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h +++ b/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h @@ -28,6 +28,13 @@ #define CONFIG_CMD(bus, dev_fn, where) \ (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 // diff --git a/reactos/boot/freeldr/freeldr/reactos/archwsup.c b/reactos/boot/freeldr/freeldr/reactos/archwsup.c index 385880d1207..3ddcd3e9106 100644 --- a/reactos/boot/freeldr/freeldr/reactos/archwsup.c +++ b/reactos/boot/freeldr/freeldr/reactos/archwsup.c @@ -14,10 +14,29 @@ /* GLOBALS ********************************************************************/ +extern CHAR reactos_arc_hardware_data[]; +ULONG FldrpHwHeapLocation; PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot; /* 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 NTAPI FldrSetComponentInformation(IN PCONFIGURATION_COMPONENT_DATA ComponentData, @@ -51,21 +70,31 @@ FldrSetComponentInformation(IN PCONFIGURATION_COMPONENT_DATA ComponentData, VOID NTAPI FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData, - IN PWCHAR Identifier) + IN PWCHAR IdentifierString) { LONG Error; - ULONG IdentifierLength = (wcslen(Identifier) + 1) * sizeof(WCHAR); + ULONG IdentifierLength; 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 */ Component->IdentifierLength = IdentifierLength; - Component->Identifier = (PCHAR)Identifier; // We need to use ASCII instead + Component->Identifier = Identifier; /* Set the key */ Error = RegSetValue((FRLDRHKEY)Component->Key, L"Identifier", REG_SZ, - (PCHAR)Identifier, + (PCHAR)IdentifierString, IdentifierLength); if (Error != ERROR_SUCCESS) { @@ -82,7 +111,7 @@ FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode) PCONFIGURATION_COMPONENT Component; /* Allocate the root */ - FldrArcHwTreeRoot = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA)); + FldrArcHwTreeRoot = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); if (!FldrArcHwTreeRoot) return; /* Set it up */ @@ -125,7 +154,7 @@ FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode, PCONFIGURATION_COMPONENT Component; /* Allocate the node for this component */ - ComponentData = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA)); + ComponentData = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); if (!ComponentData) return; /* Now save our parent */ @@ -168,21 +197,29 @@ FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode, VOID NTAPI FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, - IN PVOID ConfigurationData, + IN PVOID Data, IN ULONG Size) { LONG Error; 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 */ ComponentData->ConfigurationData = ConfigurationData; Component->ConfigurationDataLength = Size; - + /* Set 'Configuration Data' value */ Error = RegSetValue((FRLDRHKEY)Component->Key, L"Configuration Data", REG_FULL_RESOURCE_DESCRIPTOR, - ConfigurationData, + Data, Size); if (Error != ERROR_SUCCESS) { diff --git a/reactos/boot/freeldr/freeldr/reactos/reactos.c b/reactos/boot/freeldr/freeldr/reactos/reactos.c index bb6889d2710..1d266610c41 100644 --- a/reactos/boot/freeldr/freeldr/reactos/reactos.c +++ b/reactos/boot/freeldr/freeldr/reactos/reactos.c @@ -35,6 +35,8 @@ reactos_mem_data_t reactos_mem_data; ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information char reactos_arc_strings[32][256]; unsigned long reactos_disk_count = 0; +char reactos_arc_hardware_data[HW_MAX_ARC_HEAP_SIZE] = {0}; + CHAR szHalName[255]; CHAR szBootPath[255]; CHAR SystemRoot[255]; @@ -601,6 +603,7 @@ LoadAndBootReactOS(PCSTR OperatingSystemName) LoaderBlock.ModsCount = 0; LoaderBlock.ModsAddr = reactos_modules; 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); if (LoaderBlock.MmapLength) {