xref: /minix/minix/lib/libsys/pci_find_dev.c (revision 7f5f010b)
1 /*
2 pci_find_dev.c
3 */
4 
5 #include "pci.h"
6 #include "syslib.h"
7 #include <minix/sysutil.h>
8 
9 /*===========================================================================*
10  *				pci_find_dev				     *
11  *===========================================================================*/
12 int pci_find_dev(u8_t bus, u8_t dev, u8_t func, int *devindp)
13 {
14 	int r;
15 	message m;
16 
17 	m.m_type= BUSC_PCI_FIND_DEV;
18 	m.m1_i1= bus;
19 	m.m1_i2= dev;
20 	m.m1_i3= func;
21 
22 	r= ipc_sendrec(pci_procnr, &m);
23 	if (r != 0)
24 		panic("pci_find_dev: can't talk to PCI: %d", r);
25 
26 	if (m.m_type == 1)
27 	{
28 		*devindp= m.m1_i1;
29 		printf("pci_find_dev: got device %d for %d.%d.%d\n",
30 			*devindp, bus, dev, func);
31 		return 1;
32 	}
33 	if (m.m_type != 0)
34 		panic("pci_find_dev: got bad reply from PCI: %d", m.m_type);
35 
36 	printf("pci_find_dev: got nothing\n");
37 	return 0;
38 }
39 
40