piix_pci.c 19 KB

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