root / hw / spapr_vio.h @ d5aea6f3
History | View | Annotate | Download (4.7 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 | 9c17d615 | Paolo Bonzini | #include "sysemu/dma.h" |
25 | ee86dfee | David Gibson | |
26 | 3954d33a | Anthony Liguori | #define TYPE_VIO_SPAPR_DEVICE "vio-spapr-device" |
27 | 3954d33a | Anthony Liguori | #define VIO_SPAPR_DEVICE(obj) \
|
28 | 3954d33a | Anthony Liguori | OBJECT_CHECK(VIOsPAPRDevice, (obj), TYPE_VIO_SPAPR_DEVICE) |
29 | 3954d33a | Anthony Liguori | #define VIO_SPAPR_DEVICE_CLASS(klass) \
|
30 | 3954d33a | Anthony Liguori | OBJECT_CLASS_CHECK(VIOsPAPRDeviceClass, (klass), TYPE_VIO_SPAPR_DEVICE) |
31 | 3954d33a | Anthony Liguori | #define VIO_SPAPR_DEVICE_GET_CLASS(obj) \
|
32 | 3954d33a | Anthony Liguori | OBJECT_GET_CLASS(VIOsPAPRDeviceClass, (obj), TYPE_VIO_SPAPR_DEVICE) |
33 | 3954d33a | Anthony Liguori | |
34 | 0d936928 | Anthony Liguori | #define TYPE_SPAPR_VIO_BUS "spapr-vio-bus" |
35 | 0d936928 | Anthony Liguori | #define SPAPR_VIO_BUS(obj) OBJECT_CHECK(VIOsPAPRBus, (obj), TYPE_SPAPR_VIO_BUS)
|
36 | 0d936928 | Anthony Liguori | |
37 | b45d63b6 | Ben Herrenschmidt | struct VIOsPAPRDevice;
|
38 | b45d63b6 | Ben Herrenschmidt | |
39 | b45d63b6 | Ben Herrenschmidt | typedef struct VIOsPAPR_CRQ { |
40 | b45d63b6 | Ben Herrenschmidt | uint64_t qladdr; |
41 | b45d63b6 | Ben Herrenschmidt | uint32_t qsize; |
42 | b45d63b6 | Ben Herrenschmidt | uint32_t qnext; |
43 | b45d63b6 | Ben Herrenschmidt | int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq); |
44 | b45d63b6 | Ben Herrenschmidt | } VIOsPAPR_CRQ; |
45 | b45d63b6 | Ben Herrenschmidt | |
46 | 3954d33a | Anthony Liguori | typedef struct VIOsPAPRDevice VIOsPAPRDevice; |
47 | 3954d33a | Anthony Liguori | typedef struct VIOsPAPRBus VIOsPAPRBus; |
48 | 3954d33a | Anthony Liguori | |
49 | 3954d33a | Anthony Liguori | typedef struct VIOsPAPRDeviceClass { |
50 | 3954d33a | Anthony Liguori | DeviceClass parent_class; |
51 | 3954d33a | Anthony Liguori | |
52 | 3954d33a | Anthony Liguori | const char *dt_name, *dt_type, *dt_compatible; |
53 | 3954d33a | Anthony Liguori | target_ulong signal_mask; |
54 | ad0ebb91 | David Gibson | uint32_t rtce_window_size; |
55 | 3954d33a | Anthony Liguori | int (*init)(VIOsPAPRDevice *dev);
|
56 | b1c7f725 | David Gibson | void (*reset)(VIOsPAPRDevice *dev);
|
57 | 3954d33a | Anthony Liguori | int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); |
58 | 3954d33a | Anthony Liguori | } VIOsPAPRDeviceClass; |
59 | 3954d33a | Anthony Liguori | |
60 | 3954d33a | Anthony Liguori | struct VIOsPAPRDevice {
|
61 | 4040ab72 | David Gibson | DeviceState qdev; |
62 | 4040ab72 | David Gibson | uint32_t reg; |
63 | a307d594 | Alexey Kardashevskiy | uint32_t irq; |
64 | 00dc738d | David Gibson | target_ulong signal_state; |
65 | b45d63b6 | Ben Herrenschmidt | VIOsPAPR_CRQ crq; |
66 | ad0ebb91 | David Gibson | DMAContext *dma; |
67 | 3954d33a | Anthony Liguori | }; |
68 | 4040ab72 | David Gibson | |
69 | ad0ebb91 | David Gibson | #define DEFINE_SPAPR_PROPERTIES(type, field) \
|
70 | ad0ebb91 | David Gibson | DEFINE_PROP_UINT32("reg", type, field.reg, -1) |
71 | 77c7ea5e | Paolo Bonzini | |
72 | 3954d33a | Anthony Liguori | struct VIOsPAPRBus {
|
73 | 4040ab72 | David Gibson | BusState bus; |
74 | d601fac4 | David Gibson | uint32_t next_reg; |
75 | 4040ab72 | David Gibson | int (*init)(VIOsPAPRDevice *dev);
|
76 | 4040ab72 | David Gibson | int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); |
77 | 3954d33a | Anthony Liguori | }; |
78 | 4040ab72 | David Gibson | |
79 | 4040ab72 | David Gibson | extern VIOsPAPRBus *spapr_vio_bus_init(void); |
80 | 4040ab72 | David Gibson | extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
|
81 | 4040ab72 | David Gibson | extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt); |
82 | 68f3a94c | David Gibson | extern int spapr_populate_chosen_stdout(void *fdt, VIOsPAPRBus *bus); |
83 | 4040ab72 | David Gibson | |
84 | 00dc738d | David Gibson | extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode); |
85 | 00dc738d | David Gibson | |
86 | a307d594 | Alexey Kardashevskiy | static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev) |
87 | a307d594 | Alexey Kardashevskiy | { |
88 | a307d594 | Alexey Kardashevskiy | return xics_get_qirq(spapr->icp, dev->irq);
|
89 | a307d594 | Alexey Kardashevskiy | } |
90 | a307d594 | Alexey Kardashevskiy | |
91 | ad0ebb91 | David Gibson | static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr, |
92 | ad0ebb91 | David Gibson | uint32_t size, DMADirection dir) |
93 | ad0ebb91 | David Gibson | { |
94 | ad0ebb91 | David Gibson | return dma_memory_valid(dev->dma, taddr, size, dir);
|
95 | ad0ebb91 | David Gibson | } |
96 | ad0ebb91 | David Gibson | |
97 | ad0ebb91 | David Gibson | static inline int spapr_vio_dma_read(VIOsPAPRDevice *dev, uint64_t taddr, |
98 | ad0ebb91 | David Gibson | void *buf, uint32_t size)
|
99 | ad0ebb91 | David Gibson | { |
100 | ad0ebb91 | David Gibson | return (dma_memory_read(dev->dma, taddr, buf, size) != 0) ? |
101 | ad0ebb91 | David Gibson | H_DEST_PARM : H_SUCCESS; |
102 | ad0ebb91 | David Gibson | } |
103 | ad0ebb91 | David Gibson | |
104 | ad0ebb91 | David Gibson | static inline int spapr_vio_dma_write(VIOsPAPRDevice *dev, uint64_t taddr, |
105 | ad0ebb91 | David Gibson | const void *buf, uint32_t size) |
106 | ad0ebb91 | David Gibson | { |
107 | ad0ebb91 | David Gibson | return (dma_memory_write(dev->dma, taddr, buf, size) != 0) ? |
108 | ad0ebb91 | David Gibson | H_DEST_PARM : H_SUCCESS; |
109 | ad0ebb91 | David Gibson | } |
110 | ad0ebb91 | David Gibson | |
111 | ad0ebb91 | David Gibson | static inline int spapr_vio_dma_set(VIOsPAPRDevice *dev, uint64_t taddr, |
112 | ad0ebb91 | David Gibson | uint8_t c, uint32_t size) |
113 | ad0ebb91 | David Gibson | { |
114 | ad0ebb91 | David Gibson | return (dma_memory_set(dev->dma, taddr, c, size) != 0) ? |
115 | ad0ebb91 | David Gibson | H_DEST_PARM : H_SUCCESS; |
116 | ad0ebb91 | David Gibson | } |
117 | ad0ebb91 | David Gibson | |
118 | ad0ebb91 | David Gibson | #define vio_stb(_dev, _addr, _val) (stb_dma((_dev)->dma, (_addr), (_val)))
|
119 | ad0ebb91 | David Gibson | #define vio_sth(_dev, _addr, _val) (stw_be_dma((_dev)->dma, (_addr), (_val)))
|
120 | ad0ebb91 | David Gibson | #define vio_stl(_dev, _addr, _val) (stl_be_dma((_dev)->dma, (_addr), (_val)))
|
121 | ad0ebb91 | David Gibson | #define vio_stq(_dev, _addr, _val) (stq_be_dma((_dev)->dma, (_addr), (_val)))
|
122 | ad0ebb91 | David Gibson | #define vio_ldq(_dev, _addr) (ldq_be_dma((_dev)->dma, (_addr)))
|
123 | ee86dfee | David Gibson | |
124 | b45d63b6 | Ben Herrenschmidt | int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
|
125 | b45d63b6 | Ben Herrenschmidt | |
126 | 5f2e2ba2 | David Gibson | VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg); |
127 | 4040ab72 | David Gibson | void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len); |
128 | d601fac4 | David Gibson | void spapr_vty_create(VIOsPAPRBus *bus, CharDriverState *chardev);
|
129 | d601fac4 | David Gibson | void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd);
|
130 | d601fac4 | David Gibson | void spapr_vscsi_create(VIOsPAPRBus *bus);
|
131 | 6e270446 | Ben Herrenschmidt | |
132 | 68f3a94c | David Gibson | VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus); |
133 | 68f3a94c | David Gibson | |
134 | 08942ac1 | Ben Herrenschmidt | void spapr_vio_quiesce(void); |
135 | 08942ac1 | Ben Herrenschmidt | |
136 | 4040ab72 | David Gibson | #endif /* _HW_SPAPR_VIO_H */ |