Add the following Pcds declaration in EdkModulePkg.spd file. EdkModulePkg PeiVariable...
[mirror_edk2.git] / EdkNt32Pkg / Library / EdkNt32PeiPeCoffGetEntryPointLib / PeCoffGetEntryPoint.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 PeCoffGetEntryPoint.c
15
16 Abstract:
17
18 Tiano PE/COFF loader
19
20 Revision History
21
22 --*/
23
24
25 RETURN_STATUS
26 EFIAPI
27 PeCoffLoaderGetEntryPoint (
28 IN VOID *Pe32Data,
29 IN OUT VOID **EntryPoint
30 )
31 /*++
32
33 Routine Description:
34
35 Loads a PE/COFF image into memory
36
37 Arguments:
38
39 Pe32Data - Pointer to a PE/COFF Image
40
41 EntryPoint - Pointer to the entry point of the PE/COFF image
42
43 Returns:
44
45 EFI_SUCCESS if the EntryPoint was returned
46 EFI_INVALID_PARAMETER if the EntryPoint could not be found from Pe32Data
47
48 --*/
49 {
50 EFI_STATUS Status;
51 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
52 NT_PEI_LOAD_FILE_PPI *PeiNtService;
53 EFI_PHYSICAL_ADDRESS ImageAddress;
54 UINT64 ImageSize;
55 EFI_PHYSICAL_ADDRESS ImageEntryPoint;
56
57 Status = PeiServicesLocatePpi (
58 &gNtPeiLoadFilePpiGuid,
59 0,
60 &PpiDescriptor,
61 &PeiNtService
62 );
63 if (EFI_ERROR (Status)) {
64 return Status;
65 }
66
67 Status = PeiNtService->PeiLoadFileService (
68 Pe32Data,
69 &ImageAddress,
70 &ImageSize,
71 &ImageEntryPoint
72 );
73 *EntryPoint = (VOID*)(UINTN)ImageEntryPoint;
74 return Status;
75 }