[FREELDR] Simplify code by using a AddReactOSArcDiskInfo() helper, and few extra...
[reactos.git] / boot / freeldr / freeldr / arch / archwsup.c
index 71fad44..e4e4487 100644 (file)
@@ -9,7 +9,7 @@
 /* INCLUDES *******************************************************************/
 
 #include <freeldr.h>
-#define NDEBUG
+
 #include <debug.h>
 
 /* GLOBALS ********************************************************************/
 PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot;
 
 // ARC Disk Information
-ARC_DISK_SIGNATURE reactos_arc_disk_info[32];
 ULONG reactos_disk_count = 0;
-CHAR reactos_arc_strings[32][256];
+ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[32];
 
 /* FUNCTIONS ******************************************************************/
 
-#define TAG_HW_COMPONENT_DATA 'DCwH'
-#define TAG_HW_NAME 'mNwH'
+#define TAG_HW_COMPONENT_DATA   'DCwH'
+#define TAG_HW_NAME             'mNwH'
 
-PVOID
-NTAPI
-FldrpHwHeapAlloc(IN SIZE_T Size)
+VOID
+AddReactOSArcDiskInfo(
+    IN PSTR ArcName,
+    IN ULONG Signature,
+    IN ULONG Checksum,
+    IN BOOLEAN ValidPartitionTable)
 {
-    PVOID Buffer;
+    ASSERT(reactos_disk_count < sizeof(reactos_arc_disk_info)/sizeof(reactos_arc_disk_info[0]));
+
+    /* Fill out the ARC disk block */
+
+    reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = Signature;
+    reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = Checksum;
+    reactos_arc_disk_info[reactos_disk_count].DiskSignature.ValidPartitionTable = ValidPartitionTable;
 
-    /* Allocate memory from generic bootloader heap */
-    Buffer = FrLdrHeapAlloc(Size, 'pHwH');
-    return Buffer;
+    strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, ArcName);
+    reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName =
+        reactos_arc_disk_info[reactos_disk_count].ArcName;
+
+    reactos_disk_count++;
 }
 
-static VOID
+//
+// ARC Component Configuration Routines
+//
+
+VOID
 NTAPI
 FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
                   IN PCHAR IdentifierString)
 {
-    SIZE_T IdentifierLength;
     PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
+    SIZE_T IdentifierLength;
     PCHAR Identifier;
 
     /* Allocate memory for the identifier */
@@ -59,6 +73,17 @@ FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
     Component->Identifier = Identifier;
 }
 
+VOID
+NTAPI
+FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
+                         IN PCM_PARTIAL_RESOURCE_LIST ResourceList,
+                         IN ULONG Size)
+{
+    /* Set component information */
+    ComponentData->ConfigurationData = ResourceList;
+    ComponentData->ComponentEntry.ConfigurationDataLength = Size;
+}
+
 VOID
 NTAPI
 FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
@@ -159,10 +184,7 @@ FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode,
 
     /* Set configuration data */
     if (ResourceList)
-    {
-        ComponentData->ConfigurationData = ResourceList;
-        ComponentData->ComponentEntry.ConfigurationDataLength = Size;
-    }
+        FldrSetConfigurationData(ComponentData, ResourceList, Size);
 
     /* Return the child */
     *ComponentKey = ComponentData;