[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/35] hw/arm/bcm2835_property: Implement "get command line" messa
From: |
Peter Maydell |
Subject: |
[PULL 15/35] hw/arm/bcm2835_property: Implement "get command line" message |
Date: |
Tue, 2 May 2023 13:14:39 +0100 |
From: Daniel Bertalan <dani@danielbertalan.dev>
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>
---
include/hw/misc/bcm2835_property.h | 1 +
hw/arm/bcm2835_peripherals.c | 2 ++
hw/arm/bcm2836.c | 2 ++
hw/arm/raspi.c | 2 ++
hw/misc/bcm2835_property.c | 13 ++++++++++++-
5 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/include/hw/misc/bcm2835_property.h
b/include/hw/misc/bcm2835_property.h
index 712b76b7a32..ba8896610cc 100644
--- a/include/hw/misc/bcm2835_property.h
+++ b/include/hw/misc/bcm2835_property.h
@@ -30,6 +30,7 @@ struct BCM2835PropertyState {
MACAddr macaddr;
uint32_t board_rev;
uint32_t addr;
+ char *command_line;
bool pending;
};
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 3c2a4160cd1..0233038b957 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -90,6 +90,8 @@ static void bcm2835_peripherals_init(Object *obj)
TYPE_BCM2835_PROPERTY);
object_property_add_alias(obj, "board-rev", OBJECT(&s->property),
"board-rev");
+ object_property_add_alias(obj, "command-line", OBJECT(&s->property),
+ "command-line");
object_property_add_const_link(OBJECT(&s->property), "fb",
OBJECT(&s->fb));
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index f894338fc6a..166dc896c09 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -55,6 +55,8 @@ static void bcm2836_init(Object *obj)
TYPE_BCM2835_PERIPHERALS);
object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals),
"board-rev");
+ object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals),
+ "command-line");
object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals),
"vcram-size");
}
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 92d068d1f9d..7b9221c9244 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -280,6 +280,8 @@ static void raspi_machine_init(MachineState *machine)
object_property_add_const_link(OBJECT(&s->soc), "ram",
OBJECT(machine->ram));
object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev,
&error_abort);
+ object_property_set_str(OBJECT(&s->soc), "command-line",
+ machine->kernel_cmdline, &error_abort);
qdev_realize(DEVICE(&s->soc), NULL, &error_fatal);
/* Create and plug in the SD cards */
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
index de056ea2df8..251b3d865d7 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()
};
--
2.34.1
- [PULL 00/35] target-arm queue, Peter Maydell, 2023/05/02
- [PULL 01/35] target/arm: Move cortex sysregs into a separate file, Peter Maydell, 2023/05/02
- [PULL 02/35] target/arm: Remove dead code from cpu_max_set_sve_max_vq, Peter Maydell, 2023/05/02
- [PULL 09/35] tests/avocado: Pass parameters to migration test, Peter Maydell, 2023/05/02
- [PULL 03/35] target/arm: Extract TCG -cpu max code into a function, Peter Maydell, 2023/05/02
- [PULL 04/35] target/arm: Do not expose all -cpu max features to qtests, Peter Maydell, 2023/05/02
- [PULL 15/35] hw/arm/bcm2835_property: Implement "get command line" message,
Peter Maydell <=
- [PULL 28/35] hw/arm/boot: Make write_bootloader() public as arm_write_bootloader(), Peter Maydell, 2023/05/02
- [PULL 26/35] docs/about/deprecated.rst: Add "since 7.1" tag to dtb-kaslr-seed deprecation, Peter Maydell, 2023/05/02
- [PULL 25/35] qmp: Deprecate 'singlestep' member of StatusInfo, Peter Maydell, 2023/05/02
- [PULL 14/35] hw/net: npcm7xx_emc: set MAC in register space, Peter Maydell, 2023/05/02
- [PULL 27/35] hw/net/msf2-emac: Don't modify descriptor in-place in emac_store_desc(), Peter Maydell, 2023/05/02
- [PULL 23/35] hmp: Add 'one-insn-per-tb' command equivalent to 'singlestep', Peter Maydell, 2023/05/02
- [PULL 16/35] make one-insn-per-tb an accel option, Peter Maydell, 2023/05/02
- [PULL 31/35] hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit(), Peter Maydell, 2023/05/02
- [PULL 33/35] target/arm: Add compile time asserts to load/store_cpu_field macros, Peter Maydell, 2023/05/02
- [PULL 24/35] qapi/run-state.json: Fix missing newline at end of file, Peter Maydell, 2023/05/02