diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-09 17:06:22 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-09 17:17:52 -0400 |
commit | d1296d7ca780daf7c54520831e6ebb5cbe0a3642 (patch) | |
tree | b2cfda818c7383875a1588ad2bb51408cf6e0903 /src/sys/include/sys/iotap.h | |
parent | 22a4e1692886c118955da0326ed45bf4a8f7682e (diff) |
kern: iotap: Expose I/O taps to userland
Expose I/O taps to userland using a tap message interface. An
application may construct a tap message to send to the kernel requesting
data from a specific tap, if there is data, the buffers will be safely
populated, otherwise some error returned.
An example is accessing the PS/2 keyboard tap:
--
char name[] = "i8042.port.0";
char buf[2] = {0, 0};
struct iotap_msg msg = {
.opcode = IOTAP_OPC_READ,
.buf = buf,
.len = len
};
...
/* muxtap() may be used */
...
--
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include/sys/iotap.h')
-rw-r--r-- | src/sys/include/sys/iotap.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/sys/include/sys/iotap.h b/src/sys/include/sys/iotap.h new file mode 100644 index 0000000..10e4f82 --- /dev/null +++ b/src/sys/include/sys/iotap.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Ian Marco Moffett and L5 engineers + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_IOTAP_H_ +#define _SYS_IOTAP_H_ 1 + +#include <sys/types.h> +#include <sys/cdefs.h> +#if !defined(_KERNEL) +#include <stdint.h> +#include <stddef.h> +#endif /* _KERNEL */ + +/* Valid I/O tap opcodes */ +#define IOTAP_OPC_READ 0x0000 + +/* + * An I/O tap message that can be send to + * the kernel to perform an operation on + * a tap. + * + * @opcode: Operation to be performed + * @buf: I/O buffer read/write operations + * @len: Length of I/O buffer + */ +struct __packed iotap_msg { + uint8_t opcode; + void *buf; + size_t len; +}; + +#endif /* _SYS_IOTAP_H_ */ |