All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB
@ 2019-06-25 23:17 Park, Aiden
  2019-07-02 14:13 ` Bin Meng
  0 siblings, 1 reply; 3+ messages in thread
From: Park, Aiden @ 2019-06-25 23:17 UTC (permalink / raw)
  To: u-boot

- Added a function to get a GUID HOB data pointer from hob_list

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 arch/x86/cpu/slimbootloader/Makefile          |  2 +-
 arch/x86/cpu/slimbootloader/hob.c             | 97 +++++++++++++++++++
 .../asm/arch-slimbootloader/slimbootloader.h  | 14 +++
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/slimbootloader/hob.c

diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile
index 627a721e8c..620fc8a139 100644
--- a/arch/x86/cpu/slimbootloader/Makefile
+++ b/arch/x86/cpu/slimbootloader/Makefile
@@ -2,4 +2,4 @@
 #
 # Copyright (C) 2019 Intel Corporation <www.intel.com>
 
-obj-y += car.o slimbootloader.o
+obj-y += car.o slimbootloader.o hob.o
diff --git a/arch/x86/cpu/slimbootloader/hob.c b/arch/x86/cpu/slimbootloader/hob.c
new file mode 100644
index 0000000000..dff86b696e
--- /dev/null
+++ b/arch/x86/cpu/slimbootloader/hob.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ */
+
+#include <common.h>
+#include <asm/arch/slimbootloader.h>
+
+/*
+ * This compares two guids and returns its result(0 or others).
+ *
+ * @guid1:  A pointer to a 128 bit guid
+ * @guid2:  A pointer to a 128 bit guid
+ *
+ * @return: 0 if guid1 and guid2 are identical. Otherwise it returns none 0.
+ */
+static int compare_guid(const struct efi_guid *guid1,
+			const struct efi_guid *guid2)
+{
+	return memcmp(guid1, guid2, sizeof(struct efi_guid));
+}
+
+/**
+ * This returns a hob header pointer which has a specific type from the given
+ * hob list.
+ *
+ * @type:     A specific hob type
+ * @hob_list: A pointer to a hob list
+ *
+ * @return:   A hob header pointer if the specified type is found.
+ *            Otherwise, this returns NULL.
+ */
+static const struct hob_header *get_next_hob_from_hdr(uint type,
+						      const void *hob_list)
+{
+	const struct hob_header *hdr;
+
+	hdr = hob_list;
+
+	/* Parse the HOB list until end of list or matching type is found */
+	while (!end_of_hob(hdr)) {
+		if (hdr->type == type)
+			return hdr;
+
+		hdr = get_next_hob(hdr);
+	}
+
+	return NULL;
+}
+
+/**
+ * This returns a hob header pointer which has a specific guid from the given
+ * hob list.
+ *
+ * @guid:     A pointer to a 128 bit guid
+ * @hob_list: A pointer to a hob list
+ *
+ * @return:   A hob header pointer if the specified guid hob entry is found.
+ *            Otherwise, this returns NULL.
+ */
+static const struct hob_header *get_next_guid_hob(const struct efi_guid *guid,
+						  const void *hob_list)
+{
+	const struct hob_header *hdr;
+	struct hob_guid *guid_hob;
+
+	hdr = hob_list;
+	while ((hdr = get_next_hob_from_hdr(HOB_TYPE_GUID_EXT, hdr))) {
+		guid_hob = (struct hob_guid *)hdr;
+		if (!compare_guid(guid, &guid_hob->name))
+			break;
+		hdr = get_next_hob(hdr);
+	}
+
+	return hdr;
+}
+
+/**
+ * This returns a pointer to hob data buffer if the given guid hob is found.
+ *
+ * @guid:     A pointer to a 128 bit guid
+ * @hob_list: A pointer to a hob list
+ *
+ * @return:   A pointer to hob data buffer if the specified guid hob entry is
+ *            found. Otherwise, this returns NULL.
+ */
+void *get_next_guid_hob_data(const struct efi_guid *guid,
+			     const void *hob_list)
+{
+	const struct hob_header *guid_hob;
+
+	guid_hob = get_next_guid_hob(guid, hob_list);
+	if (!guid_hob)
+		return NULL;
+
+	return get_guid_hob_data(guid_hob);
+}
diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
index 7309a83724..bd1f4ee374 100644
--- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
+++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
@@ -7,5 +7,19 @@
 #define __SLIMBOOTLOADER_ARCH_H__
 
 #include <common.h>
+#include <asm/fsp/fsp_types.h>
+#include <asm/fsp/fsp_hob.h>
+
+/**
+ * This returns a pointer to hob data buffer if the given guid hob is found.
+ *
+ * @guid:     A pointer to a 128 bit guid
+ * @hob_list: A pointer to a hob list
+ *
+ * @return:   A pointer to hob data buffer if the specified guid hob entry is
+ *            found. Otherwise, this returns NULL.
+ */
+void *get_next_guid_hob_data(const struct efi_guid *guid,
+			     const void *hob_list);
 
 #endif
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB
  2019-06-25 23:17 [U-Boot] [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB Park, Aiden
@ 2019-07-02 14:13 ` Bin Meng
  2019-07-08 16:32   ` Park, Aiden
  0 siblings, 1 reply; 3+ messages in thread
From: Bin Meng @ 2019-07-02 14:13 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Wed, Jun 26, 2019 at 7:17 AM Park, Aiden <aiden.park@intel.com> wrote:
>
> - Added a function to get a GUID HOB data pointer from hob_list
>

We need some changes to arch/x86/lib/fsp/fsp_support.c: move these
fsp_get_xxx() APIs to a separate module (hob.c?) and rename them to
get_xxx() for both FSP based board and slim bootloader to use. Some
refactor is needed.

> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  arch/x86/cpu/slimbootloader/Makefile          |  2 +-
>  arch/x86/cpu/slimbootloader/hob.c             | 97 +++++++++++++++++++
>  .../asm/arch-slimbootloader/slimbootloader.h  | 14 +++
>  3 files changed, 112 insertions(+), 1 deletion(-)
>  create mode 100644 arch/x86/cpu/slimbootloader/hob.c
>

Regards,
Bin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB
  2019-07-02 14:13 ` Bin Meng
