From 661c94c72caa843ce14c830b66accae1406f7d29 Mon Sep 17 00:00:00 2001 From: simonb Date: Tue, 8 Jun 1999 23:40:19 +0000 Subject: [PATCH] + 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 instead of declaring our own prom_*() prototypes. --- sys/arch/pmax/pmax/promcall.c | 42 +++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/sys/arch/pmax/pmax/promcall.c b/sys/arch/pmax/pmax/promcall.c index 1ed51522da79..706cc82a2d9b 100644 --- a/sys/arch/pmax/pmax/promcall.c +++ b/sys/arch/pmax/pmax/promcall.c @@ -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 /* 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 +#include #include #include #include #include +#include #include -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) */