ESP SCSI qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
parent
418dcf5b7d
commit
cfb9de9ce4
61
hw/esp.c
61
hw/esp.c
@ -22,7 +22,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hw.h"
|
||||
#include "sysbus.h"
|
||||
#include "scsi-disk.h"
|
||||
#include "scsi.h"
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
typedef struct ESPState ESPState;
|
||||
|
||||
struct ESPState {
|
||||
SysBusDevice busdev;
|
||||
uint32_t it_shift;
|
||||
qemu_irq irq;
|
||||
uint8_t rregs[ESP_REGS];
|
||||
@ -617,9 +618,9 @@ static int esp_load(QEMUFile *f, void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id)
|
||||
static void esp_scsi_attach(DeviceState *host, BlockDriverState *bd, int id)
|
||||
{
|
||||
ESPState *s = (ESPState *)opaque;
|
||||
ESPState *s = FROM_SYSBUS(ESPState, sysbus_from_qdev(host));
|
||||
|
||||
if (id < 0) {
|
||||
for (id = 0; id < ESP_MAX_DEVS; id++) {
|
||||
@ -644,31 +645,53 @@ void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id)
|
||||
s->scsi_dev[id] = scsi_disk_init(bd, 0, esp_command_complete, s);
|
||||
}
|
||||
|
||||
void *esp_init(target_phys_addr_t espaddr, int it_shift,
|
||||
espdma_memory_read_write dma_memory_read,
|
||||
espdma_memory_read_write dma_memory_write,
|
||||
void *dma_opaque, qemu_irq irq, qemu_irq *reset)
|
||||
void esp_init(target_phys_addr_t espaddr, int it_shift,
|
||||
espdma_memory_read_write dma_memory_read,
|
||||
espdma_memory_read_write dma_memory_write,
|
||||
void *dma_opaque, qemu_irq irq, qemu_irq *reset)
|
||||
{
|
||||
ESPState *s;
|
||||
DeviceState *dev;
|
||||
SysBusDevice *s;
|
||||
|
||||
dev = qdev_create(NULL, "esp");
|
||||
qdev_set_prop_ptr(dev, "dma_memory_read", dma_memory_read);
|
||||
qdev_set_prop_ptr(dev, "dma_memory_write", dma_memory_write);
|
||||
qdev_set_prop_ptr(dev, "dma_opaque", dma_opaque);
|
||||
qdev_set_prop_int(dev, "it_shift", it_shift);
|
||||
qdev_init(dev);
|
||||
s = sysbus_from_qdev(dev);
|
||||
sysbus_connect_irq(s, 0, irq);
|
||||
sysbus_mmio_map(s, 0, espaddr);
|
||||
}
|
||||
|
||||
static void esp_init1(SysBusDevice *dev)
|
||||
{
|
||||
ESPState *s = FROM_SYSBUS(ESPState, dev);
|
||||
int esp_io_memory;
|
||||
|
||||
s = qemu_mallocz(sizeof(ESPState));
|
||||
|
||||
s->irq = irq;
|
||||
s->it_shift = it_shift;
|
||||
s->dma_memory_read = dma_memory_read;
|
||||
s->dma_memory_write = dma_memory_write;
|
||||
s->dma_opaque = dma_opaque;
|
||||
sysbus_init_irq(dev, &s->irq);
|
||||
s->it_shift = qdev_get_prop_int(&dev->qdev, "it_shift", -1);
|
||||
assert(s->it_shift != -1);
|
||||
s->dma_memory_read = qdev_get_prop_ptr(&dev->qdev, "dma_memory_read");
|
||||
s->dma_memory_write = qdev_get_prop_ptr(&dev->qdev, "dma_memory_write");
|
||||
s->dma_opaque = qdev_get_prop_ptr(&dev->qdev, "dma_opaque");
|
||||
|
||||
esp_io_memory = cpu_register_io_memory(0, esp_mem_read, esp_mem_write, s);
|
||||
cpu_register_physical_memory(espaddr, ESP_REGS << it_shift, esp_io_memory);
|
||||
sysbus_init_mmio(dev, ESP_REGS << s->it_shift, esp_io_memory);
|
||||
|
||||
esp_reset(s);
|
||||
|
||||
register_savevm("esp", espaddr, 3, esp_save, esp_load, s);
|
||||
register_savevm("esp", -1, 3, esp_save, esp_load, s);
|
||||
qemu_register_reset(esp_reset, s);
|
||||
|
||||
*reset = *qemu_allocate_irqs(parent_esp_reset, s, 1);
|
||||
qdev_init_irq_sink(&dev->qdev, parent_esp_reset, 1);
|
||||
|
||||
return s;
|
||||
scsi_bus_new(&dev->qdev, esp_scsi_attach);
|
||||
}
|
||||
|
||||
static void esp_register_devices(void)
|
||||
{
|
||||
sysbus_register_dev("esp", sizeof(ESPState), esp_init1);
|
||||
}
|
||||
|
||||
device_init(esp_register_devices)
|
||||
|
@ -129,8 +129,6 @@ void mips_jazz_init (ram_addr_t ram_size,
|
||||
qemu_irq *rc4030, *i8259;
|
||||
rc4030_dma *dmas;
|
||||
void* rc4030_opaque;
|
||||
void *scsi_hba;
|
||||
int hd;
|
||||
int s_rtc, s_dma_dummy;
|
||||
NICInfo *nd;
|
||||
PITState *pit;
|
||||
@ -226,15 +224,9 @@ void mips_jazz_init (ram_addr_t ram_size,
|
||||
}
|
||||
|
||||
/* SCSI adapter */
|
||||
scsi_hba = esp_init(0x80002000, 0,
|
||||
rc4030_dma_read, rc4030_dma_write, dmas[0],
|
||||
rc4030[5], &esp_reset);
|
||||
for (n = 0; n < ESP_MAX_DEVS; n++) {
|
||||
hd = drive_get_index(IF_SCSI, 0, n);
|
||||
if (hd != -1) {
|
||||
esp_scsi_attach(scsi_hba, drives_table[hd].bdrv, n);
|
||||
}
|
||||
}
|
||||
esp_init(0x80002000, 0,
|
||||
rc4030_dma_read, rc4030_dma_write, dmas[0],
|
||||
rc4030[5], &esp_reset);
|
||||
|
||||
/* Floppy */
|
||||
if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* esp.c */
|
||||
#define ESP_MAX_DEVS 7
|
||||
typedef void (*espdma_memory_read_write)(void *opaque, uint8_t *buf, int len);
|
||||
void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id);
|
||||
void *esp_init(target_phys_addr_t espaddr, int it_shift,
|
||||
espdma_memory_read_write dma_memory_read,
|
||||
espdma_memory_read_write dma_memory_write,
|
||||
void *dma_opaque, qemu_irq irq, qemu_irq *reset);
|
||||
void esp_init(target_phys_addr_t espaddr, int it_shift,
|
||||
espdma_memory_read_write dma_memory_read,
|
||||
espdma_memory_read_write dma_memory_write,
|
||||
void *dma_opaque, qemu_irq irq, qemu_irq *reset);
|
||||
|
47
hw/sun4m.c
47
hw/sun4m.c
@ -391,7 +391,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
{
|
||||
CPUState *env, *envs[MAX_CPUS];
|
||||
unsigned int i;
|
||||
void *iommu, *espdma, *ledma, *main_esp, *nvram;
|
||||
void *iommu, *espdma, *ledma, *nvram;
|
||||
qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
|
||||
*espdma_irq, *ledma_irq;
|
||||
qemu_irq *esp_reset, *le_reset;
|
||||
@ -533,16 +533,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main_esp = esp_init(hwdef->esp_base, 2,
|
||||
espdma_memory_read, espdma_memory_write,
|
||||
espdma, *espdma_irq, esp_reset);
|
||||
|
||||
for (i = 0; i < ESP_MAX_DEVS; i++) {
|
||||
drive_index = drive_get_index(IF_SCSI, 0, i);
|
||||
if (drive_index == -1)
|
||||
continue;
|
||||
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
|
||||
}
|
||||
esp_init(hwdef->esp_base, 2,
|
||||
espdma_memory_read, espdma_memory_write,
|
||||
espdma, *espdma_irq, esp_reset);
|
||||
|
||||
if (hwdef->cs_base)
|
||||
cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
|
||||
@ -1184,7 +1177,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
{
|
||||
CPUState *env, *envs[MAX_CPUS];
|
||||
unsigned int i;
|
||||
void *iounits[MAX_IOUNITS], *espdma, *ledma, *main_esp, *nvram, *sbi;
|
||||
void *iounits[MAX_IOUNITS], *espdma, *ledma, *nvram, *sbi;
|
||||
qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq,
|
||||
*espdma_irq, *ledma_irq;
|
||||
qemu_irq *esp_reset, *le_reset;
|
||||
@ -1192,7 +1185,6 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
unsigned long kernel_size;
|
||||
int ret;
|
||||
char buf[1024];
|
||||
int drive_index;
|
||||
void *fw_cfg;
|
||||
|
||||
/* init CPUs */
|
||||
@ -1292,16 +1284,9 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main_esp = esp_init(hwdef->esp_base, 2,
|
||||
espdma_memory_read, espdma_memory_write,
|
||||
espdma, *espdma_irq, esp_reset);
|
||||
|
||||
for (i = 0; i < ESP_MAX_DEVS; i++) {
|
||||
drive_index = drive_get_index(IF_SCSI, 0, i);
|
||||
if (drive_index == -1)
|
||||
continue;
|
||||
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
|
||||
}
|
||||
esp_init(hwdef->esp_base, 2,
|
||||
espdma_memory_read, espdma_memory_write,
|
||||
espdma, *espdma_irq, esp_reset);
|
||||
|
||||
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
|
||||
RAM_size);
|
||||
@ -1406,8 +1391,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
const char *initrd_filename, const char *cpu_model)
|
||||
{
|
||||
CPUState *env;
|
||||
unsigned int i;
|
||||
void *iommu, *espdma, *ledma, *main_esp, *nvram;
|
||||
void *iommu, *espdma, *ledma, *nvram;
|
||||
qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq;
|
||||
qemu_irq *esp_reset, *le_reset;
|
||||
qemu_irq *fdc_tc;
|
||||
@ -1518,16 +1502,9 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main_esp = esp_init(hwdef->esp_base, 2,
|
||||
espdma_memory_read, espdma_memory_write,
|
||||
espdma, *espdma_irq, esp_reset);
|
||||
|
||||
for (i = 0; i < ESP_MAX_DEVS; i++) {
|
||||
drive_index = drive_get_index(IF_SCSI, 0, i);
|
||||
if (drive_index == -1)
|
||||
continue;
|
||||
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
|
||||
}
|
||||
esp_init(hwdef->esp_base, 2,
|
||||
espdma_memory_read, espdma_memory_write,
|
||||
espdma, *espdma_irq, esp_reset);
|
||||
|
||||
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
|
||||
RAM_size);
|
||||
|
Loading…
Reference in New Issue
Block a user