ReactOS 0.4.16-dev-2610-ge2c92c0
archwsup.c
Go to the documentation of this file.
1/*
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)
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <freeldr.h>
12
13#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
18/* Strings corresponding to CONFIGURATION_TYPE */
19const PCSTR ArcTypes[MaximumType + 1] = // CmTypeName
20{
21 "System",
22 "CentralProcessor",
23 "FloatingPointProcessor",
24 "PrimaryICache",
25 "PrimaryDCache",
26 "SecondaryICache",
27 "SecondaryDCache",
28 "SecondaryCache",
29 "EisaAdapter",
30 "TcAdapter",
31 "ScsiAdapter",
32 "DtiAdapter",
33 "MultifunctionAdapter",
34 "DiskController",
35 "TapeController",
36 "CdRomController",
37 "WormController",
38 "SerialController",
39 "NetworkController",
40 "DisplayController",
41 "ParallelController",
42 "PointerController",
43 "KeyboardController",
44 "AudioController",
45 "OtherController",
46 "DiskPeripheral",
47 "FloppyDiskPeripheral",
48 "TapePeripheral",
49 "ModemPeripheral",
50 "MonitorPeripheral",
51 "PrinterPeripheral",
52 "PointerPeripheral",
53 "KeyboardPeripheral",
54 "TerminalPeripheral",
55 "OtherPeripheral",
56 "LinePeripheral",
57 "NetworkPeripheral",
58 "SystemMemory",
59 "DockingInformation",
60 "RealModeIrqRoutingTable",
61 "RealModePCIEnumeration",
62 "Undefined"
63};
64
65#define TAG_HW_COMPONENT_DATA 'DCwH'
66#define TAG_HW_NAME 'mNwH'
67
69
70// ARC Disk Information
73
74/* FUNCTIONS ******************************************************************/
75
76VOID
78 _In_ PCSTR ArcName,
79 _In_opt_ PGUID GptDiskGuid,
81 _In_ ULONG Checksum,
82 _In_ BOOLEAN ValidPartitionTable)
83{
84 PARC_DISK_SIGNATURE ArcDiskSignature;
85 C_ASSERT(sizeof(*GptDiskGuid) == sizeof(ArcDiskSignature->GptSignature));
86
88
89 /* Fill out the ARC disk block */
93
94 ArcDiskSignature->Signature = Signature;
95 ArcDiskSignature->CheckSum = Checksum;
96 ArcDiskSignature->ValidPartitionTable = ValidPartitionTable;
97
98 ArcDiskSignature->IsGpt = (GptDiskGuid != NULL);
99 if (GptDiskGuid)
100 {
101 RtlCopyMemory(&ArcDiskSignature->GptSignature,
102 GptDiskGuid, sizeof(*GptDiskGuid));
103 }
104
107
109}
110
112{
113 return reactos_disk_count;
114}
115
117{
119 return NULL;
121}
122
123
124//
125// ARC Component Configuration Routines
126//
127
128static VOID
131 _In_ PCSTR IdentifierString)
132{
133 SIZE_T IdentifierLength;
135
136 /* Allocate memory for the identifier */
137 IdentifierLength = strlen(IdentifierString) + 1;
138 Identifier = FrLdrHeapAlloc(IdentifierLength, TAG_HW_NAME);
139 if (!Identifier) return;
140
141 /* Copy the identifier */
142 RtlCopyMemory(Identifier, IdentifierString, IdentifierLength);
143
144 /* Set component information */
145 Component->IdentifierLength = (ULONG)IdentifierLength;
146 Component->Identifier = Identifier;
147}
148
149VOID
154{
155 /* Set component information */
156 ComponentData->ConfigurationData = ResourceList;
157 ComponentData->ComponentEntry.ConfigurationDataLength = Size;
158}
159
160VOID
163 _In_ PCSTR IdentifierString)
164{
166
167 /* Allocate the root */
170 if (!FldrArcHwTreeRoot) return;
171
172 /* Set it up */
175 Component->Type = MaximumType;
176 Component->ConfigurationDataLength = 0;
177 Component->Identifier = 0;
178 Component->IdentifierLength = 0;
179 Component->Flags = 0;
180 Component->Version = 0;
181 Component->Revision = 0;
182 Component->Key = 0;
183 Component->AffinityMask = 0xFFFFFFFF;
184
185 /* Set identifier */
186 if (IdentifierString)
187 FldrSetIdentifier(Component, IdentifierString);
188
189 /* Return the node */
190 *SystemNode = FldrArcHwTreeRoot;
191}
192
193static VOID
197{
199
200 /* Get the first sibling */
201 Sibling = Parent->Child;
202
203 /* If no sibling exists, then we are the first child */
204 if (!Sibling)
205 {
206 /* Link us in */
207 Parent->Child = Child;
208 }
209 else
210 {
211 /* Loop each sibling */
212 do
213 {
214 /* This is now the parent */
215 Parent = Sibling;
216 } while ((Sibling = Sibling->Sibling));
217
218 /* Found the lowest sibling; mark us as its sibling too */
219 Parent->Sibling = Child;
220 }
221}
222
223VOID
229 _In_ ULONG Key,
231 _In_ PCSTR IdentifierString,
235{
236 PCONFIGURATION_COMPONENT_DATA ComponentData;
238
239 /* Allocate the node for this component */
240 ComponentData = FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA),
242 if (!ComponentData) return;
243
244 /* Now save our parent */
245 ComponentData->Parent = SystemNode;
246
247 /* Link us to the parent */
248 if (SystemNode)
249 FldrLinkToParent(SystemNode, ComponentData);
250
251 /* Set us up */
252 Component = &ComponentData->ComponentEntry;
254 Component->Type = Type;
255 Component->Flags = Flags;
256 Component->Key = Key;
257 Component->AffinityMask = Affinity;
258
259 /* Set identifier */
260 if (IdentifierString)
261 FldrSetIdentifier(Component, IdentifierString);
262
263 /* Set configuration data */
264 if (ResourceList)
266
267 TRACE("Created key: %s\\%d\n", ArcTypes[min(Type, MaximumType)], Key);
268
269 /* Return the child */
270 *ComponentKey = ComponentData;
271}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
Type
Definition: Type.h:7
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
unsigned char BOOLEAN
Definition: actypes.h:127
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:161
PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot
Definition: archwsup.c:68
#define TAG_HW_NAME
Definition: archwsup.c:66
static VOID FldrSetIdentifier(_In_ PCONFIGURATION_COMPONENT Component, _In_ PCSTR IdentifierString)
Definition: archwsup.c:129
VOID FldrCreateComponentKey(_In_ PCONFIGURATION_COMPONENT_DATA SystemNode, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_ IDENTIFIER_FLAG Flags, _In_ ULONG Key, _In_ ULONG Affinity, _In_ PCSTR IdentifierString, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size, _Out_ PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:224
VOID AddReactOSArcDiskInfo(_In_ PCSTR ArcName, _In_opt_ PGUID GptDiskGuid, _In_ ULONG Signature, _In_ ULONG Checksum, _In_ BOOLEAN ValidPartitionTable)
Definition: archwsup.c:77
const PCSTR ArcTypes[MaximumType+1]
Definition: archwsup.c:19
static VOID FldrLinkToParent(_In_ PCONFIGURATION_COMPONENT_DATA Parent, _In_ PCONFIGURATION_COMPONENT_DATA Child)
Definition: archwsup.c:194
ULONG ArcGetDiskCount(VOID)
Definition: archwsup.c:111
#define TAG_HW_COMPONENT_DATA
Definition: archwsup.c:65
PARC_DISK_SIGNATURE_EX ArcGetDiskInfo(ULONG Index)
Definition: archwsup.c:116
VOID FldrSetConfigurationData(_Inout_ PCONFIGURATION_COMPONENT_DATA ComponentData, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size)
Definition: archwsup.c:150
ULONG reactos_disk_count
Definition: archwsup.c:71
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[32]
Definition: archwsup.c:72
@ Identifier
Definition: asmpp.cpp:95
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
#define NULL
Definition: types.h:112
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
static const WCHAR Signature[]
Definition: parser.c:141
#define C_ASSERT(e)
Definition: intsafe.h:73
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
@ SystemClass
Definition: arc.h:99
enum _CONFIGURATION_CLASS CONFIGURATION_CLASS
@ MaximumType
Definition: arc.h:154
enum _IDENTIFIER_FLAG IDENTIFIER_FLAG
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
strcpy
Definition: string.h:131
#define TRACE(s)
Definition: solgame.cpp:4
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
BOOLEAN IsGpt
Definition: arc.h:349
ULONG CheckSum
Definition: arc.h:346
CHAR GptSignature[16]
Definition: arc.h:351
PCHAR ArcName
Definition: arc.h:345
BOOLEAN ValidPartitionTable
Definition: arc.h:347
ULONG Signature
Definition: arc.h:344
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:287
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:286
struct _CONFIGURATION_COMPONENT_DATA * Parent
Definition: arc.h:284
CONFIGURATION_CLASS Class
Definition: arc.h:160
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
_In_ ULONG Component
Definition: potypes.h:499