diff options
Diffstat (limited to 'release/picobsd/tinyware')
25 files changed, 1382 insertions, 222 deletions
diff --git a/release/picobsd/tinyware/aps/README b/release/picobsd/tinyware/aps/README index 760af8b53ce7f..2664c449bbaf6 100644 --- a/release/picobsd/tinyware/aps/README +++ b/release/picobsd/tinyware/aps/README @@ -11,9 +11,9 @@ When I have some time, I'll add usual switches and other functions that normal Also, what I'm now inclined to think is that it should be reworked to use more general (and less complicated) sysctl(3). -<abial@freebsd.org> +<abial@nask.pl> (As of 1998.07.31 this program is no longer used in PicoBSD. See sps(1) in TinyWare collection). -$Id: README,v 1.1.1.1 1998/08/27 17:38:44 abial Exp $ +$Id: README,v 1.2 1998/07/31 20:57:42 abial Exp $ diff --git a/release/picobsd/tinyware/help/README b/release/picobsd/tinyware/help/README index ededf1f29db42..8b86ba1375766 100644 --- a/release/picobsd/tinyware/help/README +++ b/release/picobsd/tinyware/help/README @@ -3,6 +3,6 @@ This is work in progress. Eventually I'll prepare the help system for newbies, and these files are just the beginning of it... -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ +$Id: README,v 1.1.1.1 1998/07/14 07:30:53 abial Exp $ diff --git a/release/picobsd/tinyware/help/help.c b/release/picobsd/tinyware/help/help.c index 5c49a04c6d390..0e0c9cc543547 100644 --- a/release/picobsd/tinyware/help/help.c +++ b/release/picobsd/tinyware/help/help.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 1998 Eric P. Scott <eps@sirius.com> - * Copyright (c) 1998 Andrzej Bialecki <abial@freebsd.org> + * Copyright (c) 1998 Andrzej Bialecki <abial@nask.pl> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: help.c,v 1.3 1998/09/23 14:51:34 abial Exp $ + * $Id: help.c,v 1.2 1998/09/07 19:00:34 abial Exp $ */ diff --git a/release/picobsd/tinyware/kget/Makefile b/release/picobsd/tinyware/kget/Makefile index ba9fe16aa7b0c..d55e863b19f61 100644 --- a/release/picobsd/tinyware/kget/Makefile +++ b/release/picobsd/tinyware/kget/Makefile @@ -1,9 +1,9 @@ -# $Id: Makefile,v 1.3 1998/10/25 03:16:02 abial Exp $ +# $Id: Makefile,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ # -SRC?=/usr/src PROG=kget -CFLAGS+= -I${SRC}/sys -SRCS= kget.c +CFLAGS+= -I/usr/src/sys -DUC_PRIVATE -DKERN_NO_SYMBOLS +SRCS= uc_isa.c uc_kmem.c uc_list.c uc_main.c uc_main.h \ + uc_eisa.c uc_pci.c NOMAN=yes .include <bsd.prog.mk> diff --git a/release/picobsd/tinyware/kget/README b/release/picobsd/tinyware/kget/README index 9490dd747969b..2acc5ea552d37 100644 --- a/release/picobsd/tinyware/kget/README +++ b/release/picobsd/tinyware/kget/README @@ -1,15 +1,12 @@ -1999.01.06 +1998.06.29 What is it? ----------- -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. +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. How can I use it? ----------------- @@ -17,25 +14,34 @@ 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. -Usage is straightforward: +NOTE: You need first to create symbols' list, using 'dumpnlist' utility, and +place it in /stand/symbols. - kget output_filename +Usage is straightforward: -where output_filename is either regular file (then it's created or -overwritten), or a "-" meaning standard output. + kget -incore|kernel_name output_filename [vanilla] In simplest form you can do - kget - + kget -incore - + +to list current in core parameters, or + + kget kernel_file - + +to see settings of another kernel. + +or -to list current in-core parameters, or + kget -incore - /stand/vanilla - kget /kernel.config +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. -to produce list of changes from 'vanilla' configuration and write -it to /kernel.config file - it already contains required keywords. +Credits go to Jordan K. Hubbard for 95% of this code. The rest is mine :-) Andrzej Bialecki -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.3 1998/11/01 20:19:40 abial Exp $ +$Id: README,v 1.2 1998/08/11 06:53:21 abial Exp $ diff --git a/release/picobsd/tinyware/kget/kget.c b/release/picobsd/tinyware/kget/kget.c deleted file mode 100644 index b8426e4fdc867..0000000000000 --- a/release/picobsd/tinyware/kget/kget.c +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * 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: kget.c,v 1.1 1999/01/08 21:09:42 abial Exp $ - */ - -#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; - } - fprintf(fout,"q\n"); - fclose(fout); - free(buf); - exit(0); -} diff --git a/release/picobsd/tinyware/kget/kget.h b/release/picobsd/tinyware/kget/kget.h new file mode 100644 index 0000000000000..fc88782379f7b --- /dev/null +++ b/release/picobsd/tinyware/kget/kget.h @@ -0,0 +1,2 @@ +#define SAFE_STRCPY strcpy +#define msgDebug printf diff --git a/release/picobsd/tinyware/kget/uc_eisa.c b/release/picobsd/tinyware/kget/uc_eisa.c new file mode 100644 index 0000000000000..c0483fc8d3a2b --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_eisa.c @@ -0,0 +1,166 @@ +/*************************************************** + * file: userconfig/uc_eisa.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. + * + * $Id: uc_eisa.c,v 1.5 1998/09/14 19:14:11 jkh Exp $ + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <nlist.h> +#include <i386/eisa/eisaconf.h> + +#include "uc_main.h" + +struct eisa_device_node { + struct eisa_device dev; + struct eisa_device_node *next; +}; + +/* module prototypes */ +static void eisa_fill_in(struct kernel *, struct uc_eisa *, struct eisa_device_node *); + +void +get_eisa_info(struct kernel *kp){ + int i, total; + u_int *ls; + struct eisa_driver *ed; + struct uc_eisa *ep, *epc; + char *name; + + if(kp->nl[EISA_SET].n_value || kp->nl[EISA_LIST].n_value) { + ep=epc=(struct uc_eisa *)malloc(sizeof(struct uc_eisa)); + if(!kp->incore) { + if(kp->nl[EISA_SET].n_value) { + u_int ndev; + ls=(u_int *)kv_to_u(kp, kp->nl[EISA_SET].n_value, sizeof(u_int)*10); /* XXX, size? */ + ndev=ls[0]; + for(i=1;i<(ndev+1);i++){ + ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*i); + epc = ep+(i-1); + ed=(struct eisa_driver *)kv_to_u(kp, ls[i], sizeof(struct eisa_driver)); + name=(char *)kv_to_u(kp, (u_int)ed->name, 10); /* XXX, size? */ + asprintf(&epc->device, "%s", name); + asprintf(&epc->full_name, "?"); + } + ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*i); + epc = ep+(i-1); + bzero(epc, sizeof(struct uc_eisa)); + kp->eisa_devp=ep; + } else { /* not incore and no symbol, we have no EISA devs... */ + kp->eisa_devp=(struct uc_eisa *)0; + } + } else { + /* if we're incore, we can get data from _eisa_dev_list, */ + /* which should be much more useful, but I'll need a machine */ + /* to test :( */ + if(kp->nl[EISA_LIST].n_value) { + u_int t; + struct eisa_device_node *edn; + + t=kv_dref_p(kp, kp->nl[EISA_LIST].n_value); + total=0; + while(t) { + edn=(struct eisa_device_node *) + kv_to_u(kp, t,sizeof(struct eisa_device_node)); + ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*(total+1)); + epc=ep+total; + eisa_fill_in(kp, epc, edn); + t=(u_int)edn->next; + free(edn); + total++; + } + + ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*(total+1)); + epc=ep+total; + bzero(epc, sizeof(struct uc_eisa)); + kp->eisa_devp=ep; + } else { + kp->eisa_devp=(struct uc_eisa *)0; + } + } + } else { + kp->eisa_devp=(struct uc_eisa *)0; + } +} + +struct list * +get_eisa_devlist(struct kernel *kp){ + struct list *dl; + struct uc_eisa *kdp; + + dl=list_new(); + + for(kdp=kp->eisa_devp; kdp->device; kdp++){ + list_append(dl, kdp->device); + } + return(dl); +} + + +struct list * +get_eisa_device(struct uc_eisa *ep){ + struct list *list; + list=list_new(); + + list_append(list, ep->device); + list_append(list, ep->full_name); + + return(list); +} + + +static void +eisa_fill_in(struct kernel *kp, struct uc_eisa *epc, struct eisa_device_node *edn){ + struct eisa_driver *edrv; + char *n; + + edrv=(struct eisa_driver *)kv_to_u(kp, (u_int)edn->dev.driver, + sizeof(struct eisa_driver)); + + n=(char *)kv_to_u(kp, (u_int)edrv->name, 20); + asprintf(&epc->device, "%s%lu", n, edn->dev.unit); + free(n); + + n=(char *)kv_to_u(kp, (u_int)edn->dev.full_name, 40); /*XXX*/ + asprintf(&epc->full_name, "%s", n); + free(n); + free(edrv); +} + +void +eisa_free(struct kernel *kp, int writeback){ + struct uc_eisa *ep; + + for(ep=kp->eisa_devp;ep->device;ep++){ + free(ep->device); + free(ep->full_name); + } + free(kp->eisa_devp); + kp->eisa_devp=0; +} + +/* end of userconfig/uc_eisa.c */ diff --git a/release/picobsd/tinyware/kget/uc_isa.c b/release/picobsd/tinyware/kget/uc_isa.c new file mode 100644 index 0000000000000..6a5d750e49d9e --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_isa.c @@ -0,0 +1,211 @@ +/*************************************************** + * file: userconfig/uc_isa.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. + * + * $Id: uc_isa.c,v 1.5 1998/10/06 07:41:48 msmith Exp $ + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <nlist.h> +#include <i386/isa/isa_device.h> + +#include "uc_main.h" + +void +get_isa_info(struct kernel *kp){ + int total, i, j; + struct uc_isa *idp; + struct isa_device *p, *isa_dp; + struct isa_driver *drv; + char *name; + + if(kp->nl[ISA_BIOTAB].n_value || kp->nl[ISA_TTYTAB].n_value || kp->nl[ISA_NETTAB].n_value || + kp->nl[ISA_CAMTAB].n_value || kp->nl[ISA_NULLTAB].n_value || + kp->nl[ISA_WDCTAB].n_value || kp->nl[ISA_FDCTAB].n_value) { + + idp = kp->isa_devp = (struct uc_isa *)malloc(sizeof(struct uc_isa)); + total=0; /* a running total of the number of isa devices */ + + for (i=0; i<6; i++) { /* the isa devices */ + if(kp->nl[i].n_value) { + p = isa_dp = (struct isa_device *)kv_to_u(kp, kp->nl[i].n_value, /* XXX size? */ + sizeof(struct isa_device)*30); + /* build the device list */ + /* `total' keeps a running total of all the devices found */ + for (j=0; p->id_id; j++, p++, total++) { + kp->isa_devp = (struct uc_isa *)realloc(kp->isa_devp, + sizeof(struct uc_isa)*(total+1)); + idp=kp->isa_devp+total; + + drv=(struct isa_driver *)kv_to_u(kp, (u_int)p->id_driver, sizeof(struct isa_driver)); + name=(char *)kv_to_u(kp, (u_int)drv->name, 64); + + if (i==ISA_WDCTAB || i==ISA_FDCTAB) { /* special case the disk devices */ + char n[10]; + strncpy(n, name, 10); + n[strlen(n)-1]=0; /* chop off the trailing 'c' */ + asprintf(&idp->device, "%s%d", n, j); + } else { + asprintf(&idp->device, "%s%d", name, p->id_unit); + } + idp->port=p->id_iobase; + idp->irq=p->id_irq; + idp->drq=p->id_drq; + idp->iomem=(u_int)p->id_maddr & 0xFFFFFF; /* kludge to get pa from kva */ + idp->iosize=p->id_msize; + idp->flags=p->id_flags; + idp->alive=p->id_alive; + idp->enabled=p->id_enabled; + idp->modified=0; + if(!kp->incore){ + idp->idp=p; + } else { + free(name); + free(drv); + } + } + if(kp->incore){ + free(isa_dp); + } + } + } + + idp=kp->isa_devp+total; + bzero(idp, sizeof(struct uc_isa)); + } else { + kp->isa_devp=0; + } +} + + +struct list * +get_isa_devlist(struct kernel *kp){ + struct list *dl; + struct uc_isa *kdp; + + dl=list_new(); + + for(kdp=kp->isa_devp; kdp->device; kdp++){ + list_append(dl, kdp->device); + } + return(dl); +} + + +struct list * +get_isa_device(struct uc_isa *ip){ + struct list *list; + char *tmp; + + list=list_new(); + + asprintf(&tmp, "%s", ip->device ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "0x%04x", ip->port ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "%d", ip->irq>0 ? ffs(ip->irq)-1 : ip->irq); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "%d", ip->drq ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "0x%08x", ip->iomem ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "0x%x", ip->iosize ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "0x%x", ip->flags ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "%d", ip->alive ); + list_append(list, tmp); + free(tmp); + + asprintf(&tmp, "%d", ip->enabled ); + list_append(list, tmp); + free(tmp); + + return(list); +} + +int +isa_setdev(struct kernel *kp, struct list *list){ + int r=1, irq; + struct uc_isa *ip; + + if(kp->isa_devp) + for(ip=kp->isa_devp;ip->device;ip++){ + if(strcmp(list->av[0], ip->device)==0){ + ip->modified=1; + ip->port = strtol(list->av[1], (char **)NULL, 0); + irq=strtol(list->av[2], (char **)NULL, 0); + ip->irq= irq > 0 ? 1 << (irq) : irq; + ip->drq = strtol(list->av[3], (char **)NULL, 0); + ip->iomem = strtol(list->av[4], (char **)NULL, 0); + ip->iosize = strtol(list->av[5], (char **)NULL, 0); + ip->flags = strtol(list->av[6], (char **)NULL, 0); + ip->enabled = strtol(list->av[8], (char **)NULL, 0); + r=0; + break; + } + } + return(r); +} + +void +isa_free(struct kernel *kp, int writeback){ + struct uc_isa *ip; + for(ip=kp->isa_devp; ip->device; ip++){ + if((!kp->incore) && ip->modified && writeback) { + /* save any changes */ + ip->idp->id_iobase=ip->port; + ip->idp->id_irq = ip->irq; + ip->idp->id_drq = ip->drq; + ip->idp->id_maddr = (caddr_t)ip->iomem; + ip->idp->id_msize = ip->iosize; + ip->idp->id_flags = ip->flags; + ip->idp->id_enabled = ip->enabled; + } + /* and, be free... */ + free(ip->device); + } + /* and free the whole ball of wax */ + free(kp->isa_devp); + kp->isa_devp=0; +} + +/* end of userconfig/uc_isa.c */ diff --git a/release/picobsd/tinyware/kget/uc_kmem.c b/release/picobsd/tinyware/kget/uc_kmem.c new file mode 100644 index 0000000000000..159fb150a5d41 --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_kmem.c @@ -0,0 +1,87 @@ +/*************************************************** + * file: userconfig/uc_kmem.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. + * + * $Id: uc_kmem.c,v 1.3 1997/02/22 14:12:28 peter Exp $ + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <unistd.h> +#include <a.out.h> + +#include <stdio.h> + +#include "uc_main.h" + +/* translate a kv pointer to user space */ +/* malloc()-ing if we aren't mmaped */ +u_int +kv_to_u(struct kernel *kp, u_int adr, u_int size){ + u_int tadr; + if(!kp->incore){ + struct exec *ep; + ep=(struct exec *)kp->core; + tadr=(u_int)((adr - ep->a_entry + (N_DATOFF(*ep) - ep->a_text))+kp->core); + } else { + caddr_t ptr; + ptr = malloc(size); + lseek(kp->fd, adr, SEEK_SET); + read(kp->fd, ptr, size); + tadr=(u_int)ptr; + } + return(tadr); +} + +/* dereference a pointer to kernel space */ +u_int +kv_dref_p(struct kernel *kp, u_int adr){ + u_int tadr; + if(!kp->incore){ + struct exec *ep; + ep=(struct exec *)kp->core; + tadr=*(u_int*)((adr - ep->a_entry + (N_DATOFF(*ep) - ep->a_text))+kp->core); + } else { + lseek(kp->fd, adr, SEEK_SET); + read(kp->fd, &tadr, sizeof(tadr)); + } + return(tadr); +} + +/* deref a pointer to kernel text */ +u_int +kv_dref_t(struct kernel *kp, u_int adr){ + u_int tadr; + if(!kp->incore){ + struct exec *ep; + ep=(struct exec *)kp->core; + tadr=*(u_int*)((adr - ep->a_entry) + N_TXTOFF(*ep) + (u_int)kp->core); + } else { + lseek(kp->fd, adr, SEEK_SET); + read(kp->fd, &tadr, sizeof(tadr)); + } + return(tadr); +} + +/* end of userconfig/uc_kmem.c */ diff --git a/release/picobsd/tinyware/kget/uc_list.c b/release/picobsd/tinyware/kget/uc_list.c new file mode 100644 index 0000000000000..e2b6bd5cb5847 --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_list.c @@ -0,0 +1,76 @@ +/*************************************************** + * file: userconfig/uc_isa.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. + * + * $Id: uc_list.c,v 1.3 1997/02/22 14:12:29 peter Exp $ + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <nlist.h> +#include "uc_main.h" + +struct list * +list_new(void){ + struct list *rv; + rv=(struct list *)malloc(sizeof(struct list)); + rv->ac=0; + rv->av=(char **)0; + return(rv); +} + +void +list_append(struct list *list , char *item){ + + if(list->ac==0) { + list->av=(char **)malloc(sizeof(char *)*(list->ac+1)); + } else { + list->av=(char **)realloc(list->av, sizeof(char *)*(list->ac+1)); + } + asprintf(list->av+list->ac, "%s", item); + list->ac++; +} + +void +list_print(struct list *list, char *separator){ + int i; + for(i=0; i<list->ac; i++) + printf("%s%s", list->av[i], separator); +} + +void +list_destroy(struct list *list){ + int i; + for(i=0;i<list->ac;i++){ + free(list->av[i]); + list->av[i]=0; + } + free(list->av); + list->av=0; + free(list); +} + +/* end of userconfig/uc_list.c */ diff --git a/release/picobsd/tinyware/kget/uc_main.c b/release/picobsd/tinyware/kget/uc_main.c new file mode 100644 index 0000000000000..2f39a11a1a96b --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_main.c @@ -0,0 +1,475 @@ +/*************************************************** + * 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); +} diff --git a/release/picobsd/tinyware/kget/uc_main.h b/release/picobsd/tinyware/kget/uc_main.h new file mode 100644 index 0000000000000..326b80622023a --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_main.h @@ -0,0 +1,168 @@ +/*************************************************** + * 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 */ diff --git a/release/picobsd/tinyware/kget/uc_pci.c b/release/picobsd/tinyware/kget/uc_pci.c new file mode 100644 index 0000000000000..0d8e601c8b404 --- /dev/null +++ b/release/picobsd/tinyware/kget/uc_pci.c @@ -0,0 +1,122 @@ +/*************************************************** + * file: userconfig/uc_pci.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. + * + * $Id: uc_pci.c,v 1.4 1997/02/22 14:12:33 peter Exp $ + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <nlist.h> +#include <pci/pcivar.h> + +#include "uc_main.h" + +void +get_pci_info(struct kernel *kp){ + int i, total; + u_int *ls, ndev; + struct pci_device *pd; + struct uc_pci *pp,*ppc; + char *name; + + if(kp->nl[PCI_SET].n_value){ + pp = ppc = (struct uc_pci *)malloc(sizeof(struct uc_pci)); + ls=(u_int *)kv_to_u(kp, kp->nl[PCI_SET].n_value, sizeof(u_int)*30); /* XXX, size? */ + ndev=ls[0]; + total=0; + for(i=1;i<(ndev+1);i++){ + pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1)); + ppc = pp+(total); + pd=(struct pci_device *)kv_to_u(kp, ls[i], sizeof(struct pci_device)); + /* don't try to dereference a null pointer */ + name=pd->pd_name ? (char *)kv_to_u(kp, (u_int)pd->pd_name, 10) : + pd->pd_name; /* XXX, size? */ + if(kp->incore){ + int u, k; + /* incore, we can get unit numbers */ + + u=kv_dref_p(kp, (u_int)pd->pd_count); + for(k=0;k<u;k++,total++){ + pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1)); + ppc = pp+(total); + asprintf(&ppc->device, "%s%d", name, k); + } + free(pd); + if(name) + free(name); + } else { + asprintf(&ppc->device, "%s?", name); + total++; + } + } + pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1)); + ppc = pp+(total); + bzero(ppc, sizeof(struct uc_pci)); + kp->pci_devp=pp; + } else { + kp->pci_devp=(struct uc_pci *)0; + } +} + + +struct list * +get_pci_devlist(struct kernel *kp){ + struct list *dl; + struct uc_pci *kdp; + + dl=list_new(); + + for(kdp=kp->pci_devp; kdp->device; kdp++){ + list_append(dl, kdp->device); + } + return(dl); +} + + +struct list * +get_pci_device(struct uc_pci *pp){ + struct list *list; + list=list_new(); + + list_append(list, pp->device); + + return(list); +} + +void +pci_free(struct kernel *kp, int writeback){ + struct uc_pci *pp; + + for(pp=kp->pci_devp;pp->device;pp++){ + free(pp->device); + } + free(kp->pci_devp); + kp->pci_devp=0; + +} + +/* end of userconfig/uc_pci.c */ diff --git a/release/picobsd/tinyware/msg/README b/release/picobsd/tinyware/msg/README index 37bac7d929884..a38101bde5fc5 100644 --- a/release/picobsd/tinyware/msg/README +++ b/release/picobsd/tinyware/msg/README @@ -10,6 +10,6 @@ recently added to the kernel sources, so if you don't mind patching your kernel tree, contact me directly - the patches are very small and simple. Andrzej Bialecki -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.1 1998/09/15 07:35:58 abial Exp $ +$Id$ diff --git a/release/picobsd/tinyware/ns/README b/release/picobsd/tinyware/ns/README index 07cb5bd43c034..9d68b0b26d943 100644 --- a/release/picobsd/tinyware/ns/README +++ b/release/picobsd/tinyware/ns/README @@ -38,6 +38,6 @@ Bugs to be small, right? :-) Andrzej Bialecki -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.2 1998/09/07 06:41:14 abial Exp $ +$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ diff --git a/release/picobsd/tinyware/oinit/README b/release/picobsd/tinyware/oinit/README index a295f499d6c44..e14b0af068b96 100644 --- a/release/picobsd/tinyware/oinit/README +++ b/release/picobsd/tinyware/oinit/README @@ -118,6 +118,6 @@ Credits The overall framework was taken from FreeBSD /sbin/init. Andrzej Bialecki -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ +$Id: README,v 1.5 1998/08/11 06:53:47 abial Exp $ diff --git a/release/picobsd/tinyware/oinit/oinit.c b/release/picobsd/tinyware/oinit/oinit.c index 1bf70bdaf3432..01f8b9741e5be 100644 --- a/release/picobsd/tinyware/oinit/oinit.c +++ b/release/picobsd/tinyware/oinit/oinit.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: oinit.c,v 1.2 1998/10/15 21:40:07 abial Exp $ + * $Id: oinit.c,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ */ /* @@ -83,7 +83,7 @@ extern char **environ; /* Struct for holding session state */ struct sess { - char tty[16]; /* vty device path */ + char tty[11]; /* vty device path */ pid_t pid; /* pid of process running on it */ int (*func)(int argc, char **argv); /* internal function to run on it (after forking) */ @@ -646,16 +646,6 @@ runcom() void runcom(char *fname) { - int fd; - - close(0); - close(1); - close(2); - fd=open(_PATH_CONSOLE,O_RDWR); - dup2(fd,0); - dup2(fd,1); - dup2(fd,2); - if(fd>2) close(fd); sourcer(fname); } #endif @@ -912,13 +902,9 @@ main(int argc, char **argv) mount("devfs","/dev",MNT_NOEXEC|MNT_RDONLY,0); /* Fill in the sess structures. */ - /* XXX Really, should be filled based upon config file. */ + /* XXX Really, should be filled basing on config file. */ for(i=0;i<MAX_CONS;i++) { - if(i==0) { - sprintf(ttys[i].tty,"/dev/console"); - } else { - sprintf(ttys[i].tty,"/dev/ttyv%c",vty[i]); - } + sprintf(ttys[i].tty,"/dev/ttyv%c",vty[i]); ttys[i].pid=0; ttys[i].func=shell; } diff --git a/release/picobsd/tinyware/simple_httpd/Makefile b/release/picobsd/tinyware/simple_httpd/Makefile index 10ea6df7be54b..20b9ed4c3ee20 100644 --- a/release/picobsd/tinyware/simple_httpd/Makefile +++ b/release/picobsd/tinyware/simple_httpd/Makefile @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.1 1998/08/31 13:10:25 abial Exp $ +# $Id$ # -PROG=simple_httpd -SRCS= simple_httpd.c +PROG=simple_httpd. +SRCS= simple_httpd..c NOMAN=yes .include <bsd.prog.mk> diff --git a/release/picobsd/tinyware/simple_httpd/simple_httpd.c b/release/picobsd/tinyware/simple_httpd/simple_httpd.c index 5b02244e4de9f..0a83f67378157 100644 --- a/release/picobsd/tinyware/simple_httpd/simple_httpd.c +++ b/release/picobsd/tinyware/simple_httpd/simple_httpd.c @@ -13,7 +13,7 @@ */ /* - * $Id: simple_httpd.c,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ + * $Id: simple_httpd.c,v 1.1 1998/08/19 16:24:06 abial Exp $ */ #include <stdio.h> @@ -31,7 +31,6 @@ #include <string.h> #include <signal.h> #include <sys/wait.h> -#define LOGDIR "/var/log" int http_sock, con_sock; int http_port = 80; @@ -130,7 +129,7 @@ traite_req() strcat(logfile,"/"); strcat(logfile,"jhttp.log"); } - else strcpy(logfile, LOGDIR "/jhttpd.log"); + else strcpy(logfile,"/usr/adm/jhttpd.log"); if ( access(logfile,W_OK)) { @@ -350,9 +349,8 @@ char *adate() struct tm *t; time(&now); t = localtime(&now); - - sprintf(out, "%4d/%02d/%02d %02d:%02d:%02d", - t->tm_year+1900, t->tm_mon+1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec ); + sprintf(out, "%02d:%02d:%02d %02d/%02d/%02d", + t->tm_hour, t->tm_min, t->tm_sec, + t->tm_mday, t->tm_mon+1, t->tm_year ); return out; } diff --git a/release/picobsd/tinyware/sps/README b/release/picobsd/tinyware/sps/README index 771ddaaf88dfd..94098e7e3f2e7 100644 --- a/release/picobsd/tinyware/sps/README +++ b/release/picobsd/tinyware/sps/README @@ -12,6 +12,6 @@ The most serious limitation of 'sps' is that it's unable to retrieve the whole command line. -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ +$Id: README,v 1.1 1998/07/16 23:21:59 abial Exp $ diff --git a/release/picobsd/tinyware/view/README b/release/picobsd/tinyware/view/README index 1a2c611b67276..53ec9a017c3a0 100644 --- a/release/picobsd/tinyware/view/README +++ b/release/picobsd/tinyware/view/README @@ -81,6 +81,6 @@ Have fun! Andrzej Bialecki -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ +$Id: README,v 1.2 1998/08/19 06:19:44 abial Exp $ diff --git a/release/picobsd/tinyware/view/view.c b/release/picobsd/tinyware/view/view.c index 0255a6b5bec1a..0c2ad2645914e 100644 --- a/release/picobsd/tinyware/view/view.c +++ b/release/picobsd/tinyware/view/view.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: view.c,v 1.2 1998/10/09 12:42:56 abial Exp $ + * $Id: view.c,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ */ /* @@ -88,7 +88,6 @@ int max_screen_colors=15; int quit,changed; char **pres; int nimg=0; -int auto_chg=0; int cur_img=0; char act; FILE *log; @@ -402,7 +401,6 @@ int kbd_action(int x, int y, char key) { changed=0; - if(key!='n') auto_chg=0; switch(key) { case 'q': quit=1; @@ -442,23 +440,15 @@ kbd_action(int x, int y, char key) break; case '\n': case 'n': - if(nimg>0) { - if(cur_img<nimg-1) { - cur_img++; - } else { - cur_img=0; - } + if((nimg>0) && (cur_img<nimg-1)) { + cur_img++; png_load(pres[cur_img]); changed++; } break; case 'p': - if(nimg>0) { - if(cur_img>0) { - cur_img--; - } else { - cur_img=nimg-1; - } + if((nimg>0) && (cur_img>0)) { + cur_img--; png_load(pres[cur_img]); changed++; } @@ -519,6 +509,7 @@ main(int argc, char *argv[]) fprintf(log,"VGL initialised\n"); #endif VGLSavePalette(); + VGLMouseInit(VGL_MOUSEHIDE); if(argc>optind) { res=png_load(argv[optind]); } else { @@ -533,14 +524,10 @@ main(int argc, char *argv[]) fprintf(log,"Trying script %s\n",argv[optind]); #endif fgets(buf,99,fsc); - buf[strlen(buf)-1]='\0'; - if(strncmp("VIEW SCRIPT",buf,11)!=NULL) { + if(strcmp("VIEW SCRIPT\n",buf)!=NULL) { VGLEnd(); usage(); } - if(strlen(buf)>12) { - auto_chg=atoi(buf+12); - } fgets(buf,99,fsc); buf[strlen(buf)-1]='\0'; nimg=atoi(buf); @@ -561,7 +548,6 @@ main(int argc, char *argv[]) #endif png_load(pres[cur_img]); } - VGLMouseInit(VGL_MOUSEHIDE); /* Prepare the keyboard */ tcgetattr(0,&t_old); memcpy(&t_new,&t_old,sizeof(struct termios)); @@ -596,12 +582,7 @@ main(int argc, char *argv[]) display(&pic,pal_red,pal_green,pal_blue,&a); changed=0; } - if(auto_chg) { - sleep(auto_chg); - kbd_action(x,y,'n'); - } else { - pause(); - } + pause(); VGLMouseStatus(&x,&y,&buttons); if(buttons & MOUSE_BUTTON3DOWN) { #ifdef DEBUG diff --git a/release/picobsd/tinyware/vm/README b/release/picobsd/tinyware/vm/README index e4d72c1a17d09..ec70bc2cfd1d7 100644 --- a/release/picobsd/tinyware/vm/README +++ b/release/picobsd/tinyware/vm/README @@ -5,6 +5,6 @@ current memory utilisation. The same info is available via sysctl(8) program, but unfortunately this particular variable doesn't have its handler, and consequently it is not displayed in stock version of sysctl(8). -<abial@freebsd.org> +<abial@nask.pl> -$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ +$Id: README,v 1.1.1.1 1998/07/14 07:30:54 abial Exp $ diff --git a/release/picobsd/tinyware/vm/vm.c b/release/picobsd/tinyware/vm/vm.c index cd744952f76f6..710cfb9715328 100644 --- a/release/picobsd/tinyware/vm/vm.c +++ b/release/picobsd/tinyware/vm/vm.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: vm.c,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ + * $Id: vm.c,v 1.1.1.1 1998/07/14 07:30:54 abial Exp $ */ #include <stdio.h> @@ -32,8 +32,6 @@ #include <sys/vmmeter.h> #include <vm/vm_param.h> -#define pgtok(a) ((a) * (u_int) DEFAULT_PAGE_SIZE >> 10) - int main(int argc, char *argv[]) { @@ -46,17 +44,14 @@ main(int argc, char *argv[]) for(;;) { sysctl(mib,2,&v,&len,NULL,0); if(i==0) { - printf(" procs kB virt mem real mem shared vm shared real free\n"); - printf(" r w l s tot act tot act tot act tot act\n"); + printf(" procs kB virt mem real mem shared vm shared real free\n"); + printf(" r d p s tot act tot act tot act tot act\n"); } - printf("%2hu%2hu%2hu%2hu",v.t_rq-1,v.t_dw+v.t_pw,v.t_sl,v.t_sw); - printf("%7ld %7ld %7ld%7ld", - (long)pgtok(v.t_vm),(long)pgtok(v.t_avm), - (long)pgtok(v.t_rm),(long)pgtok(v.t_arm)); - printf("%7ld%7ld%7ld%7ld%7ld\n", - (long)pgtok(v.t_vmshr),(long)pgtok(v.t_avmshr), - (long)pgtok(v.t_rmshr),(long)pgtok(v.t_armshr), - (long)pgtok(v.t_free)); + printf("%2hu%2hu%2hu%2hu",v.t_rq,v.t_dw,v.t_pw,v.t_sl); + printf("%7u%7u%7u%7u", + v.t_vm<<2,v.t_avm<<2,v.t_rm<<2,v.t_arm<<2); + printf("%7u%7u%7u%7u%7u\n", + v.t_vmshr<<2,v.t_avmshr<<2,v.t_rmshr<<2,v.t_armshr<<2,v.t_free<<2); sleep(5); i++; if(i>22) i=0; |