4 * Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
5 * VA Linux Systems Japan K.K.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #define PCI_DPRINTF(fmt, ...) \
30 do { printf("pci_host_data: " fmt , ## __VA_ARGS__); } while (0)
32 #define PCI_DPRINTF(fmt, ...)
35 static void pci_host_config_writel(void *opaque
, target_phys_addr_t addr
,
38 PCIHostState
*s
= opaque
;
40 #ifdef TARGET_WORDS_BIGENDIAN
43 PCI_DPRINTF("%s addr " TARGET_FMT_plx
" val %"PRIx32
"\n",
48 static uint32_t pci_host_config_readl(void *opaque
, target_phys_addr_t addr
)
50 PCIHostState
*s
= opaque
;
51 uint32_t val
= s
->config_reg
;
53 #ifdef TARGET_WORDS_BIGENDIAN
56 PCI_DPRINTF("%s addr " TARGET_FMT_plx
" val %"PRIx32
"\n",
61 static CPUWriteMemoryFunc
* const pci_host_config_write
[] = {
62 &pci_host_config_writel
,
63 &pci_host_config_writel
,
64 &pci_host_config_writel
,
67 static CPUReadMemoryFunc
* const pci_host_config_read
[] = {
68 &pci_host_config_readl
,
69 &pci_host_config_readl
,
70 &pci_host_config_readl
,
73 int pci_host_config_register_io_memory(PCIHostState
*s
)
75 return cpu_register_io_memory(pci_host_config_read
,
76 pci_host_config_write
, s
);
79 static void pci_host_config_writel_noswap(void *opaque
,
80 target_phys_addr_t addr
,
83 PCIHostState
*s
= opaque
;
85 PCI_DPRINTF("%s addr " TARGET_FMT_plx
" val %"PRIx32
"\n",
90 static uint32_t pci_host_config_readl_noswap(void *opaque
,
91 target_phys_addr_t addr
)
93 PCIHostState
*s
= opaque
;
94 uint32_t val
= s
->config_reg
;
96 PCI_DPRINTF("%s addr " TARGET_FMT_plx
" val %"PRIx32
"\n",
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
,
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
,
113 int pci_host_config_register_io_memory_noswap(PCIHostState
*s
)
115 return cpu_register_io_memory(pci_host_config_read_noswap
,
116 pci_host_config_write_noswap
, s
);
119 static void pci_host_config_writel_ioport(void *opaque
,
120 uint32_t addr
, uint32_t val
)
122 PCIHostState
*s
= opaque
;
124 PCI_DPRINTF("%s addr %"PRIx32
" val %"PRIx32
"\n", __func__
, addr
, val
);
128 static uint32_t pci_host_config_readl_ioport(void *opaque
, uint32_t addr
)
130 PCIHostState
*s
= opaque
;
131 uint32_t val
= s
->config_reg
;
133 PCI_DPRINTF("%s addr %"PRIx32
" val %"PRIx32
"\n", __func__
, addr
, val
);
137 void pci_host_config_register_ioport(pio_addr_t ioport
, PCIHostState
*s
)
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
);
143 #define PCI_ADDR_T target_phys_addr_t
144 #define PCI_HOST_SUFFIX _mmio
146 #include "pci_host_template.h"
148 static CPUWriteMemoryFunc
* const pci_host_data_write_mmio
[] = {
149 pci_host_data_writeb_mmio
,
150 pci_host_data_writew_mmio
,
151 pci_host_data_writel_mmio
,
154 static CPUReadMemoryFunc
* const pci_host_data_read_mmio
[] = {
155 pci_host_data_readb_mmio
,
156 pci_host_data_readw_mmio
,
157 pci_host_data_readl_mmio
,
160 int pci_host_data_register_io_memory(PCIHostState
*s
)
162 return cpu_register_io_memory(pci_host_data_read_mmio
,
163 pci_host_data_write_mmio
,
168 #undef PCI_HOST_SUFFIX
170 #define PCI_ADDR_T uint32_t
171 #define PCI_HOST_SUFFIX _ioport
173 #include "pci_host_template.h"
175 void pci_host_data_register_ioport(pio_addr_t ioport
, PCIHostState
*s
)
177 register_ioport_write(ioport
, 4, 1, pci_host_data_writeb_ioport
, s
);
178 register_ioport_write(ioport
, 4, 2, pci_host_data_writew_ioport
, s
);
179 register_ioport_write(ioport
, 4, 4, pci_host_data_writel_ioport
, s
);
180 register_ioport_read(ioport
, 4, 1, pci_host_data_readb_ioport
, s
);
181 register_ioport_read(ioport
, 4, 2, pci_host_data_readw_ioport
, s
);
182 register_ioport_read(ioport
, 4, 4, pci_host_data_readl_ioport
, s
);