root / hw / spapr_vio.h @ ab034c26
History | View | Annotate | Download (4.6 kB)
1 | 4040ab72 | David Gibson | #ifndef _HW_SPAPR_VIO_H
|
---|---|---|---|
2 | 4040ab72 | David Gibson | #define _HW_SPAPR_VIO_H
|
3 | 4040ab72 | David Gibson | /*
|
4 | 4040ab72 | David Gibson | * QEMU sPAPR VIO bus definitions
|
5 | 4040ab72 | David Gibson | *
|
6 | 4040ab72 | David Gibson | * Copyright (c) 2010 David Gibson, IBM Corporation <david@gibson.dropbear.id.au>
|
7 | 4040ab72 | David Gibson | * Based on the s390 virtio bus definitions:
|
8 | 4040ab72 | David Gibson | * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
|
9 | 4040ab72 | David Gibson | *
|
10 | 4040ab72 | David Gibson | * This library is free software; you can redistribute it and/or
|
11 | 4040ab72 | David Gibson | * modify it under the terms of the GNU Lesser General Public
|
12 | 4040ab72 | David Gibson | * License as published by the Free Software Foundation; either
|
13 | 4040ab72 | David Gibson | * version 2 of the License, or (at your option) any later version.
|
14 | 4040ab72 | David Gibson | *
|
15 | 4040ab72 | David Gibson | * This library is distributed in the hope that it will be useful,
|
16 | 4040ab72 | David Gibson | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 | 4040ab72 | David Gibson | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 | 4040ab72 | David Gibson | * Lesser General Public License for more details.
|
19 | 4040ab72 | David Gibson | *
|
20 | 4040ab72 | David Gibson | * You should have received a copy of the GNU Lesser General Public
|
21 | 4040ab72 | David Gibson | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
22 | 4040ab72 | David Gibson | */
|
23 | 4040ab72 | David Gibson | |
24 | ee86dfee | David Gibson | #define SPAPR_VIO_TCE_PAGE_SHIFT 12 |
25 | ee86dfee | David Gibson | #define SPAPR_VIO_TCE_PAGE_SIZE (1ULL << SPAPR_VIO_TCE_PAGE_SHIFT) |
26 | ee86dfee | David Gibson | #define SPAPR_VIO_TCE_PAGE_MASK (SPAPR_VIO_TCE_PAGE_SIZE - 1) |
27 | ee86dfee | David Gibson | |
28 | ee86dfee | David Gibson | enum VIOsPAPR_TCEAccess {
|
29 | ee86dfee | David Gibson | SPAPR_TCE_FAULT = 0,
|
30 | ee86dfee | David Gibson | SPAPR_TCE_RO = 1,
|
31 | ee86dfee | David Gibson | SPAPR_TCE_WO = 2,
|
32 | ee86dfee | David Gibson | SPAPR_TCE_RW = 3,
|
33 | ee86dfee | David Gibson | }; |
34 | ee86dfee | David Gibson | |
35 | 3954d33a | Anthony Liguori | #define TYPE_VIO_SPAPR_DEVICE "vio-spapr-device" |
36 | 3954d33a | Anthony Liguori | #define VIO_SPAPR_DEVICE(obj) \
|
37 | 3954d33a | Anthony Liguori | OBJECT_CHECK(VIOsPAPRDevice, (obj), TYPE_VIO_SPAPR_DEVICE) |
38 | 3954d33a | Anthony Liguori | #define VIO_SPAPR_DEVICE_CLASS(klass) \
|
39 | 3954d33a | Anthony Liguori | OBJECT_CLASS_CHECK(VIOsPAPRDeviceClass, (klass), TYPE_VIO_SPAPR_DEVICE) |
40 | 3954d33a | Anthony Liguori | #define VIO_SPAPR_DEVICE_GET_CLASS(obj) \
|
41 | 3954d33a | Anthony Liguori | OBJECT_GET_CLASS(VIOsPAPRDeviceClass, (obj), TYPE_VIO_SPAPR_DEVICE) |
42 | 3954d33a | Anthony Liguori | |
43 | b45d63b6 | Ben Herrenschmidt | struct VIOsPAPRDevice;
|
44 | b45d63b6 | Ben Herrenschmidt | |
45 | ee86dfee | David Gibson | typedef struct VIOsPAPR_RTCE { |
46 | ee86dfee | David Gibson | uint64_t tce; |
47 | ee86dfee | David Gibson | } VIOsPAPR_RTCE; |
48 | ee86dfee | David Gibson | |
49 | b45d63b6 | Ben Herrenschmidt | typedef struct VIOsPAPR_CRQ { |
50 | b45d63b6 | Ben Herrenschmidt | uint64_t qladdr; |
51 | b45d63b6 | Ben Herrenschmidt | uint32_t qsize; |
52 | b45d63b6 | Ben Herrenschmidt | uint32_t qnext; |
53 | b45d63b6 | Ben Herrenschmidt | int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq); |
54 | b45d63b6 | Ben Herrenschmidt | } VIOsPAPR_CRQ; |
55 | b45d63b6 | Ben Herrenschmidt | |
56 | 3954d33a | Anthony Liguori | typedef struct VIOsPAPRDevice VIOsPAPRDevice; |
57 | 3954d33a | Anthony Liguori | typedef struct VIOsPAPRBus VIOsPAPRBus; |
58 | 3954d33a | Anthony Liguori | |
59 | 3954d33a | Anthony Liguori | typedef struct VIOsPAPRDeviceClass { |
60 | 3954d33a | Anthony Liguori | DeviceClass parent_class; |
61 | 3954d33a | Anthony Liguori | |
62 | 3954d33a | Anthony Liguori | const char *dt_name, *dt_type, *dt_compatible; |
63 | 3954d33a | Anthony Liguori | target_ulong signal_mask; |
64 | 3954d33a | Anthony Liguori | int (*init)(VIOsPAPRDevice *dev);
|
65 | b1c7f725 | David Gibson | void (*reset)(VIOsPAPRDevice *dev);
|
66 | 3954d33a | Anthony Liguori | int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); |
67 | 3954d33a | Anthony Liguori | } VIOsPAPRDeviceClass; |
68 | 3954d33a | Anthony Liguori | |
69 | 3954d33a | Anthony Liguori | struct VIOsPAPRDevice {
|
70 | 4040ab72 | David Gibson | DeviceState qdev; |
71 | 4040ab72 | David Gibson | uint32_t reg; |
72 | 08942ac1 | Ben Herrenschmidt | uint32_t flags; |
73 | 08942ac1 | Ben Herrenschmidt | #define VIO_PAPR_FLAG_DMA_BYPASS 0x1 |
74 | 00dc738d | David Gibson | qemu_irq qirq; |
75 | 00dc738d | David Gibson | uint32_t vio_irq_num; |
76 | 00dc738d | David Gibson | target_ulong signal_state; |
77 | ee86dfee | David Gibson | uint32_t rtce_window_size; |
78 | ee86dfee | David Gibson | VIOsPAPR_RTCE *rtce_table; |
79 | 0f5cb298 | David Gibson | int kvmtce_fd;
|
80 | b45d63b6 | Ben Herrenschmidt | VIOsPAPR_CRQ crq; |
81 | 3954d33a | Anthony Liguori | }; |
82 | 4040ab72 | David Gibson | |
83 | d601fac4 | David Gibson | #define DEFINE_SPAPR_PROPERTIES(type, field, default_dma_window) \
|
84 | d601fac4 | David Gibson | DEFINE_PROP_UINT32("reg", type, field.reg, -1), \ |
85 | 77c7ea5e | Paolo Bonzini | DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \
|
86 | 77c7ea5e | Paolo Bonzini | default_dma_window) |
87 | 77c7ea5e | Paolo Bonzini | |
88 | 3954d33a | Anthony Liguori | struct VIOsPAPRBus {
|
89 | 4040ab72 | David Gibson | BusState bus; |
90 | d601fac4 | David Gibson | uint32_t next_reg; |
91 | 4040ab72 | David Gibson | int (*init)(VIOsPAPRDevice *dev);
|
92 | 4040ab72 | David Gibson | int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); |
93 | 3954d33a | Anthony Liguori | }; |
94 | 4040ab72 | David Gibson | |
95 | 4040ab72 | David Gibson | extern VIOsPAPRBus *spapr_vio_bus_init(void); |
96 | 4040ab72 | David Gibson | extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
|
97 | 4040ab72 | David Gibson | extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt); |
98 | 68f3a94c | David Gibson | extern int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus); |
99 | 4040ab72 | David Gibson | |
100 | 00dc738d | David Gibson | extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode); |
101 | 00dc738d | David Gibson | |
102 | ee86dfee | David Gibson | int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
|
103 | ee86dfee | David Gibson | target_ulong len, |
104 | ee86dfee | David Gibson | enum VIOsPAPR_TCEAccess access);
|
105 | ee86dfee | David Gibson | |
106 | ee86dfee | David Gibson | int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
|
107 | ee86dfee | David Gibson | void *buf, uint32_t size);
|
108 | ee86dfee | David Gibson | int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
|
109 | ee86dfee | David Gibson | const void *buf, uint32_t size); |
110 | ee86dfee | David Gibson | int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size);
|
111 | ee86dfee | David Gibson | void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val);
|
112 | ee86dfee | David Gibson | void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val);
|
113 | ee86dfee | David Gibson | void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val);
|
114 | ee86dfee | David Gibson | void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val);
|
115 | ee86dfee | David Gibson | uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr); |
116 | ee86dfee | David Gibson | |
117 | b45d63b6 | Ben Herrenschmidt | int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
|
118 | b45d63b6 | Ben Herrenschmidt | |
119 | 5f2e2ba2 | David Gibson | VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg); |
120 | 4040ab72 | David Gibson | void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len); |
121 | d601fac4 | David Gibson | void spapr_vty_create(VIOsPAPRBus *bus, CharDriverState *chardev);
|
122 | d601fac4 | David Gibson | void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd);
|
123 | d601fac4 | David Gibson | void spapr_vscsi_create(VIOsPAPRBus *bus);
|
124 | 6e270446 | Ben Herrenschmidt | |
125 | 68f3a94c | David Gibson | VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus); |
126 | 68f3a94c | David Gibson | |
127 | 08942ac1 | Ben Herrenschmidt | int spapr_tce_set_bypass(uint32_t unit, uint32_t enable);
|
128 | 08942ac1 | Ben Herrenschmidt | void spapr_vio_quiesce(void); |
129 | 08942ac1 | Ben Herrenschmidt | |
130 | 4040ab72 | David Gibson | #endif /* _HW_SPAPR_VIO_H */ |