2011-04-01 08:15:21 +04:00
|
|
|
#ifndef _HW_SPAPR_VIO_H
|
|
|
|
#define _HW_SPAPR_VIO_H
|
|
|
|
/*
|
|
|
|
* QEMU sPAPR VIO bus definitions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 David Gibson, IBM Corporation <david@gibson.dropbear.id.au>
|
|
|
|
* Based on the s390 virtio bus definitions:
|
|
|
|
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-04-01 08:15:28 +04:00
|
|
|
#define SPAPR_VIO_TCE_PAGE_SHIFT 12
|
|
|
|
#define SPAPR_VIO_TCE_PAGE_SIZE (1ULL << SPAPR_VIO_TCE_PAGE_SHIFT)
|
|
|
|
#define SPAPR_VIO_TCE_PAGE_MASK (SPAPR_VIO_TCE_PAGE_SIZE - 1)
|
|
|
|
|
|
|
|
enum VIOsPAPR_TCEAccess {
|
|
|
|
SPAPR_TCE_FAULT = 0,
|
|
|
|
SPAPR_TCE_RO = 1,
|
|
|
|
SPAPR_TCE_WO = 2,
|
|
|
|
SPAPR_TCE_RW = 3,
|
|
|
|
};
|
|
|
|
|
2011-12-16 02:31:06 +04:00
|
|
|
#define TYPE_VIO_SPAPR_DEVICE "vio-spapr-device"
|
|
|
|
#define VIO_SPAPR_DEVICE(obj) \
|
|
|
|
OBJECT_CHECK(VIOsPAPRDevice, (obj), TYPE_VIO_SPAPR_DEVICE)
|
|
|
|
#define VIO_SPAPR_DEVICE_CLASS(klass) \
|
|
|
|
OBJECT_CLASS_CHECK(VIOsPAPRDeviceClass, (klass), TYPE_VIO_SPAPR_DEVICE)
|
|
|
|
#define VIO_SPAPR_DEVICE_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(VIOsPAPRDeviceClass, (obj), TYPE_VIO_SPAPR_DEVICE)
|
|
|
|
|
2011-04-01 08:15:30 +04:00
|
|
|
struct VIOsPAPRDevice;
|
|
|
|
|
2011-04-01 08:15:28 +04:00
|
|
|
typedef struct VIOsPAPR_RTCE {
|
|
|
|
uint64_t tce;
|
|
|
|
} VIOsPAPR_RTCE;
|
|
|
|
|
2011-04-01 08:15:30 +04:00
|
|
|
typedef struct VIOsPAPR_CRQ {
|
|
|
|
uint64_t qladdr;
|
|
|
|
uint32_t qsize;
|
|
|
|
uint32_t qnext;
|
|
|
|
int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq);
|
|
|
|
} VIOsPAPR_CRQ;
|
|
|
|
|
2011-12-16 02:31:06 +04:00
|
|
|
typedef struct VIOsPAPRDevice VIOsPAPRDevice;
|
|
|
|
typedef struct VIOsPAPRBus VIOsPAPRBus;
|
|
|
|
|
|
|
|
typedef struct VIOsPAPRDeviceClass {
|
|
|
|
DeviceClass parent_class;
|
|
|
|
|
|
|
|
const char *dt_name, *dt_type, *dt_compatible;
|
|
|
|
target_ulong signal_mask;
|
|
|
|
int (*init)(VIOsPAPRDevice *dev);
|
2012-04-12 06:44:13 +04:00
|
|
|
void (*reset)(VIOsPAPRDevice *dev);
|
2011-12-16 02:31:06 +04:00
|
|
|
int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
|
|
|
|
} VIOsPAPRDeviceClass;
|
|
|
|
|
|
|
|
struct VIOsPAPRDevice {
|
2011-04-01 08:15:21 +04:00
|
|
|
DeviceState qdev;
|
|
|
|
uint32_t reg;
|
2011-04-01 08:15:32 +04:00
|
|
|
uint32_t flags;
|
|
|
|
#define VIO_PAPR_FLAG_DMA_BYPASS 0x1
|
2011-04-01 08:15:26 +04:00
|
|
|
qemu_irq qirq;
|
|
|
|
uint32_t vio_irq_num;
|
|
|
|
target_ulong signal_state;
|
2011-04-01 08:15:28 +04:00
|
|
|
uint32_t rtce_window_size;
|
|
|
|
VIOsPAPR_RTCE *rtce_table;
|
2011-09-30 01:39:12 +04:00
|
|
|
int kvmtce_fd;
|
2011-04-01 08:15:30 +04:00
|
|
|
VIOsPAPR_CRQ crq;
|
2011-12-16 02:31:06 +04:00
|
|
|
};
|
2011-04-01 08:15:21 +04:00
|
|
|
|
2012-04-25 21:55:41 +04:00
|
|
|
#define DEFINE_SPAPR_PROPERTIES(type, field, default_dma_window) \
|
|
|
|
DEFINE_PROP_UINT32("reg", type, field.reg, -1), \
|
2011-05-26 13:52:45 +04:00
|
|
|
DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \
|
|
|
|
default_dma_window)
|
|
|
|
|
2011-12-16 02:31:06 +04:00
|
|
|
struct VIOsPAPRBus {
|
2011-04-01 08:15:21 +04:00
|
|
|
BusState bus;
|
2012-04-25 21:55:41 +04:00
|
|
|
uint32_t next_reg;
|
2011-04-01 08:15:21 +04:00
|
|
|
int (*init)(VIOsPAPRDevice *dev);
|
|
|
|
int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
|
2011-12-16 02:31:06 +04:00
|
|
|
};
|
2011-04-01 08:15:21 +04:00
|
|
|
|
|
|
|
extern VIOsPAPRBus *spapr_vio_bus_init(void);
|
|
|
|
extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
|
|
|
|
extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt);
|
2011-12-13 08:24:34 +04:00
|
|
|
extern int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus);
|
2011-04-01 08:15:21 +04:00
|
|
|
|
2011-04-01 08:15:26 +04:00
|
|
|
extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode);
|
|
|
|
|
2011-04-01 08:15:28 +04:00
|
|
|
int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
|
|
|
|
target_ulong len,
|
|
|
|
enum VIOsPAPR_TCEAccess access);
|
|
|
|
|
|
|
|
int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
void *buf, uint32_t size);
|
|
|
|
int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
const void *buf, uint32_t size);
|
|
|
|
int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size);
|
|
|
|
void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val);
|
|
|
|
void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val);
|
|
|
|
void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val);
|
|
|
|
void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val);
|
|
|
|
uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr);
|
|
|
|
|
2011-04-01 08:15:30 +04:00
|
|
|
int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
|
|
|
|
|
2012-04-04 09:02:07 +04:00
|
|
|
VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg);
|
2011-04-01 08:15:21 +04:00
|
|
|
void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len);
|
2012-04-25 21:55:41 +04:00
|
|
|
void spapr_vty_create(VIOsPAPRBus *bus, CharDriverState *chardev);
|
|
|
|
void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd);
|
|
|
|
void spapr_vscsi_create(VIOsPAPRBus *bus);
|
2011-04-01 08:15:31 +04:00
|
|
|
|
2011-12-13 08:24:34 +04:00
|
|
|
VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus);
|
|
|
|
|
2011-04-01 08:15:32 +04:00
|
|
|
int spapr_tce_set_bypass(uint32_t unit, uint32_t enable);
|
|
|
|
void spapr_vio_quiesce(void);
|
|
|
|
|
2011-04-01 08:15:21 +04:00
|
|
|
#endif /* _HW_SPAPR_VIO_H */
|