Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Add BUS_ADDR_{LO,HI}32() macros to correctly extract...
details: https://anonhg.NetBSD.org/src/rev/96dc2d5bdbc1
branches: trunk
changeset: 1008007:96dc2d5bdbc1
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Mar 08 02:42:00 2020 +0000
description:
Add BUS_ADDR_{LO,HI}32() macros to correctly extract the lower and
upper halves of 64-bit DMA addresses for 32-bit and 64-bit bus_addr_t.
This is a common pattern in modern drivers, so it's a good idea to provide
a common correct definition.
This particular implementation suggested by riastradh@.
diffstat:
sys/sys/bus.h | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diffs (22 lines):
diff -r effd3134a01e -r 96dc2d5bdbc1 sys/sys/bus.h
--- a/sys/sys/bus.h Sun Mar 08 00:53:12 2020 +0000
+++ b/sys/sys/bus.h Sun Mar 08 02:42:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.12 2018/04/19 21:19:07 christos Exp $ */
+/* $NetBSD: bus.h,v 1.13 2020/03/08 02:42:00 thorpej Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -245,4 +245,12 @@
} *bus_dmamap_t;
#endif /* __HAVE_NO_BUS_DMA */
+/*
+ * Convenience macros to correctly extract the upper and lower
+ * 32 bits of a bus_addr_t (which may be a 32-bit or 64-bit
+ * value).
+ */
+#define BUS_ADDR_HI32(a) ((uint32_t) __SHIFTOUT(a, __BITS(32,63)))
+#define BUS_ADDR_LO32(a) ((uint32_t) __SHIFTOUT(a, __BITS(0,31)))
+
#endif /* _SYS_BUS_H_ */
Home |
Main Index |
Thread Index |
Old Index