static int rtc_initfn(ISADevice *dev) { RTCState *s = DO_UPCAST(RTCState, dev, dev); int base = 0x70; int isairq = 8; isa_init_irq(dev, &s->irq, isairq); s->cmos_data[RTC_REG_A] = 0x26; s->cmos_data[RTC_REG_B] = 0x02; s->cmos_data[RTC_REG_C] = 0x00; s->cmos_data[RTC_REG_D] = 0x80; rtc_set_date_from_host(dev); s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s); #ifdef TARGET_I386 if (rtc_td_hack) s->coalesced_timer = qemu_new_timer(rtc_clock, rtc_coalesced_timer, s); #endif s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s); s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s); s->next_second_time = qemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100; qemu_mod_timer(s->second_timer2, s->next_second_time); register_ioport_write(base, 2, 1, cmos_ioport_write, s); register_ioport_read(base, 2, 1, cmos_ioport_read, s); qdev_set_legacy_instance_id(&dev->qdev, base, 2); qemu_register_reset(rtc_reset, s); return 0; }
static void tpm_tis_realizefn(DeviceState *dev, Error **errp) { TPMState *s = TPM(dev); TPMTISEmuState *tis = &s->s.tis; s->be_driver = qemu_find_tpm(s->backend); if (!s->be_driver) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " "found", s->backend); return; } s->be_driver->fe_model = TPM_MODEL_TPM_TIS; if (s->be_driver->ops->init(s->be_driver, s, tpm_tis_receive_cb)) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " "initialized", s->backend); return; } if (tis->irq_num > 15) { error_setg(errp, "tpm_tis: IRQ %d for TPM TIS is outside valid range " "of 0 to 15.\n", tis->irq_num); return; } tis->bh = qemu_bh_new(tpm_tis_receive_bh, s); isa_init_irq(&s->busdev, &tis->irq, tis->irq_num); }
static void i8042_realizefn(DeviceState *dev, Error **errp) { ISADevice *isadev = ISA_DEVICE(dev); ISAKBDState *isa_s = I8042(dev); KBDState *s = &isa_s->kbd; isa_init_irq(isadev, &s->irq_kbd, 1); isa_init_irq(isadev, &s->irq_mouse, 12); isa_register_ioport(isadev, isa_s->io + 0, 0x60); isa_register_ioport(isadev, isa_s->io + 1, 0x64); s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s); s->mouse = ps2_mouse_init(kbd_update_aux_irq, s); qemu_register_reset(kbd_reset, s); }
static void serial_isa_realizefn(DeviceState *dev, Error **errp) { static int index; ISADevice *isadev = ISA_DEVICE(dev); ISASerialState *isa = ISA_SERIAL(dev); SerialState *s = &isa->state; if (isa->index == -1) { isa->index = index; } if (isa->index >= MAX_SERIAL_PORTS) { error_setg(errp, "Max. supported number of ISA serial ports is %d.", MAX_SERIAL_PORTS); return; } if (isa->iobase == -1) { isa->iobase = isa_serial_io[isa->index]; } if (isa->isairq == -1) { isa->isairq = isa_serial_irq[isa->index]; } index++; s->baudbase = 115200; isa_init_irq(isadev, &s->irq, isa->isairq); serial_realize_core(s, errp); qdev_set_legacy_instance_id(dev, isa->iobase, 3); memory_region_init_io(&s->io, OBJECT(isa), &serial_io_ops, s, "serial", 8); isa_register_ioport(isadev, &s->io, isa->iobase); }
static int serial_isa_initfn(ISADevice *dev) { static int index; ISASerialState *isa = ISA_SERIAL(dev); SerialState *s = &isa->state; if (isa->index == -1) { isa->index = index; } if (isa->index >= MAX_SERIAL_PORTS) { return -1; } if (isa->iobase == -1) { isa->iobase = isa_serial_io[isa->index]; } if (isa->isairq == -1) { isa->isairq = isa_serial_irq[isa->index]; } index++; s->baudbase = 115200; isa_init_irq(dev, &s->irq, isa->isairq); serial_init_core(s); qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 3); memory_region_init_io(&s->io, &serial_io_ops, s, "serial", 8); isa_register_ioport(dev, &s->io, isa->iobase); return 0; }
void __init footbridge_init_irq(void) { __fb_init_irq(); if (!footbridge_cfn_mode()) return; if (machine_is_ebsa285()) isa_init_irq(IRQ_PCI); if (machine_is_cats()) isa_init_irq(IRQ_IN2); if (machine_is_netwinder()) isa_init_irq(IRQ_IN3); }
static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp) { ISADevice *isadev = ISA_DEVICE(dev); ISAIPMIBTDevice *iib = ISA_IPMI_BT(dev); IPMIInterface *ii = IPMI_INTERFACE(dev); IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii); if (!iib->bt.bmc) { error_setg(errp, "IPMI device requires a bmc attribute to be set"); return; } iib->uuid = ipmi_next_uuid(); iib->bt.bmc->intf = ii; iic->init(ii, errp); if (*errp) return; if (iib->isairq > 0) { isa_init_irq(isadev, &iib->bt.irq, iib->isairq); iib->bt.use_irq = 1; } qdev_set_legacy_instance_id(dev, iib->bt.io_base, iib->bt.io_length); isa_register_ioport(isadev, &iib->bt.io, iib->bt.io_base); }
void __init footbridge_init_irq(void) { __fb_init_irq(); if (!footbridge_cfn_mode()) return; if (machine_is_ebsa285()) /* The following is dependent on which slot * you plug the Southbridge card into. We * currently assume that you plug it into * the right-hand most slot. */ isa_init_irq(IRQ_PCI); if (machine_is_cats()) isa_init_irq(IRQ_IN2); if (machine_is_netwinder()) isa_init_irq(IRQ_IN3); }
static int i8042_initfn(ISADevice *dev) { KBDState *s = &(DO_UPCAST(ISAKBDState, dev, dev)->kbd); isa_init_irq(dev, &s->irq_kbd, 1); isa_init_irq(dev, &s->irq_mouse, 12); kbd_reset(s); vmstate_register(0, &vmstate_kbd, s); register_ioport_read(0x60, 1, 1, kbd_read_data, s); register_ioport_write(0x60, 1, 1, kbd_write_data, s); register_ioport_read(0x64, 1, 1, kbd_read_status, s); register_ioport_write(0x64, 1, 1, kbd_write_command, s); s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s); s->mouse = ps2_mouse_init(kbd_update_aux_irq, s); #ifdef TARGET_I386 vmmouse_init(s->mouse); #endif qemu_register_reset(kbd_reset, s); return 0; }
static int parallel_isa_initfn(ISADevice *dev) { static int index; ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev); ParallelState *s = &isa->state; int base; uint8_t dummy; if (!s->chr) { fprintf(stderr, "Can't create parallel device, empty char device\n"); exit(1); } if (isa->index == -1) isa->index = index; if (isa->index >= MAX_PARALLEL_PORTS) return -1; if (isa->iobase == -1) isa->iobase = isa_parallel_io[isa->index]; index++; base = isa->iobase; isa_init_irq(dev, &s->irq, isa->isairq); qemu_register_reset(parallel_reset, s); if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) { s->hw_driver = 1; s->status = dummy; } if (s->hw_driver) { register_ioport_write(base, 8, 1, parallel_ioport_write_hw, s); register_ioport_read(base, 8, 1, parallel_ioport_read_hw, s); isa_init_ioport_range(dev, base, 8); register_ioport_write(base+4, 1, 2, parallel_ioport_eppdata_write_hw2, s); register_ioport_read(base+4, 1, 2, parallel_ioport_eppdata_read_hw2, s); register_ioport_write(base+4, 1, 4, parallel_ioport_eppdata_write_hw4, s); register_ioport_read(base+4, 1, 4, parallel_ioport_eppdata_read_hw4, s); isa_init_ioport(dev, base+4); register_ioport_write(base+0x400, 8, 1, parallel_ioport_ecp_write, s); register_ioport_read(base+0x400, 8, 1, parallel_ioport_ecp_read, s); isa_init_ioport_range(dev, base+0x400, 8); } else { register_ioport_write(base, 8, 1, parallel_ioport_write_sw, s); register_ioport_read(base, 8, 1, parallel_ioport_read_sw, s); isa_init_ioport_range(dev, base, 8); } return 0; }
ISADevice *rtc_init(int base_year, qemu_irq intercept_irq) { ISADevice *dev; RTCState *s; dev = isa_create("mc146818rtc"); s = DO_UPCAST(RTCState, dev, dev); qdev_prop_set_int32(&dev->qdev, "base_year", base_year); qdev_init_nofail(&dev->qdev); if (intercept_irq) { s->irq = intercept_irq; } else { isa_init_irq(dev, &s->irq, RTC_ISA_IRQ); } return dev; }
ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) { DeviceState *dev; ISADevice *isadev; RTCState *s; isadev = isa_create(bus, TYPE_MC146818_RTC); dev = DEVICE(isadev); s = MC146818_RTC(isadev); qdev_prop_set_int32(dev, "base_year", base_year); qdev_init_nofail(dev); if (intercept_irq) { s->irq = intercept_irq; } else { isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ); } return isadev; }
static int isa_ne2000_initfn(ISADevice *dev) { ISANE2000State *isa = DO_UPCAST(ISANE2000State, dev, dev); NE2000State *s = &isa->ne2000; ne2000_setup_io(s, 0x20); isa_register_ioport(dev, &s->io, isa->iobase); isa_init_irq(dev, &s->irq, isa->isairq); qemu_macaddr_default_if_unset(&s->c.macaddr); ne2000_reset(s); s->nic = qemu_new_nic(&net_ne2000_isa_info, &s->c, object_get_typename(OBJECT(dev)), dev->qdev.id, s); qemu_format_nic_info_str(&s->nic->nc, s->c.macaddr.a); return 0; }
static int pc98_ide_initfn(ISADevice *dev) { PC98IDEState *s = DO_UPCAST(PC98IDEState, dev, dev); int i; ide_bus_new(&s->bus[0], &s->dev.qdev, 0); ide_bus_new(&s->bus[1], &s->dev.qdev, 1); isa_init_irq(dev, &s->irq, s->isairq); ide_init2(&s->bus[0], s->irq); ide_init2(&s->bus[1], s->irq); register_ioport_write(0xf0, 1, 1, pc98_ide_cpu_shutdown, s); register_ioport_read(0xf0, 1, 1, pc98_ide_connection_read, s); isa_init_ioport(dev, 0xf0); register_ioport_write(0x430, 1, 1, pc98_ide_bank_write, s); register_ioport_read(0x430, 1, 1, pc98_ide_bank_read, s); isa_init_ioport(dev, 0x430); register_ioport_write(0x432, 1, 1, pc98_ide_bank_write, s); register_ioport_read(0x432, 1, 1, pc98_ide_bank_read, s); isa_init_ioport(dev, 0x432); for (i = 0; i < 8; i++) { register_ioport_write(0x640 + (i << 1), 1, 1, pc98_ide_ioport_write, s); register_ioport_read(0x640 + (i << 1), 1, 1, pc98_ide_ioport_read, s); isa_init_ioport(dev, 0x640 + (i << 1)); } register_ioport_write(0x640, 2, 2, pc98_ide_data_writew, s); register_ioport_read(0x640, 2, 2, pc98_ide_data_readw, s); /*isa_init_ioport_range(dev, 0x640, 2);*/ register_ioport_write(0x640, 4, 4, pc98_ide_data_writel, s); register_ioport_read(0x640, 4, 4, pc98_ide_data_readl, s); /*isa_init_ioport_range(dev, 0x640, 4);*/ register_ioport_write(0x74c, 1, 1, pc98_ide_digital_write, s); register_ioport_read(0x74c, 1, 1, pc98_ide_status_read, s); isa_init_ioport(dev, 0x74c); register_ioport_read(0x74e, 1, 1, pc98_ide_digital_read, s); isa_init_ioport(dev, 0x74e); vmstate_register(&dev->qdev, 0, &vmstate_ide_pc98, s); pc98_ide_reset(&dev->qdev); return 0; };
static void parallel_isa_realizefn(DeviceState *dev, Error **errp) { static int index; ISADevice *isadev = ISA_DEVICE(dev); ISAParallelState *isa = ISA_PARALLEL(dev); ParallelState *s = &isa->state; int base; uint8_t dummy; if (!s->chr) { error_setg(errp, "Can't create parallel device, empty char device"); return; } if (isa->index == -1) { isa->index = index; } if (isa->index >= MAX_PARALLEL_PORTS) { error_setg(errp, "Max. supported number of parallel ports is %d.", MAX_PARALLEL_PORTS); return; } if (isa->iobase == -1) { isa->iobase = isa_parallel_io[isa->index]; } index++; base = isa->iobase; isa_init_irq(isadev, &s->irq, isa->isairq); qemu_register_reset(parallel_reset, s); if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) { s->hw_driver = 1; s->status = dummy; } isa_register_portio_list(isadev, base, (s->hw_driver ? &isa_parallel_portio_hw_list[0] : &isa_parallel_portio_sw_list[0]), s, "parallel"); }
static int pc98_serial_initfn(ISADevice *dev) { SerialPortState *s = DO_UPCAST(SerialPortState, dev, dev); isa_init_irq(dev, &s->pic, s->irq); register_ioport_write(0x30, 1, 1, sio_data_write, s); register_ioport_read(0x30, 1, 1, sio_data_read, s); isa_init_ioport(dev, 0x30); register_ioport_write(0x32, 1, 1, sio_cmd_write, s); register_ioport_read(0x32, 1, 1, sio_status_read, s); isa_init_ioport(dev, 0x32); s->sio_timer = qemu_new_timer(rt_clock, sio_timer_handler, s); pc98_serial_reset(s); qemu_register_reset(pc98_serial_reset, s); return 0; }
static int pc98_kbd_initfn(ISADevice *dev) { KeyBoardState *s = DO_UPCAST(KeyBoardState, dev, dev); isa_init_irq(dev, &s->pic, s->irq); register_ioport_write(0x41, 1, 1, sio_data_write, s); register_ioport_read(0x41, 1, 1, sio_data_read, s); isa_init_ioport(dev, 0x41); register_ioport_write(0x43, 1, 1, sio_cmd_write, s); register_ioport_read(0x43, 1, 1, sio_status_read, s); isa_init_ioport(dev, 0x43); s->sio_timer = qemu_new_timer(rt_clock, sio_timer_handler, s); qemu_add_kbd_event_handler(kbd_event_handler, s); pc98_kbd_reset(s); qemu_register_reset(pc98_kbd_reset, s); return 0; }
static int parallel_isa_initfn(ISADevice *dev) { static int index; ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev); ParallelState *s = &isa->state; int base; uint8_t dummy; if (!s->chr) { fprintf(stderr, "Can't create parallel device, empty char device\n"); exit(1); } if (isa->index == -1) isa->index = index; if (isa->index >= MAX_PARALLEL_PORTS) return -1; if (isa->iobase == -1) isa->iobase = isa_parallel_io[isa->index]; index++; base = isa->iobase; isa_init_irq(dev, &s->irq, isa->isairq); qemu_register_reset(parallel_reset, s); if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) { s->hw_driver = 1; s->status = dummy; } isa_register_portio_list(dev, base, (s->hw_driver ? &isa_parallel_portio_hw_list[0] : &isa_parallel_portio_sw_list[0]), s, "parallel"); return 0; }
void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, int isairq) { qemu_irq irq; isa_init_irq(isadev, &irq, isairq); qdev_connect_gpio_out(DEVICE(isadev), gpioirq, irq); }