summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys
diff options
context:
space:
mode:
authorKevin Kirspel <kevin-kirspel@idexx.com>2017-05-04 08:27:56 -0400
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-05-11 11:15:41 +0200
commitf6c52e086dbc0e7101ea4e03a84005dd2811ad42 (patch)
tree9c3e5f6f4c7c7a5df9b2c559cd652d6cbfc32065 /freebsd/sys/sys
parentAdding stty command files from FREEBSD tree (diff)
downloadrtems-libbsd-f6c52e086dbc0e7101ea4e03a84005dd2811ad42.tar.bz2
Adding tty support files from FREEBSD tree
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r--freebsd/sys/sys/cons.h144
-rw-r--r--freebsd/sys/sys/serial.h92
2 files changed, 236 insertions, 0 deletions
diff --git a/freebsd/sys/sys/cons.h b/freebsd/sys/sys/cons.h
new file mode 100644
index 00000000..78cba61e
--- /dev/null
+++ b/freebsd/sys/sys/cons.h
@@ -0,0 +1,144 @@
+/*-
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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 University 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 REGENTS 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 REGENTS 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.
+ *
+ * from: @(#)cons.h 7.2 (Berkeley) 5/9/91
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE_CONS_H_
+#define _MACHINE_CONS_H_
+
+struct consdev;
+struct tty;
+
+typedef void cn_probe_t(struct consdev *);
+typedef void cn_init_t(struct consdev *);
+typedef void cn_term_t(struct consdev *);
+typedef void cn_grab_t(struct consdev *);
+typedef void cn_ungrab_t(struct consdev *);
+typedef int cn_getc_t(struct consdev *);
+typedef void cn_putc_t(struct consdev *, int);
+
+struct consdev_ops {
+ cn_probe_t *cn_probe;
+ /* probe hardware and fill in consdev info */
+ cn_init_t *cn_init;
+ /* turn on as console */
+ cn_term_t *cn_term;
+ /* turn off as console */
+ cn_getc_t *cn_getc;
+ /* kernel getchar interface */
+ cn_putc_t *cn_putc;
+ /* kernel putchar interface */
+ cn_grab_t *cn_grab;
+ /* grab console for exclusive kernel use */
+ cn_ungrab_t *cn_ungrab;
+ /* ungrab console */
+};
+
+struct consdev {
+ const struct consdev_ops *cn_ops;
+ /* console device operations. */
+ short cn_pri; /* pecking order; the higher the better */
+ void *cn_arg; /* drivers method argument */
+ int cn_flags; /* capabilities of this console */
+ char cn_name[SPECNAMELEN + 1]; /* console (device) name */
+};
+
+/* values for cn_pri - reflect our policy for console selection */
+#define CN_DEAD 0 /* device doesn't exist */
+#define CN_LOW 1 /* device is a last restort only */
+#define CN_NORMAL 2 /* device exists but is nothing special */
+#define CN_INTERNAL 3 /* "internal" bit-mapped display */
+#define CN_REMOTE 4 /* serial interface with remote bit set */
+
+/* Values for cn_flags. */
+#define CN_FLAG_NODEBUG 0x00000001 /* Not supported with debugger. */
+#define CN_FLAG_NOAVAIL 0x00000002 /* Temporarily not available. */
+
+/* Visibility of characters in cngets() */
+#define GETS_NOECHO 0 /* Disable echoing of characters. */
+#define GETS_ECHO 1 /* Enable echoing of characters. */
+#define GETS_ECHOPASS 2 /* Print a * for every character. */
+
+#ifdef _KERNEL
+
+extern struct msgbuf consmsgbuf; /* Message buffer for constty. */
+extern struct tty *constty; /* Temporary virtual console. */
+
+#define CONSOLE_DEVICE(name, ops, arg) \
+ static struct consdev name = { \
+ .cn_ops = &ops, \
+ .cn_arg = (arg), \
+ }; \
+ DATA_SET(cons_set, name)
+
+#define CONSOLE_DRIVER(name) \
+ static const struct consdev_ops name##_consdev_ops = { \
+ .cn_probe = name##_cnprobe, \
+ .cn_init = name##_cninit, \
+ .cn_term = name##_cnterm, \
+ .cn_getc = name##_cngetc, \
+ .cn_putc = name##_cnputc, \
+ .cn_grab = name##_cngrab, \
+ .cn_ungrab = name##_cnungrab, \
+ }; \
+ CONSOLE_DEVICE(name##_consdev, name##_consdev_ops, NULL)
+
+/* Other kernel entry points. */
+void cninit(void);
+void cninit_finish(void);
+int cnadd(struct consdev *);
+void cnavailable(struct consdev *, int);
+void cnremove(struct consdev *);
+void cnselect(struct consdev *);
+void cngrab(void);
+void cnungrab(void);
+int cncheckc(void);
+int cngetc(void);
+void cngets(char *, size_t, int);
+void cnputc(int);
+void cnputs(char *);
+int cnunavailable(void);
+void constty_set(struct tty *tp);
+void constty_clear(void);
+
+/* sc(4) / vt(4) coexistence shim */
+#define VTY_SC 0x01
+#define VTY_VT 0x02
+int vty_enabled(unsigned int);
+void vty_set_preferred(unsigned int);
+
+#endif /* _KERNEL */
+
+#endif /* !_MACHINE_CONS_H_ */
diff --git a/freebsd/sys/sys/serial.h b/freebsd/sys/sys/serial.h
new file mode 100644
index 00000000..1a149a96
--- /dev/null
+++ b/freebsd/sys/sys/serial.h
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 2004 Poul-Henning Kamp
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * This file contains definitions which pertain to serial ports as such,
+ * (both async and sync), but which do not necessarily have anything to
+ * do with tty processing.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_SERIAL_H_
+#define _SYS_SERIAL_H_
+
+
+/*
+ * Indentification of modem control signals. These definitions match
+ * the TIOCMGET definitions in <sys/ttycom.h> shifted a bit down, and
+ * that identity is enforced with CTASSERT at the bottom of kern/tty.c
+ * Both the modem bits and delta bits must fit in 16 bit.
+ */
+#define SER_DTR 0x0001 /* data terminal ready */
+#define SER_RTS 0x0002 /* request to send */
+#define SER_STX 0x0004 /* secondary transmit */
+#define SER_SRX 0x0008 /* secondary receive */
+#define SER_CTS 0x0010 /* clear to send */
+#define SER_DCD 0x0020 /* data carrier detect */
+#define SER_RI 0x0040 /* ring indicate */
+#define SER_DSR 0x0080 /* data set ready */
+
+#define SER_MASK_STATE 0x00ff
+
+/* Delta bits, used to indicate which signals should/was affected */
+#define SER_DELTA(x) ((x) << 8)
+
+#define SER_DDTR SER_DELTA(SER_DTR)
+#define SER_DRTS SER_DELTA(SER_RTS)
+#define SER_DSTX SER_DELTA(SER_STX)
+#define SER_DSRX SER_DELTA(SER_SRX)
+#define SER_DCTS SER_DELTA(SER_CTS)
+#define SER_DDCD SER_DELTA(SER_DCD)
+#define SER_DRI SER_DELTA(SER_RI)
+#define SER_DDSR SER_DELTA(SER_DSR)
+
+#define SER_MASK_DELTA SER_DELTA(SER_MASK_STATE)
+
+#ifdef _KERNEL
+/*
+ * Specification of interrupt sources typical for serial ports. These are
+ * useful when some umbrella driver like scc(4) has enough knowledge of
+ * the hardware to obtain the set of pending interrupts but does not itself
+ * handle the interrupt. Each interrupt source can be given an interrupt
+ * resource for which inferior drivers can install handlers. The lower 16
+ * bits are kept free for the signals above.
+ */
+#define SER_INT_OVERRUN 0x010000
+#define SER_INT_BREAK 0x020000
+#define SER_INT_RXREADY 0x040000
+#define SER_INT_SIGCHG 0x080000
+#define SER_INT_TXIDLE 0x100000
+
+#define SER_INT_MASK 0xff0000
+#define SER_INT_SIGMASK (SER_MASK_DELTA | SER_MASK_STATE)
+
+#ifndef LOCORE
+typedef int serdev_intr_t(void*);
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_SERIAL_H_ */