]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
EmbeddedPkg: Apply uncrustify changes
[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
878b807a 5* SPDX-License-Identifier: BSD-2-Clause-Patent\r
4c725c89
AB
6*\r
7**/\r
8\r
9#include <PiDxe.h>\r
10\r
11#include <Library/BaseLib.h>\r
12#include <Library/DxeServicesLib.h>\r
13#include <Library/MemoryAllocationLib.h>\r
14\r
15/**\r
16 Return a pool allocated copy of the DTB image that is appropriate for\r
17 booting the current platform via DT.\r
18\r
19 @param[out] Dtb Pointer to the DTB copy\r
20 @param[out] DtbSize Size of the DTB copy\r
21\r
22 @retval EFI_SUCCESS Operation completed successfully\r
23 @retval EFI_NOT_FOUND No suitable DTB image could be located\r
24 @retval EFI_OUT_OF_RESOURCES No pool memory available\r
25\r
26**/\r
27EFI_STATUS\r
28EFIAPI\r
29DtPlatformLoadDtb (\r
e7108d0e
MK
30 OUT VOID **Dtb,\r
31 OUT UINTN *DtbSize\r
4c725c89
AB
32 )\r
33{\r
e7108d0e
MK
34 EFI_STATUS Status;\r
35 VOID *OrigDtb;\r
36 VOID *CopyDtb;\r
37 UINTN OrigDtbSize;\r
38\r
39 Status = GetSectionFromAnyFv (\r
40 &gDtPlatformDefaultDtbFileGuid,\r
41 EFI_SECTION_RAW,\r
42 0,\r
43 &OrigDtb,\r
44 &OrigDtbSize\r
45 );\r
4c725c89
AB
46 if (EFI_ERROR (Status)) {\r
47 return EFI_NOT_FOUND;\r
48 }\r
49\r
50 CopyDtb = AllocateCopyPool (OrigDtbSize, OrigDtb);\r
51 if (CopyDtb == NULL) {\r
52 return EFI_OUT_OF_RESOURCES;\r
53 }\r
54\r
e7108d0e 55 *Dtb = CopyDtb;\r
4c725c89
AB
56 *DtbSize = OrigDtbSize;\r
57\r
58 return EFI_SUCCESS;\r
59}\r