Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darjeeling updates #70

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitlab-ci.d/opentitan/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ format:
script:
- scripts/opentitan/ot-format.sh --ci -i
- git status -s
- test $(git status -s | wc -l) -eq 0
- test -z "$(git status -s)" || git diff
- test -z "$(git status -s)"

tidy:
tags:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.d/opentitan/qemu-ot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
BAREMETAL_REF: "240604-2"
BAREMETAL_REF: "240606-1"
QEMU_BUILD_OPTS: ""

include:
Expand Down
3 changes: 2 additions & 1 deletion docs/opentitan/rom_ctrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ The ROM image ID may depend on the SoC.

* for EarlGrey which has a single ROM, the ID is expected to be `rom`.
* for a SoC with two ROMs, the IDs would be expected to be `rom0` and `rom1`.
* for a machine with multiple SoCs, the IDs would be additionnally prefixed with the SoC name.
* for a machine with multiple SoCs, the IDs would be additionnally prefixed with the SoC name and a
full stop, _e.g._ `soc0.rom0`

## Booting with and without ROM

Expand Down
10 changes: 5 additions & 5 deletions hw/misc/pulp_rv_dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,24 +497,24 @@ static void pulp_rv_dm_init(Object *obj)

/* Top-level MMIO */
memory_region_init_io(&s->regs, obj, &pulp_rv_dm_regs_ops, s,
TYPE_PULP_RV_DM "-regs", PULP_RV_DM_REGS_SIZE);
TYPE_PULP_RV_DM ".regs", PULP_RV_DM_REGS_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->regs);

/* Mem container content */
memory_region_init_io(&s->dmact, obj, &pulp_rv_dm_dmact_ops, s,
TYPE_PULP_RV_DM "-act", PULP_RV_DM_DMACT_SIZE);
TYPE_PULP_RV_DM ".act", PULP_RV_DM_DMACT_SIZE);
memory_region_add_subregion(&s->mem, PULP_RV_DM_DMACT_BASE, &s->dmact);

memory_region_init_ram_nomigrate(&s->prog, obj, TYPE_PULP_RV_DM "-prog",
memory_region_init_ram_nomigrate(&s->prog, obj, TYPE_PULP_RV_DM ".prog",
PULP_RV_DM_PROG_SIZE, &error_fatal);
memory_region_add_subregion(&s->mem, PULP_RV_DM_PROG_BASE, &s->prog);

memory_region_init_io(&s->dmflag, obj, &pulp_rv_dm_dmflag_ops, s,
TYPE_PULP_RV_DM "-flag", PULP_RV_DM_DMFLAG_SIZE);
TYPE_PULP_RV_DM ".flag", PULP_RV_DM_DMFLAG_SIZE);
memory_region_add_subregion(&s->mem, PULP_RV_DM_DMFLAG_BASE, &s->dmflag);
s->dmflag.disable_reentrancy_guard = true;

memory_region_init_rom_nomigrate(&s->rom, obj, TYPE_PULP_RV_DM "-rom",
memory_region_init_rom_nomigrate(&s->rom, obj, TYPE_PULP_RV_DM ".rom",
PULP_RV_DM_ROM_SIZE, &error_abort);
memory_region_add_subregion(&s->mem, PULP_RV_DM_ROM_BASE, &s->rom);

Expand Down
8 changes: 4 additions & 4 deletions hw/opentitan/ot_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1796,10 +1796,10 @@ static void ot_flash_realize(DeviceState *dev, Error **errp)

#if DATA_PART_USE_IO_OPS
memory_region_init_io(mr, OBJECT(dev), &ot_flash_mem_ops, s,
TYPE_OT_FLASH "-mem", size);
TYPE_OT_FLASH ".mem", size);
#else
/* there is no "memory_region_init_rom_ptr" - use ram_ptr variant and r/o */
memory_region_init_ram_ptr(mr, OBJECT(dev), TYPE_OT_FLASH "-mem", size,
memory_region_init_ram_ptr(mr, OBJECT(dev), TYPE_OT_FLASH ".mem", size,
(void *)s->flash.data);
mr->readonly = true;
#endif /* DATA_PART_USE_IO_OPS */
Expand All @@ -1812,11 +1812,11 @@ static void ot_flash_init(Object *obj)
OtFlashState *s = OT_FLASH(obj);

memory_region_init_io(&s->mmio.regs, obj, &ot_flash_regs_ops, s,
TYPE_OT_FLASH "-regs", REGS_SIZE);
TYPE_OT_FLASH ".regs", REGS_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio.regs);

