qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC PATCH  5/6] hw/arm: add mask boot ROM logic
Date: Mon, 10 Jan 2022 17:51:03 +0000	[thread overview]
Message-ID: <20220110175104.2908956-6-alex.bennee@linaro.org> (raw)
In-Reply-To: <20220110175104.2908956-1-alex.bennee@linaro.org>

The mask ROM contains the initial boot code to start the RP2040. It
also contains some common sub-routines as well as the flash
programming code for drag and drop programming. As a result we need to
ensure the full version is available to any user supplied programs we
might want to run.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 hw/arm/rp2040.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/hw/arm/rp2040.c b/hw/arm/rp2040.c
index c6cc9b7165..9a5bc20159 100644
--- a/hw/arm/rp2040.c
+++ b/hw/arm/rp2040.c
@@ -8,10 +8,12 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
+#include "qemu/datadir.h"
 #include "qapi/error.h"
 #include "hw/arm/armv7m.h"
 #include "hw/arm/rp2040.h"
 #include "hw/misc/unimp.h"
+#include "hw/loader.h"
 #include "hw/sysbus.h"
 #include "hw/qdev-properties.h"
 
@@ -33,6 +35,8 @@ typedef struct RP2040Class {
 #define RP2040_SRAM4_BASE 0x20040000
 #define RP2040_SRAM5_BASE 0x20041000
 
+#define RP2040_MASK_ROM   "pipico.rom"
+
 static void rp2040_init(Object *obj)
 {
     RP2040State *s = RP2040(obj);
@@ -61,6 +65,8 @@ static void rp2040_realize(DeviceState *dev, Error **errp)
     RP2040State *s = RP2040(dev);
     Object *obj = OBJECT(dev);
     int n;
+    g_autofree char *mask_rom = qemu_find_file(QEMU_FILE_TYPE_BIOS,
+                                               RP2040_MASK_ROM);
 
     if (!s->memory) {
         error_setg(errp, "%s: memory property was not set", __func__);
@@ -68,9 +74,20 @@ static void rp2040_realize(DeviceState *dev, Error **errp)
     }
 
     /* initialize internal 16 KB internal ROM */
-    memory_region_init_rom(&s->rom, obj, "rp2040.rom0", 16 * KiB, errp);
+    memory_region_init_rom(&s->rom, obj, "rp2040.rom", 16 * KiB, errp);
     memory_region_add_subregion(s->memory, 0, &s->rom);
 
+    if (!mask_rom) {
+        error_setg(errp, "%s: unable to find mask_rom %s",
+                   __func__, RP2040_MASK_ROM);
+        return;
+    }
+    n = load_image_targphys(mask_rom, 0x0, 16 * KiB);
+    if (n <= 0) {
+        error_setg(errp, "%s: failed to load mask rom image: %s",
+                   __func__, RP2040_MASK_ROM);
+    }
+
     /* SRAM (Main 256k bank + two 4k banks)*/
     memory_region_init_ram(&s->sram03, obj, "rp2040.sram03", 256 * KiB, errp);
     memory_region_add_subregion(s->memory, RP2040_SRAM_BASE, &s->sram03);
-- 
2.30.2



  parent reply	other threads:[~2022-01-10 17:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 17:50 [RFC PATCH 0/6] Basic skeleton of RP2040 Raspbery Pi Pico Alex Bennée
2022-01-10 17:50 ` [RFC PATCH 1/6] hw/arm: arm initial boilerplate for RP2040 SoC Alex Bennée
2022-01-17 12:21   ` Philippe Mathieu-Daudé via
2022-01-10 17:51 ` [RFC PATCH 2/6] hw/arm: add boilerplate for machines based on the RP2040 Alex Bennée
2022-01-17 12:23   ` Philippe Mathieu-Daudé via
2022-01-10 17:51 ` [RFC PATCH 3/6] hw/arm: wire-up memory from the Pico board and the SoC Alex Bennée
2022-01-17 12:27   ` Philippe Mathieu-Daudé via
2022-01-10 17:51 ` [RFC PATCH 4/6] pc-bios: add pipico mask rom (!upstream) Alex Bennée
2022-01-10 17:51 ` Alex Bennée [this message]
2022-01-10 17:51 ` [RFC PATCH 6/6] docs/devel: add some clarifying text for aliases Alex Bennée
2022-01-17 12:29   ` Philippe Mathieu-Daudé via
2022-01-18  7:28   ` Philippe Mathieu-Daudé via

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=20220110175104.2908956-6-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).