From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, lersek@redhat.com
Cc: leif.lindholm@linaro.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v2 2/3] EmbeddedPkg: add base DtPlatformDtbLoaderLib implementation
Date: Fri, 31 Mar 2017 11:56:06 +0100 [thread overview]
Message-ID: <20170331105607.3477-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20170331105607.3477-1-ard.biesheuvel@linaro.org>
Introduce an implementation of the new DtPlatformDtbLoaderLib library
class that simply retrieves the first raw section for an FV file named
gDtPlatformDefaultDtbFileGuid.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
EmbeddedPkg/EmbeddedPkg.dsc | 4 ++
EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.c | 60 ++++++++++++++++++++
EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf | 36 ++++++++++++
3 files changed, 100 insertions(+)
diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
index ba4f1ea0f004..0d5db68631bb 100644
--- a/EmbeddedPkg/EmbeddedPkg.dsc
+++ b/EmbeddedPkg/EmbeddedPkg.dsc
@@ -109,6 +109,9 @@ [LibraryClasses.common]
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+ DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf
+
[LibraryClasses.common.DXE_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
@@ -247,6 +250,7 @@ [Components.common]
EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf
EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf
+ EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf
EmbeddedPkg/Ebl/Ebl.inf
#### EmbeddedPkg/EblExternCmd/EblExternCmd.inf
diff --git a/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.c b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.c
new file mode 100644
index 000000000000..313d0b104681
--- /dev/null
+++ b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.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;
+}
diff --git a/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf
new file mode 100644
index 000000000000..7c337aace3ef
--- /dev/null
+++ b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf
@@ -0,0 +1,36 @@
+/** @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.
+*
+**/
+
+[Defines]
+ INF_VERSION = 0x00010019
+ BASE_NAME = DtPlatformDtbLoaderBaseLib
+ FILE_GUID = 419a1910-70da-4c99-8696-ba81a57be508
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = DtPlatformDtbLoaderLib|DXE_DRIVER
+
+[Sources]
+ DtPlatformDtbLoaderBaseLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DxeServicesLib
+ MemoryAllocationLib
+
+[Guids]
+ gDtPlatformDefaultDtbFileGuid
--
2.9.3
next prev parent reply other threads:[~2017-03-31 10:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 10:56 [PATCH v2 0/3] EmbeddedPkg: revert DTB loading to platform lib Ard Biesheuvel
2017-03-31 10:56 ` [PATCH v2 1/3] EmbeddedPkg: add DtPlatformDtbLoaderLib library class Ard Biesheuvel
2017-03-31 11:15 ` Laszlo Ersek
2017-03-31 10:56 ` Ard Biesheuvel [this message]
2017-03-31 11:29 ` [PATCH v2 2/3] EmbeddedPkg: add base DtPlatformDtbLoaderLib implementation Laszlo Ersek
2017-03-31 10:56 ` [PATCH v2 3/3] EmbeddedPkg/DtPlatformDxe: load platform DTB via new library Ard Biesheuvel
2017-03-31 11:39 ` Laszlo Ersek
2017-03-31 12:22 ` Ard Biesheuvel
2017-03-31 13:38 ` Laszlo Ersek
2017-03-31 12:26 ` [PATCH v2 0/3] EmbeddedPkg: revert DTB loading to platform lib Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170331105607.3477-3-ard.biesheuvel@linaro.org \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox