2 * PROJECT: ReactOS Boot Loader (FreeLDR)
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: boot/freeldr/freeldr/arch/archwsup.c
5 * PURPOSE: Routines for ARC Hardware Tree and Configuration Data
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES *******************************************************************/
15 /* GLOBALS ********************************************************************/
17 PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot
;
19 // ARC Disk Information
20 ARC_DISK_SIGNATURE reactos_arc_disk_info
[32];
21 ULONG reactos_disk_count
= 0;
22 CHAR reactos_arc_strings
[32][256];
24 /* FUNCTIONS ******************************************************************/
26 #define TAG_HW_COMPONENT_DATA 'DCwH'
27 #define TAG_HW_NAME 'mNwH'
31 FldrpHwHeapAlloc(IN SIZE_T Size
)
35 /* Allocate memory from generic bootloader heap */
36 Buffer
= FrLdrHeapAlloc(Size
, 'pHwH');
42 FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData
,
43 IN PCHAR IdentifierString
)
45 SIZE_T IdentifierLength
;
46 PCONFIGURATION_COMPONENT Component
= &ComponentData
->ComponentEntry
;
49 /* Allocate memory for the identifier */
50 IdentifierLength
= strlen(IdentifierString
) + 1;
51 Identifier
= FrLdrHeapAlloc(IdentifierLength
, TAG_HW_NAME
);
52 if (!Identifier
) return;
54 /* Copy the identifier */
55 RtlCopyMemory(Identifier
, IdentifierString
, IdentifierLength
);
57 /* Set component information */
58 Component
->IdentifierLength
= (ULONG
)IdentifierLength
;
59 Component
->Identifier
= Identifier
;
64 FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA
*SystemNode
)
66 PCONFIGURATION_COMPONENT Component
;
68 /* Allocate the root */
69 FldrArcHwTreeRoot
= FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
),
70 TAG_HW_COMPONENT_DATA
);
71 if (!FldrArcHwTreeRoot
) return;
74 Component
= &FldrArcHwTreeRoot
->ComponentEntry
;
75 Component
->Class
= SystemClass
;
76 Component
->Type
= MaximumType
;
77 Component
->ConfigurationDataLength
= 0;
78 Component
->Identifier
= 0;
79 Component
->IdentifierLength
= 0;
81 Component
->Version
= 0;
82 Component
->Revision
= 0;
84 Component
->AffinityMask
= 0xFFFFFFFF;
87 *SystemNode
= FldrArcHwTreeRoot
;
92 FldrLinkToParent(IN PCONFIGURATION_COMPONENT_DATA Parent
,
93 IN PCONFIGURATION_COMPONENT_DATA Child
)
95 PCONFIGURATION_COMPONENT_DATA Sibling
;
97 /* Get the first sibling */
98 Sibling
= Parent
->Child
;
100 /* If no sibling exists, then we are the first child */
104 Parent
->Child
= Child
;
108 /* Loop each sibling */
111 /* This is now the parent */
113 } while ((Sibling
= Sibling
->Sibling
));
115 /* Found the lowest sibling; mark us as its sibling too */
116 Parent
->Sibling
= Child
;
122 FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode
,
123 IN CONFIGURATION_CLASS Class
,
124 IN CONFIGURATION_TYPE Type
,
125 IN IDENTIFIER_FLAG Flags
,
128 IN PCHAR IdentifierString
,
129 IN PCM_PARTIAL_RESOURCE_LIST ResourceList
,
131 OUT PCONFIGURATION_COMPONENT_DATA
*ComponentKey
)
133 PCONFIGURATION_COMPONENT_DATA ComponentData
;
134 PCONFIGURATION_COMPONENT Component
;
136 /* Allocate the node for this component */
137 ComponentData
= FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
),
138 TAG_HW_COMPONENT_DATA
);
139 if (!ComponentData
) return;
141 /* Now save our parent */
142 ComponentData
->Parent
= SystemNode
;
144 /* Link us to the parent */
146 FldrLinkToParent(SystemNode
, ComponentData
);
149 Component
= &ComponentData
->ComponentEntry
;
150 Component
->Class
= Class
;
151 Component
->Type
= Type
;
152 Component
->Flags
= Flags
;
153 Component
->Key
= Key
;
154 Component
->AffinityMask
= Affinity
;
157 if (IdentifierString
)
158 FldrSetIdentifier(ComponentData
, IdentifierString
);
160 /* Set configuration data */
163 ComponentData
->ConfigurationData
= ResourceList
;
164 ComponentData
->ComponentEntry
.ConfigurationDataLength
= Size
;
167 /* Return the child */
168 *ComponentKey
= ComponentData
;