SioService.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /** @file
  2. The SioBusDxe driver is used to create child devices on the ISA bus and
  3. installs the Super I/O protocols on them.
  4. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __SIO_SERVICE_H__
  8. #define __SIO_SERVICE_H__
  9. #pragma pack(1)
  10. typedef struct {
  11. EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR Io;
  12. EFI_ACPI_END_TAG_DESCRIPTOR End;
  13. } SIO_RESOURCES_IO;
  14. #pragma pack()
  15. typedef struct {
  16. UINT32 Hid;
  17. UINT32 Uid;
  18. ACPI_RESOURCE_HEADER_PTR Resources;
  19. } SIO_DEVICE_INFO;
  20. //
  21. // SIO device private data structure
  22. //
  23. typedef struct {
  24. UINT32 Signature;
  25. EFI_HANDLE Handle;
  26. EFI_PCI_IO_PROTOCOL *PciIo;
  27. EFI_DEVICE_PATH_PROTOCOL *DevicePath;
  28. EFI_SIO_PROTOCOL Sio;
  29. UINT32 DeviceIndex;
  30. } SIO_DEV;
  31. #define SIO_DEV_SIGNATURE SIGNATURE_32 ('S', 'I', 'O', 'D')
  32. #define SIO_DEV_FROM_SIO(a) CR (a, SIO_DEV, Sio, SIO_DEV_SIGNATURE)
  33. //
  34. // Super I/O Protocol interfaces
  35. //
  36. /**
  37. Provides a low level access to the registers for the Super I/O.
  38. @param[in] This Indicates a pointer to the calling context.
  39. @param[in] Write Specifies the type of the register operation.
  40. If this parameter is TRUE, Value is interpreted
  41. as an input parameter and the operation is a
  42. register write. If this parameter is FALSE,
  43. Value is interpreted as an output parameter and
  44. the operation is a register read.
  45. @param[in] ExitCfgMode Exit Configuration Mode Indicator. If this
  46. parameter is set to TRUE, the Super I/O driver
  47. will turn off configuration mode of the Super
  48. I/O prior to returning from this function. If
  49. this parameter is set to FALSE, the Super I/O
  50. driver will leave Super I/O in the
  51. configuration mode. The Super I/O driver must
  52. track the current state of the Super I/O and
  53. enable the configuration mode of Super I/O if
  54. necessary prior to register access.
  55. @param[in] Register Register number.
  56. @param[in,out] Value If Write is TRUE, Value is a pointer to the
  57. buffer containing the byte of data to be
  58. written to the Super I/O register. If Write is
  59. FALSE, Value is a pointer to the destination
  60. buffer for the byte of data to be read from the
  61. Super I/O register.
  62. @retval EFI_SUCCESS The operation completed successfully.
  63. @retval EFI_INVALID_PARAMETER The Value is NULL.
  64. @retval EFI_INVALID_PARAMETER Invalid Register number.
  65. **/
  66. EFI_STATUS
  67. EFIAPI
  68. SioRegisterAccess (
  69. IN CONST EFI_SIO_PROTOCOL *This,
  70. IN BOOLEAN Write,
  71. IN BOOLEAN ExitCfgMode,
  72. IN UINT8 Register,
  73. IN OUT UINT8 *Value
  74. );
  75. /**
  76. Provides an interface to get a list of the current resources consumed by the
  77. device in the ACPI Resource Descriptor format.
  78. GetResources() returns a list of resources currently consumed by the device.
  79. The ResourceList is a pointer to the buffer containing resource descriptors
  80. for the device. The descriptors are in the format of Small or Large ACPI
  81. resource descriptor as defined by ACPI specification (2.0 & 3.0). The buffer
  82. of resource descriptors is terminated with the 'End tag' resource descriptor.
  83. @param[in] This Indicates a pointer to the calling context.
  84. @param[out] ResourceList A pointer to an ACPI resource descriptor list
  85. that defines the current resources used by the
  86. device.
  87. @retval EFI_SUCCESS The operation completed successfully.
  88. @retval EFI_INVALID_PARAMETER ResourceList is NULL.
  89. **/
  90. EFI_STATUS
  91. EFIAPI
  92. SioGetResources (
  93. IN CONST EFI_SIO_PROTOCOL *This,
  94. OUT ACPI_RESOURCE_HEADER_PTR *ResourceList
  95. );
  96. /**
  97. Sets the resources for the device.
  98. @param[in] This Indicates a pointer to the calling context.
  99. @param[in] ResourceList Pointer to the ACPI resource descriptor list.
  100. @retval EFI_SUCCESS The operation completed successfully.
  101. @retval EFI_INVALID_PARAMETER ResourceList is invalid.
  102. @retval EFI_ACCESS_DENIED Some of the resources in ResourceList are in
  103. use.
  104. **/
  105. EFI_STATUS
  106. EFIAPI
  107. SioSetResources (
  108. IN CONST EFI_SIO_PROTOCOL *This,
  109. IN ACPI_RESOURCE_HEADER_PTR ResourceList
  110. );
  111. /**
  112. Provides a collection of resource descriptor lists. Each resource descriptor
  113. list in the collection defines a combination of resources that can
  114. potentially be used by the device.
  115. @param[in] This Indicates a pointer to the calling context.
  116. @param[out] ResourceCollection Collection of the resource descriptor
  117. lists.
  118. @retval EFI_SUCCESS The operation completed successfully.
  119. @retval EFI_INVALID_PARAMETER ResourceCollection is NULL.
  120. **/
  121. EFI_STATUS
  122. EFIAPI
  123. SioPossibleResources (
  124. IN CONST EFI_SIO_PROTOCOL *This,
  125. OUT ACPI_RESOURCE_HEADER_PTR *ResourceCollection
  126. );
  127. /**
  128. Provides an interface for a table based programming of the Super I/O
  129. registers.
  130. The Modify() function provides an interface for table based programming of
  131. the Super I/O registers. This function can be used to perform programming of
  132. multiple Super I/O registers with a single function call. For each table
  133. entry, the Register is read, its content is bitwise ANDed with AndMask, and
  134. then ORed with OrMask before being written back to the Register. The Super
  135. I/O driver must track the current state of the Super I/O and enable the
  136. configuration mode of Super I/O if necessary prior to table processing. Once
  137. the table is processed, the Super I/O device has to be returned to the
  138. original state.
  139. @param[in] This Indicates a pointer to the calling context.
  140. @param[in] Command A pointer to an array of NumberOfCommands
  141. EFI_SIO_REGISTER_MODIFY structures. Each
  142. structure specifies a single Super I/O register
  143. modify operation.
  144. @param[in] NumberOfCommands Number of elements in the Command array.
  145. @retval EFI_SUCCESS The operation completed successfully.
  146. @retval EFI_INVALID_PARAMETER Command is NULL.
  147. **/
  148. EFI_STATUS
  149. EFIAPI
  150. SioModify (
  151. IN CONST EFI_SIO_PROTOCOL *This,
  152. IN CONST EFI_SIO_REGISTER_MODIFY *Command,
  153. IN UINTN NumberOfCommands
  154. );
  155. //
  156. // Internal functions
  157. //
  158. /**
  159. Create all the ISA child devices on the ISA bus controller (PCI to ISA
  160. bridge).
  161. @param[in] This The EFI_DRIVER_BINDING_PROTOCOL instance.
  162. @param[in] Controller The handle of ISA bus controller.
  163. @param[in] PciIo The pointer to the PCI protocol.
  164. @param[in] ParentDevicePath Device path of the ISA bus controller.
  165. @retval The number of child device that is successfully created.
  166. **/
  167. UINT32
  168. SioCreateAllChildDevices (
  169. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  170. IN EFI_HANDLE Controller,
  171. IN EFI_PCI_IO_PROTOCOL *PciIo,
  172. IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath
  173. );
  174. #endif // __SIO_SERVICE_H__