smc37c669-superio.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * SMC FDC37C669 Super I/O controller
  3. *
  4. * Copyright (c) 2018 Philippe Mathieu-Daudé
  5. *
  6. * This code is licensed under the GNU GPLv2 and 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 bool is_serial_enabled(ISASuperIODevice *sio, uint8_t index)
  15. {
  16. return index < 2;
  17. }
  18. static uint16_t get_serial_iobase(ISASuperIODevice *sio, uint8_t index)
  19. {
  20. return index ? 0x2f8 : 0x3f8;
  21. }
  22. static unsigned int get_serial_irq(ISASuperIODevice *sio, uint8_t index)
  23. {
  24. return index ? 3 : 4;
  25. }
  26. /* Parallel port */
  27. static bool is_parallel_enabled(ISASuperIODevice *sio, uint8_t index)
  28. {
  29. return index < 1;
  30. }
  31. static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index)
  32. {
  33. return 0x378;
  34. }
  35. static unsigned int get_parallel_irq(ISASuperIODevice *sio, uint8_t index)
  36. {
  37. return 7;
  38. }
  39. static unsigned int get_parallel_dma(ISASuperIODevice *sio, uint8_t index)
  40. {
  41. return 3;
  42. }
  43. /* Diskette controller (Software compatible with the Intel PC8477) */
  44. static bool is_fdc_enabled(ISASuperIODevice *sio, uint8_t index)
  45. {
  46. return index < 1;
  47. }
  48. static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index)
  49. {
  50. return 0x3f0;
  51. }
  52. static unsigned int get_fdc_irq(ISASuperIODevice *sio, uint8_t index)
  53. {
  54. return 6;
  55. }
  56. static unsigned int get_fdc_dma(ISASuperIODevice *sio, uint8_t index)
  57. {
  58. return 2;
  59. }
  60. static void smc37c669_class_init(ObjectClass *klass, void *data)
  61. {
  62. ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
  63. sc->parallel = (ISASuperIOFuncs){
  64. .count = 1,
  65. .is_enabled = is_parallel_enabled,
  66. .get_iobase = get_parallel_iobase,
  67. .get_irq = get_parallel_irq,
  68. .get_dma = get_parallel_dma,
  69. };
  70. sc->serial = (ISASuperIOFuncs){
  71. .count = 2,
  72. .is_enabled = is_serial_enabled,
  73. .get_iobase = get_serial_iobase,
  74. .get_irq = get_serial_irq,
  75. };
  76. sc->floppy = (ISASuperIOFuncs){
  77. .count = 1,
  78. .is_enabled = is_fdc_enabled,
  79. .get_iobase = get_fdc_iobase,
  80. .get_irq = get_fdc_irq,
  81. .get_dma = get_fdc_dma,
  82. };
  83. sc->ide.count = 0;
  84. }
  85. static const TypeInfo smc37c669_type_info = {
  86. .name = TYPE_SMC37C669_SUPERIO,
  87. .parent = TYPE_ISA_SUPERIO,
  88. .instance_size = sizeof(ISASuperIODevice),
  89. .class_size = sizeof(ISASuperIOClass),
  90. .class_init = smc37c669_class_init,
  91. };
  92. static void smc37c669_register_types(void)
  93. {
  94. type_register_static(&smc37c669_type_info);
  95. }
  96. type_init(smc37c669_register_types)