Author: tkreuzer Date: Mon Feb 25 20:07:17 2013 New Revision: 58369
URL: http://svn.reactos.org/svn/reactos?rev=58369&view=rev Log: [FREELDR] Get rid of reactos_arc_hardware_data, which wasn't used anyway. This frees up 16KB of memory. Don't reallocate the PARTIAL_RESOURE_LISTs in FldrCreateComponentKey, instead take over the ones passed by the caller.
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c trunk/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c trunk/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c trunk/reactos/boot/freeldr/freeldr/bootmgr.c trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h trunk/reactos/boot/freeldr/freeldr/include/arch/powerpc/hardware.h trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -31,7 +31,6 @@
ARC_DISK_SIGNATURE reactos_arc_disk_info; ULONG reactos_disk_count; -CHAR reactos_arc_hardware_data[256];
ULONG SizeBits[] = {
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -355,8 +355,6 @@ &BusKey);
(*BusNumber)++; - - MmHeapFree(PartialResourceList); }
@@ -545,8 +543,6 @@ PartialResourceList, Size, &PeripheralKey); - - MmHeapFree(PartialResourceList); } }
@@ -619,8 +615,6 @@ &ControllerKey); TRACE("Created key: DiskController\0\n");
- MmHeapFree(PartialResourceList); - if (FloppyCount) DetectBiosFloppyPeripheral(ControllerKey); }
@@ -690,8 +684,6 @@ PartialResourceList, Size, &SystemKey); - - MmHeapFree(PartialResourceList);
return SystemKey; } @@ -739,7 +731,6 @@ Size, &DiskKey); } - }
static @@ -917,12 +908,12 @@ DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base) { - CM_PARTIAL_RESOURCE_LIST PartialResourceList; + PCM_PARTIAL_RESOURCE_LIST PartialResourceList; char Buffer[256]; CHAR Identifier[256]; PCONFIGURATION_COMPONENT_DATA PeripheralKey; ULONG MouseType; - ULONG Length; + ULONG Size, Length; ULONG i; ULONG j; ULONG k; @@ -1043,10 +1034,13 @@ }
/* Set 'Configuration Data' value */ - memset(&PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST)); - PartialResourceList.Version = 1; - PartialResourceList.Revision = 1; - PartialResourceList.Count = 0; + Size = sizeof(CM_PARTIAL_RESOURCE_LIST) - + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); + PartialResourceList = MmHeapAlloc(Size); + memset(PartialResourceList, 0, Size); + PartialResourceList->Version = 1; + PartialResourceList->Revision = 1; + PartialResourceList->Count = 0;
/* Create 'PointerPeripheral' key */ FldrCreateComponentKey(ControllerKey, @@ -1056,9 +1050,8 @@ 0x0, 0xFFFFFFFF, Identifier, - &PartialResourceList, - sizeof(CM_PARTIAL_RESOURCE_LIST) - - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR), + PartialResourceList, + Size, &PeripheralKey);
TRACE("Created key: PointerPeripheral\0\n"); @@ -1160,8 +1153,6 @@ Size, &ControllerKey);
- MmHeapFree(PartialResourceList); - if (!Rs232PortInUse(UlongToPtr(Base))) { /* Detect serial mouse */ @@ -1257,8 +1248,6 @@ PartialResourceList, Size, &ControllerKey); - - MmHeapFree(PartialResourceList);
ControllerNumber++; } @@ -1390,8 +1379,6 @@ Size, &PeripheralKey); TRACE("Created key: KeyboardPeripheral\0\n"); - - MmHeapFree(PartialResourceList); } }
@@ -1461,8 +1448,6 @@ &ControllerKey); TRACE("Created key: KeyboardController\0\n");
- MmHeapFree(PartialResourceList); - DetectKeyboardPeripheral(ControllerKey); }
@@ -1582,28 +1567,30 @@ VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey) { - CM_PARTIAL_RESOURCE_LIST PartialResourceList; + PCM_PARTIAL_RESOURCE_LIST PartialResourceList; PCONFIGURATION_COMPONENT_DATA ControllerKey; PCONFIGURATION_COMPONENT_DATA PeripheralKey; + ULONG Size;
if (DetectPS2AuxPort()) { TRACE("Detected PS2 port\n");
- memset(&PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST)); + PartialResourceList = MmHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST)); + memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST));
/* Initialize resource descriptor */ - PartialResourceList.Version = 1; - PartialResourceList.Revision = 1; - PartialResourceList.Count = 1; + PartialResourceList->Version = 1; + PartialResourceList->Revision = 1; + PartialResourceList->Count = 1;
/* Set Interrupt */ - PartialResourceList.PartialDescriptors[0].Type = CmResourceTypeInterrupt; - PartialResourceList.PartialDescriptors[0].ShareDisposition = CmResourceShareUndetermined; - PartialResourceList.PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED; - PartialResourceList.PartialDescriptors[0].u.Interrupt.Level = 12; - PartialResourceList.PartialDescriptors[0].u.Interrupt.Vector = 12; - PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF; + PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt; + PartialResourceList->PartialDescriptors[0].ShareDisposition = CmResourceShareUndetermined; + PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED; + PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12; + PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12; + PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
/* Create controller key */ FldrCreateComponentKey(BusKey, @@ -1613,7 +1600,7 @@ 0x0, 0xFFFFFFFF, NULL, - &PartialResourceList, + PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST), &ControllerKey); TRACE("Created key: PointerController\0\n"); @@ -1623,10 +1610,13 @@ TRACE("Detected PS2 mouse\n");
/* Initialize resource descriptor */ - memset(&PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST)); - PartialResourceList.Version = 1; - PartialResourceList.Revision = 1; - PartialResourceList.Count = 0; + Size = sizeof(CM_PARTIAL_RESOURCE_LIST) - + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); + PartialResourceList = MmHeapAlloc(Size); + memset(PartialResourceList, 0, Size); + PartialResourceList->Version = 1; + PartialResourceList->Revision = 1; + PartialResourceList->Count = 0;
/* Create peripheral key */ FldrCreateComponentKey(ControllerKey, @@ -1636,9 +1626,8 @@ 0x0, 0xFFFFFFFF, "MICROSOFT PS2 MOUSE", - &PartialResourceList, - sizeof(CM_PARTIAL_RESOURCE_LIST) - - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR), + PartialResourceList, + Size, &PeripheralKey); TRACE("Created key: PointerPeripheral\0\n"); } @@ -1731,8 +1720,6 @@ Size, &BusKey);
- MmHeapFree(PartialResourceList); - /* Detect ISA/BIOS devices */ DetectBiosDisks(BusKey);
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -115,8 +115,6 @@
/* Increment bus number */ (*BusNumber)++; - - MmHeapFree(PartialResourceList); } }
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -59,15 +59,20 @@ DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) { PCONFIGURATION_COMPONENT_DATA BiosKey; - CM_PARTIAL_RESOURCE_LIST PartialResourceList; + PCM_PARTIAL_RESOURCE_LIST PartialResourceList; + ULONG Size; + + Size = sizeof(CM_PARTIAL_RESOURCE_LIST) - + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
if (FindApmBios()) { /* Create 'Configuration Data' value */ - memset(&PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST)); - PartialResourceList.Version = 0; - PartialResourceList.Revision = 0; - PartialResourceList.Count = 0; + PartialResourceList = MmHeapAlloc(Size); + memset(&PartialResourceList, 0, Size); + PartialResourceList->Version = 0; + PartialResourceList->Revision = 0; + PartialResourceList->Count = 0;
/* Create new bus key */ FldrCreateComponentKey(SystemKey, @@ -77,9 +82,8 @@ 0x0, 0xFFFFFFFF, "APM", - &PartialResourceList, - sizeof(CM_PARTIAL_RESOURCE_LIST) - - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR), + PartialResourceList, + Size, &BiosKey);
/* Increment bus number */
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -158,8 +158,6 @@ PartialResourceList, Size, &TableKey); - - MmHeapFree(PartialResourceList); } }
@@ -204,8 +202,6 @@
/* Increment bus number */ (*BusNumber)++; - - MmHeapFree(PartialResourceList);
DetectPciIrqRoutingTable(BiosKey);
@@ -268,8 +264,6 @@ Size, &BusKey);
- MmHeapFree(PartialResourceList); - /* Increment bus number */ (*BusNumber)++; }
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -429,8 +429,6 @@ &ControllerKey); TRACE("Created key: DiskController\0\n");
- MmHeapFree(PartialResourceList); - /* Create and fill subkey for each harddisk */ for (i = 0; i < DiskCount; i++) { @@ -451,9 +449,6 @@ PartialResourceList, Size, &DiskKey); - - if (PartialResourceList) - MmHeapFree(PartialResourceList); } }
@@ -497,8 +492,6 @@ /* Increment bus number */ (*BusNumber)++;
- MmHeapFree(PartialResourceList); - /* Detect ISA/BIOS devices */ DetectBiosDisks(SystemKey, BusKey);
Modified: trunk/reactos/boot/freeldr/freeldr/bootmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/bootmg... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -21,7 +21,6 @@
ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information ULONG reactos_disk_count = 0; -CHAR reactos_arc_hardware_data[HW_MAX_ARC_HEAP_SIZE] = {0}; CHAR reactos_arc_strings[32][256];
typedef
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -24,8 +24,6 @@ OUT PCONFIGURATION_COMPONENT_DATA *SystemKey );
-#define HW_MAX_ARC_HEAP_SIZE 256 - extern PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock; extern ULONG FirstLevelDcacheSize; extern ULONG FirstLevelDcacheFillSize;
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -23,12 +23,6 @@ #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
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/powerpc/hardware.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/arch/powerpc/hardware.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/arch/powerpc/hardware.h [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -26,12 +26,6 @@
#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
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/reacto... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -14,17 +14,7 @@
/* GLOBALS ********************************************************************/
-extern CHAR reactos_arc_hardware_data[]; -SIZE_T FldrpHwHeapLocation; PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot; - -BOOLEAN UseRealHeap = FALSE; - -VOID -NTAPI -FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, - IN PCM_PARTIAL_RESOURCE_LIST ResourceList, - IN ULONG Size);
/* FUNCTIONS ******************************************************************/
@@ -34,26 +24,8 @@ { PVOID Buffer;
- if (UseRealHeap) - { - /* Allocate memory from generic bootloader heap */ - Buffer = MmHeapAlloc(Size); - } - else - { - /* 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; - } - - /* Clear it */ - if (Buffer) - RtlZeroMemory(Buffer, Size); - - /* Return the buffer */ + /* Allocate memory from generic bootloader heap */ + Buffer = MmHeapAlloc(Size); return Buffer; }
@@ -65,10 +37,10 @@ SIZE_T IdentifierLength; PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry; PCHAR Identifier; - + /* Allocate memory for the identifier */ IdentifierLength = strlen(IdentifierString) + 1; - Identifier = FldrpHwHeapAlloc(IdentifierLength); + Identifier = MmHeapAlloc(IdentifierLength); if (!Identifier) return;
/* Copy the identifier */ @@ -84,11 +56,11 @@ FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode) { PCONFIGURATION_COMPONENT Component; - + /* Allocate the root */ - FldrArcHwTreeRoot = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); + FldrArcHwTreeRoot = MmHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); if (!FldrArcHwTreeRoot) return; - + /* Set it up */ Component = &FldrArcHwTreeRoot->ComponentEntry; Component->Class = SystemClass; @@ -101,7 +73,7 @@ Component->Revision = 0; Component->Key = 0; Component->AffinityMask = 0xFFFFFFFF; - + /* Return the node */ *SystemNode = FldrArcHwTreeRoot; } @@ -130,7 +102,7 @@ /* This is now the parent */ Parent = Sibling; } while ((Sibling = Sibling->Sibling)); - + /* Found the lowest sibling; mark us as its sibling too */ Parent->Sibling = Child; } @@ -153,16 +125,16 @@ PCONFIGURATION_COMPONENT Component;
/* Allocate the node for this component */ - ComponentData = FldrpHwHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); + ComponentData = MmHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA)); if (!ComponentData) return; - + /* Now save our parent */ ComponentData->Parent = SystemNode; - + /* Link us to the parent */ if (SystemNode) FldrLinkToParent(SystemNode, ComponentData); - + /* Set us up */ Component = &ComponentData->ComponentEntry; Component->Class = Class; @@ -170,36 +142,19 @@ Component->Flags = Flags; Component->Key = Key; Component->AffinityMask = Affinity; - + /* Set identifier */ if (IdentifierString) FldrSetIdentifier(ComponentData, IdentifierString); - + /* Set configuration data */ if (ResourceList) - FldrSetConfigurationData(ComponentData, ResourceList, Size); - + { + ComponentData->ConfigurationData = ResourceList; + ComponentData->ComponentEntry.ConfigurationDataLength = Size; + } + /* Return the child */ - *ComponentKey = ComponentData; + *ComponentKey = ComponentData; }
-VOID -NTAPI -FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, - IN PCM_PARTIAL_RESOURCE_LIST ResourceList, - IN ULONG Size) -{ - 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, ResourceList, Size); - - /* Set component information */ - ComponentData->ConfigurationData = ConfigurationData; - Component->ConfigurationDataLength = Size; -}
Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/window... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] Mon Feb 25 20:07:17 2013 @@ -30,7 +30,6 @@ extern ULONG reactos_disk_count; extern ARC_DISK_SIGNATURE reactos_arc_disk_info[];
-extern BOOLEAN UseRealHeap; extern ULONG LoaderPagesSpanned; extern BOOLEAN AcpiPresent;
@@ -582,7 +581,6 @@ SystemRoot = strstr(BootPath, "\");
/* Detect hardware */ - UseRealHeap = TRUE; LoaderBlock->ConfigurationRoot = MachHwDetect();
if (OperatingSystemVersion == 0)