aboutsummaryrefslogtreecommitdiff
path: root/hw/misc
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2023-04-25 10:34:31 +0000
committerPeter Maydell <peter.maydell@linaro.org>2023-05-02 15:47:40 +0100
commitf802ff1e281eac50f2b4b177b180be97e80da21f (patch)
treed151200340eb288858c655ffd0a573ba9ce1e88c /hw/misc
parent471896381ae895b1c4c2afe1eff2ce13d85e6c2c (diff)
hw/arm/bcm2835_property: Implement "get command line" message
This query copies the kernel command line into the message buffer. It was previously stubbed out to return empty, this commit makes it reflect the arguments specified with `-append`. I observed the following peculiarities on my Pi 3B+: - If the buffer is shorter than the string, the response header gives the full length, but no data is actually copied. - No NUL terminator is added: even if the buffer is long enough to fit one, the buffer's original contents are preserved past the string's end. - The VC firmware adds the following extra parameters beside the user-supplied ones (via /boot/cmdline.txt): `video`, `vc_mem.mem_base` and `vc_mem.mem_size`. This is currently not implemented in qemu. Signed-off-by: Daniel Bertalan <dani@danielbertalan.dev> Message-id: 20230425103250.56653-1-dani@danielbertalan.dev Reviewed-by: Peter Maydell <peter.maydell@linaro.org> [PMM: added comment about NUL and short-buffer behaviour] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/misc')
-rw-r--r--hw/misc/bcm2835_property.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index de056ea2df..251b3d865d 100644
--- a/hw/misc/bcm2835_property.c
+++ b/hw/misc/bcm2835_property.c
@@ -282,7 +282,17 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
break;
case 0x00050001: /* Get command line */
- resplen = 0;
+ /*
+ * We follow the firmware behaviour: no NUL terminator is
+ * written to the buffer, and if the buffer is too short
+ * we report the required length in the response header
+ * and copy nothing to the buffer.
+ */
+ resplen = strlen(s->command_line);
+ if (bufsize >= resplen)
+ address_space_write(&s->dma_as, value + 12,
+ MEMTXATTRS_UNSPECIFIED, s->command_line,
+ resplen);
break;
default:
@@ -420,6 +430,7 @@ static void bcm2835_property_realize(DeviceState *dev, Error **errp)
static Property bcm2835_property_props[] = {
DEFINE_PROP_UINT32("board-rev", BCM2835PropertyState, board_rev, 0),
+ DEFINE_PROP_STRING("command-line", BCM2835PropertyState, command_line),
DEFINE_PROP_END_OF_LIST()
};