aspeed: Various extensions, fixes and cleanups
Subsystems (2)
cover aspeed: Various extensions, fixes and cleanups
Hello,
Here are the patches I have collected so far that I plan to include in the next Aspeed PR for QEMU 8.0. Most have been reviewed but not all, so please take a look, specially the one on VFP registers.
* various small cleanups and fixes
* new variant of the supermicrox11-bmc machine using an ast2500-a1 SoC
* at24c_eeprom extension to define eeprom contents with static arrays
* ast10x0 model and test improvements
* avocado update of images to use the latest
Thanks,
C.
Cédric Le Goater (6):
m25p80: Improve error when the backend file size does not match the device tests/avocado/machine_aspeed.py: update buildroot tests tests/avocado/machine_aspeed.py: Mask systemd services to speed up SDK boot hw/arm/boot: Export write_bootloader for Aspeed machines hw/core/loader: Remove declarations of option_rom_has_mr/rom_file_has_mr target/arm: Allow users to set the number of VFP registers
Guenter Roeck (2):
aspeed: Add Supermicro X11 SPI machine type
m25p80: Add the is25wp256 SFPD table
Joel Stanley (1):
avocado/boot_linux_console.py: Update ast2600 test
Peter Delevoryas (5):
hw/arm: Extract at24c_eeprom_init helper from Aspeed and Nuvoton boards hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init hw/nvram/eeprom_at24c: Add init_rom field and at24c_eeprom_init_rom helper hw/arm/aspeed: Add aspeed_eeprom.c
hw/nvram/eeprom_at24c: Make reset behavior more like hardware
Philippe Mathieu-Daudé (10):
hw/watchdog/wdt_aspeed: Rename MMIO region size as 'iosize' hw/watchdog/wdt_aspeed: Extend MMIO range to cover more registers hw/watchdog/wdt_aspeed: Log unimplemented registers as UNIMP level hw/misc/aspeed_hace: Do not crash if address_space_map() failed hw/arm/aspeed_ast10x0: Add various unimplemented peripherals hw/arm/aspeed_ast10x0: Map I3C peripheral hw/arm/aspeed_ast10x0: Map the secure SRAM hw/arm/aspeed_ast10x0: Map HACE peripheral hw/arm/aspeed_ast10x0: Add TODO comment to use Cortex-M4F tests/avocado: Test Aspeed Zephyr SDK v00.01.08 on AST1030 board
Stephen Longfield (1):
hw/net: Fix read of uninitialized memory in ftgmac100
hw/arm/aspeed_eeprom.h | 19 +++ hw/block/m25p80_sfdp.h | 2 + include/hw/arm/aspeed_soc.h | 14 +++ include/hw/arm/boot.h | 24 ++++ include/hw/loader.h | 3 - include/hw/nvram/eeprom_at24c.h | 39 ++++++ include/hw/watchdog/wdt_aspeed.h | 4 +- target/arm/cpu.h | 2 + hw/arm/aspeed.c | 184 ++++++++++++++++------------ hw/arm/aspeed_ast10x0.c | 83 ++++++++++++- hw/arm/aspeed_ast2600.c | 6 +- hw/arm/aspeed_eeprom.c | 81 ++++++++++++ hw/arm/aspeed_soc.c | 4 +- hw/arm/boot.c | 34 ++--- hw/arm/npcm7xx_boards.c | 20 +-- hw/block/m25p80.c | 7 +- hw/block/m25p80_sfdp.c | 40 ++++++ hw/misc/aspeed_hace.c | 21 +++- hw/net/ftgmac100.c | 4 +- hw/nvram/eeprom_at24c.c | 59 +++++++-- hw/watchdog/wdt_aspeed.c | 24 +++- target/arm/cpu.c | 31 +++++ hw/arm/meson.build | 1 + tests/avocado/boot_linux_console.py | 12 +- tests/avocado/machine_aspeed.py | 60 +++++++-- 25 files changed, 602 insertions(+), 176 deletions(-) create mode 100644 hw/arm/aspeed_eeprom.h create mode 100644 include/hw/nvram/eeprom_at24c.h create mode 100644 hw/arm/aspeed_eeprom.c
Signature · 1 line
2.39.0
PATCH 1/25 m25p80: Improve error when the backend file size does not match the device
Currently, when a block backend is attached to a m25p80 device and the associated file size does not match the flash model, QEMU complains with the error message "failed to read the initial flash content". This is confusing for the user.
Use blk_check_size_and_read_all() instead of blk_pread() to improve the reported error.
Message-Id: <[email protected]>
--- hw/block/m25p80.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/block/m25p80.c +2 -2
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "sysemu/block-backend.h" +#include "hw/block/block.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h"
@@ -1614,8 +1615,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error **errp)trace_m25p80_binding (s); s->storage =blk_blockalign (s->blk, s->size); -if (blk_pread (s->blk,0 , s->size, s->storage,0 ) <0 ) { -error_setg (errp,"failed to read the initial flash content" ); +if (!blk_check_size_and_read_all (s->blk, s->storage, s->size, errp)) {return ; } }else {
Signature · 1 line
2.39.0
PATCH 2/25 aspeed: Add Supermicro X11 SPI machine type
In reply to Cédric Le GoaterFrom: Guenter Roeck <[email protected]>
supermicrox11-bmc is configured with ast2400-a1 SoC. This does not match the Supermicro documentation for X11 BMCs, and it does not match the devicetree file in the Linux kernel.
As it turns out, some Supermicro X11 motherboards use AST2400 SoCs, while others use AST2500.
Introduce new machine type supermicrox11-spi-bmc with AST2500 SoC to match the devicetree description in the Linux kernel. Hardware configuration details for this machine type are guesswork and taken from defaults as well as from the Linux kernel devicetree file.
The new machine type was tested with aspeed-bmc-supermicro-x11spi.dts from the Linux kernel and with Linux versions 6.0.3 and 6.1-rc2. Linux booted successfully from initrd and from both SPI interfaces. Ethernet interfaces were confirmed to be operational.
Message-Id: <[email protected]>
--- hw/arm/aspeed.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
hw/arm/aspeed.c +33 -0
@@ -71,6 +71,16 @@ struct AspeedMachineState { SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \ SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT)) +/* TODO: Find the actual hardware value */ +#define SUPERMICROX11_SPI_BMC_HW_STRAP1 ( \ + AST2500_HW_STRAP1_DEFAULTS | \ + SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ + SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ + SCU_AST2500_HW_STRAP_UART_DEBUG | \ + SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ + SCU_HW_STRAP_SPI_WIDTH | \ + SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN)) +/* AST2500 evb hardware value: 0xF100C2E6 */ #define AST2500_EVB_HW_STRAP1 (( \ AST2500_HW_STRAP1_DEFAULTS | \
@@ -1141,6 +1151,25 @@ static void aspeed_machine_supermicrox11_bmc_class_init(ObjectClass *oc, mc->default_ram_size =256 * MiB; } +static void aspeed_machine_supermicrox11_spi_bmc_class_init (ObjectClass *oc, +void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +AspeedMachineClass *amc =ASPEED_MACHINE_CLASS (oc); + + mc->desc ="Supermicro X11 SPI BMC (ARM1176)" ; + amc->soc_name ="ast2500-a1" ; + amc->hw_strap1 =SUPERMICROX11_SPI_BMC_HW_STRAP1 ; + amc->fmc_model ="mx25l25635e" ; + amc->spi_model ="mx25l25635e" ; + amc->num_cs =1 ; + amc->macs_mask =ASPEED_MAC0_ON |ASPEED_MAC1_ON ; + amc->i2c_init = palmetto_bmc_i2c_init; + mc->default_ram_size =512 * MiB; + mc->default_cpus = mc->min_cpus = mc->max_cpus = +aspeed_soc_num_cpus (amc->soc_name); +} +static void aspeed_machine_ast2500_evb_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1522,6 +1551,10 @@ static const TypeInfo aspeed_machine_types[] = { .name = MACHINE_TYPE_NAME("supermicrox11-bmc"), .parent = TYPE_ASPEED_MACHINE, .class_init = aspeed_machine_supermicrox11_bmc_class_init, + }, { + .name = MACHINE_TYPE_NAME("supermicrox11-spi-bmc"), + .parent = TYPE_ASPEED_MACHINE, + .class_init = aspeed_machine_supermicrox11_spi_bmc_class_init, }, { .name = MACHINE_TYPE_NAME("ast2500-evb"), .parent = TYPE_ASPEED_MACHINE,
Signature · 1 line
2.39.0
Joel Stanley
maintainerRe: [PATCH 02/25] aspeed: Add Supermicro X11 SPI machine type
Quoted 6 lines · Cédric Le Goater
From: Guenter Roeck <[email protected]>
supermicrox11-bmc is configured with ast2400-a1 SoC. This does not match the Supermicro documentation for X11 BMCs, and it does not match the devicetree file in the Linux kernel.
I found this sentence confusing; AFAICT X11 doesn't name a specific motherboard. It appears to be a marketing term for a bunch of different things.
Quoted 4 lines
As it turns out, some Supermicro X11 motherboards use AST2400 SoCs, while others use AST2500.
Introduce new machine type supermicrox11-spi-bmc with AST2500 SoC
How about supermicro-x11spi-bmc? It would match the product name:
https://www.supermicro.com/en/products/motherboard/X11SPi-TF
as well as the device tree filename.
Quoted 80 lines
to match the devicetree description in the Linux kernel. Hardware configuration details for this machine type are guesswork and taken from defaults as well as from the Linux kernel devicetree file.
The new machine type was tested with
aspeed-bmc-supermicro-x11spi.dtsfrom the Linux kernel and with Linux versions 6.0.3 and 6.1-rc2. Linux booted successfully from initrd and from both SPI interfaces. Ethernet interfaces were confirmed to be operational.Signed-off-by Guenter Roeck <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Message-Id: <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>--- hw/arm/aspeed.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)hw/arm/aspeed.c +33
-1@@ -71,6 +71,16 @@ struct AspeedMachineState { SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \ SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT)) +/* TODO: Find the actual hardware value */ +#define SUPERMICROX11_SPI_BMC_HW_STRAP1 ( \ + AST2500_HW_STRAP1_DEFAULTS | \ + SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ + SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ + SCU_AST2500_HW_STRAP_UART_DEBUG | \ + SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ + SCU_HW_STRAP_SPI_WIDTH | \ + SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN)) +/* AST2500 evb hardware value: 0xF100C2E6 */ #define AST2500_EVB_HW_STRAP1 (( \ AST2500_HW_STRAP1_DEFAULTS | \@@ -1141,6 +1151,25 @@ static void aspeed_machine_supermicrox11_bmc_class_init(ObjectClass *oc, mc->default_ram_size =256 * MiB; } +static void aspeed_machine_supermicrox11_spi_bmc_class_init (ObjectClass *oc, +void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +AspeedMachineClass *amc =ASPEED_MACHINE_CLASS (oc); + + mc->desc ="Supermicro X11 SPI BMC (ARM1176)" ; + amc->soc_name ="ast2500-a1" ; + amc->hw_strap1 =SUPERMICROX11_SPI_BMC_HW_STRAP1 ; + amc->fmc_model ="mx25l25635e" ; + amc->spi_model ="mx25l25635e" ; + amc->num_cs =1 ; + amc->macs_mask =ASPEED_MAC0_ON |ASPEED_MAC1_ON ; + amc->i2c_init = palmetto_bmc_i2c_init; + mc->default_ram_size =512 * MiB; + mc->default_cpus = mc->min_cpus = mc->max_cpus = +aspeed_soc_num_cpus (amc->soc_name); +} +static void aspeed_machine_ast2500_evb_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);@@ -1522,6 +1551,10 @@ static const TypeInfo aspeed_machine_types[] = { .name = MACHINE_TYPE_NAME("supermicrox11-bmc"), .parent = TYPE_ASPEED_MACHINE, .class_init = aspeed_machine_supermicrox11_bmc_class_init, + }, { + .name = MACHINE_TYPE_NAME("supermicrox11-spi-bmc"), + .parent = TYPE_ASPEED_MACHINE, + .class_init = aspeed_machine_supermicrox11_spi_bmc_class_init, }, { .name = MACHINE_TYPE_NAME("ast2500-evb"), .parent = TYPE_ASPEED_MACHINE, --2.39.0
Re: [PATCH 02/25] aspeed: Add Supermicro X11 SPI machine type
Quoted 15 lines · Joel Stanley
Quoted 6 lines · Cédric Le Goater
From: Guenter Roeck <[email protected]>
supermicrox11-bmc is configured with ast2400-a1 SoC. This does not match the Supermicro documentation for X11 BMCs, and it does not match the devicetree file in the Linux kernel.
I found this sentence confusing; AFAICT X11 doesn't name a specific motherboard. It appears to be a marketing term for a bunch of different things.
Quoted 3 lines
As it turns out, some Supermicro X11 motherboards use AST2400 SoCs, while others use AST2500.
Quoted 7 lines
Quoted 1 line
Introduce new machine type supermicrox11-spi-bmc with AST2500 SoC
How about supermicro-x11spi-bmc? It would match the product name:
https://www.supermicro.com/en/products/motherboard/X11SPi-TF
as well as the device tree filename.
Indeed,
model = "X11SPI BMC";
compatible = "supermicro,x11spi-bmc", "aspeed,ast2500";I was the one who suggested the name. Let's change if Guenter agrees.
Thanks,
C.
Re: [PATCH 02/25] aspeed: Add Supermicro X11 SPI machine type
Quoted 22 lines · Cédric Le Goater
Quoted 21 lines · Joel Stanley
Quoted 6 lines · Cédric Le Goater
From: Guenter Roeck <[email protected]>
supermicrox11-bmc is configured with ast2400-a1 SoC. This does not match the Supermicro documentation for X11 BMCs, and it does not match the devicetree file in the Linux kernel.
I found this sentence confusing; AFAICT X11 doesn't name a specific motherboard. It appears to be a marketing term for a bunch of different things.
Quoted 4 lines
As it turns out, some Supermicro X11 motherboards use AST2400 SoCs, while others use AST2500.
Introduce new machine type supermicrox11-spi-bmc with AST2500 SoC
How about supermicro-x11spi-bmc? It would match the product name:
https://www.supermicro.com/en/products/motherboard/X11SPi-TF
Quoted 9 lines
Quoted 1 line
as well as the device tree filename.
Indeed,
model = "X11SPI BMC";
compatible = "supermicro,x11spi-bmc", "aspeed,ast2500";I was the one who suggested the name. Let's change if Guenter agrees.
Sure, any name is fine with me.
Guenter
PATCH 3/25 hw/net: Fix read of uninitialized memory in ftgmac100
In reply to Cédric Le GoaterFrom: Stephen Longfield <[email protected]>
With the size += 4 before the call to crc32, the CRC calculation would overrun the buffer. Size is used in the while loop starting on line 1009 to determine how much data to write back, with the last four bytes coming from crc_ptr, so do need to increase it, but should do this after the computation.
I'm unsure why this use of uninitialized memory in the CRC doesn't result in CRC errors, but it seems clear to me that it should not be included in the calculation.
Message-Id: <[email protected]>
--- hw/net/ftgmac100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/ftgmac100.c +2 -2
@@ -980,9 +980,9 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,return size; } -/* 4 bytes for the CRC. */ - size +=4 ; crc =cpu_to_be32 (crc32 (~0 , buf, size)); +/* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */ + size +=4 ; crc_ptr = (uint8_t *) &crc;/* Huge frames are truncated. */
Signature · 1 line
2.39.0
Re: [PATCH 03/25] hw/net: Fix read of uninitialized memory in ftgmac100
Quoted 9 lines · Cédric Le Goater
From: Stephen Longfield <[email protected]>
With the
size += 4before the call tocrc32, the CRC calculation would overrun the buffer. Size is used in the while loop starting on line 1009 to determine how much data to write back, with the last four bytes coming fromcrc_ptr, so do need to increase it, but should do this after the computation.
Quoted 3 lines
I'm unsure why this use of uninitialized memory in the CRC doesn't result in CRC errors, but it seems clear to me that it should not be included in the calculation.
Does this affect the error counters observed under Linux?
Quoted 5 lines
Signed-off-by Stephen Longfield <[email protected]>Reviewed-by Hao Wu <[email protected]>Message-Id: <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 24 lines
--- hw/net/ftgmac100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/net/ftgmac100.c +2
-3@@ -980,9 +980,9 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,return size; } -/* 4 bytes for the CRC. */ - size +=4 ; crc =cpu_to_be32 (crc32 (~0 , buf, size)); +/* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */ + size +=4 ; crc_ptr = (uint8_t *) &crc;/* Huge frames are truncated. */ --2.39.0
PATCH 4/25 avocado/boot_linux_console.py: Update ast2600 test
In reply to Cédric Le GoaterFrom: Joel Stanley <[email protected]>
Update the test_arm_ast2600_debian test to
- the latest Debian kernel
- use the Rainier machine instead of Tacoma
Both of which contains support for more hardware and thus exercises more of the hardware Qemu models.
Message-Id: <[email protected]>
--- tests/avocado/boot_linux_console.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tests/avocado/boot_linux_console.py +6 -6
@@ -1098,18 +1098,18 @@ def test_arm_vexpressa9(self): def test_arm_ast2600_debian(self): """ :avocado: tags=arch:arm - :avocado: tags=machine:tacoma-bmc + :avocado: tags=machine:rainier-bmc """ deb_url = ('http://snapshot.debian.org/archive/debian/' - '20210302T203551Z/' + '20220606T211338Z/' 'pool/main/l/linux/' - 'linux-image-5.10.0-3-armmp_5.10.13-1_armhf.deb') - deb_hash = 'db40d32fe39255d05482bea48d72467b67d6225bb2a2a4d6f618cb8976f1e09e' + 'linux-image-5.17.0-2-armmp_5.17.6-1%2Bb1_armhf.deb') + deb_hash = '8acb2b4439faedc2f3ed4bdb2847ad4f6e0491f73debaeb7f660c8abe4dcdc0e' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash, algorithm='sha256') - kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.10.0-3-armmp') + kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.17.0-2-armmp') dtb_path = self.extract_from_deb(deb_path, - '/usr/lib/linux-image-5.10.0-3-armmp/aspeed-bmc-opp-tacoma.dtb') + '/usr/lib/linux-image-5.17.0-2-armmp/aspeed-bmc-ibm-rainier.dtb') self.vm.set_console() self.vm.add_args('-kernel', kernel_path,
Signature · 1 line
2.39.0
Joel Stanley
maintainerRe: [PATCH 04/25] avocado/boot_linux_console.py: Update ast2600 test
Quoted 6 lines · Cédric Le Goater
From: Joel Stanley <[email protected]>
Update the
test_arm_ast2600_debiantest to- the latest Debian kernel
Would you like a newer version of this patch that uses the latest kernel?
Quoted 45 lines
- use the Rainier machine instead of Tacoma
Both of which contains support for more hardware and thus exercises more of the hardware Qemu models.
Signed-off-by Joel Stanley <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Message-Id: <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>--- tests/avocado/boot_linux_console.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)tests/avocado/boot_linux_console.py +6
-7@@ -1098,18 +1098,18 @@ def test_arm_vexpressa9(self): def test_arm_ast2600_debian(self): """ :avocado: tags=arch:arm - :avocado: tags=machine:tacoma-bmc + :avocado: tags=machine:rainier-bmc """ deb_url = ('http://snapshot.debian.org/archive/debian/' - '20210302T203551Z/' + '20220606T211338Z/' 'pool/main/l/linux/' - 'linux-image-5.10.0-3-armmp_5.10.13-1_armhf.deb') - deb_hash = 'db40d32fe39255d05482bea48d72467b67d6225bb2a2a4d6f618cb8976f1e09e' + 'linux-image-5.17.0-2-armmp_5.17.6-1%2Bb1_armhf.deb') + deb_hash = '8acb2b4439faedc2f3ed4bdb2847ad4f6e0491f73debaeb7f660c8abe4dcdc0e' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash, algorithm='sha256') - kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.10.0-3-armmp') + kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.17.0-2-armmp') dtb_path = self.extract_from_deb(deb_path, - '/usr/lib/linux-image-5.10.0-3-armmp/aspeed-bmc-opp-tacoma.dtb') + '/usr/lib/linux-image-5.17.0-2-armmp/aspeed-bmc-ibm-rainier.dtb') self.vm.set_console() self.vm.add_args('-kernel', kernel_path, --2.39.0
Re: [PATCH 04/25] avocado/boot_linux_console.py: Update ast2600 test
Quoted 9 lines · Joel Stanley
Quoted 6 lines · Cédric Le Goater
From: Joel Stanley <[email protected]>
Update the
test_arm_ast2600_debiantest to- the latest Debian kernel
Would you like a newer version of this patch that uses the latest kernel?
Sure. We can not test all kernels. Using the latest is the best approach I think.
Thanks,
C.
Quoted 46 lines
Quoted 46 lines
- use the Rainier machine instead of Tacoma
Both of which contains support for more hardware and thus exercises more of the hardware Qemu models.
Signed-off-by Joel Stanley <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Message-Id: <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>--- tests/avocado/boot_linux_console.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)tests/avocado/boot_linux_console.py +6
-7@@ -1098,18 +1098,18 @@ def test_arm_vexpressa9(self): def test_arm_ast2600_debian(self): """ :avocado: tags=arch:arm - :avocado: tags=machine:tacoma-bmc + :avocado: tags=machine:rainier-bmc """ deb_url = ('http://snapshot.debian.org/archive/debian/' - '20210302T203551Z/' + '20220606T211338Z/' 'pool/main/l/linux/' - 'linux-image-5.10.0-3-armmp_5.10.13-1_armhf.deb') - deb_hash = 'db40d32fe39255d05482bea48d72467b67d6225bb2a2a4d6f618cb8976f1e09e' + 'linux-image-5.17.0-2-armmp_5.17.6-1%2Bb1_armhf.deb') + deb_hash = '8acb2b4439faedc2f3ed4bdb2847ad4f6e0491f73debaeb7f660c8abe4dcdc0e' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash, algorithm='sha256') - kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.10.0-3-armmp') + kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.17.0-2-armmp') dtb_path = self.extract_from_deb(deb_path, - '/usr/lib/linux-image-5.10.0-3-armmp/aspeed-bmc-opp-tacoma.dtb') + '/usr/lib/linux-image-5.17.0-2-armmp/aspeed-bmc-ibm-rainier.dtb') self.vm.set_console() self.vm.add_args('-kernel', kernel_path, --2.39.0
PATCH 5/25 m25p80: Add the is25wp256 SFPD table
In reply to Cédric Le GoaterFrom: Guenter Roeck <[email protected]>
Generated from hardware using the following command and then padding with 0xff to fill out a power-of-2:
xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
Message-Id: <[email protected]>
--- hw/block/m25p80_sfdp.h | 2 ++ hw/block/m25p80.c | 3 ++- hw/block/m25p80_sfdp.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-)
hw/block/m25p80_sfdp.h +2 -0
@@ -26,4 +26,6 @@ uint8_t m25p80_sfdp_w25q512jv(uint32_t addr);uint8_t m25p80_sfdp_w25q01jvq (uint32_t addr); +uint8_t m25p80_sfdp_is25wp256 (uint32_t addr); +#endif
hw/block/m25p80.c +2 -1
@@ -222,7 +222,8 @@ static const FlashPartInfo known_devices[] = { { INFO("is25wp032", 0x9d7016, 0, 64 << 10, 64, ER_4K) }, { INFO("is25wp064", 0x9d7017, 0, 64 << 10, 128, ER_4K) }, { INFO("is25wp128", 0x9d7018, 0, 64 << 10, 256, ER_4K) }, - { INFO("is25wp256", 0x9d7019, 0, 64 << 10, 512, ER_4K) }, + { INFO("is25wp256", 0x9d7019, 0, 64 << 10, 512, ER_4K), + .sfdp_read = m25p80_sfdp_is25wp256 },/* Macronix */ { INFO("mx25l2005a", 0xc22012, 0, 64 << 10, 4, ER_4K) },
hw/block/m25p80_sfdp.c +40 -0
@@ -330,3 +330,43 @@ static const uint8_t sfdp_w25q01jvq[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , };define_sfdp_read (w25q01jvq); + +/* +* Integrated Silicon Solution (ISSI) +*/ + +static const uint8_t sfdp_is25wp256[] = { +0x53 ,0x46 ,0x44 ,0x50 ,0x06 ,0x01 ,0x01 ,0xff , +0x00 ,0x06 ,0x01 ,0x10 ,0x30 ,0x00 ,0x00 ,0xff , +0x9d ,0x05 ,0x01 ,0x03 ,0x80 ,0x00 ,0x00 ,0x02 , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xe5 ,0x20 ,0xf9 ,0xff ,0xff ,0xff ,0xff ,0x0f , +0x44 ,0xeb ,0x08 ,0x6b ,0x08 ,0x3b ,0x80 ,0xbb , +0xfe ,0xff ,0xff ,0xff ,0xff ,0xff ,0x00 ,0xff , +0xff ,0xff ,0x44 ,0xeb ,0x0c ,0x20 ,0x0f ,0x52 , +0x10 ,0xd8 ,0x00 ,0xff ,0x23 ,0x4a ,0xc9 ,0x00 , +0x82 ,0xd8 ,0x11 ,0xce ,0xcc ,0xcd ,0x68 ,0x46 , +0x7a ,0x75 ,0x7a ,0x75 ,0xf7 ,0xae ,0xd5 ,0x5c , +0x4a ,0x42 ,0x2c ,0xff ,0xf0 ,0x30 ,0xfa ,0xa9 , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0x50 ,0x19 ,0x50 ,0x16 ,0x9f ,0xf9 ,0xc0 ,0x64 , +0x8f ,0xef ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +}; +define_sfdp_read (is25wp256);
Signature · 1 line
2.39.0
Re: [PATCH 05/25] m25p80: Add the is25wp256 SFPD table
Quoted 5 lines · Cédric Le Goater
From: Guenter Roeck <[email protected]>
Generated from hardware using the following command and then padding with
0xffto fill out a power-of-2:
Quoted 8 lines
xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdpCc Michael Walle <[email protected]>Cc Tudor Ambarus <[email protected]>Signed-off-by Guenter Roeck <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Message-Id: <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>
I wonder if we could update the code so the padding is assumed.
Quoted 83 lines
--- hw/block/m25p80_sfdp.h | 2 ++ hw/block/m25p80.c | 3 ++- hw/block/m25p80_sfdp.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-)hw/block/m25p80_sfdp.h +2
-0@@ -26,4 +26,6 @@ uint8_t m25p80_sfdp_w25q512jv(uint32_t addr);uint8_t m25p80_sfdp_w25q01jvq (uint32_t addr); +uint8_t m25p80_sfdp_is25wp256 (uint32_t addr); +#endif hw/block/m25p80.c +2
-1@@ -222,7 +222,8 @@ static const FlashPartInfo known_devices[] = { { INFO("is25wp032", 0x9d7016, 0, 64 << 10, 64, ER_4K) }, { INFO("is25wp064", 0x9d7017, 0, 64 << 10, 128, ER_4K) }, { INFO("is25wp128", 0x9d7018, 0, 64 << 10, 256, ER_4K) }, - { INFO("is25wp256", 0x9d7019, 0, 64 << 10, 512, ER_4K) }, + { INFO("is25wp256", 0x9d7019, 0, 64 << 10, 512, ER_4K), + .sfdp_read = m25p80_sfdp_is25wp256 },/* Macronix */ { INFO("mx25l2005a", 0xc22012, 0, 64 << 10, 4, ER_4K) },hw/block/m25p80_sfdp.c +40
-1@@ -330,3 +330,43 @@ static const uint8_t sfdp_w25q01jvq[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , };define_sfdp_read (w25q01jvq); + +/* +* Integrated Silicon Solution (ISSI) +*/ + +static const uint8_t sfdp_is25wp256[] = { +0x53 ,0x46 ,0x44 ,0x50 ,0x06 ,0x01 ,0x01 ,0xff , +0x00 ,0x06 ,0x01 ,0x10 ,0x30 ,0x00 ,0x00 ,0xff , +0x9d ,0x05 ,0x01 ,0x03 ,0x80 ,0x00 ,0x00 ,0x02 , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xe5 ,0x20 ,0xf9 ,0xff ,0xff ,0xff ,0xff ,0x0f , +0x44 ,0xeb ,0x08 ,0x6b ,0x08 ,0x3b ,0x80 ,0xbb , +0xfe ,0xff ,0xff ,0xff ,0xff ,0xff ,0x00 ,0xff , +0xff ,0xff ,0x44 ,0xeb ,0x0c ,0x20 ,0x0f ,0x52 , +0x10 ,0xd8 ,0x00 ,0xff ,0x23 ,0x4a ,0xc9 ,0x00 , +0x82 ,0xd8 ,0x11 ,0xce ,0xcc ,0xcd ,0x68 ,0x46 , +0x7a ,0x75 ,0x7a ,0x75 ,0xf7 ,0xae ,0xd5 ,0x5c , +0x4a ,0x42 ,0x2c ,0xff ,0xf0 ,0x30 ,0xfa ,0xa9 , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0x50 ,0x19 ,0x50 ,0x16 ,0x9f ,0xf9 ,0xc0 ,0x64 , +0x8f ,0xef ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +}; +define_sfdp_read (is25wp256); --2.39.0
PATCH 6/25 tests/avocado/machine_aspeed.py: update buildroot tests
In reply to Cédric Le GoaterUse buildroot 2022.11 based images plus some customization :
- Linux version is bumped to 6.0.9 and kernel is built with a custom config similar to what OpenBMC provides.
- U-Boot is switched to the one provided by OpenBMC for better support.
- defconfigs includes more target tools for dev.
--- tests/avocado/machine_aspeed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tests/avocado/machine_aspeed.py +4 -4
@@ -123,8 +123,8 @@ def test_arm_ast2500_evb_buildroot(self): """ image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' - 'images/ast2500-evb/buildroot-2022.05/flash.img') - image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f') + 'images/ast2500-evb/buildroot-2022.11-2-g15d3648df9/flash.img') + image_hash = ('f96d11db521fe7a2787745e9e391225deeeec3318ee0fc07c8b799b8833dd474') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256')
@@ -151,8 +151,8 @@ def test_arm_ast2600_evb_buildroot(self): """ image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' - 'images/ast2600-evb/buildroot-2022.05/flash.img') - image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d') + 'images/ast2600-evb/buildroot-2022.11-2-g15d3648df9/flash.img') + image_hash = ('e598d86e5ea79671ca8b59212a326c911bc8bea728dec1a1f5390d717a28bb8b') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256')
Signature · 1 line
2.39.0
Re: [PATCH 06/25] tests/avocado/machine_aspeed.py: update buildroot tests
Quoted 9 lines · Cédric Le Goater
Use buildroot 2022.11 based images plus some customization :
- Linux version is bumped to 6.0.9 and kernel is built with a custom config similar to what OpenBMC provides.
- U-Boot is switched to the one provided by OpenBMC for better support.
- defconfigs includes more target tools for dev.Signed-off-by Cédric Le Goater <[email protected]>
Quoted 34 lines
--- tests/avocado/machine_aspeed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tests/avocado/machine_aspeed.py +4
-5@@ -123,8 +123,8 @@ def test_arm_ast2500_evb_buildroot(self): """ image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' - 'images/ast2500-evb/buildroot-2022.05/flash.img') - image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f') + 'images/ast2500-evb/buildroot-2022.11-2-g15d3648df9/flash.img') + image_hash = ('f96d11db521fe7a2787745e9e391225deeeec3318ee0fc07c8b799b8833dd474') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256')@@ -151,8 +151,8 @@ def test_arm_ast2600_evb_buildroot(self): """ image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' - 'images/ast2600-evb/buildroot-2022.05/flash.img') - image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d') + 'images/ast2600-evb/buildroot-2022.11-2-g15d3648df9/flash.img') + image_hash = ('e598d86e5ea79671ca8b59212a326c911bc8bea728dec1a1f5390d717a28bb8b') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') --2.39.0
PATCH 7/25 tests/avocado/machine_aspeed.py: Mask systemd services to speed up SDK boot
In reply to Cédric Le Goater--- tests/avocado/machine_aspeed.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tests/avocado/machine_aspeed.py +9 -2
@@ -183,7 +183,14 @@ def test_arm_ast2600_evb_buildroot(self): class AST2x00MachineSDK(QemuSystemTest): - EXTRA_BOOTARGS = ' quiet' + EXTRA_BOOTARGS = ( + 'quiet ' + 'systemd.mask=org.openbmc.HostIpmi.service ' + '[email protected] ' + '[email protected] ' + 'systemd.mask=rngd.service ' + '[email protected] ' + ) # FIXME: Although these tests boot a whole distro they are still # slower than comparable machine models. There may be some
@@ -208,7 +215,7 @@ def do_test_arm_aspeed_sdk_start(self, image): interrupt_interactive_console_until_pattern( self, 'Hit any key to stop autoboot:', 'ast#') exec_command_and_wait_for_pattern( - self, 'setenv bootargs ${bootargs}' + self.EXTRA_BOOTARGS, 'ast#') + self, 'setenv bootargs ${bootargs} ' + self.EXTRA_BOOTARGS, 'ast#') exec_command_and_wait_for_pattern( self, 'boot', '## Loading kernel from FIT Image') self.wait_for_console_pattern('Starting kernel ...')
Signature · 1 line
2.39.0
Re: [PATCH 07/25] tests/avocado/machine_aspeed.py: Mask systemd services to speed up SDK boot
Quoted 2 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
NIce!
Quoted 37 lines
--- tests/avocado/machine_aspeed.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)tests/avocado/machine_aspeed.py +9
-3@@ -183,7 +183,14 @@ def test_arm_ast2600_evb_buildroot(self): class AST2x00MachineSDK(QemuSystemTest): - EXTRA_BOOTARGS = ' quiet' + EXTRA_BOOTARGS = ( + 'quiet ' + 'systemd.mask=org.openbmc.HostIpmi.service ' + '[email protected] ' + '[email protected] ' + 'systemd.mask=rngd.service ' + '[email protected] ' + ) # FIXME: Although these tests boot a whole distro they are still # slower than comparable machine models. There may be some@@ -208,7 +215,7 @@ def do_test_arm_aspeed_sdk_start(self, image): interrupt_interactive_console_until_pattern( self, 'Hit any key to stop autoboot:', 'ast#') exec_command_and_wait_for_pattern( - self, 'setenv bootargs ${bootargs}' + self.EXTRA_BOOTARGS, 'ast#') + self, 'setenv bootargs ${bootargs} ' + self.EXTRA_BOOTARGS, 'ast#') exec_command_and_wait_for_pattern( self, 'boot', '## Loading kernel from FIT Image') self.wait_for_console_pattern('Starting kernel ...') --2.39.0
PATCH 8/25 hw/arm/boot: Export write_bootloader for Aspeed machines
In reply to Cédric Le GoaterAST2600 Aspeed machines have an home made boot loader for secondaries. To improve support, export the internal ARM boot loader and use it instead.
--- include/hw/arm/boot.h | 24 ++++++++++++++++++++++++ hw/arm/aspeed.c | 42 ++++++++++++++++++++++-------------------- hw/arm/boot.c | 34 +++++++--------------------------- 3 files changed, 53 insertions(+), 47 deletions(-)
include/hw/arm/boot.h +24 -0
@@ -183,4 +183,28 @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,const struct arm_boot_info *info, hwaddr mvbar_addr); +typedef enum { +FIXUP_NONE =0 ,/* do nothing */ +FIXUP_TERMINATOR ,/* end of insns */ +FIXUP_BOARDID ,/* overwrite with board ID number */ +FIXUP_BOARD_SETUP ,/* overwrite with board specific setup code address */ +FIXUP_ARGPTR_LO ,/* overwrite with pointer to kernel args */ +FIXUP_ARGPTR_HI ,/* overwrite with pointer to kernel args (high half) */ +FIXUP_ENTRYPOINT_LO ,/* overwrite with kernel entry point */ +FIXUP_ENTRYPOINT_HI ,/* overwrite with kernel entry point (high half) */ +FIXUP_GIC_CPU_IF ,/* overwrite with GIC CPU interface address */ +FIXUP_BOOTREG ,/* overwrite with boot register address */ +FIXUP_DSB ,/* overwrite with correct DSB insn for cpu */ +FIXUP_MAX , +}FixupType ; + +typedef struct ARMInsnFixup { +uint32_t insn; +FixupType fixup; +}ARMInsnFixup ; + +void arm_write_bootloader (const char *name,hwaddr addr, +const ARMInsnFixup *insns,uint32_t *fixupcontext, +AddressSpace *as); +#endif /* HW_ARM_BOOT_H */
hw/arm/aspeed.c +22 -20
55 lines not on this page · raw message
hw/arm/boot.c +7 -27
@@ -59,26 +59,6 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,return cpu_get_address_space (cs, asidx); } -typedef enum { -FIXUP_NONE =0 ,/* do nothing */ -FIXUP_TERMINATOR ,/* end of insns */ -FIXUP_BOARDID ,/* overwrite with board ID number */ -FIXUP_BOARD_SETUP ,/* overwrite with board specific setup code address */ -FIXUP_ARGPTR_LO ,/* overwrite with pointer to kernel args */ -FIXUP_ARGPTR_HI ,/* overwrite with pointer to kernel args (high half) */ -FIXUP_ENTRYPOINT_LO ,/* overwrite with kernel entry point */ -FIXUP_ENTRYPOINT_HI ,/* overwrite with kernel entry point (high half) */ -FIXUP_GIC_CPU_IF ,/* overwrite with GIC CPU interface address */ -FIXUP_BOOTREG ,/* overwrite with boot register address */ -FIXUP_DSB ,/* overwrite with correct DSB insn for cpu */ -FIXUP_MAX , -}FixupType ; - -typedef struct ARMInsnFixup { -uint32_t insn; -FixupType fixup; -}ARMInsnFixup ; -static const ARMInsnFixup bootloader_aarch64[] = { {0x580000c0 },/* ldr x0, arg ; Load the lower 32-bits of DTB */ {0xaa1f03e1 },/* mov x1, xzr */
@@ -149,9 +129,9 @@ static const ARMInsnFixup smpboot[] = { { 0, FIXUP_TERMINATOR } }; -static void write_bootloader (const char *name,hwaddr addr, -const ARMInsnFixup *insns,uint32_t *fixupcontext, -AddressSpace *as) +void arm_write_bootloader (const char *name,hwaddr addr, +const ARMInsnFixup *insns,uint32_t *fixupcontext, +AddressSpace *as) {/* Fix up the specified bootloader fragment and write it into * guest memory using rom_add_blob_fixed(). fixupcontext is
@@ -213,8 +193,8 @@ static void default_write_secondary(ARMCPU *cpu, fixupcontext[FIXUP_DSB ] =CP15_DSB_INSN ; } -write_bootloader ("smpboot" , info->smp_loader_start, - smpboot, fixupcontext, as); +arm_write_bootloader ("smpboot" , info->smp_loader_start, + smpboot, fixupcontext, as); } void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
@@ -1173,8 +1153,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, fixupcontext[FIXUP_ENTRYPOINT_LO ] = entry; fixupcontext[FIXUP_ENTRYPOINT_HI ] = entry >>32 ; -write_bootloader ("bootloader" , info->loader_start, - primary_loader, fixupcontext, as); +arm_write_bootloader ("bootloader" , info->loader_start, + primary_loader, fixupcontext, as);if (info->write_board_setup) { info->write_board_setup (cpu, info);
Signature · 1 line
2.39.0
Joel Stanley
maintainerRe: [PATCH 08/25] hw/arm/boot: Export write_bootloader for Aspeed machines
Quoted 4 lines · Cédric Le Goater
AST2600 Aspeed machines have an home made boot loader for secondaries. To improve support, export the internal ARM boot loader and use it instead.
I didn't quite follow why we're doing this. Is it just a cleanup?
Quoted 171 lines
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/arm/boot.h | 24 ++++++++++++++++++++++++ hw/arm/aspeed.c | 42 ++++++++++++++++++++++-------------------- hw/arm/boot.c | 34 +++++++--------------------------- 3 files changed, 53 insertions(+), 47 deletions(-)include/hw/arm/boot.h +24
-0@@ -183,4 +183,28 @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,const struct arm_boot_info *info, hwaddr mvbar_addr); +typedef enum { +FIXUP_NONE =0 ,/* do nothing */ +FIXUP_TERMINATOR ,/* end of insns */ +FIXUP_BOARDID ,/* overwrite with board ID number */ +FIXUP_BOARD_SETUP ,/* overwrite with board specific setup code address */ +FIXUP_ARGPTR_LO ,/* overwrite with pointer to kernel args */ +FIXUP_ARGPTR_HI ,/* overwrite with pointer to kernel args (high half) */ +FIXUP_ENTRYPOINT_LO ,/* overwrite with kernel entry point */ +FIXUP_ENTRYPOINT_HI ,/* overwrite with kernel entry point (high half) */ +FIXUP_GIC_CPU_IF ,/* overwrite with GIC CPU interface address */ +FIXUP_BOOTREG ,/* overwrite with boot register address */ +FIXUP_DSB ,/* overwrite with correct DSB insn for cpu */ +FIXUP_MAX , +}FixupType ; + +typedef struct ARMInsnFixup { +uint32_t insn; +FixupType fixup; +}ARMInsnFixup ; + +void arm_write_bootloader (const char *name,hwaddr addr, +const ARMInsnFixup *insns,uint32_t *fixupcontext, +AddressSpace *as); +#endif /* HW_ARM_BOOT_H */ hw/arm/aspeed.c +22
-20@@ -198,33 +198,35 @@ struct AspeedMachineState {static void aspeed_write_smpboot (ARMCPU *cpu,const struct arm_boot_info *info) { -static const uint32_t poll_mailbox_ready[] = { +AddressSpace *as =arm_boot_address_space (cpu, info); +static const ARMInsnFixup poll_mailbox_ready[] = {/* * r2 = per-cpu go sign value * r1 = AST_SMP_MBOX_FIELD_ENTRY * r0 = AST_SMP_MBOX_FIELD_GOSIGN */ -0xee100fb0 ,/* mrc p15, 0, r0, c0, c0, 5 */ -0xe21000ff ,/* ands r0, r0, #255 */ -0xe59f201c ,/* ldr r2, [pc, #28] */ -0xe1822000 ,/* orr r2, r2, r0 */ - -0xe59f1018 ,/* ldr r1, [pc, #24] */ -0xe59f0018 ,/* ldr r0, [pc, #24] */ - -0xe320f002 ,/* wfe */ -0xe5904000 ,/* ldr r4, [r0] */ -0xe1520004 ,/* cmp r2, r4 */ -0x1afffffb ,/* bne <wfe> */ -0xe591f000 ,/* ldr pc, [r1] */ -AST_SMP_MBOX_GOSIGN , -AST_SMP_MBOX_FIELD_ENTRY , -AST_SMP_MBOX_FIELD_GOSIGN , + {0xee100fb0 },/* mrc p15, 0, r0, c0, c0, 5 */ + {0xe21000ff },/* ands r0, r0, #255 */ + {0xe59f201c },/* ldr r2, [pc, #28] */ + {0xe1822000 },/* orr r2, r2, r0 */ + + {0xe59f1018 },/* ldr r1, [pc, #24] */ + {0xe59f0018 },/* ldr r0, [pc, #24] */ + + {0xe320f002 },/* wfe */ + {0xe5904000 },/* ldr r4, [r0] */ + {0xe1520004 },/* cmp r2, r4 */ + {0x1afffffb },/* bne <wfe> */ + {0xe591f000 },/* ldr pc, [r1] */ + {AST_SMP_MBOX_GOSIGN }, + {AST_SMP_MBOX_FIELD_ENTRY }, + {AST_SMP_MBOX_FIELD_GOSIGN }, + {0 ,FIXUP_TERMINATOR } }; +uint32_t fixupcontext[FIXUP_MAX ] = {0 }; -rom_add_blob_fixed ("aspeed.smpboot" , poll_mailbox_ready, -sizeof (poll_mailbox_ready), - info->smp_loader_start); +arm_write_bootloader ("aspeed.smpboot" , info->smp_loader_start, + poll_mailbox_ready, fixupcontext, as); } static void aspeed_reset_secondary(ARMCPU *cpu,hw/arm/boot.c +7
-28@@ -59,26 +59,6 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,return cpu_get_address_space (cs, asidx); } -typedef enum { -FIXUP_NONE =0 ,/* do nothing */ -FIXUP_TERMINATOR ,/* end of insns */ -FIXUP_BOARDID ,/* overwrite with board ID number */ -FIXUP_BOARD_SETUP ,/* overwrite with board specific setup code address */ -FIXUP_ARGPTR_LO ,/* overwrite with pointer to kernel args */ -FIXUP_ARGPTR_HI ,/* overwrite with pointer to kernel args (high half) */ -FIXUP_ENTRYPOINT_LO ,/* overwrite with kernel entry point */ -FIXUP_ENTRYPOINT_HI ,/* overwrite with kernel entry point (high half) */ -FIXUP_GIC_CPU_IF ,/* overwrite with GIC CPU interface address */ -FIXUP_BOOTREG ,/* overwrite with boot register address */ -FIXUP_DSB ,/* overwrite with correct DSB insn for cpu */ -FIXUP_MAX , -}FixupType ; - -typedef struct ARMInsnFixup { -uint32_t insn; -FixupType fixup; -}ARMInsnFixup ; -static const ARMInsnFixup bootloader_aarch64[] = { {0x580000c0 },/* ldr x0, arg ; Load the lower 32-bits of DTB */ {0xaa1f03e1 },/* mov x1, xzr */ @@ -149,9 +129,9 @@ static const ARMInsnFixup smpboot[] = { { 0, FIXUP_TERMINATOR } }; -static void write_bootloader (const char *name,hwaddr addr, -const ARMInsnFixup *insns,uint32_t *fixupcontext, -AddressSpace *as) +void arm_write_bootloader (const char *name,hwaddr addr, +const ARMInsnFixup *insns,uint32_t *fixupcontext, +AddressSpace *as) {/* Fix up the specified bootloader fragment and write it into * guest memory using rom_add_blob_fixed(). fixupcontext is @@ -213,8 +193,8 @@ static void default_write_secondary(ARMCPU *cpu, fixupcontext[FIXUP_DSB ] =CP15_DSB_INSN ; } -write_bootloader ("smpboot" , info->smp_loader_start, - smpboot, fixupcontext, as); +arm_write_bootloader ("smpboot" , info->smp_loader_start, + smpboot, fixupcontext, as); } void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,@@ -1173,8 +1153,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, fixupcontext[FIXUP_ENTRYPOINT_LO ] = entry; fixupcontext[FIXUP_ENTRYPOINT_HI ] = entry >>32 ; -write_bootloader ("bootloader" , info->loader_start, - primary_loader, fixupcontext, as); +arm_write_bootloader ("bootloader" , info->loader_start, + primary_loader, fixupcontext, as);if (info->write_board_setup) { info->write_board_setup (cpu, info); --2.39.0
Re: [PATCH 08/25] hw/arm/boot: Export write_bootloader for Aspeed machines
Quoted 7 lines · Joel Stanley
Quoted 4 lines · Cédric Le Goater
AST2600 Aspeed machines have an home made boot loader for secondaries. To improve support, export the internal ARM boot loader and use it instead.
I didn't quite follow why we're doing this. Is it just a cleanup?
It comes from this discussion :
https://lore.kernel.org/qemu-devel/[email protected]/
I will leave Phil handle it. The patch is on the list now.
Thanks,
C.
Quoted 171 lines
Quoted 171 lines
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/arm/boot.h | 24 ++++++++++++++++++++++++ hw/arm/aspeed.c | 42 ++++++++++++++++++++++-------------------- hw/arm/boot.c | 34 +++++++--------------------------- 3 files changed, 53 insertions(+), 47 deletions(-)include/hw/arm/boot.h +24
-0@@ -183,4 +183,28 @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,const struct arm_boot_info *info, hwaddr mvbar_addr); +typedef enum { +FIXUP_NONE =0 ,/* do nothing */ +FIXUP_TERMINATOR ,/* end of insns */ +FIXUP_BOARDID ,/* overwrite with board ID number */ +FIXUP_BOARD_SETUP ,/* overwrite with board specific setup code address */ +FIXUP_ARGPTR_LO ,/* overwrite with pointer to kernel args */ +FIXUP_ARGPTR_HI ,/* overwrite with pointer to kernel args (high half) */ +FIXUP_ENTRYPOINT_LO ,/* overwrite with kernel entry point */ +FIXUP_ENTRYPOINT_HI ,/* overwrite with kernel entry point (high half) */ +FIXUP_GIC_CPU_IF ,/* overwrite with GIC CPU interface address */ +FIXUP_BOOTREG ,/* overwrite with boot register address */ +FIXUP_DSB ,/* overwrite with correct DSB insn for cpu */ +FIXUP_MAX , +}FixupType ; + +typedef struct ARMInsnFixup { +uint32_t insn; +FixupType fixup; +}ARMInsnFixup ; + +void arm_write_bootloader (const char *name,hwaddr addr, +const ARMInsnFixup *insns,uint32_t *fixupcontext, +AddressSpace *as); +#endif /* HW_ARM_BOOT_H */ hw/arm/aspeed.c +22
-20@@ -198,33 +198,35 @@ struct AspeedMachineState {static void aspeed_write_smpboot (ARMCPU *cpu,const struct arm_boot_info *info) { -static const uint32_t poll_mailbox_ready[] = { +AddressSpace *as =arm_boot_address_space (cpu, info); +static const ARMInsnFixup poll_mailbox_ready[] = {/* * r2 = per-cpu go sign value * r1 = AST_SMP_MBOX_FIELD_ENTRY * r0 = AST_SMP_MBOX_FIELD_GOSIGN */ -0xee100fb0 ,/* mrc p15, 0, r0, c0, c0, 5 */ -0xe21000ff ,/* ands r0, r0, #255 */ -0xe59f201c ,/* ldr r2, [pc, #28] */ -0xe1822000 ,/* orr r2, r2, r0 */ - -0xe59f1018 ,/* ldr r1, [pc, #24] */ -0xe59f0018 ,/* ldr r0, [pc, #24] */ - -0xe320f002 ,/* wfe */ -0xe5904000 ,/* ldr r4, [r0] */ -0xe1520004 ,/* cmp r2, r4 */ -0x1afffffb ,/* bne <wfe> */ -0xe591f000 ,/* ldr pc, [r1] */ -AST_SMP_MBOX_GOSIGN , -AST_SMP_MBOX_FIELD_ENTRY , -AST_SMP_MBOX_FIELD_GOSIGN , + {0xee100fb0 },/* mrc p15, 0, r0, c0, c0, 5 */ + {0xe21000ff },/* ands r0, r0, #255 */ + {0xe59f201c },/* ldr r2, [pc, #28] */ + {0xe1822000 },/* orr r2, r2, r0 */ + + {0xe59f1018 },/* ldr r1, [pc, #24] */ + {0xe59f0018 },/* ldr r0, [pc, #24] */ + + {0xe320f002 },/* wfe */ + {0xe5904000 },/* ldr r4, [r0] */ + {0xe1520004 },/* cmp r2, r4 */ + {0x1afffffb },/* bne <wfe> */ + {0xe591f000 },/* ldr pc, [r1] */ + {AST_SMP_MBOX_GOSIGN }, + {AST_SMP_MBOX_FIELD_ENTRY }, + {AST_SMP_MBOX_FIELD_GOSIGN }, + {0 ,FIXUP_TERMINATOR } }; +uint32_t fixupcontext[FIXUP_MAX ] = {0 }; -rom_add_blob_fixed ("aspeed.smpboot" , poll_mailbox_ready, -sizeof (poll_mailbox_ready), - info->smp_loader_start); +arm_write_bootloader ("aspeed.smpboot" , info->smp_loader_start, + poll_mailbox_ready, fixupcontext, as); } static void aspeed_reset_secondary(ARMCPU *cpu,hw/arm/boot.c +7
-28@@ -59,26 +59,6 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,return cpu_get_address_space (cs, asidx); } -typedef enum { -FIXUP_NONE =0 ,/* do nothing */ -FIXUP_TERMINATOR ,/* end of insns */ -FIXUP_BOARDID ,/* overwrite with board ID number */ -FIXUP_BOARD_SETUP ,/* overwrite with board specific setup code address */ -FIXUP_ARGPTR_LO ,/* overwrite with pointer to kernel args */ -FIXUP_ARGPTR_HI ,/* overwrite with pointer to kernel args (high half) */ -FIXUP_ENTRYPOINT_LO ,/* overwrite with kernel entry point */ -FIXUP_ENTRYPOINT_HI ,/* overwrite with kernel entry point (high half) */ -FIXUP_GIC_CPU_IF ,/* overwrite with GIC CPU interface address */ -FIXUP_BOOTREG ,/* overwrite with boot register address */ -FIXUP_DSB ,/* overwrite with correct DSB insn for cpu */ -FIXUP_MAX , -}FixupType ; - -typedef struct ARMInsnFixup { -uint32_t insn; -FixupType fixup; -}ARMInsnFixup ; -static const ARMInsnFixup bootloader_aarch64[] = { {0x580000c0 },/* ldr x0, arg ; Load the lower 32-bits of DTB */ {0xaa1f03e1 },/* mov x1, xzr */ @@ -149,9 +129,9 @@ static const ARMInsnFixup smpboot[] = { { 0, FIXUP_TERMINATOR } }; -static void write_bootloader (const char *name,hwaddr addr, -const ARMInsnFixup *insns,uint32_t *fixupcontext, -AddressSpace *as) +void arm_write_bootloader (const char *name,hwaddr addr, +const ARMInsnFixup *insns,uint32_t *fixupcontext, +AddressSpace *as) {/* Fix up the specified bootloader fragment and write it into * guest memory using rom_add_blob_fixed(). fixupcontext is @@ -213,8 +193,8 @@ static void default_write_secondary(ARMCPU *cpu, fixupcontext[FIXUP_DSB ] =CP15_DSB_INSN ; } -write_bootloader ("smpboot" , info->smp_loader_start, - smpboot, fixupcontext, as); +arm_write_bootloader ("smpboot" , info->smp_loader_start, + smpboot, fixupcontext, as); } void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,@@ -1173,8 +1153,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, fixupcontext[FIXUP_ENTRYPOINT_LO ] = entry; fixupcontext[FIXUP_ENTRYPOINT_HI ] = entry >>32 ; -write_bootloader ("bootloader" , info->loader_start, - primary_loader, fixupcontext, as); +arm_write_bootloader ("bootloader" , info->loader_start, + primary_loader, fixupcontext, as);if (info->write_board_setup) { info->write_board_setup (cpu, info); --2.39.0
Re: [PATCH 08/25] hw/arm/boot: Export write_bootloader for Aspeed machines
Quoted 7 lines · Cédric Le Goater
Quoted 6 lines · Joel Stanley
Quoted 4 lines · Cédric Le Goater
AST2600 Aspeed machines have an home made boot loader for secondaries. To improve support, export the internal ARM boot loader and use it instead.
Quoted 6 lines
Quoted 1 line
I didn't quite follow why we're doing this. Is it just a cleanup?
It comes from this discussion :
PATCH 9/25 hw/core/loader: Remove declarations of option_rom_has_mr/rom_file_has_mr
In reply to Cédric Le GoaterThese globals were moved to MachineClass by commit 71ae9e94d9 ("pc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass"). Finish cleanup.
--- include/hw/loader.h | 3 --- 1 file changed, 3 deletions(-)
include/hw/loader.h +0 -3
@@ -251,9 +251,6 @@ void pstrcpy_targphys(const char *name, hwaddr dest, int buf_size, const char *source); -extern bool option_rom_has_mr; -extern bool rom_file_has_mr; -ssize_t rom_add_file (const char *file,const char *fw_dir,hwaddr addr,int32_t bootindex,bool option_rom,MemoryRegion *mr,AddressSpace *as);
Signature · 1 line
2.39.0
Re: [PATCH 09/25] hw/core/loader: Remove declarations of option_rom_has_mr/rom_file_has_mr
Quoted 9 lines · Cédric Le Goater
These globals were moved to MachineClass by commit
71ae9e94d9("pc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass"). Finish cleanup.Cc Eduardo Habkost <[email protected]>Cc Marcel Apfelbaum <[email protected]>Reviewed-by Alex Bennée <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 22 lines
--- include/hw/loader.h | 3 --- 1 file changed, 3 deletions(-)include/hw/loader.h +0
-4@@ -251,9 +251,6 @@ void pstrcpy_targphys(const char *name, hwaddr dest, int buf_size, const char *source); -extern bool option_rom_has_mr; -extern bool rom_file_has_mr; -ssize_t rom_add_file (const char *file,const char *fw_dir,hwaddr addr,int32_t bootindex,bool option_rom,MemoryRegion *mr,AddressSpace *as); --2.39.0
PATCH 10/25 hw/arm: Extract at24c_eeprom_init helper from Aspeed and Nuvoton boards
In reply to Cédric Le GoaterFrom: Peter Delevoryas <[email protected]>
This helper is useful in board initialization because lets users initialize and realize an EEPROM on an I2C bus with a single function call.
--- include/hw/nvram/eeprom_at24c.h | 23 +++++++++++++++++++++++ hw/arm/aspeed.c | 10 +--------- hw/arm/npcm7xx_boards.c | 20 +++++--------------- hw/nvram/eeprom_at24c.c | 12 ++++++++++++ 4 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 include/hw/nvram/eeprom_at24c.h
include/hw/nvram/eeprom_at24c.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* SPDX-License-Identifier: GPL-2.0-only +*/ + +#ifndef EEPROM_AT24C_H +#define EEPROM_AT24C_H + +#include "hw/i2c/i2c.h" + +/* +* Create and realize an AT24C EEPROM device on the heap. +* @bus: I2C bus to put it on +* @address: I2C address of the EEPROM slave when put on a bus +* @rom_size: size of the EEPROM +* +* Create the device state structure, initialize it, put it on the specified +* @bus, and drop the reference to it (the device is realized). +*/ +I2CSlave *at24c_eeprom_init (I2CBus *bus,uint8_t address,uint32_t rom_size); + +#endif
hw/arm/aspeed.c +1 -9
@@ -17,6 +17,7 @@#include "hw/i2c/i2c_mux_pca954x.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/misc/pca9552.h" +#include "hw/nvram/eeprom_at24c.h" #include "hw/sensor/tmp105.h" #include "hw/misc/led.h" #include "hw/qdev-properties.h"
@@ -441,15 +442,6 @@ static void aspeed_machine_init(MachineState *machine)arm_load_kernel (ARM_CPU (first_cpu), machine, &aspeed_board_binfo); } -static void at24c_eeprom_init (I2CBus *bus,uint8_t addr,uint32_t rsize) -{ -I2CSlave *i2c_dev =i2c_slave_new ("at24c-eeprom" , addr); -DeviceState *dev =DEVICE (i2c_dev); - -qdev_prop_set_uint32 (dev,"rom-size" , rsize); -i2c_slave_realize_and_unref (i2c_dev, bus, &error_abort); -} -static void palmetto_bmc_i2c_init (AspeedMachineState *bmc) {AspeedSoCState *soc = &bmc->soc;
hw/arm/npcm7xx_boards.c +5 -15
@@ -21,6 +21,7 @@#include "hw/i2c/i2c_mux_pca954x.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/loader.h" +#include "hw/nvram/eeprom_at24c.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "qapi/error.h"
@@ -140,17 +141,6 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc, uint32_t num)return I2C_BUS (qdev_get_child_bus (DEVICE (&soc->smbus[num]),"i2c-bus" )); } -static void at24c_eeprom_init (NPCM7xxState *soc,int bus,uint8_t addr, -uint32_t rsize) -{ -I2CBus *i2c_bus =npcm7xx_i2c_get_bus (soc, bus); -I2CSlave *i2c_dev =i2c_slave_new ("at24c-eeprom" , addr); -DeviceState *dev =DEVICE (i2c_dev); - -qdev_prop_set_uint32 (dev,"rom-size" , rsize); -i2c_slave_realize_and_unref (i2c_dev, i2c_bus, &error_abort); -} -static void npcm7xx_init_pwm_splitter (NPCM7xxMachine *machine,NPCM7xxState *soc,const int *fan_counts) {
@@ -253,8 +243,8 @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc)i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,3 ),"tmp105" ,0x5c );i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,4 ),"tmp105" ,0x5c ); -at24c_eeprom_init (soc,9 ,0x55 ,8192 ); -at24c_eeprom_init (soc,10 ,0x55 ,8192 ); +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,9 ),0x55 ,8192 ); +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,10 ),0x55 ,8192 );/* * i2c-11:
@@ -360,7 +350,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,4 ),TYPE_PCA9548 ,0x77 ); -at24c_eeprom_init (soc,4 ,0x50 ,8192 );/* mbfru */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,4 ),0x50 ,8192 );/* mbfru */ i2c_mux =i2c_slave_create_simple (npcm7xx_i2c_get_bus (soc,13 ),TYPE_PCA9548 ,0x77 );
@@ -371,7 +361,7 @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,4 ),"tmp105" ,0x48 );i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ),"tmp105" ,0x49 ); -at24c_eeprom_init (soc,14 ,0x55 ,8192 );/* bmcfru */ +at24c_eeprom_init (npcm7xx_i2c_get_bus (soc,14 ),0x55 ,8192 );/* bmcfru */ /* TODO: Add remaining i2c devices. */ }
hw/nvram/eeprom_at24c.c +12 -0
@@ -12,6 +12,7 @@#include "qapi/error.h" #include "qemu/module.h" #include "hw/i2c/i2c.h" +#include "hw/nvram/eeprom_at24c.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h"
@@ -128,6 +129,17 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)return 0 ; } +I2CSlave *at24c_eeprom_init (I2CBus *bus,uint8_t address,uint32_t rom_size) +{ +I2CSlave *i2c_dev =i2c_slave_new (TYPE_AT24C_EE , address); +DeviceState *dev =DEVICE (i2c_dev); + +qdev_prop_set_uint32 (dev,"rom-size" , rom_size); +i2c_slave_realize_and_unref (i2c_dev, bus, &error_abort); + +return i2c_dev; +} +static void at24c_eeprom_realize (DeviceState *dev,Error **errp) {EEPROMState *ee =AT24C_EE (dev);
Signature · 1 line
2.39.0
PATCH 11/25 hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init
In reply to Cédric Le GoaterFrom: Peter Delevoryas <[email protected]>
aspeed_eeprom_init is an exact copy of at24c_eeprom_init, not needed.
--- hw/arm/aspeed.c | 95 ++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 52 deletions(-)
hw/arm/aspeed.c +43 -52
@@ -672,15 +672,6 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc) eeprom_buf); } -static void aspeed_eeprom_init (I2CBus *bus,uint8_t addr,uint32_t rsize) -{ -I2CSlave *i2c_dev =i2c_slave_new ("at24c-eeprom" , addr); -DeviceState *dev =DEVICE (i2c_dev); - -qdev_prop_set_uint32 (dev,"rom-size" , rsize); -i2c_slave_realize_and_unref (i2c_dev, bus, &error_abort); -} -static void fp5280g2_bmc_i2c_init (AspeedMachineState *bmc) {AspeedSoCState *soc = &bmc->soc;
@@ -713,7 +704,7 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)AspeedSoCState *soc = &bmc->soc;I2CSlave *i2c_mux; -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,0 ),0x51 ,32 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,0 ),0x51 ,32 * KiB);create_pca9552 (soc,3 ,0x61 );
@@ -726,9 +717,9 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) 0x4a); i2c_mux =i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,4 ),"pca9546" ,0x70 ); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,2 ),0x52 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,2 ),0x52 ,64 * KiB);create_pca9552 (soc,4 ,0x60 ); i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105,
@@ -739,8 +730,8 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)create_pca9552 (soc,5 ,0x61 ); i2c_mux =i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,5 ),"pca9546" ,0x70 ); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB);i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,6 ),TYPE_TMP105 ,0x48 );
@@ -750,10 +741,10 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) 0x4b); i2c_mux =i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,6 ),"pca9546" ,0x70 ); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,2 ),0x50 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,3 ),0x51 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,2 ),0x50 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,3 ),0x51 ,64 * KiB);create_pca9552 (soc,7 ,0x30 );create_pca9552 (soc,7 ,0x31 );
@@ -766,15 +757,15 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,7 ),TYPE_TMP105 ,0x48 );i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,7 ),"max31785" ,0x52 ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,7 ),0x50 ,64 * KiB); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,7 ),0x51 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,7 ),0x50 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,7 ),0x51 ,64 * KiB);i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,8 ),TYPE_TMP105 ,0x48 );i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,8 ),TYPE_TMP105 ,0x4a ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,8 ),0x50 ,64 * KiB); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,8 ),0x51 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,8 ),0x50 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,8 ),0x51 ,64 * KiB);create_pca9552 (soc,8 ,0x60 );create_pca9552 (soc,8 ,0x61 );/* Bus 8: ucd90320@11 */
@@ -783,11 +774,11 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc)i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp423" ,0x4c );i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp423" ,0x4d ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,9 ),0x50 ,128 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,9 ),0x50 ,128 * KiB);i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,10 ),"tmp423" ,0x4c );i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,10 ),"tmp423" ,0x4d ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,10 ),0x50 ,128 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,10 ),0x50 ,128 * KiB);i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),TYPE_TMP105 ,0x48 );
@@ -795,18 +786,18 @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) 0x49); i2c_mux =i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"pca9546" ,0x70 ); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); -aspeed_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,0 ),0x50 ,64 * KiB); +at24c_eeprom_init (pca954x_i2c_get_bus (i2c_mux,1 ),0x51 ,64 * KiB);create_pca9552 (soc,11 ,0x60 ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,13 ),0x50 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,13 ),0x50 ,64 * KiB);create_pca9552 (soc,13 ,0x60 ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,14 ),0x50 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,14 ),0x50 ,64 * KiB);create_pca9552 (soc,14 ,0x60 ); -aspeed_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,15 ),0x50 ,64 * KiB); +at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,15 ),0x50 ,64 * KiB);create_pca9552 (soc,15 ,0x60 ); }
@@ -850,45 +841,45 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)i2c_slave_create_simple (i2c[17 ],TYPE_LM75 ,0x4c );i2c_slave_create_simple (i2c[17 ],TYPE_LM75 ,0x4d ); -aspeed_eeprom_init (i2c[19 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[20 ],0x50 ,2 * KiB); -aspeed_eeprom_init (i2c[22 ],0x52 ,2 * KiB); +at24c_eeprom_init (i2c[19 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[20 ],0x50 ,2 * KiB); +at24c_eeprom_init (i2c[22 ],0x52 ,2 * KiB);i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x48 );i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x49 );i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x4a );i2c_slave_create_simple (i2c[3 ],TYPE_TMP422 ,0x4c ); -aspeed_eeprom_init (i2c[8 ],0x51 ,64 * KiB); +at24c_eeprom_init (i2c[8 ],0x51 ,64 * KiB);i2c_slave_create_simple (i2c[8 ],TYPE_LM75 ,0x4a );i2c_slave_create_simple (i2c[50 ],TYPE_LM75 ,0x4c ); -aspeed_eeprom_init (i2c[50 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[50 ],0x52 ,64 * KiB);i2c_slave_create_simple (i2c[51 ],TYPE_TMP75 ,0x48 );i2c_slave_create_simple (i2c[52 ],TYPE_TMP75 ,0x49 );i2c_slave_create_simple (i2c[59 ],TYPE_TMP75 ,0x48 );i2c_slave_create_simple (i2c[60 ],TYPE_TMP75 ,0x49 ); -aspeed_eeprom_init (i2c[65 ],0x53 ,64 * KiB); +at24c_eeprom_init (i2c[65 ],0x53 ,64 * KiB);i2c_slave_create_simple (i2c[66 ],TYPE_TMP75 ,0x49 );i2c_slave_create_simple (i2c[66 ],TYPE_TMP75 ,0x48 ); -aspeed_eeprom_init (i2c[68 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[69 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[70 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[71 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[68 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[69 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[70 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[71 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[73 ],0x53 ,64 * KiB); +at24c_eeprom_init (i2c[73 ],0x53 ,64 * KiB);i2c_slave_create_simple (i2c[74 ],TYPE_TMP75 ,0x49 );i2c_slave_create_simple (i2c[74 ],TYPE_TMP75 ,0x48 ); -aspeed_eeprom_init (i2c[76 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[77 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[78 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[79 ],0x52 ,64 * KiB); -aspeed_eeprom_init (i2c[28 ],0x50 ,2 * KiB); +at24c_eeprom_init (i2c[76 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[77 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[78 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[79 ],0x52 ,64 * KiB); +at24c_eeprom_init (i2c[28 ],0x50 ,2 * KiB);for (int i =0 ; i <8 ; i++) { -aspeed_eeprom_init (i2c[81 + i *8 ],0x56 ,64 * KiB); +at24c_eeprom_init (i2c[81 + i *8 ],0x56 ,64 * KiB);i2c_slave_create_simple (i2c[82 + i *8 ],TYPE_TMP75 ,0x48 );i2c_slave_create_simple (i2c[83 + i *8 ],TYPE_TMP75 ,0x4b );i2c_slave_create_simple (i2c[84 + i *8 ],TYPE_TMP75 ,0x4a );
@@ -959,11 +950,11 @@ static void fby35_i2c_init(AspeedMachineState *bmc)i2c_slave_create_simple (i2c[12 ],TYPE_LM75 ,0x4e );i2c_slave_create_simple (i2c[12 ],TYPE_LM75 ,0x4f ); -aspeed_eeprom_init (i2c[4 ],0x51 ,128 * KiB); -aspeed_eeprom_init (i2c[6 ],0x51 ,128 * KiB); -aspeed_eeprom_init (i2c[8 ],0x50 ,32 * KiB); -aspeed_eeprom_init (i2c[11 ],0x51 ,128 * KiB); -aspeed_eeprom_init (i2c[11 ],0x54 ,128 * KiB); +at24c_eeprom_init (i2c[4 ],0x51 ,128 * KiB); +at24c_eeprom_init (i2c[6 ],0x51 ,128 * KiB); +at24c_eeprom_init (i2c[8 ],0x50 ,32 * KiB); +at24c_eeprom_init (i2c[11 ],0x51 ,128 * KiB); +at24c_eeprom_init (i2c[11 ],0x54 ,128 * KiB);/* * TODO: There is a multi-master i2c connection to an AST1030 MiniBMC on
Signature · 1 line
2.39.0
PATCH 12/25 hw/nvram/eeprom_at24c: Add init_rom field and at24c_eeprom_init_rom helper
In reply to Cédric Le GoaterFrom: Peter Delevoryas <[email protected]>
Allows users to specify binary data to initialize an EEPROM, allowing users to emulate data programmed at manufacturing time.
- Added init_rom and init_rom_size attributes to TYPE_AT24C_EE
- Added at24c_eeprom_init_rom helper function to initialize attributes
- If -drive property is provided, it overrides init_rom data
--- include/hw/nvram/eeprom_at24c.h | 16 ++++++++++++++ hw/nvram/eeprom_at24c.c | 37 ++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 5 deletions(-)
include/hw/nvram/eeprom_at24c.h +16 -0
@@ -20,4 +20,20 @@*/ I2CSlave *at24c_eeprom_init (I2CBus *bus,uint8_t address,uint32_t rom_size); + +/* +* Create and realize an AT24C EEPROM device on the heap with initial data. +* @bus: I2C bus to put it on +* @address: I2C address of the EEPROM slave when put on a bus +* @rom_size: size of the EEPROM +* @init_rom: Array of bytes to initialize EEPROM memory with +* @init_rom_size: Size of @init_rom, must be less than or equal to @rom_size +* +* Create the device state structure, initialize it, put it on the specified +* @bus, and drop the reference to it (the device is realized). Copies the data +* from @init_rom to the beginning of the EEPROM memory buffer. +*/ +I2CSlave *at24c_eeprom_init_rom (I2CBus *bus,uint8_t address,uint32_t rom_size, +const uint8_t *init_rom,uint32_t init_rom_size); +#endif
hw/nvram/eeprom_at24c.c +32 -5
@@ -50,6 +50,9 @@ struct EEPROMState {uint8_t *mem;BlockBackend *blk; + +const uint8_t *init_rom; +uint32_t init_rom_size; }; static
@@ -131,19 +134,38 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)I2CSlave *at24c_eeprom_init (I2CBus *bus,uint8_t address,uint32_t rom_size) { -I2CSlave *i2c_dev =i2c_slave_new (TYPE_AT24C_EE , address); -DeviceState *dev =DEVICE (i2c_dev); +return at24c_eeprom_init_rom (bus, address, rom_size,NULL ,0 ); +} + +I2CSlave *at24c_eeprom_init_rom (I2CBus *bus,uint8_t address,uint32_t rom_size, +const uint8_t *init_rom,uint32_t init_rom_size) +{ +EEPROMState *s; + + s =AT24C_EE (qdev_new (TYPE_AT24C_EE )); + +qdev_prop_set_uint8 (DEVICE (s),"address" , address); +qdev_prop_set_uint32 (DEVICE (s),"rom-size" , rom_size); -qdev_prop_set_uint32 (dev,"rom-size" , rom_size); -i2c_slave_realize_and_unref (i2c_dev, bus, &error_abort); +/* TODO: Model init_rom with QOM properties. */ + s->init_rom = init_rom; + s->init_rom_size = init_rom_size; -return i2c_dev; +i2c_slave_realize_and_unref (I2C_SLAVE (s), bus, &error_abort); + +return I2C_SLAVE (s); }static void at24c_eeprom_realize (DeviceState *dev,Error **errp) {EEPROMState *ee =AT24C_EE (dev); +if (ee->init_rom_size > ee->rsize) { +error_setg (errp,"%s: init rom is larger than rom: %u > %u" , +TYPE_AT24C_EE , ee->init_rom_size, ee->rsize); +return ; + } +if (ee->blk) {int64_t len =blk_getlength (ee->blk);
@@ -163,6 +185,7 @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp) } ee->mem =g_malloc0 (ee->rsize); + } static
@@ -176,6 +199,10 @@ void at24c_eeprom_reset(DeviceState *state)memset (ee->mem,0 , ee->rsize); +if (ee->init_rom) { +memcpy (ee->mem, ee->init_rom,MIN (ee->init_rom_size, ee->rsize)); + } +if (ee->blk) {int ret =blk_pread (ee->blk,0 , ee->rsize, ee->mem,0 );
Signature · 1 line
2.39.0
PATCH 13/25 hw/arm/aspeed: Add aspeed_eeprom.c
In reply to Cédric Le GoaterFrom: Peter Delevoryas <[email protected]>
- Create aspeed_eeprom.c and aspeed_eeprom.h
- Include aspeed_eeprom.c in CONFIG_ASPEED meson source files
- Include aspeed_eeprom.h in aspeed.c
- Add fby35_bmc_fruid data
- Use new at24c_eeprom_init_rom helper to initialize BMC FRUID EEPROM with data from aspeed_eeprom.c
wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
qemu-system-aarch64 -machine fby35-bmc -nographic -mtdblock fby35.mtd
...
user: root
pass: 0penBmc
...
root@bmc-oob:~# fruid-util bb
FRU Information : Baseboard --------------- : ------------------ Chassis Type : Rack Mount Chassis Chassis Part Number : N/A Chassis Serial Number : N/A Board Mfg Date : Fri Jan 7 10:30:00 2022 Board Mfg : XXXXXX Board Product : Management Board wBMC Board Serial : XXXXXXXXXXXXX Board Part Number : XXXXXXXXXXXXXX Board FRU ID : 1.0 Board Custom Data 1 : XXXXXXXXX Board Custom Data 2 : XXXXXXXXXXXXXXXXXX Product Manufacturer : XXXXXX Product Name : Yosemite V3.5 EVT2 Product Part Number : XXXXXXXXXXXXXX Product Version : EVT2 Product Serial : XXXXXXXXXXXXX Product Asset Tag : XXXXXXX Product FRU ID : 1.0 Product Custom Data 1 : XXXXXXXXX Product Custom Data 2 : N/A root@bmc-oob:~# fruid-util bmc
FRU Information : BMC --------------- : ------------------ Board Mfg Date : Mon Jan 10 21:42:00 2022 Board Mfg : XXXXXX Board Product : BMC Storage Module Board Serial : XXXXXXXXXXXXX Board Part Number : XXXXXXXXXXXXXX Board FRU ID : 1.0 Board Custom Data 1 : XXXXXXXXX Board Custom Data 2 : XXXXXXXXXXXXXXXXXX Product Manufacturer : XXXXXX Product Name : Yosemite V3.5 EVT2 Product Part Number : XXXXXXXXXXXXXX Product Version : EVT2 Product Serial : XXXXXXXXXXXXX Product Asset Tag : XXXXXXX Product FRU ID : 1.0 Product Custom Data 1 : XXXXXXXXX Product Custom Data 2 : Config A root@bmc-oob:~# fruid-util nic
FRU Information : NIC --------------- : ------------------ Board Mfg Date : Tue Nov 2 08:51:00 2021 Board Mfg : XXXXXXXX Board Product : Mellanox ConnectX-6 DX OCP3.0 Board Serial : XXXXXXXXXXXXXXXXXXXXXXXX Board Part Number : XXXXXXXXXXXXXXXXXXXXX Board FRU ID : FRU Ver 0.02 Product Manufacturer : XXXXXXXX Product Name : Mellanox ConnectX-6 DX OCP3.0 Product Part Number : XXXXXXXXXXXXXXXXXXXXX Product Version : A9 Product Serial : XXXXXXXXXXXXXXXXXXXXXXXX Product Custom Data 3 : ConnectX-6 DX
--- hw/arm/aspeed_eeprom.h | 19 ++++++++++ hw/arm/aspeed.c | 10 ++++-- hw/arm/aspeed_eeprom.c | 81 ++++++++++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 1 + 4 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 hw/arm/aspeed_eeprom.h create mode 100644 hw/arm/aspeed_eeprom.c
hw/arm/aspeed_eeprom.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright (c) Meta Platforms, Inc. and affiliates. +* +* SPDX-License-Identifier: GPL-2.0-only +*/ + +#ifndef ASPEED_EEPROM_H +#define ASPEED_EEPROM_H + +#include "qemu/osdep.h" + +extern const uint8_t fby35_nic_fruid[]; +extern const size_t fby35_nic_fruid_len; +extern const uint8_t fby35_bb_fruid[]; +extern const size_t fby35_bb_fruid_len; +extern const uint8_t fby35_bmc_fruid[]; +extern const size_t fby35_bmc_fruid_len; + +#endif
hw/arm/aspeed.c +7 -3
@@ -14,6 +14,7 @@#include "hw/arm/boot.h" #include "hw/arm/aspeed.h" #include "hw/arm/aspeed_soc.h" +#include "hw/arm/aspeed_eeprom.h" #include "hw/i2c/i2c_mux_pca954x.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/misc/pca9552.h"
@@ -952,9 +953,12 @@ static void fby35_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init (i2c[4 ],0x51 ,128 * KiB);at24c_eeprom_init (i2c[6 ],0x51 ,128 * KiB); -at24c_eeprom_init (i2c[8 ],0x50 ,32 * KiB); -at24c_eeprom_init (i2c[11 ],0x51 ,128 * KiB); -at24c_eeprom_init (i2c[11 ],0x54 ,128 * KiB); +at24c_eeprom_init_rom (i2c[8 ],0x50 ,32 * KiB, fby35_nic_fruid, + fby35_nic_fruid_len); +at24c_eeprom_init_rom (i2c[11 ],0x51 ,128 * KiB, fby35_bb_fruid, + fby35_bb_fruid_len); +at24c_eeprom_init_rom (i2c[11 ],0x54 ,128 * KiB, fby35_bmc_fruid, + fby35_bmc_fruid_len);/* * TODO: There is a multi-master i2c connection to an AST1030 MiniBMC on
hw/arm/aspeed_eeprom.c new file +81 -0
81 lines not on this page · raw message
hw/arm/meson.build +1 -0
@@ -53,6 +53,7 @@ arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( 'aspeed.c', 'aspeed_ast2600.c', 'aspeed_ast10x0.c', + 'aspeed_eeprom.c', 'fby35.c')) arm_ss.add(when: 'CONFIG_MPS2', if_true: files('mps2.c')) arm_ss.add(when: 'CONFIG_MPS2', if_true: files('mps2-tz.c'))
Signature · 1 line
2.39.0
PATCH 14/25 hw/nvram/eeprom_at24c: Make reset behavior more like hardware
In reply to Cédric Le GoaterFrom: Peter Delevoryas <[email protected]>
EEPROM's are a form of non-volatile memory. After power-cycling an EEPROM, I would expect the I2C state machine to be reset to default values, but I wouldn't really expect the memory to change at all.
The current implementation of the at24c EEPROM resets its internal memory on reset. This matches the specification in docs/devel/reset.rst:
Cold reset is supported by every resettable object. In QEMU, it means we reset to the initial state corresponding to the start of QEMU; this might differ from what is a real hardware cold reset. It differs from other resets (like warm or bus resets) which may keep certain parts untouched.
But differs from my intuition. For example, if someone writes some information to an EEPROM, then AC power cycles their board, they would expect the EEPROM to retain that information. It's very useful to be able to test things like this in QEMU as well, to verify software instrumentation like determining the cause of a reboot.
--- hw/nvram/eeprom_at24c.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
hw/nvram/eeprom_at24c.c +10 -12
@@ -185,18 +185,6 @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp) } ee->mem =g_malloc0 (ee->rsize); - -} - -static -void at24c_eeprom_reset (DeviceState *state) -{ -EEPROMState *ee =AT24C_EE (state); - - ee->changed = false; - ee->cur =0 ; - ee->haveaddr =0 ; -memset (ee->mem,0 , ee->rsize);if (ee->init_rom) {
@@ -214,6 +202,16 @@ void at24c_eeprom_reset(DeviceState *state) } } +static +void at24c_eeprom_reset (DeviceState *state) +{ +EEPROMState *ee =AT24C_EE (state); + + ee->changed = false; + ee->cur =0 ; + ee->haveaddr =0 ; +} +static Property at24c_eeprom_props[] = {DEFINE_PROP_UINT32 ("rom-size" , EEPROMState, rsize,0 ),DEFINE_PROP_BOOL ("writable" , EEPROMState, writable, true),
Signature · 1 line
2.39.0
PATCH 15/25 target/arm: Allow users to set the number of VFP registers
In reply to Cédric Le GoaterCortex A7 CPUs with an FPU implementing VFPv4 without NEON support have 16 64-bit FPU registers and not 32 registers. Let users set the number of VFP registers with a CPU property.
The primary use case of this property is for the Cortex A7 of the Aspeed AST2600 SoC.
--- target/arm/cpu.h | 2 ++ hw/arm/aspeed_ast2600.c | 2 ++ target/arm/cpu.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+)
target/arm/cpu.h +2 -0
@@ -901,6 +901,8 @@ struct ArchCPU {bool has_pmu;/* CPU has VFP */ bool has_vfp; +/* CPU has 32 VFP registers */ +bool has_vfp_d32;/* CPU has Neon */ bool has_neon;/* CPU has M-profile DSP extension */
hw/arm/aspeed_ast2600.c +2 -0
@@ -309,6 +309,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->cpu[i]),"neon" , false, &error_abort); +object_property_set_bool (OBJECT (&s->cpu[i]),"vfp-d32" , false, + &error_abort);object_property_set_link (OBJECT (&s->cpu[i]),"memory" ,OBJECT (s->memory), &error_abort);
target/arm/cpu.c +31 -0
@@ -1269,6 +1269,9 @@ static Property arm_cpu_cfgend_property =static Property arm_cpu_has_vfp_property =DEFINE_PROP_BOOL ("vfp" ,ARMCPU , has_vfp, true); +static Property arm_cpu_has_vfp_d32_property = +DEFINE_PROP_BOOL ("vfp-d32" ,ARMCPU , has_vfp_d32, true); +static Property arm_cpu_has_neon_property =DEFINE_PROP_BOOL ("neon" ,ARMCPU , has_neon, true);
@@ -1400,6 +1403,14 @@ void arm_cpu_post_init(Object *obj) } } +if (cpu->has_vfp &&cpu_isar_feature (aa32_simd_r32, cpu)) { + cpu->has_vfp_d32 = true; +if (!kvm_enabled ()) { +qdev_property_add_static (DEVICE (obj), + &arm_cpu_has_vfp_d32_property); + } + } +if (arm_feature (&cpu->env,ARM_FEATURE_NEON )) { cpu->has_neon = true;if (!kvm_enabled ()) {
@@ -1661,6 +1672,26 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)return ; } +if (!cpu->has_vfp_d32 && +arm_feature (env,ARM_FEATURE_V8 ) && + !arm_feature (env,ARM_FEATURE_M )) { +error_setg (errp,"ARMv8A CPUs must have VFP32" ); +return ; + } + +if (cpu->has_vfp_d32 != cpu->has_neon) { +error_setg (errp,"ARM CPUs must have both VFP32 and Neon or neither" ); +return ; + } + +if (!cpu->has_vfp_d32) { +uint32_t u; + + u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; + } +if (!cpu->has_vfp) {uint64_t t;uint32_t u;
Signature · 1 line
2.39.0
Re: [PATCH 15/25] target/arm: Allow users to set the number of VFP registers
Quoted 70 lines · Cédric Le Goater
Cortex A7 CPUs with an FPU implementing VFPv4 without NEON support have 16 64-bit FPU registers and not 32 registers. Let users set the number of VFP registers with a CPU property.
The primary use case of this property is for the Cortex A7 of the Aspeed AST2600 SoC.
Signed-off-by Cédric Le Goater <[email protected]>--- target/arm/cpu.h | 2 ++ hw/arm/aspeed_ast2600.c | 2 ++ target/arm/cpu.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+)target/arm/cpu.h +2
-0@@ -901,6 +901,8 @@ struct ArchCPU {bool has_pmu;/* CPU has VFP */ bool has_vfp; +/* CPU has 32 VFP registers */ +bool has_vfp_d32;/* CPU has Neon */ bool has_neon;/* CPU has M-profile DSP extension */ hw/arm/aspeed_ast2600.c +2
-0@@ -309,6 +309,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->cpu[i]),"neon" , false, &error_abort); +object_property_set_bool (OBJECT (&s->cpu[i]),"vfp-d32" , false, + &error_abort);object_property_set_link (OBJECT (&s->cpu[i]),"memory" ,OBJECT (s->memory), &error_abort);target/arm/cpu.c +11
-0@@ -1269,6 +1269,9 @@ static Property arm_cpu_cfgend_property =static Property arm_cpu_has_vfp_property =DEFINE_PROP_BOOL ("vfp" ,ARMCPU , has_vfp, true); +static Property arm_cpu_has_vfp_d32_property = +DEFINE_PROP_BOOL ("vfp-d32" ,ARMCPU , has_vfp_d32, true); +static Property arm_cpu_has_neon_property =DEFINE_PROP_BOOL ("neon" ,ARMCPU , has_neon, true);@@ -1400,6 +1403,14 @@ void arm_cpu_post_init(Object *obj) } } +if (cpu->has_vfp &&cpu_isar_feature (aa32_simd_r32, cpu)) { + cpu->has_vfp_d32 = true; +if (!kvm_enabled ()) { +qdev_property_add_static (DEVICE (obj), + &arm_cpu_has_vfp_d32_property); + } + } +if (arm_feature (&cpu->env,ARM_FEATURE_NEON )) { cpu->has_neon = true;if (!kvm_enabled ()) {
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1680
Quoted 9 lines
target/arm/cpu.c +6
-0@@ -1661,6 +1672,26 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)return ; } +if (!cpu->has_vfp_d32 && +arm_feature (env,ARM_FEATURE_V8 ) && + !arm_feature (env,ARM_FEATURE_M )) { +error_setg (errp,"ARMv8A CPUs must have VFP32" ); +return ; + }
The specs say that the permitted values of the SIMDReg bits [3:0] in Armv8-A are 0b0000 and 0b0010. In Armv8-M, the possible values of the field are b0001. All other values are reserved.
This should be better :
if (arm_feature(env, ARM_FEATURE_V8)) {
if (arm_feature(env, ARM_FEATURE_M)) {
if (cpu->has_vfp_d32) {
error_setg(errp, "ARMv8-M CPUs do not support VFP-D32");
return;
}
} else if (!cpu->has_vfp_d32) {
error_setg(errp, "ARMv8-A CPUs must have VFP-D32");
return;
}
}?
Thanks,
C.
Quoted 16 lines
target/arm/cpu.c +13
-0+if (cpu->has_vfp_d32 != cpu->has_neon) { +error_setg (errp,"ARM CPUs must have both VFP32 and Neon or neither" ); +return ; + } + +if (!cpu->has_vfp_d32) { +uint32_t u; + + u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; + } +if (!cpu->has_vfp) {uint64_t t;uint32_t u;
Re: [PATCH 15/25] target/arm: Allow users to set the number of VFP registers
Quoted 75 lines · Cédric Le Goater
Quoted 73 lines · Cédric Le Goater
Cortex A7 CPUs with an FPU implementing VFPv4 without NEON support have 16 64-bit FPU registers and not 32 registers. Let users set the number of VFP registers with a CPU property.
The primary use case of this property is for the Cortex A7 of the Aspeed AST2600 SoC.
Signed-off-by Cédric Le Goater <[email protected]>--- target/arm/cpu.h | 2 ++ hw/arm/aspeed_ast2600.c | 2 ++ target/arm/cpu.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+)target/arm/cpu.h +2
-0@@ -901,6 +901,8 @@ struct ArchCPU {bool has_pmu;/* CPU has VFP */ bool has_vfp; +/* CPU has 32 VFP registers */ +bool has_vfp_d32;/* CPU has Neon */ bool has_neon;/* CPU has M-profile DSP extension */ hw/arm/aspeed_ast2600.c +2
-0@@ -309,6 +309,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->cpu[i]),"neon" , false, &error_abort); +object_property_set_bool (OBJECT (&s->cpu[i]),"vfp-d32" , false, + &error_abort);object_property_set_link (OBJECT (&s->cpu[i]),"memory" ,OBJECT (s->memory), &error_abort);target/arm/cpu.c +11
-0@@ -1269,6 +1269,9 @@ static Property arm_cpu_cfgend_property =static Property arm_cpu_has_vfp_property =DEFINE_PROP_BOOL ("vfp" ,ARMCPU , has_vfp, true); +static Property arm_cpu_has_vfp_d32_property = +DEFINE_PROP_BOOL ("vfp-d32" ,ARMCPU , has_vfp_d32, true); +static Property arm_cpu_has_neon_property =DEFINE_PROP_BOOL ("neon" ,ARMCPU , has_neon, true);@@ -1400,6 +1403,14 @@ void arm_cpu_post_init(Object *obj) } } +if (cpu->has_vfp &&cpu_isar_feature (aa32_simd_r32, cpu)) { + cpu->has_vfp_d32 = true; +if (!kvm_enabled ()) { +qdev_property_add_static (DEVICE (obj), + &arm_cpu_has_vfp_d32_property); + } + } +if (arm_feature (&cpu->env,ARM_FEATURE_NEON )) { cpu->has_neon = true;if (!kvm_enabled ()) {@@ -1661,6 +1672,26 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)return ; }
Quoted 4 lines
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1678
Quoted 4 lines
target/arm/cpu.c +4
-0+if (!cpu->has_vfp_d32 && +arm_feature (env,ARM_FEATURE_V8 ) && + !arm_feature (env,ARM_FEATURE_M )) { +error_setg (errp,"ARMv8A CPUs must have VFP32" );
I wonder if we should instead not create the property for v8A CPUs? That way there's no way for has_vfp_d32 to get set to false. But checking after the fact is fine too. (One day we might move away from the current setup where properties get set up per-object for Arm CPUs and towards a "the class of the object determines the properties it has" setup; the way we do it today is a bit odd for historical reasons.)
Quoted 7 lines
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1680
Quoted 2 lines
target/arm/cpu.c +2
-0+return ; + }The specs say that the permitted values of the SIMDReg bits [3:0] in Armv8-A are 0b0000 and 0b0010. In Armv8-M, the possible values of the field are b0001. All other values are reserved.
Quoted 5 lines
This should be better :
if (arm_feature(env, ARM_FEATURE_V8)) { if (arm_feature(env, ARM_FEATURE_M)) { if (cpu->has_vfp_d32) {
This is unreachable code, because we only set has_vfp_d32 to true and set up the property if the CPU has the aa32_simd_r32 feature; and v8M CPUs will never have that feature, so has_vfp_d32 must be false for them here.
(Put another way, we set up the property so we can only "downgrade" from 32 to 16 dregs, so there is no need to check whether a CPU that can't have 32 dregs still doesn't have 32 dregs.)
Quoted 10 lines
error_setg(errp, "ARMv8-M CPUs do not support VFP-D32"); return; } } else if (!cpu->has_vfp_d32) { error_setg(errp, "ARMv8-A CPUs must have VFP-D32"); return; } }?
thanks
-- PMM
PATCH 16/25 hw/watchdog/wdt_aspeed: Rename MMIO region size as 'iosize'
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid confusing two different things:
- the WDT I/O region size ('iosize')
- at which offset the SoC map the WDT ('offset') While it is often the same, we can map smaller region sizes at larger offsets.
Here we are interested in the I/O region size, so rename as 'iosize'.
--- include/hw/watchdog/wdt_aspeed.h | 2 +- hw/arm/aspeed_ast10x0.c | 4 ++-- hw/arm/aspeed_ast2600.c | 4 ++-- hw/arm/aspeed_soc.c | 4 ++-- hw/watchdog/wdt_aspeed.c | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-)
include/hw/watchdog/wdt_aspeed.h +1 -1
@@ -40,7 +40,7 @@ struct AspeedWDTState {struct AspeedWDTClass {SysBusDeviceClass parent_class; -uint32_t offset; +uint32_t iosize;uint32_t ext_pulse_width_mask;uint32_t reset_ctrl_reg;void (*reset_pulse)(AspeedWDTState *s,uint32_t property);
hw/arm/aspeed_ast10x0.c +2 -2
@@ -318,14 +318,14 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)/* Watch dog */ for (i =0 ; i < sc->wdts_num; i++) {AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]); +hwaddr wdt_offset = sc->memmap[ASPEED_DEV_WDT ] + i * awc->iosize;object_property_set_link (OBJECT (&s->wdt[i]),"scu" ,OBJECT (&s->scu), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->wdt[i]), errp)) {return ; } -aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->wdt[i]),0 , - sc->memmap[ASPEED_DEV_WDT ] + i * awc->offset); +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->wdt[i]),0 , wdt_offset); }/* GPIO */
hw/arm/aspeed_ast2600.c +2 -2
@@ -467,14 +467,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* Watch dog */ for (i =0 ; i < sc->wdts_num; i++) {AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]); +hwaddr wdt_offset = sc->memmap[ASPEED_DEV_WDT ] + i * awc->iosize;object_property_set_link (OBJECT (&s->wdt[i]),"scu" ,OBJECT (&s->scu), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->wdt[i]), errp)) {return ; } -aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->wdt[i]),0 , - sc->memmap[ASPEED_DEV_WDT ] + i * awc->offset); +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->wdt[i]),0 , wdt_offset); }/* RAM */
hw/arm/aspeed_soc.c +2 -2
@@ -386,14 +386,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)/* Watch dog */ for (i =0 ; i < sc->wdts_num; i++) {AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]); +hwaddr wdt_offset = sc->memmap[ASPEED_DEV_WDT ] + i * awc->iosize;object_property_set_link (OBJECT (&s->wdt[i]),"scu" ,OBJECT (&s->scu), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->wdt[i]), errp)) {return ; } -aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->wdt[i]),0 , - sc->memmap[ASPEED_DEV_WDT ] + i * awc->offset); +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->wdt[i]),0 , wdt_offset); }/* RAM */
hw/watchdog/wdt_aspeed.c +4 -4
@@ -309,7 +309,7 @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data)AspeedWDTClass *awc =ASPEED_WDT_CLASS (klass); dc->desc ="ASPEED 2400 Watchdog Controller" ; - awc->offset =0x20 ; + awc->iosize =0x20 ; awc->ext_pulse_width_mask =0xff ; awc->reset_ctrl_reg =SCU_RESET_CONTROL1 ; awc->wdt_reload = aspeed_wdt_reload;
@@ -346,7 +346,7 @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data)AspeedWDTClass *awc =ASPEED_WDT_CLASS (klass); dc->desc ="ASPEED 2500 Watchdog Controller" ; - awc->offset =0x20 ; + awc->iosize =0x20 ; awc->ext_pulse_width_mask =0xfffff ; awc->reset_ctrl_reg =SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse;
@@ -369,7 +369,7 @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data)AspeedWDTClass *awc =ASPEED_WDT_CLASS (klass); dc->desc ="ASPEED 2600 Watchdog Controller" ; - awc->offset =0x40 ; + awc->iosize =0x40 ; awc->ext_pulse_width_mask =0xfffff ;/* TODO */ awc->reset_ctrl_reg =AST2600_SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse;
@@ -392,7 +392,7 @@ static void aspeed_1030_wdt_class_init(ObjectClass *klass, void *data)AspeedWDTClass *awc =ASPEED_WDT_CLASS (klass); dc->desc ="ASPEED 1030 Watchdog Controller" ; - awc->offset =0x80 ; + awc->iosize =0x80 ; awc->ext_pulse_width_mask =0xfffff ;/* TODO */ awc->reset_ctrl_reg =AST2600_SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse;
Signature · 1 line
2.39.0
PATCH 17/25 hw/watchdog/wdt_aspeed: Extend MMIO range to cover more registers
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
When booting the Zephyr demo in [1] we get:
aspeed.io: unimplemented device write (size 4, offset 0x185128, value 0x030f1ff1) <-- aspeed.io: unimplemented device write (size 4, offset 0x18512c, value 0x03fffff1)
This corresponds to this Zephyr code [2]:
static int aspeed_wdt_init(const struct device *dev)
{
const struct aspeed_wdt_config *config = dev->config;
struct aspeed_wdt_data *const data = dev->data;
uint32_t reg_val; /* disable WDT by default */
reg_val = sys_read32(config->ctrl_base + WDT_CTRL_REG);
reg_val &= ~WDT_CTRL_ENABLE;
sys_write32(reg_val, config->ctrl_base + WDT_CTRL_REG);
sys_write32(data->rst_mask1,
config->ctrl_base + WDT_SW_RESET_MASK1_REG); <------
sys_write32(data->rst_mask2,
config->ctrl_base + WDT_SW_RESET_MASK2_REG);
return 0;}
The register definitions are [3]:
#define WDT_RELOAD_VAL_REG 0x0004 #define WDT_RESTART_REG 0x0008 #define WDT_CTRL_REG 0x000C #define WDT_TIMEOUT_STATUS_REG 0x0010 #define WDT_TIMEOUT_STATUS_CLR_REG 0x0014 #define WDT_RESET_MASK1_REG 0x001C #define WDT_RESET_MASK2_REG 0x0020 #define WDT_SW_RESET_MASK1_REG 0x0028 <------ #define WDT_SW_RESET_MASK2_REG 0x002C #define WDT_SW_RESET_CTRL_REG 0x0024
Currently QEMU only cover a MMIO region of size 0x20:
#define ASPEED_WDT_REGS_MAX (0x20 / 4)
Change to map the whole 'iosize' which might be bigger, covering the other registers. The MemoryRegionOps read/write handlers will report the accesses as out-of-bounds guest-errors, but the next commit will report them as unimplemented.
[1] https://github.com/AspeedTech-BMC/zephyr/releases/tag/v00.01.07
[2] https://github.com/AspeedTech-BMC/zephyr/commit/2e99f10ac27b
[3] https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/drivers/watchdog/wdt_aspeed.c#L31
--- hw/watchdog/wdt_aspeed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c +2 -1
@@ -260,6 +260,7 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) {SysBusDevice *sbd =SYS_BUS_DEVICE (dev);AspeedWDTState *s =ASPEED_WDT (dev); +AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (dev);assert (s->scu);
@@ -271,7 +272,7 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) s->pclk_freq =PCLK_HZ ;memory_region_init_io (&s->iomem,OBJECT (s), &aspeed_wdt_ops, s, -TYPE_ASPEED_WDT ,ASPEED_WDT_REGS_MAX *4 ); +TYPE_ASPEED_WDT , awc->iosize);sysbus_init_mmio (sbd, &s->iomem); }
Signature · 1 line
2.39.0
PATCH 18/25 hw/watchdog/wdt_aspeed: Log unimplemented registers as UNIMP level
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Add more Aspeed watchdog registers from [*].
Since guests can righteously access them, log the access at 'unimplemented' level instead of 'guest-errors'.
[*] https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/drivers/watchdog/wdt_aspeed.c#L31
--- include/hw/watchdog/wdt_aspeed.h | 2 +- hw/watchdog/wdt_aspeed.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
include/hw/watchdog/wdt_aspeed.h +1 -1
@@ -21,7 +21,7 @@ OBJECT_DECLARE_TYPE(AspeedWDTState, AspeedWDTClass, ASPEED_WDT)#define TYPE_ASPEED_2600_WDT TYPE_ASPEED_WDT "-ast2600"#define TYPE_ASPEED_1030_WDT TYPE_ASPEED_WDT "-ast1030" -#define ASPEED_WDT_REGS_MAX (0x20 / 4) +#define ASPEED_WDT_REGS_MAX (0x30 / 4)struct AspeedWDTState {/*< private >*/
hw/watchdog/wdt_aspeed.c +13 -0
@@ -42,6 +42,11 @@#define WDT_PUSH_PULL_MAGIC (0xA8 << 24)#define WDT_OPEN_DRAIN_MAGIC (0x8A << 24)#define WDT_RESET_MASK1 (0x1c / 4) +#define WDT_RESET_MASK2 (0x20 / 4) + +#define WDT_SW_RESET_CTRL (0x24 / 4) +#define WDT_SW_RESET_MASK1 (0x28 / 4) +#define WDT_SW_RESET_MASK2 (0x2c / 4)#define WDT_TIMEOUT_STATUS (0x10 / 4)#define WDT_TIMEOUT_CLEAR (0x14 / 4)
@@ -83,6 +88,10 @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size)return s->regs[WDT_RESET_MASK1 ];case WDT_TIMEOUT_STATUS :case WDT_TIMEOUT_CLEAR : +case WDT_RESET_MASK2 : +case WDT_SW_RESET_CTRL : +case WDT_SW_RESET_MASK1 : +case WDT_SW_RESET_MASK2 :qemu_log_mask (LOG_UNIMP ,"%s: uninmplemented read at offset 0x%" HWADDR_PRIx"\n" , __func__, offset);
@@ -190,6 +199,10 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,case WDT_TIMEOUT_STATUS :case WDT_TIMEOUT_CLEAR : +case WDT_RESET_MASK2 : +case WDT_SW_RESET_CTRL : +case WDT_SW_RESET_MASK1 : +case WDT_SW_RESET_MASK2 :qemu_log_mask (LOG_UNIMP ,"%s: uninmplemented write at offset 0x%" HWADDR_PRIx"\n" , __func__, offset);
Signature · 1 line
2.39.0
PATCH 19/25 hw/misc/aspeed_hace: Do not crash if address_space_map() failed
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
address_space_map() can fail:
uart:~$ hash test
sha256_test
tv[0]:
Segmentation fault: 11
Thread 3 "qemu-system-arm" received signal SIGSEGV, Segmentation fault.
gen_acc_mode_iov (req_len=0x7ffff18b7778, id=<optimized out>, iov=0x7ffff18b7780, s=0x555556ce0bd0)
at ../hw/misc/aspeed_hace.c:171
171 if (has_padding(s, &iov[id], *req_len, &total_msg_len, &pad_offset)) {
(gdb) bt
#0 gen_acc_mode_iov (req_len=0x7ffff18b7778, id=<optimized out>, iov=0x7ffff18b7780, s=0x555556ce0bd0)
at ../hw/misc/aspeed_hace.c:171
#1 do_hash_operation (s=s@entry=0x555556ce0bd0, algo=3, sg_mode=sg_mode@entry=true, acc_mode=acc_mode@entry=true)
at ../hw/misc/aspeed_hace.c:224
#2 0x00005555559bdbb8 in aspeed_hace_write (opaque=<optimized out>, addr=12, data=262488, size=<optimized out>)
at ../hw/misc/aspeed_hace.c:358This change doesn't fix much, but at least the guest can't crash QEMU anymore. Instead it is still usable:
uart:~$ hash test sha256_test tv[0]:hash_final error sha384_test tv[0]:hash_final error sha512_test tv[0]:hash_final error [00:00:06.278,000] <err> hace_global: HACE poll timeout [00:00:09.324,000] <err> hace_global: HACE poll timeout [00:00:12.261,000] <err> hace_global: HACE poll timeout uart:~$
--- hw/misc/aspeed_hace.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hw/misc/aspeed_hace.c +15 -6
@@ -193,6 +193,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,size_t digest_len =0 ;int niov =0 ;int i; +void *haddr;if (sg_mode) {uint32_t len =0 ;
@@ -217,9 +218,13 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode, addr &=SG_LIST_ADDR_MASK ; plen = len &SG_LIST_LEN_MASK ; - iov[i].iov_base =address_space_map (&s->dram_as, addr, &plen, false, -MEMTXATTRS_UNSPECIFIED ); - + haddr =address_space_map (&s->dram_as, addr, &plen, false, +MEMTXATTRS_UNSPECIFIED ); +if (haddr ==NULL ) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: qcrypto failed\n" , __func__); +return ; + } + iov[i].iov_base = haddr;if (acc_mode) { niov =gen_acc_mode_iov (s, iov, i, &plen);
@@ -230,10 +235,14 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode, }else {hwaddr len = s->regs[R_HASH_SRC_LEN ]; + haddr =address_space_map (&s->dram_as, s->regs[R_HASH_SRC ], + &len, false,MEMTXATTRS_UNSPECIFIED ); +if (haddr ==NULL ) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: qcrypto failed\n" , __func__); +return ; + } + iov[0 ].iov_base = haddr; iov[0 ].iov_len = len; - iov[0 ].iov_base =address_space_map (&s->dram_as, s->regs[R_HASH_SRC ], - &len, false, -MEMTXATTRS_UNSPECIFIED ); i =1 ;if (s->iov_count) {
Signature · 1 line
2.39.0
PATCH 20/25 hw/arm/aspeed_ast10x0: Add various unimplemented peripherals
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Based on booting Zephyr demo from [1] running QEMU with '-d unimp' and checking missing devices in [2].
[1] https://github.com/AspeedTech-BMC/zephyr/releases/tag/v00.01.07
[2] https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/dts/arm/aspeed/ast10x0.dtsi
--- include/hw/arm/aspeed_soc.h | 11 +++++++++++ hw/arm/aspeed_ast10x0.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
include/hw/arm/aspeed_soc.h +11 -0
@@ -44,6 +44,7 @@#define ASPEED_CPUS_NUM 2#define ASPEED_MACS_NUM 4#define ASPEED_UARTS_NUM 13 +#define ASPEED_JTAG_NUM 2struct AspeedSoCState {/*< private >*/
@@ -87,6 +88,11 @@ struct AspeedSoCState {UnimplementedDeviceState video;UnimplementedDeviceState emmc_boot_controller;UnimplementedDeviceState dpmcu; +UnimplementedDeviceState pwm; +UnimplementedDeviceState espi; +UnimplementedDeviceState udc; +UnimplementedDeviceState sgpiom; +UnimplementedDeviceState jtag[ASPEED_JTAG_NUM ]; };#define TYPE_ASPEED_SOC "aspeed-soc"
@@ -174,6 +180,11 @@ enum {ASPEED_DEV_DPMCU ,ASPEED_DEV_DP ,ASPEED_DEV_I3C , +ASPEED_DEV_ESPI , +ASPEED_DEV_UDC , +ASPEED_DEV_SGPIOM , +ASPEED_DEV_JTAG0 , + ASPEED_DEV_JTAG1, };qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int dev);
hw/arm/aspeed_ast10x0.c +35 -0
@@ -27,10 +27,15 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_FMC] = 0x7E620000, [ASPEED_DEV_SPI1] = 0x7E630000, [ASPEED_DEV_SPI2] = 0x7E640000, + [ASPEED_DEV_UDC] = 0x7E6A2000, [ASPEED_DEV_SCU] = 0x7E6E2000, + [ASPEED_DEV_JTAG0] = 0x7E6E4000, + [ASPEED_DEV_JTAG1] = 0x7E6E4100, [ASPEED_DEV_ADC] = 0x7E6E9000, + [ASPEED_DEV_ESPI] = 0x7E6EE000, [ASPEED_DEV_SBC] = 0x7E6F2000, [ASPEED_DEV_GPIO] = 0x7E780000, + [ASPEED_DEV_SGPIOM] = 0x7E780500, [ASPEED_DEV_TIMER1] = 0x7E782000, [ASPEED_DEV_UART1] = 0x7E783000, [ASPEED_DEV_UART2] = 0x7E78D000,
@@ -78,12 +83,17 @@ static const int aspeed_soc_ast1030_irqmap[] = { [ASPEED_DEV_LPC] = 35, [ASPEED_DEV_PECI] = 38, [ASPEED_DEV_FMC] = 39, + [ASPEED_DEV_ESPI] = 42, [ASPEED_DEV_PWM] = 44, [ASPEED_DEV_ADC] = 46, [ASPEED_DEV_SPI1] = 65, [ASPEED_DEV_SPI2] = 66, [ASPEED_DEV_I2C] = 110, /* 110 ~ 123 */ [ASPEED_DEV_KCS] = 138, /* 138 -> 142 */ + [ASPEED_DEV_UDC] = 9, + [ASPEED_DEV_SGPIOM] = 51, + [ASPEED_DEV_JTAG0] = 27, + [ASPEED_DEV_JTAG1] = 53, };static qemu_irq aspeed_soc_ast1030_get_irq (AspeedSoCState *s,int dev)
@@ -154,6 +164,15 @@ static void aspeed_soc_ast1030_init(Object *obj)object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"sbc-unimplemented" , &s->sbc_unimplemented,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"pwm" , &s->pwm,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"espi" , &s->espi,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"udc" , &s->udc,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"sgpiom" , &s->sgpiom, +TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"jtag[0]" , &s->jtag[0 ], +TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"jtag[1]" , &s->jtag[1 ], +TYPE_UNIMPLEMENTED_DEVICE ); }static void aspeed_soc_ast1030_realize (DeviceState *dev_soc,Error **errp)
@@ -336,6 +355,22 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) sc->memmap[ASPEED_DEV_GPIO]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->gpio),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_GPIO )); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->pwm),"aspeed.pwm" , + sc->memmap[ASPEED_DEV_PWM ],0x100 ); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->espi),"aspeed.espi" , + sc->memmap[ASPEED_DEV_ESPI ],0x800 ); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->udc),"aspeed.udc" , + sc->memmap[ASPEED_DEV_UDC ],0x1000 ); +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->sgpiom),"aspeed.sgpiom" , + sc->memmap[ASPEED_DEV_SGPIOM ],0x100 ); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->jtag[0 ]),"aspeed.jtag" , + sc->memmap[ASPEED_DEV_JTAG0 ],0x20 ); +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->jtag[1 ]),"aspeed.jtag" , + sc->memmap[ASPEED_DEV_JTAG1 ],0x20 ); }static void aspeed_soc_ast1030_class_init (ObjectClass *klass,void *data)
Signature · 1 line
2.39.0
Re: [PATCH 20/25] hw/arm/aspeed_ast10x0: Add various unimplemented peripherals
Quoted 6 lines · Cédric Le Goater
From: Philippe Mathieu-Daudé <[email protected]>
Based on booting Zephyr demo from [1] running QEMU with '-d unimp' and checking missing devices in [2].
Quoted 7 lines
[1] https://github.com/AspeedTech-BMC/zephyr/releases/tag/v00.01.07
[2] https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/dts/arm/aspeed/ast10x0.dtsiSigned-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Peter Delevoryas <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 66 lines
--- include/hw/arm/aspeed_soc.h | 11 +++++++++++ hw/arm/aspeed_ast10x0.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)include/hw/arm/aspeed_soc.h +11
-0@@ -44,6 +44,7 @@#define ASPEED_CPUS_NUM 2#define ASPEED_MACS_NUM 4#define ASPEED_UARTS_NUM 13 +#define ASPEED_JTAG_NUM 2struct AspeedSoCState {/*< private >*/ @@ -87,6 +88,11 @@ struct AspeedSoCState {UnimplementedDeviceState video;UnimplementedDeviceState emmc_boot_controller;UnimplementedDeviceState dpmcu; +UnimplementedDeviceState pwm; +UnimplementedDeviceState espi; +UnimplementedDeviceState udc; +UnimplementedDeviceState sgpiom; +UnimplementedDeviceState jtag[ASPEED_JTAG_NUM ]; };#define TYPE_ASPEED_SOC "aspeed-soc"@@ -174,6 +180,11 @@ enum {ASPEED_DEV_DPMCU ,ASPEED_DEV_DP ,ASPEED_DEV_I3C , +ASPEED_DEV_ESPI , +ASPEED_DEV_UDC , +ASPEED_DEV_SGPIOM , +ASPEED_DEV_JTAG0 , + ASPEED_DEV_JTAG1, };qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int dev);hw/arm/aspeed_ast10x0.c +6
-0@@ -27,10 +27,15 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_FMC] = 0x7E620000, [ASPEED_DEV_SPI1] = 0x7E630000, [ASPEED_DEV_SPI2] = 0x7E640000, + [ASPEED_DEV_UDC] = 0x7E6A2000, [ASPEED_DEV_SCU] = 0x7E6E2000, + [ASPEED_DEV_JTAG0] = 0x7E6E4000, + [ASPEED_DEV_JTAG1] = 0x7E6E4100, [ASPEED_DEV_ADC] = 0x7E6E9000, + [ASPEED_DEV_ESPI] = 0x7E6EE000, [ASPEED_DEV_SBC] = 0x7E6F2000, [ASPEED_DEV_GPIO] = 0x7E780000, + [ASPEED_DEV_SGPIOM] = 0x7E780500, [ASPEED_DEV_TIMER1] = 0x7E782000, [ASPEED_DEV_UART1] = 0x7E783000, [ASPEED_DEV_UART2] = 0x7E78D000,@@ -78,12 +83,17 @@ static const int aspeed_soc_ast1030_irqmap[] = { [ASPEED_DEV_LPC] = 35, [ASPEED_DEV_PECI] = 38, [ASPEED_DEV_FMC] = 39, + [ASPEED_DEV_ESPI] = 42,
hw/arm/aspeed_ast10x0.c static const int aspeed_soc_ast1030_irqmap[] = { · line 96
Quoted 10 lines
hw/arm/aspeed_ast10x0.c +4
-0[ASPEED_DEV_PWM] = 44, [ASPEED_DEV_ADC] = 46, [ASPEED_DEV_SPI1] = 65, [ASPEED_DEV_SPI2] = 66, [ASPEED_DEV_I2C] = 110, /* 110 ~ 123 */ [ASPEED_DEV_KCS] = 138, /* 138 -> 142 */ + [ASPEED_DEV_UDC] = 9, + [ASPEED_DEV_SGPIOM] = 51, + [ASPEED_DEV_JTAG0] = 27, + [ASPEED_DEV_JTAG1] = 53,
nit: The array is kind of sorted by irq number, these could probably go above?
Quoted 46 lines
hw/arm/aspeed_ast10x0.c +25
-1};static qemu_irq aspeed_soc_ast1030_get_irq (AspeedSoCState *s,int dev)@@ -154,6 +164,15 @@ static void aspeed_soc_ast1030_init(Object *obj)object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"sbc-unimplemented" , &s->sbc_unimplemented,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"pwm" , &s->pwm,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"espi" , &s->espi,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"udc" , &s->udc,TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"sgpiom" , &s->sgpiom, +TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"jtag[0]" , &s->jtag[0 ], +TYPE_UNIMPLEMENTED_DEVICE ); +object_initialize_child (obj,"jtag[1]" , &s->jtag[1 ], +TYPE_UNIMPLEMENTED_DEVICE ); }static void aspeed_soc_ast1030_realize (DeviceState *dev_soc,Error **errp)@@ -336,6 +355,22 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) sc->memmap[ASPEED_DEV_GPIO]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->gpio),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_GPIO )); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->pwm),"aspeed.pwm" , + sc->memmap[ASPEED_DEV_PWM ],0x100 ); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->espi),"aspeed.espi" , + sc->memmap[ASPEED_DEV_ESPI ],0x800 ); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->udc),"aspeed.udc" , + sc->memmap[ASPEED_DEV_UDC ],0x1000 ); +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->sgpiom),"aspeed.sgpiom" , + sc->memmap[ASPEED_DEV_SGPIOM ],0x100 ); + +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->jtag[0 ]),"aspeed.jtag" , + sc->memmap[ASPEED_DEV_JTAG0 ],0x20 ); +aspeed_mmio_map_unimplemented (s,SYS_BUS_DEVICE (&s->jtag[1 ]),"aspeed.jtag" , + sc->memmap[ASPEED_DEV_JTAG1 ],0x20 ); }static void aspeed_soc_ast1030_class_init (ObjectClass *klass,void *data) --2.39.0
PATCH 21/25 hw/arm/aspeed_ast10x0: Map I3C peripheral
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Since I don't have access to the datasheet, the relevant values were found in:
https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/dts/arm/aspeed/ast10x0.dtsi
--- hw/arm/aspeed_ast10x0.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
hw/arm/aspeed_ast10x0.c +16 -0
@@ -53,6 +53,7 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_WDT] = 0x7E785000, [ASPEED_DEV_LPC] = 0x7E789000, [ASPEED_DEV_PECI] = 0x7E78B000, + [ASPEED_DEV_I3C] = 0x7E7A0000, [ASPEED_DEV_I2C] = 0x7E7B0000, };
@@ -88,6 +89,7 @@ static const int aspeed_soc_ast1030_irqmap[] = { [ASPEED_DEV_ADC] = 46, [ASPEED_DEV_SPI1] = 65, [ASPEED_DEV_SPI2] = 66, + [ASPEED_DEV_I3C] = 102, /* 102 -> 105 */ [ASPEED_DEV_I2C] = 110, /* 110 ~ 123 */ [ASPEED_DEV_KCS] = 138, /* 138 -> 142 */ [ASPEED_DEV_UDC] = 9,
@@ -129,6 +131,8 @@ static void aspeed_soc_ast1030_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.i2c-%s" , socname);object_initialize_child (obj,"i2c" , &s->i2c, typename); +object_initialize_child (obj,"i3c" , &s->i3c,TYPE_ASPEED_I3C ); +snprintf (typename,sizeof (typename),"aspeed.timer-%s" , socname);object_initialize_child (obj,"timerctrl" , &s->timerctrl, typename);
@@ -239,6 +243,18 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c.busses[i]),0 , irq); } +/* I3C */ +if (!sysbus_realize (SYS_BUS_DEVICE (&s->i3c), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->i3c),0 , sc->memmap[ASPEED_DEV_I3C ]); +for (i =0 ; i <ASPEED_I3C_NR_DEVICES ; i++) { +qemu_irq irq =qdev_get_gpio_in (DEVICE (&s->armv7m), + sc->irqmap[ASPEED_DEV_I3C ] + i); +/* The AST1030 I3C controller has one IRQ per bus. */ +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i3c.devices[i]),0 , irq); + } +/* PECI */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->peci), errp)) {return ;
Signature · 1 line
2.39.0
PATCH 22/25 hw/arm/aspeed_ast10x0: Map the secure SRAM
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Some SRAM appears to be used by the Secure Boot unit and crypto accelerators. Name it 'secure sram'.
Note, the SRAM base address was already present but unused (the 'SBC' index is used for the MMIO peripheral).
Interestingly using CFLAGS=-Winitializer-overrides reports:
../hw/arm/aspeed_ast10x0.c:32:30: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
[ASPEED_DEV_SBC] = 0x7E6F2000,
^~~~~~~~~~
../hw/arm/aspeed_ast10x0.c:24:30: note: previous initialization is here
[ASPEED_DEV_SBC] = 0x79000000,
^~~~~~~~~~This fixes with Zephyr:
uart:~$ rsa test rsa test vector[0]: [00:00:26.156,000] <err> os: ***** BUS FAULT ***** [00:00:26.157,000] <err> os: Precise data bus error [00:00:26.157,000] <err> os: BFAR Address: 0x79000000 [00:00:26.158,000] <err> os: r0/a1: 0x79000000 r1/a2: 0x00000000 r2/a3: 0x00001800 [00:00:26.158,000] <err> os: r3/a4: 0x79001800 r12/ip: 0x00000800 r14/lr: 0x0001098d [00:00:26.158,000] <err> os: xpsr: 0x81000000 [00:00:26.158,000] <err> os: Faulting instruction address (r15/pc): 0x0001e1bc [00:00:26.158,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0 [00:00:26.158,000] <err> os: Current thread: 0x38248 (shell_uart) [00:00:26.165,000] <err> os: Halting system
--- include/hw/arm/aspeed_soc.h | 3 +++ hw/arm/aspeed_ast10x0.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
include/hw/arm/aspeed_soc.h +3 -0
@@ -71,6 +71,7 @@ struct AspeedSoCState {AspeedSMCState spi[ASPEED_SPIS_NUM ];EHCISysBusState ehci[ASPEED_EHCIS_NUM ];AspeedSBCState sbc; +MemoryRegion secsram;UnimplementedDeviceState sbc_unimplemented;AspeedSDMCState sdmc;AspeedWDTState wdt[ASPEED_WDTS_NUM ];
@@ -105,6 +106,7 @@ struct AspeedSoCClass {const char *cpu_type;uint32_t silicon_rev;uint64_t sram_size; +uint64_t secsram_size;int spis_num;int ehcis_num;int wdts_num;
@@ -143,6 +145,7 @@ enum {ASPEED_DEV_SCU ,ASPEED_DEV_ADC ,ASPEED_DEV_SBC , +ASPEED_DEV_SECSRAM ,ASPEED_DEV_EMMC_BC ,ASPEED_DEV_VIDEO , ASPEED_DEV_SRAM,
hw/arm/aspeed_ast10x0.c +10 -1
@@ -21,7 +21,7 @@static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_SRAM ] =0x00000000 , - [ASPEED_DEV_SBC ] =0x79000000 , + [ASPEED_DEV_SECSRAM ] =0x79000000 , [ASPEED_DEV_IOMEM ] =0x7E600000 , [ASPEED_DEV_PWM ] =0x7E610000 , [ASPEED_DEV_FMC ] =0x7E620000 ,
@@ -221,6 +221,14 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SRAM ], &s->sram); +memory_region_init_ram (&s->secsram,OBJECT (s),"sec.sram" , + sc->secsram_size, &err); +if (err !=NULL ) { +error_propagate (errp, err); +return ; + } +memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SECSRAM ], + &s->secsram);/* SCU */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->scu), errp)) {
@@ -400,6 +408,7 @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data) sc->cpu_type =ARM_CPU_TYPE_NAME ("cortex-m4" ); sc->silicon_rev =AST1030_A1_SILICON_REV ; sc->sram_size =0xc0000 ; + sc->secsram_size =0x40000 ;/* 256 * KiB */ sc->spis_num =2 ; sc->ehcis_num =0 ; sc->wdts_num =4 ;
Signature · 1 line
2.39.0
PATCH 23/25 hw/arm/aspeed_ast10x0: Map HACE peripheral
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Since I don't have access to the datasheet, the relevant values were found in:
https://github.com/AspeedTech-BMC/zephyr/blob/v00.01.08/dts/arm/aspeed/ast10x0.dtsi
Before on Zephyr:
uart:~$ hash test sha256_test tv[0]:hash_final error sha384_test tv[0]:hash_final error sha512_test tv[0]:hash_final error [00:00:06.278,000] <err> hace_global: HACE poll timeout [00:00:09.324,000] <err> hace_global: HACE poll timeout [00:00:12.261,000] <err> hace_global: HACE poll timeout
uart:~$ crypto aes256_cbc_vault aes256_cbc vault key 1 [00:00:06.699,000] <inf> hace_global: aspeed_crypto_session_setup [00:00:06.699,000] <inf> hace_global: data->cmd: 1c2098 [00:00:06.699,000] <inf> hace_global: crypto_data_src: 93340 [00:00:06.699,000] <inf> hace_global: crypto_data_dst: 93348 [00:00:06.699,000] <inf> hace_global: crypto_ctx_base: 93300 [00:00:06.699,000] <inf> hace_global: crypto_data_len: 80000040 [00:00:06.699,000] <inf> hace_global: crypto_cmd_reg: 11c2098 [00:00:09.743,000] <inf> hace_global: HACE_STS: 0 [00:00:09.743,000] <err> hace_global: HACE poll timeout [00:00:09.743,000] <err> crypto: CBC mode ENCRYPT - Failed [00:00:09.743,000] <inf> hace_global: aspeed_crypto_session_free uart:~$
After:
uart:~$ hash test sha256_test tv[0]:PASS tv[1]:PASS tv[2]:PASS tv[3]:PASS tv[4]:PASS sha384_test tv[0]:PASS tv[1]:PASS tv[2]:PASS tv[3]:PASS tv[4]:PASS tv[5]:PASS sha512_test tv[0]:PASS tv[1]:PASS tv[2]:PASS tv[3]:PASS tv[4]:PASS tv[5]:PASS
uart:~$ crypto aes256_cbc_vault aes256_cbc vault key 1 Was waiting for: 6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a ae 2d 8a 57 1e 03 ac 9c 9e b7 6f ac 45 af 8e 51 30 c8 1c 46 a3 5c e4 11 e5 fb c1 19 1a 0a 52 ef f6 9f 24 45 df 4f 9b 17 ad 2b 41 7b e6 6c 37 10
But got:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[00:00:05.771,000] <inf> hace_global: aspeed_crypto_session_setup
[00:00:05.772,000] <inf> hace_global: data->cmd: 1c2098
[00:00:05.772,000] <inf> hace_global: crypto_data_src: 93340
[00:00:05.772,000] <inf> hace_global: crypto_data_dst: 93348
[00:00:05.772,000] <inf> hace_global: crypto_ctx_base: 93300
[00:00:05.772,000] <inf> hace_global: crypto_data_len: 80000040
[00:00:05.772,000] <inf> hace_global: crypto_cmd_reg: 11c2098
[00:00:05.772,000] <inf> hace_global: HACE_STS: 1000
[00:00:05.772,000] <inf> crypto: Output length (encryption): 80
[00:00:05.772,000] <inf> hace_global: aspeed_crypto_session_free
[00:00:05.772,000] <inf> hace_global: aspeed_crypto_session_setup
[00:00:05.772,000] <inf> hace_global: data->cmd: 1c2018
[00:00:05.772,000] <inf> hace_global: crypto_data_src: 93340
[00:00:05.772,000] <inf> hace_global: crypto_data_dst: 93348
[00:00:05.772,000] <inf> hace_global: crypto_ctx_base: 93300
[00:00:05.772,000] <inf> hace_global: crypto_data_len: 80000040
[00:00:05.772,000] <inf> hace_global: crypto_cmd_reg: 11c2018
[00:00:05.772,000] <inf> hace_global: HACE_STS: 1000
[00:00:05.772,000] <inf> crypto: Output length (decryption): 64
[00:00:05.772,000] <err> crypto: CBC mode DECRYPT - Mismatch between plaintext and decrypted cipher text [00:00:05.774,000] <inf> hace_global: aspeed_crypto_session_free
uart:~$
--- hw/arm/aspeed_ast10x0.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/arm/aspeed_ast10x0.c +15 -0
@@ -28,6 +28,7 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_SPI1] = 0x7E630000, [ASPEED_DEV_SPI2] = 0x7E640000, [ASPEED_DEV_UDC] = 0x7E6A2000, + [ASPEED_DEV_HACE] = 0x7E6D0000, [ASPEED_DEV_SCU] = 0x7E6E2000, [ASPEED_DEV_JTAG0] = 0x7E6E4000, [ASPEED_DEV_JTAG1] = 0x7E6E4100,
@@ -165,6 +166,9 @@ static void aspeed_soc_ast1030_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.gpio-%s" , socname);object_initialize_child (obj,"gpio" , &s->gpio, typename); +snprintf (typename,sizeof (typename),"aspeed.hace-%s" , socname); +object_initialize_child (obj,"hace" , &s->hace, typename); +object_initialize_child (obj,"iomem" , &s->iomem,TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"sbc-unimplemented" , &s->sbc_unimplemented,TYPE_UNIMPLEMENTED_DEVICE );
@@ -358,6 +362,17 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) }aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->sbc),0 , sc->memmap[ASPEED_DEV_SBC ]); +/* HACE */ +object_property_set_link (OBJECT (&s->hace),"dram" ,OBJECT (&s->sram), + &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->hace), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->hace),0 , + sc->memmap[ASPEED_DEV_HACE ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->hace),0 , +aspeed_soc_get_irq (s,ASPEED_DEV_HACE )); +/* Watch dog */ for (i =0 ; i < sc->wdts_num; i++) {AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]);
Signature · 1 line
2.39.0
PATCH 24/25 hw/arm/aspeed_ast10x0: Add TODO comment to use Cortex-M4F
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
This SoC uses a Cortex-M4F. QEMU only implements a M4, which is good enough. Add a TODO note in case the M4F is added.
--- hw/arm/aspeed_ast10x0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/aspeed_ast10x0.c +1 -1
@@ -420,7 +420,7 @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data) dc->realize = aspeed_soc_ast1030_realize; sc->name ="ast1030-a1" ; - sc->cpu_type =ARM_CPU_TYPE_NAME ("cortex-m4" ); + sc->cpu_type =ARM_CPU_TYPE_NAME ("cortex-m4" );/* TODO cortex-m4f */ sc->silicon_rev =AST1030_A1_SILICON_REV ; sc->sram_size =0xc0000 ; sc->secsram_size =0x40000 ;/* 256 * KiB */
Signature · 1 line
2.39.0
PATCH 25/25 tests/avocado: Test Aspeed Zephyr SDK v00.01.08 on AST1030 board
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Add a very quick test that runs some commands in a Zephyr shell:
$ tests/venv/bin/avocado --show=app,console run -t os:zephyr tests/avocado (2/2) tests/avocado/machine_aspeed.py:AST1030Machine.test_ast1030_zephyros_1_07: console: *** Booting Zephyr OS build v00.01.07 *** console: ast1030_evb demo console: SOC: AST1030-A1 console: uart:~$ kernel stacks console: 0x36910 wdt_background (real size 1024): unused 988 usage 36 / 1024 (3 %) console: 0x36ad8 shell_uart (real size 4096): unused 3084 usage 1012 / 4096 (24 %) console: 0x2edb8 ADC0 (real size 400): unused 260 usage 140 / 400 (35 %) console: 0x2f0f0 ADC1 (real size 400): unused 260 usage 140 / 400 (35 %) console: 0x3b098 sysworkq (real size 1024): unused 860 usage 164 / 1024 (16 %) console: 0x36cc0 usbdworkq (real size 1024): unused 860 usage 164 / 1024 (16 %) console: 0x36bd8 usbworkq (real size 1024): unused 860 usage 164 / 1024 (16 %) console: 0x36a10 logging (real size 768): unused 548 usage 220 / 768 (28 %) console: 0x36ef8 idle 00 (real size 320): unused 268 usage 52 / 320 (16 %) console: 0x47800 IRQ 00 (real size 2048): unused 1504 usage 544 / 2048 (26 %) console: uart:~$ otp info scu console: SCU BIT reg_protect Description console: ____________________________________________________________________ console: 0x500 0x0 0x0 Disable ARM CM4 CPU boot (TXD5) console: 0x500 0x1 0x0 /Reserved console: 0x500 0x2 0x0 \ " console: 0x500 0x3 0x0 Address offset of single chip ABR mode console: 0x500 0x4 0x0 /Reserved console: 0x500 0x5 0x0 | " console: 0x500 0x6 0x0 | " console: 0x500 0x7 0x0 | " console: 0x500 0x8 0x0 | " console: 0x500 0x9 0x0 | " console: 0x500 0xA 0x0 | " console: 0x500 0xB 0x0 | " console: 0x500 0xC 0x0 | " console: 0x500 0xD 0x0 | " console: 0x500 0xE 0x0 | " console: 0x500 0xF 0x0 | " console: 0x500 0x10 0x0 \ " console: 0x500 0x11 0x0 Disabl3 ARM JTAG debug console: 0x500 0x12 0x0 /Reserved console: 0x500 0x13 0x0 | " console: 0x500 0x14 0x0 | " console: 0x500 0x15 0x0 | " console: 0x500 0x16 0x0 | " console: 0x500 0x17 0x0 | " console: 0x500 0x18 0x0 | " console: 0x500 0x19 0x0 | " console: 0x500 0x1A 0x0 | " console: 0x500 0x1B 0x0 | " console: 0x500 0x1C 0x0 | " console: 0x500 0x1D 0x0 | " console: 0x500 0x1E 0x0 | " console: 0x500 0x1F 0x0 \ " console: 0x510 0x0 0x0 /Reserved console: 0x510 0x1 0x0 | " console: 0x510 0x2 0x0 | " console: 0x510 0x3 0x0 \ " console: 0x510 0x4 0x0 Disable debug interfaces console: 0x510 0x5 0x0 /Reserved console: 0x510 0x6 0x0 | " console: 0x510 0x7 0x0 \ " console: 0x510 0x8 0x0 Enable boot from Uart5 by Pin Strap console: 0x510 0x9 0x0 /Reserved console: 0x510 0xA 0x0 \ " console: 0x510 0xB 0x0 Enable boot SPI ABR console: 0x510 0xC 0x0 Boot SPI ABR Mode console: 0x510 0xD 0x0 /Boot SPI flash size console: 0x510 0xE 0x0 | " console: 0x510 0xF 0x0 \ " console: 0x510 0x10 0x0 /Reserved console: 0x510 0x11 0x0 | " console: 0x510 0x12 0x0 | " console: 0x510 0x13 0x0 | " console: 0x510 0x14 0x0 | " console: 0x510 0x15 0x0 \ " console: 0x510 0x16 0x0 Enable boot SPI auxiliary control pins console: 0x510 0x19 0x0 /Reserved console: 0x510 0x1A 0x0 | " console: 0x510 0x1B 0x0 | " console: 0x510 0x1C 0x0 | " console: 0x510 0x1D 0x0 | " console: 0x510 0x1E 0x0 | " console: 0x510 0x1F 0x0 \ " console: 0x510 0x1E 0x0 Enable dedicate GPIO strap pins console: 0x510 0x1F 0x0 Enable Secure Boot by Pin Strap console: uart:~$ hwinfo devid console: Length: 8 console: ID: 0x0000018000000180 console: uart:~$ crypto aes256_cbc_vault console: aes256_cbc vault key 1 console: Was waiting for: console: 6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a console: ae 2d 8a 57 1e 03 ac 9c 9e b7 6f ac 45 af 8e 51 console: 30 c8 1c 46 a3 5c e4 11 e5 fb c1 19 1a 0a 52 ef console: f6 9f 24 45 df 4f 9b 17 ad 2b 41 7b e6 6c 37 10 console: But got: console: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 console: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 console: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 console: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 console: uart:~$ random get console: 0x862460d console: uart:~$ i2c scan I2C_0 console: 0 1 2 3 4 5 6 7 8 9 a b c d e f console: 00: -- -- -- -- -- -- -- -- -- -- -- -- console: 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- console: 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- console: 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- console: 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- console: 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- console: 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- console: 70: -- -- -- -- -- -- -- -- console: 1 devices found on I2C_0 console: uart:~$ kernel uptime console: Uptime: 9897 ms console: uart:~$ kernel reboot warm console: *** Booting Zephyr OS build v00.01.07 *** PASS (1.08 s)
--- tests/avocado/machine_aspeed.py | 41 ++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-)
tests/avocado/machine_aspeed.py +40 -1
@@ -22,10 +22,11 @@ class AST1030Machine(QemuSystemTest): timeout = 10 - def test_ast1030_zephyros(self): + def test_ast1030_zephyros_1_04(self): """ :avocado: tags=arch:arm :avocado: tags=machine:ast1030-evb + :avocado: tags=os:zephyr """ tar_url = ('https://github.com/AspeedTech-BMC' '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
@@ -41,6 +42,44 @@ def test_ast1030_zephyros(self): exec_command_and_wait_for_pattern(self, "help", "Available commands") + def test_ast1030_zephyros_1_07(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:ast1030-evb + :avocado: tags=os:zephyr + """ + tar_url = ('https://github.com/AspeedTech-BMC' + '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip') + tar_hash = '40ac87eabdcd3b3454ce5aad11fedc72a33ecda2' + tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) + archive.extract(tar_path, self.workdir) + kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.bin" + self.vm.set_console() + self.vm.add_args('-kernel', kernel_file, + '-nographic') + self.vm.launch() + wait_for_console_pattern(self, "Booting Zephyr OS") + for shell_cmd in [ + 'kernel stacks', + 'otp info conf', + 'otp info scu', + 'hwinfo devid', + 'crypto aes256_cbc_vault', + 'random get', + 'jtag JTAG1 sw_xfer high TMS', + 'adc ADC0 resolution 12', + 'adc ADC0 read 42', + 'adc ADC1 read 69', + 'i2c scan I2C_0', + 'i3c attach I3C_0', + 'hash test', + 'kernel uptime', + 'kernel reboot warm', + 'kernel uptime', + 'kernel reboot cold', + 'kernel uptime', + ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") + class AST2x00Machine(QemuSystemTest): timeout = 90
Signature · 1 line
2.39.0