TianoCore EDK2 master
Loading...
Searching...
No Matches
FlashDeviceLib.c
Go to the documentation of this file.
1
9#include <PiDxe.h>
11#include <Library/DebugLib.h>
12#include <Library/SpiFlashLib.h>
13
22EFIAPI
24 VOID
25 )
26{
27 return SpiConstructor ();
28}
29
44EFIAPI
46 IN UINTN PAddress,
47 IN OUT UINTN *NumBytes,
48 OUT UINT8 *Buffer
49 )
50{
51 EFI_STATUS Status;
52 UINT32 ByteCount;
53 UINT32 RgnSize;
54 UINT32 AddrOffset;
55
56 Status = SpiGetRegionAddress (FlashRegionBios, NULL, &RgnSize);
57 if (EFI_ERROR (Status)) {
58 return Status;
59 }
60
61 // BIOS region offset can be calculated by (PAddress - (0x100000000 - RgnSize))
62 // which equal (PAddress + RgnSize) here.
63 AddrOffset = (UINT32)((UINT32)PAddress + RgnSize);
64 ByteCount = (UINT32)*NumBytes;
65 return SpiFlashRead (FlashRegionBios, AddrOffset, ByteCount, Buffer);
66}
67
82EFIAPI
84 IN UINTN PAddress,
85 IN OUT UINTN *NumBytes,
86 IN UINT8 *Buffer
87 )
88{
89 EFI_STATUS Status;
90 UINT32 ByteCount;
91 UINT32 RgnSize;
92 UINT32 AddrOffset;
93
94 Status = SpiGetRegionAddress (FlashRegionBios, NULL, &RgnSize);
95 if (EFI_ERROR (Status)) {
96 return Status;
97 }
98
99 // BIOS region offset can be calculated by (PAddress - (0x100000000 - RgnSize))
100 // which equal (PAddress + RgnSize) here.
101 AddrOffset = (UINT32)((UINT32)PAddress + RgnSize);
102 ByteCount = (UINT32)*NumBytes;
103 return SpiFlashWrite (FlashRegionBios, AddrOffset, ByteCount, Buffer);
104}
105
119EFIAPI
121 IN UINTN PAddress,
122 IN UINTN LbaLength
123 )
124{
125 EFI_STATUS Status;
126 UINT32 RgnSize;
127 UINT32 AddrOffset;
128
129 Status = SpiGetRegionAddress (FlashRegionBios, NULL, &RgnSize);
130 if (EFI_ERROR (Status)) {
131 return Status;
132 }
133
134 // BIOS region offset can be calculated by (PAddress - (0x100000000 - RgnSize))
135 // which equal (PAddress + RgnSize) here.
136 AddrOffset = (UINT32)((UINT32)PAddress + RgnSize);
137 return SpiFlashErase (FlashRegionBios, AddrOffset, (UINT32)LbaLength);
138}
139
152EFIAPI
154 IN UINTN PAddress,
155 IN UINTN LbaLength,
156 IN BOOLEAN Lock
157 )
158{
159 return EFI_SUCCESS;
160}
UINT64 UINTN
EFI_STATUS EFIAPI LibFvbFlashDeviceInit(VOID)
EFI_STATUS EFIAPI LibFvbFlashDeviceRead(IN UINTN PAddress, IN OUT UINTN *NumBytes, OUT UINT8 *Buffer)
EFI_STATUS EFIAPI LibFvbFlashDeviceBlockLock(IN UINTN PAddress, IN UINTN LbaLength, IN BOOLEAN Lock)
EFI_STATUS EFIAPI LibFvbFlashDeviceBlockErase(IN UINTN PAddress, IN UINTN LbaLength)
EFI_STATUS EFIAPI LibFvbFlashDeviceWrite(IN UINTN PAddress, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI Lock(IN EFI_SMM_ACCESS2_PROTOCOL *This)
Definition: SmmAccessDxe.c:133
EFI_STATUS EFIAPI SpiFlashErase(IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount)
Definition: SpiFlashLib.c:221
EFI_STATUS EFIAPI SpiConstructor(VOID)
Definition: SpiFlashLib.c:42
EFI_STATUS EFIAPI SpiGetRegionAddress(IN FLASH_REGION_TYPE FlashRegionType, OUT UINT32 *BaseAddress OPTIONAL, OUT UINT32 *RegionSize OPTIONAL)
Definition: SpiFlashLib.c:820
EFI_STATUS EFIAPI SpiFlashWrite(IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer)
Definition: SpiFlashLib.c:195
EFI_STATUS EFIAPI SpiFlashRead(IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer)
Definition: SpiFlashLib.c:168
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112