]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/UnixFlashMapPei/FlashMap.c
Added support for Xcode on Snow Leopard. Upaded with bug fixes for Snow Leopard.
[mirror_edk2.git] / UnixPkg / UnixFlashMapPei / FlashMap.c
1 /*++
2
3 Copyright (c) 2006 - 2008, 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 #include "PiPei.h"
24
25 #include <Guid/SystemNvDataGuid.h>
26 #include <Guid/FirmwareFileSystem.h>
27 #include <Ppi/UnixFwh.h>
28 #include <Protocol/FirmwareVolumeBlock.h>
29
30 #include <Library/DebugLib.h>
31 #include <Library/PeimEntryPoint.h>
32 #include <Library/HobLib.h>
33 #include <Library/PeiServicesLib.h>
34 #include <Library/PeiServicesTablePointerLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/PcdLib.h>
37
38 EFI_STATUS
39 EFIAPI
40 PeimInitializeFlashMap (
41 IN EFI_PEI_FILE_HANDLE FileHandle,
42 IN CONST 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 UNIX_FWH_PPI *UnixFwhPpi;
61 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
62 EFI_PHYSICAL_ADDRESS FdBase;
63 EFI_PHYSICAL_ADDRESS FdFixUp;
64 UINT64 FdSize;
65
66 DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n"));
67
68 //
69 // Get the Fwh Information PPI
70 //
71 Status = PeiServicesLocatePpi (
72 &gUnixFwhPpiGuid, // GUID
73 0, // INSTANCE
74 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
75 (VOID **)&UnixFwhPpi // PPI
76 );
77 ASSERT_EFI_ERROR (Status);
78
79 //
80 // Assume that FD0 contains the Flash map.
81 //
82 Status = UnixFwhPpi->UnixFwh (0, &FdBase, &FdSize, &FdFixUp);
83 if (EFI_ERROR (Status)) {
84 return Status;
85 }
86
87 PcdSet32 (PcdFlashNvStorageVariableBase, PcdGet32 (PcdUnixFlashNvStorageVariableBase) + (UINT32)FdFixUp);
88 PcdSet32 (PcdFlashNvStorageFtwWorkingBase, PcdGet32 (PcdUnixFlashNvStorageFtwWorkingBase) + (UINT32)FdFixUp);
89 PcdSet32 (PcdFlashNvStorageFtwSpareBase, PcdGet32 (PcdUnixFlashNvStorageFtwSpareBase) + (UINT32)FdFixUp);
90
91 return EFI_SUCCESS;
92 }