]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtFlashMapPei/FlashMap.c
Replace the FlashMapHob with PCD defined in FDF on Nt32 platform. Currently, the...
[mirror_edk2.git] / Nt32Pkg / WinNtFlashMapPei / FlashMap.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 FlashMap.c
15
16 Abstract:
17
18 PEIM to build GUIDed HOBs for platform specific flash map
19
20 --*/
21
22 //
23 // The package level header files this module uses
24 //
25 #include <PiPei.h>
26
27 #include <WinNtPeim.h>
28 //
29 // The protocols, PPI and GUID defintions for this module
30 //
31 #include <Ppi/NtFwh.h>
32
33 #include <Library/DebugLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/PeiServicesLib.h>
36
37 EFI_STATUS
38 EFIAPI
39 PeimInitializeFlashMap (
40 IN EFI_FFS_FILE_HEADER *FfsHeader,
41 IN EFI_PEI_SERVICES **PeiServices
42 )
43 /*++
44
45 Routine Description:
46 Build GUIDed HOBs for platform specific flash map
47
48 Arguments:
49 FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure.
50 PeiServices - General purpose services available to every PEIM.
51
52 Returns:
53 EFI_STATUS
54
55 --*/
56 // TODO: EFI_SUCCESS - add return value to function comment
57 {
58 EFI_STATUS Status;
59 NT_FWH_PPI *NtFwhPpi;
60 EFI_PHYSICAL_ADDRESS FdBase;
61 UINT64 FdSize;
62 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
63
64 DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n"));
65
66 __asm int 3;
67 //
68 // Get the Fwh Information PPI
69 //
70 Status = PeiServicesLocatePpi (
71 &gNtFwhPpiGuid, // GUID
72 0, // INSTANCE
73 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
74 &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 PcdSet32 (PcdFlashNvStorageVariableBase, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT32) FdBase);
90 PcdSet32 (PcdFlashNvStorageFtwWorkingBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase);
91 PcdSet32 (PcdFlashNvStorageFtwSpareBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase);
92
93 return EFI_SUCCESS;
94 }
95