summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2018-03-28 02:27:30 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-03-28 02:27:30 +0000
commit3572a2ed37e1174ba2b2a3418483c113f060da00 (patch)
treec4edf9d97d054e74e0bd33791adc4ea51603e445 /EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
parent4f2fa8444202eddc6ab0a5aa0390d189b0e2b558 (diff)
parent08244e33149eacfbeee382aa02a17940fc5abfce (diff)
downloaddevice_linaro_bootloader_edk2-3572a2ed37e1174ba2b2a3418483c113f060da00.tar.gz
device_linaro_bootloader_edk2-3572a2ed37e1174ba2b2a3418483c113f060da00.tar.bz2
device_linaro_bootloader_edk2-3572a2ed37e1174ba2b2a3418483c113f060da00.zip
Merge remote-tracking branch 'aosp/upstream-hikey-aosp' into edk am: 27fa02b096 am: a8fa7d906e
am: 08244e3314 Change-Id: Icb98a90530a21e638de410c996bf01c7ffadb80d
Diffstat (limited to 'EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c')
-rw-r--r--EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c b/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
new file mode 100644
index 000000000..313d0b104
--- /dev/null
+++ b/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
@@ -0,0 +1,60 @@
+/** @file
+*
+* Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include <PiDxe.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+/**
+ Return a pool allocated copy of the DTB image that is appropriate for
+ booting the current platform via DT.
+
+ @param[out] Dtb Pointer to the DTB copy
+ @param[out] DtbSize Size of the DTB copy
+
+ @retval EFI_SUCCESS Operation completed successfully
+ @retval EFI_NOT_FOUND No suitable DTB image could be located
+ @retval EFI_OUT_OF_RESOURCES No pool memory available
+
+**/
+EFI_STATUS
+EFIAPI
+DtPlatformLoadDtb (
+ OUT VOID **Dtb,
+ OUT UINTN *DtbSize
+ )
+{
+ EFI_STATUS Status;
+ VOID *OrigDtb;
+ VOID *CopyDtb;
+ UINTN OrigDtbSize;
+
+ Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid,
+ EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ CopyDtb = AllocateCopyPool (OrigDtbSize, OrigDtb);
+ if (CopyDtb == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ *Dtb = CopyDtb;
+ *DtbSize = OrigDtbSize;
+
+ return EFI_SUCCESS;
+}