Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1751 lines
41 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. ixpnpdrv.c
  5. Abstract:
  6. Implements functionality necessary for the
  7. HAL to become a PnP-style device driver
  8. after system initialization. This is done
  9. so that the HAL can enumerate the ACPI driver
  10. in the way that the PnP stuff expects.
  11. Author:
  12. Jake Oshins (jakeo) 27-Jan-1997
  13. Environment:
  14. Kernel mode only.
  15. Revision History:
  16. --*/
  17. #include "halp.h"
  18. #include "acpitabl.h"
  19. #include "exboosts.h"
  20. #include "wchar.h"
  21. #include "xxacpi.h"
  22. //
  23. // Cause the GUID to be defined.
  24. //
  25. #ifdef ALLOC_DATA_PRAGMA
  26. #pragma const_seg("PAGECONST")
  27. #endif // ALLOC_DATA_PRAGMA
  28. #include "initguid.h"
  29. #include "wdmguid.h"
  30. #include "halpnpp.h"
  31. #ifdef ALLOC_DATA_PRAGMA
  32. #pragma const_seg()
  33. #endif // ALLOC_DATA_PRAGMA
  34. #if DBG
  35. ULONG HalDebug = 0;
  36. #endif
  37. extern WCHAR HalHardwareIdString[];
  38. #if defined(NT_UP) && defined(APIC_HAL)
  39. extern WCHAR MpHalHardwareIdString[];
  40. #endif
  41. typedef enum {
  42. Hal = 0x80,
  43. AcpiDriver
  44. } PDO_TYPE;
  45. typedef enum {
  46. PdoExtensionType = 0xc0,
  47. FdoExtensionType
  48. } EXTENSION_TYPE;
  49. typedef struct _PDO_EXTENSION *PPDO_EXTENSION;
  50. typedef struct _FDO_EXTENSION *PFDO_EXTENSION;
  51. typedef struct _PDO_EXTENSION{
  52. EXTENSION_TYPE ExtensionType;
  53. PPDO_EXTENSION Next;
  54. PDEVICE_OBJECT PhysicalDeviceObject;
  55. PFDO_EXTENSION ParentFdoExtension;
  56. PDO_TYPE PdoType;
  57. } PDO_EXTENSION, *PPDO_EXTENSION;
  58. #define ASSERT_PDO_EXTENSION(x) ASSERT((x)->ExtensionType == PdoExtensionType );
  59. typedef struct _FDO_EXTENSION{
  60. EXTENSION_TYPE ExtensionType;
  61. PPDO_EXTENSION ChildPdoList;
  62. PDEVICE_OBJECT PhysicalDeviceObject; // PDO passed into AddDevice()
  63. PDEVICE_OBJECT FunctionalDeviceObject;
  64. PDEVICE_OBJECT AttachedDeviceObject;
  65. } FDO_EXTENSION, *PFDO_EXTENSION;
  66. #define ASSERT_FDO_EXTENSION(x) ASSERT((x)->ExtensionType == FdoExtensionType );
  67. INT_ROUTE_INTERFACE_STANDARD PciIrqRoutingInterface = {0};
  68. NTSTATUS
  69. HalpDriverEntry (
  70. IN PDRIVER_OBJECT DriverObject,
  71. IN PUNICODE_STRING RegistryPath
  72. );
  73. NTSTATUS
  74. HalpAddDevice(
  75. IN PDRIVER_OBJECT DriverObject,
  76. IN PDEVICE_OBJECT PhysicalDeviceObject
  77. );
  78. NTSTATUS
  79. HalpDispatchPnp(
  80. IN PDEVICE_OBJECT DeviceObject,
  81. IN OUT PIRP Irp
  82. );
  83. NTSTATUS
  84. HalpDispatchPower(
  85. IN PDEVICE_OBJECT DeviceObject,
  86. IN OUT PIRP Irp
  87. );
  88. NTSTATUS
  89. HalpDispatchWmi(
  90. IN PDEVICE_OBJECT DeviceObject,
  91. IN OUT PIRP Irp
  92. );
  93. NTSTATUS
  94. HalpQueryDeviceRelations(
  95. IN PDEVICE_OBJECT DeviceObject,
  96. IN DEVICE_RELATION_TYPE RelationType,
  97. OUT PDEVICE_RELATIONS *DeviceRelations
  98. );
  99. NTSTATUS
  100. HalpQueryIdPdo(
  101. IN PDEVICE_OBJECT PdoExtension,
  102. IN BUS_QUERY_ID_TYPE IdType,
  103. IN OUT PWSTR *BusQueryId
  104. );
  105. NTSTATUS
  106. HalpQueryIdFdo(
  107. IN PDEVICE_OBJECT PdoExtension,
  108. IN BUS_QUERY_ID_TYPE IdType,
  109. IN OUT PWSTR *BusQueryId
  110. );
  111. NTSTATUS
  112. HalpQueryCapabilities(
  113. IN PDEVICE_OBJECT PdoExtension,
  114. IN PDEVICE_CAPABILITIES Capabilities
  115. );
  116. NTSTATUS
  117. HalpQueryResources(
  118. PDEVICE_OBJECT DeviceObject,
  119. PCM_RESOURCE_LIST *Resources
  120. );
  121. NTSTATUS
  122. HalpQueryResourceRequirements(
  123. PDEVICE_OBJECT DeviceObject,
  124. PIO_RESOURCE_REQUIREMENTS_LIST *Requirements
  125. );
  126. NTSTATUS
  127. HalpQueryInterface(
  128. IN PDEVICE_OBJECT DeviceObject,
  129. IN LPCGUID InterfaceType,
  130. IN USHORT Version,
  131. IN PVOID InterfaceSpecificData,
  132. IN ULONG InterfaceBufferSize,
  133. IN OUT PINTERFACE Interface,
  134. IN OUT PULONG Length
  135. );
  136. NTSTATUS
  137. HalIrqTranslateResourcesRoot(
  138. IN PVOID Context,
  139. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  140. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  141. IN ULONG AlternativesCount, OPTIONAL
  142. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  143. IN PDEVICE_OBJECT PhysicalDeviceObject,
  144. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  145. );
  146. NTSTATUS
  147. HalIrqTranslateResourceRequirementsRoot(
  148. IN PVOID Context,
  149. IN PIO_RESOURCE_DESCRIPTOR Source,
  150. IN PDEVICE_OBJECT PhysicalDeviceObject,
  151. OUT PULONG TargetCount,
  152. OUT PIO_RESOURCE_DESCRIPTOR *Target
  153. );
  154. VOID
  155. HalpMaskAcpiInterrupt(
  156. VOID
  157. );
  158. VOID
  159. HalpUnmaskAcpiInterrupt(
  160. VOID
  161. );
  162. // from xxacpi.c
  163. NTSTATUS
  164. HalpQueryAcpiResourceRequirements(
  165. IN PIO_RESOURCE_REQUIREMENTS_LIST *Requirements
  166. );
  167. VOID
  168. HalpMarkAcpiHal(
  169. VOID
  170. );
  171. NTSTATUS
  172. HalpOpenRegistryKey(
  173. OUT PHANDLE Handle,
  174. IN HANDLE BaseHandle OPTIONAL,
  175. IN PUNICODE_STRING KeyName,
  176. IN ACCESS_MASK DesiredAccess,
  177. IN BOOLEAN Create
  178. );
  179. #ifdef ACPI_CMOS_ACTIVATE
  180. VOID
  181. HalpCmosNullReference(
  182. PVOID Context
  183. );
  184. VOID
  185. HalpCmosNullDereference(
  186. PVOID Context
  187. );
  188. #endif // ACPI_CMOS_ACTIVATE
  189. #define HAL_DRIVER_NAME L"\\Driver\\ACPI_HAL"
  190. #ifdef ALLOC_PRAGMA
  191. #pragma alloc_text(PAGE, HaliInitPnpDriver)
  192. #pragma alloc_text(PAGE, HalpMarkAcpiHal)
  193. #pragma alloc_text(PAGE, HalpOpenRegistryKey)
  194. #pragma alloc_text(PAGE, HalpDriverEntry)
  195. #pragma alloc_text(PAGE, HalpAddDevice)
  196. #pragma alloc_text(PAGE, HalpDispatchPnp)
  197. #pragma alloc_text(PAGELK, HalpDispatchPower)
  198. #pragma alloc_text(PAGE, HalpDispatchWmi)
  199. #pragma alloc_text(PAGE, HalpQueryDeviceRelations)
  200. #pragma alloc_text(PAGE, HalpQueryIdPdo)
  201. #pragma alloc_text(PAGE, HalpQueryIdFdo)
  202. #pragma alloc_text(PAGE, HalpQueryCapabilities)
  203. #pragma alloc_text(PAGE, HalpQueryResources)
  204. #pragma alloc_text(PAGE, HalpQueryResourceRequirements)
  205. #pragma alloc_text(PAGE, HalpQueryInterface)
  206. #endif
  207. PDRIVER_OBJECT HalpDriverObject;
  208. NTSTATUS
  209. HaliInitPnpDriver(
  210. VOID
  211. )
  212. /*++
  213. Routine Description:
  214. This routine starts the process of making the HAL into
  215. a "driver," which is necessary because we need to
  216. enumerate a Plug and Play PDO for the ACPI driver.
  217. Arguments:
  218. None.
  219. Return Value:
  220. NTSTATUS.
  221. --*/
  222. {
  223. UNICODE_STRING DriverName;
  224. NTSTATUS Status;
  225. PAGED_CODE();
  226. RtlInitUnicodeString( &DriverName, HAL_DRIVER_NAME );
  227. Status = IoCreateDriver( &DriverName, HalpDriverEntry );
  228. HalpMarkAcpiHal();
  229. ASSERT( NT_SUCCESS( Status ));
  230. return Status;
  231. }
  232. VOID
  233. HalpMarkAcpiHal(
  234. VOID
  235. )
  236. /*++
  237. Routine Description:
  238. Arguments:
  239. None.
  240. Return Value:
  241. None.
  242. --*/
  243. {
  244. ULONG tmpValue;
  245. UNICODE_STRING unicodeString;
  246. HANDLE hCurrentControlSet, handle;
  247. NTSTATUS status;
  248. PAGED_CODE();
  249. //
  250. // Open/create System\CurrentControlSet key.
  251. //
  252. RtlInitUnicodeString(&unicodeString, L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
  253. status = HalpOpenRegistryKey (
  254. &hCurrentControlSet,
  255. NULL,
  256. &unicodeString,
  257. KEY_ALL_ACCESS,
  258. FALSE
  259. );
  260. if (!NT_SUCCESS(status)) {
  261. return;
  262. }
  263. //
  264. // Open HKLM\System\CurrentControlSet\Control\Pnp
  265. //
  266. RtlInitUnicodeString(&unicodeString, L"Control\\Pnp");
  267. status = HalpOpenRegistryKey (
  268. &handle,
  269. hCurrentControlSet,
  270. &unicodeString,
  271. KEY_ALL_ACCESS,
  272. TRUE
  273. );
  274. ZwClose(hCurrentControlSet);
  275. if (!NT_SUCCESS(status)) {
  276. return;
  277. }
  278. RtlInitUnicodeString(&unicodeString, L"DisableFirmwareMapper");
  279. tmpValue = 1;
  280. ZwSetValueKey(handle,
  281. &unicodeString,
  282. 0,
  283. REG_DWORD,
  284. &tmpValue,
  285. sizeof(tmpValue)
  286. );
  287. ZwClose(handle);
  288. }
  289. NTSTATUS
  290. HalpOpenRegistryKey(
  291. OUT PHANDLE Handle,
  292. IN HANDLE BaseHandle OPTIONAL,
  293. IN PUNICODE_STRING KeyName,
  294. IN ACCESS_MASK DesiredAccess,
  295. IN BOOLEAN Create
  296. )
  297. /*++
  298. Routine Description:
  299. Opens or creates a VOLATILE registry key using the name passed in based
  300. at the BaseHandle node.
  301. Arguments:
  302. Handle - Pointer to the handle which will contain the registry key that
  303. was opened.
  304. BaseHandle - Handle to the base path from which the key must be opened.
  305. KeyName - Name of the Key that must be opened/created.
  306. DesiredAccess - Specifies the desired access that the caller needs to
  307. the key.
  308. Create - Determines if the key is to be created if it does not exist.
  309. Return Value:
  310. The function value is the final status of the operation.
  311. --*/
  312. {
  313. OBJECT_ATTRIBUTES objectAttributes;
  314. ULONG disposition;
  315. PAGED_CODE();
  316. //
  317. // Initialize the object for the key.
  318. //
  319. InitializeObjectAttributes( &objectAttributes,
  320. KeyName,
  321. OBJ_CASE_INSENSITIVE,
  322. BaseHandle,
  323. (PSECURITY_DESCRIPTOR) NULL );
  324. //
  325. // Create the key or open it, as appropriate based on the caller's
  326. // wishes.
  327. //
  328. if (Create) {
  329. return ZwCreateKey( Handle,
  330. DesiredAccess,
  331. &objectAttributes,
  332. 0,
  333. (PUNICODE_STRING) NULL,
  334. REG_OPTION_VOLATILE,
  335. &disposition );
  336. } else {
  337. return ZwOpenKey( Handle,
  338. DesiredAccess,
  339. &objectAttributes );
  340. }
  341. }
  342. NTSTATUS
  343. HalpDriverEntry (
  344. IN PDRIVER_OBJECT DriverObject,
  345. IN PUNICODE_STRING RegistryPath
  346. )
  347. /*++
  348. Routine Description:
  349. This is the callback function when we call IoCreateDriver to create a
  350. PnP Driver Object. In this function, we need to remember the DriverObject.
  351. Arguments:
  352. DriverObject - Pointer to the driver object created by the system.
  353. RegistryPath - is NULL.
  354. Return Value:
  355. STATUS_SUCCESS
  356. --*/
  357. {
  358. NTSTATUS status;
  359. PDEVICE_OBJECT detectedDeviceObject = NULL;
  360. ANSI_STRING AKeyName;
  361. PAGED_CODE();
  362. //
  363. // File the pointer to our driver object away
  364. //
  365. HalpDriverObject = DriverObject;
  366. //
  367. // Fill in the driver object
  368. //
  369. DriverObject->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)HalpAddDevice;
  370. DriverObject->MajorFunction[ IRP_MJ_PNP ] = HalpDispatchPnp;
  371. DriverObject->MajorFunction[ IRP_MJ_POWER ] = HalpDispatchPower;
  372. DriverObject->MajorFunction[ IRP_MJ_SYSTEM_CONTROL ] = HalpDispatchWmi;
  373. status = IoReportDetectedDevice(DriverObject,
  374. InterfaceTypeUndefined,
  375. -1,
  376. -1,
  377. NULL,
  378. NULL,
  379. FALSE,
  380. &detectedDeviceObject);
  381. ASSERT(detectedDeviceObject);
  382. if (!(NT_SUCCESS(status))) {
  383. return status;
  384. }
  385. HalpAddDevice(DriverObject,
  386. detectedDeviceObject);
  387. return STATUS_SUCCESS;
  388. }
  389. NTSTATUS
  390. HalpAddDevice(
  391. IN PDRIVER_OBJECT DriverObject,
  392. IN PDEVICE_OBJECT PhysicalDeviceObject
  393. )
  394. /*++
  395. Routine Description:
  396. This routine handles AddDevice for an madeup PDO device.
  397. Arguments:
  398. DriverObject - Pointer to our pseudo driver object.
  399. DeviceObject - Pointer to the device object for which this requestapplies.
  400. Return Value:
  401. NT status.
  402. --*/
  403. {
  404. PDEVICE_OBJECT functionalDeviceObject;
  405. PDEVICE_OBJECT childDeviceObject;
  406. PDEVICE_OBJECT AttachedDevice;
  407. NTSTATUS status;
  408. PFDO_EXTENSION FdoExtension;
  409. PPDO_EXTENSION PdoExtension;
  410. PAGED_CODE();
  411. //
  412. // We've been given the PhysicalDeviceObject. Create the
  413. // FunctionalDeviceObject. Our FDO will be nameless.
  414. //
  415. status = IoCreateDevice(
  416. DriverObject, // our driver object
  417. sizeof(FDO_EXTENSION), // size of our extension
  418. NULL, // our name
  419. FILE_DEVICE_BUS_EXTENDER, // device type
  420. 0, // device characteristics
  421. FALSE, // not exclusive
  422. &functionalDeviceObject // store new device object here
  423. );
  424. if( !NT_SUCCESS( status )){
  425. DbgBreakPoint();
  426. return status;
  427. }
  428. //
  429. // Fill in the FDO extension
  430. //
  431. FdoExtension = (PFDO_EXTENSION)functionalDeviceObject->DeviceExtension;
  432. FdoExtension->ExtensionType = FdoExtensionType;
  433. FdoExtension->PhysicalDeviceObject = PhysicalDeviceObject;
  434. FdoExtension->FunctionalDeviceObject = functionalDeviceObject;
  435. functionalDeviceObject->Flags &= ~(DO_DEVICE_INITIALIZING);
  436. //
  437. // Now attach to the PDO we were given.
  438. //
  439. AttachedDevice = IoAttachDeviceToDeviceStack(functionalDeviceObject,
  440. PhysicalDeviceObject );
  441. if(AttachedDevice == NULL){
  442. //
  443. // Couldn't attach. Delete the FDO.
  444. //
  445. IoDeleteDevice( functionalDeviceObject );
  446. return STATUS_NO_SUCH_DEVICE;
  447. }
  448. FdoExtension->AttachedDeviceObject = AttachedDevice;
  449. //
  450. // Next, create a PDO for the ACPI driver.
  451. //
  452. status = IoCreateDevice(
  453. DriverObject, // our driver object
  454. sizeof(PDO_EXTENSION), // size of our extension
  455. NULL, // our name
  456. FILE_DEVICE_BUS_EXTENDER, // device type
  457. FILE_AUTOGENERATED_DEVICE_NAME, // device characteristics
  458. FALSE, // not exclusive
  459. &childDeviceObject // store new device object here
  460. );
  461. if (!NT_SUCCESS(status)) {
  462. return status;
  463. }
  464. //
  465. // Fill in the PDO extension
  466. //
  467. PdoExtension = (PPDO_EXTENSION)childDeviceObject->DeviceExtension;
  468. PdoExtension->ExtensionType = PdoExtensionType;
  469. PdoExtension->Next = NULL;
  470. PdoExtension->PhysicalDeviceObject = childDeviceObject;
  471. PdoExtension->ParentFdoExtension = FdoExtension;
  472. PdoExtension->PdoType = AcpiDriver;
  473. childDeviceObject->Flags &= ~(DO_DEVICE_INITIALIZING);
  474. //
  475. // Record this as a child of the HAL
  476. //
  477. FdoExtension->ChildPdoList = PdoExtension;
  478. return STATUS_SUCCESS;
  479. }
  480. NTSTATUS
  481. HalpPassIrpFromFdoToPdo(
  482. PDEVICE_OBJECT DeviceObject,
  483. PIRP Irp
  484. )
  485. /*++
  486. Description:
  487. Given an FDO, pass the IRP to the next device object in the
  488. device stack. This is the PDO if there are no lower level
  489. filters.
  490. Arguments:
  491. DeviceObject - the Fdo
  492. Irp - the request
  493. Return Value:
  494. Returns the result from calling the next level.
  495. --*/
  496. {
  497. PIO_STACK_LOCATION irpSp; // our stack location
  498. PIO_STACK_LOCATION nextIrpSp; // next guy's
  499. PFDO_EXTENSION fdoExtension;
  500. //
  501. // Get the pointer to the device extension.
  502. //
  503. fdoExtension = (PFDO_EXTENSION)DeviceObject->DeviceExtension;
  504. IoSkipCurrentIrpStackLocation(Irp);
  505. //
  506. // Call the PDO driver with the request.
  507. //
  508. return IoCallDriver(fdoExtension->AttachedDeviceObject ,Irp);
  509. }
  510. NTSTATUS
  511. HalpDispatchPnp(
  512. IN PDEVICE_OBJECT DeviceObject,
  513. IN OUT PIRP Irp
  514. )
  515. /*++
  516. Routine Description:
  517. This routine handles all IRP_MJ_PNP IRPs for madeup PDO device.
  518. Arguments:
  519. DeviceObject - Pointer to the device object for which this IRP applies.
  520. Irp - Pointer to the IRP_MJ_PNP IRP to dispatch.
  521. Return Value:
  522. NT status.
  523. --*/
  524. {
  525. PIO_STACK_LOCATION irpSp;
  526. NTSTATUS status;
  527. ULONG length;
  528. DEVICE_RELATION_TYPE relationType;
  529. EXTENSION_TYPE extensionType;
  530. BOOLEAN passDown;
  531. #if DBG
  532. PUCHAR objectTypeString;
  533. #endif //DBG
  534. PAGED_CODE();
  535. extensionType = ((PFDO_EXTENSION)(DeviceObject->DeviceExtension))->ExtensionType;
  536. //
  537. // Get a pointer to our stack location and take appropriate action based
  538. // on the minor function.
  539. //
  540. irpSp = IoGetCurrentIrpStackLocation(Irp);
  541. status = Irp->IoStatus.Status;
  542. switch (extensionType) {
  543. case PdoExtensionType:
  544. #if DBG
  545. objectTypeString = "PDO";
  546. #endif //DBG
  547. switch (irpSp->MinorFunction) {
  548. case IRP_MN_START_DEVICE:
  549. HalPrint(("HAL: (%s) Start_Device Irp received\n",
  550. objectTypeString));
  551. //
  552. // If we get a start device request for a PDO, we simply
  553. // return success.
  554. //
  555. status = STATUS_SUCCESS;
  556. break;
  557. case IRP_MN_QUERY_STOP_DEVICE:
  558. HalPrint(("(%s) Query_Stop_Device Irp received",
  559. objectTypeString));
  560. status = STATUS_SUCCESS;
  561. break;
  562. case IRP_MN_CANCEL_STOP_DEVICE:
  563. HalPrint(("(%s) Cancel_Stop_Device Irp received",
  564. objectTypeString));
  565. status = STATUS_SUCCESS;
  566. break;
  567. case IRP_MN_STOP_DEVICE:
  568. HalPrint(("HAL: (%s) Stop_Device Irp received\n",
  569. objectTypeString));
  570. //
  571. // If we get a stop device request for a PDO, we simply
  572. // return success.
  573. //
  574. status = STATUS_SUCCESS;
  575. break;
  576. case IRP_MN_QUERY_RESOURCES:
  577. HalPrint(("HAL: (%s) Query_Resources Irp received\n",
  578. objectTypeString));
  579. status = HalpQueryResources(DeviceObject,
  580. (PCM_RESOURCE_LIST*)&Irp->IoStatus.Information);
  581. break;
  582. case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
  583. HalPrint(("HAL: (%s) Query_Resource_Requirements Irp received\n",
  584. objectTypeString));
  585. status = HalpQueryResourceRequirements(DeviceObject,
  586. (PIO_RESOURCE_REQUIREMENTS_LIST*)&Irp->IoStatus.Information);
  587. break;
  588. case IRP_MN_QUERY_REMOVE_DEVICE:
  589. HalPrint(("(%s) Query_Remove_device Irp for %x",
  590. objectTypeString,
  591. DeviceObject));
  592. status = STATUS_UNSUCCESSFUL;
  593. break;
  594. case IRP_MN_CANCEL_REMOVE_DEVICE:
  595. HalPrint(("(%s) Cancel_Remove_device Irp for %x",
  596. objectTypeString,
  597. DeviceObject));
  598. status = STATUS_SUCCESS;
  599. break;
  600. case IRP_MN_REMOVE_DEVICE:
  601. HalPrint(("HAL: (%s) Remove_device Irp for PDO %x\n",
  602. objectTypeString,
  603. DeviceObject));
  604. status = STATUS_SUCCESS;
  605. break;
  606. case IRP_MN_QUERY_DEVICE_RELATIONS:
  607. HalPrint(("HAL: (%s) Query_Device_Relations Irp received\n",
  608. objectTypeString));
  609. relationType = irpSp->Parameters.QueryDeviceRelations.Type;
  610. status = HalpQueryDeviceRelations(DeviceObject,
  611. relationType,
  612. (PDEVICE_RELATIONS*)&Irp->IoStatus.Information);
  613. break;
  614. case IRP_MN_QUERY_ID:
  615. HalPrint(("HAL: (%s) Query_Id Irp received\n",
  616. objectTypeString));
  617. status = HalpQueryIdPdo(DeviceObject,
  618. irpSp->Parameters.QueryId.IdType,
  619. (PWSTR*)&Irp->IoStatus.Information);
  620. break;
  621. case IRP_MN_QUERY_INTERFACE:
  622. HalPrint(("HAL: (%s) Query_Interface Irp received\n",
  623. objectTypeString));
  624. status = HalpQueryInterface(
  625. DeviceObject,
  626. irpSp->Parameters.QueryInterface.InterfaceType,
  627. irpSp->Parameters.QueryInterface.Version,
  628. irpSp->Parameters.QueryInterface.InterfaceSpecificData,
  629. irpSp->Parameters.QueryInterface.Size,
  630. irpSp->Parameters.QueryInterface.Interface,
  631. &Irp->IoStatus.Information
  632. );
  633. break;
  634. case IRP_MN_QUERY_CAPABILITIES:
  635. HalPrint(("HAL: (%s) Query_Capabilities Irp received\n",
  636. objectTypeString));
  637. status = HalpQueryCapabilities(DeviceObject,
  638. irpSp->Parameters.DeviceCapabilities.Capabilities);
  639. break;
  640. case IRP_MN_DEVICE_USAGE_NOTIFICATION:
  641. HalPrint(("HAL: DEVICE_USAGE Irp received\n"));
  642. status = STATUS_SUCCESS;
  643. break;
  644. default:
  645. HalPrint(("HAL: (%s) Unsupported Irp (%d) received\n",
  646. objectTypeString,
  647. irpSp->MinorFunction));
  648. status = STATUS_NOT_SUPPORTED ;
  649. break;
  650. }
  651. break; // end PDO cases
  652. case FdoExtensionType:
  653. #if DBG
  654. objectTypeString = "FDO";
  655. #endif //DBG
  656. passDown = TRUE;
  657. //
  658. // In case we don't touch this IRP, save the current status.
  659. //
  660. switch (irpSp->MinorFunction) {
  661. case IRP_MN_QUERY_DEVICE_RELATIONS:
  662. HalPrint(("HAL: (%s) Query_Device_Relations Irp received\n",
  663. objectTypeString));
  664. relationType = irpSp->Parameters.QueryDeviceRelations.Type;
  665. status = HalpQueryDeviceRelations(DeviceObject,
  666. relationType,
  667. (PDEVICE_RELATIONS*)&Irp->IoStatus.Information);
  668. break;
  669. case IRP_MN_QUERY_INTERFACE:
  670. HalPrint(("HAL: (%s) Query_Interface Irp received\n",
  671. objectTypeString));
  672. status = HalpQueryInterface(
  673. DeviceObject,
  674. irpSp->Parameters.QueryInterface.InterfaceType,
  675. irpSp->Parameters.QueryInterface.Version,
  676. irpSp->Parameters.QueryInterface.InterfaceSpecificData,
  677. irpSp->Parameters.QueryInterface.Size,
  678. irpSp->Parameters.QueryInterface.Interface,
  679. &Irp->IoStatus.Information
  680. );
  681. break;
  682. case IRP_MN_QUERY_ID:
  683. HalPrint(("HAL: (%s) Query_Id Irp received\n",
  684. objectTypeString));
  685. status = HalpQueryIdFdo(DeviceObject,
  686. irpSp->Parameters.QueryId.IdType,
  687. (PWSTR*)&Irp->IoStatus.Information);
  688. break;
  689. default:
  690. //
  691. // Ignore any PNP Irps unknown by the FDO but allow them
  692. // down to the PDO.
  693. //
  694. status = STATUS_NOT_SUPPORTED ;
  695. break;
  696. }
  697. if (passDown && (NT_SUCCESS(status) || (status == STATUS_NOT_SUPPORTED))) {
  698. //
  699. // Pass FDO IRPs down to the PDO.
  700. //
  701. // Set Irp status first.
  702. //
  703. if (status != STATUS_NOT_SUPPORTED) {
  704. Irp->IoStatus.Status = status;
  705. }
  706. HalPrint(("HAL: (%s) Passing down Irp (%x)\n",
  707. objectTypeString, irpSp->MinorFunction));
  708. return HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
  709. }
  710. break; // end FDO cases
  711. default:
  712. HalPrint(( "HAL: Received IRP for unknown Device Object\n"));
  713. status = STATUS_INVALID_DEVICE_REQUEST ;
  714. break;
  715. }
  716. //
  717. // Complete the Irp and return.
  718. //
  719. if (status != STATUS_NOT_SUPPORTED) {
  720. Irp->IoStatus.Status = status;
  721. } else {
  722. status = Irp->IoStatus.Status ;
  723. }
  724. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  725. return status;
  726. }
  727. NTSTATUS
  728. HalpDispatchPower(
  729. IN PDEVICE_OBJECT DeviceObject,
  730. IN OUT PIRP Irp
  731. )
  732. /*++
  733. Routine Description:
  734. This routine handles all IRP_MJ_POWER IRPs for madeup PDO device.
  735. Note: We don't actually handle any Power IRPs at this level so
  736. all we do is return the status from the incoming IRP.
  737. Arguments:
  738. DeviceObject - Pointer to the device object for which this IRP applies.
  739. Irp - Pointer to the IRP_MJ_POWER IRP to dispatch.
  740. Return Value:
  741. NT status.
  742. --*/
  743. {
  744. NTSTATUS Status;
  745. EXTENSION_TYPE extensionType;
  746. PIO_STACK_LOCATION irpSp;
  747. HalPrint(("Hal: Power IRP for DevObj: %x\n", DeviceObject));
  748. extensionType = ((PFDO_EXTENSION)(DeviceObject->DeviceExtension))->ExtensionType;
  749. irpSp = IoGetCurrentIrpStackLocation(Irp);
  750. //
  751. // Simply store the appropriate status and complete the request.
  752. //
  753. Status = Irp->IoStatus.Status;
  754. PoStartNextPowerIrp(Irp);
  755. if (extensionType == FdoExtensionType) {
  756. switch (irpSp->MinorFunction) {
  757. case IRP_MN_SET_POWER:
  758. if (irpSp->Parameters.Power.Type == SystemPowerState) {
  759. switch (irpSp->Parameters.Power.State.SystemState) {
  760. case PowerSystemSleeping1:
  761. case PowerSystemSleeping2:
  762. case PowerSystemSleeping3:
  763. case PowerSystemHibernate:
  764. //
  765. // Allocate structures used for starting up
  766. // processors while resuming from sleep.
  767. //
  768. HalpBuildResumeStructures();
  769. HalpMaskAcpiInterrupt();
  770. break;
  771. case PowerSystemWorking:
  772. HalpUnmaskAcpiInterrupt();
  773. //
  774. // Free structures used for starting up
  775. // processors while resuming from sleep.
  776. //
  777. HalpFreeResumeStructures();
  778. break;
  779. default:
  780. break;
  781. }
  782. }
  783. //
  784. // Fall through.
  785. //
  786. case IRP_MN_QUERY_POWER:
  787. Irp->IoStatus.Status = Status = STATUS_SUCCESS;
  788. //
  789. // Fall through.
  790. //
  791. default:
  792. Status = HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
  793. break;
  794. }
  795. } else {
  796. switch (irpSp->MinorFunction) {
  797. case IRP_MN_SET_POWER:
  798. case IRP_MN_QUERY_POWER:
  799. Irp->IoStatus.Status = Status = STATUS_SUCCESS;
  800. //
  801. // Fall through.
  802. //
  803. default:
  804. IoCompleteRequest( Irp, IO_NO_INCREMENT );
  805. break;
  806. }
  807. }
  808. return Status;
  809. }
  810. NTSTATUS
  811. HalpDispatchWmi(
  812. IN PDEVICE_OBJECT DeviceObject,
  813. IN OUT PIRP Irp
  814. )
  815. {
  816. NTSTATUS Status;
  817. EXTENSION_TYPE extensionType;
  818. extensionType = ((PFDO_EXTENSION)(DeviceObject->DeviceExtension))->ExtensionType;
  819. if (extensionType == FdoExtensionType) {
  820. Status = HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
  821. } else {
  822. Status = Irp->IoStatus.Status;
  823. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  824. }
  825. return Status;
  826. }
  827. NTSTATUS
  828. HalpQueryDeviceRelations(
  829. IN PDEVICE_OBJECT DeviceObject,
  830. IN DEVICE_RELATION_TYPE RelationType,
  831. OUT PDEVICE_RELATIONS *DeviceRelations
  832. )
  833. /*++
  834. Routine Description:
  835. This routine builds a DEVICE_RELATIONS structure that
  836. tells the PnP manager how many children we have.
  837. Arguments:
  838. DeviceObject - FDO of ACPI_HAL
  839. RelationType - we only respond to BusRelations
  840. DeviceRelations - pointer to the structure
  841. Return Value:
  842. status
  843. --*/
  844. {
  845. PFDO_EXTENSION FdoExtension;
  846. PDEVICE_RELATIONS relations = NULL;
  847. PDEVICE_OBJECT deviceObjectToReturn ;
  848. EXTENSION_TYPE extensionType;
  849. NTSTATUS status ;
  850. PAGED_CODE();
  851. FdoExtension = (PFDO_EXTENSION)DeviceObject->DeviceExtension;
  852. extensionType = FdoExtension->ExtensionType;
  853. status = STATUS_NOT_SUPPORTED ;
  854. switch(RelationType) {
  855. case BusRelations:
  856. if (extensionType == FdoExtensionType) {
  857. deviceObjectToReturn = FdoExtension->ChildPdoList->PhysicalDeviceObject ;
  858. status = STATUS_SUCCESS ;
  859. }
  860. break;
  861. case TargetDeviceRelation:
  862. if (extensionType == PdoExtensionType) {
  863. deviceObjectToReturn = DeviceObject ;
  864. status = STATUS_SUCCESS ;
  865. }
  866. break;
  867. }
  868. if (status == STATUS_NOT_SUPPORTED) {
  869. HalPrint(("HAL: We don't support this kind of device relation\n"));
  870. } else if (NT_SUCCESS(status)) {
  871. ASSERT(*DeviceRelations == 0);
  872. relations = ExAllocatePoolWithTag(
  873. PagedPool,
  874. sizeof(DEVICE_RELATIONS),
  875. HAL_POOL_TAG
  876. );
  877. if (!relations) {
  878. status = STATUS_INSUFFICIENT_RESOURCES;
  879. } else {
  880. relations->Count = 1;
  881. relations->Objects[0] = deviceObjectToReturn ;
  882. ObReferenceObject(relations->Objects[0]);
  883. *DeviceRelations = relations;
  884. }
  885. }
  886. return status ;
  887. }
  888. NTSTATUS
  889. HalpQueryIdPdo(
  890. IN PDEVICE_OBJECT DeviceObject,
  891. IN BUS_QUERY_ID_TYPE IdType,
  892. IN OUT PWSTR *BusQueryId
  893. )
  894. /*++
  895. Routine Description:
  896. This routine identifies each of the children that were
  897. enumerated in HalpQueryDeviceRelations.
  898. Arguments:
  899. DeviceObject - PDO of the child
  900. IdType - the type of ID to be returned, currently ignored
  901. BusQueryId - pointer to the wide string being returned
  902. Return Value:
  903. status
  904. --*/
  905. {
  906. PPDO_EXTENSION PdoExtension = DeviceObject->DeviceExtension;
  907. PWSTR idString;
  908. PWCHAR sourceString;
  909. ULONG stringLen;
  910. static WCHAR AcpiHardwareIdString[] = L"ACPI_HAL\\PNP0C08\0*PNP0C08";
  911. static WCHAR AcpiCompatibleString[] = L"*PNP0C08";
  912. static WCHAR AcpiInstanceIdString[] = L"0";
  913. PAGED_CODE();
  914. switch (IdType) {
  915. case BusQueryDeviceID:
  916. case BusQueryHardwareIDs:
  917. switch (PdoExtension->PdoType) {
  918. case AcpiDriver:
  919. sourceString = AcpiHardwareIdString;
  920. stringLen = sizeof(AcpiHardwareIdString);
  921. break;
  922. default:
  923. return STATUS_NOT_SUPPORTED;
  924. }
  925. break;
  926. case BusQueryCompatibleIDs:
  927. return STATUS_NOT_SUPPORTED;
  928. break;
  929. case BusQueryInstanceID:
  930. sourceString = AcpiInstanceIdString;
  931. stringLen = sizeof(AcpiInstanceIdString);
  932. break;
  933. default:
  934. return STATUS_NOT_SUPPORTED;
  935. }
  936. idString = ExAllocatePoolWithTag(PagedPool,
  937. stringLen + sizeof(UNICODE_NULL),
  938. HAL_POOL_TAG);
  939. if (!idString) {
  940. return STATUS_INSUFFICIENT_RESOURCES;
  941. }
  942. RtlCopyMemory(idString,
  943. sourceString, stringLen);
  944. *(idString + stringLen / sizeof(WCHAR)) = UNICODE_NULL;
  945. *BusQueryId = idString;
  946. return STATUS_SUCCESS;
  947. }
  948. NTSTATUS
  949. HalpQueryIdFdo(
  950. IN PDEVICE_OBJECT DeviceObject,
  951. IN BUS_QUERY_ID_TYPE IdType,
  952. IN OUT PWSTR *BusQueryId
  953. )
  954. /*++
  955. Routine Description:
  956. This routine identifies each of the children that were
  957. enumerated in HalpQueryDeviceRelations.
  958. Arguments:
  959. DeviceObject - PDO of the child
  960. IdType - the type of ID to be returned.
  961. BusQueryId - pointer to the wide string being returned
  962. Return Value:
  963. status
  964. --*/
  965. {
  966. PPDO_EXTENSION PdoExtension = DeviceObject->DeviceExtension;
  967. PWSTR idString;
  968. PWCHAR sourceString = NULL;
  969. ULONG stringLen;
  970. UNICODE_STRING String;
  971. WCHAR Buffer[16];
  972. NTSTATUS Status;
  973. PWCHAR widechar;
  974. static WCHAR HalInstanceIdString[] = L"0";
  975. PAGED_CODE();
  976. switch (IdType) {
  977. case BusQueryDeviceID:
  978. case BusQueryHardwareIDs:
  979. //
  980. // For the UP version of the APIC HAL, we want to detect if there is more
  981. // than one processor installed. If so, we want to return the ID of
  982. // the MP HAL rather than the UP HAL. This will induce PNP to reconfigure
  983. // our devnode and setup the MP HAL for the next boot.
  984. //
  985. sourceString = HalHardwareIdString;
  986. #if defined(NT_UP) && defined(APIC_HAL)
  987. if (HalpMpInfoTable.ProcessorCount > 1) {
  988. sourceString = MpHalHardwareIdString;
  989. }
  990. #endif
  991. widechar = sourceString;
  992. while (*widechar != UNICODE_NULL) {
  993. widechar++;
  994. }
  995. stringLen = (PUCHAR)widechar - ((PUCHAR)sourceString) + 2;
  996. break;
  997. case BusQueryInstanceID:
  998. sourceString = HalInstanceIdString;
  999. stringLen = sizeof(HalInstanceIdString);
  1000. break;
  1001. default:
  1002. break;
  1003. }
  1004. if (sourceString) {
  1005. //
  1006. // Note that hardware IDs and compatible IDs must be terminated by
  1007. // 2 NULLs.
  1008. //
  1009. idString = ExAllocatePoolWithTag(PagedPool,
  1010. stringLen + sizeof(UNICODE_NULL),
  1011. HAL_POOL_TAG);
  1012. if (!idString) {
  1013. HalPrint(( "HalpQueryIdFdo: couldn't allocate pool\n"));
  1014. return STATUS_INSUFFICIENT_RESOURCES;
  1015. }
  1016. RtlCopyMemory(idString,
  1017. sourceString, stringLen);
  1018. *(idString + stringLen / sizeof(WCHAR)) = UNICODE_NULL;
  1019. *BusQueryId = idString;
  1020. return STATUS_SUCCESS;
  1021. } else {
  1022. return STATUS_NOT_SUPPORTED;
  1023. }
  1024. }
  1025. NTSTATUS
  1026. HalpQueryCapabilities(
  1027. IN PDEVICE_OBJECT PdoExtension,
  1028. IN PDEVICE_CAPABILITIES Capabilities
  1029. )
  1030. /*++
  1031. Routine Description:
  1032. This routine fills in the DEVICE_CAPABILITIES structure for
  1033. a device.
  1034. Arguments:
  1035. DeviceObject - PDO of the child
  1036. Capabilities - pointer to the structure to be filled in.
  1037. Return Value:
  1038. status
  1039. --*/
  1040. {
  1041. PAGED_CODE();
  1042. ASSERT(Capabilities->Version == 1);
  1043. if (Capabilities->Version != 1) {
  1044. return STATUS_NOT_SUPPORTED;
  1045. }
  1046. Capabilities->LockSupported = FALSE;
  1047. Capabilities->EjectSupported = FALSE;
  1048. Capabilities->Removable = FALSE;
  1049. Capabilities->DockDevice = FALSE;
  1050. Capabilities->UniqueID = TRUE;
  1051. Capabilities->SilentInstall = TRUE;
  1052. Capabilities->RawDeviceOK = FALSE;
  1053. Capabilities->Address = 0xffffffff;
  1054. Capabilities->UINumber = 0xffffffff;
  1055. Capabilities->D1Latency = 0;
  1056. Capabilities->D2Latency = 0;
  1057. Capabilities->D3Latency = 0;
  1058. //
  1059. // Default S->D mapping
  1060. //
  1061. Capabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0;
  1062. Capabilities->DeviceState[PowerSystemHibernate] = PowerDeviceD3;
  1063. Capabilities->DeviceState[PowerSystemShutdown] = PowerDeviceD3;
  1064. return STATUS_SUCCESS;
  1065. }
  1066. NTSTATUS
  1067. HalpQueryResources(
  1068. PDEVICE_OBJECT DeviceObject,
  1069. PCM_RESOURCE_LIST *Resources
  1070. )
  1071. {
  1072. PIO_RESOURCE_REQUIREMENTS_LIST requirements;
  1073. PPDO_EXTENSION PdoExtension = DeviceObject->DeviceExtension;
  1074. PIO_RESOURCE_DESCRIPTOR descriptor;
  1075. PCM_RESOURCE_LIST cmResList;
  1076. NTSTATUS status;
  1077. ULONG i;
  1078. PAGED_CODE();
  1079. if (PdoExtension->PdoType == AcpiDriver) {
  1080. //
  1081. // The whole point behind creating a boot config for the
  1082. // ACPI PDO is that the PnP Manager will not terminate
  1083. // its algorithm that tries to reserve boot configs for
  1084. // all of ACPI's children. So it is not necessary that
  1085. // ACPI have a complicated list of resources in its boot
  1086. // config. We'll be happy with just the IRQ.
  1087. //
  1088. // N.B. At the time of this writing, it should also be
  1089. // true that the IRQ is the only resource that the ACPI
  1090. // claims anyhow.
  1091. //
  1092. status = HalpQueryAcpiResourceRequirements(&requirements);
  1093. if (!NT_SUCCESS(status)) {
  1094. return status;
  1095. }
  1096. cmResList = ExAllocatePoolWithTag(PagedPool,
  1097. sizeof(CM_RESOURCE_LIST),
  1098. HAL_POOL_TAG);
  1099. if (!cmResList) {
  1100. ExFreePool(requirements);
  1101. return STATUS_INSUFFICIENT_RESOURCES;
  1102. }
  1103. RtlZeroMemory(cmResList, sizeof(CM_RESOURCE_LIST));
  1104. cmResList->Count = 1;
  1105. cmResList->List[0].InterfaceType = PNPBus;
  1106. cmResList->List[0].BusNumber = -1;
  1107. cmResList->List[0].PartialResourceList.Version = 1;
  1108. cmResList->List[0].PartialResourceList.Revision = 1;
  1109. cmResList->List[0].PartialResourceList.Count = 1;
  1110. cmResList->List[0].PartialResourceList.PartialDescriptors[0].Type =
  1111. CmResourceTypeInterrupt;
  1112. ASSERT(requirements->AlternativeLists == 1);
  1113. for (i = 0; i < requirements->List[0].Count; i++) {
  1114. descriptor = &requirements->List[0].Descriptors[i];
  1115. if (descriptor->Type == CmResourceTypeInterrupt) {
  1116. cmResList->List[0].PartialResourceList.PartialDescriptors[0].ShareDisposition =
  1117. descriptor->ShareDisposition;
  1118. cmResList->List[0].PartialResourceList.PartialDescriptors[0].Flags =
  1119. descriptor->Flags;
  1120. ASSERT(descriptor->u.Interrupt.MinimumVector ==
  1121. descriptor->u.Interrupt.MaximumVector);
  1122. cmResList->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Level =
  1123. descriptor->u.Interrupt.MinimumVector;
  1124. cmResList->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Vector =
  1125. descriptor->u.Interrupt.MinimumVector;
  1126. cmResList->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity = -1;
  1127. *Resources = cmResList;
  1128. ExFreePool(requirements);
  1129. return STATUS_SUCCESS;
  1130. }
  1131. }
  1132. ExFreePool(requirements);
  1133. ExFreePool(cmResList);
  1134. return STATUS_NOT_FOUND;
  1135. } else {
  1136. return STATUS_NOT_SUPPORTED;
  1137. }
  1138. }
  1139. NTSTATUS
  1140. HalpQueryResourceRequirements(
  1141. IN PDEVICE_OBJECT DeviceObject,
  1142. IN PIO_RESOURCE_REQUIREMENTS_LIST *Requirements
  1143. )
  1144. /*++
  1145. Routine Description:
  1146. This routine handles IRP_MN_QUERY_RESOURCE_REQUIREMENTS.
  1147. Arguments:
  1148. DeviceObject - PDO of the child
  1149. Requirements - pointer to be filled in with the devices
  1150. resource requirements.
  1151. Return Value:
  1152. status
  1153. --*/
  1154. {
  1155. PPDO_EXTENSION PdoExtension = DeviceObject->DeviceExtension;
  1156. PAGED_CODE();
  1157. if (PdoExtension->PdoType == AcpiDriver) {
  1158. return HalpQueryAcpiResourceRequirements(Requirements);
  1159. } else {
  1160. return STATUS_NOT_SUPPORTED;
  1161. }
  1162. }
  1163. NTSTATUS
  1164. HalpQueryInterface(
  1165. IN PDEVICE_OBJECT DeviceObject,
  1166. IN LPCGUID InterfaceType,
  1167. IN USHORT Version,
  1168. IN PVOID InterfaceSpecificData,
  1169. IN ULONG InterfaceBufferSize,
  1170. IN OUT PINTERFACE Interface,
  1171. IN OUT PULONG Length
  1172. )
  1173. /*++
  1174. Routine Description:
  1175. This routine fills in the interface structure for
  1176. a device.
  1177. Arguments:
  1178. DeviceObject - PDO of the child
  1179. InterfaceType - Pointer to the interface type GUID.
  1180. Version - Supplies the requested interface version.
  1181. InterfaceSpecificData - This is context that means something based on the
  1182. interface.
  1183. InterfaceBufferSize - Supplies the length of the buffer for the interface
  1184. structure.
  1185. Interface - Supplies a pointer where the interface informaiton should
  1186. be returned.
  1187. Length - This value is updated on return to actual number of bytes modified.
  1188. Return Value:
  1189. status
  1190. --*/
  1191. {
  1192. if (IsEqualGUID(InterfaceType, (PVOID)&GUID_TRANSLATOR_INTERFACE_STANDARD)) {
  1193. PTRANSLATOR_INTERFACE translator = (PTRANSLATOR_INTERFACE)Interface;
  1194. //
  1195. // Common initialization.
  1196. //
  1197. if (InterfaceBufferSize < sizeof(TRANSLATOR_INTERFACE)) {
  1198. *Length = sizeof(TRANSLATOR_INTERFACE);
  1199. return STATUS_BUFFER_TOO_SMALL;
  1200. }
  1201. switch ((CM_RESOURCE_TYPE)InterfaceSpecificData) {
  1202. case CmResourceTypeInterrupt:
  1203. translator->Size = sizeof(TRANSLATOR_INTERFACE);
  1204. translator->Version = HAL_IRQ_TRANSLATOR_VERSION;
  1205. translator->Context = DeviceObject;
  1206. translator->InterfaceReference = HalTranslatorReference;
  1207. translator->InterfaceDereference = HalTranslatorDereference;
  1208. translator->TranslateResources = HalIrqTranslateResourcesRoot;
  1209. translator->TranslateResourceRequirements =
  1210. HalIrqTranslateResourceRequirementsRoot;
  1211. *Length = sizeof(TRANSLATOR_INTERFACE);
  1212. break;
  1213. default:
  1214. return STATUS_NOT_SUPPORTED ;
  1215. }
  1216. return STATUS_SUCCESS;
  1217. }
  1218. #ifdef ACPI_CMOS_ACTIVATE
  1219. else if (IsEqualGUID(InterfaceType, (PVOID) &GUID_ACPI_CMOS_INTERFACE_STANDARD)) {
  1220. PACPI_CMOS_INTERFACE_STANDARD CmosInterface = (PACPI_CMOS_INTERFACE_STANDARD)Interface;
  1221. //
  1222. // Common initialization.
  1223. //
  1224. if (InterfaceBufferSize < sizeof(ACPI_CMOS_INTERFACE_STANDARD)) {
  1225. *Length = sizeof(ACPI_CMOS_INTERFACE_STANDARD);
  1226. return STATUS_BUFFER_TOO_SMALL;
  1227. }
  1228. switch ((CM_RESOURCE_TYPE)InterfaceSpecificData) {
  1229. case CmResourceTypeNull:
  1230. // standard header
  1231. CmosInterface->Size = sizeof(ACPI_CMOS_INTERFACE_STANDARD);
  1232. CmosInterface->Version = 1;
  1233. CmosInterface->InterfaceReference = HalpCmosNullReference;
  1234. CmosInterface->InterfaceDereference = HalpCmosNullReference;
  1235. // cmos interface specific
  1236. CmosInterface->ReadCmos = HalpcGetCmosDataByType;
  1237. CmosInterface->WriteCmos = HalpcSetCmosDataByType;
  1238. *Length = sizeof(ACPI_CMOS_INTERFACE_STANDARD);
  1239. break;
  1240. default:
  1241. return STATUS_NOT_SUPPORTED ;
  1242. }
  1243. return STATUS_SUCCESS;
  1244. }
  1245. #endif // ACPI_CMOS_ACTIVATE
  1246. //
  1247. // If we got here, we don't handle this interface type.
  1248. //
  1249. return STATUS_NOT_SUPPORTED ;
  1250. }
  1251. #ifdef ACPI_CMOS_ACTIVATE
  1252. //
  1253. // This section implements a CMOS access method
  1254. //
  1255. VOID
  1256. HalpCmosNullReference(
  1257. PVOID Context
  1258. )
  1259. {
  1260. return;
  1261. }
  1262. VOID
  1263. HalpCmosNullDereference(
  1264. PVOID Context
  1265. )
  1266. {
  1267. return;
  1268. }
  1269. #endif