1 /******************************************************************************
2  * include/xen/grant_table.h
3  *
4  * Mechanism for granting foreign access to page frames, and receiving
5  * page-ownership transfers.
6  *
7  * Copyright (c) 2004-2005 K A Fraser
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program 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
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef __XEN_GRANT_TABLE_H__
24 #define __XEN_GRANT_TABLE_H__
25 
26 #include <xen/mm.h>
27 #include <xen/rwlock.h>
28 #include <public/grant_table.h>
29 #include <asm/page.h>
30 #include <asm/grant_table.h>
31 
32 struct grant_table;
33 
34 /* Create/destroy per-domain grant table context. */
35 int grant_table_create(
36     struct domain *d);
37 void grant_table_destroy(
38     struct domain *d);
39 void grant_table_init_vcpu(struct vcpu *v);
40 int grant_table_set_limits(struct domain *d, unsigned int grant_frames,
41                            unsigned int maptrack_frames);
42 
43 /*
44  * Check if domain has active grants and log first 10 of them.
45  */
46 void grant_table_warn_active_grants(struct domain *d);
47 
48 /* Domain death release of granted mappings of other domains' memory. */
49 void
50 gnttab_release_mappings(
51     struct domain *d);
52 
53 int mem_sharing_gref_to_gfn(struct grant_table *gt, grant_ref_t ref,
54                             gfn_t *gfn, uint16_t *status);
55 
56 int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
57                      mfn_t *mfn);
58 
59 unsigned int gnttab_dom0_frames(void);
60 
61 #endif /* __XEN_GRANT_TABLE_H__ */
62