root / hw / piix4.c @ d8ed79ae
History | View | Annotate | Download (3.7 kB)
1 | 823e675a | Juan Quintela | /*
|
---|---|---|---|
2 | 823e675a | Juan Quintela | * QEMU PIIX4 PCI Bridge Emulation
|
3 | 823e675a | Juan Quintela | *
|
4 | 823e675a | Juan Quintela | * Copyright (c) 2006 Fabrice Bellard
|
5 | 823e675a | Juan Quintela | *
|
6 | 823e675a | Juan Quintela | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 823e675a | Juan Quintela | * of this software and associated documentation files (the "Software"), to deal
|
8 | 823e675a | Juan Quintela | * in the Software without restriction, including without limitation the rights
|
9 | 823e675a | Juan Quintela | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 823e675a | Juan Quintela | * copies of the Software, and to permit persons to whom the Software is
|
11 | 823e675a | Juan Quintela | * furnished to do so, subject to the following conditions:
|
12 | 823e675a | Juan Quintela | *
|
13 | 823e675a | Juan Quintela | * The above copyright notice and this permission notice shall be included in
|
14 | 823e675a | Juan Quintela | * all copies or substantial portions of the Software.
|
15 | 823e675a | Juan Quintela | *
|
16 | 823e675a | Juan Quintela | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 823e675a | Juan Quintela | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 823e675a | Juan Quintela | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 823e675a | Juan Quintela | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 823e675a | Juan Quintela | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 823e675a | Juan Quintela | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 823e675a | Juan Quintela | * THE SOFTWARE.
|
23 | 823e675a | Juan Quintela | */
|
24 | 823e675a | Juan Quintela | |
25 | 823e675a | Juan Quintela | #include "hw.h" |
26 | 823e675a | Juan Quintela | #include "pc.h" |
27 | 823e675a | Juan Quintela | #include "pci.h" |
28 | 823e675a | Juan Quintela | #include "isa.h" |
29 | 823e675a | Juan Quintela | #include "sysbus.h" |
30 | 823e675a | Juan Quintela | |
31 | 823e675a | Juan Quintela | PCIDevice *piix4_dev; |
32 | 823e675a | Juan Quintela | |
33 | 823e675a | Juan Quintela | static void piix4_reset(void *opaque) |
34 | 823e675a | Juan Quintela | { |
35 | 823e675a | Juan Quintela | PCIDevice *d = opaque; |
36 | 823e675a | Juan Quintela | uint8_t *pci_conf = d->config; |
37 | 823e675a | Juan Quintela | |
38 | 823e675a | Juan Quintela | pci_conf[0x04] = 0x07; // master, memory and I/O |
39 | 823e675a | Juan Quintela | pci_conf[0x05] = 0x00; |
40 | 823e675a | Juan Quintela | pci_conf[0x06] = 0x00; |
41 | 823e675a | Juan Quintela | pci_conf[0x07] = 0x02; // PCI_status_devsel_medium |
42 | 823e675a | Juan Quintela | pci_conf[0x4c] = 0x4d; |
43 | 823e675a | Juan Quintela | pci_conf[0x4e] = 0x03; |
44 | 823e675a | Juan Quintela | pci_conf[0x4f] = 0x00; |
45 | 823e675a | Juan Quintela | pci_conf[0x60] = 0x0a; // PCI A -> IRQ 10 |
46 | 823e675a | Juan Quintela | pci_conf[0x61] = 0x0a; // PCI B -> IRQ 10 |
47 | 823e675a | Juan Quintela | pci_conf[0x62] = 0x0b; // PCI C -> IRQ 11 |
48 | 823e675a | Juan Quintela | pci_conf[0x63] = 0x0b; // PCI D -> IRQ 11 |
49 | 823e675a | Juan Quintela | pci_conf[0x69] = 0x02; |
50 | 823e675a | Juan Quintela | pci_conf[0x70] = 0x80; |
51 | 823e675a | Juan Quintela | pci_conf[0x76] = 0x0c; |
52 | 823e675a | Juan Quintela | pci_conf[0x77] = 0x0c; |
53 | 823e675a | Juan Quintela | pci_conf[0x78] = 0x02; |
54 | 823e675a | Juan Quintela | pci_conf[0x79] = 0x00; |
55 | 823e675a | Juan Quintela | pci_conf[0x80] = 0x00; |
56 | 823e675a | Juan Quintela | pci_conf[0x82] = 0x00; |
57 | 823e675a | Juan Quintela | pci_conf[0xa0] = 0x08; |
58 | 823e675a | Juan Quintela | pci_conf[0xa2] = 0x00; |
59 | 823e675a | Juan Quintela | pci_conf[0xa3] = 0x00; |
60 | 823e675a | Juan Quintela | pci_conf[0xa4] = 0x00; |
61 | 823e675a | Juan Quintela | pci_conf[0xa5] = 0x00; |
62 | 823e675a | Juan Quintela | pci_conf[0xa6] = 0x00; |
63 | 823e675a | Juan Quintela | pci_conf[0xa7] = 0x00; |
64 | 823e675a | Juan Quintela | pci_conf[0xa8] = 0x0f; |
65 | 823e675a | Juan Quintela | pci_conf[0xaa] = 0x00; |
66 | 823e675a | Juan Quintela | pci_conf[0xab] = 0x00; |
67 | 823e675a | Juan Quintela | pci_conf[0xac] = 0x00; |
68 | 823e675a | Juan Quintela | pci_conf[0xae] = 0x00; |
69 | 823e675a | Juan Quintela | } |
70 | 823e675a | Juan Quintela | |
71 | 823e675a | Juan Quintela | static void piix_save(QEMUFile* f, void *opaque) |
72 | 823e675a | Juan Quintela | { |
73 | 823e675a | Juan Quintela | PCIDevice *d = opaque; |
74 | 823e675a | Juan Quintela | pci_device_save(d, f); |
75 | 823e675a | Juan Quintela | } |
76 | 823e675a | Juan Quintela | |
77 | 823e675a | Juan Quintela | static int piix_load(QEMUFile* f, void *opaque, int version_id) |
78 | 823e675a | Juan Quintela | { |
79 | 823e675a | Juan Quintela | PCIDevice *d = opaque; |
80 | 823e675a | Juan Quintela | if (version_id != 2) |
81 | 823e675a | Juan Quintela | return -EINVAL;
|
82 | 823e675a | Juan Quintela | return pci_device_load(d, f);
|
83 | 823e675a | Juan Quintela | } |
84 | 823e675a | Juan Quintela | |
85 | 823e675a | Juan Quintela | static int piix4_initfn(PCIDevice *d) |
86 | 823e675a | Juan Quintela | { |
87 | 823e675a | Juan Quintela | uint8_t *pci_conf; |
88 | 823e675a | Juan Quintela | |
89 | ae027ad3 | Stefan Weil | isa_bus_new(&d->qdev); |
90 | 823e675a | Juan Quintela | register_savevm("PIIX4", 0, 2, piix_save, piix_load, d); |
91 | 823e675a | Juan Quintela | |
92 | 823e675a | Juan Quintela | pci_conf = d->config; |
93 | 823e675a | Juan Quintela | pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); |
94 | 823e675a | Juan Quintela | pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_0); // 82371AB/EB/MB PIIX4 PCI-to-ISA bridge
|
95 | 823e675a | Juan Quintela | pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); |
96 | 823e675a | Juan Quintela | pci_conf[PCI_HEADER_TYPE] = |
97 | 823e675a | Juan Quintela | PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; // header_type = PCI_multifunction, generic
|
98 | 823e675a | Juan Quintela | |
99 | 823e675a | Juan Quintela | piix4_dev = d; |
100 | 823e675a | Juan Quintela | piix4_reset(d); |
101 | 823e675a | Juan Quintela | qemu_register_reset(piix4_reset, d); |
102 | 823e675a | Juan Quintela | return 0; |
103 | 823e675a | Juan Quintela | } |
104 | 823e675a | Juan Quintela | |
105 | 823e675a | Juan Quintela | int piix4_init(PCIBus *bus, int devfn) |
106 | 823e675a | Juan Quintela | { |
107 | 823e675a | Juan Quintela | PCIDevice *d; |
108 | 823e675a | Juan Quintela | |
109 | 823e675a | Juan Quintela | d = pci_create_simple(bus, devfn, "PIIX4");
|
110 | 823e675a | Juan Quintela | return d->devfn;
|
111 | 823e675a | Juan Quintela | } |
112 | 823e675a | Juan Quintela | |
113 | 823e675a | Juan Quintela | static PCIDeviceInfo piix4_info[] = {
|
114 | 823e675a | Juan Quintela | { |
115 | 823e675a | Juan Quintela | .qdev.name = "PIIX4",
|
116 | 823e675a | Juan Quintela | .qdev.desc = "ISA bridge",
|
117 | 823e675a | Juan Quintela | .qdev.size = sizeof(PCIDevice),
|
118 | 823e675a | Juan Quintela | .qdev.no_user = 1,
|
119 | 823e675a | Juan Quintela | .init = piix4_initfn, |
120 | 823e675a | Juan Quintela | },{ |
121 | 823e675a | Juan Quintela | /* end of list */
|
122 | 823e675a | Juan Quintela | } |
123 | 823e675a | Juan Quintela | }; |
124 | 823e675a | Juan Quintela | |
125 | 823e675a | Juan Quintela | static void piix4_register(void) |
126 | 823e675a | Juan Quintela | { |
127 | 823e675a | Juan Quintela | pci_qdev_register_many(piix4_info); |
128 | 823e675a | Juan Quintela | } |
129 | 823e675a | Juan Quintela | device_init(piix4_register); |