ptms.h revision eb5a5c7888f20ad6fa4580e785308db395ef6dfc
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _SYS_PTMS_H
#define _SYS_PTMS_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* Structures and definitions supporting the pseudo terminal
* drivers. This structure is private and should not be used by any
* applications.
*/
struct pt_ttys {
};
/*
* pt_state values
*/
/*
* Multi-threading primitives.
* Values of pt_refcnt: -1 if a writer is accessing the struct
* 0 if no one is reading or writing
* > 0 equals to the number of readers accessing the struct
*/
#define PT_ENTER_READ(p) { \
mutex_enter(&(p)->pt_lock); \
while ((p)->pt_refcnt < 0) \
(p)->pt_refcnt++; \
mutex_exit(&(p)->pt_lock); \
}
#define PT_ENTER_WRITE(p) { \
mutex_enter(&(p)->pt_lock); \
while ((p)->pt_refcnt != 0) \
(p)->pt_refcnt = -1; \
mutex_exit(&(p)->pt_lock); \
}
#define PT_EXIT_READ(p) { \
mutex_enter(&(p)->pt_lock); \
if ((--((p)->pt_refcnt)) == 0) \
cv_broadcast(&(p)->pt_cv); \
mutex_exit(&(p)->pt_lock); \
}
#define PT_EXIT_WRITE(p) { \
mutex_enter(&(p)->pt_lock); \
(p)->pt_refcnt = 0; \
cv_broadcast(&(p)->pt_cv); \
mutex_exit(&(p)->pt_lock); \
}
/*
* ptms_lock and pt_cnt are defined in ptms_conf.c
*/
extern void ptms_init(void);
extern struct pt_ttys *pt_ttys_alloc(void);
extern int ptms_attach_slave(void);
extern major_t ptms_slave_attached(void);
#ifdef DEBUG
#else
#define DDBG(a, b)
#define DDBGP(a, b)
#endif
#endif /* _KERNEL */
typedef struct pt_own {
} pt_own_t;
/*
* ioctl commands
*
* ISPTM: Determines whether the file descriptor is that of an open master
* device. Return code of zero indicates that the file descriptor
* represents master device.
*
* UNLKPT: Unlocks the master and slave devices. It returns 0 on success. On
* failure, the errno is set to EINVAL indicating that the master
* device is not open.
*
* ZONEPT: Sets the zoneid of the pair of master and slave devices. It
* returns 0 upon success. Used to force a pty 'into' a zone upon
* zone entry.
*
* PT_OWNER: Sets uid and gid for slave device. It returns 0 on success.
*
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PTMS_H */