Message ID | 20221227064812.1903326-4-bmeng@tinylab.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/riscv: Improve Spike HTIF emulation fidelity | expand |
On 12/27/22 03:48, Bin Meng wrote: > struct HTIFState has 3 members for address space and memory region, > and are initialized during htif_mm_init(). But they are actually > useless. Drop them. > > Signed-off-by: Bin Meng <bmeng@tinylab.org> > --- Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > > include/hw/char/riscv_htif.h | 7 ++----- > hw/char/riscv_htif.c | 7 ++----- > hw/riscv/spike.c | 5 ++--- > 3 files changed, 6 insertions(+), 13 deletions(-) > > diff --git a/include/hw/char/riscv_htif.h b/include/hw/char/riscv_htif.h > index 3eccc1914f..6d172ebd6d 100644 > --- a/include/hw/char/riscv_htif.h > +++ b/include/hw/char/riscv_htif.h > @@ -34,9 +34,6 @@ typedef struct HTIFState { > hwaddr tohost_offset; > hwaddr fromhost_offset; > MemoryRegion mmio; > - MemoryRegion *address_space; > - MemoryRegion *main_mem; > - void *main_mem_ram_ptr; > > CPURISCVState *env; > CharBackend chr; > @@ -54,7 +51,7 @@ void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value, > bool htif_uses_elf_symbols(void); > > /* legacy pre qom */ > -HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, > - CPURISCVState *env, Chardev *chr, uint64_t nonelf_base); > +HTIFState *htif_mm_init(MemoryRegion *address_space, CPURISCVState *env, > + Chardev *chr, uint64_t nonelf_base); > > #endif > diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c > index 088556bb04..e7e319ca1d 100644 > --- a/hw/char/riscv_htif.c > +++ b/hw/char/riscv_htif.c > @@ -265,8 +265,8 @@ bool htif_uses_elf_symbols(void) > return (address_symbol_set == 3) ? true : false; > } > > -HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, > - CPURISCVState *env, Chardev *chr, uint64_t nonelf_base) > +HTIFState *htif_mm_init(MemoryRegion *address_space, CPURISCVState *env, > + Chardev *chr, uint64_t nonelf_base) > { > uint64_t base, size, tohost_offset, fromhost_offset; > > @@ -281,9 +281,6 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, > fromhost_offset = fromhost_addr - base; > > HTIFState *s = g_new0(HTIFState, 1); > - s->address_space = address_space; > - s->main_mem = main_mem; > - s->main_mem_ram_ptr = memory_region_get_ram_ptr(main_mem); > s->env = env; > s->tohost_offset = tohost_offset; > s->fromhost_offset = fromhost_offset; > diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c > index 1e1d752c00..82cf41ac27 100644 > --- a/hw/riscv/spike.c > +++ b/hw/riscv/spike.c > @@ -317,9 +317,8 @@ static void spike_board_init(MachineState *machine) > fdt_load_addr); > > /* initialize HTIF using symbols found in load_kernel */ > - htif_mm_init(system_memory, mask_rom, > - &s->soc[0].harts[0].env, serial_hd(0), > - memmap[SPIKE_HTIF].base); > + htif_mm_init(system_memory, &s->soc[0].harts[0].env, > + serial_hd(0), memmap[SPIKE_HTIF].base); > } > > static void spike_machine_instance_init(Object *obj)
On Tue, Dec 27, 2022 at 4:50 PM Bin Meng <bmeng@tinylab.org> wrote: > > struct HTIFState has 3 members for address space and memory region, > and are initialized during htif_mm_init(). But they are actually > useless. Drop them. > > Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > > include/hw/char/riscv_htif.h | 7 ++----- > hw/char/riscv_htif.c | 7 ++----- > hw/riscv/spike.c | 5 ++--- > 3 files changed, 6 insertions(+), 13 deletions(-) > > diff --git a/include/hw/char/riscv_htif.h b/include/hw/char/riscv_htif.h > index 3eccc1914f..6d172ebd6d 100644 > --- a/include/hw/char/riscv_htif.h > +++ b/include/hw/char/riscv_htif.h > @@ -34,9 +34,6 @@ typedef struct HTIFState { > hwaddr tohost_offset; > hwaddr fromhost_offset; > MemoryRegion mmio; > - MemoryRegion *address_space; > - MemoryRegion *main_mem; > - void *main_mem_ram_ptr; > > CPURISCVState *env; > CharBackend chr; > @@ -54,7 +51,7 @@ void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value, > bool htif_uses_elf_symbols(void); > > /* legacy pre qom */ > -HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, > - CPURISCVState *env, Chardev *chr, uint64_t nonelf_base); > +HTIFState *htif_mm_init(MemoryRegion *address_space, CPURISCVState *env, > + Chardev *chr, uint64_t nonelf_base); > > #endif > diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c > index 088556bb04..e7e319ca1d 100644 > --- a/hw/char/riscv_htif.c > +++ b/hw/char/riscv_htif.c > @@ -265,8 +265,8 @@ bool htif_uses_elf_symbols(void) > return (address_symbol_set == 3) ? true : false; > } > > -HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, > - CPURISCVState *env, Chardev *chr, uint64_t nonelf_base) > +HTIFState *htif_mm_init(MemoryRegion *address_space, CPURISCVState *env, > + Chardev *chr, uint64_t nonelf_base) > { > uint64_t base, size, tohost_offset, fromhost_offset; > > @@ -281,9 +281,6 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, > fromhost_offset = fromhost_addr - base; > > HTIFState *s = g_new0(HTIFState, 1); > - s->address_space = address_space; > - s->main_mem = main_mem; > - s->main_mem_ram_ptr = memory_region_get_ram_ptr(main_mem); > s->env = env; > s->tohost_offset = tohost_offset; > s->fromhost_offset = fromhost_offset; > diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c > index 1e1d752c00..82cf41ac27 100644 > --- a/hw/riscv/spike.c > +++ b/hw/riscv/spike.c > @@ -317,9 +317,8 @@ static void spike_board_init(MachineState *machine) > fdt_load_addr); > > /* initialize HTIF using symbols found in load_kernel */ > - htif_mm_init(system_memory, mask_rom, > - &s->soc[0].harts[0].env, serial_hd(0), > - memmap[SPIKE_HTIF].base); > + htif_mm_init(system_memory, &s->soc[0].harts[0].env, > + serial_hd(0), memmap[SPIKE_HTIF].base); > } > > static void spike_machine_instance_init(Object *obj) > -- > 2.34.1 > >
diff --git a/include/hw/char/riscv_htif.h b/include/hw/char/riscv_htif.h index 3eccc1914f..6d172ebd6d 100644 --- a/include/hw/char/riscv_htif.h +++ b/include/hw/char/riscv_htif.h @@ -34,9 +34,6 @@ typedef struct HTIFState { hwaddr tohost_offset; hwaddr fromhost_offset; MemoryRegion mmio; - MemoryRegion *address_space; - MemoryRegion *main_mem; - void *main_mem_ram_ptr; CPURISCVState *env; CharBackend chr; @@ -54,7 +51,7 @@ void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value, bool htif_uses_elf_symbols(void); /* legacy pre qom */ -HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, - CPURISCVState *env, Chardev *chr, uint64_t nonelf_base); +HTIFState *htif_mm_init(MemoryRegion *address_space, CPURISCVState *env, + Chardev *chr, uint64_t nonelf_base); #endif diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c index 088556bb04..e7e319ca1d 100644 --- a/hw/char/riscv_htif.c +++ b/hw/char/riscv_htif.c @@ -265,8 +265,8 @@ bool htif_uses_elf_symbols(void) return (address_symbol_set == 3) ? true : false; } -HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, - CPURISCVState *env, Chardev *chr, uint64_t nonelf_base) +HTIFState *htif_mm_init(MemoryRegion *address_space, CPURISCVState *env, + Chardev *chr, uint64_t nonelf_base) { uint64_t base, size, tohost_offset, fromhost_offset; @@ -281,9 +281,6 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, fromhost_offset = fromhost_addr - base; HTIFState *s = g_new0(HTIFState, 1); - s->address_space = address_space; - s->main_mem = main_mem; - s->main_mem_ram_ptr = memory_region_get_ram_ptr(main_mem); s->env = env; s->tohost_offset = tohost_offset; s->fromhost_offset = fromhost_offset; diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 1e1d752c00..82cf41ac27 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -317,9 +317,8 @@ static void spike_board_init(MachineState *machine) fdt_load_addr); /* initialize HTIF using symbols found in load_kernel */ - htif_mm_init(system_memory, mask_rom, - &s->soc[0].harts[0].env, serial_hd(0), - memmap[SPIKE_HTIF].base); + htif_mm_init(system_memory, &s->soc[0].harts[0].env, + serial_hd(0), memmap[SPIKE_HTIF].base); } static void spike_machine_instance_init(Object *obj)
struct HTIFState has 3 members for address space and memory region, and are initialized during htif_mm_init(). But they are actually useless. Drop them. Signed-off-by: Bin Meng <bmeng@tinylab.org> --- include/hw/char/riscv_htif.h | 7 ++----- hw/char/riscv_htif.c | 7 ++----- hw/riscv/spike.c | 5 ++--- 3 files changed, 6 insertions(+), 13 deletions(-)