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