ReactOS 0.4.16-dev-340-g0540c21
cmconfig.c File Reference
#include "ntoskrnl.h"
#include "debug.h"
Include dependency graph for cmconfig.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI CmpInitializeRegistryNode (IN PCONFIGURATION_COMPONENT_DATA CurrentEntry, IN HANDLE NodeHandle, OUT PHANDLE NewHandle, IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PUSHORT DeviceIndexTable)
 
NTSTATUS NTAPI CmpSetupConfigurationTree (IN PCONFIGURATION_COMPONENT_DATA CurrentEntry, IN HANDLE ParentHandle, IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
 
NTSTATUS NTAPI CmpInitializeHardwareConfiguration (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file cmconfig.c.

Function Documentation

◆ CmpInitializeHardwareConfiguration()

NTSTATUS NTAPI CmpInitializeHardwareConfiguration ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 329 of file cmconfig.c.

330{
336
337 /* Set the alternative system architecture information */
338#if defined(SARCH_PC98)
339 SharedUserData->AlternativeArchitecture = NEC98x86;
340#endif
341
342 /* Setup the key name */
344 L"\\Registry\\Machine\\Hardware\\DeviceMap");
346 &KeyName,
348 NULL,
349 NULL);
350
351 /* Create the device map key */
355 0,
356 NULL,
357 0,
358 &Disposition);
359 if (!NT_SUCCESS(Status))
360 return Status;
362
363 /* Nobody should've created this key yet! */
365
366 /* Setup the key name */
368 L"\\Registry\\Machine\\Hardware\\Description");
370 &KeyName,
372 NULL,
373 NULL);
374
375 /* Create the description key */
379 0,
380 NULL,
381 0,
382 &Disposition);
383 if (!NT_SUCCESS(Status))
384 return Status;
385
386 /* Nobody should've created this key yet! */
388
389 /* Allocate the configuration data buffer */
392 TAG_CM);
394 {
397 }
398
399 /* Check if we got anything from NTLDR */
400 if (LoaderBlock->ConfigurationRoot)
401 {
402 /* Setup the configuration tree */
403 Status = CmpSetupConfigurationTree(LoaderBlock->ConfigurationRoot,
404 KeyHandle,
406 -1);
407 }
408 else
409 {
410 /* Nothing else to do */
412 }
413
414 /* Free the buffer, close our handle and return status */
417 return Status;
418}
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI CmpSetupConfigurationTree(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry, IN HANDLE ParentHandle, IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: cmconfig.c:205
PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData
Definition: cmdata.c:37
ULONG CmpConfigurationAreaSize
Definition: cmdata.c:36
#define TAG_CM
Definition: cmlib.h:212
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
#define L(x)
Definition: ntvdm.h:50
#define SharedUserData
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
@ NEC98x86
Definition: ketypes.h:903

Referenced by CmInitSystem1().

◆ CmpInitializeRegistryNode()

NTSTATUS NTAPI CmpInitializeRegistryNode ( IN PCONFIGURATION_COMPONENT_DATA  CurrentEntry,
IN HANDLE  NodeHandle,
OUT PHANDLE  NewHandle,
IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN PUSHORT  DeviceIndexTable 
)

Definition at line 20 of file cmconfig.c.

26{
30 HANDLE KeyHandle, ParentHandle;
31 ANSI_STRING TempString;
32 CHAR TempBuffer[12];
33 WCHAR Buffer[12];
36
37 /* Get the component */
38 Component = &CurrentEntry->ComponentEntry;
39
40 /* Set system class components to ARC system type */
41 if (Component->Class == SystemClass) Component->Type = ArcSystem;
42
43 /* Create a key for the component */
45 &CmTypeName[Component->Type],
48 NULL);
52 0,
53 NULL,
54 0,
56 if (!NT_SUCCESS(Status)) return Status;
57
58 /* Check if this is anything but a system class component */
59 if (Component->Class != SystemClass)
60 {
61 /* Build the sub-component string */
62 RtlIntegerToChar(DeviceIndexTable[Component->Type]++,
63 10,
64 12,
65 TempBuffer);
66 RtlInitAnsiString(&TempString, TempBuffer);
67
68 /* Convert it to Unicode */
69 RtlInitEmptyUnicodeString(&KeyName, Buffer, sizeof(Buffer));
71 if (!NT_SUCCESS(Status))
72 {
74 return Status;
75 }
76
77 /* Create the key */
78 ParentHandle = KeyHandle;
80 &KeyName,
82 ParentHandle,
83 NULL);
87 0,
88 NULL,
89 0,
91 NtClose(ParentHandle);
92
93 /* Fail if the key couldn't be created, and make sure it's a new key */
94 if (!NT_SUCCESS(Status)) return Status;
96 }
97
98 /* Setup the component information key */
99 RtlInitUnicodeString(&ValueName, L"Component Information");
101 &ValueName,
102 0,
104 &Component->Flags,
106 ConfigurationDataLength) -
108 if (!NT_SUCCESS(Status))
109 {
110 /* Fail */
112 return Status;
113 }
114
115 /* Check if we have an identifier */
116 if (Component->IdentifierLength)
117 {
118 /* Build the string and convert it to Unicode */
119 RtlInitUnicodeString(&ValueName, L"Identifier");
120 RtlInitAnsiString(&TempString, Component->Identifier);
122 &TempString,
123 TRUE);
124 if (NT_SUCCESS(Status))
125 {
126 /* Save the identifier in the registry */
128 &ValueName,
129 0,
130 REG_SZ,
131 ValueData.Buffer,
132 ValueData.Length + sizeof(UNICODE_NULL));
134 }
135
136 /* Check for failure during conversion or registry write */
137 if (!NT_SUCCESS(Status))
138 {
139 /* Fail */
141 return Status;
142 }
143 }
144
145 /* Setup the configuration data string */
146 RtlInitUnicodeString(&ValueName, L"Configuration Data");
147
148 /* Check if we got configuration data */
149 if (CurrentEntry->ConfigurationData)
150 {
151 /* Calculate the total length and check if it fits into our buffer */
152 Length = Component->ConfigurationDataLength +
153 FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList);
155 {
156 ASSERTMSG("Component too large -- need reallocation!\n", FALSE);
157 }
158 else
159 {
160 /* Copy the data */
162 CurrentEntry->ConfigurationData,
163 Component->ConfigurationDataLength);
164 }
165 }
166 else
167 {
168 /* No configuration data, setup defaults */
172 Length = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
173 FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList);
174 }
175
176 /* Set the interface type and bus number */
179
180 /* Save the actual data */
182 &ValueName,
183 0,
186 Length);
187 if (!NT_SUCCESS(Status))
188 {
189 /* Fail */
191 }
192 else
193 {
194 /* Return the new handle */
195 *NewHandle = KeyHandle;
196 }
197
198 /* Return status */
199 return Status;
200}
Definition: bufpool.h:45
UNICODE_STRING CmTypeName[]
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4548
#define REG_SZ
Definition: layer.c:22
NTSYSAPI NTSTATUS NTAPI RtlIntegerToChar(_In_ ULONG Value, _In_ ULONG Base, _In_ ULONG Length, _Out_ PCHAR String)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
#define REG_BINARY
Definition: nt_native.h:1496
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define REG_FULL_RESOURCE_DESCRIPTOR
Definition: nt_native.h:1503
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ SystemClass
Definition: arc.h:90
@ ArcSystem
Definition: arc.h:104
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_In_ ULONG Component
Definition: potypes.h:496
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