memory_region_init_io(&s->mmio.csrs, obj, &ot_flash_csrs_ops, s,
TYPE_OT_FLASH "-csrs", CSRS_SIZE);
TYPE_OT_FLASH ".csrs", CSRS_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio.csrs);

s->regs = g_new0(uint32_t, REGS_COUNT);
Expand Down
4 changes: 2 additions & 2 deletions hw/opentitan/ot_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ static void ot_hmac_init(Object *obj)
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);

memory_region_init_io(&s->regs_mmio, obj, &ot_hmac_regs_ops, s,
TYPE_OT_HMAC "-regs", REGS_SIZE);
TYPE_OT_HMAC ".regs", REGS_SIZE);
memory_region_add_subregion(&s->mmio, OT_HMAC_REGS_BASE, &s->regs_mmio);

memory_region_init_io(&s->fifo_mmio, obj, &ot_hmac_fifo_ops, s,
TYPE_OT_HMAC "-fifo", OT_HMAC_FIFO_SIZE);
TYPE_OT_HMAC ".fifo", OT_HMAC_FIFO_SIZE);
memory_region_add_subregion(&s->mmio, OT_HMAC_FIFO_BASE, &s->fifo_mmio);

/* setup FIFO Interrupt Timer */
Expand Down
6 changes: 3 additions & 3 deletions hw/opentitan/ot_kmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,15 +1634,15 @@ static void ot_kmac_init(Object *obj)
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);

memory_region_init_io(&s->regs_mmio, obj, &ot_kmac_regs_ops, s,
TYPE_OT_KMAC "-regs", REGS_SIZE);
TYPE_OT_KMAC ".regs", REGS_SIZE);
memory_region_add_subregion(&s->mmio, OT_KMAC_REGS_BASE, &s->regs_mmio);

memory_region_init_io(&s->state_mmio, obj, &ot_kmac_state_ops, s,
TYPE_OT_KMAC "-state", OT_KMAC_STATE_SIZE);
TYPE_OT_KMAC ".state", OT_KMAC_STATE_SIZE);
memory_region_add_subregion(&s->mmio, OT_KMAC_STATE_BASE, &s->state_mmio);

memory_region_init_io(&s->msgfifo_mmio, obj, &ot_kmac_msgfifo_ops, s,
TYPE_OT_KMAC "-msgfifo", OT_KMAC_MSG_FIFO_SIZE);
TYPE_OT_KMAC ".msgfifo", OT_KMAC_MSG_FIFO_SIZE);
memory_region_add_subregion(&s->mmio, OT_KMAC_MSG_FIFO_BASE,
&s->msgfifo_mmio);

Expand Down
6 changes: 3 additions & 3 deletions hw/opentitan/ot_otbn.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,23 +657,23 @@ static void ot_otbn_init(Object *obj)
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);

memory_region_init_io(&s->regs, obj, &ot_otbn_regs_ops, s,
TYPE_OT_OTBN "-regs", REGS_SIZE);
TYPE_OT_OTBN ".regs", REGS_SIZE);
memory_region_add_subregion(&s->mmio, OT_OTBN_REGS_BASE, &s->regs);

