cirrus_vga_isa.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * QEMU Cirrus CLGD 54xx VGA Emulator, ISA bus support
  3. *
  4. * Copyright (c) 2004 Fabrice Bellard
  5. * Copyright (c) 2004 Makoto Suzuki (suzu)
  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
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. * THE SOFTWARE.
  24. */
  25. #include "qemu/osdep.h"
  26. #include "qapi/error.h"
  27. #include "qemu/module.h"
  28. #include "hw/loader.h"
  29. #include "hw/qdev-properties.h"
  30. #include "hw/isa/isa.h"
  31. #include "cirrus_vga_internal.h"
  32. #define TYPE_ISA_CIRRUS_VGA "isa-cirrus-vga"
  33. #define ISA_CIRRUS_VGA(obj) \
  34. OBJECT_CHECK(ISACirrusVGAState, (obj), TYPE_ISA_CIRRUS_VGA)
  35. typedef struct ISACirrusVGAState {
  36. ISADevice parent_obj;
  37. CirrusVGAState cirrus_vga;
  38. } ISACirrusVGAState;
  39. static void isa_cirrus_vga_realizefn(DeviceState *dev, Error **errp)
  40. {
  41. ISADevice *isadev = ISA_DEVICE(dev);
  42. ISACirrusVGAState *d = ISA_CIRRUS_VGA(dev);
  43. VGACommonState *s = &d->cirrus_vga.vga;
  44. /* follow real hardware, cirrus card emulated has 4 MB video memory.
  45. Also accept 8 MB/16 MB for backward compatibility. */
  46. if (s->vram_size_mb != 4 && s->vram_size_mb != 8 &&
  47. s->vram_size_mb != 16) {
  48. error_setg(errp, "Invalid cirrus_vga ram size '%u'",
  49. s->vram_size_mb);
  50. return;
  51. }
  52. s->global_vmstate = true;
  53. vga_common_init(s, OBJECT(dev));
  54. cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0,
  55. isa_address_space(isadev),
  56. isa_address_space_io(isadev));
  57. s->con = graphic_console_init(dev, 0, s->hw_ops, s);
  58. rom_add_vga(VGABIOS_CIRRUS_FILENAME);
  59. /* XXX ISA-LFB support */
  60. /* FIXME not qdev yet */
  61. }
  62. static Property isa_cirrus_vga_properties[] = {
  63. DEFINE_PROP_UINT32("vgamem_mb", struct ISACirrusVGAState,
  64. cirrus_vga.vga.vram_size_mb, 4),
  65. DEFINE_PROP_BOOL("blitter", struct ISACirrusVGAState,
  66. cirrus_vga.enable_blitter, true),
  67. DEFINE_PROP_END_OF_LIST(),
  68. };
  69. static void isa_cirrus_vga_class_init(ObjectClass *klass, void *data)
  70. {
  71. DeviceClass *dc = DEVICE_CLASS(klass);
  72. dc->vmsd = &vmstate_cirrus_vga;
  73. dc->realize = isa_cirrus_vga_realizefn;
  74. dc->props = isa_cirrus_vga_properties;
  75. set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
  76. }
  77. static const TypeInfo isa_cirrus_vga_info = {
  78. .name = TYPE_ISA_CIRRUS_VGA,
  79. .parent = TYPE_ISA_DEVICE,
  80. .instance_size = sizeof(ISACirrusVGAState),
  81. .class_init = isa_cirrus_vga_class_init,
  82. };
  83. static void cirrus_vga_isa_register_types(void)
  84. {
  85. type_register_static(&isa_cirrus_vga_info);
  86. }
  87. type_init(cirrus_vga_isa_register_types)