+ Add prom_getenv(), and use it instead off calling callv->_getenv.

+ Add prom_scsiid() to read and decode the prom scsiidN environment
   variable that says what the host SCSI id should be.
 + Include <pmax/pmax/machdep.h> instead of declaring our own
   prom_*() prototypes.
This commit is contained in:
simonb 1999-06-08 23:40:19 +00:00
parent 674c377f8f
commit 661c94c72c
1 changed files with 33 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: promcall.c,v 1.2 1999/05/25 07:37:08 nisimura Exp $ */
/* $NetBSD: promcall.c,v 1.3 1999/06/08 23:40:19 simonb Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,25 +43,24 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.2 1999/05/25 07:37:08 nisimura Exp $");
__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.3 1999/06/08 23:40:19 simonb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/reboot.h>
#include <dev/cons.h>
#include <pmax/pmax/pmaxtype.h>
#include <pmax/pmax/machdep.h>
#include <machine/dec_prom.h>
int prom_systype __P((void));
void prom_haltbutton __P((void));
void prom_halt __P((int, char *)) __attribute__((__noreturn__));
void prom_findcons __P((int *, int *, int *));
static int romgetc __P((dev_t));
static void romputc __P((dev_t, int));
static int atoi __P((const char *));
#define DEFAULT_SCSIID 7 /* XXX - this should really live somewhere else */
/*
* Default consdev, for errors or warnings before
* consinit runs: use the PROM.
@ -123,7 +122,7 @@ prom_findcons(kbdslot, crtslot, prom_using_screen)
* Get and parse the "osconsole" environment variable.
*/
*crtslot = *kbdslot = -1;
oscon = (*callv->_getenv)("osconsole");
oscon = prom_getenv("osconsole");
if (oscon && *oscon >= '0' && *oscon <= '9') {
*kbdslot = *oscon - '0';
*prom_using_screen = 0;
@ -160,6 +159,16 @@ prom_findcons(kbdslot, crtslot, prom_using_screen)
}
/*
* Get a prom environment variable.
*/
char *
prom_getenv(name)
char *name;
{
return (*callv->_getenv)(name);
}
/*
* Get 32bit system type of Digital hardware.
* cputype, u_int8_t [3]
@ -174,7 +183,7 @@ prom_systype()
if (callv != &callvec)
return (*callv->_getsysid)();
cp = (*callv->_getenv)("systype");
cp = prom_getenv("systype");
return (cp != NULL) ? atoi(cp) : 0;
}
@ -210,6 +219,21 @@ prom_halt(howto, bootstr)
/*NOTREACHED*/
}
/*
* Get the host SCSI ID from the PROM.
*/
int
prom_scsiid(cnum)
int cnum;
{
char scsiid_var[8]; /* strlen("scsiidX") + NULL */
char *cp;
snprintf(scsiid_var, 8, "scsiid%d", cnum);
cp = prom_getenv(scsiid_var);
return (cp != NULL) ? atoi(cp) : DEFAULT_SCSIID;
}
/*
* over-engineered atoi(3)
*/