2 This file defines the Legacy SPI Controller Protocol.
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD
7 License which accompanies this distribution. The full text of the license may
8 be found at http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 @par Revision Reference:
14 This Protocol was introduced in UEFI PI Specification 1.6.
18 #ifndef __LEGACY_SPI_CONTROLLER_PROTOCOL_H__
19 #define __LEGACY_SPI_CONTROLLER_PROTOCOL_H__
22 /// Note: The UEFI PI 1.6 specification uses the character 'l' in the GUID
23 /// definition. This definition assumes it was supposed to be '1'.
25 /// Global ID for the Legacy SPI Controller Protocol
27 #define EFI_LEGACY_SPI_CONTROLLER_GUID \
28 { 0x39136fc7, 0x1a11, 0x49de, \
29 { 0xbf, 0x35, 0x0e, 0x78, 0xdd, 0xb5, 0x24, 0xfc }}
32 struct _EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
33 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
;
36 Set the erase block opcode.
38 This routine must be called at or below TPL_NOTIFY.
39 The menu table contains SPI transaction opcodes which are accessible after
40 the legacy SPI flash controller's configuration is locked. The board layer
41 specifies the erase block size for the SPI NOR flash part. The SPI NOR flash
42 peripheral driver selects the erase block opcode which matches the erase
43 block size and uses this API to load the opcode into the opcode menu table.
45 @param[in] This Pointer to an EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
47 @param[in] EraseBlockOpcode Erase block opcode to be placed into the opcode
50 @retval EFI_SUCCESS The opcode menu table was updated
51 @retval EFI_ACCESS_ERROR The SPI controller is locked
55 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_ERASE_BLOCK_OPCODE
) (
56 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
,
57 IN UINT8 EraseBlockOpcode
61 Set the write status prefix opcode.
63 This routine must be called at or below TPL_NOTIFY.
64 The prefix table contains SPI transaction write prefix opcodes which are
65 accessible after the legacy SPI flash controller's configuration is locked.
66 The board layer specifies the write status prefix opcode for the SPI NOR
67 flash part. The SPI NOR flash peripheral driver uses this API to load the
68 opcode into the prefix table.
70 @param[in] This Pointer to an
71 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL structure.
72 @param[in] WriteStatusPrefix Prefix opcode for the write status command.
74 @retval EFI_SUCCESS The prefix table was updated
75 @retval EFI_ACCESS_ERROR The SPI controller is locked
80 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_WRITE_STATUS_PREFIX
) (
81 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
,
82 IN UINT8 WriteStatusPrefix
86 Set the BIOS base address.
88 This routine must be called at or below TPL_NOTIFY.
89 The BIOS base address works with the protect range registers to protect
90 portions of the SPI NOR flash from erase and write operat ions. The BIOS
91 calls this API prior to passing control to the OS loader.
93 @param[in] This Pointer to an EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
95 @param[in] BiosBaseAddress The BIOS base address.
97 @retval EFI_SUCCESS The BIOS base address was properly set
98 @retval EFI_ACCESS_ERROR The SPI controller is locked
99 @retval EFI_INVALID_PARAMETER The BIOS base address is greater than
101 @retval EFI_UNSUPPORTED The BIOS base address was already set
105 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_BIOS_BASE_ADDRESS
) (
106 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
,
107 IN UINT32 BiosBaseAddress
111 Clear the SPI protect range registers.
113 This routine must be called at or below TPL_NOTIFY.
114 The BIOS uses this routine to set an initial condition on the SPI protect
117 @param[in] This Pointer to an EFI_LEGACY_SPI_CONTROLLER_PROTOCOL structure.
119 @retval EFI_SUCCESS The registers were successfully cleared
120 @retval EFI_ACCESS_ERROR The SPI controller is locked
125 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_CLEAR_SPI_PROTECT
) (
126 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
130 Determine if the SPI range is protected.
132 This routine must be called at or below TPL_NOTIFY.
133 The BIOS uses this routine to verify a range in the SPI is protected.
135 @param[in] This Pointer to an EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
137 @param[in] BiosAddress Address within a 4 KiB block to start protecting.
138 @param[in] BytesToProtect The number of 4 KiB blocks to protect.
140 @retval TRUE The range is protected
141 @retval FALSE The range is not protected
146 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_IS_RANGE_PROTECTED
) (
147 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
,
148 IN UINT32 BiosAddress
,
149 IN UINT32 BlocksToProtect
153 Set the next protect range register.
155 This routine must be called at or below TPL_NOTIFY.
156 The BIOS sets the protect range register to prevent write and erase
157 operations to a portion of the SPI NOR flash device.
159 @param[in] This Pointer to an EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
161 @param[in] BiosAddress Address within a 4 KiB block to start protecting.
162 @param[in] BlocksToProtect The number of 4 KiB blocks to protect.
164 @retval EFI_SUCCESS The register was successfully updated
165 @retval EFI_ACCESS_ERROR The SPI controller is locked
166 @retval EFI_INVALID_PARAMETER BiosAddress < This->BiosBaseAddress, or
167 BlocksToProtect * 4 KiB
168 > This->MaximumRangeBytes, or
169 BiosAddress - This->BiosBaseAddress
170 + (BlocksToProtect * 4 KiB)
171 > This->MaximumRangeBytes
172 @retval EFI_OUT_OF_RESOURCES No protect range register available
173 @retval EFI_UNSUPPORTED Call This->SetBaseAddress because the BIOS base
179 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_PROTECT_NEXT_RANGE
) (
180 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
,
181 IN UINT32 BiosAddress
,
182 IN UINT32 BlocksToProtect
186 Lock the SPI controller configuration.
188 This routine must be called at or below TPL_NOTIFY.
189 This routine locks the SPI controller's configuration so that the software
190 is no longer able to update:
195 * Protect range registers
197 @param[in] This Pointer to an EFI_LEGACY_SPI_CONTROLLER_PROTOCOL structure.
199 @retval EFI_SUCCESS The SPI controller was successfully locked
200 @retval EFI_ALREADY_STARTED The SPI controller was already locked
204 (EFIAPI
*EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_LOCK_CONTROLLER
) (
205 IN CONST EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
*This
209 /// Support the extra features of the legacy SPI flash controller.
211 struct _EFI_LEGACY_SPI_CONTROLLER_PROTOCOL
{
213 /// Maximum offset from the BIOS base address that is able to be protected.
215 UINT32 MaximumOffset
;
218 /// Maximum number of bytes that can be protected by one range register.
220 UINT32 MaximumRangeBytes
;
223 /// The number of registers available for protecting the BIOS.
225 UINT32 RangeRegisterCount
;
228 /// Set the erase block opcode.
230 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_ERASE_BLOCK_OPCODE EraseBlockOpcode
;
233 /// Set the write status prefix opcode.
235 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_WRITE_STATUS_PREFIX WriteStatusPrefix
;
238 /// Set the BIOS base address.
240 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_BIOS_BASE_ADDRESS BiosBaseAddress
;
243 /// Clear the SPI protect range registers.
245 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_CLEAR_SPI_PROTECT ClearSpiProtect
;
248 /// Determine if the SPI range is protected.
250 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_IS_RANGE_PROTECTED IsRangeProtected
;
253 /// Set the next protect range register.
255 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_PROTECT_NEXT_RANGE ProtectNextRange
;
258 /// Lock the SPI controller configuration.
260 EFI_LEGACY_SPI_CONTROLLER_PROTOCOL_LOCK_CONTROLLER LockController
;
263 extern EFI_GUID gEfiLegacySpiControllerProtocolGuid
;
265 #endif // __LEGACY_SPI_CONTROLLER_PROTOCOL_H__