aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/bus.h
diff options
context:
space:
mode:
authorMichal Meloun <mmel@FreeBSD.org>2020-09-19 11:06:41 +0000
committerMichal Meloun <mmel@FreeBSD.org>2020-09-19 11:06:41 +0000
commit95a85c125d0e6761eb56430e6679358ffab53624 (patch)
tree0bda2263180f6d956c2e6bf19f9fbb9a08744346 /sys/sys/bus.h
parent9a63bbc93e574d1f93c1583a5f51ae3bbace476a (diff)
downloadsrc-95a85c125d0e6761eb56430e6679358ffab53624.tar.gz
src-95a85c125d0e6761eb56430e6679358ffab53624.zip
Add NetBSD compatible bus_space_peek_N() and bus_space_poke_N() functions.
One problem with the bus_space_read_N() and bus_space_write_N() family of functions is that they provide no protection against exceptions which can occur when no physical hardware or device responds to the read or write cycles. In such a situation, the system typically would panic due to a kernel-mode bus error. The bus_space_peek_N() and bus_space_poke_N() family of functions provide a mechanism to handle these exceptions gracefully without the risk of crashing the system. Typical example is access to PCI(e) configuration space in bus enumeration function on badly implemented PCI(e) root complexes (RK3399 or Neoverse N1 N1SDP and/or access to PCI(e) register when device is in deep sleep state. This commit adds a real implementation for arm64 only. The remaining architectures have bus_space_peek()/bus_space_poke() emulated by using bus_space_read()/bus_space_write() (without exception handling). MFC after: 1 month Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D25371
Notes
Notes: svn path=/head/; revision=365899
Diffstat (limited to 'sys/sys/bus.h')
-rw-r--r--sys/sys/bus.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 6a286d0f9ef3..fbc69ca625c1 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -827,6 +827,10 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \
#define bus_barrier(r, o, l, f) \
bus_space_barrier((r)->r_bustag, (r)->r_bushandle, (o), (l), (f))
+#define bus_poke_1(r, o, v) \
+ bus_space_poke_1((r)->r_bustag, (r)->r_bushandle, (o), (v))
+#define bus_peek_1(r, o, vp) \
+ bus_space_peek_1((r)->r_bustag, (r)->r_bushandle, (o), (vp))
#define bus_read_1(r, o) \
bus_space_read_1((r)->r_bustag, (r)->r_bushandle, (o))
#define bus_read_multi_1(r, o, d, c) \
@@ -859,6 +863,10 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \
bus_space_write_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
#define bus_write_region_stream_1(r, o, d, c) \
bus_space_write_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
+#define bus_poke_2(r, o, v) \
+ bus_space_poke_2((r)->r_bustag, (r)->r_bushandle, (o), (v))
+#define bus_peek_2(r, o, vp) \
+ bus_space_peek_2((r)->r_bustag, (r)->r_bushandle, (o), (vp))
#define bus_read_2(r, o) \
bus_space_read_2((r)->r_bustag, (r)->r_bushandle, (o))
#define bus_read_multi_2(r, o, d, c) \
@@ -891,6 +899,10 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \
bus_space_write_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
#define bus_write_region_stream_2(r, o, d, c) \
bus_space_write_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
+#define bus_poke_4(r, o, v) \
+ bus_space_poke_4((r)->r_bustag, (r)->r_bushandle, (o), (v))
+#define bus_peek_4(r, o, vp) \
+ bus_space_peek_4((r)->r_bustag, (r)->r_bushandle, (o), (vp))
#define bus_read_4(r, o) \
bus_space_read_4((r)->r_bustag, (r)->r_bushandle, (o))
#define bus_read_multi_4(r, o, d, c) \
@@ -923,6 +935,10 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \
bus_space_write_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
#define bus_write_region_stream_4(r, o, d, c) \
bus_space_write_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
+#define bus_poke_8(r, o, v) \
+ bus_space_poke_8((r)->r_bustag, (r)->r_bushandle, (o), (v))
+#define bus_peek_8(r, o, vp) \
+ bus_space_peek_8((r)->r_bustag, (r)->r_bushandle, (o), (vp))
#define bus_read_8(r, o) \
bus_space_read_8((r)->r_bustag, (r)->r_bushandle, (o))
#define bus_read_multi_8(r, o, d, c) \