smc37c669-superio.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * SMC FDC37C669 Super I/O controller
  3. *
  4. * Copyright (c) 2018 Philippe Mathieu-Daudé
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  7. * See the COPYING file in the top-level directory.
  8. * SPDX-License-Identifier: GPL-2.0-or-later
  9. */
  10. #include "qemu/osdep.h"
  11. #include "hw/isa/superio.h"
  12. #include "qemu/module.h"
  13. /* UARTs (compatible with NS16450 or PC16550) */
  14. static uint16_t get_serial_iobase(ISASuperIODevice *sio, uint8_t index)
  15. {
  16. return index ? 0x2f8 : 0x3f8;
  17. }
  18. static unsigned int get_serial_irq(ISASuperIODevice *sio, uint8_t index)
  19. {
  20. return index ? 3 : 4;
  21. }
  22. /* Parallel port */
  23. static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index)
  24. {
  25. return 0x378;
  26. }
  27. static unsigned int get_parallel_irq(ISASuperIODevice *sio, uint8_t index)
  28. {
  29. return 7;
  30. }
  31. static unsigned int get_parallel_dma(ISASuperIODevice *sio, uint8_t index)
  32. {
  33. return 3;
  34. }
  35. /* Diskette controller (Software compatible with the Intel PC8477) */
  36. static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index)
  37. {
  38. return 0x3f0;
  39. }
  40. static unsigned int get_fdc_irq(ISASuperIODevice *sio, uint8_t index)
  41. {
  42. return 6;
  43. }
  44. static unsigned int get_fdc_dma(ISASuperIODevice *sio, uint8_t index)
  45. {
  46. return 2;
  47. }
  48. static void smc37c669_class_init(ObjectClass *klass, void *data)
  49. {
  50. ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
  51. sc->parallel = (ISASuperIOFuncs){
  52. .count = 1,
  53. .get_iobase = get_parallel_iobase,
  54. .get_irq = get_parallel_irq,
  55. .get_dma = get_parallel_dma,
  56. };
  57. sc->serial = (ISASuperIOFuncs){
  58. .count = 2,
  59. .get_iobase = get_serial_iobase,
  60. .get_irq = get_serial_irq,
  61. };
  62. sc->floppy = (ISASuperIOFuncs){
  63. .count = 1,
  64. .get_iobase = get_fdc_iobase,
  65. .get_irq = get_fdc_irq,
  66. .get_dma = get_fdc_dma,
  67. };
  68. sc->ide.count = 0;
  69. }
  70. static const TypeInfo smc37c669_type_info = {
  71. .name = TYPE_SMC37C669_SUPERIO,
  72. .parent = TYPE_ISA_SUPERIO,
  73. .class_size = sizeof(ISASuperIOClass),
  74. .class_init = smc37c669_class_init,
  75. };
  76. static void smc37c669_register_types(void)
  77. {
  78. type_register_static(&smc37c669_type_info);
  79. }
  80. type_init(smc37c669_register_types)