i82801b11.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2006 Fabrice Bellard
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. /*
  23. * QEMU i82801b11 dmi-to-pci Bridge Emulation
  24. *
  25. * Copyright (c) 2009, 2010, 2011
  26. * Isaku Yamahata <yamahata at valinux co jp>
  27. * VA Linux Systems Japan K.K.
  28. * Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
  29. *
  30. * This library is free software; you can redistribute it and/or
  31. * modify it under the terms of the GNU Lesser General Public
  32. * License as published by the Free Software Foundation; either
  33. * version 2 of the License, or (at your option) any later version.
  34. *
  35. * This library is distributed in the hope that it will be useful,
  36. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  38. * Lesser General Public License for more details.
  39. *
  40. * You should have received a copy of the GNU Lesser General Public
  41. * License along with this library; if not, see <http://www.gnu.org/licenses/>
  42. */
  43. #include "qemu/osdep.h"
  44. #include "hw/pci/pci.h"
  45. #include "migration/vmstate.h"
  46. #include "qemu/module.h"
  47. #include "hw/i386/ich9.h"
  48. /*****************************************************************************/
  49. /* ICH9 DMI-to-PCI bridge */
  50. #define I82801ba_SSVID_OFFSET 0x50
  51. #define I82801ba_SSVID_SVID 0
  52. #define I82801ba_SSVID_SSID 0
  53. typedef struct I82801b11Bridge {
  54. /*< private >*/
  55. PCIBridge parent_obj;
  56. /*< public >*/
  57. } I82801b11Bridge;
  58. static void i82801b11_bridge_realize(PCIDevice *d, Error **errp)
  59. {
  60. int rc;
  61. pci_bridge_initfn(d, TYPE_PCI_BUS);
  62. rc = pci_bridge_ssvid_init(d, I82801ba_SSVID_OFFSET,
  63. I82801ba_SSVID_SVID, I82801ba_SSVID_SSID,
  64. errp);
  65. if (rc < 0) {
  66. goto err_bridge;
  67. }
  68. pci_config_set_prog_interface(d->config, PCI_CLASS_BRIDGE_PCI_INF_SUB);
  69. return;
  70. err_bridge:
  71. pci_bridge_exitfn(d);
  72. }
  73. static const VMStateDescription i82801b11_bridge_dev_vmstate = {
  74. .name = "i82801b11_bridge",
  75. .priority = MIG_PRI_PCI_BUS,
  76. .fields = (VMStateField[]) {
  77. VMSTATE_PCI_DEVICE(parent_obj, PCIBridge),
  78. VMSTATE_END_OF_LIST()
  79. }
  80. };
  81. static void i82801b11_bridge_class_init(ObjectClass *klass, void *data)
  82. {
  83. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  84. DeviceClass *dc = DEVICE_CLASS(klass);
  85. k->is_bridge = true;
  86. k->vendor_id = PCI_VENDOR_ID_INTEL;
  87. k->device_id = PCI_DEVICE_ID_INTEL_82801BA_11;
  88. k->revision = ICH9_D2P_A2_REVISION;
  89. k->realize = i82801b11_bridge_realize;
  90. k->config_write = pci_bridge_write_config;
  91. dc->vmsd = &i82801b11_bridge_dev_vmstate;
  92. dc->reset = pci_bridge_reset;
  93. set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  94. }
  95. static const TypeInfo i82801b11_bridge_info = {
  96. .name = "i82801b11-bridge",
  97. .parent = TYPE_PCI_BRIDGE,
  98. .instance_size = sizeof(I82801b11Bridge),
  99. .class_init = i82801b11_bridge_class_init,
  100. .interfaces = (InterfaceInfo[]) {
  101. { INTERFACE_CONVENTIONAL_PCI_DEVICE },
  102. { },
  103. },
  104. };
  105. static void d2pbr_register(void)
  106. {
  107. type_register_static(&i82801b11_bridge_info);
  108. }
  109. type_init(d2pbr_register);