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/>.
|
|
|
|
*/
|
|
|
|
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/dma.h"
|
2011-04-01 08:15:28 +04:00
|
|
|
|
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)
|
|
|
|
|
2012-05-02 11:00:20 +04:00
|
|
|
#define TYPE_SPAPR_VIO_BUS "spapr-vio-bus"
|
|
|
|
#define SPAPR_VIO_BUS(obj) OBJECT_CHECK(VIOsPAPRBus, (obj), TYPE_SPAPR_VIO_BUS)
|
|
|
|
|
2011-04-01 08:15:30 +04:00
|
|
|
struct VIOsPAPRDevice;
|
|
|
|
|
|
|
|
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;
|
2012-06-27 08:50:44 +04:00
|
|
|
uint32_t rtce_window_size;
|
2015-02-27 13:52:17 +03:00
|
|
|
void (*realize)(VIOsPAPRDevice *dev, Error **errp);
|
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;
|
2012-08-07 20:10:32 +04:00
|
|
|
uint32_t irq;
|
2011-04-01 08:15:26 +04:00
|
|
|
target_ulong signal_state;
|
2011-04-01 08:15:30 +04:00
|
|
|
VIOsPAPR_CRQ crq;
|
2013-04-11 14:38:50 +04:00
|
|
|
AddressSpace as;
|
2015-01-29 08:04:58 +03:00
|
|
|
MemoryRegion mrroot;
|
|
|
|
MemoryRegion mrbypass;
|
2013-04-10 19:30:48 +04:00
|
|
|
sPAPRTCETable *tcet;
|
2011-12-16 02:31:06 +04:00
|
|
|
};
|
2011-04-01 08:15:21 +04:00
|
|
|
|
2012-06-27 08:50:44 +04:00
|
|
|
#define DEFINE_SPAPR_PROPERTIES(type, field) \
|
|
|
|
DEFINE_PROP_UINT32("reg", type, field.reg, -1)
|
2011-05-26 13:52:45 +04:00
|
|
|
|
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);
|
|
|
|
|
2012-08-07 20:10:32 +04:00
|
|
|
static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev)
|
|
|
|
{
|
|
|
|
return xics_get_qirq(spapr->icp, dev->irq);
|
|
|
|
}
|
|
|
|
|
2012-06-27 08:50:44 +04:00
|
|
|
static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
uint32_t size, DMADirection dir)
|
|
|
|
{
|
2013-04-10 20:15:49 +04:00
|
|
|
return dma_memory_valid(&dev->as, taddr, size, dir);
|
2012-06-27 08:50:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int spapr_vio_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
void *buf, uint32_t size)
|
|
|
|
{
|
2013-04-10 20:15:49 +04:00
|
|
|
return (dma_memory_read(&dev->as, taddr, buf, size) != 0) ?
|
2012-06-27 08:50:44 +04:00
|
|
|
H_DEST_PARM : H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int spapr_vio_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
const void *buf, uint32_t size)
|
|
|
|
{
|
2013-04-10 20:15:49 +04:00
|
|
|
return (dma_memory_write(&dev->as, taddr, buf, size) != 0) ?
|
2012-06-27 08:50:44 +04:00
|
|
|
H_DEST_PARM : H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int spapr_vio_dma_set(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
uint8_t c, uint32_t size)
|
|
|
|
{
|
2013-04-10 20:15:49 +04:00
|
|
|
return (dma_memory_set(&dev->as, taddr, c, size) != 0) ?
|
2012-06-27 08:50:44 +04:00
|
|
|
H_DEST_PARM : H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-04-10 20:15:49 +04:00
|
|
|
#define vio_stb(_dev, _addr, _val) (stb_dma(&(_dev)->as, (_addr), (_val)))
|
|
|
|
#define vio_sth(_dev, _addr, _val) (stw_be_dma(&(_dev)->as, (_addr), (_val)))
|
|
|
|
#define vio_stl(_dev, _addr, _val) (stl_be_dma(&(_dev)->as, (_addr), (_val)))
|
|
|
|
#define vio_stq(_dev, _addr, _val) (stq_be_dma(&(_dev)->as, (_addr), (_val)))
|
|
|
|
#define vio_ldq(_dev, _addr) (ldq_be_dma(&(_dev)->as, (_addr)))
|
2011-04-01 08:15:28 +04:00
|
|
|
|
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
|
|
|
void spapr_vio_quiesce(void);
|
|
|
|
|
2013-07-18 23:32:55 +04:00
|
|
|
extern const VMStateDescription vmstate_spapr_vio;
|
|
|
|
|
|
|
|
#define VMSTATE_SPAPR_VIO(_f, _s) \
|
|
|
|
VMSTATE_STRUCT(_f, _s, 0, vmstate_spapr_vio, VIOsPAPRDevice)
|
|
|
|
|
2015-01-29 08:04:58 +03:00
|
|
|
void spapr_vio_set_bypass(VIOsPAPRDevice *dev, bool bypass);
|
|
|
|
|
2011-04-01 08:15:21 +04:00
|
|
|
#endif /* _HW_SPAPR_VIO_H */
|