vga-isa.c 3.2 KB

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