]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtFlashMapPei/FlashMap.c
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmiCr3" with PatchInstructionX86()
[mirror_edk2.git] / Nt32Pkg / WinNtFlashMapPei / FlashMap.c
1 /**@file
2
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name:
14
15 FlashMap.c
16
17 Abstract:
18
19 PEIM to build GUIDed HOBs for platform specific flash map
20
21 **/
22
23 //
24 // The package level header files this module uses
25 //
26 #include <PiPei.h>
27
28 #include <WinNtPeim.h>
29 //
30 // The protocols, PPI and GUID defintions for this module
31 //
32 #include <Ppi/NtFwh.h>
33
34 #include <Library/DebugLib.h>
35 #include <Library/PcdLib.h>
36 #include <Library/PeiServicesLib.h>
37
38 EFI_STATUS
39 EFIAPI
40 PeimInitializeFlashMap (
41 IN EFI_FFS_FILE_HEADER *FfsHeader,
42 IN EFI_PEI_SERVICES **PeiServices
43 )
44 /*++
45
46 Routine Description:
47 Build GUIDed HOBs for platform specific flash map
48
49 Arguments:
50 FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure.
51 PeiServices - General purpose services available to every PEIM.
52
53 Returns:
54 EFI_STATUS
55
56 --*/
57 // TODO: EFI_SUCCESS - add return value to function comment
58 {
59 EFI_STATUS Status;
60 NT_FWH_PPI *NtFwhPpi;
61 EFI_PHYSICAL_ADDRESS FdBase;
62 UINT64 FdSize;
63 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
64
65 DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n"));
66
67 //
68 // Get the Fwh Information PPI
69 //
70 Status = PeiServicesLocatePpi (
71 &gNtFwhPpiGuid, // GUID
72 0, // INSTANCE
73 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
74 (VOID**)&NtFwhPpi // PPI
75 );
76 ASSERT_EFI_ERROR (Status);
77
78 //
79 // Assume that FD0 contains the Flash map.
80 //
81 Status = NtFwhPpi->NtFwh (0, &FdBase, &FdSize);
82 if (EFI_ERROR (Status)) {
83 return Status;
84 }
85
86 //
87 // Relocate the base of FV region
88 //
89 if (FdBase >= BASE_4GB) {
90 PcdSet64 (PcdFlashNvStorageVariableBase64, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT64) FdBase);
91 PcdSet64 (PcdFlashNvStorageFtwWorkingBase64, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT64) FdBase);
92 PcdSet64 (PcdFlashNvStorageFtwSpareBase64, PcdGet32 (PcdWinNtFlashNvStorageFtwSpareBase) + (UINT64) FdBase);
93 } else {
94 PcdSet32 (PcdFlashNvStorageVariableBase, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT32) FdBase);
95 PcdSet32 (PcdFlashNvStorageFtwWorkingBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase);
96 PcdSet32 (PcdFlashNvStorageFtwSpareBase, PcdGet32 (PcdWinNtFlashNvStorageFtwSpareBase) + (UINT32) FdBase);
97 }
98
99 return EFI_SUCCESS;
100 }
101