]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / EmbeddedPkg / Library / DxeDtPlatformDtbLoaderLibDefault / DxeDtPlatformDtbLoaderLibDefault.c
CommitLineData
4c725c89
AB
1/** @file\r
2*\r
3* Copyright (c) 2017, Linaro, Ltd. All rights reserved.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#include <PiDxe.h>\r
16\r
17#include <Library/BaseLib.h>\r
18#include <Library/DxeServicesLib.h>\r
19#include <Library/MemoryAllocationLib.h>\r
20\r
21/**\r
22 Return a pool allocated copy of the DTB image that is appropriate for\r
23 booting the current platform via DT.\r
24\r
25 @param[out] Dtb Pointer to the DTB copy\r
26 @param[out] DtbSize Size of the DTB copy\r
27\r
28 @retval EFI_SUCCESS Operation completed successfully\r
29 @retval EFI_NOT_FOUND No suitable DTB image could be located\r
30 @retval EFI_OUT_OF_RESOURCES No pool memory available\r
31\r
32**/\r
33EFI_STATUS\r
34EFIAPI\r
35DtPlatformLoadDtb (\r
36 OUT VOID **Dtb,\r
37 OUT UINTN *DtbSize\r
38 )\r
39{\r
40 EFI_STATUS Status;\r
41 VOID *OrigDtb;\r
42 VOID *CopyDtb;\r
43 UINTN OrigDtbSize;\r
44\r
45 Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid,\r
46 EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize);\r
47 if (EFI_ERROR (Status)) {\r
48 return EFI_NOT_FOUND;\r
49 }\r
50\r
51 CopyDtb = AllocateCopyPool (OrigDtbSize, OrigDtb);\r
52 if (CopyDtb == NULL) {\r
53 return EFI_OUT_OF_RESOURCES;\r
54 }\r
55\r
56 *Dtb = CopyDtb;\r
57 *DtbSize = OrigDtbSize;\r
58\r
59 return EFI_SUCCESS;\r
60}\r