2018-06-30 09:45:25 +03:00
|
|
|
/*
|
|
|
|
* NeXT Cube System Driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Bryce Lanham
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published
|
|
|
|
* by the Free Software Foundation; either version 2 of the License,
|
|
|
|
* or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "exec/hwaddr.h"
|
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
#include "sysemu/qtest.h"
|
2018-06-30 17:58:01 +03:00
|
|
|
#include "hw/irq.h"
|
2018-06-30 09:45:25 +03:00
|
|
|
#include "hw/m68k/next-cube.h"
|
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/loader.h"
|
|
|
|
#include "hw/scsi/esp.h"
|
|
|
|
#include "hw/sysbus.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2018-06-30 09:45:25 +03:00
|
|
|
#include "hw/char/escc.h" /* ZILOG 8530 Serial Emulation */
|
|
|
|
#include "hw/block/fdc.h"
|
2018-06-30 17:58:01 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2018-06-30 09:45:25 +03:00
|
|
|
#include "qapi/error.h"
|
2023-03-15 20:43:13 +03:00
|
|
|
#include "qemu/error-report.h"
|
2018-06-30 09:45:25 +03:00
|
|
|
#include "ui/console.h"
|
|
|
|
#include "target/m68k/cpu.h"
|
2021-01-15 23:12:05 +03:00
|
|
|
#include "migration/vmstate.h"
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* #define DEBUG_NEXT */
|
|
|
|
#ifdef DEBUG_NEXT
|
|
|
|
#define DPRINTF(fmt, ...) \
|
|
|
|
do { printf("NeXT: " fmt , ## __VA_ARGS__); } while (0)
|
|
|
|
#else
|
|
|
|
#define DPRINTF(fmt, ...) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TYPE_NEXT_MACHINE MACHINE_TYPE_NAME("next-cube")
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(NeXTState, NEXT_MACHINE)
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
#define ENTRY 0x0100001e
|
|
|
|
#define RAM_SIZE 0x4000000
|
|
|
|
#define ROM_FILE "Rev_2.5_v66.bin"
|
|
|
|
|
|
|
|
typedef struct next_dma {
|
|
|
|
uint32_t csr;
|
|
|
|
|
|
|
|
uint32_t saved_next;
|
|
|
|
uint32_t saved_limit;
|
|
|
|
uint32_t saved_start;
|
|
|
|
uint32_t saved_stop;
|
|
|
|
|
|
|
|
uint32_t next;
|
|
|
|
uint32_t limit;
|
|
|
|
uint32_t start;
|
|
|
|
uint32_t stop;
|
|
|
|
|
|
|
|
uint32_t next_initbuf;
|
|
|
|
uint32_t size;
|
|
|
|
} next_dma;
|
|
|
|
|
2019-09-21 12:17:38 +03:00
|
|
|
typedef struct NextRtc {
|
2023-12-20 16:16:37 +03:00
|
|
|
int8_t phase;
|
2019-09-21 12:17:38 +03:00
|
|
|
uint8_t ram[32];
|
|
|
|
uint8_t command;
|
|
|
|
uint8_t value;
|
|
|
|
uint8_t status;
|
|
|
|
uint8_t control;
|
|
|
|
uint8_t retval;
|
|
|
|
} NextRtc;
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct NeXTState {
|
2018-06-30 09:45:25 +03:00
|
|
|
MachineState parent;
|
|
|
|
|
2023-12-20 16:16:41 +03:00
|
|
|
MemoryRegion rom;
|
|
|
|
MemoryRegion rom2;
|
|
|
|
MemoryRegion dmamem;
|
|
|
|
MemoryRegion bmapm1;
|
|
|
|
MemoryRegion bmapm2;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
next_dma dma[10];
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2021-01-15 23:11:57 +03:00
|
|
|
#define TYPE_NEXT_PC "next-pc"
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(NeXTPC, NEXT_PC)
|
|
|
|
|
|
|
|
/* NeXT Peripheral Controller */
|
|
|
|
struct NeXTPC {
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2021-01-15 23:12:00 +03:00
|
|
|
M68kCPU *cpu;
|
|
|
|
|
2021-01-15 23:11:58 +03:00
|
|
|
MemoryRegion mmiomem;
|
2021-01-15 23:11:59 +03:00
|
|
|
MemoryRegion scrmem;
|
2021-01-15 23:11:58 +03:00
|
|
|
|
|
|
|
uint32_t scr1;
|
|
|
|
uint32_t scr2;
|
2023-12-20 16:16:38 +03:00
|
|
|
uint32_t old_scr2;
|
2021-01-15 23:12:01 +03:00
|
|
|
uint32_t int_mask;
|
|
|
|
uint32_t int_status;
|
2023-12-20 16:16:36 +03:00
|
|
|
uint32_t led;
|
2023-09-30 16:23:49 +03:00
|
|
|
uint8_t scsi_csr_1;
|
|
|
|
uint8_t scsi_csr_2;
|
|
|
|
|
|
|
|
qemu_irq scsi_reset;
|
|
|
|
qemu_irq scsi_dma;
|
2021-01-15 23:12:03 +03:00
|
|
|
|
|
|
|
NextRtc rtc;
|
2021-01-15 23:11:57 +03:00
|
|
|
};
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
/* Thanks to NeXT forums for this */
|
|
|
|
/*
|
|
|
|
static const uint8_t rtc_ram3[32] = {
|
|
|
|
0x94, 0x0f, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0xfb, 0x6d, 0x00, 0x00, 0x7B, 0x00,
|
|
|
|
0x00, 0x00, 0x65, 0x6e, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x13
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
static const uint8_t rtc_ram2[32] = {
|
|
|
|
0x94, 0x0f, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0xfb, 0x6d, 0x00, 0x00, 0x4b, 0x00,
|
|
|
|
0x41, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x7e,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SCR2_RTCLK 0x2
|
|
|
|
#define SCR2_RTDATA 0x4
|
|
|
|
#define SCR2_TOBCD(x) (((x / 10) << 4) + (x % 10))
|
|
|
|
|
2023-12-20 16:16:39 +03:00
|
|
|
static void next_scr2_led_update(NeXTPC *s)
|
|
|
|
{
|
|
|
|
if (s->scr2 & 0x1) {
|
|
|
|
DPRINTF("fault!\n");
|
|
|
|
s->led++;
|
|
|
|
if (s->led == 10) {
|
|
|
|
DPRINTF("LED flashing, possible fault!\n");
|
|
|
|
s->led = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:40 +03:00
|
|
|
static void next_scr2_rtc_update(NeXTPC *s)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
2023-12-20 16:16:38 +03:00
|
|
|
uint8_t old_scr2, scr2_2;
|
2021-01-15 23:12:03 +03:00
|
|
|
NextRtc *rtc = &s->rtc;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2023-12-20 16:16:40 +03:00
|
|
|
old_scr2 = extract32(s->old_scr2, 8, 8);
|
|
|
|
scr2_2 = extract32(s->scr2, 8, 8);
|
2023-12-20 16:16:38 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
if (scr2_2 & 0x1) {
|
2023-12-20 16:16:37 +03:00
|
|
|
/* DPRINTF("RTC %x phase %i\n", scr2_2, rtc->phase); */
|
|
|
|
if (rtc->phase == -1) {
|
|
|
|
rtc->phase = 0;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
/* If we are in going down clock... do something */
|
|
|
|
if (((old_scr2 & SCR2_RTCLK) != (scr2_2 & SCR2_RTCLK)) &&
|
|
|
|
((scr2_2 & SCR2_RTCLK) == 0)) {
|
2023-12-20 16:16:37 +03:00
|
|
|
if (rtc->phase < 8) {
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->command = (rtc->command << 1) |
|
|
|
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
2023-12-20 16:16:37 +03:00
|
|
|
if (rtc->phase >= 8 && rtc->phase < 16) {
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->value = (rtc->value << 1) |
|
|
|
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* if we read RAM register, output RT_DATA bit */
|
2019-09-21 12:17:38 +03:00
|
|
|
if (rtc->command <= 0x1F) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 = scr2_2 & (~SCR2_RTDATA);
|
2023-12-20 16:16:37 +03:00
|
|
|
if (rtc->ram[rtc->command] & (0x80 >> (rtc->phase - 8))) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 |= SCR2_RTDATA;
|
|
|
|
}
|
|
|
|
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->retval = (rtc->retval << 1) |
|
|
|
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
/* read the status 0x30 */
|
2019-09-21 12:17:38 +03:00
|
|
|
if (rtc->command == 0x30) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 = scr2_2 & (~SCR2_RTDATA);
|
|
|
|
/* for now status = 0x98 (new rtc + FTU) */
|
2023-12-20 16:16:37 +03:00
|
|
|
if (rtc->status & (0x80 >> (rtc->phase - 8))) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 |= SCR2_RTDATA;
|
|
|
|
}
|
|
|
|
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->retval = (rtc->retval << 1) |
|
|
|
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
/* read the status 0x31 */
|
2019-09-21 12:17:38 +03:00
|
|
|
if (rtc->command == 0x31) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 = scr2_2 & (~SCR2_RTDATA);
|
2023-12-20 16:16:37 +03:00
|
|
|
if (rtc->control & (0x80 >> (rtc->phase - 8))) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 |= SCR2_RTDATA;
|
|
|
|
}
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->retval = (rtc->retval << 1) |
|
|
|
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2019-09-21 12:17:38 +03:00
|
|
|
if ((rtc->command >= 0x20) && (rtc->command <= 0x2F)) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 = scr2_2 & (~SCR2_RTDATA);
|
|
|
|
/* for now 0x00 */
|
|
|
|
time_t time_h = time(NULL);
|
|
|
|
struct tm *info = localtime(&time_h);
|
|
|
|
int ret = 0;
|
|
|
|
|
2019-09-21 12:17:38 +03:00
|
|
|
switch (rtc->command) {
|
2018-06-30 09:45:25 +03:00
|
|
|
case 0x20:
|
|
|
|
ret = SCR2_TOBCD(info->tm_sec);
|
|
|
|
break;
|
|
|
|
case 0x21:
|
|
|
|
ret = SCR2_TOBCD(info->tm_min);
|
|
|
|
break;
|
|
|
|
case 0x22:
|
|
|
|
ret = SCR2_TOBCD(info->tm_hour);
|
|
|
|
break;
|
|
|
|
case 0x24:
|
|
|
|
ret = SCR2_TOBCD(info->tm_mday);
|
|
|
|
break;
|
|
|
|
case 0x25:
|
|
|
|
ret = SCR2_TOBCD((info->tm_mon + 1));
|
|
|
|
break;
|
|
|
|
case 0x26:
|
|
|
|
ret = SCR2_TOBCD((info->tm_year - 100));
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:37 +03:00
|
|
|
if (ret & (0x80 >> (rtc->phase - 8))) {
|
2018-06-30 09:45:25 +03:00
|
|
|
scr2_2 |= SCR2_RTDATA;
|
|
|
|
}
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->retval = (rtc->retval << 1) |
|
|
|
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:37 +03:00
|
|
|
rtc->phase++;
|
|
|
|
if (rtc->phase == 16) {
|
2019-09-21 12:17:38 +03:00
|
|
|
if (rtc->command >= 0x80 && rtc->command <= 0x9F) {
|
|
|
|
rtc->ram[rtc->command - 0x80] = rtc->value;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
/* write to x30 register */
|
2019-09-21 12:17:38 +03:00
|
|
|
if (rtc->command == 0xB1) {
|
2018-06-30 09:45:25 +03:00
|
|
|
/* clear FTU */
|
2019-09-21 12:17:38 +03:00
|
|
|
if (rtc->value & 0x04) {
|
|
|
|
rtc->status = rtc->status & (~0x18);
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_status = s->int_status & (~0x04);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* else end or abort */
|
2023-12-20 16:16:37 +03:00
|
|
|
rtc->phase = -1;
|
2019-09-21 12:17:38 +03:00
|
|
|
rtc->command = 0;
|
|
|
|
rtc->value = 0;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
2023-12-20 16:16:40 +03:00
|
|
|
|
|
|
|
s->scr2 = deposit32(s->scr2, 8, 8, scr2_2);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
static uint64_t next_mmio_read(void *opaque, hwaddr addr, unsigned size)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
2023-12-20 16:16:33 +03:00
|
|
|
NeXTPC *s = NEXT_PC(opaque);
|
|
|
|
uint64_t val;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case 0x7000:
|
2021-01-15 23:12:01 +03:00
|
|
|
/* DPRINTF("Read INT status: %x\n", s->int_status); */
|
2023-12-20 16:16:33 +03:00
|
|
|
val = s->int_status;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
case 0x7800:
|
2021-01-15 23:12:01 +03:00
|
|
|
DPRINTF("MMIO Read INT mask: %x\n", s->int_mask);
|
2023-12-20 16:16:33 +03:00
|
|
|
val = s->int_mask;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
case 0xc000 ... 0xc003:
|
|
|
|
val = extract32(s->scr1, (4 - (addr - 0xc000) - size) << 3,
|
|
|
|
size << 3);
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
case 0xd000 ... 0xd003:
|
|
|
|
val = extract32(s->scr2, (4 - (addr - 0xd000) - size) << 3,
|
|
|
|
size << 3);
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
case 0x14020:
|
|
|
|
val = 0x7f;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:33 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
default:
|
2023-12-20 16:16:33 +03:00
|
|
|
val = 0;
|
|
|
|
DPRINTF("MMIO Read @ 0x%"HWADDR_PRIx" size %d\n", addr, size);
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
return val;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
static void next_mmio_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
|
unsigned size)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
2023-12-20 16:16:33 +03:00
|
|
|
NeXTPC *s = NEXT_PC(opaque);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case 0x7000:
|
2023-12-20 16:16:33 +03:00
|
|
|
DPRINTF("INT Status old: %x new: %x\n", s->int_status,
|
|
|
|
(unsigned int)val);
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_status = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:33 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case 0x7800:
|
2023-12-20 16:16:33 +03:00
|
|
|
DPRINTF("INT Mask old: %x new: %x\n", s->int_mask, (unsigned int)val);
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_mask = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
case 0xc000 ... 0xc003:
|
|
|
|
DPRINTF("SCR1 Write: %x\n", (unsigned int)val);
|
|
|
|
s->scr1 = deposit32(s->scr1, (4 - (addr - 0xc000) - size) << 3,
|
|
|
|
size << 3, val);
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:33 +03:00
|
|
|
|
|
|
|
case 0xd000 ... 0xd003:
|
2023-12-20 16:16:38 +03:00
|
|
|
s->scr2 = deposit32(s->scr2, (4 - (addr - 0xd000) - size) << 3,
|
|
|
|
size << 3, val);
|
2023-12-20 16:16:39 +03:00
|
|
|
next_scr2_led_update(s);
|
2023-12-20 16:16:40 +03:00
|
|
|
next_scr2_rtc_update(s);
|
2023-12-20 16:16:38 +03:00
|
|
|
s->old_scr2 = s->scr2;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:33 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
default:
|
2023-12-20 16:16:33 +03:00
|
|
|
DPRINTF("MMIO Write @ 0x%"HWADDR_PRIx " with 0x%x size %u\n", addr,
|
|
|
|
(unsigned int)val, size);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
static const MemoryRegionOps next_mmio_ops = {
|
|
|
|
.read = next_mmio_read,
|
|
|
|
.write = next_mmio_write,
|
2018-06-30 09:45:25 +03:00
|
|
|
.valid.min_access_size = 1,
|
|
|
|
.valid.max_access_size = 4,
|
2023-12-20 16:16:33 +03:00
|
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
2018-06-30 09:45:25 +03:00
|
|
|
};
|
|
|
|
|
2023-12-20 16:16:34 +03:00
|
|
|
#define SCSICSR_ENABLE 0x01
|
|
|
|
#define SCSICSR_RESET 0x02 /* reset scsi dma */
|
|
|
|
#define SCSICSR_FIFOFL 0x04
|
|
|
|
#define SCSICSR_DMADIR 0x08 /* if set, scsi to mem */
|
|
|
|
#define SCSICSR_CPUDMA 0x10 /* if set, dma enabled */
|
|
|
|
#define SCSICSR_INTMASK 0x20 /* if set, interrupt enabled */
|
|
|
|
|
|
|
|
static uint64_t next_scr_readfn(void *opaque, hwaddr addr, unsigned size)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
2023-12-20 16:16:34 +03:00
|
|
|
NeXTPC *s = NEXT_PC(opaque);
|
|
|
|
uint64_t val;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
switch (addr) {
|
|
|
|
case 0x14108:
|
|
|
|
DPRINTF("FD read @ %x\n", (unsigned int)addr);
|
2023-12-20 16:16:34 +03:00
|
|
|
val = 0x40 | 0x04 | 0x2 | 0x1;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case 0x14020:
|
|
|
|
DPRINTF("SCSI 4020 STATUS READ %X\n", s->scsi_csr_1);
|
2023-12-20 16:16:34 +03:00
|
|
|
val = s->scsi_csr_1;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
case 0x14021:
|
|
|
|
DPRINTF("SCSI 4021 STATUS READ %X\n", s->scsi_csr_2);
|
2023-12-20 16:16:34 +03:00
|
|
|
val = 0x40;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These 4 registers are the hardware timer, not sure which register
|
2023-12-20 16:16:34 +03:00
|
|
|
* is the latch instead of data, but no problems so far.
|
|
|
|
*
|
|
|
|
* Hack: We need to have the LSB change consistently to make it work
|
2018-06-30 09:45:25 +03:00
|
|
|
*/
|
2023-12-20 16:16:34 +03:00
|
|
|
case 0x1a000 ... 0x1a003:
|
|
|
|
val = extract32(clock(), (4 - (addr - 0x1a000) - size) << 3,
|
|
|
|
size << 3);
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2023-12-20 16:16:31 +03:00
|
|
|
/* For now return dummy byte to allow the Ethernet test to timeout */
|
|
|
|
case 0x6000:
|
2023-12-20 16:16:34 +03:00
|
|
|
val = 0xff;
|
|
|
|
break;
|
2023-12-20 16:16:31 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
default:
|
2023-12-20 16:16:34 +03:00
|
|
|
DPRINTF("BMAP Read @ 0x%x size %u\n", (unsigned int)addr, size);
|
|
|
|
val = 0;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:34 +03:00
|
|
|
return val;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:34 +03:00
|
|
|
static void next_scr_writefn(void *opaque, hwaddr addr, uint64_t val,
|
|
|
|
unsigned size)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
2023-12-20 16:16:34 +03:00
|
|
|
NeXTPC *s = NEXT_PC(opaque);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case 0x14108:
|
|
|
|
DPRINTF("FDCSR Write: %x\n", value);
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val == 0x0) {
|
2018-06-30 09:45:25 +03:00
|
|
|
/* qemu_irq_raise(s->fd_irq[0]); */
|
|
|
|
}
|
|
|
|
break;
|
2023-12-20 16:16:34 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case 0x14020: /* SCSI Control Register */
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & SCSICSR_FIFOFL) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("SCSICSR FIFO Flush\n");
|
|
|
|
/* will have to add another irq to the esp if this is needed */
|
|
|
|
/* esp_puflush_fifo(esp_g); */
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & SCSICSR_ENABLE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("SCSICSR Enable\n");
|
|
|
|
/*
|
|
|
|
* qemu_irq_raise(s->scsi_dma);
|
|
|
|
* s->scsi_csr_1 = 0xc0;
|
|
|
|
* s->scsi_csr_1 |= 0x1;
|
|
|
|
* qemu_irq_pulse(s->scsi_dma);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* else
|
|
|
|
* s->scsi_csr_1 &= ~SCSICSR_ENABLE;
|
|
|
|
*/
|
|
|
|
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & SCSICSR_RESET) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("SCSICSR Reset\n");
|
|
|
|
/* I think this should set DMADIR. CPUDMA and INTMASK to 0 */
|
2023-09-30 16:23:49 +03:00
|
|
|
qemu_irq_raise(s->scsi_reset);
|
|
|
|
s->scsi_csr_1 &= ~(SCSICSR_INTMASK | 0x80 | 0x1);
|
|
|
|
qemu_irq_lower(s->scsi_reset);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & SCSICSR_DMADIR) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("SCSICSR DMAdir\n");
|
|
|
|
}
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & SCSICSR_CPUDMA) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("SCSICSR CPUDMA\n");
|
|
|
|
/* qemu_irq_raise(s->scsi_dma); */
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_status |= 0x4000000;
|
2018-06-30 09:45:25 +03:00
|
|
|
} else {
|
2023-09-30 16:23:49 +03:00
|
|
|
/* fprintf(stderr,"SCSICSR CPUDMA disabled\n"); */
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_status &= ~(0x4000000);
|
2023-09-30 16:23:49 +03:00
|
|
|
/* qemu_irq_lower(s->scsi_dma); */
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & SCSICSR_INTMASK) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("SCSICSR INTMASK\n");
|
|
|
|
/*
|
|
|
|
* int_mask &= ~0x1000;
|
2023-12-20 16:16:34 +03:00
|
|
|
* s->scsi_csr_1 |= val;
|
2018-06-30 09:45:25 +03:00
|
|
|
* s->scsi_csr_1 &= ~SCSICSR_INTMASK;
|
|
|
|
* if (s->scsi_queued) {
|
|
|
|
* s->scsi_queued = 0;
|
|
|
|
* next_irq(s, NEXT_SCSI_I, level);
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
/* int_mask |= 0x1000; */
|
|
|
|
}
|
2023-12-20 16:16:34 +03:00
|
|
|
if (val & 0x80) {
|
2018-06-30 09:45:25 +03:00
|
|
|
/* int_mask |= 0x1000; */
|
|
|
|
/* s->scsi_csr_1 |= 0x80; */
|
|
|
|
}
|
2023-12-20 16:16:34 +03:00
|
|
|
DPRINTF("SCSICSR Write: %x\n", val);
|
|
|
|
/* s->scsi_csr_1 = val; */
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
/* Hardware timer latch - not implemented yet */
|
|
|
|
case 0x1a000:
|
|
|
|
default:
|
2023-12-20 16:16:34 +03:00
|
|
|
DPRINTF("BMAP Write @ 0x%x with 0x%x size %u\n", (unsigned int)addr,
|
|
|
|
val, size);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:34 +03:00
|
|
|
static const MemoryRegionOps next_scr_ops = {
|
|
|
|
.read = next_scr_readfn,
|
|
|
|
.write = next_scr_writefn,
|
2018-06-30 09:45:25 +03:00
|
|
|
.valid.min_access_size = 1,
|
|
|
|
.valid.max_access_size = 4,
|
2023-12-20 16:16:34 +03:00
|
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
2018-06-30 09:45:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NEXTDMA_SCSI(x) (0x10 + x)
|
|
|
|
#define NEXTDMA_FD(x) (0x10 + x)
|
|
|
|
#define NEXTDMA_ENTX(x) (0x110 + x)
|
|
|
|
#define NEXTDMA_ENRX(x) (0x150 + x)
|
|
|
|
#define NEXTDMA_CSR 0x0
|
|
|
|
#define NEXTDMA_NEXT 0x4000
|
|
|
|
#define NEXTDMA_LIMIT 0x4004
|
|
|
|
#define NEXTDMA_START 0x4008
|
|
|
|
#define NEXTDMA_STOP 0x400c
|
|
|
|
#define NEXTDMA_NEXT_INIT 0x4200
|
|
|
|
#define NEXTDMA_SIZE 0x4204
|
|
|
|
|
2023-12-20 16:16:35 +03:00
|
|
|
static void next_dma_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
|
unsigned int size)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
|
|
|
NeXTState *next_state = NEXT_MACHINE(opaque);
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case NEXTDMA_ENRX(NEXTDMA_CSR):
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_DEV2M) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].csr |= DMA_DEV2M;
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_SETENABLE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
/* DPRINTF("SCSI DMA ENABLE\n"); */
|
|
|
|
next_state->dma[NEXTDMA_ENRX].csr |= DMA_ENABLE;
|
|
|
|
}
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_SETSUPDATE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].csr |= DMA_SUPDATE;
|
|
|
|
}
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_CLRCOMPLETE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].csr &= ~DMA_COMPLETE;
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_RESET) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].csr &= ~(DMA_COMPLETE | DMA_SUPDATE |
|
|
|
|
DMA_ENABLE | DMA_DEV2M);
|
|
|
|
}
|
|
|
|
/* DPRINTF("RXCSR \tWrite: %x\n",value); */
|
|
|
|
break;
|
2023-12-20 16:16:35 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_NEXT_INIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].next_initbuf = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:35 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_NEXT):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].next = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:35 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_LIMIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_ENRX].limit = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
2023-12-20 16:16:35 +03:00
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_SCSI(NEXTDMA_CSR):
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_DEV2M) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].csr |= DMA_DEV2M;
|
|
|
|
}
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_SETENABLE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
/* DPRINTF("SCSI DMA ENABLE\n"); */
|
|
|
|
next_state->dma[NEXTDMA_SCSI].csr |= DMA_ENABLE;
|
|
|
|
}
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_SETSUPDATE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].csr |= DMA_SUPDATE;
|
|
|
|
}
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_CLRCOMPLETE) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].csr &= ~DMA_COMPLETE;
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:35 +03:00
|
|
|
if (val & DMA_RESET) {
|
2018-06-30 09:45:25 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].csr &= ~(DMA_COMPLETE | DMA_SUPDATE |
|
|
|
|
DMA_ENABLE | DMA_DEV2M);
|
|
|
|
/* DPRINTF("SCSI DMA RESET\n"); */
|
|
|
|
}
|
|
|
|
/* DPRINTF("RXCSR \tWrite: %x\n",value); */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_NEXT):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].next = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_LIMIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].limit = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_START):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].start = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_STOP):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].stop = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_NEXT_INIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
next_state->dma[NEXTDMA_SCSI].next_initbuf = val;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DPRINTF("DMA write @ %x w/ %x\n", (unsigned)addr, (unsigned)value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:35 +03:00
|
|
|
static uint64_t next_dma_read(void *opaque, hwaddr addr, unsigned int size)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
|
|
|
NeXTState *next_state = NEXT_MACHINE(opaque);
|
2023-12-20 16:16:35 +03:00
|
|
|
uint64_t val;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_CSR):
|
|
|
|
DPRINTF("SCSI DMA CSR READ\n");
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_SCSI].csr;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_CSR):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_ENRX].csr;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_NEXT_INIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_ENRX].next_initbuf;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_NEXT):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_ENRX].next;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_ENRX(NEXTDMA_LIMIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_ENRX].limit;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
case NEXTDMA_SCSI(NEXTDMA_NEXT):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_SCSI].next;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_SCSI(NEXTDMA_NEXT_INIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_SCSI].next_initbuf;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_SCSI(NEXTDMA_LIMIT):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_SCSI].limit;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_SCSI(NEXTDMA_START):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_SCSI].start;
|
|
|
|
break;
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
case NEXTDMA_SCSI(NEXTDMA_STOP):
|
2023-12-20 16:16:35 +03:00
|
|
|
val = next_state->dma[NEXTDMA_SCSI].stop;
|
|
|
|
break;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
DPRINTF("DMA read @ %x\n", (unsigned int)addr);
|
2023-12-20 16:16:35 +03:00
|
|
|
val = 0;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* once the csr's are done, subtract 0x3FEC from the addr, and that will
|
|
|
|
* normalize the upper registers
|
|
|
|
*/
|
2023-12-20 16:16:35 +03:00
|
|
|
|
|
|
|
return val;
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 16:16:35 +03:00
|
|
|
static const MemoryRegionOps next_dma_ops = {
|
|
|
|
.read = next_dma_read,
|
|
|
|
.write = next_dma_write,
|
2018-06-30 09:45:25 +03:00
|
|
|
.impl.min_access_size = 4,
|
|
|
|
.valid.min_access_size = 4,
|
|
|
|
.valid.max_access_size = 4,
|
2023-12-20 16:16:35 +03:00
|
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
2018-06-30 09:45:25 +03:00
|
|
|
};
|
|
|
|
|
2021-01-15 23:11:56 +03:00
|
|
|
static void next_irq(void *opaque, int number, int level)
|
2018-06-30 09:45:25 +03:00
|
|
|
{
|
2021-01-15 23:12:00 +03:00
|
|
|
NeXTPC *s = NEXT_PC(opaque);
|
|
|
|
M68kCPU *cpu = s->cpu;
|
2018-06-30 09:45:25 +03:00
|
|
|
int shift = 0;
|
|
|
|
|
2023-07-14 14:23:51 +03:00
|
|
|
/* first switch sets interrupt status */
|
2018-06-30 09:45:25 +03:00
|
|
|
/* DPRINTF("IRQ %i\n",number); */
|
|
|
|
switch (number) {
|
|
|
|
/* level 3 - floppy, kbd/mouse, power, ether rx/tx, scsi, clock */
|
|
|
|
case NEXT_FD_I:
|
2020-02-18 12:43:55 +03:00
|
|
|
shift = 7;
|
2018-06-30 09:45:25 +03:00
|
|
|
break;
|
|
|
|
case NEXT_KBD_I:
|
|
|
|
shift = 3;
|
|
|
|
break;
|
|
|
|
case NEXT_PWR_I:
|
|
|
|
shift = 2;
|
|
|
|
break;
|
|
|
|
case NEXT_ENRX_I:
|
|
|
|
shift = 9;
|
|
|
|
break;
|
|
|
|
case NEXT_ENTX_I:
|
|
|
|
shift = 10;
|
|
|
|
break;
|
|
|
|
case NEXT_SCSI_I:
|
|
|
|
shift = 12;
|
|
|
|
break;
|
|
|
|
case NEXT_CLK_I:
|
|
|
|
shift = 5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* level 5 - scc (serial) */
|
|
|
|
case NEXT_SCC_I:
|
|
|
|
shift = 17;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* level 6 - audio etherrx/tx dma */
|
|
|
|
case NEXT_ENTX_DMA_I:
|
|
|
|
shift = 28;
|
|
|
|
break;
|
|
|
|
case NEXT_ENRX_DMA_I:
|
|
|
|
shift = 27;
|
|
|
|
break;
|
|
|
|
case NEXT_SCSI_DMA_I:
|
|
|
|
shift = 26;
|
|
|
|
break;
|
|
|
|
case NEXT_SND_I:
|
|
|
|
shift = 23;
|
|
|
|
break;
|
|
|
|
case NEXT_SCC_DMA_I:
|
|
|
|
shift = 21;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* this HAS to be wrong, the interrupt handlers in mach and together
|
|
|
|
* int_status and int_mask and return if there is a hit
|
|
|
|
*/
|
2021-01-15 23:12:01 +03:00
|
|
|
if (s->int_mask & (1 << shift)) {
|
2018-06-30 09:45:25 +03:00
|
|
|
DPRINTF("%x interrupt masked @ %x\n", 1 << shift, cpu->env.pc);
|
|
|
|
/* return; */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* second switch triggers the correct interrupt */
|
|
|
|
if (level) {
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_status |= 1 << shift;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
switch (number) {
|
|
|
|
/* level 3 - floppy, kbd/mouse, power, ether rx/tx, scsi, clock */
|
|
|
|
case NEXT_FD_I:
|
|
|
|
case NEXT_KBD_I:
|
|
|
|
case NEXT_PWR_I:
|
|
|
|
case NEXT_ENRX_I:
|
|
|
|
case NEXT_ENTX_I:
|
|
|
|
case NEXT_SCSI_I:
|
|
|
|
case NEXT_CLK_I:
|
|
|
|
m68k_set_irq_level(cpu, 3, 27);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* level 5 - scc (serial) */
|
|
|
|
case NEXT_SCC_I:
|
|
|
|
m68k_set_irq_level(cpu, 5, 29);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* level 6 - audio etherrx/tx dma */
|
|
|
|
case NEXT_ENTX_DMA_I:
|
|
|
|
case NEXT_ENRX_DMA_I:
|
|
|
|
case NEXT_SCSI_DMA_I:
|
|
|
|
case NEXT_SND_I:
|
|
|
|
case NEXT_SCC_DMA_I:
|
|
|
|
m68k_set_irq_level(cpu, 6, 30);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2021-01-15 23:12:01 +03:00
|
|
|
s->int_status &= ~(1 << shift);
|
2018-06-30 09:45:25 +03:00
|
|
|
cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-30 16:23:49 +03:00
|
|
|
static void nextdma_write(void *opaque, uint8_t *buf, int size, int type)
|
|
|
|
{
|
|
|
|
uint32_t base_addr;
|
|
|
|
int irq = 0;
|
|
|
|
uint8_t align = 16;
|
|
|
|
NeXTState *next_state = NEXT_MACHINE(qdev_get_machine());
|
|
|
|
|
|
|
|
if (type == NEXTDMA_ENRX || type == NEXTDMA_ENTX) {
|
|
|
|
align = 32;
|
|
|
|
}
|
|
|
|
/* Most DMA is supposedly 16 byte aligned */
|
|
|
|
if ((size % align) != 0) {
|
|
|
|
size -= size % align;
|
|
|
|
size += align;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prom sets the dma start using initbuf while the bootloader uses next
|
|
|
|
* so we check to see if initbuf is 0
|
|
|
|
*/
|
|
|
|
if (next_state->dma[type].next_initbuf == 0) {
|
|
|
|
base_addr = next_state->dma[type].next;
|
|
|
|
} else {
|
|
|
|
base_addr = next_state->dma[type].next_initbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu_physical_memory_write(base_addr, buf, size);
|
|
|
|
|
|
|
|
next_state->dma[type].next_initbuf = 0;
|
|
|
|
|
|
|
|
/* saved limit is checked to calculate packet size by both, rom and netbsd */
|
|
|
|
next_state->dma[type].saved_limit = (next_state->dma[type].next + size);
|
|
|
|
next_state->dma[type].saved_next = (next_state->dma[type].next);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 32 bytes under savedbase seems to be some kind of register
|
|
|
|
* of which the purpose is unknown as of yet
|
|
|
|
*/
|
|
|
|
/* stl_phys(s->rx_dma.base-32,0xFFFFFFFF); */
|
|
|
|
|
|
|
|
if (!(next_state->dma[type].csr & DMA_SUPDATE)) {
|
|
|
|
next_state->dma[type].next = next_state->dma[type].start;
|
|
|
|
next_state->dma[type].limit = next_state->dma[type].stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set dma registers and raise an irq */
|
|
|
|
next_state->dma[type].csr |= DMA_COMPLETE; /* DON'T CHANGE THIS! */
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case NEXTDMA_SCSI:
|
|
|
|
irq = NEXT_SCSI_DMA_I;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
next_irq(opaque, irq, 1);
|
|
|
|
next_irq(opaque, irq, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nextscsi_read(void *opaque, uint8_t *buf, int len)
|
|
|
|
{
|
|
|
|
DPRINTF("SCSI READ: %x\n", len);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nextscsi_write(void *opaque, uint8_t *buf, int size)
|
|
|
|
{
|
|
|
|
DPRINTF("SCSI WRITE: %i\n", size);
|
|
|
|
nextdma_write(opaque, buf, size, NEXTDMA_SCSI);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void next_scsi_init(DeviceState *pcdev, M68kCPU *cpu)
|
|
|
|
{
|
|
|
|
struct NeXTPC *next_pc = NEXT_PC(pcdev);
|
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *sysbusdev;
|
|
|
|
SysBusESPState *sysbus_esp;
|
|
|
|
ESPState *esp;
|
|
|
|
|
|
|
|
dev = qdev_new(TYPE_SYSBUS_ESP);
|
|
|
|
sysbus_esp = SYSBUS_ESP(dev);
|
|
|
|
esp = &sysbus_esp->esp;
|
|
|
|
esp->dma_memory_read = nextscsi_read;
|
|
|
|
esp->dma_memory_write = nextscsi_write;
|
|
|
|
esp->dma_opaque = pcdev;
|
|
|
|
sysbus_esp->it_shift = 0;
|
|
|
|
esp->dma_enabled = 1;
|
|
|
|
sysbusdev = SYS_BUS_DEVICE(dev);
|
|
|
|
sysbus_realize_and_unref(sysbusdev, &error_fatal);
|
|
|
|
sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(pcdev, NEXT_SCSI_I));
|
|
|
|
sysbus_mmio_map(sysbusdev, 0, 0x2114000);
|
|
|
|
|
|
|
|
next_pc->scsi_reset = qdev_get_gpio_in(dev, 0);
|
|
|
|
next_pc->scsi_dma = qdev_get_gpio_in(dev, 1);
|
|
|
|
|
|
|
|
scsi_bus_legacy_handle_cmdline(&esp->bus);
|
|
|
|
}
|
|
|
|
|
2021-01-15 23:12:00 +03:00
|
|
|
static void next_escc_init(DeviceState *pcdev)
|
2018-06-30 17:58:01 +03:00
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *s;
|
|
|
|
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_ESCC);
|
2018-06-30 17:58:01 +03:00
|
|
|
qdev_prop_set_uint32(dev, "disabled", 0);
|
|
|
|
qdev_prop_set_uint32(dev, "frequency", 9600 * 384);
|
|
|
|
qdev_prop_set_uint32(dev, "it_shift", 0);
|
|
|
|
qdev_prop_set_bit(dev, "bit_swap", true);
|
|
|
|
qdev_prop_set_chr(dev, "chrB", serial_hd(1));
|
|
|
|
qdev_prop_set_chr(dev, "chrA", serial_hd(0));
|
|
|
|
qdev_prop_set_uint32(dev, "chnBtype", escc_serial);
|
|
|
|
qdev_prop_set_uint32(dev, "chnAtype", escc_serial);
|
|
|
|
|
|
|
|
s = SYS_BUS_DEVICE(dev);
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2021-01-15 23:12:02 +03:00
|
|
|
sysbus_connect_irq(s, 0, qdev_get_gpio_in(pcdev, NEXT_SCC_I));
|
|
|
|
sysbus_connect_irq(s, 1, qdev_get_gpio_in(pcdev, NEXT_SCC_DMA_I));
|
2018-06-30 17:58:01 +03:00
|
|
|
sysbus_mmio_map(s, 0, 0x2118000);
|
|
|
|
}
|
|
|
|
|
2021-01-15 23:11:57 +03:00
|
|
|
static void next_pc_reset(DeviceState *dev)
|
|
|
|
{
|
2021-01-15 23:11:58 +03:00
|
|
|
NeXTPC *s = NEXT_PC(dev);
|
|
|
|
|
|
|
|
/* Set internal registers to initial values */
|
|
|
|
/* 0x0000XX00 << vital bits */
|
|
|
|
s->scr1 = 0x00011102;
|
|
|
|
s->scr2 = 0x00ff0c80;
|
2023-12-20 16:16:38 +03:00
|
|
|
s->old_scr2 = s->scr2;
|
2021-01-15 23:12:03 +03:00
|
|
|
|
|
|
|
s->rtc.status = 0x90;
|
|
|
|
|
|
|
|
/* Load RTC RAM - TODO: provide possibility to load contents from file */
|
|
|
|
memcpy(s->rtc.ram, rtc_ram2, 32);
|
2021-01-15 23:11:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void next_pc_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2021-01-15 23:11:58 +03:00
|
|
|
NeXTPC *s = NEXT_PC(dev);
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
|
|
|
|
2021-01-15 23:12:02 +03:00
|
|
|
qdev_init_gpio_in(dev, next_irq, NEXT_NUM_IRQS);
|
|
|
|
|
2023-12-20 16:16:33 +03:00
|
|
|
memory_region_init_io(&s->mmiomem, OBJECT(s), &next_mmio_ops, s,
|
|
|
|
"next.mmio", 0xd0000);
|
2023-12-20 16:16:34 +03:00
|
|
|
memory_region_init_io(&s->scrmem, OBJECT(s), &next_scr_ops, s,
|
2021-01-15 23:11:59 +03:00
|
|
|
"next.scr", 0x20000);
|
2021-01-15 23:11:58 +03:00
|
|
|
sysbus_init_mmio(sbd, &s->mmiomem);
|
2021-01-15 23:11:59 +03:00
|
|
|
sysbus_init_mmio(sbd, &s->scrmem);
|
2021-01-15 23:11:57 +03:00
|
|
|
}
|
|
|
|
|
2021-01-15 23:12:00 +03:00
|
|
|
/*
|
|
|
|
* If the m68k CPU implemented its inbound irq lines as GPIO lines
|
|
|
|
* rather than via the m68k_set_irq_level() function we would not need
|
|
|
|
* this cpu link property and could instead provide outbound IRQ lines
|
|
|
|
* that the board could wire up to the CPU.
|
|
|
|
*/
|
|
|
|
static Property next_pc_properties[] = {
|
|
|
|
DEFINE_PROP_LINK("cpu", NeXTPC, cpu, TYPE_M68K_CPU, M68kCPU *),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
2021-01-15 23:12:05 +03:00
|
|
|
static const VMStateDescription next_rtc_vmstate = {
|
|
|
|
.name = "next-rtc",
|
2023-12-20 16:16:37 +03:00
|
|
|
.version_id = 2,
|
|
|
|
.minimum_version_id = 2,
|
2023-12-21 06:16:20 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2023-12-20 16:16:37 +03:00
|
|
|
VMSTATE_INT8(phase, NextRtc),
|
2021-01-15 23:12:05 +03:00
|
|
|
VMSTATE_UINT8_ARRAY(ram, NextRtc, 32),
|
|
|
|
VMSTATE_UINT8(command, NextRtc),
|
|
|
|
VMSTATE_UINT8(value, NextRtc),
|
|
|
|
VMSTATE_UINT8(status, NextRtc),
|
|
|
|
VMSTATE_UINT8(control, NextRtc),
|
|
|
|
VMSTATE_UINT8(retval, NextRtc),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const VMStateDescription next_pc_vmstate = {
|
|
|
|
.name = "next-pc",
|
2023-12-20 16:16:36 +03:00
|
|
|
.version_id = 2,
|
|
|
|
.minimum_version_id = 2,
|
2023-12-21 06:16:20 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2021-01-15 23:12:05 +03:00
|
|
|
VMSTATE_UINT32(scr1, NeXTPC),
|
|
|
|
VMSTATE_UINT32(scr2, NeXTPC),
|
2023-12-20 16:16:38 +03:00
|
|
|
VMSTATE_UINT32(old_scr2, NeXTPC),
|
2021-01-15 23:12:05 +03:00
|
|
|
VMSTATE_UINT32(int_mask, NeXTPC),
|
|
|
|
VMSTATE_UINT32(int_status, NeXTPC),
|
2023-12-20 16:16:36 +03:00
|
|
|
VMSTATE_UINT32(led, NeXTPC),
|
2021-01-15 23:12:05 +03:00
|
|
|
VMSTATE_UINT8(scsi_csr_1, NeXTPC),
|
|
|
|
VMSTATE_UINT8(scsi_csr_2, NeXTPC),
|
|
|
|
VMSTATE_STRUCT(rtc, NeXTPC, 0, next_rtc_vmstate, NextRtc),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-15 23:11:57 +03:00
|
|
|
static void next_pc_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
|
|
|
dc->desc = "NeXT Peripheral Controller";
|
|
|
|
dc->realize = next_pc_realize;
|
2024-09-13 17:31:44 +03:00
|
|
|
device_class_set_legacy_reset(dc, next_pc_reset);
|
2021-01-15 23:12:00 +03:00
|
|
|
device_class_set_props(dc, next_pc_properties);
|
2021-01-15 23:12:05 +03:00
|
|
|
dc->vmsd = &next_pc_vmstate;
|
2021-01-15 23:11:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo next_pc_info = {
|
|
|
|
.name = TYPE_NEXT_PC,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(NeXTPC),
|
|
|
|
.class_init = next_pc_class_init,
|
|
|
|
};
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
static void next_cube_init(MachineState *machine)
|
|
|
|
{
|
2023-12-20 16:16:41 +03:00
|
|
|
NeXTState *m = NEXT_MACHINE(machine);
|
2018-06-30 09:45:25 +03:00
|
|
|
M68kCPU *cpu;
|
|
|
|
CPUM68KState *env;
|
|
|
|
MemoryRegion *sysmem = get_system_memory();
|
2020-10-26 17:30:20 +03:00
|
|
|
const char *bios_name = machine->firmware ?: ROM_FILE;
|
2021-01-15 23:11:57 +03:00
|
|
|
DeviceState *pcdev;
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* Initialize the cpu core */
|
|
|
|
cpu = M68K_CPU(cpu_create(machine->cpu_type));
|
|
|
|
if (!cpu) {
|
|
|
|
error_report("Unable to find m68k CPU definition");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
env = &cpu->env;
|
|
|
|
|
|
|
|
/* Initialize CPU registers. */
|
|
|
|
env->vbr = 0;
|
|
|
|
env->sr = 0x2700;
|
|
|
|
|
2021-01-15 23:11:57 +03:00
|
|
|
/* Peripheral Controller */
|
|
|
|
pcdev = qdev_new(TYPE_NEXT_PC);
|
2021-01-15 23:12:00 +03:00
|
|
|
object_property_set_link(OBJECT(pcdev), "cpu", OBJECT(cpu), &error_abort);
|
2021-01-15 23:11:57 +03:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(pcdev), &error_fatal);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* 64MB RAM starting at 0x04000000 */
|
2020-02-19 19:09:23 +03:00
|
|
|
memory_region_add_subregion(sysmem, 0x04000000, machine->ram);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* Framebuffer */
|
2023-10-24 11:30:08 +03:00
|
|
|
sysbus_create_simple(TYPE_NEXTFB, 0x0B000000, NULL);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* MMIO */
|
2021-01-15 23:11:58 +03:00
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 0, 0x02000000);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
2021-01-15 23:11:59 +03:00
|
|
|
/* BMAP IO - acts as a catch-all for now */
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 1, 0x02100000);
|
|
|
|
|
2018-06-30 09:45:25 +03:00
|
|
|
/* BMAP memory */
|
2023-12-20 16:16:41 +03:00
|
|
|
memory_region_init_ram_flags_nomigrate(&m->bmapm1, NULL, "next.bmapmem",
|
|
|
|
64, RAM_SHARED, &error_fatal);
|
|
|
|
memory_region_add_subregion(sysmem, 0x020c0000, &m->bmapm1);
|
2018-06-30 09:45:25 +03:00
|
|
|
/* The Rev_2.5_v66.bin firmware accesses it at 0x820c0020, too */
|
2023-12-20 16:16:41 +03:00
|
|
|
memory_region_init_alias(&m->bmapm2, NULL, "next.bmapmem2", &m->bmapm1,
|
|
|
|
0x0, 64);
|
|
|
|
memory_region_add_subregion(sysmem, 0x820c0000, &m->bmapm2);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* KBD */
|
2023-10-24 11:30:08 +03:00
|
|
|
sysbus_create_simple(TYPE_NEXTKBD, 0x0200e000, NULL);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* Load ROM here */
|
2023-12-20 16:16:41 +03:00
|
|
|
memory_region_init_rom(&m->rom, NULL, "next.rom", 0x20000, &error_fatal);
|
|
|
|
memory_region_add_subregion(sysmem, 0x01000000, &m->rom);
|
|
|
|
memory_region_init_alias(&m->rom2, NULL, "next.rom2", &m->rom, 0x0,
|
|
|
|
0x20000);
|
|
|
|
memory_region_add_subregion(sysmem, 0x0, &m->rom2);
|
2018-06-30 09:45:25 +03:00
|
|
|
if (load_image_targphys(bios_name, 0x01000000, 0x20000) < 8) {
|
|
|
|
if (!qtest_enabled()) {
|
|
|
|
error_report("Failed to load firmware '%s'.", bios_name);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uint8_t *ptr;
|
|
|
|
/* Initial PC is always at offset 4 in firmware binaries */
|
|
|
|
ptr = rom_ptr(0x01000004, 4);
|
|
|
|
g_assert(ptr != NULL);
|
|
|
|
env->pc = ldl_p(ptr);
|
|
|
|
if (env->pc >= 0x01020000) {
|
|
|
|
error_report("'%s' does not seem to be a valid firmware image.",
|
|
|
|
bios_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Serial */
|
2021-01-15 23:12:00 +03:00
|
|
|
next_escc_init(pcdev);
|
2018-06-30 17:58:01 +03:00
|
|
|
|
|
|
|
/* TODO: */
|
2018-06-30 09:45:25 +03:00
|
|
|
/* Network */
|
|
|
|
/* SCSI */
|
2023-09-30 16:23:49 +03:00
|
|
|
next_scsi_init(pcdev, cpu);
|
2018-06-30 09:45:25 +03:00
|
|
|
|
|
|
|
/* DMA */
|
2023-12-20 16:16:41 +03:00
|
|
|
memory_region_init_io(&m->dmamem, NULL, &next_dma_ops, machine,
|
|
|
|
"next.dma", 0x5000);
|
|
|
|
memory_region_add_subregion(sysmem, 0x02000000, &m->dmamem);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void next_machine_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
|
|
|
|
|
mc->desc = "NeXT Cube";
|
|
|
|
mc->init = next_cube_init;
|
2023-09-30 16:23:49 +03:00
|
|
|
mc->block_default_type = IF_SCSI;
|
2018-06-30 09:45:25 +03:00
|
|
|
mc->default_ram_size = RAM_SIZE;
|
2020-02-19 19:09:23 +03:00
|
|
|
mc->default_ram_id = "next.ram";
|
2018-06-30 09:45:25 +03:00
|
|
|
mc->default_cpu_type = M68K_CPU_TYPE_NAME("m68040");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo next_typeinfo = {
|
|
|
|
.name = TYPE_NEXT_MACHINE,
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.class_init = next_machine_class_init,
|
|
|
|
.instance_size = sizeof(NeXTState),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void next_register_type(void)
|
|
|
|
{
|
|
|
|
type_register_static(&next_typeinfo);
|
2021-01-15 23:11:57 +03:00
|
|
|
type_register_static(&next_pc_info);
|
2018-06-30 09:45:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type_init(next_register_type)
|