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