]> git.proxmox.com Git - mirror_edk2.git/blame - EdkNt32Pkg/Library/EdkNt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
Initial import.
[mirror_edk2.git] / EdkNt32Pkg / Library / EdkNt32PeiPeCoffGetEntryPointLib / PeCoffGetEntryPoint.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 PeCoffGetEntryPoint.c\r
15\r
16Abstract:\r
17\r
18 Tiano PE/COFF loader\r
19\r
20Revision History\r
21\r
22--*/\r
23\r
24\r
25RETURN_STATUS\r
26EFIAPI\r
27PeCoffLoaderGetEntryPoint (\r
28 IN VOID *Pe32Data,\r
29 IN OUT VOID **EntryPoint\r
30 )\r
31/*++\r
32\r
33Routine Description:\r
34\r
35 Loads a PE/COFF image into memory\r
36\r
37Arguments:\r
38\r
39 Pe32Data - Pointer to a PE/COFF Image\r
40\r
41 EntryPoint - Pointer to the entry point of the PE/COFF image\r
42\r
43Returns:\r
44\r
45 EFI_SUCCESS if the EntryPoint was returned\r
46 EFI_INVALID_PARAMETER if the EntryPoint could not be found from Pe32Data\r
47\r
48--*/\r
49{\r
50 EFI_STATUS Status;\r
51 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
52 NT_PEI_LOAD_FILE_PPI *PeiNtService;\r
53 EFI_PHYSICAL_ADDRESS ImageAddress;\r
54 UINT64 ImageSize;\r
55 EFI_PHYSICAL_ADDRESS ImageEntryPoint;\r
56\r
57 Status = PeiCoreLocatePpi (\r
58 &gNtPeiLoadFilePpiGuid,\r
59 0,\r
60 &PpiDescriptor,\r
61 &PeiNtService\r
62 );\r
63 if (EFI_ERROR (Status)) {\r
64 return Status;\r
65 }\r
66\r
67 Status = PeiNtService->PeiLoadFileService (\r
68 Pe32Data,\r
69 &ImageAddress,\r
70 &ImageSize,\r
71 &ImageEntryPoint\r
72 );\r
73 *EntryPoint = (VOID*)(UINTN)ImageEntryPoint;\r
74 return Status;\r
75}