/*
* IMEM cannot be defined as a RAM region since accesses need to be
* controlled and checksum to be computed in-order
*/
memory_region_init_io(&s->imem, obj, &ot_otbn_imem_ops, s,
TYPE_OT_OTBN "-imem", OT_OTBN_IMEM_SIZE);
TYPE_OT_OTBN ".imem", OT_OTBN_IMEM_SIZE);
memory_region_add_subregion(&s->mmio, OT_OTBN_IMEM_BASE, &s->imem);

/*
* DMEM cannot be defined as a RAM region since accesses need to be
* controlled and checksum to be computed in-order
*/
memory_region_init_io(&s->dmem, obj, &ot_otbn_dmem_ops, s,
TYPE_OT_OTBN "-dmem", OT_OTBN_DMEM_SIZE);
TYPE_OT_OTBN ".dmem", OT_OTBN_DMEM_SIZE);
memory_region_add_subregion(&s->mmio, OT_OTBN_DMEM_BASE, &s->dmem);

ibex_sysbus_init_irq(obj, &s->irq_done);
Expand Down
8 changes: 4 additions & 4 deletions hw/opentitan/ot_otp_eg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,21 +1372,21 @@ static void ot_otp_eg_init(Object *obj)
{
OtOTPEgState *s = OT_OTP_EG(obj);

memory_region_init(&s->mmio.ctrl, obj, TYPE_OT_OTP "-ctrl", 0x2000u);
memory_region_init(&s->mmio.ctrl, obj, TYPE_OT_OTP ".ctrl", 0x2000u);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio.ctrl);

memory_region_init_io(&s->mmio.sub.regs, obj, &ot_otp_eg_regs_ops, s,
TYPE_OT_OTP "-regs", REGS_SIZE);
TYPE_OT_OTP ".regs", REGS_SIZE);
memory_region_add_subregion(&s->mmio.ctrl, 0u, &s->mmio.sub.regs);

/* TODO: it might be worthwhile to use a ROM-kind here */
memory_region_init_io(&s->mmio.sub.swcfg, obj, &ot_otp_eg_swcfg_ops, s,
TYPE_OT_OTP "-swcfg", SW_CFG_WINDOW_SIZE);
TYPE_OT_OTP ".swcfg", SW_CFG_WINDOW_SIZE);
memory_region_add_subregion(&s->mmio.ctrl, SW_CFG_WINDOW,
&s->mmio.sub.swcfg);

memory_region_init_io(&s->prim.csrs, obj, &ot_otp_eg_csrs_ops, s,
TYPE_OT_OTP "-prim", CSRS_SIZE);
TYPE_OT_OTP ".prim", CSRS_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->prim.csrs);

for (unsigned ix = 0; ix < ARRAY_SIZE(s->irqs); ix++) {
Expand Down
4 changes: 2 additions & 2 deletions hw/opentitan/ot_rom_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ static void ot_rom_ctrl_realize(DeviceState *dev, Error **errp)

memory_region_init_rom_device_nomigrate(&s->mem, OBJECT(dev),
&ot_rom_ctrl_mem_ops, s,
TYPE_OT_ROM_CTRL "-mem", s->size,
TYPE_OT_ROM_CTRL ".mem", s->size,
errp);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mem);

Expand All @@ -595,7 +595,7 @@ static void ot_rom_ctrl_init(Object *obj)
ibex_qdev_init_irq(obj, &s->pwrmgr_done, OT_ROM_CTRL_DONE);

memory_region_init_io(&s->mmio, obj, &ot_rom_ctrl_regs_ops, s,
TYPE_OT_ROM_CTRL "-regs", REGS_SIZE);
TYPE_OT_ROM_CTRL ".regs", REGS_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);

ibex_qdev_init_irq(obj, &s->alert, OT_DEVICE_ALERT);
Expand Down
8 changes: 4 additions & 4 deletions hw/opentitan/ot_spi_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -2631,19 +2631,19 @@ static void ot_spi_device_init(Object *obj)
SpiDeviceFlash *f = &s->flash;
SpiDeviceBus *bus = &s->bus;

