VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c

Last change on this file was 105670, checked in by vboxsync, 5 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1/**@file
2
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 Module Name:
8
9 FvbInfo.c
10
11 Abstract:
12
13 Defines data structure that is the volume header found.These data is intent
14 to decouple FVB driver with FV header.
15
16**/
17
18//
19// The package level header files this module uses
20//
21#include <Pi/PiFirmwareVolume.h>
22
23//
24// The protocols, PPI and GUID definitions for this module
25//
26#include <Guid/SystemNvDataGuid.h>
27//
28// The Library classes this module consumes
29//
30#include <Library/BaseLib.h>
31#include <Library/PcdLib.h>
32
33typedef struct {
34 UINT64 FvLength;
35 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
36 //
37 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
38 //
39 EFI_FV_BLOCK_MAP_ENTRY End[1];
40} EFI_FVB_MEDIA_INFO;
41
42EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
43 //
44 // System NvStorage FVB
45 //
46 {
47 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
48 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
49 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
50 FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize),
51 {
52 {
53 0,
54 }, // ZeroVector[16]
55 EFI_SYSTEM_NV_DATA_FV_GUID,
56 FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
57 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
58 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
59 FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize),
60 EFI_FVH_SIGNATURE,
61 EFI_FVB2_MEMORY_MAPPED |
62 EFI_FVB2_READ_ENABLED_CAP |
63 EFI_FVB2_READ_STATUS |
64 EFI_FVB2_WRITE_ENABLED_CAP |
65 EFI_FVB2_WRITE_STATUS |
66 EFI_FVB2_ERASE_POLARITY |
67 EFI_FVB2_ALIGNMENT_16,
68 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
69 0, // CheckSum
70 0, // ExtHeaderOffset
71 {
72 0,
73 }, // Reserved[1]
74 2, // Revision
75 {
76 {
77 (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
78 FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
79 FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
80 FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) /
81 FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
82 FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
83 }
84 } // BlockMap[1]
85 },
86 {
87 {
88 0,
89 0
90 }
91 } // End[1]
92 }
93};
94
95EFI_STATUS
96GetFvbInfo (
97 IN UINT64 FvLength,
98 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
99 )
100{
101 STATIC BOOLEAN Checksummed = FALSE;
102 UINTN Index;
103
104 if (!Checksummed) {
105 for (Index = 0;
106 Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
107 Index += 1)
108 {
109 UINT16 Checksum;
110 mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0;
111 Checksum = CalculateCheckSum16 (
112 (UINT16 *)&mPlatformFvbMediaInfo[Index].FvbInfo,
113 mPlatformFvbMediaInfo[Index].FvbInfo.HeaderLength
114 );
115 mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = Checksum;
116 }
117
118 Checksummed = TRUE;
119 }
120
121 for (Index = 0;
122 Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
123 Index += 1)
124 {
125 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
126 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
127 return EFI_SUCCESS;
128 }
129 }
130
131 return EFI_NOT_FOUND;
132}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette