2 * PROJECT: ReactOS Boot Loader (FreeLDR)
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: boot/freeldr/freeldr/reactos/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 /* FUNCTIONS ******************************************************************/
23 FldrpHwHeapAlloc(IN SIZE_T Size
)
27 /* Allocate memory from generic bootloader heap */
28 Buffer
= MmHeapAlloc(Size
);
34 FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData
,
35 IN PCHAR IdentifierString
)
37 SIZE_T IdentifierLength
;
38 PCONFIGURATION_COMPONENT Component
= &ComponentData
->ComponentEntry
;
41 /* Allocate memory for the identifier */
42 IdentifierLength
= strlen(IdentifierString
) + 1;
43 Identifier
= MmHeapAlloc(IdentifierLength
);
44 if (!Identifier
) return;
46 /* Copy the identifier */
47 RtlCopyMemory(Identifier
, IdentifierString
, IdentifierLength
);
49 /* Set component information */
50 Component
->IdentifierLength
= (ULONG
)IdentifierLength
;
51 Component
->Identifier
= Identifier
;
56 FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA
*SystemNode
)
58 PCONFIGURATION_COMPONENT Component
;
60 /* Allocate the root */
61 FldrArcHwTreeRoot
= MmHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
));
62 if (!FldrArcHwTreeRoot
) return;
65 Component
= &FldrArcHwTreeRoot
->ComponentEntry
;
66 Component
->Class
= SystemClass
;
67 Component
->Type
= MaximumType
;
68 Component
->ConfigurationDataLength
= 0;
69 Component
->Identifier
= 0;
70 Component
->IdentifierLength
= 0;
72 Component
->Version
= 0;
73 Component
->Revision
= 0;
75 Component
->AffinityMask
= 0xFFFFFFFF;
78 *SystemNode
= FldrArcHwTreeRoot
;
83 FldrLinkToParent(IN PCONFIGURATION_COMPONENT_DATA Parent
,
84 IN PCONFIGURATION_COMPONENT_DATA Child
)
86 PCONFIGURATION_COMPONENT_DATA Sibling
;
88 /* Get the first sibling */
89 Sibling
= Parent
->Child
;
91 /* If no sibling exists, then we are the first child */
95 Parent
->Child
= Child
;
99 /* Loop each sibling */
102 /* This is now the parent */
104 } while ((Sibling
= Sibling
->Sibling
));
106 /* Found the lowest sibling; mark us as its sibling too */
107 Parent
->Sibling
= Child
;
113 FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode
,
114 IN CONFIGURATION_CLASS Class
,
115 IN CONFIGURATION_TYPE Type
,
116 IN IDENTIFIER_FLAG Flags
,
119 IN PCHAR IdentifierString
,
120 IN PCM_PARTIAL_RESOURCE_LIST ResourceList
,
122 OUT PCONFIGURATION_COMPONENT_DATA
*ComponentKey
)
124 PCONFIGURATION_COMPONENT_DATA ComponentData
;
125 PCONFIGURATION_COMPONENT Component
;
127 /* Allocate the node for this component */
128 ComponentData
= MmHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA
));
129 if (!ComponentData
) return;
131 /* Now save our parent */
132 ComponentData
->Parent
= SystemNode
;
134 /* Link us to the parent */
136 FldrLinkToParent(SystemNode
, ComponentData
);
139 Component
= &ComponentData
->ComponentEntry
;
140 Component
->Class
= Class
;
141 Component
->Type
= Type
;
142 Component
->Flags
= Flags
;
143 Component
->Key
= Key
;
144 Component
->AffinityMask
= Affinity
;
147 if (IdentifierString
)
148 FldrSetIdentifier(ComponentData
, IdentifierString
);
150 /* Set configuration data */
153 ComponentData
->ConfigurationData
= ResourceList
;
154 ComponentData
->ComponentEntry
.ConfigurationDataLength
= Size
;
157 /* Return the child */
158 *ComponentKey
= ComponentData
;