Remove building with NOCRYPTO option
[minix.git] / minix / lib / libsys / pci_dev_name.c
blob72548e2d129259e52c17caa167c6baf7edfbe8a2
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 char *pci_dev_name(u16_t vid, u16_t did)
14 static char name[80]; /* We need a better interface for this */
16 int r;
17 cp_grant_id_t gid;
18 message m;
20 gid= cpf_grant_direct(pci_procnr, (vir_bytes)name, sizeof(name),
21 CPF_WRITE);
22 if (gid == -1)
24 printf("pci_dev_name: cpf_grant_direct failed: %d\n",
25 errno);
26 return NULL;
29 m.m_type= BUSC_PCI_DEV_NAME_S;
30 m.m7_i1= vid;
31 m.m7_i2= did;
32 m.m7_i3= sizeof(name);
33 m.m7_i4= gid;
35 r= ipc_sendrec(pci_procnr, &m);
36 cpf_revoke(gid);
37 if (r != 0)
38 panic("pci_dev_name: can't talk to PCI: %d", r);
40 if (m.m_type == ENOENT)
42 #ifdef DEBUG
43 printf("pci_dev_name: got no name\n");
44 #endif
45 return NULL; /* No name for this device */
47 if (m.m_type != 0)
48 panic("pci_dev_name: got bad reply from PCI: %d", m.m_type);
50 name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
51 * terminated.
54 #ifdef DEBUG
55 printf("pci_dev_name: got name %s\n", name);
56 #endif
57 return name;