Statistics
| Branch: | Revision:

root / hw / spapr_vio.h @ 2b8b3bb9

History | View | Annotate | Download (3.9 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 b45d63b6 Ben Herrenschmidt
    VIOsPAPR_CRQ crq;
61 4040ab72 David Gibson
} VIOsPAPRDevice;
62 4040ab72 David Gibson
63 4040ab72 David Gibson
typedef struct VIOsPAPRBus {
64 4040ab72 David Gibson
    BusState bus;
65 4040ab72 David Gibson
} VIOsPAPRBus;
66 4040ab72 David Gibson
67 4040ab72 David Gibson
typedef struct {
68 4040ab72 David Gibson
    DeviceInfo qdev;
69 4040ab72 David Gibson
    const char *dt_name, *dt_type, *dt_compatible;
70 00dc738d David Gibson
    target_ulong signal_mask;
71 4040ab72 David Gibson
    int (*init)(VIOsPAPRDevice *dev);
72 4040ab72 David Gibson
    void (*hcalls)(VIOsPAPRBus *bus);
73 4040ab72 David Gibson
    int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off);
74 4040ab72 David Gibson
} VIOsPAPRDeviceInfo;
75 4040ab72 David Gibson
76 4040ab72 David Gibson
extern VIOsPAPRBus *spapr_vio_bus_init(void);
77 4040ab72 David Gibson
extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg);
78 4040ab72 David Gibson
extern void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info);
79 4040ab72 David Gibson
extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt);
80 4040ab72 David Gibson
81 00dc738d David Gibson
extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode);
82 00dc738d David Gibson
83 ee86dfee David Gibson
int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
84 ee86dfee David Gibson
                         target_ulong len,
85 ee86dfee David Gibson
                         enum VIOsPAPR_TCEAccess access);
86 ee86dfee David Gibson
87 ee86dfee David Gibson
int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr,
88 ee86dfee David Gibson
                       void *buf, uint32_t size);
89 ee86dfee David Gibson
int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr,
90 ee86dfee David Gibson
                        const void *buf, uint32_t size);
91 ee86dfee David Gibson
int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size);
92 ee86dfee David Gibson
void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val);
93 ee86dfee David Gibson
void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val);
94 ee86dfee David Gibson
void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val);
95 ee86dfee David Gibson
void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val);
96 ee86dfee David Gibson
uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr);
97 ee86dfee David Gibson
98 b45d63b6 Ben Herrenschmidt
int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq);
99 b45d63b6 Ben Herrenschmidt
100 4040ab72 David Gibson
void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len);
101 4040ab72 David Gibson
void spapr_vty_create(VIOsPAPRBus *bus,
102 0201e2da David Gibson
                      uint32_t reg, CharDriverState *chardev,
103 0201e2da David Gibson
                      qemu_irq qirq, uint32_t vio_irq_num);
104 4040ab72 David Gibson
105 8d90ad90 David Gibson
void spapr_vlan_create(VIOsPAPRBus *bus, uint32_t reg, NICInfo *nd,
106 8d90ad90 David Gibson
                       qemu_irq qirq, uint32_t vio_irq_num);
107 8d90ad90 David Gibson
108 6e270446 Ben Herrenschmidt
void spapr_vscsi_create(VIOsPAPRBus *bus, uint32_t reg,
109 6e270446 Ben Herrenschmidt
                        qemu_irq qirq, uint32_t vio_irq_num);
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 */