Referenced by CmpInitializeMachineDependentConfiguration(), and CmpSetupConfigurationTree().

◆ CmpSetupConfigurationTree()

NTSTATUS NTAPI CmpSetupConfigurationTree ( IN PCONFIGURATION_COMPONENT_DATA  CurrentEntry,
IN HANDLE  ParentHandle,
IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber 
)

Definition at line 205 of file cmconfig.c.

209{
211 USHORT DeviceIndexTable[MaximumType + 1] = {0};
213 ULONG Bus = BusNumber, i;
215 HANDLE NewHandle;
216
217 /* Loop each entry */
218 while (CurrentEntry)
219 {
220 /* Check if this is an adapter */
221 Component = &CurrentEntry->ComponentEntry;
222 if ((Component->Class == AdapterClass) &&
223 (CurrentEntry->Parent->ComponentEntry.Class == SystemClass))
224 {
225 /* Check what kind of adapter it is */
226 switch (Component->Type)
227 {
228 /* EISA */
229 case EisaAdapter:
230 {
231 /* Fixup information */
232 Interface = Eisa;
233 Bus = CmpTypeCount[EisaAdapter]++;
234 break;
235 }
236
237 /* Turbo-channel */
238 case TcAdapter:
239 {
240 /* Fixup information */
242 Bus = CmpTypeCount[TurboChannel]++;
243 break;
244 }
245
246 /* ISA, PCI, etc busses */
248 {
249 /* Check if we have an identifier */
250 if (Component->Identifier)
251 {
252 /* Loop each multi-function adapter type */
253 for (i = 0; CmpMultifunctionTypes[i].Identifier; i++)
254 {
255 /* Check for a name match */
257 Component->Identifier))
258 {
259 /* Match found */
260 break;
261 }
262 }
263
264 /* Fix up information */
267 }
268 break;
269 }
270
271 /* SCSI Bus */
272 case ScsiAdapter:
273 {
274 /* Fix up */
276 Bus = CmpTypeCount[ScsiAdapter]++;
277 break;
278 }
279
280 /* Unknown */
281 default:
282 {
284 Bus = CmpUnknownBusCount++;
285 break;
286 }
287 }
288 }
289
290 /* Dump information on the component */
291
292 /* Setup the hardware node */
293 Status = CmpInitializeRegistryNode(CurrentEntry,
294 ParentHandle,
295 &NewHandle,
296 Interface,
297 Bus,
298 DeviceIndexTable);
299 if (!NT_SUCCESS(Status)) return Status;
300
301 /* Check for children */
302 if (CurrentEntry->Child)
303 {
304 /* Recurse child */
305 Status = CmpSetupConfigurationTree(CurrentEntry->Child,
306 NewHandle,
307 Interface,
308 Bus);
309 if (!NT_SUCCESS(Status))
310 {
311 /* Fail */
312 NtClose(NewHandle);
313 return Status;
314 }
315 }
316
317 /* Get to the next entry */
318 NtClose(NewHandle);
319 CurrentEntry = CurrentEntry->Sibling;
320 }
321
322 /* We're done */
323 return STATUS_SUCCESS;
324}
@ Identifier
Definition: asmpp.cpp:95
@ ScsiAdapter
Definition: arcname.c:40
@ EisaAdapter
Definition: arcname.c:39
#define _stricmp
Definition: cat.c:22
CMP_MF_TYPE CmpMultifunctionTypes[]
NTSTATUS NTAPI CmpInitializeRegistryNode(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry, IN HANDLE NodeHandle, OUT PHANDLE NewHandle, IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PUSHORT DeviceIndexTable)
Definition: cmconfig.c:20
USHORT CmpUnknownBusCount
Definition: cmdata.c:66
ULONG CmpTypeCount[MaximumType+1]
Definition: cmdata.c:67
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ Eisa
Definition: hwresource.cpp:139
@ TurboChannel
Definition: hwresource.cpp:141
@ Internal
Definition: hwresource.cpp:137
enum _INTERFACE_TYPE INTERFACE_TYPE
unsigned short USHORT
Definition: pedump.c:61
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116
@ TcAdapter
Definition: arc.h:113
@ MaximumType
Definition: arc.h:145
USHORT Count
Definition: cm.h:455
PCHAR Identifier
Definition: cm.h:453
USHORT InterfaceType
Definition: cm.h:454
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by CmpInitializeHardwareConfiguration(), and CmpSetupConfigurationTree().