Revision 952760bb hw/pci_host.c
b/hw/pci_host.c | ||
---|---|---|
78 | 78 |
return val; |
79 | 79 |
} |
80 | 80 |
|
81 |
static void pci_host_config_write(ReadWriteHandler *handler, |
|
82 |
pcibus_t addr, uint32_t val, int len) |
|
81 |
static void pci_host_config_write_swap(ReadWriteHandler *handler,
|
|
82 |
pcibus_t addr, uint32_t val, int len)
|
|
83 | 83 |
{ |
84 | 84 |
PCIHostState *s = container_of(handler, PCIHostState, conf_handler); |
85 | 85 |
|
86 | 86 |
PCI_DPRINTF("%s addr %" FMT_PCIBUS " %d val %"PRIx32"\n", |
87 | 87 |
__func__, addr, len, val); |
88 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
89 | 88 |
val = qemu_bswap_len(val, len); |
90 |
#endif |
|
91 | 89 |
s->config_reg = val; |
92 | 90 |
} |
93 | 91 |
|
94 |
static uint32_t pci_host_config_read(ReadWriteHandler *handler, |
|
95 |
pcibus_t addr, int len)
|
|
92 |
static uint32_t pci_host_config_read_swap(ReadWriteHandler *handler,
|
|
93 |
pcibus_t addr, int len) |
|
96 | 94 |
{ |
97 | 95 |
PCIHostState *s = container_of(handler, PCIHostState, conf_handler); |
98 | 96 |
uint32_t val = s->config_reg; |
99 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
97 |
|
|
100 | 98 |
val = qemu_bswap_len(val, len); |
101 |
#endif |
|
102 | 99 |
PCI_DPRINTF("%s addr %" FMT_PCIBUS " len %d val %"PRIx32"\n", |
103 | 100 |
__func__, addr, len, val); |
104 | 101 |
return val; |
... | ... | |
125 | 122 |
return val; |
126 | 123 |
} |
127 | 124 |
|
128 |
static void pci_host_data_write(ReadWriteHandler *handler, |
|
129 |
pcibus_t addr, uint32_t val, int len) |
|
125 |
static void pci_host_data_write_swap(ReadWriteHandler *handler,
|
|
126 |
pcibus_t addr, uint32_t val, int len)
|
|
130 | 127 |
{ |
131 | 128 |
PCIHostState *s = container_of(handler, PCIHostState, data_handler); |
132 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
129 |
|
|
133 | 130 |
val = qemu_bswap_len(val, len); |
134 |
#endif |
|
135 | 131 |
PCI_DPRINTF("write addr %" FMT_PCIBUS " len %d val %x\n", |
136 | 132 |
addr, len, val); |
137 | 133 |
if (s->config_reg & (1u << 31)) |
138 | 134 |
pci_data_write(s->bus, s->config_reg | (addr & 3), val, len); |
139 | 135 |
} |
140 | 136 |
|
141 |
static uint32_t pci_host_data_read(ReadWriteHandler *handler, |
|
142 |
pcibus_t addr, int len) |
|
137 |
static uint32_t pci_host_data_read_swap(ReadWriteHandler *handler,
|
|
138 |
pcibus_t addr, int len)
|
|
143 | 139 |
{ |
144 | 140 |
PCIHostState *s = container_of(handler, PCIHostState, data_handler); |
145 | 141 |
uint32_t val; |
... | ... | |
148 | 144 |
val = pci_data_read(s->bus, s->config_reg | (addr & 3), len); |
149 | 145 |
PCI_DPRINTF("read addr %" FMT_PCIBUS " len %d val %x\n", |
150 | 146 |
addr, len, val); |
151 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
152 | 147 |
val = qemu_bswap_len(val, len); |
153 |
#endif |
|
154 | 148 |
return val; |
155 | 149 |
} |
156 | 150 |
|
157 |
static void pci_host_init(PCIHostState *s) |
|
151 |
static void pci_host_data_write_noswap(ReadWriteHandler *handler, |
|
152 |
pcibus_t addr, uint32_t val, int len) |
|
158 | 153 |
{ |
159 |
s->conf_handler.write = pci_host_config_write; |
|
160 |
s->conf_handler.read = pci_host_config_read; |
|
161 |
s->conf_noswap_handler.write = pci_host_config_write_noswap; |
|
162 |
s->conf_noswap_handler.read = pci_host_config_read_noswap; |
|
163 |
s->data_handler.write = pci_host_data_write; |
|
164 |
s->data_handler.read = pci_host_data_read; |
|
154 |
PCIHostState *s = container_of(handler, PCIHostState, data_handler); |
|
155 |
PCI_DPRINTF("write addr %" FMT_PCIBUS " len %d val %x\n", |
|
156 |
addr, len, val); |
|
157 |
if (s->config_reg & (1u << 31)) |
|
158 |
pci_data_write(s->bus, s->config_reg | (addr & 3), val, len); |
|
165 | 159 |
} |
166 | 160 |
|
167 |
int pci_host_conf_register_mmio(PCIHostState *s) |
|
161 |
static uint32_t pci_host_data_read_noswap(ReadWriteHandler *handler, |
|
162 |
pcibus_t addr, int len) |
|
168 | 163 |
{ |
169 |
pci_host_init(s); |
|
170 |
return cpu_register_io_memory_simple(&s->conf_handler); |
|
164 |
PCIHostState *s = container_of(handler, PCIHostState, data_handler); |
|
165 |
uint32_t val; |
|
166 |
if (!(s->config_reg & (1 << 31))) |
|
167 |
return 0xffffffff; |
|
168 |
val = pci_data_read(s->bus, s->config_reg | (addr & 3), len); |
|
169 |
PCI_DPRINTF("read addr %" FMT_PCIBUS " len %d val %x\n", |
|
170 |
addr, len, val); |
|
171 |
return val; |
|
171 | 172 |
} |
172 | 173 |
|
173 |
int pci_host_conf_register_mmio_noswap(PCIHostState *s) |
|
174 |
static void pci_host_init(PCIHostState *s) |
|
175 |
{ |
|
176 |
s->conf_handler.write = pci_host_config_write_swap; |
|
177 |
s->conf_handler.read = pci_host_config_read_swap; |
|
178 |
s->conf_noswap_handler.write = pci_host_config_write_noswap; |
|
179 |
s->conf_noswap_handler.read = pci_host_config_read_noswap; |
|
180 |
s->data_handler.write = pci_host_data_write_swap; |
|
181 |
s->data_handler.read = pci_host_data_read_swap; |
|
182 |
s->data_noswap_handler.write = pci_host_data_write_noswap; |
|
183 |
s->data_noswap_handler.read = pci_host_data_read_noswap; |
|
184 |
} |
|
185 |
|
|
186 |
int pci_host_conf_register_mmio(PCIHostState *s, int swap) |
|
174 | 187 |
{ |
175 | 188 |
pci_host_init(s); |
176 |
return cpu_register_io_memory_simple(&s->conf_noswap_handler); |
|
189 |
if (swap) { |
|
190 |
return cpu_register_io_memory_simple(&s->conf_handler); |
|
191 |
} else { |
|
192 |
return cpu_register_io_memory_simple(&s->conf_noswap_handler); |
|
193 |
} |
|
177 | 194 |
} |
178 | 195 |
|
179 | 196 |
void pci_host_conf_register_ioport(pio_addr_t ioport, PCIHostState *s) |
... | ... | |
182 | 199 |
register_ioport_simple(&s->conf_noswap_handler, ioport, 4, 4); |
183 | 200 |
} |
184 | 201 |
|
185 |
int pci_host_data_register_mmio(PCIHostState *s) |
|
202 |
int pci_host_data_register_mmio(PCIHostState *s, int swap)
|
|
186 | 203 |
{ |
187 | 204 |
pci_host_init(s); |
188 |
return cpu_register_io_memory_simple(&s->data_handler); |
|
205 |
if (swap) { |
|
206 |
return cpu_register_io_memory_simple(&s->data_handler); |
|
207 |
} else { |
|
208 |
return cpu_register_io_memory_simple(&s->data_noswap_handler); |
|
209 |
} |
|
189 | 210 |
} |
190 | 211 |
|
191 | 212 |
void pci_host_data_register_ioport(pio_addr_t ioport, PCIHostState *s) |
Also available in: Unified diff