TianoCore EDK2 master
Loading...
Searching...
No Matches
SpiFlashLib.h File Reference

Go to the source code of this file.

Enumerations

enum  FLASH_REGION_TYPE {
  FlashRegionDescriptor , FlashRegionBios , FlashRegionMe , FlashRegionGbE ,
  FlashRegionPlatformData , FlashRegionDer , FlashRegionAll , FlashRegionMax
}
 

Functions

EFI_STATUS EFIAPI SpiFlashReadSfdp (IN UINT8 ComponentNumber, IN UINT32 ByteCount, OUT UINT8 *SfdpData)
 
EFI_STATUS EFIAPI SpiFlashReadJedecId (IN UINT8 ComponentNumber, IN UINT32 ByteCount, OUT UINT8 *JedecId)
 
EFI_STATUS EFIAPI SpiFlashWriteStatus (IN UINT32 ByteCount, IN UINT8 *StatusValue)
 
EFI_STATUS EFIAPI SpiFlashReadStatus (IN UINT32 ByteCount, OUT UINT8 *StatusValue)
 
EFI_STATUS EFIAPI SpiReadPchSoftStrap (IN UINT32 SoftStrapAddr, IN UINT32 ByteCount, OUT UINT8 *SoftStrapValue)
 
EFI_STATUS EFIAPI SpiFlashRead (IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer)
 
EFI_STATUS EFIAPI SpiFlashErase (IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount)
 
EFI_STATUS EFIAPI SpiFlashWrite (IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer)
 
EFI_STATUS EFIAPI SpiConstructor (VOID)
 
EFI_STATUS EFIAPI SpiGetRegionAddress (IN FLASH_REGION_TYPE FlashRegionType, OUT UINT32 *BaseAddress OPTIONAL, OUT UINT32 *RegionSize OPTIONAL)
 

Detailed Description

PCH SPI Common Driver implements the SPI Host Controller Compatibility Interface.

Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SpiFlashLib.h.

Enumeration Type Documentation

◆ FLASH_REGION_TYPE

Flash Region Type

Definition at line 15 of file SpiFlashLib.h.

Function Documentation

◆ SpiConstructor()

EFI_STATUS EFIAPI SpiConstructor ( VOID  )

Initialize an SPI library.

Return values
EFI_SUCCESSThe protocol instance was properly initialized
EFI_NOT_FOUNDThe expected SPI info could not be found

Definition at line 42 of file SpiFlashLib.c.

◆ SpiFlashErase()

EFI_STATUS EFIAPI SpiFlashErase ( IN FLASH_REGION_TYPE  FlashRegionType,
IN UINT32  Address,
IN UINT32  ByteCount 
)

Erase some area on the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 221 of file SpiFlashLib.c.

◆ SpiFlashRead()

EFI_STATUS EFIAPI SpiFlashRead ( IN FLASH_REGION_TYPE  FlashRegionType,
IN UINT32  Address,
IN UINT32  ByteCount,
OUT UINT8 *  Buffer 
)

Read data from the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
[out]BufferThe Pointer to caller-allocated buffer containing the dada received. It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Read data from the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
[out]BufferThe Pointer to caller-allocated buffer containing the data received. It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 168 of file SpiFlashLib.c.

◆ SpiFlashReadJedecId()

EFI_STATUS EFIAPI SpiFlashReadJedecId ( IN UINT8  ComponentNumber,
IN UINT32  ByteCount,
OUT UINT8 *  JedecId 
)

Read Jedec Id from the flash part.

Parameters
[in]ComponentNumberThe Component Number for chip select
[in]ByteCountNumber of bytes in JedecId data portion of the SPI cycle, the data size is 3 typically
[out]JedecIdThe Pointer to caller-allocated buffer containing JEDEC ID received It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 290 of file SpiFlashLib.c.

◆ SpiFlashReadSfdp()

EFI_STATUS EFIAPI SpiFlashReadSfdp ( IN UINT8  ComponentNumber,
IN UINT32  ByteCount,
OUT UINT8 *  SfdpData 
)

Read SFDP data from the flash part.

Parameters
[in]ComponentNumberThe Component Number for chip select
[in]ByteCountNumber of bytes in SFDP data portion of the SPI cycle, the max number is 64
[out]SfdpDataThe Pointer to caller-allocated buffer containing the SFDP data received It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 247 of file SpiFlashLib.c.

◆ SpiFlashReadStatus()

EFI_STATUS EFIAPI SpiFlashReadStatus ( IN UINT32  ByteCount,
OUT UINT8 *  StatusValue 
)

Read status register in the flash part.

Parameters
[in]ByteCountNumber of bytes in Status data portion of the SPI cycle, the data size is 1 typically
[out]StatusValueThe Pointer to caller-allocated buffer containing the value of Status register received.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 354 of file SpiFlashLib.c.

◆ SpiFlashWrite()

EFI_STATUS EFIAPI SpiFlashWrite ( IN FLASH_REGION_TYPE  FlashRegionType,
IN UINT32  Address,
IN UINT32  ByteCount,
IN UINT8 *  Buffer 
)

Write data to the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
[in]BufferPointer to caller-allocated buffer containing the data sent during the SPI cycle.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 195 of file SpiFlashLib.c.

◆ SpiFlashWriteStatus()

EFI_STATUS EFIAPI SpiFlashWriteStatus ( IN UINT32  ByteCount,
IN UINT8 *  StatusValue 
)

Write the status register in the flash part.

Parameters
[in]ByteCountNumber of bytes in Status data portion of the SPI cycle, the data size is 1 typically
[in]StatusValueThe Pointer to caller-allocated buffer containing the value of Status register writing
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 331 of file SpiFlashLib.c.

◆ SpiGetRegionAddress()

EFI_STATUS EFIAPI SpiGetRegionAddress ( IN FLASH_REGION_TYPE  FlashRegionType,
OUT UINT32 *BaseAddress  OPTIONAL,
OUT UINT32 *RegionSize  OPTIONAL 
)

Get the SPI region base and size, based on the enum type

Parameters
[in]FlashRegionTypeThe Flash Region type for for the base address which is listed in the Descriptor.
[out]BaseAddressThe Flash Linear Address for the Region 'n' Base
[out]RegionSizeThe size for the Region 'n'
Return values
EFI_SUCCESSRead success
EFI_INVALID_PARAMETERInvalid region type given
EFI_DEVICE_ERRORThe region is not used

Definition at line 820 of file SpiFlashLib.c.

◆ SpiReadPchSoftStrap()

EFI_STATUS EFIAPI SpiReadPchSoftStrap ( IN UINT32  SoftStrapAddr,
IN UINT32  ByteCount,
OUT UINT8 *  SoftStrapValue 
)

Read SC Soft Strap Values

Parameters
[in]SoftStrapAddrSC Soft Strap address offset from FPSBA.
[in]ByteCountNumber of bytes in SoftStrap data portion of the SPI cycle
[out]SoftStrapValueThe Pointer to caller-allocated buffer containing SC Soft Strap Value. It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.

Definition at line 379 of file SpiFlashLib.c.