Remove a hard-coded table of kernel console I/O functions exported
from sc, vt and sio drivers. Use instead a linker_set to collect them. Staticize ??cngetc(), ??cnputc(), etc functions in sc and vt drivers. We must still have siocngetc() and siocnputc() as globals because they are directly referred to by i386-gdbstub.c :-( Oked by: bde
This commit is contained in:
parent
7cedcfa765
commit
fc847f6651
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42373
@ -153,6 +153,9 @@ strcpy (char *dst, const char *src)
|
||||
/* XXX sio always uses its major with minor 0 no matter what we specify. */
|
||||
#define REMOTE_DEV 0
|
||||
|
||||
cn_getc_t siocngetc;
|
||||
cn_putc_t siocnputc;
|
||||
|
||||
static int
|
||||
putDebugChar (int c) /* write a single character */
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: syscons.c,v 1.287 1998/11/08 12:39:02 dfr Exp $
|
||||
* $Id: syscons.c,v 1.288 1998/12/07 21:58:23 archie Exp $
|
||||
*/
|
||||
|
||||
#include "sc.h"
|
||||
@ -301,6 +301,14 @@ static void scsplash_saver(int show);
|
||||
#define scsplash_stick(stick)
|
||||
#endif
|
||||
|
||||
static cn_probe_t sccnprobe;
|
||||
static cn_init_t sccninit;
|
||||
static cn_getc_t sccngetc;
|
||||
static cn_checkc_t sccncheckc;
|
||||
static cn_putc_t sccnputc;
|
||||
|
||||
CONS_DRIVER(sc, sccnprobe, sccninit, sccngetc, sccncheckc, sccnputc);
|
||||
|
||||
struct isa_driver scdriver = {
|
||||
scprobe, scattach, "sc", 1
|
||||
};
|
||||
@ -1876,7 +1884,7 @@ scmousestart(struct tty *tp)
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
sccnprobe(struct consdev *cp)
|
||||
{
|
||||
struct isa_device *dvp;
|
||||
@ -1902,13 +1910,13 @@ sccnprobe(struct consdev *cp)
|
||||
sc_kbdc = kbdc_open(sc_port);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
sccninit(struct consdev *cp)
|
||||
{
|
||||
scinit();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
sccnputc(dev_t dev, int c)
|
||||
{
|
||||
u_char buf[1];
|
||||
@ -1931,7 +1939,7 @@ sccnputc(dev_t dev, int c)
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
sccngetc(dev_t dev)
|
||||
{
|
||||
int s = spltty(); /* block scintr and scrn_timer while we poll */
|
||||
@ -1950,7 +1958,7 @@ sccngetc(dev_t dev)
|
||||
return(c);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
sccncheckc(dev_t dev)
|
||||
{
|
||||
int s = spltty(); /* block scintr and scrn_timer while we poll */
|
||||
|
@ -57,23 +57,6 @@
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cons.h>
|
||||
|
||||
/* XXX this should be config(8)ed. */
|
||||
#include "sc.h"
|
||||
#include "vt.h"
|
||||
#include "sio.h"
|
||||
static struct consdev constab[] = {
|
||||
#if NSC > 0
|
||||
{ sccnprobe, sccninit, sccngetc, sccncheckc, sccnputc },
|
||||
#endif
|
||||
#if NVT > 0
|
||||
{ pccnprobe, pccninit, pccngetc, pccncheckc, pccnputc },
|
||||
#endif
|
||||
#if NSIO > 0
|
||||
{ siocnprobe, siocninit, siocngetc, siocncheckc, siocnputc },
|
||||
#endif
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
static d_open_t cnopen;
|
||||
static d_close_t cnclose;
|
||||
static d_read_t cnread;
|
||||
@ -112,16 +95,22 @@ static struct tty *cn_tp; /* physical console tty struct */
|
||||
static void *cn_devfs_token; /* represents the devfs entry */
|
||||
#endif /* DEVFS */
|
||||
|
||||
CONS_DRIVER(cons, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
void
|
||||
cninit()
|
||||
{
|
||||
struct consdev *best_cp, *cp;
|
||||
struct consdev **list;
|
||||
|
||||
/*
|
||||
* Find the first console with the highest priority.
|
||||
*/
|
||||
best_cp = NULL;
|
||||
for (cp = constab; cp->cn_probe; cp++) {
|
||||
list = (struct consdev **)cons_set.ls_items;
|
||||
while ((cp = *list++) != NULL) {
|
||||
if (cp->cn_probe == NULL)
|
||||
continue;
|
||||
(*cp->cn_probe)(cp);
|
||||
if (cp->cn_pri > CN_DEAD &&
|
||||
(best_cp == NULL || cp->cn_pri > best_cp->cn_pri))
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)cons.h 7.2 (Berkeley) 5/9/91
|
||||
* $Id: cons.h,v 1.16 1997/04/01 16:13:31 bde Exp $
|
||||
* $Id: cons.h,v 1.17 1997/07/01 00:54:37 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_CONS_H_
|
||||
@ -49,30 +49,6 @@ typedef int cn_getc_t __P((dev_t));
|
||||
typedef int cn_checkc_t __P((dev_t));
|
||||
typedef void cn_putc_t __P((dev_t, int));
|
||||
|
||||
#ifdef KERNEL
|
||||
/*
|
||||
* XXX public functions in drivers should be declared in headers produced
|
||||
* by `config', not here.
|
||||
*/
|
||||
cn_probe_t pccnprobe;
|
||||
cn_init_t pccninit;
|
||||
cn_getc_t pccngetc;
|
||||
cn_checkc_t pccncheckc;
|
||||
cn_putc_t pccnputc;
|
||||
|
||||
cn_probe_t sccnprobe;
|
||||
cn_init_t sccninit;
|
||||
cn_getc_t sccngetc;
|
||||
cn_checkc_t sccncheckc;
|
||||
cn_putc_t sccnputc;
|
||||
|
||||
cn_probe_t siocnprobe;
|
||||
cn_init_t siocninit;
|
||||
cn_getc_t siocngetc;
|
||||
cn_checkc_t siocncheckc;
|
||||
cn_putc_t siocnputc;
|
||||
#endif /* KERNEL */
|
||||
|
||||
struct consdev {
|
||||
cn_probe_t *cn_probe;
|
||||
/* probe hardware and fill in consdev info */
|
||||
@ -96,8 +72,15 @@ struct consdev {
|
||||
#define CN_REMOTE 3 /* serial interface with remote bit set */
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct linker_set cons_set;
|
||||
extern int cons_unavail;
|
||||
|
||||
#define CONS_DRIVER(name, probe, init, getc, checkc, putc) \
|
||||
static struct consdev name##_consdev = { \
|
||||
probe, init, getc, checkc, putc \
|
||||
}; \
|
||||
DATA_SET(cons_set, name##_consdev);
|
||||
|
||||
/* Other kernel entry points. */
|
||||
int cncheckc __P((void));
|
||||
int cngetc __P((void));
|
||||
|
@ -153,6 +153,9 @@ strcpy (char *dst, const char *src)
|
||||
/* XXX sio always uses its major with minor 0 no matter what we specify. */
|
||||
#define REMOTE_DEV 0
|
||||
|
||||
cn_getc_t siocngetc;
|
||||
cn_putc_t siocnputc;
|
||||
|
||||
static int
|
||||
putDebugChar (int c) /* write a single character */
|
||||
{
|
||||
|
@ -114,6 +114,14 @@ static void vgapelinit(void); /* read initial VGA DAC palette */
|
||||
static int pcvt_xmode_set(int on, struct proc *p); /* initialize for X mode */
|
||||
#endif /* XSERVER && !PCVT_USL_VT_COMPAT */
|
||||
|
||||
static cn_probe_t pccnprobe;
|
||||
static cn_init_t pccninit;
|
||||
static cn_getc_t pccngetc;
|
||||
static cn_checkc_t pccncheckc;
|
||||
static cn_putc_t pccnputc;
|
||||
|
||||
CONS_DRIVER(pc, pccnprobe, pccninit, pccngetc, pccncheckc, pccnputc);
|
||||
|
||||
static d_open_t pcopen;
|
||||
static d_close_t pcclose;
|
||||
static d_read_t pcread;
|
||||
@ -1116,7 +1124,7 @@ consinit() /* init for kernel messages during boot */
|
||||
#endif /* PCVT_NETBSD */
|
||||
|
||||
#if PCVT_FREEBSD > 205
|
||||
void
|
||||
static void
|
||||
#else
|
||||
int
|
||||
#endif
|
||||
@ -1171,7 +1179,7 @@ pccnprobe(struct consdev *cp)
|
||||
}
|
||||
|
||||
#if PCVT_FREEBSD > 205
|
||||
void
|
||||
static void
|
||||
#else
|
||||
int
|
||||
#endif
|
||||
@ -1184,7 +1192,7 @@ pccninit(struct consdev *cp)
|
||||
}
|
||||
|
||||
#if PCVT_FREEBSD > 205
|
||||
void
|
||||
static void
|
||||
#else
|
||||
int
|
||||
#endif
|
||||
@ -1218,7 +1226,7 @@ pccnputc(Dev_t dev, U_char c)
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
pccngetc(Dev_t dev)
|
||||
{
|
||||
register int s;
|
||||
@ -1267,7 +1275,7 @@ pccngetc(Dev_t dev)
|
||||
}
|
||||
|
||||
#if PCVT_FREEBSD >= 200
|
||||
int
|
||||
static int
|
||||
pccncheckc(Dev_t dev)
|
||||
{
|
||||
char *cp;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
|
||||
* $Id: sio.c,v 1.219 1998/12/07 21:58:22 archie Exp $
|
||||
* $Id: sio.c,v 1.220 1998/12/27 12:35:48 phk Exp $
|
||||
*/
|
||||
|
||||
#include "opt_comconsole.h"
|
||||
@ -2485,6 +2485,18 @@ static void siocnclose __P((struct siocnstate *sp));
|
||||
static void siocnopen __P((struct siocnstate *sp));
|
||||
static void siocntxwait __P((void));
|
||||
|
||||
/*
|
||||
* XXX: sciocnget() and sciocnputc() are not declared static, as they are
|
||||
* referred to from i386/i386/i386-gdbstub.c.
|
||||
*/
|
||||
static cn_probe_t siocnprobe;
|
||||
static cn_init_t siocninit;
|
||||
static cn_checkc_t siocncheckc;
|
||||
cn_getc_t siocngetc;
|
||||
cn_putc_t siocnputc;
|
||||
|
||||
CONS_DRIVER(sio, siocnprobe, siocninit, siocngetc, siocncheckc, siocnputc);
|
||||
|
||||
static void
|
||||
siocntxwait()
|
||||
{
|
||||
@ -2606,7 +2618,7 @@ siocnclose(sp)
|
||||
outb(iobase + com_ier, sp->ier);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
siocnprobe(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
@ -2672,14 +2684,14 @@ siocnprobe(cp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
siocninit(cp)
|
||||
struct consdev *cp;
|
||||
{
|
||||
comconsole = DEV_TO_UNIT(cp->cn_dev);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
siocncheckc(dev)
|
||||
dev_t dev;
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: syscons.c,v 1.287 1998/11/08 12:39:02 dfr Exp $
|
||||
* $Id: syscons.c,v 1.288 1998/12/07 21:58:23 archie Exp $
|
||||
*/
|
||||
|
||||
#include "sc.h"
|
||||
@ -301,6 +301,14 @@ static void scsplash_saver(int show);
|
||||
#define scsplash_stick(stick)
|
||||
#endif
|
||||
|
||||
static cn_probe_t sccnprobe;
|
||||
static cn_init_t sccninit;
|
||||
static cn_getc_t sccngetc;
|
||||
static cn_checkc_t sccncheckc;
|
||||
static cn_putc_t sccnputc;
|
||||
|
||||
CONS_DRIVER(sc, sccnprobe, sccninit, sccngetc, sccncheckc, sccnputc);
|
||||
|
||||
struct isa_driver scdriver = {
|
||||
scprobe, scattach, "sc", 1
|
||||
};
|
||||
@ -1876,7 +1884,7 @@ scmousestart(struct tty *tp)
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
sccnprobe(struct consdev *cp)
|
||||
{
|
||||
struct isa_device *dvp;
|
||||
@ -1902,13 +1910,13 @@ sccnprobe(struct consdev *cp)
|
||||
sc_kbdc = kbdc_open(sc_port);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
sccninit(struct consdev *cp)
|
||||
{
|
||||
scinit();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
sccnputc(dev_t dev, int c)
|
||||
{
|
||||
u_char buf[1];
|
||||
@ -1931,7 +1939,7 @@ sccnputc(dev_t dev, int c)
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
sccngetc(dev_t dev)
|
||||
{
|
||||
int s = spltty(); /* block scintr and scrn_timer while we poll */
|
||||
@ -1950,7 +1958,7 @@ sccngetc(dev_t dev)
|
||||
return(c);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
sccncheckc(dev_t dev)
|
||||
{
|
||||
int s = spltty(); /* block scintr and scrn_timer while we poll */
|
||||
|
@ -57,23 +57,6 @@
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cons.h>
|
||||
|
||||
/* XXX this should be config(8)ed. */
|
||||
#include "sc.h"
|
||||
#include "vt.h"
|
||||
#include "sio.h"
|
||||
static struct consdev constab[] = {
|
||||
#if NSC > 0
|
||||
{ sccnprobe, sccninit, sccngetc, sccncheckc, sccnputc },
|
||||
#endif
|
||||
#if NVT > 0
|
||||
{ pccnprobe, pccninit, pccngetc, pccncheckc, pccnputc },
|
||||
#endif
|
||||
#if NSIO > 0
|
||||
{ siocnprobe, siocninit, siocngetc, siocncheckc, siocnputc },
|
||||
#endif
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
static d_open_t cnopen;
|
||||
static d_close_t cnclose;
|
||||
static d_read_t cnread;
|
||||
@ -112,16 +95,22 @@ static struct tty *cn_tp; /* physical console tty struct */
|
||||
static void *cn_devfs_token; /* represents the devfs entry */
|
||||
#endif /* DEVFS */
|
||||
|
||||
CONS_DRIVER(cons, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
void
|
||||
cninit()
|
||||
{
|
||||
struct consdev *best_cp, *cp;
|
||||
struct consdev **list;
|
||||
|
||||
/*
|
||||
* Find the first console with the highest priority.
|
||||
*/
|
||||
best_cp = NULL;
|
||||
for (cp = constab; cp->cn_probe; cp++) {
|
||||
list = (struct consdev **)cons_set.ls_items;
|
||||
while ((cp = *list++) != NULL) {
|
||||
if (cp->cn_probe == NULL)
|
||||
continue;
|
||||
(*cp->cn_probe)(cp);
|
||||
if (cp->cn_pri > CN_DEAD &&
|
||||
(best_cp == NULL || cp->cn_pri > best_cp->cn_pri))
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)cons.h 7.2 (Berkeley) 5/9/91
|
||||
* $Id: cons.h,v 1.16 1997/04/01 16:13:31 bde Exp $
|
||||
* $Id: cons.h,v 1.17 1997/07/01 00:54:37 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_CONS_H_
|
||||
@ -49,30 +49,6 @@ typedef int cn_getc_t __P((dev_t));
|
||||
typedef int cn_checkc_t __P((dev_t));
|
||||
typedef void cn_putc_t __P((dev_t, int));
|
||||
|
||||
#ifdef KERNEL
|
||||
/*
|
||||
* XXX public functions in drivers should be declared in headers produced
|
||||
* by `config', not here.
|
||||
*/
|
||||
cn_probe_t pccnprobe;
|
||||
cn_init_t pccninit;
|
||||
cn_getc_t pccngetc;
|
||||
cn_checkc_t pccncheckc;
|
||||
cn_putc_t pccnputc;
|
||||
|
||||
cn_probe_t sccnprobe;
|
||||
cn_init_t sccninit;
|
||||
cn_getc_t sccngetc;
|
||||
cn_checkc_t sccncheckc;
|
||||
cn_putc_t sccnputc;
|
||||
|
||||
cn_probe_t siocnprobe;
|
||||
cn_init_t siocninit;
|
||||
cn_getc_t siocngetc;
|
||||
cn_checkc_t siocncheckc;
|
||||
cn_putc_t siocnputc;
|
||||
#endif /* KERNEL */
|
||||
|
||||
struct consdev {
|
||||
cn_probe_t *cn_probe;
|
||||
/* probe hardware and fill in consdev info */
|
||||
@ -96,8 +72,15 @@ struct consdev {
|
||||
#define CN_REMOTE 3 /* serial interface with remote bit set */
|
||||
|
||||
#ifdef KERNEL
|
||||
extern struct linker_set cons_set;
|
||||
extern int cons_unavail;
|
||||
|
||||
#define CONS_DRIVER(name, probe, init, getc, checkc, putc) \
|
||||
static struct consdev name##_consdev = { \
|
||||
probe, init, getc, checkc, putc \
|
||||
}; \
|
||||
DATA_SET(cons_set, name##_consdev);
|
||||
|
||||
/* Other kernel entry points. */
|
||||
int cncheckc __P((void));
|
||||
int cngetc __P((void));
|
||||
|
Loading…
Reference in New Issue
Block a user