parallel-isa.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * QEMU Parallel PORT (ISA bus helpers)
  3. *
  4. * These functions reside in a separate file since they also might be
  5. * required for linking when compiling QEMU without CONFIG_PARALLEL.
  6. *
  7. * Copyright (c) 2003 Fabrice Bellard
  8. *
  9. * SPDX-License-Identifier: MIT
  10. */
  11. #include "qemu/osdep.h"
  12. #include "system/system.h"
  13. #include "hw/isa/isa.h"
  14. #include "hw/qdev-properties.h"
  15. #include "hw/char/parallel-isa.h"
  16. #include "hw/char/parallel.h"
  17. #include "qapi/error.h"
  18. static void parallel_init(ISABus *bus, int index, Chardev *chr)
  19. {
  20. DeviceState *dev;
  21. ISADevice *isadev;
  22. isadev = isa_new(TYPE_ISA_PARALLEL);
  23. dev = DEVICE(isadev);
  24. qdev_prop_set_uint32(dev, "index", index);
  25. qdev_prop_set_chr(dev, "chardev", chr);
  26. isa_realize_and_unref(isadev, bus, &error_fatal);
  27. }
  28. void parallel_hds_isa_init(ISABus *bus, int n)
  29. {
  30. int i;
  31. assert(n <= MAX_PARALLEL_PORTS);
  32. for (i = 0; i < n; i++) {
  33. if (parallel_hds[i]) {
  34. parallel_init(bus, i, parallel_hds[i]);
  35. }
  36. }
  37. }
  38. void isa_parallel_set_iobase(ISADevice *parallel, hwaddr iobase)
  39. {
  40. ISAParallelState *s = ISA_PARALLEL(parallel);
  41. parallel->ioport_id = iobase;
  42. s->iobase = iobase;
  43. portio_list_set_address(&s->portio_list, s->iobase);
  44. }
  45. void isa_parallel_set_enabled(ISADevice *parallel, bool enabled)
  46. {
  47. portio_list_set_enabled(&ISA_PARALLEL(parallel)->portio_list, enabled);
  48. }