Split off cdevsw initialization in cninit() into a new function
cninit_finish() that isn't called until all hardware device drivers
have been attached.  The bdevsw entry of the driver for the physical
console needs to be hooked after the physical driver has been
attached in case the attachment modified the entry.

Rearrange cninit() to avoid changing cn_tab until the driver for the
physical console has been initialized, so that the previous driver
(if any) can be used for debugging.

Start removing half-baked lint support.  bdevsw functions usually have
unused args but /*ARGSUSED*/ was used for only about 5% of them.

cons.h:
Declare cn_init_finish().

autoconf.c:
Call cn_init_finish().

Start adding prototypes.  Functions with bogus linkage (extern where
static is probably should be static) are explicitly declared as extern
so that the can be found easily (extern in a non-header is usually
wrong).

All:
Continue cleaning up init stuff: init functions shall be static;
INITs should be at the start of files...
This commit is contained in:
Bruce Evans 1995-09-10 18:57:26 +00:00
parent 26f1808769
commit f2cb5630d0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10665
6 changed files with 110 additions and 58 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.37 1995/09/03 05:43:00 julian Exp $
* $Id: autoconf.c,v 1.38 1995/09/09 18:09:41 davidg Exp $
*/
/*
@ -55,9 +55,17 @@
#include <sys/kernel.h>
#include <sys/mount.h> /* mountrootvfsops, struct vfsops*/
#include <machine/cons.h>
#include <machine/md_var.h>
#include <machine/pte.h>
static void configure __P((void *));
SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
int find_cdrom_root __P((void *));
void configure_start __P((void));
void configure_finish __P((void));
static void setroot(void);
/*
@ -128,7 +136,7 @@ find_cdrom_root(dummy)
rootdev = makedev(try_cdrom[k].major,j*8);
printf("trying rootdev=0x%lx (%s%d)\n",
rootdev, try_cdrom[k].name,j);
i = (*cd9660_mountroot)(NULL);
i = (*cd9660_mountroot)((void *)NULL);
if (!i) return i;
}
return EINVAL;
@ -159,8 +167,8 @@ configure_finish()
/*
* Determine i/o configuration for a machine.
*/
void
configure(dummy) /* arg not used */
static void
configure(dummy)
void *dummy;
{
@ -185,6 +193,8 @@ configure(dummy) /* arg not used */
configure_finish();
cninit_finish();
#ifdef MFS_ROOT
mfs_initminiroot(mfs_root); /* XXX UGLY*/
#endif /* MFS_ROOT */
@ -241,11 +251,6 @@ configure(dummy) /* arg not used */
setconf();
cold = 0;
}
/*
* Add a SYSINIT entry so that Configure gets called at the right time.
*/
SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
int
setdumpdev(dev)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.37 1995/09/03 05:43:00 julian Exp $
* $Id: autoconf.c,v 1.38 1995/09/09 18:09:41 davidg Exp $
*/
/*
@ -55,9 +55,17 @@
#include <sys/kernel.h>
#include <sys/mount.h> /* mountrootvfsops, struct vfsops*/
#include <machine/cons.h>
#include <machine/md_var.h>
#include <machine/pte.h>
static void configure __P((void *));
SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
int find_cdrom_root __P((void *));
void configure_start __P((void));
void configure_finish __P((void));
static void setroot(void);
/*
@ -128,7 +136,7 @@ find_cdrom_root(dummy)
rootdev = makedev(try_cdrom[k].major,j*8);
printf("trying rootdev=0x%lx (%s%d)\n",
rootdev, try_cdrom[k].name,j);
i = (*cd9660_mountroot)(NULL);
i = (*cd9660_mountroot)((void *)NULL);
if (!i) return i;
}
return EINVAL;
@ -159,8 +167,8 @@ configure_finish()
/*
* Determine i/o configuration for a machine.
*/
void
configure(dummy) /* arg not used */
static void
configure(dummy)
void *dummy;
{
@ -185,6 +193,8 @@ configure(dummy) /* arg not used */
configure_finish();
cninit_finish();
#ifdef MFS_ROOT
mfs_initminiroot(mfs_root); /* XXX UGLY*/
#endif /* MFS_ROOT */
@ -241,11 +251,6 @@ configure(dummy) /* arg not used */
setconf();
cold = 0;
}
/*
* Add a SYSINIT entry so that Configure gets called at the right time.
*/
SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
int
setdumpdev(dev)

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.31 1995/09/03 05:43:01 julian Exp $
* $Id: cons.c,v 1.32 1995/09/09 18:09:44 davidg Exp $
*/
#include <sys/param.h>
@ -76,40 +76,65 @@ static d_open_t *cn_phys_open; /* physical device open function */
static struct consdev *cn_tab; /* physical console device info */
static struct tty *cn_tp; /* physical console tty struct */
#ifdef DEVFS
#ifdef DEVFS
#include <sys/kernel.h>
#include <sys/devfsext.h>
#include "sys/kernel.h"
void cndev_init(void *data) /* data not used */
static void cndev_init __P((void *));
SYSINIT(cndev, SI_SUB_DEVFS, SI_ORDER_ANY, cndev_init, NULL)
static void
cndev_init(dummy)
void *dummy;
{
void * x;
/* path name devsw minor type uid gid perm*/
x=dev_add("/misc", "console", cnopen, 0, DV_CHR, 0, 0, 0640);
}
SYSINIT(cndev,SI_SUB_DEVFS, SI_ORDER_ANY, cndev_init, NULL)
#endif /*DEVFS*/
#endif /* DEVFS */
void
cninit()
{
register struct consdev *cp;
struct cdevsw *cdp;
struct consdev *best_cp, *cp;
/*
* Collect information about all possible consoles
* and find the one with highest priority
* Find the first console with the highest priority.
*/
best_cp = NULL;
for (cp = constab; cp->cn_probe; cp++) {
(*cp->cn_probe)(cp);
if (cp->cn_pri > CN_DEAD &&
(cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
cn_tab = cp;
(best_cp == NULL || cp->cn_pri > best_cp->cn_pri))
best_cp = cp;
}
/*
* No console, give up.
* If no console, give up.
*/
if ((cp = cn_tab) == NULL)
if (best_cp == NULL) {
cn_tab = best_cp;
return;
}
/*
* Initialize console, then attach to it. This ordering allows
* debugging using the previous console, if any.
* XXX if there was a previous console, then its driver should
* be informed when we forget about it.
*/
(*best_cp->cn_init)(best_cp);
cn_tab = best_cp;
}
void
cninit_finish()
{
struct cdevsw *cdp;
if (cn_tab == NULL)
return;
/*
* Hook the open and close functions.
*/
@ -127,10 +152,6 @@ cninit()
* cn_tty to the wrong value) for a year or two.
*/
cn_tty = cn_tp;
/*
* Turn on console
*/
(*cp->cn_init)(cp);
}
int
@ -243,7 +264,6 @@ cnioctl(dev, cmd, data, flag, p)
return ((*cdevsw[major(dev)].d_ioctl)(dev, cmd, data, flag, p));
}
/*ARGSUSED*/
int
cnselect(dev, rw, p)
dev_t dev;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.h 7.2 (Berkeley) 5/9/91
* $Id: cons.h,v 1.8 1995/04/23 12:55:55 bde Exp $
* $Id: cons.h,v 1.9 1995/04/24 16:43:01 bde Exp $
*/
#ifndef _MACHINE_CONS_H_
@ -110,6 +110,7 @@ extern int cnselect(dev_t, int, struct proc *);
/* other kernel entry points */
extern void cninit(void);
extern void cninit_finish(void);
extern int cngetc(void);
extern int cncheckc(void);
extern void cnputc(int);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.31 1995/09/03 05:43:01 julian Exp $
* $Id: cons.c,v 1.32 1995/09/09 18:09:44 davidg Exp $
*/
#include <sys/param.h>
@ -76,40 +76,65 @@ static d_open_t *cn_phys_open; /* physical device open function */
static struct consdev *cn_tab; /* physical console device info */
static struct tty *cn_tp; /* physical console tty struct */
#ifdef DEVFS
#ifdef DEVFS
#include <sys/kernel.h>
#include <sys/devfsext.h>
#include "sys/kernel.h"
void cndev_init(void *data) /* data not used */
static void cndev_init __P((void *));
SYSINIT(cndev, SI_SUB_DEVFS, SI_ORDER_ANY, cndev_init, NULL)
static void
cndev_init(dummy)
void *dummy;
{
void * x;
/* path name devsw minor type uid gid perm*/
x=dev_add("/misc", "console", cnopen, 0, DV_CHR, 0, 0, 0640);
}
SYSINIT(cndev,SI_SUB_DEVFS, SI_ORDER_ANY, cndev_init, NULL)
#endif /*DEVFS*/
#endif /* DEVFS */
void
cninit()
{
register struct consdev *cp;
struct cdevsw *cdp;
struct consdev *best_cp, *cp;
/*
* Collect information about all possible consoles
* and find the one with highest priority
* Find the first console with the highest priority.
*/
best_cp = NULL;
for (cp = constab; cp->cn_probe; cp++) {
(*cp->cn_probe)(cp);
if (cp->cn_pri > CN_DEAD &&
(cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
cn_tab = cp;
(best_cp == NULL || cp->cn_pri > best_cp->cn_pri))
best_cp = cp;
}
/*
* No console, give up.
* If no console, give up.
*/
if ((cp = cn_tab) == NULL)
if (best_cp == NULL) {
cn_tab = best_cp;
return;
}
/*
* Initialize console, then attach to it. This ordering allows
* debugging using the previous console, if any.
* XXX if there was a previous console, then its driver should
* be informed when we forget about it.
*/
(*best_cp->cn_init)(best_cp);
cn_tab = best_cp;
}
void
cninit_finish()
{
struct cdevsw *cdp;
if (cn_tab == NULL)
return;
/*
* Hook the open and close functions.
*/
@ -127,10 +152,6 @@ cninit()
* cn_tty to the wrong value) for a year or two.
*/
cn_tty = cn_tp;
/*
* Turn on console
*/
(*cp->cn_init)(cp);
}
int
@ -243,7 +264,6 @@ cnioctl(dev, cmd, data, flag, p)
return ((*cdevsw[major(dev)].d_ioctl)(dev, cmd, data, flag, p));
}
/*ARGSUSED*/
int
cnselect(dev, rw, p)
dev_t dev;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.h 7.2 (Berkeley) 5/9/91
* $Id: cons.h,v 1.8 1995/04/23 12:55:55 bde Exp $
* $Id: cons.h,v 1.9 1995/04/24 16:43:01 bde Exp $
*/
#ifndef _MACHINE_CONS_H_
@ -110,6 +110,7 @@ extern int cnselect(dev_t, int, struct proc *);
/* other kernel entry points */
extern void cninit(void);
extern void cninit_finish(void);
extern int cngetc(void);
extern int cncheckc(void);
extern void cnputc(int);