]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.h
Vlv2TbltDevicePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2TbltDevicePkg / Application / FirmwareUpdate / FirmwareUpdate.h
1 /** @file
2
3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 **/
10
11 #ifndef _FIRMWARE_UPDATE_H_
12 #define _FIRMWARE_UPDATE_H_
13
14 #include <Uefi.h>
15
16 #include <PiDxe.h>
17
18 #include <Guid/FileInfo.h>
19
20 #include <Protocol/FirmwareVolumeBlock.h>
21 #include <Protocol/LoadedImage.h>
22 #include <Protocol/SimpleFileSystem.h>
23 #include <Protocol/Spi.h>
24
25 #include <Library/BaseLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/CacheMaintenanceLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/FileHandleLib.h>
30 #include <Library/HiiLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/PcdLib.h>
33 #include <Library/PrintLib.h>
34 #include <Library/ShellLib.h>
35 #include <Library/UefiApplicationEntryPoint.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/UefiRuntimeServicesTableLib.h>
39
40 //
41 // Function Prototypes.
42 //
43 STATIC
44 EFI_STATUS
45 ReadFileData (
46 IN CHAR16 *FileName,
47 OUT UINT8 **Buffer,
48 OUT UINT32 *BufferSize
49 );
50
51 STATIC
52 EFI_STATUS
53 InternalEraseBlock (
54 IN EFI_PHYSICAL_ADDRESS BaseAddress
55 );
56
57 #if 0
58 STATIC
59 EFI_STATUS
60 InternalReadBlock (
61 IN EFI_PHYSICAL_ADDRESS BaseAddress,
62 OUT VOID *ReadBuffer
63 );
64 #endif
65
66 STATIC
67 EFI_STATUS
68 InternalCompareBlock (
69 IN EFI_PHYSICAL_ADDRESS BaseAddress,
70 IN UINT8 *Buffer
71 );
72
73 STATIC
74 EFI_STATUS
75 InternalWriteBlock (
76 IN EFI_PHYSICAL_ADDRESS BaseAddress,
77 IN UINT8 *Buffer,
78 IN UINT32 BufferSize
79 );
80
81 STATIC
82 VOID
83 PrintHelpInfo (
84 VOID
85 );
86
87 STATIC
88 EFI_STATUS
89 EFIAPI
90 SpiFlashRead (
91 IN UINTN Address,
92 IN OUT UINT32 *NumBytes,
93 OUT UINT8 *Buffer
94 );
95
96 STATIC
97 EFI_STATUS
98 EFIAPI
99 SpiFlashWrite (
100 IN UINTN Address,
101 IN OUT UINT32 *NumBytes,
102 IN UINT8 *Buffer
103 );
104
105 STATIC
106 EFI_STATUS
107 EFIAPI
108 SpiFlashBlockErase (
109 IN UINTN Address,
110 IN UINTN *NumBytes
111 );
112
113 STATIC
114 EFI_STATUS
115 EFIAPI
116 ConvertMac (
117 CHAR16 *Str
118 );
119
120 EFI_STATUS
121 InitializeFVUPDATE (
122 IN EFI_HANDLE ImageHandle,
123 IN EFI_SYSTEM_TABLE *SystemTable
124 );
125
126 //
127 // Flash specific definitions.
128 // - Should we use a PCD for this information?
129 //
130 #define BLOCK_SIZE SIZE_4KB
131
132 //
133 // Flash region layout and update information.
134 //
135 typedef struct {
136 EFI_PHYSICAL_ADDRESS Base;
137 UINTN Size;
138 BOOLEAN Update;
139 } FV_REGION_INFO;
140
141 //
142 // MAC Address information.
143 //
144 #define MAC_ADD_STR_LEN 12
145 #define MAC_ADD_STR_SIZE (MAC_ADD_STR_LEN + 1)
146 #define MAC_ADD_BYTE_COUNT 6
147 #define MAC_ADD_TMP_STR_LEN 2
148 #define MAC_ADD_TMP_STR_SIZE (MAC_ADD_TMP_STR_LEN + 1)
149
150 //
151 // Command Line Data.
152 //
153 #define INPUT_STRING_LEN 255
154 #define INPUT_STRING_SIZE (INPUT_STRING_LEN + 1)
155 typedef struct {
156 BOOLEAN UpdateFromFile;
157 CHAR16 FileName[INPUT_STRING_SIZE];
158 BOOLEAN UpdateMac;
159 UINT8 MacValue[MAC_ADD_BYTE_COUNT];
160 BOOLEAN FullFlashUpdate;
161 } FV_INPUT_DATA;
162
163 //
164 // Prefix Opcode Index on the host SPI controller.
165 //
166 typedef enum {
167 SPI_WREN, // Prefix Opcode 0: Write Enable.
168 SPI_EWSR, // Prefix Opcode 1: Enable Write Status Register.
169 } PREFIX_OPCODE_INDEX;
170
171 //
172 // Opcode Menu Index on the host SPI controller.
173 //
174 typedef enum {
175 SPI_READ_ID, // Opcode 0: READ ID, Read cycle with address.
176 SPI_READ, // Opcode 1: READ, Read cycle with address.
177 SPI_RDSR, // Opcode 2: Read Status Register, No address.
178 SPI_WRDI_SFDP, // Opcode 3: Write Disable or Discovery Parameters, No address.
179 SPI_SERASE, // Opcode 4: Sector Erase (4KB), Write cycle with address.
180 SPI_BERASE, // Opcode 5: Block Erase (32KB), Write cycle with address.
181 SPI_PROG, // Opcode 6: Byte Program, Write cycle with address.
182 SPI_WRSR, // Opcode 7: Write Status Register, No address.
183 } SPI_OPCODE_INDEX;
184
185 #endif