piix_pci.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * QEMU i440FX/PIIX3 PCI Bridge Emulation
  3. *
  4. * Copyright (c) 2006 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 "pc.h"
  26. #include "pci/pci.h"
  27. #include "pci/pci_host.h"
  28. #include "isa.h"
  29. #include "sysbus.h"
  30. #include "qemu/range.h"
  31. #include "xen.h"
  32. #include "pam.h"
  33. #include "sysemu/sysemu.h"
  34. /*
  35. * I440FX chipset data sheet.
  36. * http://download.intel.com/design/chipsets/datashts/29054901.pdf
  37. */
  38. typedef struct I440FXState {
  39. PCIHostState parent_obj;
  40. } I440FXState;
  41. #define PIIX_NUM_PIC_IRQS 16 /* i8259 * 2 */
  42. #define PIIX_NUM_PIRQS 4ULL /* PIRQ[A-D] */
  43. #define XEN_PIIX_NUM_PIRQS 128ULL
  44. #define PIIX_PIRQC 0x60
  45. /*
  46. * Reset Control Register: PCI-accessible ISA-Compatible Register at address
  47. * 0xcf9, provided by the PCI/ISA bridge (PIIX3 PCI function 0, 8086:7000).
  48. */
  49. #define RCR_IOPORT 0xcf9
  50. typedef struct PIIX3State {
  51. PCIDevice dev;
  52. /*
  53. * bitmap to track pic levels.
  54. * The pic level is the logical OR of all the PCI irqs mapped to it
  55. * So one PIC level is tracked by PIIX_NUM_PIRQS bits.
  56. *
  57. * PIRQ is mapped to PIC pins, we track it by
  58. * PIIX_NUM_PIRQS * PIIX_NUM_PIC_IRQS = 64 bits with
  59. * pic_irq * PIIX_NUM_PIRQS + pirq
  60. */
  61. #if PIIX_NUM_PIC_IRQS * PIIX_NUM_PIRQS > 64
  62. #error "unable to encode pic state in 64bit in pic_levels."
  63. #endif
  64. uint64_t pic_levels;
  65. qemu_irq *pic;
  66. /* This member isn't used. Just for save/load compatibility */
  67. int32_t pci_irq_levels_vmstate[PIIX_NUM_PIRQS];
  68. /* Reset Control Register contents */
  69. uint8_t rcr;
  70. /* IO memory region for Reset Control Register (RCR_IOPORT) */
  71. MemoryRegion rcr_mem;
  72. } PIIX3State;
  73. struct PCII440FXState {
  74. PCIDevice dev;
  75. MemoryRegion *system_memory;
  76. MemoryRegion *pci_address_space;
  77. MemoryRegion *ram_memory;
  78. MemoryRegion pci_hole;
  79. MemoryRegion pci_hole_64bit;
  80. PAMMemoryRegion pam_regions[13];
  81. MemoryRegion smram_region;
  82. uint8_t smm_enabled;
  83. };
  84. #define I440FX_PAM 0x59
  85. #define I440FX_PAM_SIZE 7
  86. #define I440FX_SMRAM 0x72
  87. static void piix3_set_irq(void *opaque, int pirq, int level);
  88. static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int pci_intx);
  89. static void piix3_write_config_xen(PCIDevice *dev,
  90. uint32_t address, uint32_t val, int len);
  91. /* return the global irq number corresponding to a given device irq
  92. pin. We could also use the bus number to have a more precise
  93. mapping. */
  94. static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
  95. {
  96. int slot_addend;
  97. slot_addend = (pci_dev->devfn >> 3) - 1;
  98. return (pci_intx + slot_addend) & 3;
  99. }
  100. static void i440fx_update_memory_mappings(PCII440FXState *d)
  101. {
  102. int i;
  103. memory_region_transaction_begin();
  104. for (i = 0; i < 13; i++) {
  105. pam_update(&d->pam_regions[i], i,
  106. d->dev.config[I440FX_PAM + ((i + 1) / 2)]);
  107. }
  108. smram_update(&d->smram_region, d->dev.config[I440FX_SMRAM], d->smm_enabled);
  109. memory_region_transaction_commit();
  110. }
  111. static void i440fx_set_smm(int val, void *arg)
  112. {
  113. PCII440FXState *d = arg;
  114. memory_region_transaction_begin();
  115. smram_set_smm(&d->smm_enabled, val, d->dev.config[I440FX_SMRAM],
  116. &d->smram_region);
  117. memory_region_transaction_commit();
  118. }
  119. static void i440fx_write_config(PCIDevice *dev,
  120. uint32_t address, uint32_t val, int len)
  121. {
  122. PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev);
  123. /* XXX: implement SMRAM.D_LOCK */
  124. pci_default_write_config(dev, address, val, len);
  125. if (ranges_overlap(address, len, I440FX_PAM, I440FX_PAM_SIZE) ||
  126. range_covers_byte(address, len, I440FX_SMRAM)) {
  127. i440fx_update_memory_mappings(d);
  128. }
  129. }
  130. static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id)
  131. {
  132. PCII440FXState *d = opaque;
  133. int ret, i;
  134. ret = pci_device_load(&d->dev, f);
  135. if (ret < 0)
  136. return ret;
  137. i440fx_update_memory_mappings(d);
  138. qemu_get_8s(f, &d->smm_enabled);
  139. if (version_id == 2) {
  140. for (i = 0; i < PIIX_NUM_PIRQS; i++) {
  141. qemu_get_be32(f); /* dummy load for compatibility */
  142. }
  143. }
  144. return 0;
  145. }
  146. static int i440fx_post_load(void *opaque, int version_id)
  147. {
  148. PCII440FXState *d = opaque;
  149. i440fx_update_memory_mappings(d);
  150. return 0;
  151. }
  152. static const VMStateDescription vmstate_i440fx = {
  153. .name = "I440FX",
  154. .version_id = 3,
  155. .minimum_version_id = 3,
  156. .minimum_version_id_old = 1,
  157. .load_state_old = i440fx_load_old,
  158. .post_load = i440fx_post_load,
  159. .fields = (VMStateField []) {
  160. VMSTATE_PCI_DEVICE(dev, PCII440FXState),
  161. VMSTATE_UINT8(smm_enabled, PCII440FXState),
  162. VMSTATE_END_OF_LIST()
  163. }
  164. };
  165. static int i440fx_pcihost_initfn(SysBusDevice *dev)
  166. {
  167. PCIHostState *s = PCI_HOST_BRIDGE(dev);
  168. memory_region_init_io(&s->conf_mem, &pci_host_conf_le_ops, s,
  169. "pci-conf-idx", 4);
  170. sysbus_add_io(dev, 0xcf8, &s->conf_mem);
  171. sysbus_init_ioports(&s->busdev, 0xcf8, 4);
  172. memory_region_init_io(&s->data_mem, &pci_host_data_le_ops, s,
  173. "pci-conf-data", 4);
  174. sysbus_add_io(dev, 0xcfc, &s->data_mem);
  175. sysbus_init_ioports(&s->busdev, 0xcfc, 4);
  176. return 0;
  177. }
  178. static int i440fx_initfn(PCIDevice *dev)
  179. {
  180. PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev);
  181. d->dev.config[I440FX_SMRAM] = 0x02;
  182. cpu_smm_register(&i440fx_set_smm, d);
  183. return 0;
  184. }
  185. static PCIBus *i440fx_common_init(const char *device_name,
  186. PCII440FXState **pi440fx_state,
  187. int *piix3_devfn,
  188. ISABus **isa_bus, qemu_irq *pic,
  189. MemoryRegion *address_space_mem,
  190. MemoryRegion *address_space_io,
  191. ram_addr_t ram_size,
  192. hwaddr pci_hole_start,
  193. hwaddr pci_hole_size,
  194. hwaddr pci_hole64_start,
  195. hwaddr pci_hole64_size,
  196. MemoryRegion *pci_address_space,
  197. MemoryRegion *ram_memory)
  198. {
  199. DeviceState *dev;
  200. PCIBus *b;
  201. PCIDevice *d;
  202. PCIHostState *s;
  203. PIIX3State *piix3;
  204. PCII440FXState *f;
  205. unsigned i;
  206. dev = qdev_create(NULL, "i440FX-pcihost");
  207. s = PCI_HOST_BRIDGE(dev);
  208. s->address_space = address_space_mem;
  209. b = pci_bus_new(dev, NULL, pci_address_space,
  210. address_space_io, 0);
  211. s->bus = b;
  212. object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL);
  213. qdev_init_nofail(dev);
  214. d = pci_create_simple(b, 0, device_name);
  215. *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d);
  216. f = *pi440fx_state;
  217. f->system_memory = address_space_mem;
  218. f->pci_address_space = pci_address_space;
  219. f->ram_memory = ram_memory;
  220. memory_region_init_alias(&f->pci_hole, "pci-hole", f->pci_address_space,
  221. pci_hole_start, pci_hole_size);
  222. memory_region_add_subregion(f->system_memory, pci_hole_start, &f->pci_hole);
  223. memory_region_init_alias(&f->pci_hole_64bit, "pci-hole64",
  224. f->pci_address_space,
  225. pci_hole64_start, pci_hole64_size);
  226. if (pci_hole64_size) {
  227. memory_region_add_subregion(f->system_memory, pci_hole64_start,
  228. &f->pci_hole_64bit);
  229. }
  230. memory_region_init_alias(&f->smram_region, "smram-region",
  231. f->pci_address_space, 0xa0000, 0x20000);
  232. memory_region_add_subregion_overlap(f->system_memory, 0xa0000,
  233. &f->smram_region, 1);
  234. memory_region_set_enabled(&f->smram_region, false);
  235. init_pam(f->ram_memory, f->system_memory, f->pci_address_space,
  236. &f->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE);
  237. for (i = 0; i < 12; ++i) {
  238. init_pam(f->ram_memory, f->system_memory, f->pci_address_space,
  239. &f->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE,
  240. PAM_EXPAN_SIZE);
  241. }
  242. /* Xen supports additional interrupt routes from the PCI devices to
  243. * the IOAPIC: the four pins of each PCI device on the bus are also
  244. * connected to the IOAPIC directly.
  245. * These additional routes can be discovered through ACPI. */
  246. if (xen_enabled()) {
  247. piix3 = DO_UPCAST(PIIX3State, dev,
  248. pci_create_simple_multifunction(b, -1, true, "PIIX3-xen"));
  249. pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq,
  250. piix3, XEN_PIIX_NUM_PIRQS);
  251. } else {
  252. piix3 = DO_UPCAST(PIIX3State, dev,
  253. pci_create_simple_multifunction(b, -1, true, "PIIX3"));
  254. pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3,
  255. PIIX_NUM_PIRQS);
  256. pci_bus_set_route_irq_fn(b, piix3_route_intx_pin_to_irq);
  257. }
  258. piix3->pic = pic;
  259. *isa_bus = DO_UPCAST(ISABus, qbus,
  260. qdev_get_child_bus(&piix3->dev.qdev, "isa.0"));
  261. *piix3_devfn = piix3->dev.devfn;
  262. ram_size = ram_size / 8 / 1024 / 1024;
  263. if (ram_size > 255)
  264. ram_size = 255;
  265. (*pi440fx_state)->dev.config[0x57]=ram_size;
  266. i440fx_update_memory_mappings(f);
  267. return b;
  268. }
  269. PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
  270. ISABus **isa_bus, qemu_irq *pic,
  271. MemoryRegion *address_space_mem,
  272. MemoryRegion *address_space_io,
  273. ram_addr_t ram_size,
  274. hwaddr pci_hole_start,
  275. hwaddr pci_hole_size,
  276. hwaddr pci_hole64_start,
  277. hwaddr pci_hole64_size,
  278. MemoryRegion *pci_memory, MemoryRegion *ram_memory)
  279. {
  280. PCIBus *b;
  281. b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
  282. address_space_mem, address_space_io, ram_size,
  283. pci_hole_start, pci_hole_size,
  284. pci_hole64_start, pci_hole64_size,
  285. pci_memory, ram_memory);
  286. return b;
  287. }
  288. /* PIIX3 PCI to ISA bridge */
  289. static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
  290. {
  291. qemu_set_irq(piix3->pic[pic_irq],
  292. !!(piix3->pic_levels &
  293. (((1ULL << PIIX_NUM_PIRQS) - 1) <<
  294. (pic_irq * PIIX_NUM_PIRQS))));
  295. }
  296. static void piix3_set_irq_level(PIIX3State *piix3, int pirq, int level)
  297. {
  298. int pic_irq;
  299. uint64_t mask;
  300. pic_irq = piix3->dev.config[PIIX_PIRQC + pirq];
  301. if (pic_irq >= PIIX_NUM_PIC_IRQS) {
  302. return;
  303. }
  304. mask = 1ULL << ((pic_irq * PIIX_NUM_PIRQS) + pirq);
  305. piix3->pic_levels &= ~mask;
  306. piix3->pic_levels |= mask * !!level;
  307. piix3_set_irq_pic(piix3, pic_irq);
  308. }
  309. static void piix3_set_irq(void *opaque, int pirq, int level)
  310. {
  311. PIIX3State *piix3 = opaque;
  312. piix3_set_irq_level(piix3, pirq, level);
  313. }
  314. static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int pin)
  315. {
  316. PIIX3State *piix3 = opaque;
  317. int irq = piix3->dev.config[PIIX_PIRQC + pin];
  318. PCIINTxRoute route;
  319. if (irq < PIIX_NUM_PIC_IRQS) {
  320. route.mode = PCI_INTX_ENABLED;
  321. route.irq = irq;
  322. } else {
  323. route.mode = PCI_INTX_DISABLED;
  324. route.irq = -1;
  325. }
  326. return route;
  327. }
  328. /* irq routing is changed. so rebuild bitmap */
  329. static void piix3_update_irq_levels(PIIX3State *piix3)
  330. {
  331. int pirq;
  332. piix3->pic_levels = 0;
  333. for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) {
  334. piix3_set_irq_level(piix3, pirq,
  335. pci_bus_get_irq_level(piix3->dev.bus, pirq));
  336. }
  337. }
  338. static void piix3_write_config(PCIDevice *dev,
  339. uint32_t address, uint32_t val, int len)
  340. {
  341. pci_default_write_config(dev, address, val, len);
  342. if (ranges_overlap(address, len, PIIX_PIRQC, 4)) {
  343. PIIX3State *piix3 = DO_UPCAST(PIIX3State, dev, dev);
  344. int pic_irq;
  345. pci_bus_fire_intx_routing_notifier(piix3->dev.bus);
  346. piix3_update_irq_levels(piix3);
  347. for (pic_irq = 0; pic_irq < PIIX_NUM_PIC_IRQS; pic_irq++) {
  348. piix3_set_irq_pic(piix3, pic_irq);
  349. }
  350. }
  351. }
  352. static void piix3_write_config_xen(PCIDevice *dev,
  353. uint32_t address, uint32_t val, int len)
  354. {
  355. xen_piix_pci_write_config_client(address, val, len);
  356. piix3_write_config(dev, address, val, len);
  357. }
  358. static void piix3_reset(void *opaque)
  359. {
  360. PIIX3State *d = opaque;
  361. uint8_t *pci_conf = d->dev.config;
  362. pci_conf[0x04] = 0x07; // master, memory and I/O
  363. pci_conf[0x05] = 0x00;
  364. pci_conf[0x06] = 0x00;
  365. pci_conf[0x07] = 0x02; // PCI_status_devsel_medium
  366. pci_conf[0x4c] = 0x4d;
  367. pci_conf[0x4e] = 0x03;
  368. pci_conf[0x4f] = 0x00;
  369. pci_conf[0x60] = 0x80;
  370. pci_conf[0x61] = 0x80;
  371. pci_conf[0x62] = 0x80;
  372. pci_conf[0x63] = 0x80;
  373. pci_conf[0x69] = 0x02;
  374. pci_conf[0x70] = 0x80;
  375. pci_conf[0x76] = 0x0c;
  376. pci_conf[0x77] = 0x0c;
  377. pci_conf[0x78] = 0x02;
  378. pci_conf[0x79] = 0x00;
  379. pci_conf[0x80] = 0x00;
  380. pci_conf[0x82] = 0x00;
  381. pci_conf[0xa0] = 0x08;
  382. pci_conf[0xa2] = 0x00;
  383. pci_conf[0xa3] = 0x00;
  384. pci_conf[0xa4] = 0x00;
  385. pci_conf[0xa5] = 0x00;
  386. pci_conf[0xa6] = 0x00;
  387. pci_conf[0xa7] = 0x00;
  388. pci_conf[0xa8] = 0x0f;
  389. pci_conf[0xaa] = 0x00;
  390. pci_conf[0xab] = 0x00;
  391. pci_conf[0xac] = 0x00;
  392. pci_conf[0xae] = 0x00;
  393. d->pic_levels = 0;
  394. d->rcr = 0;
  395. }
  396. static int piix3_post_load(void *opaque, int version_id)
  397. {
  398. PIIX3State *piix3 = opaque;
  399. piix3_update_irq_levels(piix3);
  400. return 0;
  401. }
  402. static void piix3_pre_save(void *opaque)
  403. {
  404. int i;
  405. PIIX3State *piix3 = opaque;
  406. for (i = 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) {
  407. piix3->pci_irq_levels_vmstate[i] =
  408. pci_bus_get_irq_level(piix3->dev.bus, i);
  409. }
  410. }
  411. static bool piix3_rcr_needed(void *opaque)
  412. {
  413. PIIX3State *piix3 = opaque;
  414. return (piix3->rcr != 0);
  415. }
  416. static const VMStateDescription vmstate_piix3_rcr = {
  417. .name = "PIIX3/rcr",
  418. .version_id = 1,
  419. .minimum_version_id = 1,
  420. .fields = (VMStateField []) {
  421. VMSTATE_UINT8(rcr, PIIX3State),
  422. VMSTATE_END_OF_LIST()
  423. }
  424. };
  425. static const VMStateDescription vmstate_piix3 = {
  426. .name = "PIIX3",
  427. .version_id = 3,
  428. .minimum_version_id = 2,
  429. .minimum_version_id_old = 2,
  430. .post_load = piix3_post_load,
  431. .pre_save = piix3_pre_save,
  432. .fields = (VMStateField[]) {
  433. VMSTATE_PCI_DEVICE(dev, PIIX3State),
  434. VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIX3State,
  435. PIIX_NUM_PIRQS, 3),
  436. VMSTATE_END_OF_LIST()
  437. },
  438. .subsections = (VMStateSubsection[]) {
  439. {
  440. .vmsd = &vmstate_piix3_rcr,
  441. .needed = piix3_rcr_needed,
  442. },
  443. { 0 }
  444. }
  445. };
  446. static void rcr_write(void *opaque, hwaddr addr, uint64_t val, unsigned len)
  447. {
  448. PIIX3State *d = opaque;
  449. if (val & 4) {
  450. qemu_system_reset_request();
  451. return;
  452. }
  453. d->rcr = val & 2; /* keep System Reset type only */
  454. }
  455. static uint64_t rcr_read(void *opaque, hwaddr addr, unsigned len)
  456. {
  457. PIIX3State *d = opaque;
  458. return d->rcr;
  459. }
  460. static const MemoryRegionOps rcr_ops = {
  461. .read = rcr_read,
  462. .write = rcr_write,
  463. .endianness = DEVICE_LITTLE_ENDIAN
  464. };
  465. static int piix3_initfn(PCIDevice *dev)
  466. {
  467. PIIX3State *d = DO_UPCAST(PIIX3State, dev, dev);
  468. isa_bus_new(&d->dev.qdev, pci_address_space_io(dev));
  469. memory_region_init_io(&d->rcr_mem, &rcr_ops, d, "piix3-reset-control", 1);
  470. memory_region_add_subregion_overlap(pci_address_space_io(dev), RCR_IOPORT,
  471. &d->rcr_mem, 1);
  472. qemu_register_reset(piix3_reset, d);
  473. return 0;
  474. }
  475. static void piix3_class_init(ObjectClass *klass, void *data)
  476. {
  477. DeviceClass *dc = DEVICE_CLASS(klass);
  478. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  479. dc->desc = "ISA bridge";
  480. dc->vmsd = &vmstate_piix3;
  481. dc->no_user = 1,
  482. k->no_hotplug = 1;
  483. k->init = piix3_initfn;
  484. k->config_write = piix3_write_config;
  485. k->vendor_id = PCI_VENDOR_ID_INTEL;
  486. k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0; // 82371SB PIIX3 PCI-to-ISA bridge (Step A1)
  487. k->class_id = PCI_CLASS_BRIDGE_ISA;
  488. }
  489. static const TypeInfo piix3_info = {
  490. .name = "PIIX3",
  491. .parent = TYPE_PCI_DEVICE,
  492. .instance_size = sizeof(PIIX3State),
  493. .class_init = piix3_class_init,
  494. };
  495. static void piix3_xen_class_init(ObjectClass *klass, void *data)
  496. {
  497. DeviceClass *dc = DEVICE_CLASS(klass);
  498. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  499. dc->desc = "ISA bridge";
  500. dc->vmsd = &vmstate_piix3;
  501. dc->no_user = 1;
  502. k->no_hotplug = 1;
  503. k->init = piix3_initfn;
  504. k->config_write = piix3_write_config_xen;
  505. k->vendor_id = PCI_VENDOR_ID_INTEL;
  506. k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0; // 82371SB PIIX3 PCI-to-ISA bridge (Step A1)
  507. k->class_id = PCI_CLASS_BRIDGE_ISA;
  508. };
  509. static const TypeInfo piix3_xen_info = {
  510. .name = "PIIX3-xen",
  511. .parent = TYPE_PCI_DEVICE,
  512. .instance_size = sizeof(PIIX3State),
  513. .class_init = piix3_xen_class_init,
  514. };
  515. static void i440fx_class_init(ObjectClass *klass, void *data)
  516. {
  517. DeviceClass *dc = DEVICE_CLASS(klass);
  518. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  519. k->no_hotplug = 1;
  520. k->init = i440fx_initfn;
  521. k->config_write = i440fx_write_config;
  522. k->vendor_id = PCI_VENDOR_ID_INTEL;
  523. k->device_id = PCI_DEVICE_ID_INTEL_82441;
  524. k->revision = 0x02;
  525. k->class_id = PCI_CLASS_BRIDGE_HOST;
  526. dc->desc = "Host bridge";
  527. dc->no_user = 1;
  528. dc->vmsd = &vmstate_i440fx;
  529. }
  530. static const TypeInfo i440fx_info = {
  531. .name = "i440FX",
  532. .parent = TYPE_PCI_DEVICE,
  533. .instance_size = sizeof(PCII440FXState),
  534. .class_init = i440fx_class_init,
  535. };
  536. static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
  537. {
  538. DeviceClass *dc = DEVICE_CLASS(klass);
  539. SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
  540. k->init = i440fx_pcihost_initfn;
  541. dc->fw_name = "pci";
  542. dc->no_user = 1;
  543. }
  544. static const TypeInfo i440fx_pcihost_info = {
  545. .name = "i440FX-pcihost",
  546. .parent = TYPE_PCI_HOST_BRIDGE,
  547. .instance_size = sizeof(I440FXState),
  548. .class_init = i440fx_pcihost_class_init,
  549. };
  550. static void i440fx_register_types(void)
  551. {
  552. type_register_static(&i440fx_info);
  553. type_register_static(&piix3_info);
  554. type_register_static(&piix3_xen_info);
  555. type_register_static(&i440fx_pcihost_info);
  556. }
  557. type_init(i440fx_register_types)