diff options
Diffstat (limited to 'release')
-rw-r--r-- | release/picobsd/tinyware/kget/Makefile | 3 | ||||
-rw-r--r-- | release/picobsd/tinyware/kget/README | 5 | ||||
-rw-r--r-- | release/picobsd/tinyware/kget/uc_eisa.c | 166 | ||||
-rw-r--r-- | release/picobsd/tinyware/kget/uc_isa.c | 211 | ||||
-rw-r--r-- | release/picobsd/tinyware/kget/uc_kmem.c | 87 | ||||
-rw-r--r-- | release/picobsd/tinyware/kget/uc_list.c | 76 | ||||
-rw-r--r-- | release/picobsd/tinyware/kget/uc_pci.c | 122 |
7 files changed, 5 insertions, 665 deletions
diff --git a/release/picobsd/tinyware/kget/Makefile b/release/picobsd/tinyware/kget/Makefile index d55e863..6a4c2b0 100644 --- a/release/picobsd/tinyware/kget/Makefile +++ b/release/picobsd/tinyware/kget/Makefile @@ -1,7 +1,8 @@ -# $Id: Makefile,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ +# $Id: Makefile,v 1.2 1998/09/19 21:40:38 abial Exp $ # 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 NOMAN=yes diff --git a/release/picobsd/tinyware/kget/README b/release/picobsd/tinyware/kget/README index 2acc5ea5..5432948 100644 --- a/release/picobsd/tinyware/kget/README +++ b/release/picobsd/tinyware/kget/README @@ -39,9 +39,10 @@ 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 go to Jordan K. Hubbard for 95% of this code. The rest is mine :-) +Credits (according to jkh) go to Eric L. Hernes for 95% of this code. The +rest is mine :-) Andrzej Bialecki <abial@nask.pl> -$Id: README,v 1.2 1998/08/11 06:53:21 abial Exp $ +$Id: README,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $ diff --git a/release/picobsd/tinyware/kget/uc_eisa.c b/release/picobsd/tinyware/kget/uc_eisa.c deleted file mode 100644 index c0483fc..0000000 --- a/release/picobsd/tinyware/kget/uc_eisa.c +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************** - * 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 deleted file mode 100644 index 6a5d750..0000000 --- a/release/picobsd/tinyware/kget/uc_isa.c +++ /dev/null @@ -1,211 +0,0 @@ -/*************************************************** - * 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 deleted file mode 100644 index 159fb15..0000000 --- a/release/picobsd/tinyware/kget/uc_kmem.c +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************** - * 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 deleted file mode 100644 index e2b6bd5..0000000 --- a/release/picobsd/tinyware/kget/uc_list.c +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************** - * 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_pci.c b/release/picobsd/tinyware/kget/uc_pci.c deleted file mode 100644 index 0d8e601..0000000 --- a/release/picobsd/tinyware/kget/uc_pci.c +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************** - * 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 */ |