diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-02-10 17:21:02 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-02-10 17:21:02 +0000 |
commit | e88c882ecc9557ea14734a418252c2c8a5d8caf9 (patch) | |
tree | efcd54ffc50bff4a6649b65bded400937532997f /term/devio.c | |
parent | 00269c069be2a461363f905f19a02bb013e7debf (diff) |
2002-02-10 Marcus Brinkmann <marcus@gnu.org>
* term.h: Include `hurd/hurd_types.h'.
(struct bottomhalf): Change the return types of the following
members from void to error_t: abandon_physical_output,
suspend_physical_output, notice_input_flushed, desert_dtr,
set_break, clear_break, start_output, set_bits (which now takes an
struct termios * as argument), mdmctl and mdmstate (which now
takes an int * as argument). Add new members init and type.
(bottom): Define as const.
(devio_bottom, ptyio_bottom): Declare as const.
(drop_output): Change return type from void to error_t.
(ptyio_init): Remove prototype.
* devio.c (devio_abandon_physical_output): Change return value to
error_t, and return 0.
(devio_suspend_physical_output): Likewise.
(devio_notice_input_flushed): Likewise.
(devio_desert_dtr): Likewise.
(devio_set_break): Likewise.
(devio_clear_break): Likewise.
(devio_start_output): Likewise.
(devio_set_bits): Likewise.
(devio_mdmctl): Likewise.
(devio_mdmstate): Likewise.
(init_devio): Rename to ...
(devio_init): ... this. Do not give constructor attribute.
Change return type to error_t, and return an error value, rather
than bailing out. Declare as static.
(devio_bottom): Add type TERM_ON_MACHDEV and init function
devio_init.
(devio_set_bits): Accept new argument STATE and use that to work
out the terminal state, rather than changing the global termstate.
(devio_mdmstate): Accept new argument STATE and use that to return
the bits.
* ptyio.c: Do not include `hurd/hurd_types.h'.
(ptyio_suspend_physical_output): Change return value to error_t,
and return 0. Likewise.
(ptyio_notice_input_flushed): Likewise.
(ptyio_desert_dtr): Likewise.
(ptyio_set_bits): Likewise.
(ptyio_set_break): Likewise.
(ptyio_clear_break): Likewise.
(ptyio_mdmctl): Likewise.
(ptyio_start_output): Likewise.
(ptyio_abandon_physical_output): Likewise.
(ptyio_mdmstate): Likewise, and accept new argument STATE.
(ptyio_init): Declare as static and change return type to error_t.
(ptyio_bottom): Add type TERM_ON_MASTERPTY and init function
ptyio_init.
(ptyio_set_bits): Accept new argument STATE and use that to work
out the terminal state, rather than changing the global termstate.
(ptyio_mdmstate): Accept new argument STATE and use that to return
the bits.
* munge.c (drop_output): Change return value to error_t. Only
clear queue if there was no error.
* users.c (S_term_get_bottom_type): Just return bottom->type.
(set_state): Rework logic to take possible errors into account,
and to delay changing the termstate until we know that we won't
fail.
(S_tioctl_tiocflush): Return errors properly, and clear queue only
if notice_input_flushed succeeded.
(open_hook): Save error value of set_bits. Save old termflags and
restore them if if set_bits failed. Call set_bits with correct
arguments.
(S_tioctl_tiocmods): Set err to result of mdmctl.
(S_tioctl_tiocmset): Likewise.
(S_tioctl_tiocmbic): Likewise.
(S_tioctl_tiocmbis): Likewise.
(S_tioctl_tioccdtr): Likewise.
(S_tioctl_tiocsdtr): Likewise.
(S_tioctl_tioccbrk): Likewise for clear_break.
(S_tioctl_tiocsbrk): Likewise for set_break.
(S_tioctl_tiocstart): Likewise for start_output. Save old
termflags and restore them if if start_output failed.
(S_tioctl_tiocstop): Likewise for stop_output.
(S_trivfs_io_write): Abort the operation if start_output fails.
Do not call start_output if it just failed, or if there was no
data to be written.
* main.c (main): Initialize bottom handler (rather than special
casing this for ptyio).
* users.c (open_hook): Use memcpy instead bcopy and memset instead
bzero.
(S_tioctl_tiocgeta): Likewise.
(set_state): Likewise.
(open_hook): Likewise.
* munge.c (rescan_inputq): Likewise.
Diffstat (limited to 'term/devio.c')
-rw-r--r-- | term/devio.c | 86 |
1 files changed, 50 insertions, 36 deletions
diff --git a/term/devio.c b/term/devio.c index f1bdab2d..55b26336 100644 --- a/term/devio.c +++ b/term/devio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995,96,98,99,2000,01 Free Software Foundation, Inc. + Copyright (C) 1995,96,98,99,2000,01,02 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -98,20 +98,20 @@ static int output_stopped; static int char_size_mask_xxx = 0xff; /* Forward */ -static void devio_desert_dtr (); +static error_t devio_desert_dtr (); -static void init_devio (void) __attribute__ ((constructor)); -static void -init_devio () +static error_t +devio_init (void) { mach_port_t host_priv; error_t err; err = get_privileged_ports (&host_priv, &device_master); if (err) - error (1, err, "Getting priviliged ports"); + return err; mach_port_deallocate (mach_task_self (), host_priv); phys_reply_class = ports_create_class (0, 0); + return 0; } /* XXX Convert a real speed to a bogus Mach speed. Return @@ -237,7 +237,7 @@ bogus_speed_to_real_speed (int bspeed) /* If there are characters on the output queue and no pending output requests, then send them. */ -static void +static error_t devio_start_output () { char *cp; @@ -247,7 +247,7 @@ devio_start_output () size = qsize (outputq); if (!size || output_pending || (termflags & USER_OUTPUT_SUSP)) - return; + return 0; if (output_stopped) { @@ -278,6 +278,7 @@ devio_start_output () devio_desert_dtr (); else if (!err) output_pending = 1; + return 0; } error_t @@ -368,19 +369,21 @@ device_read_reply_inband (mach_port_t replypt, return 0; } -static void +static error_t devio_set_break () { device_set_status (phys_device, TTY_SET_BREAK, 0, 0); + return 0; } -static void +static error_t devio_clear_break () { device_set_status (phys_device, TTY_CLEAR_BREAK, 0, 0); + return 0; } -static void +static error_t devio_abandon_physical_output () { int val = D_WRITE; @@ -388,7 +391,7 @@ devio_abandon_physical_output () /* If this variable is clear, then carrier is gone, so we have nothing to do. */ if (!phys_reply_writes_pi) - return; + return 0; mach_port_deallocate (mach_task_self (), phys_reply_writes); ports_reallocate_port (phys_reply_writes_pi); @@ -397,9 +400,10 @@ devio_abandon_physical_output () device_set_status (phys_device, TTY_FLUSH, &val, TTY_FLUSH_COUNT); npending_output = 0; output_pending = 0; + return 0; } -static void +static error_t devio_suspend_physical_output () { if (!output_stopped) @@ -407,11 +411,13 @@ devio_suspend_physical_output () device_set_status (phys_device, TTY_STOP, 0, 0); output_stopped = 1; } + return 0; } -static void +static error_t devio_notice_input_flushed () { + return 0; } static int @@ -460,7 +466,7 @@ initial_open () return err; } -static void +static error_t devio_desert_dtr () { int bits; @@ -471,6 +477,7 @@ devio_desert_dtr () (dev_status_t) &bits, TTY_MODEM_COUNT); report_carrier_off (); + return 0; } static error_t @@ -580,20 +587,20 @@ device_open_reply (mach_port_t replyport, /* Adjust physical state on the basis of the terminal state. Where it isn't possible, mutate terminal state to match reality. */ -static void -devio_set_bits () +static error_t +devio_set_bits (struct termios *state) { - if (!(termstate.c_cflag & CIGNORE) && phys_device != MACH_PORT_NULL) + if (!(state->c_cflag & CIGNORE) && phys_device != MACH_PORT_NULL) { struct tty_status ttystat; int cnt = TTY_STATUS_COUNT; /* Find the current state. */ device_get_status (phys_device, TTY_STATUS, (dev_status_t) &ttystat, &cnt); - if (termstate.__ispeed) - real_speed_to_bogus_speed (termstate.__ispeed, &ttystat.tt_ispeed); - if (termstate.__ospeed) - real_speed_to_bogus_speed (termstate.__ospeed, &ttystat.tt_ospeed); + if (state->__ispeed) + real_speed_to_bogus_speed (state->__ispeed, &ttystat.tt_ispeed); + if (state->__ospeed) + real_speed_to_bogus_speed (state->__ospeed, &ttystat.tt_ospeed); /* Try and set it. */ device_set_status (phys_device, TTY_STATUS, @@ -602,19 +609,19 @@ devio_set_bits () /* And now make termstate match reality. */ cnt = TTY_STATUS_COUNT; device_get_status (phys_device, TTY_STATUS, (dev_status_t) &ttystat, &cnt); - termstate.__ispeed = bogus_speed_to_real_speed (ttystat.tt_ispeed); - termstate.__ospeed = bogus_speed_to_real_speed (ttystat.tt_ospeed); + state->__ispeed = bogus_speed_to_real_speed (ttystat.tt_ispeed); + state->__ospeed = bogus_speed_to_real_speed (ttystat.tt_ospeed); /* Mach forces us to use the normal stop bit convention: two bits at 110 bps; 1 bit otherwise. */ - if (termstate.__ispeed == 110) - termstate.c_cflag |= CSTOPB; + if (state->__ispeed == 110) + state->c_cflag |= CSTOPB; else - termstate.c_cflag &= ~CSTOPB; + state->c_cflag &= ~CSTOPB; /* Figure out how to munge input, since we are unable to actually affect what the hardware does. */ - switch (termstate.c_cflag & CSIZE) + switch (state->c_cflag & CSIZE) { case CS5: char_size_mask_xxx = 0x1f; @@ -633,12 +640,13 @@ devio_set_bits () char_size_mask_xxx = 0xff; break; } - if (termstate.c_cflag & PARENB) + if (state->c_cflag & PARENB) char_size_mask_xxx |= 0x80; } + return 0; } -static void +static error_t devio_mdmctl (int how, int bits) { int oldbits, newbits; @@ -661,21 +669,25 @@ devio_mdmctl (int how, int bits) device_set_status (phys_device, TTY_MODEM, (dev_status_t) &newbits, TTY_MODEM_COUNT); + + return 0; } -static int -devio_mdmstate () +static error_t +devio_mdmstate (int *state) { int bits, cnt; cnt = TTY_MODEM_COUNT; device_get_status (phys_device, TTY_MODEM, (dev_status_t) &bits, &cnt); - if (cnt != TTY_MODEM_COUNT) - return 0; + if (cnt == TTY_MODEM_COUNT) + *state = bits; else - return bits; + *state = 0; + return 0; } + /* Unused stubs */ kern_return_t device_read_reply (mach_port_t port, @@ -747,8 +759,10 @@ ports_do_mach_notify_send_once (mach_port_t notify) } -struct bottomhalf devio_bottom = +const struct bottomhalf devio_bottom = { + TERM_ON_MACHDEV, + devio_init, devio_start_output, devio_set_break, devio_clear_break, |