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