Skip to content

Commit 6963b2c

Browse files
mcaylandhuth
authored andcommitted
next-cube: move next_rtc_cmd_is_write() and next_rtc_data_in_irq() functions
Move these functions in next-cube.c so that they are with the rest of the next-rtc functions. Signed-off-by: Mark Cave-Ayland <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Message-ID: <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent eb1f036 commit 6963b2c

File tree

1 file changed

+86
-86
lines changed

1 file changed

+86
-86
lines changed

hw/m68k/next-cube.c

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -175,92 +175,6 @@ static void next_scr2_led_update(NeXTPC *s)
175175
}
176176
}
177177

178-
static bool next_rtc_cmd_is_write(uint8_t cmd)
179-
{
180-
return (cmd >= 0x80 && cmd <= 0x9f) ||
181-
(cmd == 0xb1);
182-
}
183-
184-
static void next_rtc_data_in_irq(void *opaque, int n, int level)
185-
{
186-
NeXTRTC *rtc = NEXT_RTC(opaque);
187-
188-
if (rtc->phase < 8) {
189-
rtc->command = (rtc->command << 1) | level;
190-
191-
if (rtc->phase == 7 && !next_rtc_cmd_is_write(rtc->command)) {
192-
if (rtc->command <= 0x1f) {
193-
/* RAM registers */
194-
rtc->retval = rtc->ram[rtc->command];
195-
}
196-
if ((rtc->command >= 0x20) && (rtc->command <= 0x2f)) {
197-
/* RTC */
198-
time_t time_h = time(NULL);
199-
struct tm *info = localtime(&time_h);
200-
rtc->retval = 0;
201-
202-
switch (rtc->command) {
203-
case 0x20:
204-
rtc->retval = SCR2_TOBCD(info->tm_sec);
205-
break;
206-
case 0x21:
207-
rtc->retval = SCR2_TOBCD(info->tm_min);
208-
break;
209-
case 0x22:
210-
rtc->retval = SCR2_TOBCD(info->tm_hour);
211-
break;
212-
case 0x24:
213-
rtc->retval = SCR2_TOBCD(info->tm_mday);
214-
break;
215-
case 0x25:
216-
rtc->retval = SCR2_TOBCD((info->tm_mon + 1));
217-
break;
218-
case 0x26:
219-
rtc->retval = SCR2_TOBCD((info->tm_year - 100));
220-
break;
221-
}
222-
}
223-
if (rtc->command == 0x30) {
224-
/* read the status 0x30 */
225-
rtc->retval = rtc->status;
226-
}
227-
if (rtc->command == 0x31) {
228-
/* read the control 0x31 */
229-
rtc->retval = rtc->control;
230-
}
231-
}
232-
}
233-
if (rtc->phase >= 8 && rtc->phase < 16) {
234-
if (next_rtc_cmd_is_write(rtc->command)) {
235-
/* Shift in value to write */
236-
rtc->value = (rtc->value << 1) | level;
237-
} else {
238-
/* Shift out value to read */
239-
if (rtc->retval & (0x80 >> (rtc->phase - 8))) {
240-
qemu_irq_raise(rtc->data_out_irq);
241-
} else {
242-
qemu_irq_lower(rtc->data_out_irq);
243-
}
244-
}
245-
}
246-
247-
rtc->phase++;
248-
if (rtc->phase == 16 && next_rtc_cmd_is_write(rtc->command)) {
249-
if (rtc->command >= 0x80 && rtc->command <= 0x9f) {
250-
/* RAM registers */
251-
rtc->ram[rtc->command - 0x80] = rtc->value;
252-
}
253-
if (rtc->command == 0xb1) {
254-
/* write to 0x30 register */
255-
if (rtc->value & 0x04) {
256-
/* clear FTU */
257-
rtc->status = rtc->status & (~0x18);
258-
qemu_irq_lower(rtc->power_irq);
259-
}
260-
}
261-
}
262-
}
263-
264178
static void next_scr2_rtc_update(NeXTPC *s)
265179
{
266180
uint8_t old_scr2, scr2_2;
@@ -1012,6 +926,92 @@ static const MemoryRegionOps next_dummy_en_ops = {
1012926
.endianness = DEVICE_BIG_ENDIAN,
1013927
};
1014928

929+
static bool next_rtc_cmd_is_write(uint8_t cmd)
930+
{
931+
return (cmd >= 0x80 && cmd <= 0x9f) ||
932+
(cmd == 0xb1);
933+
}
934+
935+
static void next_rtc_data_in_irq(void *opaque, int n, int level)
936+
{
937+
NeXTRTC *rtc = NEXT_RTC(opaque);
938+
939+
if (rtc->phase < 8) {
940+
rtc->command = (rtc->command << 1) | level;
941+
942+
if (rtc->phase == 7 && !next_rtc_cmd_is_write(rtc->command)) {
943+
if (rtc->command <= 0x1f) {
944+
/* RAM registers */
945+
rtc->retval = rtc->ram[rtc->command];
946+
}
947+
if ((rtc->command >= 0x20) && (rtc->command <= 0x2f)) {
948+
/* RTC */
949+
time_t time_h = time(NULL);
950+
struct tm *info = localtime(&time_h);
951+
rtc->retval = 0;
952+
953+
switch (rtc->command) {
954+
case 0x20:
955+
rtc->retval = SCR2_TOBCD(info->tm_sec);
956+
break;
957+
case 0x21:
958+
rtc->retval = SCR2_TOBCD(info->tm_min);
959+
break;
960+
case 0x22:
961+
rtc->retval = SCR2_TOBCD(info->tm_hour);
962+
break;
963+
case 0x24:
964+
rtc->retval = SCR2_TOBCD(info->tm_mday);
965+
break;
966+
case 0x25:
967+
rtc->retval = SCR2_TOBCD((info->tm_mon + 1));
968+
break;
969+
case 0x26:
970+
rtc->retval = SCR2_TOBCD((info->tm_year - 100));
971+
break;
972+
}
973+
}
974+
if (rtc->command == 0x30) {
975+
/* read the status 0x30 */
976+
rtc->retval = rtc->status;
977+
}
978+
if (rtc->command == 0x31) {
979+
/* read the control 0x31 */
980+
rtc->retval = rtc->control;
981+
}
982+
}
983+
}
984+
if (rtc->phase >= 8 && rtc->phase < 16) {
985+
if (next_rtc_cmd_is_write(rtc->command)) {
986+
/* Shift in value to write */
987+
rtc->value = (rtc->value << 1) | level;
988+
} else {
989+
/* Shift out value to read */
990+
if (rtc->retval & (0x80 >> (rtc->phase - 8))) {
991+
qemu_irq_raise(rtc->data_out_irq);
992+
} else {
993+
qemu_irq_lower(rtc->data_out_irq);
994+
}
995+
}
996+
}
997+
998+
rtc->phase++;
999+
if (rtc->phase == 16 && next_rtc_cmd_is_write(rtc->command)) {
1000+
if (rtc->command >= 0x80 && rtc->command <= 0x9f) {
1001+
/* RAM registers */
1002+
rtc->ram[rtc->command - 0x80] = rtc->value;
1003+
}
1004+
if (rtc->command == 0xb1) {
1005+
/* write to 0x30 register */
1006+
if (rtc->value & 0x04) {
1007+
/* clear FTU */
1008+
rtc->status = rtc->status & (~0x18);
1009+
qemu_irq_lower(rtc->power_irq);
1010+
}
1011+
}
1012+
}
1013+
}
1014+
10151015
static void next_rtc_cmd_reset_irq(void *opaque, int n, int level)
10161016
{
10171017
NeXTRTC *rtc = NEXT_RTC(opaque);

0 commit comments

Comments
 (0)