Deleted Added
full compact
pci_xhci.c (320891) pci_xhci.c (336161)
1/*-
2 * Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26/*
27 XHCI options:
28 -s <n>,xhci,{devices}
29
30 devices:
31 tablet USB tablet mouse
32 */
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26/*
27 XHCI options:
28 -s <n>,xhci,{devices}
29
30 devices:
31 tablet USB tablet mouse
32 */
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/pci_xhci.c 320891 2017-07-11 06:39:12Z grehan $");
34__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/pci_xhci.c 336161 2018-07-10 04:26:32Z araujo $");
35
36#include <sys/param.h>
37#include <sys/uio.h>
38#include <sys/types.h>
39#include <sys/queue.h>
40
41#include <stdio.h>
42#include <stdlib.h>

--- 2162 unchanged lines hidden (view full) ---

2205static void
2206pci_xhci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
2207 int baridx, uint64_t offset, int size, uint64_t value)
2208{
2209 struct pci_xhci_softc *sc;
2210
2211 sc = pi->pi_arg;
2212
35
36#include <sys/param.h>
37#include <sys/uio.h>
38#include <sys/types.h>
39#include <sys/queue.h>
40
41#include <stdio.h>
42#include <stdlib.h>

--- 2162 unchanged lines hidden (view full) ---

2205static void
2206pci_xhci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
2207 int baridx, uint64_t offset, int size, uint64_t value)
2208{
2209 struct pci_xhci_softc *sc;
2210
2211 sc = pi->pi_arg;
2212
2213 assert(baridx == 0);
2213 assert(baridx == 0);
2214
2215
2214
2215
2216 pthread_mutex_lock(&sc->mtx);
2216 pthread_mutex_lock(&sc->mtx);
2217 if (offset < XHCI_CAPLEN) /* read only registers */
2217 if (offset < XHCI_CAPLEN) /* read only registers */
2218 WPRINTF(("pci_xhci: write RO-CAPs offset %ld\r\n", offset));
2218 WPRINTF(("pci_xhci: write RO-CAPs offset %ld\r\n", offset));
2219 else if (offset < sc->dboff)
2220 pci_xhci_hostop_write(sc, offset, value);
2221 else if (offset < sc->rtsoff)
2222 pci_xhci_dbregs_write(sc, offset, value);
2223 else if (offset < sc->regsend)
2224 pci_xhci_rtsregs_write(sc, offset, value);
2225 else
2219 else if (offset < sc->dboff)
2220 pci_xhci_hostop_write(sc, offset, value);
2221 else if (offset < sc->rtsoff)
2222 pci_xhci_dbregs_write(sc, offset, value);
2223 else if (offset < sc->regsend)
2224 pci_xhci_rtsregs_write(sc, offset, value);
2225 else
2226 WPRINTF(("pci_xhci: write invalid offset %ld\r\n", offset));
2226 WPRINTF(("pci_xhci: write invalid offset %ld\r\n", offset));
2227
2227
2228 pthread_mutex_unlock(&sc->mtx);
2228 pthread_mutex_unlock(&sc->mtx);
2229}
2230
2231static uint64_t
2232pci_xhci_hostcap_read(struct pci_xhci_softc *sc, uint64_t offset)
2233{
2234 uint64_t value;
2235
2236 switch (offset) {

--- 191 unchanged lines hidden (view full) ---

2428pci_xhci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
2429 uint64_t offset, int size)
2430{
2431 struct pci_xhci_softc *sc;
2432 uint32_t value;
2433
2434 sc = pi->pi_arg;
2435
2229}
2230
2231static uint64_t
2232pci_xhci_hostcap_read(struct pci_xhci_softc *sc, uint64_t offset)
2233{
2234 uint64_t value;
2235
2236 switch (offset) {

--- 191 unchanged lines hidden (view full) ---

2428pci_xhci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
2429 uint64_t offset, int size)
2430{
2431 struct pci_xhci_softc *sc;
2432 uint32_t value;
2433
2434 sc = pi->pi_arg;
2435
2436 assert(baridx == 0);
2436 assert(baridx == 0);
2437
2437
2438 pthread_mutex_lock(&sc->mtx);
2438 pthread_mutex_lock(&sc->mtx);
2439 if (offset < XHCI_CAPLEN)
2440 value = pci_xhci_hostcap_read(sc, offset);
2441 else if (offset < sc->dboff)
2442 value = pci_xhci_hostop_read(sc, offset);
2443 else if (offset < sc->rtsoff)
2444 value = pci_xhci_dbregs_read(sc, offset);
2445 else if (offset < sc->regsend)
2446 value = pci_xhci_rtsregs_read(sc, offset);
2447 else if (offset < (sc->regsend + 4*32))
2448 value = pci_xhci_xecp_read(sc, offset);
2449 else {
2450 value = 0;
2439 if (offset < XHCI_CAPLEN)
2440 value = pci_xhci_hostcap_read(sc, offset);
2441 else if (offset < sc->dboff)
2442 value = pci_xhci_hostop_read(sc, offset);
2443 else if (offset < sc->rtsoff)
2444 value = pci_xhci_dbregs_read(sc, offset);
2445 else if (offset < sc->regsend)
2446 value = pci_xhci_rtsregs_read(sc, offset);
2447 else if (offset < (sc->regsend + 4*32))
2448 value = pci_xhci_xecp_read(sc, offset);
2449 else {
2450 value = 0;
2451 WPRINTF(("pci_xhci: read invalid offset %ld\r\n", offset));
2451 WPRINTF(("pci_xhci: read invalid offset %ld\r\n", offset));
2452 }
2453
2452 }
2453
2454 pthread_mutex_unlock(&sc->mtx);
2454 pthread_mutex_unlock(&sc->mtx);
2455
2456 switch (size) {
2457 case 1:
2458 value &= 0xFF;
2459 break;
2460 case 2:
2461 value &= 0xFFFF;
2462 break;

--- 372 unchanged lines hidden ---
2455
2456 switch (size) {
2457 case 1:
2458 value &= 0xFF;
2459 break;
2460 case 2:
2461 value &= 0xFFFF;
2462 break;

--- 372 unchanged lines hidden ---