summaryrefslogtreecommitdiffstats
path: root/sys/x86/include/bus.h
diff options
context:
space:
mode:
authorjimharris <jimharris@FreeBSD.org>2012-12-13 21:40:11 +0000
committerjimharris <jimharris@FreeBSD.org>2012-12-13 21:40:11 +0000
commit49ec139f258e2a94685e330d52afa4e6eee4ee09 (patch)
tree7595669a90e038d7605151c2974795069b2a83eb /sys/x86/include/bus.h
parent5e7d94235a64f85da6072462c6458acd8210728f (diff)
downloadFreeBSD-src-49ec139f258e2a94685e330d52afa4e6eee4ee09.zip
FreeBSD-src-49ec139f258e2a94685e330d52afa4e6eee4ee09.tar.gz
Add bus_space_read_8 and bus_space_write_8 for amd64.
Rather than trying to KASSERT for callers that invoke this on IO tags, either do nothing (for write_8) or return ~0 (for read_8). Using KASSERT here just makes bus.h too messy from both polluting bus.h with systm.h (for any number of drivers that include bus.h without first including systm.h) or ports that use bus.h directly (i.e. libpciaccess) as reported by zeising@. Also don't try to implement all of the other bus_space functions for 8 byte access since realistically only these two are needed for some devices that expose 64-bit memory-mapped registers. Put the amd64-specific functions here rather than sys/amd64/include/bus.h so that we can keep this header unified for x86, as requested by mdf@ and tijl@. Submitted by: Carl Delsey <carl.r.delsey@intel.com> MFC after: 3 days
Diffstat (limited to 'sys/x86/include/bus.h')
-rw-r--r--sys/x86/include/bus.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/sys/x86/include/bus.h b/sys/x86/include/bus.h
index fb5babf..52c4251 100644
--- a/sys/x86/include/bus.h
+++ b/sys/x86/include/bus.h
@@ -130,6 +130,7 @@
#define BUS_SPACE_MAXADDR 0xFFFFFFFF
#endif
+#define BUS_SPACE_INVALID_DATA (~0)
#define BUS_SPACE_UNRESTRICTED (~0)
/*
@@ -221,6 +222,12 @@ static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
bus_space_handle_t handle,
bus_size_t offset);
+#ifdef __amd64__
+static __inline uint64_t bus_space_read_8(bus_space_tag_t tag,
+ bus_space_handle_t handle,
+ bus_size_t offset);
+#endif
+
static __inline u_int8_t
bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
bus_size_t offset)
@@ -251,8 +258,16 @@ bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
return (*(volatile u_int32_t *)(handle + offset));
}
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
+#ifdef __amd64__
+static __inline uint64_t
+bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
+ bus_size_t offset)
+{
+
+ if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */
+ return (BUS_SPACE_INVALID_DATA);
+ return (*(volatile uint64_t *)(handle + offset));
+}
#endif
/*
@@ -479,6 +494,12 @@ static __inline void bus_space_write_4(bus_space_tag_t tag,
bus_space_handle_t bsh,
bus_size_t offset, u_int32_t value);
+#ifdef __amd64__
+static __inline void bus_space_write_8(bus_space_tag_t tag,
+ bus_space_handle_t bsh,
+ bus_size_t offset, uint64_t value);
+#endif
+
static __inline void
bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
bus_size_t offset, u_int8_t value)
@@ -512,8 +533,17 @@ bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
*(volatile u_int32_t *)(bsh + offset) = value;
}
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
+#ifdef __amd64__
+static __inline void
+bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
+ bus_size_t offset, uint64_t value)
+{
+
+ if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */
+ return;
+ else
+ *(volatile uint64_t *)(bsh + offset) = value;
+}
#endif
/*
OpenPOWER on IntegriCloud