parallel.c (b0dc5ee6bd0b16986a0f45ca778f3ead2398b2ee) | parallel.c (db895a1e6a97e919f9b86d60c969377357b05066) |
---|---|
1/* 2 * QEMU Parallel PORT emulation 3 * 4 * Copyright (c) 2003-2005 Fabrice Bellard 5 * Copyright (c) 2007 Marko Kohtala 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 463 unchanged lines hidden (view full) --- 472 473static const MemoryRegionPortio isa_parallel_portio_sw_list[] = { 474 { 0, 8, 1, 475 .read = parallel_ioport_read_sw, 476 .write = parallel_ioport_write_sw }, 477 PORTIO_END_OF_LIST(), 478}; 479 | 1/* 2 * QEMU Parallel PORT emulation 3 * 4 * Copyright (c) 2003-2005 Fabrice Bellard 5 * Copyright (c) 2007 Marko Kohtala 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 463 unchanged lines hidden (view full) --- 472 473static const MemoryRegionPortio isa_parallel_portio_sw_list[] = { 474 { 0, 8, 1, 475 .read = parallel_ioport_read_sw, 476 .write = parallel_ioport_write_sw }, 477 PORTIO_END_OF_LIST(), 478}; 479 |
480static int parallel_isa_initfn(ISADevice *dev) | 480static void parallel_isa_realizefn(DeviceState *dev, Error **errp) |
481{ 482 static int index; | 481{ 482 static int index; |
483 ISADevice *isadev = ISA_DEVICE(dev); |
|
483 ISAParallelState *isa = ISA_PARALLEL(dev); 484 ParallelState *s = &isa->state; 485 int base; 486 uint8_t dummy; 487 488 if (!s->chr) { | 484 ISAParallelState *isa = ISA_PARALLEL(dev); 485 ParallelState *s = &isa->state; 486 int base; 487 uint8_t dummy; 488 489 if (!s->chr) { |
489 fprintf(stderr, "Can't create parallel device, empty char device\n"); 490 exit(1); | 490 error_setg(errp, "Can't create parallel device, empty char device"); 491 return; |
491 } 492 | 492 } 493 |
493 if (isa->index == -1) | 494 if (isa->index == -1) { |
494 isa->index = index; | 495 isa->index = index; |
495 if (isa->index >= MAX_PARALLEL_PORTS) 496 return -1; 497 if (isa->iobase == -1) | 496 } 497 if (isa->index >= MAX_PARALLEL_PORTS) { 498 error_setg(errp, "Max. supported number of parallel ports is %d.", 499 MAX_PARALLEL_PORTS); 500 return; 501 } 502 if (isa->iobase == -1) { |
498 isa->iobase = isa_parallel_io[isa->index]; | 503 isa->iobase = isa_parallel_io[isa->index]; |
504 } |
|
499 index++; 500 501 base = isa->iobase; | 505 index++; 506 507 base = isa->iobase; |
502 isa_init_irq(dev, &s->irq, isa->isairq); | 508 isa_init_irq(isadev, &s->irq, isa->isairq); |
503 qemu_register_reset(parallel_reset, s); 504 505 if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) { 506 s->hw_driver = 1; 507 s->status = dummy; 508 } 509 | 509 qemu_register_reset(parallel_reset, s); 510 511 if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) { 512 s->hw_driver = 1; 513 s->status = dummy; 514 } 515 |
510 isa_register_portio_list(dev, base, | 516 isa_register_portio_list(isadev, base, |
511 (s->hw_driver 512 ? &isa_parallel_portio_hw_list[0] 513 : &isa_parallel_portio_sw_list[0]), 514 s, "parallel"); | 517 (s->hw_driver 518 ? &isa_parallel_portio_hw_list[0] 519 : &isa_parallel_portio_sw_list[0]), 520 s, "parallel"); |
515 return 0; | |
516} 517 518/* Memory mapped interface */ 519static uint32_t parallel_mm_readb (void *opaque, hwaddr addr) 520{ 521 ParallelState *s = opaque; 522 523 return parallel_ioport_read_sw(s, addr >> s->it_shift) & 0xFF; --- 70 unchanged lines hidden (view full) --- 594 DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7), 595 DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr), 596 DEFINE_PROP_END_OF_LIST(), 597}; 598 599static void parallel_isa_class_initfn(ObjectClass *klass, void *data) 600{ 601 DeviceClass *dc = DEVICE_CLASS(klass); | 521} 522 523/* Memory mapped interface */ 524static uint32_t parallel_mm_readb (void *opaque, hwaddr addr) 525{ 526 ParallelState *s = opaque; 527 528 return parallel_ioport_read_sw(s, addr >> s->it_shift) & 0xFF; --- 70 unchanged lines hidden (view full) --- 599 DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7), 600 DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr), 601 DEFINE_PROP_END_OF_LIST(), 602}; 603 604static void parallel_isa_class_initfn(ObjectClass *klass, void *data) 605{ 606 DeviceClass *dc = DEVICE_CLASS(klass); |
602 ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); 603 ic->init = parallel_isa_initfn; | 607 608 dc->realize = parallel_isa_realizefn; |
604 dc->props = parallel_isa_properties; 605} 606 607static const TypeInfo parallel_isa_info = { 608 .name = TYPE_ISA_PARALLEL, 609 .parent = TYPE_ISA_DEVICE, 610 .instance_size = sizeof(ISAParallelState), 611 .class_init = parallel_isa_class_initfn, 612}; 613 614static void parallel_register_types(void) 615{ 616 type_register_static(¶llel_isa_info); 617} 618 619type_init(parallel_register_types) | 609 dc->props = parallel_isa_properties; 610} 611 612static const TypeInfo parallel_isa_info = { 613 .name = TYPE_ISA_PARALLEL, 614 .parent = TYPE_ISA_DEVICE, 615 .instance_size = sizeof(ISAParallelState), 616 .class_init = parallel_isa_class_initfn, 617}; 618 619static void parallel_register_types(void) 620{ 621 type_register_static(¶llel_isa_info); 622} 623 624type_init(parallel_register_types) |