xref: /minix/minix/lib/libsys/pci_set_acl.c (revision 433d6423)
1 /*
2 pci_set_acl.c
3 */
4 
5 #include "pci.h"
6 #include "syslib.h"
7 #include <unistd.h>
8 #include <minix/rs.h>
9 #include <minix/ds.h>
10 #include <minix/sysutil.h>
11 
12 /*===========================================================================*
13  *				pci_set_acl				     *
14  *===========================================================================*/
pci_set_acl(rs_pci)15 int pci_set_acl(rs_pci)
16 struct rs_pci *rs_pci;
17 {
18 	int r;
19 	cp_grant_id_t gid;
20 	message m;
21 	endpoint_t endpoint;
22 
23 	if (pci_procnr == ANY)
24 	{
25 		r= ds_retrieve_label_endpt("pci", &endpoint);
26 		if (r != 0)
27 		{
28 			panic("pci_set_acl: ds_retrieve_label_endpt failed for 'pci': %d", r);
29 		}
30 		pci_procnr = endpoint;
31 	}
32 
33 
34 	gid= cpf_grant_direct(pci_procnr, (vir_bytes)rs_pci, sizeof(*rs_pci),
35 		CPF_READ);
36 	if (gid == -1)
37 	{
38 		printf("pci_set_acl: cpf_grant_direct failed: %d\n",
39 			errno);
40 		return EINVAL;
41 	}
42 
43 	m.m_type= BUSC_PCI_SET_ACL;
44 	m.m1_i1= gid;
45 
46 	r= ipc_sendrec(pci_procnr, &m);
47 	cpf_revoke(gid);
48 	if (r != 0)
49 		panic("pci_set_acl: can't talk to PCI: %d", r);
50 
51 	return m.m_type;
52 }
53 
54