1 /***************************************************
2 * file: userconfig/uc_pci.c
4 * Copyright (c) 1996 Eric L. Hernes (erich@rrnet.com)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software withough specific prior written permission
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/types.h>
34 #include <pci/pcivar.h>
39 get_pci_info(struct kernel *kp){
42 struct pci_device *pd;
43 struct uc_pci *pp,*ppc;
46 if(kp->nl[PCI_SET].n_value){
47 pp = ppc = (struct uc_pci *)malloc(sizeof(struct uc_pci));
48 ls=(u_int *)kv_to_u(kp, kp->nl[PCI_SET].n_value, sizeof(u_int)*30); /* XXX, size? */
51 for(i=1;i<(ndev+1);i++){
52 pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1));
54 pd=(struct pci_device *)kv_to_u(kp, ls[i], sizeof(struct pci_device));
55 /* don't try to dereference a null pointer */
56 name=pd->pd_name ? (char *)kv_to_u(kp, (u_int)pd->pd_name, 10) :
57 pd->pd_name; /* XXX, size? */
60 /* incore, we can get unit numbers */
62 u=kv_dref_p(kp, (u_int)pd->pd_count);
63 for(k=0;k<u;k++,total++){
64 pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1));
66 asprintf(&ppc->device, "%s%d", name, k);
72 asprintf(&ppc->device, "%s?", name);
76 pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1));
78 bzero(ppc, sizeof(struct uc_pci));
81 kp->pci_devp=(struct uc_pci *)0;
87 get_pci_devlist(struct kernel *kp){
93 for(kdp=kp->pci_devp; kdp->device; kdp++){
94 list_append(dl, kdp->device);
101 get_pci_device(struct uc_pci *pp){
105 list_append(list, pp->device);
111 pci_free(struct kernel *kp, int writeback){
114 for(pp=kp->pci_devp;pp->device;pp++){
122 /* end of userconfig/uc_pci.c */