• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**@file
2 
3 Copyright (c) 2006, 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 // 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
PeimInitializeFlashMap(IN EFI_FFS_FILE_HEADER * FfsHeader,IN EFI_PEI_SERVICES ** PeiServices)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   //
67   // Get the Fwh Information PPI
68   //
69   Status = PeiServicesLocatePpi (
70             &gNtFwhPpiGuid, // GUID
71             0,              // INSTANCE
72             &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
73             (VOID**)&NtFwhPpi       // PPI
74             );
75   ASSERT_EFI_ERROR (Status);
76 
77   //
78   // Assume that FD0 contains the Flash map.
79   //
80   Status = NtFwhPpi->NtFwh (0, &FdBase, &FdSize);
81   if (EFI_ERROR (Status)) {
82     return Status;
83   }
84 
85   //
86   // Relocate the base of FV region
87   //
88   PcdSet32 (PcdFlashNvStorageVariableBase, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT32) FdBase);
89   PcdSet32 (PcdFlashNvStorageFtwWorkingBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase);
90   PcdSet32 (PcdFlashNvStorageFtwSpareBase, PcdGet32 (PcdWinNtFlashNvStorageFtwSpareBase) + (UINT32) FdBase);
91 
92   return EFI_SUCCESS;
93 }
94 
95