Revision a455783b hw/pci_host.c
b/hw/pci_host.c | ||
---|---|---|
32 | 32 |
#define PCI_DPRINTF(fmt, ...) |
33 | 33 |
#endif |
34 | 34 |
|
35 |
static void pci_host_config_writel(void *opaque, target_phys_addr_t addr, |
|
36 |
uint32_t val) |
|
37 |
{ |
|
38 |
PCIHostState *s = opaque; |
|
39 |
|
|
40 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
41 |
val = bswap32(val); |
|
42 |
#endif |
|
43 |
PCI_DPRINTF("%s addr " TARGET_FMT_plx " val %"PRIx32"\n", |
|
44 |
__func__, addr, val); |
|
45 |
s->config_reg = val; |
|
46 |
} |
|
47 |
|
|
48 |
static uint32_t pci_host_config_readl(void *opaque, target_phys_addr_t addr) |
|
49 |
{ |
|
50 |
PCIHostState *s = opaque; |
|
51 |
uint32_t val = s->config_reg; |
|
52 |
|
|
53 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
54 |
val = bswap32(val); |
|
55 |
#endif |
|
56 |
PCI_DPRINTF("%s addr " TARGET_FMT_plx " val %"PRIx32"\n", |
|
57 |
__func__, addr, val); |
|
58 |
return val; |
|
59 |
} |
|
60 |
|
|
61 |
static CPUWriteMemoryFunc * const pci_host_config_write[] = { |
|
62 |
&pci_host_config_writel, |
|
63 |
&pci_host_config_writel, |
|
64 |
&pci_host_config_writel, |
|
65 |
}; |
|
66 |
|
|
67 |
static CPUReadMemoryFunc * const pci_host_config_read[] = { |
|
68 |
&pci_host_config_readl, |
|
69 |
&pci_host_config_readl, |
|
70 |
&pci_host_config_readl, |
|
71 |
}; |
|
72 |
|
|
73 |
int pci_host_config_register_io_memory(PCIHostState *s) |
|
74 |
{ |
|
75 |
return cpu_register_io_memory(pci_host_config_read, |
|
76 |
pci_host_config_write, s); |
|
77 |
} |
|
78 |
|
|
79 |
static void pci_host_config_writel_noswap(void *opaque, |
|
80 |
target_phys_addr_t addr, |
|
81 |
uint32_t val) |
|
82 |
{ |
|
83 |
PCIHostState *s = opaque; |
|
84 |
|
|
85 |
PCI_DPRINTF("%s addr " TARGET_FMT_plx " val %"PRIx32"\n", |
|
86 |
__func__, addr, val); |
|
87 |
s->config_reg = val; |
|
88 |
} |
|
89 |
|
|
90 |
static uint32_t pci_host_config_readl_noswap(void *opaque, |
|
91 |
target_phys_addr_t addr) |
|
92 |
{ |
|
93 |
PCIHostState *s = opaque; |
|
94 |
uint32_t val = s->config_reg; |
|
95 |
|
|
96 |
PCI_DPRINTF("%s addr " TARGET_FMT_plx " val %"PRIx32"\n", |
|
97 |
__func__, addr, val); |
|
98 |
return val; |
|
99 |
} |
|
100 |
|
|
101 |
static CPUWriteMemoryFunc * const pci_host_config_write_noswap[] = { |
|
102 |
&pci_host_config_writel_noswap, |
|
103 |
&pci_host_config_writel_noswap, |
|
104 |
&pci_host_config_writel_noswap, |
|
105 |
}; |
|
106 |
|
|
107 |
static CPUReadMemoryFunc * const pci_host_config_read_noswap[] = { |
|
108 |
&pci_host_config_readl_noswap, |
|
109 |
&pci_host_config_readl_noswap, |
|
110 |
&pci_host_config_readl_noswap, |
|
111 |
}; |
|
112 |
|
|
113 |
int pci_host_config_register_io_memory_noswap(PCIHostState *s) |
|
114 |
{ |
|
115 |
return cpu_register_io_memory(pci_host_config_read_noswap, |
|
116 |
pci_host_config_write_noswap, s); |
|
117 |
} |
|
118 |
|
|
119 |
static void pci_host_config_writel_ioport(void *opaque, |
|
120 |
uint32_t addr, uint32_t val) |
|
121 |
{ |
|
122 |
PCIHostState *s = opaque; |
|
123 |
|
|
124 |
PCI_DPRINTF("%s addr %"PRIx32 " val %"PRIx32"\n", __func__, addr, val); |
|
125 |
s->config_reg = val; |
|
126 |
} |
|
127 |
|
|
128 |
static uint32_t pci_host_config_readl_ioport(void *opaque, uint32_t addr) |
|
129 |
{ |
|
130 |
PCIHostState *s = opaque; |
|
131 |
uint32_t val = s->config_reg; |
|
132 |
|
|
133 |
PCI_DPRINTF("%s addr %"PRIx32" val %"PRIx32"\n", __func__, addr, val); |
|
134 |
return val; |
|
135 |
} |
|
136 |
|
|
137 |
void pci_host_config_register_ioport(pio_addr_t ioport, PCIHostState *s) |
|
138 |
{ |
|
139 |
register_ioport_write(ioport, 4, 4, pci_host_config_writel_ioport, s); |
|
140 |
register_ioport_read(ioport, 4, 4, pci_host_config_readl_ioport, s); |
|
141 |
} |
|
142 |
|
|
35 | 143 |
#define PCI_ADDR_T target_phys_addr_t |
36 | 144 |
#define PCI_HOST_SUFFIX _mmio |
37 | 145 |
|
Also available in: Unified diff