ReactOS 0.4.16-dev-122-g325d74c
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
66
67// ARC Disk Information
70
71/* FUNCTIONS ******************************************************************/
72
73#define TAG_HW_COMPONENT_DATA 'DCwH'
74#define TAG_HW_NAME 'mNwH'
75
76VOID
78 IN PSTR ArcName,
80 IN ULONG Checksum,
81 IN BOOLEAN ValidPartitionTable)
82{
84
85 /* Fill out the ARC disk block */
86
90
94
96}
97
98//
99// ARC Component Configuration Routines
100//
101
102static VOID
105 _In_ PCSTR IdentifierString)
106{
107 SIZE_T IdentifierLength;
109
110 /* Allocate memory for the identifier */
111 IdentifierLength = strlen(IdentifierString) + 1;
112 Identifier = FrLdrHeapAlloc(IdentifierLength, TAG_HW_NAME);
113 if (!Identifier) return;
114
115 /* Copy the identifier */
116 RtlCopyMemory(Identifier, IdentifierString, IdentifierLength);
117
118 /* Set component information */
119 Component->IdentifierLength = (ULONG)IdentifierLength;
120 Component->Identifier = Identifier;
121}
122
123VOID
128{
129 /* Set component information */
130 ComponentData->ConfigurationData = ResourceList;
131 ComponentData->ComponentEntry.ConfigurationDataLength = Size;
132}
133
134VOID
137 _In_ PCSTR IdentifierString)
138{
140
141 /* Allocate the root */
144 if (!FldrArcHwTreeRoot) return;
145
146 /* Set it up */
149 Component->Type = MaximumType;
150 Component->ConfigurationDataLength = 0;
151 Component->Identifier = 0;
152 Component->IdentifierLength = 0;
153 Component->Flags = 0;
154 Component->Version = 0;
155 Component->Revision = 0;
156 Component->Key = 0;
157 Component->AffinityMask = 0xFFFFFFFF;
158
159 /* Set identifier */
160 if (IdentifierString)
161 FldrSetIdentifier(Component, IdentifierString);
162
163 /* Return the node */
164 *SystemNode = FldrArcHwTreeRoot;
165}
166
167static VOID
171{
173
174 /* Get the first sibling */
175 Sibling = Parent->Child;
176
177 /* If no sibling exists, then we are the first child */
178 if (!Sibling)
179 {
180 /* Link us in */
181 Parent->Child = Child;
182 }
183 else
184 {
185 /* Loop each sibling */
186 do
187 {
188 /* This is now the parent */
189 Parent = Sibling;
190 } while ((Sibling = Sibling->Sibling));
191
192 /* Found the lowest sibling; mark us as its sibling too */
193 Parent->Sibling = Child;
194 }
195}
196
197VOID
203 _In_ ULONG Key,
205 _In_ PCSTR IdentifierString,
209{
210 PCONFIGURATION_COMPONENT_DATA ComponentData;
212
213 /* Allocate the node for this component */
214 ComponentData = FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA),
216 if (!ComponentData) return;
217
218 /* Now save our parent */
219 ComponentData->Parent = SystemNode;
220
221 /* Link us to the parent */
222 if (SystemNode)
223 FldrLinkToParent(SystemNode, ComponentData);
224
225 /* Set us up */
226 Component = &ComponentData->ComponentEntry;
228 Component->Type = Type;
229 Component->Flags = Flags;
230 Component->Key = Key;
231 Component->AffinityMask = Affinity;
232
233 /* Set identifier */
234 if (IdentifierString)
235 FldrSetIdentifier(Component, IdentifierString);
236
237 /* Set configuration data */
238 if (ResourceList)
240
241 TRACE("Created key: %s\\%d\n", ArcTypes[min(Type, MaximumType)], Key);
242
243 /* Return the child */
244 *ComponentKey = ComponentData;
245}
unsigned char BOOLEAN
Type
Definition: Type.h:7
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
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
VOID AddReactOSArcDiskInfo(IN PSTR ArcName, IN ULONG Signature, IN ULONG Checksum, IN BOOLEAN ValidPartitionTable)
Definition: archwsup.c:77
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot
Definition: archwsup.c:65
#define TAG_HW_NAME
Definition: archwsup.c:74
static VOID FldrSetIdentifier(_In_ PCONFIGURATION_COMPONENT Component, _In_ PCSTR IdentifierString)
Definition: archwsup.c:103
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:198
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:168
#define TAG_HW_COMPONENT_DATA
Definition: archwsup.c:73
VOID FldrSetConfigurationData(_Inout_ PCONFIGURATION_COMPONENT_DATA ComponentData, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size)
Definition: archwsup.c:124
ULONG reactos_disk_count
Definition: archwsup.c:68
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[32]
Definition: archwsup.c:69
@ Identifier
Definition: asmpp.cpp:95
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
static const WCHAR Signature[]
Definition: parser.c:141
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
@ SystemClass
Definition: arc.h:90
enum _CONFIGURATION_CLASS CONFIGURATION_CLASS
@ MaximumType
Definition: arc.h:145
enum _IDENTIFIER_FLAG IDENTIFIER_FLAG
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
#define TRACE(s)
Definition: solgame.cpp:4
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
ULONG CheckSum
Definition: arc.h:258
PCHAR ArcName
Definition: arc.h:257
BOOLEAN ValidPartitionTable
Definition: arc.h:259
ULONG Signature
Definition: arc.h:256
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:168
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:167
struct _CONFIGURATION_COMPONENT_DATA * Parent
Definition: arc.h:165
CONFIGURATION_CLASS Class
Definition: arc.h:151
char * PSTR
Definition: typedefs.h:51
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 IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_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:496