[PATCH 2/2] hw/sparc/leon3: Remove duplicated code

Philippe Mathieu-Daudé posted 2 patches 10 months ago
Maintainers: Fabien Chouteau <chouteau@adacore.com>, Frederic Konrad <konrad.frederic@yahoo.fr>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH 2/2] hw/sparc/leon3: Remove duplicated code
Posted by Philippe Mathieu-Daudé 10 months ago
Since commit b04d989054 ("SPARC: Emulation of Leon3") the
main_cpu_reset() handler sets both pc/npc when the CPU is
reset, after the machine is realized. It is pointless to
set it in leon3_generic_hw_init().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sparc/leon3.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 2dfb742566..1ae9a37583 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -343,8 +343,6 @@ static void leon3_generic_hw_init(MachineState *machine)
 
             bootloader_entry = memory_region_get_ram_ptr(prom);
             write_bootloader(env, bootloader_entry, entry);
-            env->pc = LEON3_PROM_OFFSET;
-            env->npc = LEON3_PROM_OFFSET + 4;
             reset_info->entry = LEON3_PROM_OFFSET;
         }
     }
-- 
2.41.0


Re: [PATCH 2/2] hw/sparc/leon3: Remove duplicated code
Posted by Clément Chigot 10 months ago
On Tue, Jan 30, 2024 at 12:31 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Since commit b04d989054 ("SPARC: Emulation of Leon3") the
> main_cpu_reset() handler sets both pc/npc when the CPU is
> reset, after the machine is realized. It is pointless to
> set it in leon3_generic_hw_init().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/sparc/leon3.c | 2 --
>  1 file changed, 2 deletions(-)

Thanks for those cleanups !
Reviewed-by: Clément Chigot <chigot@adacore.com>


> diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
> index 2dfb742566..1ae9a37583 100644
> --- a/hw/sparc/leon3.c
> +++ b/hw/sparc/leon3.c
> @@ -343,8 +343,6 @@ static void leon3_generic_hw_init(MachineState *machine)
>
>              bootloader_entry = memory_region_get_ram_ptr(prom);
>              write_bootloader(env, bootloader_entry, entry);
> -            env->pc = LEON3_PROM_OFFSET;
> -            env->npc = LEON3_PROM_OFFSET + 4;
>              reset_info->entry = LEON3_PROM_OFFSET;
>          }
>      }
> --
> 2.41.0
>