memory_region_init(&s->mmio.main, obj, TYPE_OT_SPI_DEVICE "-mmio",
memory_region_init(&s->mmio.main, obj, TYPE_OT_SPI_DEVICE ".mmio",
SPI_DEVICE_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio.main);
memory_region_init_io(&s->mmio.spi, obj, &ot_spi_device_spi_regs_ops, s,
TYPE_OT_SPI_DEVICE "-spi-regs", SPI_REGS_SIZE);
TYPE_OT_SPI_DEVICE ".spi-regs", SPI_REGS_SIZE);
memory_region_add_subregion(&s->mmio.main, SPI_DEVICE_SPI_REGS_OFFSET,
&s->mmio.spi);
memory_region_init_io(&s->mmio.tpm, obj, &ot_spi_device_tpm_regs_ops, s,
TYPE_OT_SPI_DEVICE "-tpm-regs", TPM_REGS_SIZE);
TYPE_OT_SPI_DEVICE ".tpm-regs", TPM_REGS_SIZE);
memory_region_add_subregion(&s->mmio.main, SPI_DEVICE_TPM_REGS_OFFSET,
&s->mmio.tpm);
memory_region_init_io(&s->mmio.buf, obj, &ot_spi_device_buf_ops, s,
TYPE_OT_SPI_DEVICE "-buf", SRAM_SIZE);
TYPE_OT_SPI_DEVICE ".buf", SRAM_SIZE);
memory_region_add_subregion(&s->mmio.main, SPI_DEVICE_SRAM_OFFSET,
&s->mmio.buf);

Expand Down
36 changes: 24 additions & 12 deletions hw/opentitan/ot_sram_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,6 @@ static void ot_sram_ctrl_reset(DeviceState *dev)
{
OtSramCtrlState *s = OT_SRAM_CTRL(dev);

g_assert(s->ot_id);

memset(s->regs, 0, REGS_SIZE);

/* note: SRAM storage is -not- reset */
Expand Down Expand Up @@ -670,19 +668,27 @@ static void ot_sram_ctrl_realize(DeviceState *dev, Error **errp)

g_assert(s->size);

if (!s->ot_id) {
s->ot_id =
g_strdup(object_get_canonical_path_component(OBJECT(s)->parent));
}

s->wsize = DIV_ROUND_UP(s->size, sizeof(uint32_t));
unsigned size = s->wsize * sizeof(uint32_t);

char *mr_name;

if (s->noinit) {
/*
* when initialization feature is disabled, simply map the final memory
* region as the memory backend. Init-related arrays are left
* uninitialized and should not be used.
*/
memory_region_init_ram_nomigrate(&s->mem->sram, OBJECT(dev),
TYPE_OT_SRAM_CTRL "-mem", size, errp);
mr_name = g_strdup_printf(TYPE_OT_SRAM_CTRL ".%s.mem", s->ot_id);
memory_region_init_ram_nomigrate(&s->mem->sram, OBJECT(dev), mr_name,
size, errp);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mem->sram);

g_free(mr_name);
return;
}

Expand Down Expand Up @@ -715,11 +721,14 @@ static void ot_sram_ctrl_realize(DeviceState *dev, Error **errp)
s->init_slot_bm[s->init_slot_count - 1u] = (1ull << slot_offset) - 1u;
}

mr_name = g_strdup_printf(TYPE_OT_SRAM_CTRL ".%s.mem.init", s->ot_id);
memory_region_init_io(&s->mem->init, OBJECT(dev),
&ot_sram_ctrl_mem_init_ops, s,
TYPE_OT_SRAM_CTRL "-mem-init", size);
memory_region_init_ram_nomigrate(&s->mem->sram, OBJECT(dev),
TYPE_OT_SRAM_CTRL "-mem-sram", size, errp);
&ot_sram_ctrl_mem_init_ops, s, mr_name, size);
g_free(mr_name);
mr_name = g_strdup_printf(TYPE_OT_SRAM_CTRL ".%s.mem.sram", s->ot_id);
memory_region_init_ram_nomigrate(&s->mem->sram, OBJECT(dev), mr_name, size,
errp);
g_free(mr_name);

