summaryrefslogtreecommitdiff
path: root/libhw_generic/include/libhw/generic
diff options
context:
space:
mode:
Diffstat (limited to 'libhw_generic/include/libhw/generic')
-rw-r--r--libhw_generic/include/libhw/generic/io.h29
-rw-r--r--libhw_generic/include/libhw/generic/net.h10
-rw-r--r--libhw_generic/include/libhw/generic/spi.h9
3 files changed, 32 insertions, 16 deletions
diff --git a/libhw_generic/include/libhw/generic/io.h b/libhw_generic/include/libhw/generic/io.h
new file mode 100644
index 0000000..681c5ef
--- /dev/null
+++ b/libhw_generic/include/libhw/generic/io.h
@@ -0,0 +1,29 @@
+/* libhw/generic/io.h - Device-independent I/O definitions
+ *
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#ifndef _LIBHW_GENERIC_IO_H_
+#define _LIBHW_GENERIC_IO_H_
+
+#include <stddef.h> /* for size_t */
+
+/* structs ********************************************************************/
+
+#if __unix__
+#include <sys/uio.h>
+#else
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+#endif
+
+struct duplex_iovec {
+ void *iov_read_dst;
+ void *iov_write_src;
+ size_t iov_len;
+};
+
+#endif /* _LIBHW_GENERIC_IO_H_ */
diff --git a/libhw_generic/include/libhw/generic/net.h b/libhw_generic/include/libhw/generic/net.h
index 8d81573..0386e12 100644
--- a/libhw_generic/include/libhw/generic/net.h
+++ b/libhw_generic/include/libhw/generic/net.h
@@ -13,16 +13,8 @@
#include <stdint.h> /* for uint{n}_t} */
#include <sys/types.h> /* for ssize_t */
-#if __unix__
-#include <sys/uio.h>
-#else
-struct iovec {
- void *iov_base;
- size_t iov_len;
-};
-#endif
-
#include <libobj/obj.h>
+#include <libhw/generic/io.h>
/* Errnos *********************************************************************/
diff --git a/libhw_generic/include/libhw/generic/spi.h b/libhw_generic/include/libhw/generic/spi.h
index aeeca37..c97232a 100644
--- a/libhw_generic/include/libhw/generic/spi.h
+++ b/libhw_generic/include/libhw/generic/spi.h
@@ -10,6 +10,7 @@
#include <stddef.h> /* for size_t */
#include <libobj/obj.h>
+#include <libhw/generic/io.h>
enum spi_mode {
SPI_MODE_0 = 0, /* clk_polarity=0 (idle low), clk_phase=0 (sample on rise) */
@@ -18,12 +19,6 @@ enum spi_mode {
SPI_MODE_3 = 3, /* clk_polarity=1 (idle high), clk_phase=1 (sample on fall) */
};
-struct bidi_iovec {
- void *iov_read_dst;
- void *iov_write_src;
- size_t iov_len;
-};
-
/* This API assumes that an SPI frame is a multiple of 8-bits.
*
* It is my understanding that this is a common constraint of SPI
@@ -37,7 +32,7 @@ struct bidi_iovec {
* non-multiple-of-8 number of bits.
*/
#define spi_LO_IFACE \
- LO_FUNC(void, readwritev, const struct bidi_iovec *iov, int iovcnt)
+ LO_FUNC(void, readwritev, const struct duplex_iovec *iov, int iovcnt)
LO_INTERFACE(spi)
#endif /* _LIBHW_GENERIC_SPI_H_ */