]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/FvbRuntimeDxe/FvbService.h
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / FvbRuntimeDxe / FvbService.h
1 /** @file
2 The header file for Firmware volume block driver.
3
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14
15 **/
16
17 #ifndef _FW_BLOCK_SERVICE_H
18 #define _FW_BLOCK_SERVICE_H
19
20 #include <Guid/EventGroup.h>
21 #include <Guid/FirmwareFileSystem2.h>
22 #include <Guid/SystemNvDataGuid.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/FirmwareVolumeBlock.h>
25
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/IoLib.h>
33 #include <Library/CacheMaintenanceLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/PcdLib.h>
36 #include <Library/FlashDeviceLib.h>
37 #include <Library/DevicePathLib.h>
38
39 //
40 // Define two helper macro to extract the Capability field or Status field in FVB
41 // bit fields.
42 //
43 #define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \
44 EFI_FVB2_READ_ENABLED_CAP | \
45 EFI_FVB2_WRITE_DISABLED_CAP | \
46 EFI_FVB2_WRITE_ENABLED_CAP | \
47 EFI_FVB2_LOCK_CAP \
48 )
49
50 #define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
51
52
53 typedef struct {
54 UINTN FvBase;
55 UINTN NumOfBlocks;
56 //
57 // Note!!!: VolumeHeader must be the last element
58 // of the structure.
59 //
60 EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
61 } EFI_FW_VOL_INSTANCE;
62
63 typedef struct {
64 EFI_FW_VOL_INSTANCE *FvInstance;
65 UINT32 NumFv;
66 } FWB_GLOBAL;
67
68 //
69 // Fvb Protocol instance data.
70 //
71 #define FVB_DEVICE_FROM_THIS(a) CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
72 #define FVB_EXTEND_DEVICE_FROM_THIS(a) CR(a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)
73 #define FVB_DEVICE_SIGNATURE SIGNATURE_32('F','V','B','C')
74
75 typedef struct {
76 MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
77 EFI_DEVICE_PATH_PROTOCOL EndDevPath;
78 } FV_PIWG_DEVICE_PATH;
79
80 typedef struct {
81 MEMMAP_DEVICE_PATH MemMapDevPath;
82 EFI_DEVICE_PATH_PROTOCOL EndDevPath;
83 } FV_MEMMAP_DEVICE_PATH;
84
85 typedef struct {
86 UINT32 Signature;
87 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
88 UINTN Instance;
89 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
90 } EFI_FW_VOL_BLOCK_DEVICE;
91
92 EFI_STATUS
93 GetFvbInfo (
94 IN EFI_PHYSICAL_ADDRESS FvBaseAddress,
95 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
96 );
97
98 //
99 // Protocol APIs
100 //
101 EFI_STATUS
102 EFIAPI
103 FvbProtocolGetAttributes (
104 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
105 OUT EFI_FVB_ATTRIBUTES_2 *Attributes
106 );
107
108 EFI_STATUS
109 EFIAPI
110 FvbProtocolSetAttributes (
111 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
112 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
113 );
114
115 EFI_STATUS
116 EFIAPI
117 FvbProtocolGetPhysicalAddress (
118 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
119 OUT EFI_PHYSICAL_ADDRESS *Address
120 );
121
122 EFI_STATUS
123 EFIAPI
124 FvbProtocolGetBlockSize (
125 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
126 IN EFI_LBA Lba,
127 OUT UINTN *BlockSize,
128 OUT UINTN *NumOfBlocks
129 );
130
131 EFI_STATUS
132 EFIAPI
133 FvbProtocolRead (
134 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
135 IN EFI_LBA Lba,
136 IN UINTN Offset,
137 IN OUT UINTN *NumBytes,
138 OUT UINT8 *Buffer
139 );
140
141 EFI_STATUS
142 EFIAPI
143 FvbProtocolWrite (
144 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
145 IN EFI_LBA Lba,
146 IN UINTN Offset,
147 IN OUT UINTN *NumBytes,
148 IN UINT8 *Buffer
149 );
150
151 EFI_STATUS
152 EFIAPI
153 FvbProtocolEraseBlocks (
154 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
155 ...
156 );
157
158 EFI_FW_VOL_INSTANCE *
159 GetFvbInstance (
160 IN UINTN Instance
161 );
162
163 BOOLEAN
164 IsFvHeaderValid (
165 IN EFI_PHYSICAL_ADDRESS FvBase,
166 IN CONST EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
167 );
168
169 VOID
170 InstallFvbProtocol (
171 IN EFI_FW_VOL_INSTANCE *FwhInstance,
172 IN UINTN InstanceNum
173 );
174
175 EFI_STATUS
176 FvbInitialize (
177 VOID
178 );
179
180 extern FWB_GLOBAL mFvbModuleGlobal;
181 extern EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate;
182 extern FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate;
183 extern FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate;
184 extern UINT32 mPlatformFvBaseAddress[3];
185
186 #endif
187