diff mbox series

[v2,01/44] binman: Allow setting the ROM offset

Message ID 20200708033246.2626378-2-sjg@chromium.org
State Superseded
Headers show
Series x86: Programmatic generation of ACPI tables (Part C) | expand

Commit Message

Simon Glass July 8, 2020, 3:32 a.m. UTC
On x86 the SPI ROM can be memory-mapped, at least most of it. Add a way
to tell binman the offset from a ROM address to a RAM address.

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

(no changes since v1)

Changes in v1:
- Add a way to set the binman ROM offset

 include/binman.h |  8 ++++++++
 lib/binman.c     | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Bin Meng July 13, 2020, 5:24 a.m. UTC | #1
On Wed, Jul 8, 2020 at 11:33 AM Simon Glass <sjg at chromium.org> wrote:
>
> On x86 the SPI ROM can be memory-mapped, at least most of it. Add a way
> to tell binman the offset from a ROM address to a RAM address.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
> Changes in v1:
> - Add a way to set the binman ROM offset
>
>  include/binman.h |  8 ++++++++
>  lib/binman.c     | 17 +++++++++++++++++
>  2 files changed, 25 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
diff mbox series

Patch

diff --git a/include/binman.h b/include/binman.h
index b462dc8542..baf49f7876 100644
--- a/include/binman.h
+++ b/include/binman.h
@@ -20,6 +20,14 @@  struct binman_entry {
 	u32 size;
 };
 
+/**
+ * binman_set_rom_offset() - Set the ROM memory-map offset
+ *
+ * @rom_offset: Offset from an image_pos to the memory-mapped address. This
+ *	tells binman that ROM image_pos x can be addressed at rom_offset + x
+ */
+void binman_set_rom_offset(int rom_offset);
+
 /**
  * binman_entry_find() - Find a binman symbol
  *
diff --git a/lib/binman.c b/lib/binman.c
index fd7de24bd2..dc3a880882 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -12,10 +12,21 @@ 
 #include <log.h>
 #include <malloc.h>
 
+/**
+ * struct binman_info - Information needed by the binman library
+ *
+ * @image: Node describing the image we are running from
+ * @rom_offset: Offset from an image_pos to the memory-mapped address, or
+ *	ROM_OFFSET_NONE if the ROM is not memory-mapped. Can be positive or
+ *	negative
+ */
 struct binman_info {
 	ofnode image;
+	int rom_offset;
 };
 
+#define ROM_OFFSET_NONE		(-1)
+
 static struct binman_info *binman;
 
 int binman_entry_find(const char *name, struct binman_entry *entry)
@@ -37,6 +48,11 @@  int binman_entry_find(const char *name, struct binman_entry *entry)
 	return 0;
 }
 
+void binman_set_rom_offset(int rom_offset)
+{
+	binman->rom_offset = rom_offset;
+}
+
 int binman_init(void)
 {
 	binman = malloc(sizeof(struct binman_info));
@@ -45,6 +61,7 @@  int binman_init(void)
 	binman->image = ofnode_path("/binman");
 	if (!ofnode_valid(binman->image))
 		return log_msg_ret("binman node", -EINVAL);
+	binman->rom_offset = ROM_OFFSET_NONE;
 
 	return 0;
 }