Module Name: src Committed By: pooka Date: Fri Aug 22 14:28:58 UTC 2014
Modified Files: src/sys/rump/dev/lib/libpci: Makefile pci_at_mainbus.c rumpdev_bus_space.c Log Message: Add a compile-time selector for I/O space operations. Needs more work some day, but allows virtio drivers to work today. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/rump/dev/lib/libpci/Makefile cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/libpci/pci_at_mainbus.c cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/dev/lib/libpci/Makefile diff -u src/sys/rump/dev/lib/libpci/Makefile:1.3 src/sys/rump/dev/lib/libpci/Makefile:1.4 --- src/sys/rump/dev/lib/libpci/Makefile:1.3 Mon Apr 14 23:53:42 2014 +++ src/sys/rump/dev/lib/libpci/Makefile Fri Aug 22 14:28:58 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2014/04/14 23:53:42 pooka Exp $ +# $NetBSD: Makefile,v 1.4 2014/08/22 14:28:58 pooka Exp $ # RUMPTOP= ${TOPRUMP} @@ -23,6 +23,10 @@ SRCS+= pci_at_mainbus.c CPPFLAGS+= -I${.CURDIR}/opt -I${RUMPTOP}/librump/rumpkern CPPFLAGS+= -I${RUMPTOP}/librump/rumpvfs +.if ${RUMP_PCI_IOSPACE:Uno} == "yes" +CPPFLAGS+=-DRUMP_PCI_IOSPACE +.endif + .if defined(RUMP_PCI_USER) RUMPCOMP_USER_SRCS= ${RUMP_PCI_USER} RUMPCOMP_INCS_DIR:= ${.PARSEDIR} Index: src/sys/rump/dev/lib/libpci/pci_at_mainbus.c diff -u src/sys/rump/dev/lib/libpci/pci_at_mainbus.c:1.4 src/sys/rump/dev/lib/libpci/pci_at_mainbus.c:1.5 --- src/sys/rump/dev/lib/libpci/pci_at_mainbus.c:1.4 Thu Jul 31 15:55:08 2014 +++ src/sys/rump/dev/lib/libpci/pci_at_mainbus.c Fri Aug 22 14:28:58 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_at_mainbus.c,v 1.4 2014/07/31 15:55:08 pooka Exp $ */ +/* $NetBSD: pci_at_mainbus.c,v 1.5 2014/08/22 14:28:58 pooka Exp $ */ /* * Copyright (c) 2010 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_at_mainbus.c,v 1.4 2014/07/31 15:55:08 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_at_mainbus.c,v 1.5 2014/08/22 14:28:58 pooka Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -80,7 +80,7 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV_AFTERM #endif pba.pba_flags = PCI_FLAGS_MEM_OKAY | PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;; -#if 0 +#ifdef RUMP_PCI_IOSPACE pba.pba_flags |= PCI_FLAGS_IO_OKAY; #endif Index: src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c diff -u src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c:1.2 src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c:1.3 --- src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c:1.2 Sun Apr 13 15:43:26 2014 +++ src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c Fri Aug 22 14:28:58 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpdev_bus_space.c,v 1.2 2014/04/13 15:43:26 pooka Exp $ */ +/* $NetBSD: rumpdev_bus_space.c,v 1.3 2014/08/22 14:28:58 pooka Exp $ */ /*- * Copyright (c) 2013 Antti Kantee. All Rights Reserved. @@ -34,6 +34,10 @@ #include "pci_user.h" +#if defined(RUMP_PCI_IOSPACE) && (defined(__i386__) || defined(__x86_64__)) +#define IOSPACE_SUPPORTED +#endif + int bus_space_map(bus_space_tag_t bst, bus_addr_t address, bus_size_t size, int flags, bus_space_handle_t *handlep) @@ -48,8 +52,12 @@ bus_space_map(bus_space_tag_t bst, bus_a * make a hypercall to request it. */ if (bst == 0) { +#ifdef IOSPACE_SUPPORTED *handlep = address; rv = 0; +#else + rv = ENOTSUP; +#endif } else { *handlep = (bus_space_handle_t)rumpcomp_pci_map(address, size); rv = *handlep ? 0 : EINVAL; @@ -65,7 +73,12 @@ bus_space_read_1(bus_space_tag_t bst, bu uint8_t rv; if (bst == 0) { - panic("8bit IO space not supported"); +#ifdef IOSPACE_SUPPORTED + unsigned short addr = bsh + offset; + __asm__ __volatile__("inb %1, %0" : "=a"(rv) : "d"(addr)); +#else + panic("IO space not supported"); +#endif } else { rv = *(volatile uint8_t *)(bsh + offset); } @@ -80,7 +93,12 @@ bus_space_read_2(bus_space_tag_t bst, bu uint16_t rv; if (bst == 0) { - panic("16bit IO space not supported"); +#ifdef IOSPACE_SUPPORTED + unsigned short addr = bsh + offset; + __asm__ __volatile__("in %1, %0" : "=a"(rv) : "d"(addr)); +#else + panic("IO space not supported"); +#endif } else { rv = *(volatile uint16_t *)(bsh + offset); } @@ -95,11 +113,11 @@ bus_space_read_4(bus_space_tag_t bst, bu uint32_t rv; if (bst == 0) { -#if 1 - panic("IO space not supported in this build"); -#else +#ifdef IOSPACE_SUPPORTED unsigned short addr = bsh + offset; __asm__ __volatile__("inl %1, %0" : "=a"(rv) : "d"(addr)); +#else + panic("IO space not supported"); #endif } else { rv = *(volatile uint32_t *)(bsh + offset); @@ -114,8 +132,11 @@ bus_space_write_1(bus_space_tag_t bst, b { if (bst == 0) { -#if 1 - panic("IO space not supported in this build"); +#ifdef IOSPACE_SUPPORTED + unsigned short addr = bsh + offset; + __asm__ __volatile__("outb %0, %1" :: "a"(v), "d"(addr)); +#else + panic("IO space not supported"); #endif } else { *(volatile uint8_t *)(bsh + offset) = v; @@ -128,8 +149,11 @@ bus_space_write_2(bus_space_tag_t bst, b { if (bst == 0) { -#if 1 - panic("IO space not supported in this build"); +#ifdef IOSPACE_SUPPORTED + unsigned short addr = bsh + offset; + __asm__ __volatile__("out %0, %1" :: "a"(v), "d"(addr)); +#else + panic("IO space not supported"); #endif } else { *(volatile uint16_t *)(bsh + offset) = v; @@ -142,11 +166,11 @@ bus_space_write_4(bus_space_tag_t bst, b { if (bst == 0) { -#if 1 - panic("IO space not supported in this build"); -#else +#ifdef IOSPACE_SUPPORTED unsigned short addr = bsh + offset; __asm__ __volatile__("outl %0, %1" :: "a"(v), "d"(addr)); +#else + panic("IO space not supported"); #endif } else { *(volatile uint32_t *)(bsh + offset) = v;