/*
* use an alias than points to the currently selected RAM backend, either
Expand All @@ -731,8 +740,11 @@ static void ot_sram_ctrl_realize(DeviceState *dev, Error **errp)
* backend is swapped. The alias enables to expose the same MemoryRegion
* object while changing its actual backend on initialization demand.
*/
memory_region_init_alias(&s->mem->alias, OBJECT(dev),
TYPE_OT_SRAM_CTRL "-mem", &s->mem->init, 0, size);
mr_name = g_strdup_printf(TYPE_OT_SRAM_CTRL ".%s.mem", s->ot_id);
memory_region_init_alias(&s->mem->alias, OBJECT(dev), mr_name,
&s->mem->init, 0, size);
g_free(mr_name);

/*
* at start up, the SRAM memory is aliased to the I/O backend, so that
* access can be controlled
Expand All @@ -745,7 +757,7 @@ static void ot_sram_ctrl_init(Object *obj)
OtSramCtrlState *s = OT_SRAM_CTRL(obj);

memory_region_init_io(&s->mmio, obj, &ot_sram_ctrl_regs_ops, s,
TYPE_OT_SRAM_CTRL "-regs", REGS_SIZE);
TYPE_OT_SRAM_CTRL ".regs", REGS_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);

ibex_qdev_init_irq(obj, &s->alert, OT_DEVICE_ALERT);
Expand Down
17 changes: 12 additions & 5 deletions hw/riscv/ibex_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ static void rust_demangle_fn(const char *st_name, int st_info,
uint64_t st_value, uint64_t st_size);

static void ibex_mmio_map_device(SysBusDevice *dev, MemoryRegion *mr,
unsigned nr, hwaddr addr)
unsigned nr, hwaddr addr, int priority)
{
g_assert(nr < dev->num_mmio);
g_assert(dev->mmio[nr].addr == (hwaddr)-1);
dev->mmio[nr].addr = addr;
memory_region_add_subregion(mr, addr, dev->mmio[nr].memory);
if (priority) {
memory_region_add_subregion_overlap(mr, addr, dev->mmio[nr].memory,
priority);
} else {
memory_region_add_subregion(mr, addr, dev->mmio[nr].memory);
}
}

DeviceState **ibex_create_devices(const IbexDeviceDef *defs, unsigned count,
Expand Down Expand Up @@ -251,7 +256,8 @@ void ibex_map_devices_mask(DeviceState **devices, MemoryRegion **mrs,
if (mr) {
ibex_mmio_map_device(busdev, mr, mem,
IBEX_MEMMAP_GET_ADDRESS(
memmap->base));
memmap->base),
memmap->priority);
}
}
mem++;
Expand Down Expand Up @@ -288,7 +294,8 @@ void ibex_map_devices_ext_mask(DeviceState *dev, MemoryRegion **mrs,
if (mr) {
ibex_mmio_map_device(sdev, mr, mem,
IBEX_MEMMAP_GET_ADDRESS(
memmap->base));
memmap->base),
memmap->priority);
}
}
}
Expand Down Expand Up @@ -516,7 +523,7 @@ void ibex_identify_devices(DeviceState **devices, const char *id_prop,

bool res;
if (is_set && id_prepend) {
char *pvalue = g_strconcat(id_value, value, NULL);
char *pvalue = g_strconcat(id_value, ".", value, NULL);
res = object_property_set_str(obj, id_prop, pvalue, NULL);
g_free(pvalue);
} else {
Expand Down
Loading
Loading