2011-04-01 06:15:21 +02: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 18:20:04 +01:00
|
|
|
#include "sysemu/dma.h"
|
2011-04-01 06:15:28 +02:00
|
|
|
|
2011-12-15 23:31:06 +01: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 09:00:20 +02:00
|
|
|
#define TYPE_SPAPR_VIO_BUS "spapr-vio-bus"
|
|
|
|
#define SPAPR_VIO_BUS(obj) OBJECT_CHECK(VIOsPAPRBus, (obj), TYPE_SPAPR_VIO_BUS)
|
|
|
|
|
2015-12-23 12:30:12 +01:00
|
|
|
#define TYPE_SPAPR_VIO_BRIDGE "spapr-vio-bridge"
|
2011-04-01 06:15:30 +02: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-15 23:31:06 +01: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 06:50:44 +02:00
|
|
|
uint32_t rtce_window_size;
|
2015-02-27 11:52:17 +01:00
|
|
|
void (*realize)(VIOsPAPRDevice *dev, Error **errp);
|
2012-04-12 04:44:13 +02:00
|
|
|
void (*reset)(VIOsPAPRDevice *dev);
|
2011-12-15 23:31:06 +01:00
|
|
|
int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
|
|
|
|
} VIOsPAPRDeviceClass;
|
|
|
|
|
|
|
|
struct VIOsPAPRDevice {
|
2011-04-01 06:15:21 +02:00
|
|
|
DeviceState qdev;
|
|
|
|
uint32_t reg;
|
2012-08-07 18:10:32 +02:00
|
|
|
uint32_t irq;
|
2011-04-01 06:15:26 +02:00
|
|
|
target_ulong signal_state;
|
2011-04-01 06:15:30 +02:00
|
|
|
VIOsPAPR_CRQ crq;
|
2013-04-11 12:38:50 +02:00
|
|
|
AddressSpace as;
|
2015-01-29 06:04:58 +01:00
|
|
|
MemoryRegion mrroot;
|
|
|
|
MemoryRegion mrbypass;
|
2013-04-10 17:30:48 +02:00
|
|
|
sPAPRTCETable *tcet;
|
2011-12-15 23:31:06 +01:00
|
|
|
};
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2012-06-27 06:50:44 +02:00
|
|
|
#define DEFINE_SPAPR_PROPERTIES(type, field) \
|
|
|
|
DEFINE_PROP_UINT32("reg", type, field.reg, -1)
|
2011-05-26 11:52:45 +02:00
|
|
|
|
2011-12-15 23:31:06 +01:00
|
|
|
struct VIOsPAPRBus {
|
2011-04-01 06:15:21 +02:00
|
|
|
BusState bus;
|
2012-04-25 19:55:41 +02:00
|
|
|
uint32_t next_reg;
|
2011-04-01 06:15:21 +02:00
|
|
|
int (*init)(VIOsPAPRDevice *dev);
|
|
|
|
int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
|
2011-12-15 23:31:06 +01:00
|
|
|
};
|
2011-04-01 06:15:21 +02: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 05:24:34 +01:00
|
|
|
extern int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus);
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2011-04-01 06:15:26 +02:00
|
|
|
extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode);
|
|
|
|
|
2012-08-07 18:10:32 +02:00
|
|
|
static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev)
|
|
|
|
{
|
2015-07-02 08:23:04 +02:00
|
|
|
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
|
|
|
|
|
2012-08-07 18:10:32 +02:00
|
|
|
return xics_get_qirq(spapr->icp, dev->irq);
|
|
|
|
}
|
|
|
|
|
2012-06-27 06:50:44 +02:00
|
|
|
static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
uint32_t size, DMADirection dir)
|
|
|
|
{
|
2013-04-10 18:15:49 +02:00
|
|
|
return dma_memory_valid(&dev->as, taddr, size, dir);
|
2012-06-27 06:50:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int spapr_vio_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
|
|
|
|
void *buf, uint32_t size)
|
|
|
|
{
|
2013-04-10 18:15:49 +02:00
|
|
|
return (dma_memory_read(&dev->as, taddr, buf, size) != 0) ?
|
2012-06-27 06:50:44 +02: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 18:15:49 +02:00
|
|
|
return (dma_memory_write(&dev->as, taddr, buf, size) != 0) ?
|
2012-06-27 06:50:44 +02: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 18:15:49 +02:00
|
|
|
return (dma_memory_set(&dev->as, taddr, c, size) != 0) ?
|
2012-06-27 06:50:44 +02:00
|
|
|
H_DEST_PARM : H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-04-10 18:15:49 +02: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 06:15:28 +02:00
|
|
|
|
2011-04-01 06:15:30 +02:00
|
|
|
int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
|
|
|
|
|
2015-07-02 08:23:04 +02:00
|
|
|
VIOsPAPRDevice *vty_lookup(sPAPRMachineState *spapr, target_ulong reg);
|
2011-04-01 06:15:21 +02:00
|
|
|
void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len);
|
2012-04-25 19:55:41 +02: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 06:15:31 +02:00
|
|
|
|
2011-12-13 05:24:34 +01:00
|
|
|
VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus);
|
|
|
|
|
2011-04-01 06:15:32 +02:00
|
|
|
void spapr_vio_quiesce(void);
|
|
|
|
|
2013-07-18 21:32:55 +02: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 06:04:58 +01:00
|
|
|
void spapr_vio_set_bypass(VIOsPAPRDevice *dev, bool bypass);
|
|
|
|
|
2011-04-01 06:15:21 +02:00
|
|
|
#endif /* _HW_SPAPR_VIO_H */
|