- 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:
Aleksey Bragin 2007-12-09 22:57:40 +00:00
parent 4fa42fad47
commit 222172277b
3 changed files with 57 additions and 10 deletions

View file

@ -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
//

View file

@ -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)
{

View file

@ -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)
{