Uninitialized vector entry?
[minix3.git] / lib / syslib / pci_dev_name.c
blob0bc6f552c35d259f70d6728220b3041753035497
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[80]; /* 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("pci", "pci_dev_name: can't talk to PCI", r);
42 if (m.m_type == ENOENT)
44 printf("pci_dev_name: got no name\n");
45 return NULL; /* No name for this device */
47 if (m.m_type != 0)
48 panic("pci", "pci_dev_name: got bad reply from PCI", m.m_type);
50 name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
51 * terminated.
54 #if DEBUG
55 printf("pci_dev_name: got name %s\n", name);
56 #endif
57 return name;