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 ULONG reactos_disk_count
= 0;
21 ARC_DISK_SIGNATURE_EX reactos_arc_disk_info
[32];
23 /* FUNCTIONS ******************************************************************/
25 #define TAG_HW_COMPONENT_DATA 'DCwH'
26 #define TAG_HW_NAME 'mNwH'
30 FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData
,
31 IN PCHAR IdentifierString
)
33 PCONFIGURATION_COMPONENT Component
= &ComponentData
->ComponentEntry
;
34 SIZE_T IdentifierLength
;
37 /* Allocate memory for the identifier */
38 IdentifierLength
= strlen(IdentifierString
) + 1;
39 Identifier
= FrLdrHeapAlloc(IdentifierLength
, TAG_HW_NAME
);
40 if (!Identifier
) return;
42 /* Copy the identifier */
43 RtlCopyMemory(Identifier
, IdentifierString
, IdentifierLength
);
45 /* Set component information */
46 Component
->IdentifierLength
= (ULONG
)IdentifierLength
;
47 Component
->Identifier
= Identifier
;
52 FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData
,
53 IN PCM_PARTIAL_RESOURCE_LIST ResourceList
,
56 /* Set component information */
57 ComponentData
->ConfigurationData
= ResourceList
;
58 ComponentData
->ComponentEntry
.ConfigurationDataLength
= Size
;
63 FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA
*SystemNode
)
65 PCONFIGURATION_COMPONENT Component
;
67 /* Allocate the root */
68 FldrArcHwTreeRoot
= FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
),
69 TAG_HW_COMPONENT_DATA
);
70 if (!FldrArcHwTreeRoot
) return;
73 Component
= &FldrArcHwTreeRoot
->ComponentEntry
;
74 Component
->Class
= SystemClass
;
75 Component
->Type
= MaximumType
;
76 Component
->ConfigurationDataLength
= 0;
77 Component
->Identifier
= 0;
78 Component
->IdentifierLength
= 0;
80 Component
->Version
= 0;
81 Component
->Revision
= 0;
83 Component
->AffinityMask
= 0xFFFFFFFF;
86 *SystemNode
= FldrArcHwTreeRoot
;
91 FldrLinkToParent(IN PCONFIGURATION_COMPONENT_DATA Parent
,
92 IN PCONFIGURATION_COMPONENT_DATA Child
)
94 PCONFIGURATION_COMPONENT_DATA Sibling
;
96 /* Get the first sibling */
97 Sibling
= Parent
->Child
;
99 /* If no sibling exists, then we are the first child */
103 Parent
->Child
= Child
;
107 /* Loop each sibling */
110 /* This is now the parent */
112 } while ((Sibling
= Sibling
->Sibling
));
114 /* Found the lowest sibling; mark us as its sibling too */
115 Parent
->Sibling
= Child
;
121 FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode
,
122 IN CONFIGURATION_CLASS Class
,
123 IN CONFIGURATION_TYPE Type
,
124 IN IDENTIFIER_FLAG Flags
,
127 IN PCHAR IdentifierString
,
128 IN PCM_PARTIAL_RESOURCE_LIST ResourceList
,
130 OUT PCONFIGURATION_COMPONENT_DATA
*ComponentKey
)
132 PCONFIGURATION_COMPONENT_DATA ComponentData
;
133 PCONFIGURATION_COMPONENT Component
;
135 /* Allocate the node for this component */
136 ComponentData
= FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
),
137 TAG_HW_COMPONENT_DATA
);
138 if (!ComponentData
) return;
140 /* Now save our parent */
141 ComponentData
->Parent
= SystemNode
;
143 /* Link us to the parent */
145 FldrLinkToParent(SystemNode
, ComponentData
);
148 Component
= &ComponentData
->ComponentEntry
;
149 Component
->Class
= Class
;
150 Component
->Type
= Type
;
151 Component
->Flags
= Flags
;
152 Component
->Key
= Key
;
153 Component
->AffinityMask
= Affinity
;
156 if (IdentifierString
)
157 FldrSetIdentifier(ComponentData
, IdentifierString
);
159 /* Set configuration data */
161 FldrSetConfigurationData(ComponentData
, ResourceList
, Size
);
163 /* Return the child */
164 *ComponentKey
= ComponentData
;