All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 04/16] sandbox: smbios: Update to support sandbox
Date: Wed, 16 May 2018 09:42:21 -0600	[thread overview]
Message-ID: <20180516154233.21457-5-sjg@chromium.org> (raw)
In-Reply-To: <20180516154233.21457-1-sjg@chromium.org>

At present this code casts addresses to pointers so cannot be used with
sandbox. Update it to use mapmem instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3:
- Drop incorrect map_sysmem() in write_smbios_table()

Changes in v2: None

 lib/smbios.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index df3d26b0710..fc3dabcbc1b 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <mapmem.h>
 #include <smbios.h>
 #include <tables_csum.h>
 #include <version.h>
@@ -72,9 +73,10 @@ static int smbios_string_table_len(char *start)
 
 static int smbios_write_type0(ulong *current, int handle)
 {
-	struct smbios_type0 *t = (struct smbios_type0 *)*current;
+	struct smbios_type0 *t;
 	int len = sizeof(struct smbios_type0);
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type0));
 	fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle);
 	t->vendor = smbios_add_string(t->eos, "U-Boot");
@@ -101,16 +103,18 @@ static int smbios_write_type0(ulong *current, int handle)
 
 	len = t->length + smbios_string_table_len(t->eos);
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
 
 static int smbios_write_type1(ulong *current, int handle)
 {
-	struct smbios_type1 *t = (struct smbios_type1 *)*current;
+	struct smbios_type1 *t;
 	int len = sizeof(struct smbios_type1);
 	char *serial_str = env_get("serial#");
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type1));
 	fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
 	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -122,15 +126,17 @@ static int smbios_write_type1(ulong *current, int handle)
 
 	len = t->length + smbios_string_table_len(t->eos);
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
 
 static int smbios_write_type2(ulong *current, int handle)
 {
-	struct smbios_type2 *t = (struct smbios_type2 *)*current;
+	struct smbios_type2 *t;
 	int len = sizeof(struct smbios_type2);
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type2));
 	fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
 	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -140,15 +146,17 @@ static int smbios_write_type2(ulong *current, int handle)
 
 	len = t->length + smbios_string_table_len(t->eos);
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
 
 static int smbios_write_type3(ulong *current, int handle)
 {
-	struct smbios_type3 *t = (struct smbios_type3 *)*current;
+	struct smbios_type3 *t;
 	int len = sizeof(struct smbios_type3);
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type3));
 	fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);
 	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -160,6 +168,7 @@ static int smbios_write_type3(ulong *current, int handle)
 
 	len = t->length + smbios_string_table_len(t->eos);
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
@@ -198,9 +207,10 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)
 
 static int smbios_write_type4(ulong *current, int handle)
 {
-	struct smbios_type4 *t = (struct smbios_type4 *)*current;
+	struct smbios_type4 *t;
 	int len = sizeof(struct smbios_type4);
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type4));
 	fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle);
 	t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL;
@@ -214,32 +224,37 @@ static int smbios_write_type4(ulong *current, int handle)
 
 	len = t->length + smbios_string_table_len(t->eos);
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
 
 static int smbios_write_type32(ulong *current, int handle)
 {
-	struct smbios_type32 *t = (struct smbios_type32 *)*current;
+	struct smbios_type32 *t;
 	int len = sizeof(struct smbios_type32);
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type32));
 	fill_smbios_header(t, SMBIOS_SYSTEM_BOOT_INFORMATION, len, handle);
 
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
 
 static int smbios_write_type127(ulong *current, int handle)
 {
-	struct smbios_type127 *t = (struct smbios_type127 *)*current;
+	struct smbios_type127 *t;
 	int len = sizeof(struct smbios_type127);
 
+	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type127));
 	fill_smbios_header(t, SMBIOS_END_OF_TABLE, len, handle);
 
 	*current += len;
+	unmap_sysmem(t);
 
 	return len;
 }
@@ -268,7 +283,7 @@ ulong write_smbios_table(ulong addr)
 	/* 16 byte align the table address */
 	addr = ALIGN(addr, 16);
 
-	se = (struct smbios_entry *)(uintptr_t)addr;
+	se = map_sysmem(addr, sizeof(struct smbios_entry));
 	memset(se, 0, sizeof(struct smbios_entry));
 
 	addr += sizeof(struct smbios_entry);
@@ -297,6 +312,7 @@ ulong write_smbios_table(ulong addr)
 	isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET;
 	se->intermediate_checksum = table_compute_checksum(istart, isize);
 	se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry));
