[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/11] hw/m68k/next-cube: Move rtc into NeXTPC struct
From: |
Thomas Huth |
Subject: |
[PULL 08/11] hw/m68k/next-cube: Move rtc into NeXTPC struct |
Date: |
Tue, 19 Jan 2021 09:36:14 +0100 |
From: Peter Maydell <peter.maydell@linaro.org>
Move the rtc into the NeXTPC struct. Since this is the last
use of the 'backdoor' NextState pointer we can now remove that.
Probably the RTC should be its own device at some point: in hardware
there is a separate MCS1850 RTC chip connected to the Peripheral
Controller via a 1-bit serial interface. That goes beyond the remit
of the current refactoring, though.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20210115201206.17347-9-peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <huth@tuxfamily.org>
---
hw/m68k/next-cube.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index 7dcd39aab9..57f9e9f837 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -78,8 +78,6 @@ struct NeXTState {
qemu_irq scsi_dma;
qemu_irq scsi_reset;
qemu_irq *fd_irq;
-
- NextRtc rtc;
};
#define TYPE_NEXT_PC "next-pc"
@@ -89,9 +87,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(NeXTPC, NEXT_PC)
struct NeXTPC {
SysBusDevice parent_obj;
- /* Temporary until all functionality has been moved into this device */
- NeXTState *ns;
-
M68kCPU *cpu;
MemoryRegion mmiomem;
@@ -103,6 +98,8 @@ struct NeXTPC {
uint8_t scsi_csr_2;
uint32_t int_mask;
uint32_t int_status;
+
+ NextRtc rtc;
};
/* Thanks to NeXT forums for this */
@@ -131,7 +128,7 @@ static void nextscr2_write(NeXTPC *s, uint32_t val, int
size)
static int phase;
static uint8_t old_scr2;
uint8_t scr2_2;
- NextRtc *rtc = &s->ns->rtc;
+ NextRtc *rtc = &s->rtc;
if (size == 4) {
scr2_2 = (val >> 8) & 0xFF;
@@ -865,6 +862,11 @@ static void next_pc_reset(DeviceState *dev)
/* 0x0000XX00 << vital bits */
s->scr1 = 0x00011102;
s->scr2 = 0x00ff0c80;
+
+ s->rtc.status = 0x90;
+
+ /* Load RTC RAM - TODO: provide possibility to load contents from file */
+ memcpy(s->rtc.ram, rtc_ram2, 32);
}
static void next_pc_realize(DeviceState *dev, Error **errp)
@@ -921,7 +923,6 @@ static void next_cube_init(MachineState *machine)
MemoryRegion *bmapm2 = g_new(MemoryRegion, 1);
MemoryRegion *sysmem = get_system_memory();
const char *bios_name = machine->firmware ?: ROM_FILE;
- NeXTState *ns = NEXT_MACHINE(machine);
DeviceState *dev;
DeviceState *pcdev;
@@ -941,13 +942,6 @@ static void next_cube_init(MachineState *machine)
pcdev = qdev_new(TYPE_NEXT_PC);
object_property_set_link(OBJECT(pcdev), "cpu", OBJECT(cpu), &error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(pcdev), &error_fatal);
- /* Temporary while we refactor this code */
- NEXT_PC(pcdev)->ns = ns;
-
- ns->rtc.status = 0x90;
-
- /* Load RTC RAM - TODO: provide possibility to load contents from file */
- memcpy(ns->rtc.ram, rtc_ram2, 32);
/* 64MB RAM starting at 0x04000000 */
memory_region_add_subregion(sysmem, 0x04000000, machine->ram);
--
2.29.2
- [PULL 00/11] m68k next-cube patches, Thomas Huth, 2021/01/19
- [PULL 01/11] hw/m68k/next-cube: Make next_irq() function static, Thomas Huth, 2021/01/19
- [PULL 02/11] hw/m68k/next-cube: Move register/interrupt functionality into a device, Thomas Huth, 2021/01/19
- [PULL 03/11] hw/m68k/next-cube: Move mmio_ops into NeXTPC device, Thomas Huth, 2021/01/19
- [PULL 05/11] hw/m68k/next-cube: Make next_irq take NeXTPC* as its opaque, Thomas Huth, 2021/01/19
- [PULL 10/11] hw/m68k/next-cube: Add vmstate for NeXTPC device, Thomas Huth, 2021/01/19
- [PULL 04/11] hw/m68k/next-cube: Move scr_ops into NeXTPC device, Thomas Huth, 2021/01/19
- [PULL 11/11] hw/m68k/next-cube: Add missing header comment to next-cube.h, Thomas Huth, 2021/01/19
- [PULL 06/11] hw/m68k/next-cube: Move int_status and int_mask to NeXTPC struct, Thomas Huth, 2021/01/19
- [PULL 07/11] hw/m68k/next-cube: Make next_irq GPIO inputs to NEXT_PC device, Thomas Huth, 2021/01/19
- [PULL 08/11] hw/m68k/next-cube: Move rtc into NeXTPC struct,
Thomas Huth <=
- [PULL 09/11] hw/m68k/next-cube: Remove unused fields from NeXTState, Thomas Huth, 2021/01/19
- Re: [PULL 00/11] m68k next-cube patches, Peter Maydell, 2021/01/19