|
|
1.1 root 1: #ifndef _HW_SPAPR_VIO_H
2: #define _HW_SPAPR_VIO_H
3: /*
4: * QEMU sPAPR VIO bus definitions
5: *
6: * Copyright (c) 2010 David Gibson, IBM Corporation <[email protected]>
7: * Based on the s390 virtio bus definitions:
8: * Copyright (c) 2009 Alexander Graf <[email protected]>
9: *
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.
14: *
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.
19: *
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/>.
22: */
23:
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)
27:
28: enum VIOsPAPR_TCEAccess {
29: SPAPR_TCE_FAULT = 0,
30: SPAPR_TCE_RO = 1,
31: SPAPR_TCE_WO = 2,
32: SPAPR_TCE_RW = 3,
33: };
34:
1.1.1.3 ! root 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)
1.1 root 42:
43: struct VIOsPAPRDevice;
44:
45: typedef struct VIOsPAPR_RTCE {
46: uint64_t tce;
47: } VIOsPAPR_RTCE;
48:
49: typedef struct VIOsPAPR_CRQ {
50: uint64_t qladdr;
51: uint32_t qsize;
52: uint32_t qnext;
53: int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq);
54: } VIOsPAPR_CRQ;
55:
1.1.1.3 ! root 56: typedef struct VIOsPAPRDevice VIOsPAPRDevice;
! 57: typedef struct VIOsPAPRBus VIOsPAPRBus;
! 58:
! 59: typedef struct VIOsPAPRDeviceClass {
! 60: DeviceClass parent_class;
! 61:
! 62: const char *dt_name, *dt_type, *dt_compatible;
! 63: target_ulong signal_mask;
! 64: int (*init)(VIOsPAPRDevice *dev);
! 65: void (*reset)(VIOsPAPRDevice *dev);
! 66: int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
! 67: } VIOsPAPRDeviceClass;
! 68:
! 69: struct VIOsPAPRDevice {
1.1 root 70: DeviceState qdev;
71: uint32_t reg;
72: uint32_t flags;
73: #define VIO_PAPR_FLAG_DMA_BYPASS 0x1
74: qemu_irq qirq;
75: uint32_t vio_irq_num;
76: target_ulong signal_state;
77: uint32_t rtce_window_size;
78: VIOsPAPR_RTCE *rtce_table;
1.1.1.2 root 79: int kvmtce_fd;
1.1 root 80: VIOsPAPR_CRQ crq;
1.1.1.3 ! root 81: };
1.1 root 82:
1.1.1.3 ! root 83: #define DEFINE_SPAPR_PROPERTIES(type, field, default_dma_window) \
! 84: DEFINE_PROP_UINT32("reg", type, field.reg, -1), \
1.1.1.2 root 85: DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \
86: default_dma_window)
87:
1.1.1.3 ! root 88: struct VIOsPAPRBus {
1.1 root 89: BusState bus;
1.1.1.3 ! root 90: uint32_t next_reg;
1.1 root 91: int (*init)(VIOsPAPRDevice *dev);
92: int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
1.1.1.3 ! root 93: };
1.1 root 94:
95: extern VIOsPAPRBus *spapr_vio_bus_init(void);
96: extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
97: extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt);
1.1.1.2 root 98: extern int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus);
1.1 root 99:
100: extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode);
101:
102: int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
103: target_ulong len,
104: enum VIOsPAPR_TCEAccess access);
105:
106: int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
107: void *buf, uint32_t size);
108: int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
109: const void *buf, uint32_t size);
110: int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size);
111: void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val);
112: void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val);
113: void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val);
114: void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val);
115: uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr);
116:
117: int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
118:
1.1.1.3 ! root 119: VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg);
1.1 root 120: void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len);
1.1.1.3 ! root 121: void spapr_vty_create(VIOsPAPRBus *bus, CharDriverState *chardev);
! 122: void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd);
! 123: void spapr_vscsi_create(VIOsPAPRBus *bus);
1.1 root 124:
1.1.1.2 root 125: VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus);
1.1 root 126:
127: int spapr_tce_set_bypass(uint32_t unit, uint32_t enable);
128: void spapr_vio_quiesce(void);
129:
130: #endif /* _HW_SPAPR_VIO_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.