ReactOS 0.4.16-dev-2534-gdcd45a5
config.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Configuration Tree Routines
5 * COPYRIGHT: Copyright 2005-2006 Alex Ionescu <alex.ionescu@reactos.org>
6 *
7 * NOTE: This module is shared by both the kernel and the bootloader.
8 */
9
10/* INCLUDES ******************************************************************/
11
12#include <ntoskrnl.h>
13
14/* FUNCTIONS *****************************************************************/
15
16/*
17 * @implemented
18 */
25 _In_opt_ PULONG ComponentKey,
27{
28 ULONG Key = 0;
29 ULONG Mask = 0;
32
33 /* If we did get a key, then use it instead */
34 if (ComponentKey)
35 {
36 Key = *ComponentKey;
37 Mask = -1;
38 }
39
40 /* Loop the components until we find a a match */
41 for (; Child; Child = Child->Child)
42 {
43 /* Check if we are starting somewhere already */
44 if (*NextLink)
45 {
46 /* If we've found the place where we started, clear and continue */
47 if (Child == *NextLink)
48 *NextLink = NULL;
49 }
50 else
51 {
52 /* Try to get a match */
53 if ((Child->ComponentEntry.Class) == Class &&
54 (Child->ComponentEntry.Type) == Type &&
55 (Child->ComponentEntry.Key & Mask) == Key)
56 {
57 /* Match found */
58 return Child;
59 }
60 }
61
62 /* Now we've also got to lookup the siblings */
63 for (Sibling = Child->Sibling; Sibling; Sibling = Sibling->Sibling)
64 {
65 /* Check if we are starting somewhere already */
66 if (*NextLink)
67 {
68 /* If we've found the place where we started, clear and continue */
69 if (Sibling == *NextLink)
70 *NextLink = NULL;
71 }
72 else
73 {
74 /* Try to get a match */
75 if ((Sibling->ComponentEntry.Class == Class) &&
76 (Sibling->ComponentEntry.Type == Type) &&
77 (Sibling->ComponentEntry.Key & Mask) == Key)
78 {
79 /* Match found */
80 return Sibling;
81 }
82 }
83
84 /* We've got to check if the sibling has a child as well */
85 if (Sibling->Child)
86 {
87 /* We're just going to call ourselves again */
88 ReturnEntry = KeFindConfigurationNextEntry(Sibling->Child,
89 Class,
90 Type,
91 ComponentKey,
92 NextLink);
93 if (ReturnEntry)
94 return ReturnEntry;
95 }
96 }
97 }
98
99 /* If we got here, nothing was found */
100 return NULL;
101}
102
103/*
104 * @implemented
105 */
107NTAPI
112 _In_opt_ PULONG ComponentKey)
113{
115
116 /* Start search at the root */
118 Class,
119 Type,
120 ComponentKey,
121 &NextLink);
122}
Type
Definition: Type.h:7
#define NULL
Definition: types.h:112
unsigned int Mask
Definition: fpcontrol.c:82
#define _Inout_
Definition: no_sal2.h:162
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationNextEntry(_In_ PCONFIGURATION_COMPONENT_DATA Child, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_opt_ PULONG ComponentKey, _Inout_ PCONFIGURATION_COMPONENT_DATA *NextLink)
Definition: config.c:21
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationEntry(_In_ PCONFIGURATION_COMPONENT_DATA Child, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_opt_ PULONG ComponentKey)
Definition: config.c:108
enum _CONFIGURATION_CLASS CONFIGURATION_CLASS
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:287
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:286
struct _CONFIGURATION_COMPONENT_DATA * Child
Definition: arc.h:285
CONFIGURATION_TYPE Type
Definition: arc.h:161
CONFIGURATION_CLASS Class
Definition: arc.h:160
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536