ReactOS  0.4.14-dev-50-g13bb5e2
config.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/ke/config.c
5  * PURPOSE: Configuration Tree Routines
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* FUNCTIONS *****************************************************************/
16 
17 /*
18  * @implemented
19  */
20 INIT_FUNCTION
22 NTAPI
26  IN PULONG ComponentKey OPTIONAL)
27 {
29 
30  /* Start Search at Root */
32  Class,
33  Type,
34  ComponentKey,
35  &NextLink);
36 }
37 
38 /*
39  * @implemented
40  */
41 INIT_FUNCTION
43 NTAPI
47  IN PULONG ComponentKey OPTIONAL,
49 {
50  ULONG Key = 0;
51  ULONG Mask = 0;
54 
55  /* If we did get a key, then use it instead */
56  if (ComponentKey)
57  {
58  Key = *ComponentKey;
59  Mask = -1;
60  }
61 
62  /* Loop the Components until we find a a match */
63  while (Child)
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 (Child == *NextLink) *NextLink = NULL;
70  }
71  else
72  {
73  /* Try to get a match */
74  if ((Child->ComponentEntry.Class) == Class &&
75  (Child->ComponentEntry.Type) == Type &&
76  (Child->ComponentEntry.Key & Mask) == Key)
77  {
78  /* Match found */
79  return Child;
80  }
81  }
82 
83  /* Now we've also got to lookup the siblings */
84  Sibling = Child->Sibling;
85  while (Sibling)
86  {
87  /* Check if we are starting somewhere already */
88  if (*NextLink)
89  {
90  /* If we've found the place where we started, clear and continue */
91  if (Sibling == *NextLink) *NextLink = NULL;
92  }
93  else
94  {
95  /* Try to get a match */
96  if ((Sibling->ComponentEntry.Class == Class) &&
97  (Sibling->ComponentEntry.Type == Type) &&
98  (Sibling->ComponentEntry.Key & Mask) == Key)
99  {
100  /* Match found */
101  return Sibling;
102  }
103  }
104 
105  /* We've got to check if the Sibling has a Child as well */
106  if (Sibling->Child)
107  {
108  /* We're just going to call ourselves again */
109  ReturnEntry = KeFindConfigurationNextEntry(Sibling->Child,
110  Class,
111  Type,
112  ComponentKey,
113  NextLink);
114  if (ReturnEntry) return ReturnEntry;
115  }
116 
117  /* Next Sibling */
118  Sibling = Sibling->Sibling;
119  }
120 
121  /* Next Child */
122  Child = Child->Child;
123  }
124 
125  /* If we got here, nothing was found */
126  return NULL;
127 }
#define IN
Definition: typedefs.h:38
Type
Definition: Type.h:6
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _CONFIGURATION_COMPONENT_DATA * Child
Definition: arc.h:119
CONFIGURATION_TYPE Type
Definition: arc.h:105
smooth NULL
Definition: ftsmooth.c:416
CONFIGURATION_CLASS Class
Definition: arc.h:104
INIT_FUNCTION PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL)
Definition: config.c:23
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:121
CONFIGURATION_TYPE
Definition: iotypes.h:4037
enum _CONFIGURATION_CLASS CONFIGURATION_CLASS
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:120
unsigned int * PULONG
Definition: retypes.h:1
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
INIT_FUNCTION PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL, IN PCONFIGURATION_COMPONENT_DATA *NextLink)
Definition: config.c:44
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68