move benchmarks to their own dir.
[minix.git] / lib / syslib / pci_dev_name.c
blob3469205ebbb3a9a7411d9ba1424b1b3d6bdb81ad
1 /*
2 pci_dev_name.c
3 */
5 #include "pci.h"
6 #include "syslib.h"
7 #include <minix/sysutil.h>
9 /*===========================================================================*
10 * pci_dev_name *
11 *===========================================================================*/
12 PUBLIC char *pci_dev_name(vid, did)
13 u16_t vid;
14 u16_t did;
16 static char name[PCIINFO_ENTRY_SIZE]; /* We need a better interface for this */
18 int r;
19 cp_grant_id_t gid;
20 message m;
22 gid= cpf_grant_direct(pci_procnr, (vir_bytes)name, sizeof(name),
23 CPF_WRITE);
24 if (gid == -1)
26 printf("pci_dev_name: cpf_grant_direct failed: %d\n",
27 errno);
28 return NULL;
31 m.m_type= BUSC_PCI_DEV_NAME_S;
32 m.m7_i1= vid;
33 m.m7_i2= did;
34 m.m7_i3= sizeof(name);
35 m.m7_i4= gid;
37 r= sendrec(pci_procnr, &m);
38 cpf_revoke(gid);
39 if (r != 0)
40 panic("syslib/" __FILE__, "pci_dev_name: can't talk to PCI", r);
42 if (m.m_type == ENOENT)
44 #if DEBUG
45 printf("pci_dev_name: got no name\n");
46 #endif
47 return NULL; /* No name for this device */
49 if (m.m_type != 0)
50 panic("syslib/" __FILE__, "pci_dev_name: got bad reply from PCI", m.m_type);
52 name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
53 * terminated.
56 #if DEBUG
57 printf("pci_dev_name: got name %s\n", name);
58 #endif
59 return name;