virtio_mmio_platform.c (274714) | virtio_mmio_platform.c (275647) |
---|---|
1/*- 2 * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 22 unchanged lines hidden (view full) --- 31/* 32 * BERI interface for Virtio MMIO bus. 33 * 34 * This driver provides interrupt-engine for software-implemented 35 * Virtio MMIO backend. 36 */ 37 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 22 unchanged lines hidden (view full) --- 31/* 32 * BERI interface for Virtio MMIO bus. 33 * 34 * This driver provides interrupt-engine for software-implemented 35 * Virtio MMIO backend. 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/dev/beri/virtio/virtio_mmio_platform.c 274714 2014-11-19 14:49:29Z br $"); | 39__FBSDID("$FreeBSD: head/sys/dev/beri/virtio/virtio_mmio_platform.c 275647 2014-12-09 16:39:21Z br $"); |
40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/bus.h> 44#include <sys/kernel.h> 45#include <sys/module.h> 46#include <sys/malloc.h> 47#include <sys/rman.h> --- 96 unchanged lines hidden (view full) --- 144 fic->iph = node; 145 fic->dev = dev; 146 SLIST_INSERT_HEAD(&fdt_ic_list_head, fic, fdt_ics); 147 148 return (0); 149} 150 151static int | 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/bus.h> 44#include <sys/kernel.h> 45#include <sys/module.h> 46#include <sys/malloc.h> 47#include <sys/rman.h> --- 96 unchanged lines hidden (view full) --- 144 fic->iph = node; 145 fic->dev = dev; 146 SLIST_INSERT_HEAD(&fdt_ic_list_head, fic, fdt_ics); 147 148 return (0); 149} 150 151static int |
152platform_note(device_t dev, size_t offset) | 152platform_note(device_t dev, size_t offset, int val) |
153{ 154 struct virtio_mmio_platform_softc *sc; | 153{ 154 struct virtio_mmio_platform_softc *sc; |
155 int note; 156 int i; |
|
155 156 sc = device_get_softc(dev); 157 | 157 158 sc = device_get_softc(dev); 159 |
158 if (offset == VIRTIO_MMIO_QUEUE_NOTIFY) { 159 mips_dcache_wbinv_all(); 160 PIO_SET(sc->pio_send, Q_NOTIFY, 1); | 160 switch (offset) { 161 case (VIRTIO_MMIO_QUEUE_NOTIFY): 162 if (val == 0) 163 note = Q_NOTIFY; 164 else if (val == 1) 165 note = Q_NOTIFY1; 166 break; 167 case (VIRTIO_MMIO_QUEUE_PFN): 168 note = Q_PFN; 169 break; 170 case (VIRTIO_MMIO_QUEUE_SEL): 171 note = Q_SEL; 172 break; 173 default: 174 note = 0; |
161 } 162 | 175 } 176 |
163 if (offset == VIRTIO_MMIO_QUEUE_PFN) { | 177 if (note) { |
164 mips_dcache_wbinv_all(); | 178 mips_dcache_wbinv_all(); |
165 PIO_SET(sc->pio_send, Q_PFN, 1); | 179 180 PIO_SET(sc->pio_send, note, 1); 181 182 /* 183 * Wait until host ack the request. 184 * Usually done within few cycles. 185 * TODO: bad 186 */ 187 188 for (i = 100; i > 0; i--) { 189 if (PIO_READ(sc->pio_send) == 0) 190 break; 191 } 192 193 if (i == 0) 194 device_printf(sc->dev, "Warning: host busy\n"); |
166 } 167 168 return (0); 169} 170 171static void 172platform_intr(void *arg) 173{ --- 54 unchanged lines hidden --- | 195 } 196 197 return (0); 198} 199 200static void 201platform_intr(void *arg) 202{ --- 54 unchanged lines hidden --- |