Synchronize with sys/i386/i386/userconfig.c revision 1.92.

This commit is contained in:
KATO Takenori 1997-09-10 08:06:35 +00:00
parent eba56748e7
commit 9614585d5b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29275

View File

@ -46,7 +46,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: userconfig.c,v 1.34 1997/08/29 14:53:18 kato Exp $
** $Id: userconfig.c,v 1.35 1997/09/04 13:21:23 kato Exp $
**/
/**
@ -122,6 +122,11 @@
#include <machine/limits.h>
#include <i386/isa/isa_device.h>
#include "pnp.h"
#if NPNP > 0
#include <i386/isa/pnp.h>
#endif
#include <pci/pcivar.h>
@ -2374,7 +2379,7 @@ visuserconfig(void)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: userconfig.c,v 1.34 1997/08/29 14:53:18 kato Exp $
* $Id: userconfig.c,v 1.35 1997/09/04 13:21:23 kato Exp $
*/
#include "scbus.h"
@ -2384,6 +2389,7 @@ visuserconfig(void)
#define PARM_DEVSPEC 0x1
#define PARM_INT 0x2
#define PARM_ADDR 0x3
#define PARM_STRING 0x4
typedef struct _cmdparm {
int type;
@ -2432,6 +2438,11 @@ static int helpfunc(CmdParm *);
static int introfunc(CmdParm *);
#endif
#if NPNP > 0
static int lspnp(void);
static int set_pnp_parms(CmdParm *);
#endif
static int lineno;
#include "eisa.h"
@ -2461,6 +2472,11 @@ static CmdParm dev_parms[] = {
{ -1, {} },
};
static CmdParm string_arg[] = {
{ PARM_STRING, {} },
{ -1, {} },
};
#if NEISA > 0
static CmdParm int_arg[] = {
{ PARM_INT, {} },
@ -2486,6 +2502,9 @@ static Cmd CmdList[] = {
{ "ios", set_device_iosize, int_parms }, /* iosize dev size */
{ "ir", set_device_irq, int_parms }, /* irq dev # */
{ "l", list_devices, NULL }, /* ls, list */
#if NPNP > 0
{ "pn", set_pnp_parms, string_arg }, /* pnp ... */
#endif
{ "po", set_device_ioaddr, int_parms }, /* port dev addr */
{ "res", (CmdFunc)cpu_reset, NULL }, /* reset CPU */
{ "q", quitfunc, NULL }, /* quit */
@ -2613,6 +2632,10 @@ parse_args(char *cmd, CmdParm *parms)
++parms;
continue;
}
if (parms->type == PARM_STRING) {
parms->parm.aparm = (void *)cmd ;
return 0;
}
}
return 0;
}
@ -2625,6 +2648,9 @@ list_devices(CmdParm *parms)
if (lsdevtab(&isa_devtab_tty[0])) return 0;
if (lsdevtab(&isa_devtab_net[0])) return 0;
if (lsdevtab(&isa_devtab_null[0])) return 0;
#if NPNP > 0
if (lspnp()) return 0;
#endif
#if NEISA > 0
printf("\nNumber of EISA slots to probe: %d\n", num_eisa_slots);
#endif /* NEISA > 0 */
@ -2717,6 +2743,94 @@ set_device_disable(CmdParm *parms)
return 0;
}
#if NPNP > 0
/*
* this function sets the kernel table to override bios PnP
* configuration.
*/
static int
set_pnp_parms(CmdParm *parms)
{
u_long idx, val, ldn, csn;
int i;
char *q, *p=parms[0].parm.aparm;
struct pnp_cinfo d;
csn=strtoul(p,&q, 0);
ldn=strtoul(q,&q, 0);
for (p=q; *p && (*p==' ' || *p=='\t'); p++) ;
if (csn < 1 || csn > MAX_PNP_CARDS || ldn >= MAX_PNP_LDN) {
printf("bad csn/ldn %d:%d\n", csn, ldn);
return 0;
}
for (i=0; i < MAX_PNP_LDN; i++) {
if (pnp_ldn_overrides[i].csn == csn &&
pnp_ldn_overrides[i].ldn == ldn)
break;
}
if (i==MAX_PNP_LDN) {
for (i=0; i < MAX_PNP_LDN; i++) {
if (pnp_ldn_overrides[i].csn <1 ||
pnp_ldn_overrides[i].csn > MAX_PNP_CARDS)
break;
}
}
if (i==MAX_PNP_LDN) {
printf("sorry, no PnP entries available, try delete one\n");
return 0 ;
}
d = pnp_ldn_overrides[i] ;
d.csn = csn;
d.ldn = ldn ;
while (*p) {
idx = 0;
val = 0;
if (!strncmp(p,"irq",3)) {
idx=strtoul(p+3,&q, 0);
val=strtoul(q,&q, 0);
if (idx >=0 && idx < 2) d.irq[idx] = val;
} else if (!strncmp(p,"flags",5)) {
idx=strtoul(p+5,&q, 0);
d.flags = idx;
} else if (!strncmp(p,"drq",3)) {
idx=strtoul(p+3,&q, 0);
val=strtoul(q,&q, 0);
if (idx >=0 && idx < 2) d.drq[idx] = val;
} else if (!strncmp(p,"port",4)) {
idx=strtoul(p+4,&q, 0);
val=strtoul(q,&q, 0);
if (idx >=0 && idx < 8) d.port[idx] = val;
} else if (!strncmp(p,"mem",3)) {
idx=strtoul(p+3,&q, 0);
val=strtoul(q,&q, 0);
if (idx >=0 && idx < 4) d.mem[idx].base = val;
} else if (!strncmp(p,"bios",4)) {
q = p+ 4;
d.override = 0 ;
} else if (!strncmp(p,"os",2)) {
q = p+2 ;
d.override = 1 ;
} else if (!strncmp(p,"disable",7)) {
q = p+7 ;
d.enable = 0 ;
} else if (!strncmp(p,"enable",6)) {
q = p+6;
d.enable = 1 ;
} else if (!strncmp(p,"delete",6)) {
bzero(&pnp_ldn_overrides[i], sizeof (pnp_ldn_overrides[i]));
if (i==0) pnp_ldn_overrides[i].csn = 255;/* not reinit */
return 0;
} else {
printf("unknown command <%s>\n", p);
break;
}
for (p=q; *p && (*p==' ' || *p=='\t'); p++) ;
}
pnp_ldn_overrides[i] = d ;
return 0;
}
#endif /* NPNP */
#if NEISA > 0
static int
set_num_eisa_slots(CmdParm *parms)
@ -2738,27 +2852,39 @@ quitfunc(CmdParm *parms)
static int
helpfunc(CmdParm *parms)
{
printf("Command\t\t\tDescription\n");
printf("-------\t\t\t-----------\n");
printf("ls\t\t\tList currently configured devices\n");
printf("port <devname> <addr>\tSet device port (i/o address)\n");
printf("irq <devname> <number>\tSet device irq\n");
printf("drq <devname> <number>\tSet device drq\n");
printf("iomem <devname> <addr>\tSet device maddr (memory address)\n");
printf("iosize <devname> <size>\tSet device memory size\n");
printf("flags <devname> <mask>\tSet device flags\n");
printf("enable <devname>\tEnable device\n");
printf("disable <devname>\tDisable device (will not be probed)\n");
printf(
"Command\t\t\tDescription\n"
"-------\t\t\t-----------\n"
"ls\t\t\tList currently configured devices\n"
"port <devname> <addr>\tSet device port (i/o address)\n"
"irq <devname> <number>\tSet device irq\n"
"drq <devname> <number>\tSet device drq\n"
"iomem <devname> <addr>\tSet device maddr (memory address)\n"
"iosize <devname> <size>\tSet device memory size\n"
"flags <devname> <mask>\tSet device flags\n"
"enable <devname>\tEnable device\n"
"disable <devname>\tDisable device (will not be probed)\n");
#if NPNP > 0
printf(
"pnp <csn> <ldn> [enable|disable]\tenable/disable device\n"
"pnp <csn> <ldn> [os|bios]\tset parameters using FreeBSD or BIOS\n"
"pnp <csn> <ldn> [portX <addr>]\tset addr for port X (0..7)\n"
"pnp <csn> <ldn> [memX <maddr>]\tset addr for memory range X (0..3)\n"
"pnp <csn> <ldn> [irq <number>]\tset irq X (0..1) to number, 0=unused\n"
"pnp <csn> <ldn> [drq <number>]\tset drq X (0..1) to number, 4=unused\n");
#endif
#if NEISA > 0
printf("eisa <number>\t\tSet the number of EISA slots to probe\n");
#endif /* NEISA > 0 */
printf("quit\t\t\tExit this configuration utility\n");
printf("reset\t\t\tReset CPU\n");
printf(
"quit\t\t\tExit this configuration utility\n"
"reset\t\t\tReset CPU\n");
#ifdef VISUAL_USERCONFIG
printf("visual\t\t\tGo to fullscreen mode.\n");
#endif
printf("help\t\t\tThis message\n\n");
printf("Commands may be abbreviated to a unique prefix\n");
printf(
"help\t\t\tThis message\n\n"
"Commands may be abbreviated to a unique prefix\n");
return 0;
}
@ -2907,6 +3033,67 @@ introfunc(CmdParm *parms)
}
#endif
#if NPNP > 0
static int
lspnp ()
{
struct pnp_cinfo *c;
int i, first = 1;
for (i=0; i< MAX_PNP_LDN; i++) {
c = &pnp_ldn_overrides[i];
if (c->csn >0 && c->csn != 255) {
int j, pmax, mmax;
static char pfmt[] =
"port 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ";
static char mfmt[] =
"mem 0x%x 0x%x 0x%x 0x%x";
char buf[256];
if (lineno >= 23) {
printf("<More> ");
if (getchar() == 'q') {
printf("quit\n");
return (1);
}
printf("\n");
lineno = 0;
}
if (lineno == 0 || first)
printf("CSN LDN conf en irqs drqs others (PnP devices)\n");
first = 0 ;
printf("%3d %3d %4s %2s %2d %-2d %2d %-2d ",
c->csn, c->ldn,
c->override ? "OS ":"BIOS",
c->enable ? "Y":"N",
c->irq[0], c->irq[1], c->drq[0], c->drq[1]);
if (c->flags)
printf("flags 0x%08x ",c->flags);
for (pmax = 7; pmax >=0 ; pmax--)
if (c->port[pmax]!=0) break;
for (mmax = 3; mmax >=0 ; mmax--)
if (c->mem[mmax].base!=0) break;
if (pmax>=0) {
strcpy(buf, pfmt);
buf[10 + 5*pmax]='\0';
printf(buf,
c->port[0], c->port[1], c->port[2], c->port[3],
c->port[4], c->port[5], c->port[6], c->port[7]);
}
if (mmax>=0) {
strcpy(buf, mfmt);
buf[8 + 5*mmax]='\0';
printf(buf,
c->mem[0].base, c->mem[1].base,
c->mem[2].base, c->mem[3].base);
}
printf("\n");
}
}
return 0 ;
}
#endif /* NPNP */
static int
lsdevtab(struct isa_device *dt)
{