Skip to contentSkip to conversation

hw/sh4: Trivial cleanups

PATCH In review Philippe Mathieu-Daudé 2 participants 7 messages May 4, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/sh4: Trivial cleanups

Some SH4 patches worth salvaging while doing housekeeping.

Philippe Mathieu-Daudé (3):
hw/sh4: Use MemoryRegion typedef
hw/sh4: Extract timer definitions to 'hw/timer/tmu012.h' hw/timer/sh_timer: Remove unused 'qemu/timer.h' include

 include/hw/sh4/sh.h       | 12 +-----------
 include/hw/timer/tmu012.h | 23 +++++++++++++++++++++++
 hw/sh4/sh7750.c           |  1 +
 hw/timer/sh_timer.c       |  3 ++-
 4 files changed, 27 insertions(+), 12 deletions(-)
 create mode 100644 include/hw/timer/tmu012.h
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/3 hw/sh4: Use MemoryRegion typedef

Use the MemoryRegion type defined in "qemu/typedefs.h", to keep the repository style consistent.

---
 include/hw/sh4/sh.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/hw/sh4/sh.h +2 -3
index 767a2df7e2..fe773cb01d 100644
@@ -10,9 +10,8 @@
 
 /* sh7750.c */
 struct SH7750State;
-struct MemoryRegion;
 
-struct SH7750State *sh7750_init(SuperHCPU *cpu, struct MemoryRegion *sysmem);
+struct SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem);
 
 typedef struct {
     /* The callback will be triggered if any of the designated lines change */
@@ -32,7 +31,7 @@ int sh7750_register_io_device(struct SH7750State *s,
 #define TMU012_FEAT_TOCR   (1 << 0)
 #define TMU012_FEAT_3CHAN  (1 << 1)
 #define TMU012_FEAT_EXTCLK (1 << 2)
-void tmu012_init(struct MemoryRegion *sysmem, hwaddr base,
+void tmu012_init(MemoryRegion *sysmem, hwaddr base,
                  int feat, uint32_t freq,
 		 qemu_irq ch0_irq, qemu_irq ch1_irq,
 		 qemu_irq ch2_irq0, qemu_irq ch2_irq1);
Signature · 1 line
2.21.3
#3 lore raw

PATCH 2/3 hw/sh4: Extract timer definitions to 'hw/timer/tmu012.h'

In reply to Philippe Mathieu-Daudé

Extract timer definitions to 'hw/timer/tmu012.h'.

---
 include/hw/sh4/sh.h       |  9 ---------
 include/hw/timer/tmu012.h | 23 +++++++++++++++++++++++
 hw/sh4/sh7750.c           |  1 +
 hw/timer/sh_timer.c       |  2 ++
 4 files changed, 26 insertions(+), 9 deletions(-)
 create mode 100644 include/hw/timer/tmu012.h
include/hw/sh4/sh.h +0 -9
index fe773cb01d..93f464bf4c 100644
@@ -27,15 +27,6 @@ typedef struct {
 
 int sh7750_register_io_device(struct SH7750State *s,
 			      sh7750_io_device * device);
-/* sh_timer.c */
-#define TMU012_FEAT_TOCR   (1 << 0)
-#define TMU012_FEAT_3CHAN  (1 << 1)
-#define TMU012_FEAT_EXTCLK (1 << 2)
-void tmu012_init(MemoryRegion *sysmem, hwaddr base,
-                 int feat, uint32_t freq,
-		 qemu_irq ch0_irq, qemu_irq ch1_irq,
-		 qemu_irq ch2_irq0, qemu_irq ch2_irq1);
-
 
 /* sh_serial.c */
 #define SH_SERIAL_FEAT_SCIF (1 << 0)
include/hw/timer/tmu012.h new file +23 -0
new file mode 100644
index 0000000000..808ed8de1d
@@ -0,0 +1,23 @@
+/*
+ * SuperH Timer
+ *
+ * Copyright (c) 2007 Magnus Damm
+ *
+ * This code is licensed under the GPL.
+ */
+
+#ifndef HW_TIMER_TMU012_H
+#define HW_TIMER_TMU012_H
+
+#include "exec/hwaddr.h"
+
+#define TMU012_FEAT_TOCR   (1 << 0)
+#define TMU012_FEAT_3CHAN  (1 << 1)
+#define TMU012_FEAT_EXTCLK (1 << 2)
+
+void tmu012_init(MemoryRegion *sysmem, hwaddr base,
+                 int feat, uint32_t freq,
+                 qemu_irq ch0_irq, qemu_irq ch1_irq,
+                 qemu_irq ch2_irq0, qemu_irq ch2_irq1);
+
+#endif
hw/sh4/sh7750.c +1 -0
index d660714443..f8ac3ec6e3 100644
@@ -30,6 +30,7 @@
 #include "sh7750_regs.h"
 #include "sh7750_regnames.h"
 #include "hw/sh4/sh_intc.h"
+#include "hw/timer/tmu012.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
 
hw/timer/sh_timer.c +2 -0
index 13c4051808..b9cbacf5d0 100644
@@ -9,10 +9,12 @@
  */
 
 #include "qemu/osdep.h"
+#include "exec/memory.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
 #include "hw/sh4/sh.h"
 #include "qemu/timer.h"
+#include "hw/timer/tmu012.h"
 #include "hw/ptimer.h"
 
 //#define DEBUG_TIMER
Signature · 1 line
2.21.3
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] hw/sh4: Extract timer definitions to 'hw/timer/tmu012.h'

Quoted 10 lines · Philippe Mathieu-Daudé

Extract timer definitions to 'hw/timer/tmu012.h'.

---
 include/hw/sh4/sh.h       |  9 ---------
 include/hw/timer/tmu012.h | 23 +++++++++++++++++++++++
 hw/sh4/sh7750.c           |  1 +
 hw/timer/sh_timer.c       |  2 ++
 4 files changed, 26 insertions(+), 9 deletions(-)
 create mode 100644 include/hw/timer/tmu012.h

r~

#5 lore raw

PATCH 3/3 hw/timer/sh_timer: Remove unused 'qemu/timer.h' include

In reply to Philippe Mathieu-Daudé

Remove unused "qemu/timer.h" include.

---
 hw/timer/sh_timer.c | 1 -
 1 file changed, 1 deletion(-)
hw/timer/sh_timer.c +0 -1
index b9cbacf5d0..bb0e1c8ee5 100644
@@ -13,7 +13,6 @@
 #include "hw/hw.h"
 #include "hw/irq.h"
 #include "hw/sh4/sh.h"
-#include "qemu/timer.h"
 #include "hw/timer/tmu012.h"
 #include "hw/ptimer.h"
 
Signature · 1 line
2.21.3