+	unmap_sysmem(se);
 
 	return addr;
 }
-- 
2.17.0.441.gb46fe60e1d-goog

  parent reply	other threads:[~2018-05-16 15:42 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 15:42 [U-Boot] [PATCH v4 00/16] efi: Enable basic sandbox support for EFI loader Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 01/16] efi: Init the 'rows' and 'cols' variables Simon Glass
2018-05-16 16:21   ` Heinrich Schuchardt
2018-05-16 15:42 ` [U-Boot] [PATCH v4 02/16] efi: Update some comments related to smbios tables Simon Glass
2018-05-16 16:30   ` Heinrich Schuchardt
2018-05-24 12:44   ` [U-Boot] [U-Boot, v4, " Alexander Graf
2018-05-16 15:42 ` [U-Boot] [PATCH v4 03/16] efi: sandbox: Adjust memory usage for sandbox Simon Glass
2018-05-16 17:02   ` Heinrich Schuchardt
2018-05-16 17:15   ` Heinrich Schuchardt
2018-05-24 19:16     ` Heinrich Schuchardt
2018-05-25  2:42       ` Simon Glass
2018-05-16 15:42 ` Simon Glass [this message]
2018-05-24 12:24   ` [U-Boot] [PATCH v4 04/16] sandbox: smbios: Update to support sandbox Alexander Graf
2018-05-25  2:42     ` Simon Glass
2018-06-03 12:13       ` Alexander Graf
2018-06-07 20:25         ` Simon Glass
2018-06-07 20:36           ` Alexander Graf
2018-06-07 20:41             ` Simon Glass
2018-06-07 20:47               ` Alexander Graf
2018-06-08 21:59                 ` Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 05/16] sandbox: Add a setjmp() implementation Simon Glass
2018-05-24 12:44   ` [U-Boot] [U-Boot, v4, " Alexander Graf
2018-06-15 12:01   ` [U-Boot] [PATCH v4 " Alexander Graf
2018-06-15 15:16     ` Simon Glass
2018-06-15 19:59       ` Alexander Graf
2018-05-16 15:42 ` [U-Boot] [PATCH v4 06/16] efi: sandbox: Add required linker sections Simon Glass
2018-05-24 12:43   ` [U-Boot] [U-Boot, v4, " Alexander Graf
2018-05-16 15:42 ` [U-Boot] [PATCH v4 07/16] efi: sandbox: Add distroboot support Simon Glass
2018-05-24 12:32   ` Alexander Graf
2018-06-12  5:27     ` Simon Glass
2018-06-12  5:42       ` Alexander Graf
2018-06-12  6:05         ` Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 08/16] Define board_quiesce_devices() in a shared location Simon Glass
2018-05-24 12:43   ` [U-Boot] [U-Boot, v4, " Alexander Graf
2018-05-16 15:42 ` [U-Boot] [PATCH v4 09/16] Add a comment for board_quiesce_devices() Simon Glass
2018-05-24 12:43   ` [U-Boot] [U-Boot, v4, " Alexander Graf
2018-05-16 15:42 ` [U-Boot] [PATCH v4 10/16] efi: sandbox: Add relocation constants Simon Glass
2018-05-24 12:34   ` Alexander Graf
2018-06-12  5:27     ` Simon Glass
2018-06-12  5:44       ` Alexander Graf
2018-06-12  6:05         ` Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 11/16] efi: Add a comment about duplicated ELF constants Simon Glass
2018-05-16 16:47   ` Heinrich Schuchardt
2018-05-16 15:42 ` [U-Boot] [PATCH v4 12/16] efi: sandbox: Enable EFI loader builder for sandbox Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 13/16] efi: Split out test init/uninit into functions Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 14/16] efi: sandbox: Add a simple 'bootefi test' command Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 15/16] efi: Create a function to set up for running EFI code Simon Glass
2018-05-16 15:42 ` [U-Boot] [PATCH v4 16/16] efi: Rename bootefi_test_finish() to bootefi_run_finish() Simon Glass
2018-05-16 17:13 ` [U-Boot] [PATCH v4 00/16] efi: Enable basic sandbox support for EFI loader Heinrich Schuchardt
2018-05-17  5:31   ` Heinrich Schuchardt
2018-06-12  5:27     ` Simon Glass
2018-05-24 12:40 ` Alexander Graf

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-all 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=20180516154233.21457-5-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 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.