version 1.1.1.13, 2018/04/24 19:29:33
|
version 1.1.1.14, 2018/04/24 19:49:52
|
Line 45 typedef struct ESPState ESPState;
|
Line 45 typedef struct ESPState ESPState;
|
|
|
struct ESPState { |
struct ESPState { |
SysBusDevice busdev; |
SysBusDevice busdev; |
|
MemoryRegion iomem; |
uint8_t rregs[ESP_REGS]; |
uint8_t rregs[ESP_REGS]; |
uint8_t wregs[ESP_REGS]; |
uint8_t wregs[ESP_REGS]; |
qemu_irq irq; |
qemu_irq irq; |
Line 389 static void esp_do_dma(ESPState *s)
|
Line 390 static void esp_do_dma(ESPState *s)
|
esp_dma_done(s); |
esp_dma_done(s); |
} |
} |
|
|
static void esp_command_complete(SCSIRequest *req, uint32_t status) |
static void esp_command_complete(SCSIRequest *req, uint32_t status, |
|
size_t resid) |
{ |
{ |
ESPState *s = DO_UPCAST(ESPState, busdev.qdev, req->bus->qbus.parent); |
ESPState *s = DO_UPCAST(ESPState, busdev.qdev, req->bus->qbus.parent); |
|
|
Line 504 static void esp_gpio_demux(void *opaque,
|
Line 506 static void esp_gpio_demux(void *opaque,
|
} |
} |
} |
} |
|
|
static uint32_t esp_mem_readb(void *opaque, target_phys_addr_t addr) |
static uint64_t esp_mem_read(void *opaque, target_phys_addr_t addr, |
|
unsigned size) |
{ |
{ |
ESPState *s = opaque; |
ESPState *s = opaque; |
uint32_t saddr, old_val; |
uint32_t saddr, old_val; |
Line 545 static uint32_t esp_mem_readb(void *opaq
|
Line 548 static uint32_t esp_mem_readb(void *opaq
|
return s->rregs[saddr]; |
return s->rregs[saddr]; |
} |
} |
|
|
static void esp_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) |
static void esp_mem_write(void *opaque, target_phys_addr_t addr, |
|
uint64_t val, unsigned size) |
{ |
{ |
ESPState *s = opaque; |
ESPState *s = opaque; |
uint32_t saddr; |
uint32_t saddr; |
Line 641 static void esp_mem_writeb(void *opaque,
|
Line 645 static void esp_mem_writeb(void *opaque,
|
s->rregs[ESP_RINTR] = 0; |
s->rregs[ESP_RINTR] = 0; |
break; |
break; |
default: |
default: |
ESP_ERROR("Unhandled ESP command (%2.2x)\n", val); |
ESP_ERROR("Unhandled ESP command (%2.2x)\n", (unsigned)val); |
break; |
break; |
} |
} |
break; |
break; |
Line 656 static void esp_mem_writeb(void *opaque,
|
Line 660 static void esp_mem_writeb(void *opaque,
|
s->rregs[saddr] = val; |
s->rregs[saddr] = val; |
break; |
break; |
default: |
default: |
ESP_ERROR("invalid write of 0x%02x at [0x%x]\n", val, saddr); |
ESP_ERROR("invalid write of 0x%02x at [0x%x]\n", (unsigned)val, saddr); |
return; |
return; |
} |
} |
s->wregs[saddr] = val; |
s->wregs[saddr] = val; |
} |
} |
|
|
static CPUReadMemoryFunc * const esp_mem_read[3] = { |
static bool esp_mem_accepts(void *opaque, target_phys_addr_t addr, |
esp_mem_readb, |
unsigned size, bool is_write) |
NULL, |
{ |
NULL, |
return (size == 1) || (is_write && size == 4); |
}; |
} |
|
|
static CPUWriteMemoryFunc * const esp_mem_write[3] = { |
static const MemoryRegionOps esp_mem_ops = { |
esp_mem_writeb, |
.read = esp_mem_read, |
NULL, |
.write = esp_mem_write, |
esp_mem_writeb, |
.endianness = DEVICE_NATIVE_ENDIAN, |
|
.valid.accepts = esp_mem_accepts, |
}; |
}; |
|
|
static const VMStateDescription vmstate_esp = { |
static const VMStateDescription vmstate_esp = { |
Line 735 static const struct SCSIBusInfo esp_scsi
|
Line 740 static const struct SCSIBusInfo esp_scsi
|
static int esp_init1(SysBusDevice *dev) |
static int esp_init1(SysBusDevice *dev) |
{ |
{ |
ESPState *s = FROM_SYSBUS(ESPState, dev); |
ESPState *s = FROM_SYSBUS(ESPState, dev); |
int esp_io_memory; |
|
|
|
sysbus_init_irq(dev, &s->irq); |
sysbus_init_irq(dev, &s->irq); |
assert(s->it_shift != -1); |
assert(s->it_shift != -1); |
|
|
esp_io_memory = cpu_register_io_memory(esp_mem_read, esp_mem_write, s, |
memory_region_init_io(&s->iomem, &esp_mem_ops, s, |
DEVICE_NATIVE_ENDIAN); |
"esp", ESP_REGS << s->it_shift); |
sysbus_init_mmio(dev, ESP_REGS << s->it_shift, esp_io_memory); |
sysbus_init_mmio(dev, &s->iomem); |
|
|
qdev_init_gpio_in(&dev->qdev, esp_gpio_demux, 2); |
qdev_init_gpio_in(&dev->qdev, esp_gpio_demux, 2); |
|
|
Line 750 static int esp_init1(SysBusDevice *dev)
|
Line 754 static int esp_init1(SysBusDevice *dev)
|
return scsi_bus_legacy_handle_cmdline(&s->bus); |
return scsi_bus_legacy_handle_cmdline(&s->bus); |
} |
} |
|
|
static SysBusDeviceInfo esp_info = { |
static Property esp_properties[] = { |
.init = esp_init1, |
{.name = NULL}, |
.qdev.name = "esp", |
}; |
.qdev.size = sizeof(ESPState), |
|
.qdev.vmsd = &vmstate_esp, |
static void esp_class_init(ObjectClass *klass, void *data) |
.qdev.reset = esp_hard_reset, |
{ |
.qdev.props = (Property[]) { |
DeviceClass *dc = DEVICE_CLASS(klass); |
{.name = NULL} |
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); |
} |
|
|
k->init = esp_init1; |
|
dc->reset = esp_hard_reset; |
|
dc->vmsd = &vmstate_esp; |
|
dc->props = esp_properties; |
|
} |
|
|
|
static TypeInfo esp_info = { |
|
.name = "esp", |
|
.parent = TYPE_SYS_BUS_DEVICE, |
|
.instance_size = sizeof(ESPState), |
|
.class_init = esp_class_init, |
}; |
}; |
|
|
static void esp_register_devices(void) |
static void esp_register_types(void) |
{ |
{ |
sysbus_register_withprop(&esp_info); |
type_register_static(&esp_info); |
} |
} |
|
|
device_init(esp_register_devices) |
type_init(esp_register_types) |