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