FreeBSD/sys/dev/sio/sio.c
/*
 * handle sysctl read/write requests for console speed
 * 
 * In addition to setting comdefaultrate for I/O through /dev/console,
 * also set the initial and lock values for the /dev/ttyXX device
 * if there is one associated with the console.  Finally, if the /dev/tty
 * device has already been open, change the speed on the open running port
 * itself.
 */
handle sysctl read/write requests for console speed


handle sysctl read / write requests for console speed
static int
sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS)
{
	int error, s;
	speed_t newspeed;
	struct com_s *com;
	struct tty *tp;
	newspeed = comdefaultrate;
	error = sysctl_handle_opaque(oidp, &newspeed, sizeof newspeed, req);
	if (error || !req->newptr)
		return (error);
	comdefaultrate = newspeed;
	if (comconsole < 0)		
		return (0);
	com = com_addr(comconsole);
	if (com == NULL)
		return (ENXIO);
	tp = com->tp;
	if (tp == NULL)
		return (ENXIO);
	tp->t_init_in.c_ispeed  = tp->t_init_in.c_ospeed =
	tp->t_lock_in.c_ispeed  = tp->t_lock_in.c_ospeed =
	tp->t_init_out.c_ispeed = tp->t_init_out.c_ospeed =
	tp->t_lock_out.c_ispeed = tp->t_lock_out.c_ospeed = comdefaultrate;
	if (tp->t_state & TS_ISOPEN) {
		tp->t_termios.c_ispeed =
		tp->t_termios.c_ospeed = comdefaultrate;
		s = spltty();
		error = comparam(tp, &tp->t_termios);
		splx(s);
	}
	return error;
}
static int sysctl_machdep_comdefaultrate ( SYSCTL_HANDLER_ARGS ) { int error , s ; speed_t newspeed ; struct com_s * com ; struct tty * tp ; newspeed = comdefaultrate ; error = sysctl_handle_opaque ( oidp , & newspeed , sizeof newspeed , req ) ; if ( error || ! req -> newptr ) return ( error ) ; comdefaultrate = newspeed ; if ( comconsole < 0 ) return ( 0 ) ; com = com_addr ( comconsole ) ; if ( com == NULL ) return ( ENXIO ) ; tp = com -> tp ; if ( tp == NULL ) return ( ENXIO ) ; tp -> t_init_in . c_ispeed = tp -> t_init_in . c_ospeed = tp -> t_lock_in . c_ispeed = tp -> t_lock_in . c_ospeed = tp -> t_init_out . c_ispeed = tp -> t_init_out . c_ospeed = tp -> t_lock_out . c_ispeed = tp -> t_lock_out . c_ospeed = comdefaultrate ; if ( tp -> t_state & TS_ISOPEN ) { tp -> t_termios . c_ispeed = tp -> t_termios . c_ospeed = comdefaultrate ; s = spltty ( ) ; error = comparam ( tp , & tp -> t_termios ) ; splx ( s ) ; } return error ; }
handle sysctl read/write requests for console speed
handle sysctl read / write requests for console speed
/* serial console not selected? */ /*
	 * set the initial and lock rates for /dev/ttydXX and /dev/cuaXX
	 * (note, the lock rates really are boolean -- if non-zero, disallow
	 *  speed changes)
	 */