1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Add support for embedded operation withou console

The boot.c patch is applied only to teh JULIAN_HACK branch
the muted console is controlable by a sysctl variable kern.consmute
This commit is contained in:
Julian Elischer 1996-10-16 00:19:40 +00:00
parent 4c6441ffd0
commit 66478c637b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18951
4 changed files with 53 additions and 19 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.46 1996/05/01 03:32:46 bde Exp $
* $Id: cons.c,v 1.47 1996/09/14 04:25:32 bde Exp $
*/
#include <sys/param.h>
@ -46,6 +46,7 @@
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/reboot.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/tty.h>
@ -88,6 +89,8 @@ struct tty *constty = 0; /* virtual console output device */
static dev_t cn_dev_t;
SYSCTL_OPAQUE(_machdep, CPU_CONSDEV, consdev, CTLTYPE_OPAQUE|CTLFLAG_RD,
&cn_dev_t, sizeof cn_dev_t, "T,dev_t", "");
static int cn_mute;
SYSCTL_INT(_kern, KERN_CONSMUTE, consmute, CTLFLAG_RW, &cn_mute, 0, "");
int cons_unavail = 0; /* XXX:
* physical console not available for
@ -120,6 +123,18 @@ cninit()
best_cp = cp;
}
/*
* Check if we should mute the console (for security reasons perhaps)
* It can be changes dynamically using sysctl kern.consmute
* once we are up and going.
*
*/
cn_mute = ((boothowto & (RB_MUTE
|RB_SINGLE
|RB_VERBOSE
|RB_ASKNAME
|RB_CONFIG)) == RB_MUTE);
/*
* If no console, give up.
*/
@ -220,7 +235,7 @@ cnread(dev, uio, flag)
struct uio *uio;
int flag;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_read)(dev, uio, flag));
@ -232,7 +247,7 @@ cnwrite(dev, uio, flag)
struct uio *uio;
int flag;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
if (constty)
dev = constty->t_dev;
@ -251,7 +266,7 @@ cnioctl(dev, cmd, data, flag, p)
{
int error;
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
/*
* Superuser can always use this to wrest control of console
@ -274,7 +289,7 @@ cnselect(dev, rw, p)
int rw;
struct proc *p;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (1);
dev = cn_tab->cn_dev;
@ -286,7 +301,7 @@ int
cngetc()
{
int c;
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
c = (*cn_tab->cn_getc)(cn_tab->cn_dev);
if (c == '\r') c = '\n'; /* console input is always ICRNL */
@ -296,7 +311,7 @@ cngetc()
int
cncheckc()
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (-1);
return ((*cn_tab->cn_checkc)(cn_tab->cn_dev));
}
@ -305,7 +320,7 @@ void
cnputc(c)
register int c;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return;
if (c) {
if (c == '\n')

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.46 1996/05/01 03:32:46 bde Exp $
* $Id: cons.c,v 1.47 1996/09/14 04:25:32 bde Exp $
*/
#include <sys/param.h>
@ -46,6 +46,7 @@
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/reboot.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/tty.h>
@ -88,6 +89,8 @@ struct tty *constty = 0; /* virtual console output device */
static dev_t cn_dev_t;
SYSCTL_OPAQUE(_machdep, CPU_CONSDEV, consdev, CTLTYPE_OPAQUE|CTLFLAG_RD,
&cn_dev_t, sizeof cn_dev_t, "T,dev_t", "");
static int cn_mute;
SYSCTL_INT(_kern, KERN_CONSMUTE, consmute, CTLFLAG_RW, &cn_mute, 0, "");
int cons_unavail = 0; /* XXX:
* physical console not available for
@ -120,6 +123,18 @@ cninit()
best_cp = cp;
}
/*
* Check if we should mute the console (for security reasons perhaps)
* It can be changes dynamically using sysctl kern.consmute
* once we are up and going.
*
*/
cn_mute = ((boothowto & (RB_MUTE
|RB_SINGLE
|RB_VERBOSE
|RB_ASKNAME
|RB_CONFIG)) == RB_MUTE);
/*
* If no console, give up.
*/
@ -220,7 +235,7 @@ cnread(dev, uio, flag)
struct uio *uio;
int flag;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_read)(dev, uio, flag));
@ -232,7 +247,7 @@ cnwrite(dev, uio, flag)
struct uio *uio;
int flag;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
if (constty)
dev = constty->t_dev;
@ -251,7 +266,7 @@ cnioctl(dev, cmd, data, flag, p)
{
int error;
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
/*
* Superuser can always use this to wrest control of console
@ -274,7 +289,7 @@ cnselect(dev, rw, p)
int rw;
struct proc *p;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (1);
dev = cn_tab->cn_dev;
@ -286,7 +301,7 @@ int
cngetc()
{
int c;
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (0);
c = (*cn_tab->cn_getc)(cn_tab->cn_dev);
if (c == '\r') c = '\n'; /* console input is always ICRNL */
@ -296,7 +311,7 @@ cngetc()
int
cncheckc()
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return (-1);
return ((*cn_tab->cn_checkc)(cn_tab->cn_dev));
}
@ -305,7 +320,7 @@ void
cnputc(c)
register int c;
{
if (cn_tab == NULL)
if ((cn_tab == NULL) || cn_mute)
return;
if (c) {
if (c == '\n')

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)reboot.h 8.3 (Berkeley) 12/13/94
* $Id: reboot.h,v 1.12 1996/08/22 03:50:32 julian Exp $
* $Id: reboot.h,v 1.13 1996/08/27 19:45:58 pst Exp $
*/
#ifndef _SYS_REBOOT_H_
@ -59,6 +59,8 @@
#define RB_CDROM 0x2000 /* use cdrom as root */
#define RB_POWEROFF 0x4000 /* if you can, turn the power off */
#define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */
#define RB_MUTE 0x10000 /* Come up with the console muted */
#define RB_SELFTEST 0x20000 /* don't boot to normal operation, do selftest */
#define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
* $Id: sysctl.h,v 1.45 1996/09/19 00:54:29 pst Exp $
* $Id: sysctl.h,v 1.46 1996/10/07 04:32:42 pst Exp $
*/
#ifndef _SYS_SYSCTL_H_
@ -223,7 +223,8 @@ int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
#define KERN_MAXSOCKBUF 31 /* int: max size of a socket buffer */
#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */
#define KERN_USRSTACK 33 /* int: address of USRSTACK */
#define KERN_MAXID 34 /* number of valid kern ids */
#define KERN_CONSMUTE 34 /* Mute the console output? */
#define KERN_MAXID 35 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@ -260,6 +261,7 @@ int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
{ "maxsockbuf", CTLTYPE_INT }, \
{ "ps_strings", CTLTYPE_INT }, \
{ "usrstack", CTLTYPE_INT }, \
{ "consmute", CTLTYPE_INT }, \
}
/*