vga-isa.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * QEMU ISA VGA Emulator.
  3. *
  4. * see docs/specs/standard-vga.txt for virtual hardware specs.
  5. *
  6. * Copyright (c) 2003 Fabrice Bellard
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #include "hw.h"
  27. #include "ui/console.h"
  28. #include "pc.h"
  29. #include "vga_int.h"
  30. #include "ui/pixel_ops.h"
  31. #include "qemu/timer.h"
  32. #include "loader.h"
  33. typedef struct ISAVGAState {
  34. ISADevice dev;
  35. struct VGACommonState state;
  36. } ISAVGAState;
  37. static void vga_reset_isa(DeviceState *dev)
  38. {
  39. ISAVGAState *d = container_of(dev, ISAVGAState, dev.qdev);
  40. VGACommonState *s = &d->state;
  41. vga_common_reset(s);
  42. }
  43. static int vga_initfn(ISADevice *dev)
  44. {
  45. ISAVGAState *d = DO_UPCAST(ISAVGAState, dev, dev);
  46. VGACommonState *s = &d->state;
  47. MemoryRegion *vga_io_memory;
  48. const MemoryRegionPortio *vga_ports, *vbe_ports;
  49. vga_common_init(s);
  50. s->legacy_address_space = isa_address_space(dev);
  51. vga_io_memory = vga_init_io(s, &vga_ports, &vbe_ports);
  52. isa_register_portio_list(dev, 0x3b0, vga_ports, s, "vga");
  53. if (vbe_ports) {
  54. isa_register_portio_list(dev, 0x1ce, vbe_ports, s, "vbe");
  55. }
  56. memory_region_add_subregion_overlap(isa_address_space(dev),
  57. isa_mem_base + 0x000a0000,
  58. vga_io_memory, 1);
  59. memory_region_set_coalescing(vga_io_memory);
  60. s->ds = graphic_console_init(s->update, s->invalidate,
  61. s->screen_dump, s->text_update, s);
  62. vga_init_vbe(s, isa_address_space(dev));
  63. /* ROM BIOS */
  64. rom_add_vga(VGABIOS_FILENAME);
  65. return 0;
  66. }
  67. static Property vga_isa_properties[] = {
  68. DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8),
  69. DEFINE_PROP_END_OF_LIST(),
  70. };
  71. static void vga_class_initfn(ObjectClass *klass, void *data)
  72. {
  73. DeviceClass *dc = DEVICE_CLASS(klass);
  74. ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
  75. ic->init = vga_initfn;
  76. dc->reset = vga_reset_isa;
  77. dc->vmsd = &vmstate_vga_common;
  78. dc->props = vga_isa_properties;
  79. }
  80. static const TypeInfo vga_info = {
  81. .name = "isa-vga",
  82. .parent = TYPE_ISA_DEVICE,
  83. .instance_size = sizeof(ISAVGAState),
  84. .class_init = vga_class_initfn,
  85. };
  86. static void vga_register_types(void)
  87. {
  88. type_register_static(&vga_info);
  89. }
  90. type_init(vga_register_types)