Statistics
| Branch: | Revision:

root / hw / spapr_vio.h @ 5844997a

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