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