/*
* Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* Please see the License for the specific language governing rights and
* limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved */
/*-
#ifdef KERNEL
+
+__BEGIN_DECLS
+#include <kern/locks.h>
+__END_DECLS
+
/*
* NetBSD Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have
* exactly the same behaviour as in true clists.
* (low, high, timeout).
*/
struct tty {
+ lck_mtx_t t_lock; /* Per tty lock */
+
struct clist t_rawq; /* Device raw input queue. */
long t_rawcc; /* Raw input queue statistics. */
struct clist t_canq; /* Device canonical queue. */
int t_hiwat; /* High water mark. */
int t_lowat; /* Low water mark. */
int t_gen; /* Generation number. */
+ void *t_iokit; /* IOKit management */
+ int t_refcnt; /* reference count */
};
+#define TTY_NULL (struct tty *)0
+
#define t_cc t_termios.c_cc
#define t_cflag t_termios.c_cflag
#define t_iflag t_termios.c_iflag
#define TS_DSR_OFLOW 0x800000 /* For CDSR_OFLOW. */
#endif
+#define TS_IOCTL_NOT_OK 0x1000000 /* Workaround <rdar://....> */
+#define TS_PGRPHUP 0x2000000 /* Don't change Foregroud process group */
+
/* Character type information. */
#define ORDINARY 0
#define TTY_BI 0x08000000 /* Break condition */
#ifdef KERNEL
-/* Is tp controlling terminal for p? */
-#define isctty(p, tp) \
- ((p)->p_session == (tp)->t_session && (p)->p_flag & P_CONTROLT)
-
-/* Is p in background of tp? */
-#define isbackground(p, tp) \
- (isctty((p), (tp)) && (p)->p_pgrp != (tp)->t_pgrp)
/* Unique sleep addresses. */
#define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq)
void clrbits(u_char *cp, int off, int len);
#ifdef KERNEL_PRIVATE
+void tty_init(void);
+/*
+ * The locked version of this function is used from routines which hold
+ * the tty_lock(), such as ttcompat() in tty_compat.c
+ */
+int ttioctl_locked(struct tty *tp, u_long com, caddr_t data, int flag,
+ struct proc *p);
+
int ttcompat(struct tty *tp, u_long com, caddr_t data, int flag,
struct proc *p);
-int ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term);
#endif /* KERNEL_PRIVATE */
+void tty_lock(struct tty *tp);
+void tty_unlock(struct tty *tp);
+
void termioschars(struct termios *t);
int tputchar(int c, struct tty *tp);
int ttioctl(struct tty *tp, u_long com, caddr_t data, int flag,
struct proc *p);
int ttread(struct tty *tp, struct uio *uio, int flag);
-void ttrstrt(void *tp);
int ttyselect(struct tty *tp, int rw, void * wql, struct proc *p);
int ttselect(dev_t dev, int rw, void * wql, struct proc *p);
void ttsetwater(struct tty *tp);
int ttwrite(struct tty *tp, struct uio *uio, int flag);
void ttwwakeup(struct tty *tp);
void ttyblock(struct tty *tp);
-void ttychars(struct tty *tp);
int ttycheckoutq(struct tty *tp, int wait);
-int ttyclose(struct tty *tp);
+int ttyclose(struct tty *tp); /* LEGACY: avoid using */
void ttyflush(struct tty *tp, int rw);
void ttyinfo(struct tty *tp);
+void ttyinfo_locked(struct tty *tp);
int ttyinput(int c, struct tty *tp);
int ttylclose(struct tty *tp, int flag);
int ttymodem(struct tty *tp, int flag);
int ttywait(struct tty *tp);
struct tty *ttymalloc(void);
void ttyfree(struct tty *);
+void ttysetpgrphup(struct tty *tp);
+void ttyclrpgrphup(struct tty *tp);
__END_DECLS