Message ID | 20240215132824.67363-3-philmd@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | hw/sparc/leon3: Trivial cleanups around write_bootloader() | expand |
On Thu, 15 Feb 2024 at 13:28, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Directly use the void pointer argument returned > by memory_region_get_ram_ptr(). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/sparc/leon3.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c > index d096fb04cb..8717c72e77 100644 > --- a/hw/sparc/leon3.c > +++ b/hw/sparc/leon3.c > @@ -94,9 +94,9 @@ static uint32_t *gen_store_u32(uint32_t *code, hwaddr addr, uint32_t val) > * state (eg: initialized by the bootloader). This little code reproduces > * this behavior. > */ > -static void write_bootloader(uint8_t *base, hwaddr kernel_addr) > +static void write_bootloader(void *ptr, hwaddr kernel_addr) > { > - uint32_t *p = (uint32_t *) base; > + uint32_t *p = (uint32_t *) ptr; I don't think you need the cast any more now ptr is void*. (If you do, then our coding style doesn't put a space after the cast.) > > /* Initialize the UARTs */ > /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */ > @@ -338,10 +338,7 @@ static void leon3_generic_hw_init(MachineState *machine) > * the machine in an initialized state through a little > * bootloader. > */ > - uint8_t *bootloader_entry; > - > - bootloader_entry = memory_region_get_ram_ptr(prom); > - write_bootloader(bootloader_entry, entry); > + write_bootloader(memory_region_get_ram_ptr(prom), entry); > env->pc = LEON3_PROM_OFFSET; > env->npc = LEON3_PROM_OFFSET + 4; > reset_info->entry = LEON3_PROM_OFFSET; > -- Either way, Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM
On 15/2/24 15:13, Peter Maydell wrote: > On Thu, 15 Feb 2024 at 13:28, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: >> >> Directly use the void pointer argument returned >> by memory_region_get_ram_ptr(). >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> --- >> hw/sparc/leon3.c | 9 +++------ >> 1 file changed, 3 insertions(+), 6 deletions(-) >> -static void write_bootloader(uint8_t *base, hwaddr kernel_addr) >> +static void write_bootloader(void *ptr, hwaddr kernel_addr) >> { >> - uint32_t *p = (uint32_t *) base; >> + uint32_t *p = (uint32_t *) ptr; > > I don't think you need the cast any more now ptr is void*. > (If you do, then our coding style doesn't put a space after > the cast.) Right, updated. > Either way, > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Thank you!
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index d096fb04cb..8717c72e77 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -94,9 +94,9 @@ static uint32_t *gen_store_u32(uint32_t *code, hwaddr addr, uint32_t val) * state (eg: initialized by the bootloader). This little code reproduces * this behavior. */ -static void write_bootloader(uint8_t *base, hwaddr kernel_addr) +static void write_bootloader(void *ptr, hwaddr kernel_addr) { - uint32_t *p = (uint32_t *) base; + uint32_t *p = (uint32_t *) ptr; /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */ @@ -338,10 +338,7 @@ static void leon3_generic_hw_init(MachineState *machine) * the machine in an initialized state through a little * bootloader. */ - uint8_t *bootloader_entry; - - bootloader_entry = memory_region_get_ram_ptr(prom); - write_bootloader(bootloader_entry, entry); + write_bootloader(memory_region_get_ram_ptr(prom), entry); env->pc = LEON3_PROM_OFFSET; env->npc = LEON3_PROM_OFFSET + 4; reset_info->entry = LEON3_PROM_OFFSET;
Directly use the void pointer argument returned by memory_region_get_ram_ptr(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/sparc/leon3.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)