@ 2019-07-08 16:32   ` Park, Aiden
  0 siblings, 0 replies; 3+ messages in thread
From: Park, Aiden @ 2019-07-08 16:32 UTC (permalink / raw)
  To: u-boot

Hi Bin,

> -----Original Message-----
> From: Bin Meng [mailto:bmeng.cn at gmail.com]
> Sent: Tuesday, July 2, 2019 7:13 AM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Simon Glass
> <sjg@chromium.org>
> Subject: Re: [PATCH v2 2/8] x86: slimbootloader: Add a function to access
> HOB
> 
> Hi Aiden,
> 
> On Wed, Jun 26, 2019 at 7:17 AM Park, Aiden <aiden.park@intel.com> wrote:
> >
> > - Added a function to get a GUID HOB data pointer from hob_list
> >
> 
> We need some changes to arch/x86/lib/fsp/fsp_support.c: move these
> fsp_get_xxx() APIs to a separate module (hob.c?) and rename them to
> get_xxx() for both FSP based board and slim bootloader to use. Some
> refactor is needed.
Agree. Let me make a common hob module for FSP and Slim Bootloader.
> 
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  arch/x86/cpu/slimbootloader/Makefile          |  2 +-
> >  arch/x86/cpu/slimbootloader/hob.c             | 97 +++++++++++++++++++
> >  .../asm/arch-slimbootloader/slimbootloader.h  | 14 +++
> >  3 files changed, 112 insertions(+), 1 deletion(-)  create mode 100644
> > arch/x86/cpu/slimbootloader/hob.c
> >
> 
> Regards,
> Bin

Best Regards,
Aiden

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-08 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 23:17 [U-Boot] [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB Park, Aiden
2019-07-02 14:13 ` Bin Meng
2019-07-08 16:32   ` Park, Aiden

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.