Add some definitions for efi event in Uefi/UefiSpec.h to follow spec.
[mirror_edk2.git] / EdkUnixPkg / RuntimeDxe / FvbServices / FvbInfo.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. 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 #include "FlashLayout.h"
24
25 #define FIRMWARE_BLOCK_SIZE 0x10000
26
27 typedef struct {
28 UINT64 FvLength;
29 EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
30 //
31 // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
32 //
33 EFI_FV_BLOCK_MAP_ENTRY End[1];
34 } EFI_FVB_MEDIA_INFO;
35
36 #define FVB_MEDIA_BLOCK_SIZE FIRMWARE_BLOCK_SIZE
37 #define RECOVERY_BOIS_BLOCK_NUM FIRMWARE_BLOCK_NUMBER
38 #define SYSTEM_NV_BLOCK_NUM 2
39
40 EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
41 //
42 // Recovery BOIS FVB
43 //
44 {
45 EFI_WINNT_FIRMWARE_LENGTH,
46 {
47 {
48 0,
49 }, // ZeroVector[16]
50 EFI_FIRMWARE_FILE_SYSTEM_GUID,
51 FVB_MEDIA_BLOCK_SIZE * RECOVERY_BOIS_BLOCK_NUM,
52 EFI_FVH_SIGNATURE,
53 EFI_FVB_READ_ENABLED_CAP |
54 EFI_FVB_READ_STATUS |
55 EFI_FVB_WRITE_ENABLED_CAP |
56 EFI_FVB_WRITE_STATUS |
57 EFI_FVB_ERASE_POLARITY,
58 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
59 0, // CheckSum
60 {
61 0,
62 }, // Reserved[3]
63 1, // Revision
64 {
65 {
66 RECOVERY_BOIS_BLOCK_NUM,
67 FVB_MEDIA_BLOCK_SIZE
68 }
69 }
70 },
71 {
72 {
73 0,
74 0
75 }
76 }
77 },
78 //
79 // Systen NvStorage FVB
80 //
81 {
82 EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,
83 {
84 {
85 0,
86 }, // ZeroVector[16]
87 EFI_SYSTEM_NV_DATA_HOB_GUID,
88 FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,
89 EFI_FVH_SIGNATURE,
90 EFI_FVB_READ_ENABLED_CAP |
91 EFI_FVB_READ_STATUS |
92 EFI_FVB_WRITE_ENABLED_CAP |
93 EFI_FVB_WRITE_STATUS |
94 EFI_FVB_ERASE_POLARITY,
95 sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
96 0, // CheckSum
97 {
98 0,
99 }, // Reserved[3]
100 1, // Revision
101 {
102 {
103 SYSTEM_NV_BLOCK_NUM,
104 FVB_MEDIA_BLOCK_SIZE
105 }
106 }
107 },
108 {
109 {
110 0,
111 0
112 }
113 }
114 }
115 };
116
117 EFI_STATUS
118 GetFvbInfo (
119 IN UINT64 FvLength,
120 OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
121 )
122 {
123 UINTN Index;
124
125 for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
126 if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
127 *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
128 return EFI_SUCCESS;
129 }
130 }
131
132 return EFI_NOT_FOUND;
133 }