root / hw / spapr_vio.h @ da726e5e
History | View | Annotate | Download (4 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 | b4a78527 | David Gibson | #define SPAPR_VTY_BASE_ADDRESS 0x30000000 |
36 | b4a78527 | David Gibson | |
37 | b45d63b6 | Ben Herrenschmidt | struct VIOsPAPRDevice;
|
38 | b45d63b6 | Ben Herrenschmidt | |
39 | ee86dfee | David Gibson | typedef struct VIOsPAPR_RTCE { |
40 | ee86dfee | David Gibson | uint64_t tce; |
41 | ee86dfee | David Gibson | } VIOsPAPR_RTCE; |
42 | ee86dfee | David Gibson | |
43 | b45d63b6 | Ben Herrenschmidt | typedef struct VIOsPAPR_CRQ { |
44 | b45d63b6 | Ben Herrenschmidt | uint64_t qladdr; |
45 | b45d63b6 | Ben Herrenschmidt | uint32_t qsize; |
46 | b45d63b6 | Ben Herrenschmidt | uint32_t qnext; |
47 | b45d63b6 | Ben Herrenschmidt | int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq); |
48 | b45d63b6 | Ben Herrenschmidt | } VIOsPAPR_CRQ; |
49 | b45d63b6 | Ben Herrenschmidt | |
50 | 4040ab72 | David Gibson | typedef struct VIOsPAPRDevice { |
51 | 4040ab72 | David Gibson | DeviceState qdev; |
52 | 4040ab72 | David Gibson | uint32_t reg; |
53 | 08942ac1 | Ben Herrenschmidt | uint32_t flags; |
54 | 08942ac1 | Ben Herrenschmidt | #define VIO_PAPR_FLAG_DMA_BYPASS 0x1 |
55 | 00dc738d | David Gibson | qemu_irq qirq; |
56 | 00dc738d | David Gibson | uint32_t vio_irq_num; |
57 | 00dc738d | David Gibson | target_ulong signal_state; |
58 | ee86dfee | David Gibson | uint32_t rtce_window_size; |
59 | ee86dfee | David Gibson | VIOsPAPR_RTCE *rtce_table; |
60 | 0f5cb298 | David Gibson | int kvmtce_fd;
|
61 | b45d63b6 | Ben Herrenschmidt | VIOsPAPR_CRQ crq; |
62 | 4040ab72 | David Gibson | } VIOsPAPRDevice; |
63 | 4040ab72 | David Gibson | |
64 | 77c7ea5e | Paolo Bonzini | #define DEFINE_SPAPR_PROPERTIES(type, field, default_reg, default_dma_window) \
|
65 | 77c7ea5e | Paolo Bonzini | DEFINE_PROP_UINT32("reg", type, field.reg, default_reg), \
|
66 | 77c7ea5e | Paolo Bonzini | DEFINE_PROP_UINT32("dma-window", type, field.rtce_window_size, \
|
67 | 77c7ea5e | Paolo Bonzini | default_dma_window) |
68 | 77c7ea5e | Paolo Bonzini | |
69 | 4040ab72 | David Gibson | typedef struct VIOsPAPRBus { |
70 | 4040ab72 | David Gibson | BusState bus; |
71 | 4040ab72 | David Gibson | } VIOsPAPRBus; |
72 | 4040ab72 | David Gibson | |
73 | 4040ab72 | David Gibson | typedef struct { |
74 | 4040ab72 | David Gibson | DeviceInfo qdev; |
75 | 4040ab72 | David Gibson | const char *dt_name, *dt_type, *dt_compatible; |
76 | 00dc738d | David Gibson | target_ulong signal_mask; |
77 | 4040ab72 | David Gibson | int (*init)(VIOsPAPRDevice *dev);
|
78 | 4040ab72 | David Gibson | void (*hcalls)(VIOsPAPRBus *bus);
|
79 | 4040ab72 | David Gibson | int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); |
80 | 4040ab72 | David Gibson | } VIOsPAPRDeviceInfo; |
81 | 4040ab72 | David Gibson | |
82 | 4040ab72 | David Gibson | extern VIOsPAPRBus *spapr_vio_bus_init(void); |
83 | 4040ab72 | David Gibson | extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
|
84 | 4040ab72 | David Gibson | extern void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info); |
85 | 4040ab72 | David Gibson | extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt); |
86 | 4040ab72 | David Gibson | |
87 | 00dc738d | David Gibson | extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode); |
88 | 00dc738d | David Gibson | |
89 | ee86dfee | David Gibson | int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
|
90 | ee86dfee | David Gibson | target_ulong len, |
91 | ee86dfee | David Gibson | enum VIOsPAPR_TCEAccess access);
|
92 | ee86dfee | David Gibson | |
93 | ee86dfee | David Gibson | int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
|
94 | ee86dfee | David Gibson | void *buf, uint32_t size);
|
95 | ee86dfee | David Gibson | int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
|
96 | ee86dfee | David Gibson | const void *buf, uint32_t size); |
97 | ee86dfee | David Gibson | int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size);
|
98 | ee86dfee | David Gibson | void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val);
|
99 | ee86dfee | David Gibson | void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val);
|
100 | ee86dfee | David Gibson | void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val);
|
101 | ee86dfee | David Gibson | void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val);
|
102 | ee86dfee | David Gibson | uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr); |
103 | ee86dfee | David Gibson | |
104 | b45d63b6 | Ben Herrenschmidt | int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
|
105 | b45d63b6 | Ben Herrenschmidt | |
106 | 4040ab72 | David Gibson | void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len); |
107 | 277f9acf | Paolo Bonzini | void spapr_vty_create(VIOsPAPRBus *bus, uint32_t reg, CharDriverState *chardev);
|
108 | 277f9acf | Paolo Bonzini | void spapr_vlan_create(VIOsPAPRBus *bus, uint32_t reg, NICInfo *nd);
|
109 | 277f9acf | Paolo Bonzini | void spapr_vscsi_create(VIOsPAPRBus *bus, uint32_t reg);
|
110 | 6e270446 | Ben Herrenschmidt | |
111 | 08942ac1 | Ben Herrenschmidt | int spapr_tce_set_bypass(uint32_t unit, uint32_t enable);
|
112 | 08942ac1 | Ben Herrenschmidt | void spapr_vio_quiesce(void); |
113 | 08942ac1 | Ben Herrenschmidt | |
114 | 4040ab72 | David Gibson | #endif /* _HW_SPAPR_VIO_H */ |