xref: /illumos-gate/usr/src/boot/efi/include/Protocol/SuperIo.h (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
1 /** @file
2   The Super I/O Protocol is installed by the Super I/O driver. The Super I/O driver is a UEFI driver
3   model compliant driver. In the Start() routine of the Super I/O driver, a handle with an instance
4   of EFI_SIO_PROTOCOL is created for each device within the Super I/O. The device within the
5   Super I/O is powered up, enabled, and assigned with the default set of resources. In the Stop()
6   routine of the Super I/O driver, the device is disabled and Super I/O protocol is uninstalled.
7 
8   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9   SPDX-License-Identifier: BSD-2-Clause-Patent
10 
11 **/
12 
13 #ifndef __EFI_SUPER_IO_PROTOCOL_H__
14 #define __EFI_SUPER_IO_PROTOCOL_H__
15 #include <IndustryStandard/Acpi.h>
16 
17 #define EFI_SIO_PROTOCOL_GUID \
18   { 0x215fdd18, 0xbd50, 0x4feb, { 0x89, 0xb, 0x58, 0xca, 0xb, 0x47, 0x39, 0xe9 } }
19 
20 typedef union {
21   ACPI_SMALL_RESOURCE_HEADER    *SmallHeader;
22   ACPI_LARGE_RESOURCE_HEADER    *LargeHeader;
23 } ACPI_RESOURCE_HEADER_PTR;
24 
25 typedef struct {
26   UINT8    Register;    ///< Register number.
27   UINT8    AndMask;     ///< Bitwise AND mask.
28   UINT8    OrMask;      ///< Bitwise OR mask.
29 } EFI_SIO_REGISTER_MODIFY;
30 
31 typedef struct _EFI_SIO_PROTOCOL EFI_SIO_PROTOCOL;
32 
33 /**
34   Provides a low level access to the registers for the Super I/O.
35 
36   @param[in]        This        Indicates a pointer to the calling context.
37   @param[in]        Write       Specifies the type of the register operation. If this parameter is TRUE, Value is
38                                 interpreted as an input parameter and the operation is a register write. If this parameter
39                                 is FALSE, Value is interpreted as an output parameter and the operation is a register
40                                 read.
41   @param[in]        ExitCfgMode Exit Configuration Mode Indicator. If this parameter is set to TRUE, the Super I/O
42                                 driver will turn off configuration mode of the Super I/O prior to returning from this
43                                 function. If this parameter is set to FALSE, the Super I/O driver will leave Super I/O
44                                 in the configuration mode.
45                                 The Super I/O driver must track the current state of the Super I/O and enable the
46                                 configuration mode of Super I/O if necessary prior to register access.
47   @param[in]        Register    Register number.
48   @param[in, out]   Value       If Write is TRUE, Value is a pointer to the buffer containing the byte of data to be
49                                 written to the Super I/O register. If Write is FALSE, Value is a pointer to the
50                                 destination buffer for the byte of data to be read from the Super I/O register.
51 
52   @retval EFI_SUCCESS           The operation completed successfully
53   @retval EFI_INVALID_PARAMETER The Value is NULL
54   @retval EFI_INVALID_PARAMETER Invalid Register number
55 
56 **/
57 typedef
58 EFI_STATUS
59 (EFIAPI *EFI_SIO_REGISTER_ACCESS)(
60   IN   CONST  EFI_SIO_PROTOCOL  *This,
61   IN          BOOLEAN           Write,
62   IN          BOOLEAN           ExitCfgMode,
63   IN          UINT8             Register,
64   IN OUT      UINT8             *Value
65   );
66 
67 /**
68   Provides an interface to get a list of the current resources consumed by the device in the ACPI
69   Resource Descriptor format.
70 
71   GetResources() returns a list of resources currently consumed by the device. The
72   ResourceList is a pointer to the buffer containing resource descriptors for the device. The
73   descriptors are in the format of Small or Large ACPI resource descriptor as defined by ACPI
74   specification (2.0 & 3.0). The buffer of resource descriptors is terminated with the 'End tag'
75   resource descriptor.
76 
77   @param[in]    This            Indicates a pointer to the calling context.
78   @param[out]   ResourceList    A pointer to an ACPI resource descriptor list that defines the current resources used by
79                                 the device. Type ACPI_RESOURCE_HEADER_PTR is defined in the "Related
80                                 Definitions" below.
81 
82   @retval EFI_SUCCESS           The operation completed successfully
83   @retval EFI_INVALID_PARAMETER ResourceList is NULL
84 
85 **/
86 typedef
87 EFI_STATUS
88 (EFIAPI *EFI_SIO_GET_RESOURCES)(
89   IN  CONST EFI_SIO_PROTOCOL            *This,
90   OUT       ACPI_RESOURCE_HEADER_PTR    *ResourceList
91   );
92 
93 /**
94   Sets the resources for the device.
95 
96   @param[in]  This          Indicates a pointer to the calling context.
97   @param[in]  ResourceList  Pointer to the ACPI resource descriptor list. Type ACPI_RESOURCE_HEADER_PTR
98                             is defined in the "Related Definitions" section of
99                             EFI_SIO_PROTOCOL.GetResources().
100 
101   @retval EFI_SUCCESS           The operation completed successfully
102   @retval EFI_INVALID_PARAMETER ResourceList is invalid
103   @retval EFI_ACCESS_DENIED     Some of the resources in ResourceList are in use
104 
105 **/
106 typedef
107 EFI_STATUS
108 (EFIAPI *EFI_SIO_SET_RESOURCES)(
109   IN CONST  EFI_SIO_PROTOCOL        *This,
110   IN        ACPI_RESOURCE_HEADER_PTR ResourceList
111   );
112 
113 /**
114   Provides a collection of resource descriptor lists. Each resource descriptor list in the collection
115   defines a combination of resources that can potentially be used by the device.
116 
117   @param[in]  This                  Indicates a pointer to the calling context.
118   @param[out] ResourceCollection    Collection of the resource descriptor lists.
119 
120   @retval EFI_SUCCESS               The operation completed successfully
121   @retval EFI_INVALID_PARAMETER     ResourceCollection is NULL
122 **/
123 typedef
124 EFI_STATUS
125 (EFIAPI *EFI_SIO_POSSIBLE_RESOURCES)(
126   IN  CONST EFI_SIO_PROTOCOL         *This,
127   OUT       ACPI_RESOURCE_HEADER_PTR *ResourceCollection
128   );
129 
130 /**
131   Provides an interface for a table based programming of the Super I/O registers.
132 
133   The Modify() function provides an interface for table based programming of the Super I/O
134   registers. This function can be used to perform programming of multiple Super I/O registers with a
135   single function call. For each table entry, the Register is read, its content is bitwise ANDed with
136   AndMask, and then ORed with OrMask before being written back to the Register. The Super
137   I/O driver must track the current state of the Super I/O and enable the configuration mode of Super I/
138   O if necessary prior to table processing. Once the table is processed, the Super I/O device has to be
139   returned to the original state.
140 
141   @param[in] This       Indicates a pointer to the calling context.
142   @param[in] Command    A pointer to an array of NumberOfCommands EFI_SIO_REGISTER_MODIFY
143                         structures. Each structure specifies a single Super I/O register modify operation. Type
144                         EFI_SIO_REGISTER_MODIFY is defined in the "Related Definitions" below.
145   @param[in] NumberOfCommands Number of elements in the Command array.
146 
147   @retval EFI_SUCCESS           The operation completed successfully
148   @retval EFI_INVALID_PARAMETER Command is NULL
149 
150 **/
151 typedef
152 EFI_STATUS
153 (EFIAPI *EFI_SIO_MODIFY)(
154   IN CONST EFI_SIO_PROTOCOL         *This,
155   IN CONST EFI_SIO_REGISTER_MODIFY  *Command,
156   IN       UINTN                    NumberOfCommands
157   );
158 
159 struct _EFI_SIO_PROTOCOL {
160   EFI_SIO_REGISTER_ACCESS       RegisterAccess;
161   EFI_SIO_GET_RESOURCES         GetResources;
162   EFI_SIO_SET_RESOURCES         SetResources;
163   EFI_SIO_POSSIBLE_RESOURCES    PossibleResources;
164   EFI_SIO_MODIFY                Modify;
165 };
166 
167 extern EFI_GUID  gEfiSioProtocolGuid;
168 
169 #endif // __EFI_SUPER_IO_PROTOCOL_H__
170