mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-01 06:21:52 -06:00
next-cube: use named gpio to read RTC data bit in scr2
This is in preparation for moving NeXTRTC to its own separate device. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Thomas Huth <huth@tuxfamily.org> Message-ID: <20241222130012.1013374-24-mark.cave-ayland@ilande.co.uk> Signed-off-by: Thomas Huth <huth@tuxfamily.org>
This commit is contained in:
parent
ccbc8fa3f9
commit
68f54f7e59
1 changed files with 92 additions and 77 deletions
|
@ -171,32 +171,20 @@ static bool next_rtc_cmd_is_write(uint8_t cmd)
|
|||
(cmd == 0xb1);
|
||||
}
|
||||
|
||||
static void next_scr2_rtc_update(NeXTPC *s)
|
||||
static void next_rtc_data_in_irq(void *opaque, int n, int level)
|
||||
{
|
||||
uint8_t old_scr2, scr2_2;
|
||||
NeXTPC *s = NEXT_PC(opaque);
|
||||
NeXTRTC *rtc = &s->rtc;
|
||||
|
||||
old_scr2 = extract32(s->old_scr2, 8, 8);
|
||||
scr2_2 = extract32(s->scr2, 8, 8);
|
||||
|
||||
if (scr2_2 & 0x1) {
|
||||
/* DPRINTF("RTC %x phase %i\n", scr2_2, rtc->phase); */
|
||||
if (rtc->phase == -1) {
|
||||
rtc->phase = 0;
|
||||
}
|
||||
/* If we are in going down clock... do something */
|
||||
if (((old_scr2 & SCR2_RTCLK) != (scr2_2 & SCR2_RTCLK)) &&
|
||||
((scr2_2 & SCR2_RTCLK) == 0)) {
|
||||
if (rtc->phase < 8) {
|
||||
rtc->command = (rtc->command << 1) |
|
||||
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
||||
rtc->command = (rtc->command << 1) | level;
|
||||
|
||||
if (rtc->phase == 7 && !next_rtc_cmd_is_write(rtc->command)) {
|
||||
if (rtc->command <= 0x1f) {
|
||||
/* RAM registers */
|
||||
rtc->retval = rtc->ram[rtc->command];
|
||||
}
|
||||
if ((rtc->command >= 0x20) && (rtc->command <= 0x2F)) {
|
||||
if ((rtc->command >= 0x20) && (rtc->command <= 0x2f)) {
|
||||
/* RTC */
|
||||
time_t time_h = time(NULL);
|
||||
struct tm *info = localtime(&time_h);
|
||||
|
@ -236,8 +224,7 @@ static void next_scr2_rtc_update(NeXTPC *s)
|
|||
if (rtc->phase >= 8 && rtc->phase < 16) {
|
||||
if (next_rtc_cmd_is_write(rtc->command)) {
|
||||
/* Shift in value to write */
|
||||
rtc->value = (rtc->value << 1) |
|
||||
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
||||
rtc->value = (rtc->value << 1) | level;
|
||||
} else {
|
||||
/* Shift out value to read */
|
||||
qemu_irq rtc_data_in_irq = qdev_get_gpio_in_named(
|
||||
|
@ -266,6 +253,32 @@ static void next_scr2_rtc_update(NeXTPC *s)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void next_scr2_rtc_update(NeXTPC *s)
|
||||
{
|
||||
uint8_t old_scr2, scr2_2;
|
||||
NeXTRTC *rtc = &s->rtc;
|
||||
|
||||
old_scr2 = extract32(s->old_scr2, 8, 8);
|
||||
scr2_2 = extract32(s->scr2, 8, 8);
|
||||
|
||||
if (scr2_2 & 0x1) {
|
||||
/* DPRINTF("RTC %x phase %i\n", scr2_2, rtc->phase); */
|
||||
if (rtc->phase == -1) {
|
||||
rtc->phase = 0;
|
||||
}
|
||||
/* If we are in going down clock... do something */
|
||||
if (((old_scr2 & SCR2_RTCLK) != (scr2_2 & SCR2_RTCLK)) &&
|
||||
((scr2_2 & SCR2_RTCLK) == 0)) {
|
||||
qemu_irq rtc_data_in_irq = qdev_get_gpio_in_named(
|
||||
DEVICE(s), "rtc-data-in", 0);
|
||||
|
||||
if (scr2_2 & SCR2_RTDATA) {
|
||||
qemu_irq_raise(rtc_data_in_irq);
|
||||
} else {
|
||||
qemu_irq_lower(rtc_data_in_irq);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* else end or abort */
|
||||
|
@ -1104,6 +1117,8 @@ static void next_pc_init(Object *obj)
|
|||
s->rtc_power_irq = qdev_get_gpio_in(DEVICE(obj), NEXT_PWR_I);
|
||||
qdev_init_gpio_in_named(DEVICE(obj), next_pc_rtc_data_in_irq,
|
||||
"pc-rtc-data-in", 1);
|
||||
qdev_init_gpio_in_named(DEVICE(obj), next_rtc_data_in_irq,
|
||||
"rtc-data-in", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue