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