1 #ifndef _HW_SPAPR_VIO_H
2 #define _HW_SPAPR_VIO_H
4 * QEMU sPAPR VIO bus definitions
6 * Copyright (c) 2010 David Gibson, IBM Corporation <david@gibson.dropbear.id.au>
7 * Based on the s390 virtio bus definitions:
8 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
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 TYPE_VIO_SPAPR_DEVICE "vio-spapr-device"
36 #define VIO_SPAPR_DEVICE(obj) \
37 OBJECT_CHECK(VIOsPAPRDevice, (obj), TYPE_VIO_SPAPR_DEVICE)
38 #define VIO_SPAPR_DEVICE_CLASS(klass) \
39 OBJECT_CLASS_CHECK(VIOsPAPRDeviceClass, (klass), TYPE_VIO_SPAPR_DEVICE)
40 #define VIO_SPAPR_DEVICE_GET_CLASS(obj) \
41 OBJECT_GET_CLASS(VIOsPAPRDeviceClass, (obj), TYPE_VIO_SPAPR_DEVICE)
43 #define TYPE_SPAPR_VIO_BUS "spapr-vio-bus"
44 #define SPAPR_VIO_BUS(obj) OBJECT_CHECK(VIOsPAPRBus, (obj), TYPE_SPAPR_VIO_BUS)
46 struct VIOsPAPRDevice
;
48 typedef struct VIOsPAPR_RTCE
{
52 typedef struct VIOsPAPR_CRQ
{
56 int(*SendFunc
)(struct VIOsPAPRDevice
*vdev
, uint8_t *crq
);
59 typedef struct VIOsPAPRDevice VIOsPAPRDevice
;
60 typedef struct VIOsPAPRBus VIOsPAPRBus
;
62 typedef struct VIOsPAPRDeviceClass
{
63 DeviceClass parent_class
;
65 const char *dt_name
, *dt_type
, *dt_compatible
;
66 target_ulong signal_mask
;
67 int (*init
)(VIOsPAPRDevice
*dev
);
68 void (*reset
)(VIOsPAPRDevice
*dev
);
69 int (*devnode
)(VIOsPAPRDevice
*dev
, void *fdt
, int node_off
);
70 } VIOsPAPRDeviceClass
;
72 struct VIOsPAPRDevice
{
76 #define VIO_PAPR_FLAG_DMA_BYPASS 0x1
79 target_ulong signal_state
;
80 uint32_t rtce_window_size
;
81 VIOsPAPR_RTCE
*rtce_table
;
86 #define DEFINE_SPAPR_PROPERTIES(type, field, default_dma_window) \
87 DEFINE_PROP_UINT32("reg", type, field.reg, -1), \
88 DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \
94 int (*init
)(VIOsPAPRDevice
*dev
);
95 int (*devnode
)(VIOsPAPRDevice
*dev
, void *fdt
, int node_off
);
98 extern VIOsPAPRBus
*spapr_vio_bus_init(void);
99 extern VIOsPAPRDevice
*spapr_vio_find_by_reg(VIOsPAPRBus
*bus
, uint32_t reg
);
100 extern int spapr_populate_vdevice(VIOsPAPRBus
*bus
, void *fdt
);
101 extern int spapr_populate_chosen_stdout(void *fdt
, VIOsPAPRBus
*bus
);
103 extern int spapr_vio_signal(VIOsPAPRDevice
*dev
, target_ulong mode
);
105 int spapr_vio_check_tces(VIOsPAPRDevice
*dev
, target_ulong ioba
,
107 enum VIOsPAPR_TCEAccess access
);
109 int spapr_tce_dma_read(VIOsPAPRDevice
*dev
, uint64_t taddr
,
110 void *buf
, uint32_t size
);
111 int spapr_tce_dma_write(VIOsPAPRDevice
*dev
, uint64_t taddr
,
112 const void *buf
, uint32_t size
);
113 int spapr_tce_dma_zero(VIOsPAPRDevice
*dev
, uint64_t taddr
, uint32_t size
);
114 void stb_tce(VIOsPAPRDevice
*dev
, uint64_t taddr
, uint8_t val
);
115 void sth_tce(VIOsPAPRDevice
*dev
, uint64_t taddr
, uint16_t val
);
116 void stw_tce(VIOsPAPRDevice
*dev
, uint64_t taddr
, uint32_t val
);
117 void stq_tce(VIOsPAPRDevice
*dev
, uint64_t taddr
, uint64_t val
);
118 uint64_t ldq_tce(VIOsPAPRDevice
*dev
, uint64_t taddr
);
120 int spapr_vio_send_crq(VIOsPAPRDevice
*dev
, uint8_t *crq
);
122 VIOsPAPRDevice
*vty_lookup(sPAPREnvironment
*spapr
, target_ulong reg
);
123 void vty_putchars(VIOsPAPRDevice
*sdev
, uint8_t *buf
, int len
);
124 void spapr_vty_create(VIOsPAPRBus
*bus
, CharDriverState
*chardev
);
125 void spapr_vlan_create(VIOsPAPRBus
*bus
, NICInfo
*nd
);
126 void spapr_vscsi_create(VIOsPAPRBus
*bus
);
128 VIOsPAPRDevice
*spapr_vty_get_default(VIOsPAPRBus
*bus
);
130 int spapr_tce_set_bypass(uint32_t unit
, uint32_t enable
);
131 void spapr_vio_quiesce(void);
133 #endif /* _HW_SPAPR_VIO_H */