Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 1 | /**@file
|
| 2 |
|
| 3 | Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
| 4 | This program and the accompanying materials
|
| 5 | are licensed and made available under the terms and conditions of the BSD License
|
| 6 | which accompanies this distribution. The full text of the license may be found at
|
| 7 | http://opensource.org/licenses/bsd-license.php
|
| 8 |
|
| 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 11 |
|
| 12 | Module Name:
|
| 13 |
|
| 14 | FvbInfo.c
|
| 15 |
|
| 16 | Abstract:
|
| 17 |
|
| 18 | Defines data structure that is the volume header found.These data is intent
|
| 19 | to decouple FVB driver with FV header.
|
| 20 |
|
| 21 | **/
|
| 22 |
|
| 23 | //
|
| 24 | // The package level header files this module uses
|
| 25 | //
|
| 26 | #include <PiDxe.h>
|
| 27 | #include <WinNtDxe.h>
|
| 28 | //
|
| 29 | // The protocols, PPI and GUID defintions for this module
|
| 30 | //
|
| 31 | #include <Guid/EventGroup.h>
|
| 32 | #include <Guid/FirmwareFileSystem2.h>
|
| 33 | #include <Guid/SystemNvDataGuid.h>
|
| 34 | #include <Protocol/FirmwareVolumeBlock.h>
|
| 35 | #include <Protocol/DevicePath.h>
|
| 36 | //
|
| 37 | // The Library classes this module consumes
|
| 38 | //
|
| 39 | #include <Library/UefiLib.h>
|
| 40 | #include <Library/UefiDriverEntryPoint.h>
|
| 41 | #include <Library/BaseLib.h>
|
| 42 | #include <Library/DxeServicesTableLib.h>
|
| 43 | #include <Library/UefiRuntimeLib.h>
|
| 44 | #include <Library/DebugLib.h>
|
| 45 | #include <Library/HobLib.h>
|
| 46 | #include <Library/BaseMemoryLib.h>
|
| 47 | #include <Library/MemoryAllocationLib.h>
|
| 48 | #include <Library/UefiBootServicesTableLib.h>
|
| 49 | #include <Library/PcdLib.h>
|
| 50 |
|
| 51 | typedef struct {
|
| 52 | UINT64 FvLength;
|
| 53 | EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
|
| 54 | //
|
| 55 | // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
|
| 56 | //
|
| 57 | EFI_FV_BLOCK_MAP_ENTRY End[1];
|
| 58 | } EFI_FVB_MEDIA_INFO;
|
| 59 |
|
| 60 | EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
|
| 61 | //
|
| 62 | // Recovery BOIS FVB
|
| 63 | //
|
| 64 | {
|
| 65 | FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
|
| 66 | {
|
| 67 | {
|
| 68 | 0,
|
| 69 | }, // ZeroVector[16]
|
| 70 | EFI_FIRMWARE_FILE_SYSTEM2_GUID,
|
| 71 | FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),
|
| 72 | EFI_FVH_SIGNATURE,
|
| 73 | EFI_FVB2_MEMORY_MAPPED |
|
| 74 | EFI_FVB2_READ_ENABLED_CAP |
|
| 75 | EFI_FVB2_READ_STATUS |
|
| 76 | EFI_FVB2_WRITE_ENABLED_CAP |
|
| 77 | EFI_FVB2_WRITE_STATUS |
|
| 78 | EFI_FVB2_ERASE_POLARITY |
|
| 79 | EFI_FVB2_ALIGNMENT_16,
|
| 80 | sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
| 81 | 0xE947, // CheckSum
|
| 82 | 0, // ExtHeaderOffset
|
| 83 | {
|
| 84 | 0,
|
| 85 | }, // Reserved[1]
|
| 86 | 2, // Revision
|
| 87 | {
|
| 88 | FixedPcdGet32 (PcdWinNtFlashFvRecoverySize)/FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
|
| 89 | FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
|
| 90 | }
|
| 91 | },
|
| 92 | {
|
| 93 | 0,
|
| 94 | 0
|
| 95 | }
|
| 96 | },
|
| 97 | //
|
| 98 | // Systen NvStorage FVB
|
| 99 | //
|
| 100 | {
|
| 101 | FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
|
| 102 | FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
|
| 103 | FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
|
| 104 | FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
|
| 105 | {
|
| 106 | {
|
| 107 | 0,
|
| 108 | }, // ZeroVector[16]
|
| 109 | EFI_SYSTEM_NV_DATA_FV_GUID,
|
| 110 | FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
|
| 111 | FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
|
| 112 | FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
|
| 113 | FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),
|
| 114 | EFI_FVH_SIGNATURE,
|
| 115 | EFI_FVB2_MEMORY_MAPPED |
|
| 116 | EFI_FVB2_READ_ENABLED_CAP |
|
| 117 | EFI_FVB2_READ_STATUS |
|
| 118 | EFI_FVB2_WRITE_ENABLED_CAP |
|
| 119 | EFI_FVB2_WRITE_STATUS |
|
| 120 | EFI_FVB2_ERASE_POLARITY |
|
| 121 | EFI_FVB2_ALIGNMENT_16,
|
| 122 | sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
| 123 | 0xFBFF, // CheckSum
|
| 124 | 0, // ExtHeaderOffset
|
| 125 | {
|
| 126 | 0,
|
| 127 | }, // Reserved[1]
|
| 128 | 2, // Revision
|
| 129 | {
|
| 130 | (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
|
| 131 | FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
|
| 132 | FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
|
| 133 | FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
|
| 134 | FixedPcdGet32 (PcdWinNtFirmwareBlockSize),
|
| 135 | }
|
| 136 | },
|
| 137 | {
|
| 138 | 0,
|
| 139 | 0
|
| 140 | }
|
| 141 | }
|
| 142 | };
|
| 143 |
|
| 144 | EFI_STATUS
|
| 145 | GetFvbInfo (
|
| 146 | IN UINT64 FvLength,
|
| 147 | OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
| 148 | )
|
| 149 | {
|
| 150 | UINTN Index;
|
| 151 |
|
| 152 | for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
|
| 153 | if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
|
| 154 | *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
|
| 155 | return EFI_SUCCESS;
|
| 156 | }
|
| 157 | }
|
| 158 |
|
| 159 | return EFI_NOT_FOUND;
|
| 160 | }
|