Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/dev/lib/libpci Add a compile-time selector for I/O ...
details: https://anonhg.NetBSD.org/src/rev/6b481404edf0
branches: trunk
changeset: 331739:6b481404edf0
user: pooka <pooka%NetBSD.org@localhost>
date: Fri Aug 22 14:28:58 2014 +0000
description:
Add a compile-time selector for I/O space operations. Needs more work
some day, but allows virtio drivers to work today.
diffstat:
sys/rump/dev/lib/libpci/Makefile | 6 ++-
sys/rump/dev/lib/libpci/pci_at_mainbus.c | 6 +-
sys/rump/dev/lib/libpci/rumpdev_bus_space.c | 50 +++++++++++++++++++++-------
3 files changed, 45 insertions(+), 17 deletions(-)
diffs (166 lines):
diff -r e5aba1791e90 -r 6b481404edf0 sys/rump/dev/lib/libpci/Makefile
--- a/sys/rump/dev/lib/libpci/Makefile Fri Aug 22 11:34:28 2014 +0000
+++ b/sys/rump/dev/lib/libpci/Makefile Fri Aug 22 14:28:58 2014 +0000
@@ -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 @@
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}
diff -r e5aba1791e90 -r 6b481404edf0 sys/rump/dev/lib/libpci/pci_at_mainbus.c
--- a/sys/rump/dev/lib/libpci/pci_at_mainbus.c Fri Aug 22 11:34:28 2014 +0000
+++ b/sys/rump/dev/lib/libpci/pci_at_mainbus.c Fri Aug 22 14:28:58 2014 +0000
@@ -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 @@
#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
diff -r e5aba1791e90 -r 6b481404edf0 sys/rump/dev/lib/libpci/rumpdev_bus_space.c
--- a/sys/rump/dev/lib/libpci/rumpdev_bus_space.c Fri Aug 22 11:34:28 2014 +0000
+++ b/sys/rump/dev/lib/libpci/rumpdev_bus_space.c Fri Aug 22 14:28:58 2014 +0000
@@ -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 @@
* 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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
{
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;
Home |
Main Index |
Thread Index |
Old Index