SioChip.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /** @file
  2. Super I/O specific header.
  3. Copyright (c) 2010 - 2019 Intel Corporation. All rights reserved. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _SIO_H_
  7. #define _SIO_H_
  8. #include "Register.h"
  9. typedef
  10. UINT8
  11. (EFIAPI *LOCAL_IO_WRITE8) (
  12. IN UINTN Port,
  13. IN UINT8 Value
  14. );
  15. #define RESOURCE_IO BIT0
  16. #define RESOURCE_IRQ BIT1
  17. #define RESOURCE_DMA BIT2
  18. #define RESOURCE_MEM BIT3
  19. #pragma pack(1)
  20. typedef struct {
  21. EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR Io;
  22. EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR Irq;
  23. EFI_ACPI_END_TAG_DESCRIPTOR End;
  24. } ACPI_SIO_RESOURCES_IO_IRQ;
  25. #pragma pack()
  26. typedef struct {
  27. UINT32 HID;
  28. UINT32 UID;
  29. } EFI_SIO_ACPI_DEVICE_ID;
  30. typedef struct {
  31. EFI_SIO_ACPI_DEVICE_ID Device;
  32. UINT8 DeviceId;
  33. UINT8 ResourceMask;
  34. ACPI_RESOURCE_HEADER_PTR Resources;
  35. ACPI_RESOURCE_HEADER_PTR PossibleResources;
  36. } DEVICE_INFO;
  37. /**
  38. Initialize the SIO chip for S3.
  39. **/
  40. VOID
  41. SioInitForS3 (
  42. VOID
  43. );
  44. /**
  45. Return the supported devices.
  46. @param[out] Devices Pointer to pointer of EFI_SIO_ACPI_DEVICE_ID.
  47. Caller is responsible to free the buffer.
  48. @param[out] Count Pointer to UINTN holding the device count.
  49. **/
  50. VOID
  51. DeviceGetList (
  52. OUT EFI_SIO_ACPI_DEVICE_ID **Devices,
  53. OUT UINTN *Count
  54. );
  55. /**
  56. Program the SIO chip to enable the specified device using the default resource.
  57. @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID.
  58. **/
  59. VOID
  60. DeviceEnable (
  61. IN EFI_SIO_ACPI_DEVICE_ID *Device
  62. );
  63. /**
  64. Get the possible ACPI resources for specified device.
  65. @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID.
  66. @param[out] Resources Pointer to ACPI_RESOURCE_HEADER_PTR.
  67. @retval EFI_SUCCESS The resources are returned successfully.
  68. **/
  69. EFI_STATUS
  70. DevicePossibleResources (
  71. IN EFI_SIO_ACPI_DEVICE_ID *Device,
  72. OUT ACPI_RESOURCE_HEADER_PTR *Resources
  73. );
  74. /**
  75. Set the ACPI resources for specified device.
  76. The SIO chip is programmed to use the new resources and the
  77. resources setting are saved. The function assumes the resources
  78. are valid.
  79. @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID.
  80. @param[in] Resources ACPI_RESOURCE_HEADER_PTR.
  81. @retval EFI_SUCCESS The resources are set successfully.
  82. **/
  83. EFI_STATUS
  84. DeviceSetResources (
  85. IN EFI_SIO_ACPI_DEVICE_ID *Device,
  86. IN ACPI_RESOURCE_HEADER_PTR Resources
  87. );
  88. /**
  89. Get the ACPI resources for specified device.
  90. @param[in] Device Pointer to EFI_SIO_ACPI_DEVICE_ID.
  91. @param[out] Resources Pointer to ACPI_RESOURCE_HEADER_PTR.
  92. @retval EFI_SUCCESS The resources are returned successfully.
  93. **/
  94. EFI_STATUS
  95. DeviceGetResources (
  96. IN EFI_SIO_ACPI_DEVICE_ID *Device,
  97. OUT ACPI_RESOURCE_HEADER_PTR *Resources
  98. );
  99. /**
  100. Program the SIO chip to enter the configure mode.
  101. **/
  102. VOID
  103. EnterConfigMode (
  104. VOID
  105. );
  106. /**
  107. Program the SIO chip to exit the configure mode.
  108. **/
  109. VOID
  110. ExitConfigMode (
  111. VOID
  112. );
  113. /**
  114. Perform a 8-bit I/O write to SIO register.
  115. @param[in] Index The register index.
  116. @param[in] Data The value to write to register.
  117. **/
  118. VOID
  119. WriteRegister (
  120. IN UINT8 Index,
  121. IN UINT8 Data
  122. );
  123. /**
  124. Perform a 8-bit I/O read from SIO register.
  125. @param[in] Index The register index.
  126. @retval Value The value written to the register.
  127. **/
  128. UINT8
  129. ReadRegister (
  130. IN UINT8 Index
  131. );
  132. //
  133. // Prototypes for the sio internal function
  134. //
  135. //
  136. // Internal function
  137. //
  138. /**
  139. Find Super I/O controller.
  140. @retval EFI_SUCCESS Super I/O controller exists.
  141. @retval EFI_UNSUPPORTED Super I/O controller does not exist.
  142. **/
  143. EFI_STATUS
  144. SioInit (
  145. VOID
  146. );
  147. #endif