]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/UnixFlashMapPei/FlashMap.c
Port UnixPkg to also support X64. Currently only supports Unix x86_64 ABI. In the...
[mirror_edk2.git] / UnixPkg / UnixFlashMapPei / FlashMap.c
1 /*++
2
3 Copyright (c) 2006 - 2010, 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 FlashMap.c
15
16 Abstract:
17
18 PEIM to build GUIDed HOBs for platform specific flash map
19
20 --*/
21
22
23 #include "PiPei.h"
24
25 #include <Guid/SystemNvDataGuid.h>
26 #include <Ppi/UnixFwh.h>
27 #include <Protocol/FirmwareVolumeBlock.h>
28
29 #include <Library/DebugLib.h>
30 #include <Library/PeimEntryPoint.h>
31 #include <Library/HobLib.h>
32 #include <Library/PeiServicesLib.h>
33 #include <Library/PeiServicesTablePointerLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/PcdLib.h>
36
37 EFI_STATUS
38 EFIAPI
39 PeimInitializeFlashMap (
40 IN EFI_PEI_FILE_HANDLE FileHandle,
41 IN CONST 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 UNIX_FWH_PPI *UnixFwhPpi;
60 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
61 EFI_PHYSICAL_ADDRESS FdBase;
62 EFI_PHYSICAL_ADDRESS FdFixUp;
63 UINT64 FdSize;
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 &gUnixFwhPpiGuid, // GUID
72 0, // INSTANCE
73 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
74 (VOID **)&UnixFwhPpi // PPI
75 );
76 ASSERT_EFI_ERROR (Status);
77
78 //
79 // Assume that FD0 contains the Flash map.
80 //
81 Status = UnixFwhPpi->UnixFwh (0, &FdBase, &FdSize, &FdFixUp);
82 if (EFI_ERROR (Status)) {
83 return Status;
84 }
85
86 PcdSet64 (PcdFlashNvStorageVariableBase64, PcdGet64 (PcdUnixFlashNvStorageVariableBase) + FdFixUp);
87 PcdSet64 (PcdFlashNvStorageFtwWorkingBase64, PcdGet64 (PcdUnixFlashNvStorageFtwWorkingBase) + FdFixUp);
88 PcdSet64 (PcdFlashNvStorageFtwSpareBase64, PcdGet64 (PcdUnixFlashNvStorageFtwSpareBase) + FdFixUp);
89
90 return EFI_SUCCESS;
91 }