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'
29 AddReactOSArcDiskInfo(
33 IN BOOLEAN ValidPartitionTable
)
35 ASSERT(reactos_disk_count
< sizeof(reactos_arc_disk_info
)/sizeof(reactos_arc_disk_info
[0]));
37 /* Fill out the ARC disk block */
39 reactos_arc_disk_info
[reactos_disk_count
].DiskSignature
.Signature
= Signature
;
40 reactos_arc_disk_info
[reactos_disk_count
].DiskSignature
.CheckSum
= Checksum
;
41 reactos_arc_disk_info
[reactos_disk_count
].DiskSignature
.ValidPartitionTable
= ValidPartitionTable
;
43 strcpy(reactos_arc_disk_info
[reactos_disk_count
].ArcName
, ArcName
);
44 reactos_arc_disk_info
[reactos_disk_count
].DiskSignature
.ArcName
=
45 reactos_arc_disk_info
[reactos_disk_count
].ArcName
;
51 // ARC Component Configuration Routines
56 FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData
,
57 IN PCHAR IdentifierString
)
59 PCONFIGURATION_COMPONENT Component
= &ComponentData
->ComponentEntry
;
60 SIZE_T IdentifierLength
;
63 /* Allocate memory for the identifier */
64 IdentifierLength
= strlen(IdentifierString
) + 1;
65 Identifier
= FrLdrHeapAlloc(IdentifierLength
, TAG_HW_NAME
);
66 if (!Identifier
) return;
68 /* Copy the identifier */
69 RtlCopyMemory(Identifier
, IdentifierString
, IdentifierLength
);
71 /* Set component information */
72 Component
->IdentifierLength
= (ULONG
)IdentifierLength
;
73 Component
->Identifier
= Identifier
;
78 FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData
,
79 IN PCM_PARTIAL_RESOURCE_LIST ResourceList
,
82 /* Set component information */
83 ComponentData
->ConfigurationData
= ResourceList
;
84 ComponentData
->ComponentEntry
.ConfigurationDataLength
= Size
;
89 FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA
*SystemNode
)
91 PCONFIGURATION_COMPONENT Component
;
93 /* Allocate the root */
94 FldrArcHwTreeRoot
= FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
),
95 TAG_HW_COMPONENT_DATA
);
96 if (!FldrArcHwTreeRoot
) return;
99 Component
= &FldrArcHwTreeRoot
->ComponentEntry
;
100 Component
->Class
= SystemClass
;
101 Component
->Type
= MaximumType
;
102 Component
->ConfigurationDataLength
= 0;
103 Component
->Identifier
= 0;
104 Component
->IdentifierLength
= 0;
105 Component
->Flags
= 0;
106 Component
->Version
= 0;
107 Component
->Revision
= 0;
109 Component
->AffinityMask
= 0xFFFFFFFF;
111 /* Return the node */
112 *SystemNode
= FldrArcHwTreeRoot
;
117 FldrLinkToParent(IN PCONFIGURATION_COMPONENT_DATA Parent
,
118 IN PCONFIGURATION_COMPONENT_DATA Child
)
120 PCONFIGURATION_COMPONENT_DATA Sibling
;
122 /* Get the first sibling */
123 Sibling
= Parent
->Child
;
125 /* If no sibling exists, then we are the first child */
129 Parent
->Child
= Child
;
133 /* Loop each sibling */
136 /* This is now the parent */
138 } while ((Sibling
= Sibling
->Sibling
));
140 /* Found the lowest sibling; mark us as its sibling too */
141 Parent
->Sibling
= Child
;
147 FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode
,
148 IN CONFIGURATION_CLASS Class
,
149 IN CONFIGURATION_TYPE Type
,
150 IN IDENTIFIER_FLAG Flags
,
153 IN PCHAR IdentifierString
,
154 IN PCM_PARTIAL_RESOURCE_LIST ResourceList
,
156 OUT PCONFIGURATION_COMPONENT_DATA
*ComponentKey
)
158 PCONFIGURATION_COMPONENT_DATA ComponentData
;
159 PCONFIGURATION_COMPONENT Component
;
161 /* Allocate the node for this component */
162 ComponentData
= FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
),
163 TAG_HW_COMPONENT_DATA
);
164 if (!ComponentData
) return;
166 /* Now save our parent */
167 ComponentData
->Parent
= SystemNode
;
169 /* Link us to the parent */
171 FldrLinkToParent(SystemNode
, ComponentData
);
174 Component
= &ComponentData
->ComponentEntry
;
175 Component
->Class
= Class
;
176 Component
->Type
= Type
;
177 Component
->Flags
= Flags
;
178 Component
->Key
= Key
;
179 Component
->AffinityMask
= Affinity
;
182 if (IdentifierString
)
183 FldrSetIdentifier(ComponentData
, IdentifierString
);
185 /* Set configuration data */
187 FldrSetConfigurationData(ComponentData
, ResourceList
, Size
);
189 /* Return the child */
190 *ComponentKey
= ComponentData
;