Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/tty.c
Show All 27 Lines | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_capsicum.h" | #include "opt_capsicum.h" | ||||
#include "opt_printf.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/cons.h> | #include <sys/cons.h> | ||||
#include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
#include <sys/file.h> | #include <sys/file.h> | ||||
#include <sys/filedesc.h> | #include <sys/filedesc.h> | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | SYSCTL_INT(_kern, OID_AUTO, tty_drainwait, CTLFLAG_RWTUN, | ||||
&tty_drainwait, 0, "Default output drain timeout in seconds"); | &tty_drainwait, 0, "Default output drain timeout in seconds"); | ||||
/* | /* | ||||
* Set TTY buffer sizes. | * Set TTY buffer sizes. | ||||
*/ | */ | ||||
#define TTYBUF_MAX 65536 | #define TTYBUF_MAX 65536 | ||||
#ifdef PRINTF_BUFR_SIZE | |||||
ed: If `PRINTF_BUFR_SIZE` is always defined in `opt_printf.h`, why do we need the conditional code… | |||||
cemUnsubmitted Not Done Inline ActionsIt's not always defined, IIRC. Hence similar logic in cam_xpt.c, subr_prf.c, and xen_console.c. cem: It's not always defined, IIRC. Hence similar logic in cam_xpt.c, subr_prf.c, and xen_console.c. | |||||
markjAuthorUnsubmitted Done Inline ActionsIndeed, there is no fallback definition that gets used if it's omitted in the kernel configuration file. markj: Indeed, there is no fallback definition that gets used if it's omitted in the kernel… | |||||
#define TTY_PRBUF_SIZE PRINTF_BUFR_SIZE | |||||
#else | |||||
#define TTY_PRBUF_SIZE 256 | |||||
#endif | |||||
/* | /* | ||||
* Allocate buffer space if necessary, and set low watermarks, based on speed. | * Allocate buffer space if necessary, and set low watermarks, based on speed. | ||||
* Note that the ttyxxxq_setsize() functions may drop and then reacquire the tty | * Note that the ttyxxxq_setsize() functions may drop and then reacquire the tty | ||||
* lock during memory allocation. They will return ENXIO if the tty disappears | * lock during memory allocation. They will return ENXIO if the tty disappears | ||||
* while unlocked. | * while unlocked. | ||||
*/ | */ | ||||
static int | static int | ||||
tty_watermarks(struct tty *tp) | tty_watermarks(struct tty *tp) | ||||
▲ Show 20 Lines • Show All 929 Lines • ▼ Show 20 Lines | #define PATCH_FUNC(x) do { \ | ||||
PATCH_FUNC(param); | PATCH_FUNC(param); | ||||
PATCH_FUNC(modem); | PATCH_FUNC(modem); | ||||
PATCH_FUNC(mmap); | PATCH_FUNC(mmap); | ||||
PATCH_FUNC(pktnotify); | PATCH_FUNC(pktnotify); | ||||
PATCH_FUNC(free); | PATCH_FUNC(free); | ||||
PATCH_FUNC(busy); | PATCH_FUNC(busy); | ||||
#undef PATCH_FUNC | #undef PATCH_FUNC | ||||
tp = malloc(sizeof(struct tty), M_TTY, M_WAITOK|M_ZERO); | tp = malloc(sizeof(struct tty) + TTY_PRBUF_SIZE, M_TTY, | ||||
M_WAITOK | M_ZERO); | |||||
tp->t_prbufsz = TTY_PRBUF_SIZE; | |||||
tp->t_devsw = tsw; | tp->t_devsw = tsw; | ||||
tp->t_devswsoftc = sc; | tp->t_devswsoftc = sc; | ||||
tp->t_flags = tsw->tsw_flags; | tp->t_flags = tsw->tsw_flags; | ||||
tp->t_drainwait = tty_drainwait; | tp->t_drainwait = tty_drainwait; | ||||
tty_init_termios(tp); | tty_init_termios(tp); | ||||
cv_init(&tp->t_inwait, "ttyin"); | cv_init(&tp->t_inwait, "ttyin"); | ||||
▲ Show 20 Lines • Show All 1,286 Lines • Show Last 20 Lines |
If PRINTF_BUFR_SIZE is always defined in opt_printf.h, why do we need the conditional code here?