3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: resource.c,v 1.8 2001/09/27 02:14:34 dwelch Exp $
21 * PROJECT: ReactOS kernel
22 * FILE: ntoskrnl/io/resource.c
23 * PURPOSE: Hardware resource managment
24 * PROGRAMMER: David Welch (welch@mcmail.com)
29 /* INCLUDES *****************************************************************/
31 #include <ddk/ntddk.h>
34 #include <internal/debug.h>
36 /* GLOBALS *******************************************************************/
38 static CONFIGURATION_INFORMATION
39 SystemConfigurationInformation
= {0, 0, 0, 0, 0, 0, 0, FALSE
, FALSE
};
41 /* FUNCTIONS *****************************************************************/
43 PCONFIGURATION_INFORMATION STDCALL
44 IoGetConfigurationInformation(VOID
)
46 return(&SystemConfigurationInformation
);
50 IoReportResourceUsage(PUNICODE_STRING DriverClassName
,
51 PDRIVER_OBJECT DriverObject
,
52 PCM_RESOURCE_LIST DriverList
,
54 PDEVICE_OBJECT DeviceObject
,
55 PCM_RESOURCE_LIST DeviceList
,
57 BOOLEAN OverrideConflict
,
58 PBOOLEAN ConflictDetected
)
60 * FUNCTION: Reports hardware resources in the
61 * \Registry\Machine\Hardware\ResourceMap tree, so that a subsequently
62 * loaded driver cannot attempt to use the same resources.
64 * DriverClassName - The class of driver under which the resource
65 * information should be stored.
66 * DriverObject - The driver object that was input to the
68 * DriverList - Resources that claimed for the driver rather than
70 * DriverListSize - Size in bytes of the DriverList.
71 * DeviceObject - The device object for which resources should be
73 * DeviceList - List of resources which should be claimed for the
75 * DeviceListSize - Size of the per-device resource list in bytes.
76 * OverrideConflict - True if the resources should be cliamed
77 * even if a conflict is found.
78 * ConflictDetected - Points to a variable that receives TRUE if
79 * a conflict is detected with another driver.
86 IoAssignResources(PUNICODE_STRING RegistryPath
,
87 PUNICODE_STRING DriverClassName
,
88 PDRIVER_OBJECT DriverObject
,
89 PDEVICE_OBJECT DeviceObject
,
90 PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources
,
91 PCM_RESOURCE_LIST
* AllocatedResources
)
97 IoQueryDeviceDescription(PINTERFACE_TYPE BusType
,
99 PCONFIGURATION_TYPE ControllerType
,
100 PULONG ControllerNumber
,
101 PCONFIGURATION_TYPE PeripheralType
,
102 PULONG PeripheralNumber
,
103 PIO_QUERY_DEVICE_ROUTINE CalloutRoutine
,
107 OBJECT_ATTRIBUTES ObjectAttributes
;
110 L
"\\Registry\\Machine\\Hardware\\MultifunctionAdapter\\0";
111 HANDLE BaseKeyHandle
;
115 KEY_BASIC_INFORMATION BasicInfo
;
119 BaseKeyName
= L
"\\Registry\\Machine\\Hardware\\MultifunctionAdapter";
120 InitializeObjectAttributes(&ObjectAttributes
,
125 Status
= ZwOpenKey(&BaseKeyHandle
,
126 KEY_QUERY_VALUE
| KEY_ENUMERATE_SUB_KEY
,
128 if (!NT_SUCCESS(Status
))
136 Status
= ZwEnumerateKey(BaseKeyHandle
,
142 if (!NT_SUCCESS(Status
))
150 return(STATUS_NOT_IMPLEMENTED
);
154 IoReportHalResourceUsage(PUNICODE_STRING HalDescription
,
155 PCM_RESOURCE_LIST RawList
,
156 PCM_RESOURCE_LIST TranslatedList
,
160 * Reports hardware resources of the HAL in the
161 * \Registry\Machine\Hardware\ResourceMap tree.
163 * HalDescription: Descriptive name of the HAL.
164 * RawList: List of raw (bus specific) resources which should be
165 * claimed for the HAL.
166 * TranslatedList: List of translated (system wide) resources which
167 * should be claimed for the HAL.
168 * ListSize: Size in bytes of the raw and translated resource lists.
169 * Both lists have the same size.
174 OBJECT_ATTRIBUTES ObjectAttributes
;
178 HANDLE ResourcemapKey
;
180 HANDLE DescriptionKey
;
182 /* Open/Create 'RESOURCEMAP' key. */
183 RtlInitUnicodeString(&Name
,
184 L
"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
185 InitializeObjectAttributes(&ObjectAttributes
,
187 OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
,
190 Status
= NtCreateKey(&ResourcemapKey
,
197 if (!NT_SUCCESS(Status
))
200 /* Open/Create 'Hardware Abstraction Layer' key */
201 RtlInitUnicodeString(&Name
,
202 L
"Hardware Abstraction Layer");
203 InitializeObjectAttributes(&ObjectAttributes
,
205 OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
,
208 Status
= NtCreateKey(&HalKey
,
215 NtClose(ResourcemapKey
);
216 if (!NT_SUCCESS(Status
))
219 /* Create 'HalDescription' key */
220 InitializeObjectAttributes(&ObjectAttributes
,
222 OBJ_CASE_INSENSITIVE
,
225 Status
= NtCreateKey(&DescriptionKey
,
233 if (!NT_SUCCESS(Status
))
236 /* Add '.Raw' value. */
237 RtlInitUnicodeString(&Name
,
239 Status
= NtSetValueKey(DescriptionKey
,
245 if (!NT_SUCCESS(Status
))
247 NtClose(DescriptionKey
);
251 /* Add '.Translated' value. */
252 RtlInitUnicodeString(&Name
,
254 Status
= NtSetValueKey(DescriptionKey
,
260 NtClose(DescriptionKey
);