9#ifndef __VIRT_NOR_FLASH__
10#define __VIRT_NOR_FLASH__
25#define NOR_FLASH_ERASE_RETRY 10
30#define HIGH_16_BITS 0xFFFF0000
31#define LOW_16_BITS 0x0000FFFF
32#define LOW_8_BITS 0x000000FF
34#define FOLD_32BIT_INTO_16BIT(value) ( ( value >> 16 ) | ( value & LOW_16_BITS ) )
36#define GET_LOW_BYTE(value) ( value & LOW_8_BITS )
37#define GET_HIGH_BYTE(value) ( GET_LOW_BYTE( value >> 16 ) )
41#define CREATE_NOR_ADDRESS(BaseAddr, OffsetAddr) ((BaseAddr) + ((OffsetAddr) << 2))
42#define CREATE_DUAL_CMD(Cmd) ( ( Cmd << 16) | ( Cmd & LOW_16_BITS) )
43#define SEND_NOR_COMMAND(BaseAddr, Offset, Cmd) MmioWrite32 (CREATE_NOR_ADDRESS(BaseAddr,Offset), CREATE_DUAL_CMD(Cmd))
44#define GET_NOR_BLOCK_ADDRESS(BaseAddr, Lba, LbaSize) ( BaseAddr + (UINTN)((Lba) * LbaSize) )
47#define P30_SR_BIT_WRITE (BIT7 << 16 | BIT7)
48#define P30_SR_BIT_ERASE_SUSPEND (BIT6 << 16 | BIT6)
49#define P30_SR_BIT_ERASE (BIT5 << 16 | BIT5)
50#define P30_SR_BIT_PROGRAM (BIT4 << 16 | BIT4)
51#define P30_SR_BIT_VPP (BIT3 << 16 | BIT3)
52#define P30_SR_BIT_PROGRAM_SUSPEND (BIT2 << 16 | BIT2)
53#define P30_SR_BIT_BLOCK_LOCKED (BIT1 << 16 | BIT1)
54#define P30_SR_BIT_BEFP (BIT0 << 16 | BIT0)
61#define P30_MAX_BUFFER_SIZE_IN_BYTES ((UINTN)128)
62#define P30_MAX_BUFFER_SIZE_IN_WORDS (P30_MAX_BUFFER_SIZE_IN_BYTES/((UINTN)4))
63#define MAX_BUFFERED_PROG_ITERATIONS 10000000
64#define BOUNDARY_OF_32_WORDS ((UINTN)0x7F)
67#define P30_CFI_ADDR_QUERY_UNIQUE_QRY 0x10
68#define P30_CFI_ADDR_VENDOR_ID 0x13
71#define CFI_QRY 0x00595251
74#define P30_CMD_READ_DEVICE_ID 0x0090
75#define P30_CMD_READ_STATUS_REGISTER 0x0070
76#define P30_CMD_CLEAR_STATUS_REGISTER 0x0050
77#define P30_CMD_READ_ARRAY 0x00FF
78#define P30_CMD_READ_CFI_QUERY 0x0098
81#define P30_CMD_WORD_PROGRAM_SETUP 0x0040
82#define P30_CMD_ALTERNATE_WORD_PROGRAM_SETUP 0x0010
83#define P30_CMD_BUFFERED_PROGRAM_SETUP 0x00E8
84#define P30_CMD_BUFFERED_PROGRAM_CONFIRM 0x00D0
85#define P30_CMD_BEFP_SETUP 0x0080
86#define P30_CMD_BEFP_CONFIRM 0x00D0
89#define P30_CMD_BLOCK_ERASE_SETUP 0x0020
90#define P30_CMD_BLOCK_ERASE_CONFIRM 0x00D0
93#define P30_CMD_PROGRAM_OR_ERASE_SUSPEND 0x00B0
94#define P30_CMD_SUSPEND_RESUME 0x00D0
97#define P30_CMD_LOCK_BLOCK_SETUP 0x0060
98#define P30_CMD_LOCK_BLOCK 0x0001
99#define P30_CMD_UNLOCK_BLOCK 0x00D0
100#define P30_CMD_LOCK_DOWN_BLOCK 0x002F
103#define P30_CMD_PROGRAM_PROTECTION_REGISTER_SETUP 0x00C0
106#define P30_CMD_READ_CONFIGURATION_REGISTER_SETUP 0x0060
107#define P30_CMD_READ_CONFIGURATION_REGISTER 0x0003
109#define NOR_FLASH_SIGNATURE SIGNATURE_32('n', 'o', 'r', '0')
110#define INSTANCE_FROM_FVB_THIS(a) CR(a, NOR_FLASH_INSTANCE, FvbProtocol, NOR_FLASH_SIGNATURE)
126 UINTN DeviceBaseAddress;
127 UINTN RegionBaseAddress;
143 IN UINT32 NumberOfBytes,
175FvbGetPhysicalAddress (
228FvbVirtualNotifyEvent (
238NorFlashWriteFullBlock (
241 IN UINT32 *DataBuffer,
242 IN UINT32 BlockSizeInWords
246NorFlashUnlockAndEraseSingleBlock (
252NorFlashCreateInstance (
258 IN BOOLEAN SupportFvb,
264NorFlashFvbInitialize (
272NorFlashWriteSingleBlock (
320NorFlashEraseSingleBlock (
326NorFlashUnlockSingleBlockIfNecessary (
332NorFlashWriteSingleWord (
340NorFlashVirtualNotifyEvent (
VOID InitializeFvAndVariableStoreHeaders(IN VOID *Ptr)
UINT32 EFI_FVB_ATTRIBUTES_2
UINT64 EFI_PHYSICAL_ADDRESS