mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
Replace kget with version which obtains its info from newly added
sysctl machdep.uc_devlist, instead of /dev/kmem.
This commit is contained in:
parent
ed70fbe40c
commit
b51e08ff33
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42413
6 changed files with 134 additions and 675 deletions
|
@ -1,10 +1,9 @@
|
|||
# $Id: Makefile,v 1.2 1998/09/19 21:40:38 abial Exp $
|
||||
# $Id: Makefile,v 1.3 1998/10/25 03:16:02 abial Exp $
|
||||
#
|
||||
SRC?=/usr/src
|
||||
PROG=kget
|
||||
CFLAGS+= -I/usr/src/sys -DUC_PRIVATE -DKERN_NO_SYMBOLS
|
||||
.PATH: ../../../sysinstall
|
||||
SRCS= uc_isa.c uc_kmem.c uc_list.c uc_main.c uc_main.h \
|
||||
uc_eisa.c uc_pci.c
|
||||
CFLAGS+= -I${SRC}/sys
|
||||
SRCS= kget.c
|
||||
NOMAN=yes
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
1998.06.29
|
||||
1999.01.06
|
||||
|
||||
What is it?
|
||||
-----------
|
||||
|
||||
This utility is taken almost in its entirety from /stand/sysinstall. It allows
|
||||
to gather device configuration which possibly was changed in userconfig (-c)
|
||||
session, and to save it to /kernel.config file on startup floppy, so that when
|
||||
user boots next time, the settings will automatically be changed.
|
||||
This utility allows to gather device configuration which possibly
|
||||
was changed in userconfig (-c) session, and to save it to /kernel.config
|
||||
file on startup floppy, so that when user boots next time, the
|
||||
settings will automatically be changed.
|
||||
|
||||
This program uses sysctl(3) interface to retrieve data from the kernel -
|
||||
the machdep.uc_devlist sysctl was added Jan 5 1999 to 3.0-current.
|
||||
|
||||
How can I use it?
|
||||
-----------------
|
||||
|
@ -14,35 +17,25 @@ How can I use it?
|
|||
The best way is to call it from /etc/rc in such phase when the startup floppy
|
||||
is mounted, and redirect its output to /kernel.config on the floppy.
|
||||
|
||||
NOTE: You need first to create symbols' list, using 'dumpnlist' utility, and
|
||||
place it in /stand/symbols.
|
||||
|
||||
Usage is straightforward:
|
||||
|
||||
kget -incore|kernel_name output_filename [vanilla]
|
||||
kget output_filename
|
||||
|
||||
where output_filename is either regular file (then it's created or
|
||||
overwritten), or a "-" meaning standard output.
|
||||
|
||||
In simplest form you can do
|
||||
|
||||
kget -incore -
|
||||
kget -
|
||||
|
||||
to list current in core parameters, or
|
||||
to list current in-core parameters, or
|
||||
|
||||
kget kernel_file -
|
||||
kget /kernel.config
|
||||
|
||||
to see settings of another kernel.
|
||||
|
||||
or
|
||||
|
||||
kget -incore - /stand/vanilla
|
||||
|
||||
to produce list of changes from 'vanilla' configuration. You can redirect this
|
||||
list to /kernel.config file with no changes - it already contains required
|
||||
keywords.
|
||||
|
||||
Credits (according to jkh) go to Eric L. Hernes for 95% of this code. The
|
||||
rest is mine :-)
|
||||
to produce list of changes from 'vanilla' configuration and write
|
||||
it to /kernel.config file - it already contains required keywords.
|
||||
|
||||
Andrzej Bialecki
|
||||
<abial@freebsd.org>
|
||||
|
||||
$Id: README,v 1.2 1998/10/25 03:16:02 abial Exp $
|
||||
$Id: README,v 1.3 1998/11/01 20:19:40 abial Exp $
|
||||
|
|
112
release/picobsd/tinyware/kget/kget.c
Normal file
112
release/picobsd/tinyware/kget/kget.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*-
|
||||
* Copyright (c) 1999 Andrzej Bialecki <abial@freebsd.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (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$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include "i386/isa/isa_device.h"
|
||||
|
||||
struct isa_device *id;
|
||||
char *p;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int len,i;
|
||||
char *buf;
|
||||
char *mib="machdep.uc_devlist";
|
||||
char name[9];
|
||||
FILE *fout;
|
||||
|
||||
if(argc<2) {
|
||||
fout=stdout;
|
||||
} else {
|
||||
if(strcmp(argv[1],"-")==0) {
|
||||
fout=stdout;
|
||||
} else {
|
||||
fout=fopen(argv[1],"w");
|
||||
if(fout==NULL) {
|
||||
perror("opening output file");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We use sysctlbyname, because the oid is unknown (OID_AUTO) */
|
||||
|
||||
/* get the buffer size */
|
||||
i=sysctlbyname(mib,NULL,&len,NULL,NULL);
|
||||
if(i) {
|
||||
perror("buffer sizing");
|
||||
exit(-1);
|
||||
}
|
||||
buf=(char *)malloc(len*sizeof(char));
|
||||
i=sysctlbyname(mib,buf,&len,NULL,NULL);
|
||||
if(i) {
|
||||
perror("retrieving data");
|
||||
exit(-1);
|
||||
}
|
||||
i=0;
|
||||
while(i<len) {
|
||||
id=(struct isa_device *)(buf+i);
|
||||
p=(buf+i+sizeof(struct isa_device));
|
||||
strncpy(name,p,8);
|
||||
if(!id->id_enabled) {
|
||||
fprintf(fout,"di %s%d\n",name,id->id_unit);
|
||||
} else {
|
||||
fprintf(fout,"en %s%d\n",name,id->id_unit);
|
||||
if(id->id_iobase>0) {
|
||||
fprintf(fout,"po %s%d %#x\n",name,id->id_unit,
|
||||
id->id_iobase);
|
||||
}
|
||||
if(id->id_irq>0) {
|
||||
fprintf(fout,"ir %s%d %d\n",name,id->id_unit,
|
||||
ffs(id->id_irq)-1);
|
||||
}
|
||||
if(id->id_drq>0) {
|
||||
fprintf(fout,"dr %s%d %d\n",name,id->id_unit,
|
||||
id->id_drq);
|
||||
}
|
||||
if(id->id_maddr>0) {
|
||||
fprintf(fout,"iom %s%d %#x\n",name,id->id_unit,
|
||||
id->id_maddr);
|
||||
}
|
||||
if(id->id_msize>0) {
|
||||
fprintf(fout,"ios %s%d %d\n",name,id->id_unit,
|
||||
id->id_msize);
|
||||
}
|
||||
fprintf(fout,"f %s%d %#x\n",name,id->id_unit,
|
||||
id->id_flags);
|
||||
}
|
||||
i+=sizeof(struct isa_device)+8;
|
||||
}
|
||||
fclose(fout);
|
||||
free(buf);
|
||||
exit(0);
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
#define SAFE_STRCPY strcpy
|
||||
#define msgDebug printf
|
|
@ -1,475 +0,0 @@
|
|||
/***************************************************
|
||||
* file: userconfig/uc_main.c
|
||||
*
|
||||
* Copyright (c) 1996 Eric L. Hernes (erich@rrnet.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* library functions for userconfig library
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <paths.h>
|
||||
#include <sys/mman.h>
|
||||
#include <nlist.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "uc_main.h"
|
||||
#include "kget.h"
|
||||
|
||||
FILE *f_out;
|
||||
|
||||
static struct nlist _nl[] = {
|
||||
{"_isa_devtab_bio"},
|
||||
{"_isa_devtab_tty"},
|
||||
{"_isa_devtab_cam"},
|
||||
{"_isa_devtab_net"},
|
||||
{"_isa_devtab_null"},
|
||||
{"_isa_biotab_wdc"},
|
||||
{"_isa_biotab_fdc"},
|
||||
{"_eisadriver_set"},
|
||||
{"_eisa_dev_list"},
|
||||
{"_pcidevice_set"},
|
||||
{"_device_list"},
|
||||
{"_scbusses"},
|
||||
#ifdef USE_SCSI
|
||||
{"_scsi_cinit"},
|
||||
{"_scsi_dinit"},
|
||||
{"_scsi_tinit"},
|
||||
#endif
|
||||
{""},
|
||||
};
|
||||
|
||||
int
|
||||
isDebug() {
|
||||
return(0);
|
||||
}
|
||||
|
||||
struct list *
|
||||
vc_getdev(char *vanilla)
|
||||
{
|
||||
FILE *fd;
|
||||
struct list *dl;
|
||||
char buf[100];
|
||||
|
||||
fd=fopen(vanilla,"r");
|
||||
if(fd==NULL) {
|
||||
printf("no such file: %s\n",vanilla);
|
||||
exit(2);
|
||||
}
|
||||
dl=list_new();
|
||||
while(!feof(fd)) {
|
||||
buf[0]='\0';
|
||||
if(fgets(buf,99,fd)==NULL) continue;
|
||||
buf[strlen(buf)-1]='\0';
|
||||
list_append(dl,buf);
|
||||
}
|
||||
fclose(fd);
|
||||
return(dl);
|
||||
}
|
||||
|
||||
void
|
||||
process(struct list *d, struct list *v, int flag)
|
||||
{
|
||||
int i,idx,found;
|
||||
int len;
|
||||
char *tok,*sep=" ";
|
||||
char *parm[]= {"<devname>",
|
||||
"port",
|
||||
"irq",
|
||||
"drq",
|
||||
"iomem",
|
||||
"iosize",
|
||||
"flags",
|
||||
"<alive>",
|
||||
"<enabled>",
|
||||
"<modified>"};
|
||||
|
||||
if(!flag) {
|
||||
fprintf(f_out,"%s",d->av[0]);
|
||||
for(i=1;i<d->ac;i++) {
|
||||
fprintf(f_out," %s",d->av[i]);
|
||||
}
|
||||
fprintf(f_out,"\n");
|
||||
return;
|
||||
}
|
||||
found=0;
|
||||
for(i=0;i<v->ac;i++) {
|
||||
if(strncmp(d->av[0],v->av[i],strlen(d->av[0]))!=0) continue;
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
if(!found) {
|
||||
printf("\nWhoa!\n");
|
||||
printf("Couldn't find device %s in 'vanilla' list!\n",
|
||||
d->av[0]);
|
||||
printf("It seems that kernel image and 'vanilla' list are out of sync...\n");
|
||||
exit(2);
|
||||
}
|
||||
idx=i;
|
||||
if(strcmp(d->av[8],"0")==0) { /* disable and return */
|
||||
fprintf(f_out,"disable %s\n",d->av[0]);
|
||||
return;
|
||||
}
|
||||
tok=strtok(v->av[idx],sep); /* discard <name> */
|
||||
for(i=1;i<d->ac;i++) {
|
||||
tok=strtok(NULL,sep); /* get next param from string */
|
||||
if(tok==NULL) {
|
||||
fprintf(stderr,"Hmmm... strange error, please report!\n");
|
||||
fprintf(stderr,"Include the 'kget -incore' output and the device name (%s)\n",d->av[0]);
|
||||
exit(10);
|
||||
}
|
||||
if(strcmp(d->av[i],tok)!=0) { /* changed */
|
||||
switch(i) {
|
||||
case 7: /* alive */
|
||||
break;
|
||||
case 8: /* enable/disable */
|
||||
if(strcmp(d->av[i],"0")==0) { /* disable */
|
||||
fprintf(f_out,"disable %s\n",d->av[0]);
|
||||
return;
|
||||
} else {
|
||||
fprintf(f_out,"enable %s\n",d->av[0]);
|
||||
}
|
||||
break;
|
||||
case 2: /* special case for npx */
|
||||
if(strcmp(d->av[0],"npx0")==0) continue;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
fprintf(f_out,"%s %s %s\n",parm[i],d->av[0],d->av[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct kernel *core;
|
||||
struct list *c_isa, *c_dev,*v_isa;
|
||||
int d,j,cnt=0;
|
||||
int diff=0;
|
||||
char buf[100];
|
||||
|
||||
if(argc<3) {
|
||||
printf("Usage: %s name|-incore -|filename [vanilla]\n",argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if(argc>3) {
|
||||
v_isa=vc_getdev(argv[3]);
|
||||
diff++;
|
||||
}
|
||||
core=uc_open(argv[1]);
|
||||
c_isa=uc_getdev(core,"-isa");
|
||||
if(c_isa==NULL) {
|
||||
printf("no symbols in kernel?\n");
|
||||
exit(2);
|
||||
}
|
||||
if(strcmp(argv[2],"-")==NULL) {
|
||||
f_out=stdout;
|
||||
} else {
|
||||
f_out=fopen(argv[2],"w");
|
||||
if(f_out==NULL) f_out=stdout;
|
||||
}
|
||||
if(diff) fprintf(f_out,"USERCONFIG\n");
|
||||
for(d=0;d<c_isa->ac;d++) {
|
||||
c_dev=uc_getdev(core,c_isa->av[d]);
|
||||
process(c_dev,v_isa,diff);
|
||||
}
|
||||
if(diff) fprintf(f_out,"quit\n");
|
||||
uc_close(core,0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
struct kernel *
|
||||
uc_open(char *name){
|
||||
int kd, flags, incore;
|
||||
struct kernel *kern;
|
||||
struct stat sb;
|
||||
char kname[80];
|
||||
int size, i = 0;
|
||||
struct nlist *nl = _nl;
|
||||
|
||||
if (strcmp(name, "-incore") == 0)
|
||||
incore = 1;
|
||||
else
|
||||
incore = 0;
|
||||
|
||||
if (incore || (strcmp(name,"-bootfile") == 0))
|
||||
SAFE_STRCPY(kname, getbootfile());
|
||||
else
|
||||
SAFE_STRCPY(kname, name);
|
||||
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: kernel name is %s, incore = %d\n", kname, incore);
|
||||
kern = (struct kernel *)malloc(sizeof(struct kernel));
|
||||
|
||||
#ifdef KERN_NO_SYMBOLS
|
||||
if (incore) {
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen("/stand/symbols", "r");
|
||||
if (!fp) {
|
||||
msgDebug("Couldn't open /stand/symbols file! Punting.\n");
|
||||
free(kern);
|
||||
return NULL;
|
||||
}
|
||||
if (fscanf(fp, "%d\n", &size) != 1) {
|
||||
msgDebug("Unable to get # of name list entries from symbol file.\n");
|
||||
free(kern);
|
||||
return NULL;
|
||||
}
|
||||
else if (isDebug())
|
||||
msgDebug("uc_open: opened /stand/symbols file, reading %d entries.\n", size);
|
||||
|
||||
|
||||
kern->nl = nl = (struct nlist *)malloc((size + 1) * sizeof(struct nlist));
|
||||
bzero(nl, (size + 1) * sizeof(struct nlist));
|
||||
for (i = 0; i < size; i++) {
|
||||
char *cp, name[255];
|
||||
int c1;
|
||||
unsigned int uc1;
|
||||
short d1;
|
||||
unsigned long v1;
|
||||
|
||||
if (fgets(name, 255, fp) == NULL) {
|
||||
msgDebug("Can't get name field for entry %d\n", i);
|
||||
free(kern);
|
||||
return NULL;
|
||||
}
|
||||
if ((cp = index(name, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
nl[i].n_name = strdup(name);
|
||||
if (fscanf(fp, "%u %d %hd %ld\n", &uc1, &c1, &d1, &v1) == 4) {
|
||||
nl[i].n_type = (unsigned char)uc1;
|
||||
nl[i].n_other = (char)c1;
|
||||
nl[i].n_desc = d1;
|
||||
nl[i].n_value = v1;
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: for entry %d, decoded: \"%s\", %u %d %hd %ld\n", i, nl[i].n_name, nl[i].n_type, nl[i].n_other, nl[i].n_desc, nl[i].n_value);
|
||||
}
|
||||
}
|
||||
nl[i].n_name = "";
|
||||
fclose(fp);
|
||||
i = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
i = nlist(kname, nl);
|
||||
if (i == -1) {
|
||||
msgDebug("uc_open: kernel %s does not contain symbols.\n", kname);
|
||||
free(kern);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef KERN_NO_SYMBOLS
|
||||
if (!incore) {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
kern->nl=(struct nlist *)malloc(sizeof(_nl));
|
||||
bcopy(_nl, kern->nl, sizeof(_nl));
|
||||
}
|
||||
|
||||
if (incore) {
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: attempting to open /dev/kmem for incore.\n");
|
||||
if ((kd = open("/dev/kmem", O_RDONLY)) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to open /dev/kmem.\n");
|
||||
return NULL;
|
||||
}
|
||||
kern->core = (caddr_t)NULL;
|
||||
kern->incore = 1;
|
||||
kern->size = 0;
|
||||
}
|
||||
else {
|
||||
if (stat(kname, &sb) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to stat %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
kern->size = sb.st_size;
|
||||
flags = sb.st_flags;
|
||||
|
||||
if (chflags(kname, 0) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to chflags %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: attempting to open %s\n", kname);
|
||||
if ((kd = open(kname, O_RDWR, 0644)) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to open %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fchflags(kd, flags);
|
||||
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: attempting to mmap %d bytes\n", sb.st_size);
|
||||
kern->core = mmap((caddr_t)0, sb.st_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, kd, 0);
|
||||
kern->incore = 0;
|
||||
if (kern->core == MAP_FAILED) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to mmap from %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
kern->fd = kd;
|
||||
get_isa_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got isa information\n");
|
||||
|
||||
get_pci_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got pci information\n");
|
||||
|
||||
get_eisa_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got eisa information\n");
|
||||
#ifdef USE_SCSI
|
||||
get_scsi_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got scsi information\n");
|
||||
#else
|
||||
kern->scsi_devp=(struct uc_scsi*)NULL;
|
||||
kern->scsibus_devp=(struct uc_scsibus*)NULL;
|
||||
#endif
|
||||
return kern;
|
||||
}
|
||||
|
||||
int
|
||||
uc_close(struct kernel *kern, int writeback)
|
||||
{
|
||||
if (kern->isa_devp)
|
||||
isa_free(kern, writeback);
|
||||
|
||||
if (kern->eisa_devp)
|
||||
eisa_free(kern, writeback); /* `writeback' isn't really useful here */
|
||||
|
||||
if (kern->pci_devp)
|
||||
pci_free(kern, writeback); /* or here */
|
||||
|
||||
#ifdef USE_SCSI
|
||||
if (kern->scsi_devp)
|
||||
scsi_free(kern, writeback);
|
||||
#endif
|
||||
|
||||
if (!kern->incore)
|
||||
munmap(kern->core, kern->size);
|
||||
|
||||
close(kern->fd);
|
||||
free(kern->nl);
|
||||
free(kern);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct list *
|
||||
uc_getdev(struct kernel *kern, char *dev)
|
||||
{
|
||||
struct list *list = (struct list *)0;
|
||||
|
||||
if (*dev == '-') { /* asked for -isa, -eisa, -pci, -scsi, -all */
|
||||
if (strcmp(dev, "-all") == 0) {
|
||||
list = list_new();
|
||||
if (kern->isa_devp)
|
||||
list_append(list, "isa");
|
||||
|
||||
if (kern->eisa_devp)
|
||||
list_append(list, "eisa");
|
||||
|
||||
if (kern->pci_devp)
|
||||
list_append(list, "pci");
|
||||
|
||||
if (kern->scsi_devp)
|
||||
list_append(list, "scsi");
|
||||
|
||||
}
|
||||
else if (strcmp(dev, "-isa") == 0)
|
||||
list = get_isa_devlist(kern);
|
||||
else if (strcmp(dev, "-eisa") == 0)
|
||||
list = get_eisa_devlist(kern);
|
||||
else if (strcmp(dev, "-pci") == 0)
|
||||
list = get_pci_devlist(kern);
|
||||
#ifdef USE_SCSI
|
||||
else if (strcmp(dev, "-scsi") == 0)
|
||||
list = get_scsi_devlist(kern);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* we gotta figure out which real device to report */
|
||||
struct uc_isa *ip;
|
||||
struct uc_scsi *sp;
|
||||
struct uc_pci *pp;
|
||||
struct uc_eisa *ep;
|
||||
|
||||
if (kern->isa_devp) {
|
||||
for (ip = kern->isa_devp; ip->device; ip++) {
|
||||
if (strcmp(dev, ip->device) == 0) {
|
||||
list = get_isa_device(ip);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_SCSI
|
||||
if (kern->scsi_devp) {
|
||||
for (sp = kern->scsi_devp; sp->device; sp++) {
|
||||
if (strcmp(dev, sp->device) == 0) {
|
||||
list = get_scsi_device(sp);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kern->pci_devp) {
|
||||
for(pp = kern->pci_devp; pp->device; pp++) {
|
||||
if (strcmp(dev, pp->device) == 0) {
|
||||
list = get_pci_device(pp);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kern->eisa_devp) {
|
||||
for (ep = kern->eisa_devp; ep->device; ep++) {
|
||||
if (strcmp(dev, ep->device) == 0) {
|
||||
list = get_eisa_device(ep);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end:
|
||||
return(list);
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
/***************************************************
|
||||
* file: userconfig/uc_main.h
|
||||
*
|
||||
* Copyright (c) 1996 Eric L. Hernes (erich@rrnet.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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: uc_main.h,v 1.5 1998/10/06 07:41:49 msmith Exp $
|
||||
*/
|
||||
|
||||
#define ISA_BIOTAB 0
|
||||
#define ISA_TTYTAB 1
|
||||
#define ISA_NETTAB 2
|
||||
#define ISA_CAMTAB 3
|
||||
#define ISA_NULLTAB 4
|
||||
#define ISA_WDCTAB 5
|
||||
#define ISA_FDCTAB 6
|
||||
#define EISA_SET 7
|
||||
#define EISA_LIST 8
|
||||
#define PCI_SET 9
|
||||
#define SCSI_LIST 10
|
||||
#define SCSI_BUSSES 11
|
||||
#define SCSI_CINIT 12
|
||||
#define SCSI_DINIT 13
|
||||
#define SCSI_TINIT 14
|
||||
/* symbols + the null terminator */
|
||||
#define NSYMBOLS 16
|
||||
|
||||
struct kernel {
|
||||
int fd; /* file descriptor for the kernel image, either a binary or /dev/kmem */
|
||||
caddr_t core; /* either the mmap()ed kernel image, or a scratch area */
|
||||
u_int size; /* size of the object at ->core */
|
||||
int incore; /* true if the kernel is running */
|
||||
#ifdef UC_PRIVATE
|
||||
struct nlist *nl; /* the symbol table */
|
||||
#else
|
||||
void *nl;
|
||||
#endif
|
||||
struct uc_isa *isa_devp; /* pointer to the isa devices (if any) */
|
||||
struct uc_eisa *eisa_devp; /* pointer to the eisa devices (if any) */
|
||||
struct uc_pci *pci_devp; /* pointer to the pci devices (if any) */
|
||||
struct uc_scsi *scsi_devp; /* pointer to the scsi devices (if any) */
|
||||
struct uc_scsibus *scsibus_devp; /* internal pointer to scsibus wirings */
|
||||
};
|
||||
|
||||
struct uc_isa {
|
||||
char *device;
|
||||
u_short port;
|
||||
u_short irq;
|
||||
short drq;
|
||||
u_int iomem;
|
||||
int iosize;
|
||||
int flags;
|
||||
int alive;
|
||||
int enabled;
|
||||
#ifdef UC_PRIVATE
|
||||
struct isa_device *idp;
|
||||
#else
|
||||
void *idp;
|
||||
#endif
|
||||
int modified;
|
||||
};
|
||||
|
||||
struct uc_pci {
|
||||
char *device;
|
||||
};
|
||||
|
||||
struct uc_eisa {
|
||||
char *device;
|
||||
char *full_name;
|
||||
};
|
||||
|
||||
struct uc_scsibus {
|
||||
int bus_no;
|
||||
int unit;
|
||||
char *driver;
|
||||
#ifdef UC_PRIVATE
|
||||
struct scsi_ctlr_config *config;
|
||||
#else
|
||||
void *config;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct uc_scsi {
|
||||
char *device;
|
||||
char *adapter;
|
||||
u_short target;
|
||||
u_short lun;
|
||||
char *desc;
|
||||
#ifdef UC_PRIVATE
|
||||
struct scsi_device_config *config;
|
||||
#else
|
||||
void *config;
|
||||
#endif
|
||||
int modified;
|
||||
};
|
||||
|
||||
/* nearly everything useful returns a list */
|
||||
|
||||
struct list {
|
||||
int ac;
|
||||
char **av;
|
||||
};
|
||||
|
||||
/* prototypes */
|
||||
|
||||
/* uc_main.c */
|
||||
/* these are really the only public ones */
|
||||
struct kernel *uc_open(char *name);
|
||||
int uc_close(struct kernel *kern, int writeback);
|
||||
struct list *uc_getdev(struct kernel *kern, char *dev);
|
||||
|
||||
/* uc_isa.c */
|
||||
void get_isa_info(struct kernel *kp);
|
||||
struct list *get_isa_devlist(struct kernel *kp);
|
||||
struct list *get_isa_device(struct uc_isa *ip);
|
||||
int isa_setdev(struct kernel *kp, struct list *list);
|
||||
void isa_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_eisa.c */
|
||||
void get_eisa_info(struct kernel *kp);
|
||||
struct list *get_eisa_devlist(struct kernel *kp);
|
||||
struct list *get_eisa_device(struct uc_eisa *ep);
|
||||
void eisa_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_pci.c */
|
||||
void get_pci_info(struct kernel *kp);
|
||||
struct list *get_pci_devlist(struct kernel *kp);
|
||||
struct list *get_pci_device(struct uc_pci *pp);
|
||||
void pci_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_scsi.c */
|
||||
void get_scsi_info(struct kernel *kp);
|
||||
struct list *get_scsi_devlist(struct kernel *kp);
|
||||
struct list *get_scsi_device(struct uc_scsi *sp);
|
||||
int scsi_setdev(struct kernel *kp, struct list *list);
|
||||
void scsi_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_kmem.c */
|
||||
u_int kv_to_u(struct kernel *kp, u_int adr, u_int size);
|
||||
u_int kv_dref_p(struct kernel *kp, u_int adr);
|
||||
u_int kv_dref_t(struct kernel *kp, u_int adr);
|
||||
|
||||
/* uc_list.c */
|
||||
struct list *list_new(void);
|
||||
void list_append(struct list *list, char *item);
|
||||
void list_print(struct list *list, char *separator);
|
||||
void list_destroy(struct list *list);
|
||||
|
||||
/* end of userconfig/uc_main.h */
|
Loading…
Reference in a new issue