1 /* 2 pci_slot_name.c 3 */ 4 5 #include "pci.h" 6 #include "syslib.h" 7 #include <minix/sysutil.h> 8 9 /*===========================================================================* 10 * pci_slot_name * 11 *===========================================================================*/ 12 char *pci_slot_name(devind) 13 int devind; 14 { 15 static char name[80]; /* We need a better interface for this */ 16 17 int r; 18 cp_grant_id_t gid; 19 message m; 20 21 gid= cpf_grant_direct(pci_procnr, (vir_bytes)name, sizeof(name), 22 CPF_WRITE); 23 if (gid == -1) 24 { 25 printf("pci_dev_name: cpf_grant_direct failed: %d\n", 26 errno); 27 return NULL; 28 } 29 30 m.m_type= BUSC_PCI_SLOT_NAME_S; 31 m.m1_i1= devind; 32 m.m1_i2= sizeof(name); 33 m.m1_i3= gid; 34 35 r= ipc_sendrec(pci_procnr, &m); 36 cpf_revoke(gid); 37 if (r != 0) 38 panic("pci_slot_name: can't talk to PCI: %d", r); 39 40 if (m.m_type != 0) 41 panic("pci_slot_name: got bad reply from PCI: %d", m.m_type); 42 43 name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL 44 * terminated. 45 */ 46 return name; 47 } 48 49