Author: fireball
Date: Mon Dec 10 01:57:40 2007
New Revision: 31116
URL:
http://svn.reactos.org/svn/reactos?rev=31116&view=rev
Log:
- 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.
Modified:
trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h
trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c
trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h Mon Dec 10 01:57:40
2007
@@ -27,6 +27,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
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/archwsup.c Mon Dec 10 01:57:40 2007
@@ -14,9 +14,28 @@
/* 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
@@ -51,21 +70,31 @@
VOID
NTAPI
FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
- IN PWCHAR Identifier)
-{
- LONG Error;
- ULONG IdentifierLength = (wcslen(Identifier) + 1) * sizeof(WCHAR);
+ IN PWCHAR IdentifierString)
+{
+ LONG Error;
+ 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 @@
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 @@
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 @@
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)
{
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c Mon Dec 10 01:57:40 2007
@@ -35,6 +35,8 @@
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 @@
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)
{