1 #ifndef _HW_SPAPR_VIO_H
2 #define _HW_SPAPR_VIO_H
4 * QEMU sPAPR VIO bus definitions
7 * Based on the s390 virtio bus definitions:
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 #define SPAPR_VIO_TCE_PAGE_SHIFT 12
25 #define SPAPR_VIO_TCE_PAGE_SIZE (1ULL << SPAPR_VIO_TCE_PAGE_SHIFT)
26 #define SPAPR_VIO_TCE_PAGE_MASK (SPAPR_VIO_TCE_PAGE_SIZE - 1)
28 enum VIOsPAPR_TCEAccess {
35 #define SPAPR_VTY_BASE_ADDRESS 0x30000000
37 struct VIOsPAPRDevice;
39 typedef struct VIOsPAPR_RTCE {
43 typedef struct VIOsPAPR_CRQ {
47 int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq);
50 typedef struct VIOsPAPRDevice {
54 #define VIO_PAPR_FLAG_DMA_BYPASS 0x1
57 target_ulong signal_state;
58 uint32_t rtce_window_size;
59 VIOsPAPR_RTCE *rtce_table;
63 #define DEFINE_SPAPR_PROPERTIES(type, field, default_reg, default_dma_window) \
64 DEFINE_PROP_UINT32("reg", type, field.reg, default_reg), \
65 DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \
68 typedef struct VIOsPAPRBus {
74 const char *dt_name, *dt_type, *dt_compatible;
75 target_ulong signal_mask;
76 int (*init)(VIOsPAPRDevice *dev);
77 void (*hcalls)(VIOsPAPRBus *bus);
78 int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
81 extern VIOsPAPRBus *spapr_vio_bus_init(void);
82 extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
83 extern void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info);
84 extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt);
86 extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode);
88 int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
90 enum VIOsPAPR_TCEAccess access);
92 int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
93 void *buf, uint32_t size);
94 int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
95 const void *buf, uint32_t size);
96 int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size);
97 void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val);
98 void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val);
99 void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val);
100 void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val);
101 uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr);
103 int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
105 void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len);
106 void spapr_vty_create(VIOsPAPRBus *bus, uint32_t reg, CharDriverState *chardev);
107 void spapr_vlan_create(VIOsPAPRBus *bus, uint32_t reg, NICInfo *nd);
108 void spapr_vscsi_create(VIOsPAPRBus *bus, uint32_t reg);
110 int spapr_tce_set_bypass(uint32_t unit, uint32_t enable);
111 void spapr_vio_quiesce(void);
113 #endif /* _HW_SPAPR_VIO_H */