ReactOS  0.4.14-dev-77-gd9e7c48
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>
14 
15 /* GLOBALS ********************************************************************/
16 
18 
19 // ARC Disk Information
22 
23 /* FUNCTIONS ******************************************************************/
24 
25 #define TAG_HW_COMPONENT_DATA 'DCwH'
26 #define TAG_HW_NAME 'mNwH'
27 
28 VOID
30  IN PSTR ArcName,
32  IN ULONG Checksum,
33  IN BOOLEAN ValidPartitionTable)
34 {
36 
37  /* Fill out the ARC disk block */
38 
42 
46 
48 }
49 
50 //
51 // ARC Component Configuration Routines
52 //
53 
54 VOID
55 NTAPI
57  IN PCHAR IdentifierString)
58 {
59  PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry;
60  SIZE_T IdentifierLength;
61  PCHAR Identifier;
62 
63  /* Allocate memory for the identifier */
64  IdentifierLength = strlen(IdentifierString) + 1;
65  Identifier = FrLdrHeapAlloc(IdentifierLength, TAG_HW_NAME);
66  if (!Identifier) return;
67 
68  /* Copy the identifier */
69  RtlCopyMemory(Identifier, IdentifierString, IdentifierLength);
70 
71  /* Set component information */
72  Component->IdentifierLength = (ULONG)IdentifierLength;
73  Component->Identifier = Identifier;
74 }
75 
76 VOID
77 NTAPI
80  IN ULONG Size)
81 {
82  /* Set component information */
83  ComponentData->ConfigurationData = ResourceList;
84  ComponentData->ComponentEntry.ConfigurationDataLength = Size;
85 }
86 
87 VOID
88 NTAPI
90 {
91  PCONFIGURATION_COMPONENT Component;
92 
93  /* Allocate the root */
96  if (!FldrArcHwTreeRoot) return;
97 
98  /* Set it up */
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;
108  Component->Key = 0;
109  Component->AffinityMask = 0xFFFFFFFF;
110 
111  /* Return the node */
112  *SystemNode = FldrArcHwTreeRoot;
113 }
114 
115 static VOID
116 NTAPI
119 {
121 
122  /* Get the first sibling */
123  Sibling = Parent->Child;
124 
125  /* If no sibling exists, then we are the first child */
126  if (!Sibling)
127  {
128  /* Link us in */
129  Parent->Child = Child;
130  }
131  else
132  {
133  /* Loop each sibling */
134  do
135  {
136  /* This is now the parent */
137  Parent = Sibling;
138  } while ((Sibling = Sibling->Sibling));
139 
140  /* Found the lowest sibling; mark us as its sibling too */
141  Parent->Sibling = Child;
142  }
143 }
144 
145 VOID
146 NTAPI
151  IN ULONG Key,
152  IN ULONG Affinity,
153  IN PCHAR IdentifierString,
155  IN ULONG Size,
156  OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
157 {
158  PCONFIGURATION_COMPONENT_DATA ComponentData;
159  PCONFIGURATION_COMPONENT Component;
160 
161  /* Allocate the node for this component */
162  ComponentData = FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA),
164  if (!ComponentData) return;
165 
166  /* Now save our parent */
167  ComponentData->Parent = SystemNode;
168 
169  /* Link us to the parent */
170  if (SystemNode)
171  FldrLinkToParent(SystemNode, ComponentData);
172 
173  /* Set us up */
174  Component = &ComponentData->ComponentEntry;
175  Component->Class = Class;
176  Component->Type = Type;
177  Component->Flags = Flags;
178  Component->Key = Key;
179  Component->AffinityMask = Affinity;
180 
181  /* Set identifier */
182  if (IdentifierString)
183  FldrSetIdentifier(ComponentData, IdentifierString);
184 
185  /* Set configuration data */
186  if (ResourceList)
187  FldrSetConfigurationData(ComponentData, ResourceList, Size);
188 
189  /* Return the child */
190  *ComponentKey = ComponentData;
191 }
VOID NTAPI FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData, IN PCHAR IdentifierString)
Definition: archwsup.c:56
ULONG IdentifierLength
Definition: arc.h:112
IDENTIFIER_FLAG Flags
Definition: arc.h:106
signed char * PCHAR
Definition: retypes.h:7
static const WCHAR Class[]
Definition: cfgmgr.c:39
#define IN
Definition: typedefs.h:38
ULONG ConfigurationDataLength
Definition: arc.h:111
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG Key
Definition: fatprocs.h:2697
Type
Definition: Type.h:6
ULONG reactos_disk_count
Definition: archwsup.c:20
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PCHAR ArcName
Definition: arc.h:210
#define TAG_HW_COMPONENT_DATA
Definition: archwsup.c:25
ULONG Signature
Definition: arc.h:209
struct _CONFIGURATION_COMPONENT_DATA * Parent
Definition: arc.h:118
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:722
PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot
Definition: archwsup.c:17
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
CONFIGURATION_TYPE Type
Definition: arc.h:105
unsigned char BOOLEAN
enum _IDENTIFIER_FLAG IDENTIFIER_FLAG
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
CONFIGURATION_CLASS Class
Definition: arc.h:104
#define TAG_HW_NAME
Definition: archwsup.c:26
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[32]
Definition: archwsup.c:21
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:121
static VOID NTAPI FldrLinkToParent(IN PCONFIGURATION_COMPONENT_DATA Parent, IN PCONFIGURATION_COMPONENT_DATA Child)
Definition: archwsup.c:117
CONFIGURATION_TYPE
Definition: iotypes.h:4037
VOID AddReactOSArcDiskInfo(IN PSTR ArcName, IN ULONG Signature, IN ULONG Checksum, IN BOOLEAN ValidPartitionTable)
Definition: archwsup.c:29
BOOLEAN ValidPartitionTable
Definition: arc.h:212
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
VOID NTAPI 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 PCHAR IdentifierString, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size, OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:147
enum _CONFIGURATION_CLASS CONFIGURATION_CLASS
ULONG_PTR SIZE_T
Definition: typedefs.h:78
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:120
signed char * PSTR
Definition: retypes.h:7
#define OUT
Definition: typedefs.h:39
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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 ACPI_HANDLE Child
Definition: acpixf.h:722
VOID NTAPI FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
Definition: archwsup.c:89
ULONG CheckSum
Definition: arc.h:211
static const WCHAR Signature[]
Definition: parser.c:141
VOID NTAPI FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size)
Definition: archwsup.c:78