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