David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 1 | #ifndef _HW_SPAPR_VIO_H |
| 2 | #define _HW_SPAPR_VIO_H |
| 3 | /* |
| 4 | * QEMU sPAPR VIO bus definitions |
| 5 | * |
| 6 | * Copyright (c) 2010 David Gibson, IBM Corporation <david@gibson.dropbear.id.au> |
| 7 | * Based on the s390 virtio bus definitions: |
| 8 | * Copyright (c) 2009 Alexander Graf <agraf@suse.de> |
| 9 | * |
| 10 | * This library is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU Lesser General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This library is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 22 | */ |
| 23 | |
David Gibson | ee86dfe | 2011-04-01 15:15:28 +1100 | [diff] [blame] | 24 | #define SPAPR_VIO_TCE_PAGE_SHIFT 12 |
| 25 | #define SPAPR_VIO_TCE_PAGE_SIZE (1ULL << SPAPR_VIO_TCE_PAGE_SHIFT) |
| 26 | #define SPAPR_VIO_TCE_PAGE_MASK (SPAPR_VIO_TCE_PAGE_SIZE - 1) |
| 27 | |
| 28 | enum VIOsPAPR_TCEAccess { |
| 29 | SPAPR_TCE_FAULT = 0, |
| 30 | SPAPR_TCE_RO = 1, |
| 31 | SPAPR_TCE_WO = 2, |
| 32 | SPAPR_TCE_RW = 3, |
| 33 | }; |
| 34 | |
David Gibson | b4a7852 | 2011-04-19 11:54:52 +1000 | [diff] [blame] | 35 | #define SPAPR_VTY_BASE_ADDRESS 0x30000000 |
| 36 | |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 37 | struct VIOsPAPRDevice; |
| 38 | |
David Gibson | ee86dfe | 2011-04-01 15:15:28 +1100 | [diff] [blame] | 39 | typedef struct VIOsPAPR_RTCE { |
| 40 | uint64_t tce; |
| 41 | } VIOsPAPR_RTCE; |
| 42 | |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 43 | typedef struct VIOsPAPR_CRQ { |
| 44 | uint64_t qladdr; |
| 45 | uint32_t qsize; |
| 46 | uint32_t qnext; |
| 47 | int(*SendFunc)(struct VIOsPAPRDevice *vdev, uint8_t *crq); |
| 48 | } VIOsPAPR_CRQ; |
| 49 | |
David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 50 | typedef struct VIOsPAPRDevice { |
| 51 | DeviceState qdev; |
| 52 | uint32_t reg; |
Ben Herrenschmidt | 08942ac | 2011-04-01 15:15:32 +1100 | [diff] [blame] | 53 | uint32_t flags; |
| 54 | #define VIO_PAPR_FLAG_DMA_BYPASS 0x1 |
David Gibson | 00dc738 | 2011-04-01 15:15:26 +1100 | [diff] [blame] | 55 | qemu_irq qirq; |
| 56 | uint32_t vio_irq_num; |
| 57 | target_ulong signal_state; |
David Gibson | ee86dfe | 2011-04-01 15:15:28 +1100 | [diff] [blame] | 58 | uint32_t rtce_window_size; |
| 59 | VIOsPAPR_RTCE *rtce_table; |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 60 | VIOsPAPR_CRQ crq; |
David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 61 | } VIOsPAPRDevice; |
| 62 | |
| 63 | typedef struct VIOsPAPRBus { |
| 64 | BusState bus; |
| 65 | } VIOsPAPRBus; |
| 66 | |
| 67 | typedef struct { |
| 68 | DeviceInfo qdev; |
| 69 | const char *dt_name, *dt_type, *dt_compatible; |
David Gibson | 00dc738 | 2011-04-01 15:15:26 +1100 | [diff] [blame] | 70 | target_ulong signal_mask; |
David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 71 | int (*init)(VIOsPAPRDevice *dev); |
| 72 | void (*hcalls)(VIOsPAPRBus *bus); |
| 73 | int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); |
| 74 | } VIOsPAPRDeviceInfo; |
| 75 | |
| 76 | extern VIOsPAPRBus *spapr_vio_bus_init(void); |
| 77 | extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg); |
| 78 | extern void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info); |
| 79 | extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt); |
| 80 | |
David Gibson | 00dc738 | 2011-04-01 15:15:26 +1100 | [diff] [blame] | 81 | extern int spapr_vio_signal(VIOsPAPRDevice *dev, target_ulong mode); |
| 82 | |
David Gibson | ee86dfe | 2011-04-01 15:15:28 +1100 | [diff] [blame] | 83 | int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba, |
| 84 | target_ulong len, |
| 85 | enum VIOsPAPR_TCEAccess access); |
| 86 | |
| 87 | int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr, |
| 88 | void *buf, uint32_t size); |
| 89 | int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr, |
| 90 | const void *buf, uint32_t size); |
| 91 | int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t size); |
| 92 | void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val); |
| 93 | void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val); |
| 94 | void stw_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint32_t val); |
| 95 | void stq_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint64_t val); |
| 96 | uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr); |
| 97 | |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 98 | int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq); |
| 99 | |
David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 100 | void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len); |
| 101 | void spapr_vty_create(VIOsPAPRBus *bus, |
David Gibson | 0201e2d | 2011-04-01 15:15:27 +1100 | [diff] [blame] | 102 | uint32_t reg, CharDriverState *chardev, |
| 103 | qemu_irq qirq, uint32_t vio_irq_num); |
David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 104 | |
David Gibson | 8d90ad9 | 2011-04-01 15:15:29 +1100 | [diff] [blame] | 105 | void spapr_vlan_create(VIOsPAPRBus *bus, uint32_t reg, NICInfo *nd, |
| 106 | qemu_irq qirq, uint32_t vio_irq_num); |
| 107 | |
Ben Herrenschmidt | 6e27044 | 2011-04-01 15:15:31 +1100 | [diff] [blame] | 108 | void spapr_vscsi_create(VIOsPAPRBus *bus, uint32_t reg, |
| 109 | qemu_irq qirq, uint32_t vio_irq_num); |
| 110 | |
Ben Herrenschmidt | 08942ac | 2011-04-01 15:15:32 +1100 | [diff] [blame] | 111 | int spapr_tce_set_bypass(uint32_t unit, uint32_t enable); |
| 112 | void spapr_vio_quiesce(void); |
| 113 | |
David Gibson | 4040ab7 | 2011-04-01 15:15:21 +1100 | [diff] [blame] | 114 | #endif /* _HW_SPAPR_VIO_H */ |