1 /******************************************************************************
2 * xc_physdev.c
3 *
4 * API for manipulating physical-device access permissions.
5 *
6 * Copyright (c) 2004, Rolf Neugebauer (Intel Research Cambridge)
7 * Copyright (c) 2004, K A Fraser (University of Cambridge)
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "xc_private.h"
24
xc_physdev_pci_access_modify(xc_interface * xch,uint32_t domid,int bus,int dev,int func,int enable)25 int xc_physdev_pci_access_modify(xc_interface *xch,
26 uint32_t domid,
27 int bus,
28 int dev,
29 int func,
30 int enable)
31 {
32 errno = ENOSYS;
33 return -1;
34 }
35
xc_physdev_map_pirq(xc_interface * xch,uint32_t domid,int index,int * pirq)36 int xc_physdev_map_pirq(xc_interface *xch,
37 uint32_t domid,
38 int index,
39 int *pirq)
40 {
41 int rc;
42 struct physdev_map_pirq map;
43
44 if ( !pirq )
45 {
46 errno = EINVAL;
47 return -1;
48 }
49 memset(&map, 0, sizeof(struct physdev_map_pirq));
50 map.domid = domid;
51 map.type = MAP_PIRQ_TYPE_GSI;
52 map.index = index;
53 map.pirq = *pirq < 0 ? index : *pirq;
54
55 rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
56
57 if ( !rc )
58 *pirq = map.pirq;
59
60 return rc;
61 }
62
xc_physdev_map_pirq_msi(xc_interface * xch,uint32_t domid,int index,int * pirq,int devfn,int bus,int entry_nr,uint64_t table_base)63 int xc_physdev_map_pirq_msi(xc_interface *xch,
64 uint32_t domid,
65 int index,
66 int *pirq,
67 int devfn,
68 int bus,
69 int entry_nr,
70 uint64_t table_base)
71 {
72 int rc;
73 struct physdev_map_pirq map;
74
75 if ( !pirq )
76 {
77 errno = EINVAL;
78 return -1;
79 }
80 memset(&map, 0, sizeof(struct physdev_map_pirq));
81 map.domid = domid;
82 map.type = MAP_PIRQ_TYPE_MSI;
83 map.index = index;
84 map.pirq = *pirq;
85 map.bus = bus;
86 map.devfn = devfn;
87 map.entry_nr = entry_nr;
88 map.table_base = table_base;
89
90 rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
91
92 if ( !rc )
93 *pirq = map.pirq;
94
95 return rc;
96 }
97
xc_physdev_unmap_pirq(xc_interface * xch,uint32_t domid,int pirq)98 int xc_physdev_unmap_pirq(xc_interface *xch,
99 uint32_t domid,
100 int pirq)
101 {
102 int rc;
103 struct physdev_unmap_pirq unmap;
104
105 memset(&unmap, 0, sizeof(struct physdev_unmap_pirq));
106 unmap.domid = domid;
107 unmap.pirq = pirq;
108
109 rc = do_physdev_op(xch, PHYSDEVOP_unmap_pirq, &unmap, sizeof(unmap));
110
111 return rc;
112 }
113
114