ia64/xen-unstable

view xen/include/xen/grant_table.h @ 6538:84ee014ebd41

Merge xen-vtx-unstable.hg
author adsharma@los-vmm.sc.intel.com
date Wed Aug 17 12:34:38 2005 -0800 (2005-08-17)
parents 23979fb12c49 c1bcea912992
children 99914b54f7bf
line source
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 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, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
24 #ifndef __XEN_GRANT_H__
25 #define __XEN_GRANT_H__
27 #include <xen/config.h>
28 #include <public/grant_table.h>
30 /* Active grant entry - used for shadowing GTF_permit_access grants. */
31 typedef struct {
32 u32 pin; /* Reference count information. */
33 domid_t domid; /* Domain being granted access. */
34 unsigned long frame; /* Frame being granted. */
35 } active_grant_entry_t;
37 /* Count of writable host-CPU mappings. */
38 #define GNTPIN_hstw_shift (0)
39 #define GNTPIN_hstw_inc (1 << GNTPIN_hstw_shift)
40 #define GNTPIN_hstw_mask (0xFFU << GNTPIN_hstw_shift)
41 /* Count of read-only host-CPU mappings. */
42 #define GNTPIN_hstr_shift (8)
43 #define GNTPIN_hstr_inc (1 << GNTPIN_hstr_shift)
44 #define GNTPIN_hstr_mask (0xFFU << GNTPIN_hstr_shift)
45 /* Count of writable device-bus mappings. */
46 #define GNTPIN_devw_shift (16)
47 #define GNTPIN_devw_inc (1 << GNTPIN_devw_shift)
48 #define GNTPIN_devw_mask (0xFFU << GNTPIN_devw_shift)
49 /* Count of read-only device-bus mappings. */
50 #define GNTPIN_devr_shift (24)
51 #define GNTPIN_devr_inc (1 << GNTPIN_devr_shift)
52 #define GNTPIN_devr_mask (0xFFU << GNTPIN_devr_shift)
54 #define ORDER_GRANT_FRAMES 2
55 #define NR_GRANT_FRAMES (1U << ORDER_GRANT_FRAMES)
56 #define NR_GRANT_ENTRIES \
57 ((NR_GRANT_FRAMES << PAGE_SHIFT) / sizeof(grant_entry_t))
59 /*
60 * Tracks a mapping of another domain's grant reference. Each domain has a
61 * table of these, indexes into which are returned as a 'mapping handle'.
62 */
63 typedef struct {
64 u16 ref_and_flags; /* 0-4: GNTMAP_* ; 5-15: grant ref */
65 domid_t domid; /* granting domain */
66 } grant_mapping_t;
67 #define MAPTRACK_GNTMAP_MASK 0x1f
68 #define MAPTRACK_REF_SHIFT 5
69 #define MAPTRACK_MAX_ENTRIES (1 << (16 - MAPTRACK_REF_SHIFT))
71 /* Per-domain grant information. */
72 typedef struct {
73 /* Shared grant table (see include/public/grant_table.h). */
74 grant_entry_t *shared;
75 /* Active grant table. */
76 active_grant_entry_t *active;
77 /* Mapping tracking table. */
78 grant_mapping_t *maptrack;
79 unsigned int maptrack_head;
80 unsigned int maptrack_order;
81 unsigned int maptrack_limit;
82 unsigned int map_count;
83 /* Lock protecting updates to active and shared grant tables. */
84 spinlock_t lock;
85 } grant_table_t;
87 /* Start-of-day system initialisation. */
88 void grant_table_init(
89 void);
91 /* Create/destroy per-domain grant table context. */
92 int grant_table_create(
93 struct domain *d);
94 void grant_table_destroy(
95 struct domain *d);
97 /* Destroy host-CPU mappings via a grant-table entry. */
98 int gnttab_check_unmap(
99 struct domain *rd, struct domain *ld, unsigned long frame, int readonly);
101 /*
102 * Check that the given grant reference (rd,ref) allows 'ld' to transfer
103 * ownership of a page frame. If so, lock down the grant entry.
104 */
105 int
106 gnttab_prepare_for_transfer(
107 struct domain *rd, struct domain *ld, grant_ref_t ref);
109 /* Notify 'rd' of a completed transfer via an already-locked grant entry. */
110 void
111 gnttab_notify_transfer(
112 struct domain *rd, struct domain *ld,
113 grant_ref_t ref, unsigned long frame);
115 /* Domain death release of granted device mappings of other domains.*/
116 void
117 gnttab_release_dev_mappings(grant_table_t *gt);
119 /* Extra GNTST_ values, for internal use only. */
120 #define GNTST_flush_all (2) /* Success, need to flush entire TLB. */
121 #define GNTST_flush_one (1) /* Success, need to flush a vaddr. */
123 #endif /* __XEN_GRANT_H__ */