Skip to contentSkip to conversation

hw/sparc/leon3: Minor cleanups

PATCH In review Philippe Mathieu-Daudé 2 participants 6 messages Jan 30, 2024 – Feb 15, 2024

lore
Share & tools
lore
#0 lore raw

cover hw/sparc/leon3: Minor cleanups

Minor cleanups noticed while reviewing Clément series:
https://lore.kernel.org/qemu-devel/[email protected]/

Philippe Mathieu-Daudé (2):
target/sparc: Provide hint about CPUSPARCState::irq_manager member hw/sparc/leon3: Remove duplicated code

 target/sparc/cpu.h | 5 ++---
 hw/sparc/leon3.c   | 2 --
 2 files changed, 2 insertions(+), 5 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 target/sparc: Provide hint about CPUSPARCState::irq_manager member

CPUSPARCState::irq_manager holds a pointer to a QDev, so declare it as DeviceState instead of void.

Move the comment about Leon3 fields.

---
 target/sparc/cpu.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
target/sparc/cpu.h +2 -3
index 12a11ecb26..d02684569a 100644
@@ -548,10 +548,9 @@ struct CPUArchState {
 #endif
     sparc_def_t def;
 
-    void *irq_manager;
+    /* Leon3 */
+    DeviceState *irq_manager;
     void (*qemu_irq_ack)(CPUSPARCState *env, int intno);
-
-    /* Leon3 cache control */
     uint32_t cache_control;
 };
 
Signature · 1 line
2.41.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] target/sparc: Provide hint about CPUSPARCState::irq_manager member

Quoted 10 lines · Philippe Mathieu-Daudé

CPUSPARCState::irq_manager holds a pointer to a QDev, so declare it as DeviceState instead of void.

Move the comment about Leon3 fields.

---
 target/sparc/cpu.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 20 lines
target/sparc/cpu.h +2 -4
index 12a11ecb26..d02684569a 100644
@@ -548,10 +548,9 @@ struct CPUArchState {
 #endif
     sparc_def_t def;
 
-    void *irq_manager;
+    /* Leon3 */
+    DeviceState *irq_manager;
     void (*qemu_irq_ack)(CPUSPARCState *env, int intno);
-
-    /* Leon3 cache control */
     uint32_t cache_control;
 };
 
--

2.41.0

#3 lore raw

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

In reply to Philippe Mathieu-Daudé

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().

---
 hw/sparc/leon3.c | 2 --
 1 file changed, 2 deletions(-)
hw/sparc/leon3.c +0 -2
index 2dfb742566..1ae9a37583 100644
@@ -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;
         }
     }
Signature · 1 line
2.41.0
Reviewed-by on v1 2/2
#4 lore raw

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

Quoted 10 lines · Philippe Mathieu-Daudé

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().

---
 hw/sparc/leon3.c | 2 --
 1 file changed, 2 deletions(-)

Thanks for those cleanups !

Quoted 16 lines
hw/sparc/leon3.c +0 -3
index 2dfb742566..1ae9a37583 100644
@@ -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