2
0

ahci-sysbus.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * QEMU AHCI Emulation (MMIO-mapped devices)
  3. *
  4. * Copyright (c) 2010 qiaochong@loongson.cn
  5. * Copyright (c) 2010 Roland Elek <elek.roland@gmail.com>
  6. * Copyright (c) 2010 Sebastian Herbszt <herbszt@gmx.de>
  7. * Copyright (c) 2010 Alexander Graf <agraf@suse.de>
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. #include "qemu/osdep.h"
  24. #include "exec/address-spaces.h"
  25. #include "hw/qdev-properties.h"
  26. #include "migration/vmstate.h"
  27. #include "hw/ide/ahci-sysbus.h"
  28. #include "ahci-internal.h"
  29. static const VMStateDescription vmstate_sysbus_ahci = {
  30. .name = "sysbus-ahci",
  31. .fields = (const VMStateField[]) {
  32. VMSTATE_AHCI(ahci, SysbusAHCIState),
  33. VMSTATE_END_OF_LIST()
  34. },
  35. };
  36. static void sysbus_ahci_reset(DeviceState *dev)
  37. {
  38. SysbusAHCIState *s = SYSBUS_AHCI(dev);
  39. ahci_reset(&s->ahci);
  40. }
  41. static void sysbus_ahci_init(Object *obj)
  42. {
  43. SysbusAHCIState *s = SYSBUS_AHCI(obj);
  44. SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
  45. ahci_init(&s->ahci, DEVICE(obj));
  46. sysbus_init_mmio(sbd, &s->ahci.mem);
  47. sysbus_init_irq(sbd, &s->ahci.irq);
  48. }
  49. static void sysbus_ahci_realize(DeviceState *dev, Error **errp)
  50. {
  51. SysbusAHCIState *s = SYSBUS_AHCI(dev);
  52. ahci_realize(&s->ahci, dev, &address_space_memory);
  53. }
  54. static const Property sysbus_ahci_properties[] = {
  55. DEFINE_PROP_UINT32("num-ports", SysbusAHCIState, ahci.ports, 1),
  56. };
  57. static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
  58. {
  59. DeviceClass *dc = DEVICE_CLASS(klass);
  60. dc->realize = sysbus_ahci_realize;
  61. dc->vmsd = &vmstate_sysbus_ahci;
  62. device_class_set_props(dc, sysbus_ahci_properties);
  63. device_class_set_legacy_reset(dc, sysbus_ahci_reset);
  64. set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
  65. }
  66. static const TypeInfo sysbus_ahci_types[] = {
  67. {
  68. .name = TYPE_SYSBUS_AHCI,
  69. .parent = TYPE_SYS_BUS_DEVICE,
  70. .instance_size = sizeof(SysbusAHCIState),
  71. .instance_init = sysbus_ahci_init,
  72. .class_init = sysbus_ahci_class_init,
  73. },
  74. };
  75. DEFINE_TYPES(sysbus_ahci_types)