debuggers.hg

view xen/include/xen/grant_table.h @ 3515:d331c6994d28

bitkeeper revision 1.1159.223.12 (41f14d3cE4GADmEAEr6XE9nXX4dyGw)

Common-code cleanups. Moved arch-specific code out into arch/x86
and asm-x86.
author kaf24@scramble.cl.cam.ac.uk
date Fri Jan 21 18:43:08 2005 +0000 (2005-01-21)
parents 3f929065a1d1
children 46c14b1a4351
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 NR_GRANT_ENTRIES (PAGE_SIZE / sizeof(grant_entry_t))
56 /*
57 * Tracks a mapping of another domain's grant reference. Each domain has a
58 * table of these, indexes into which are returned as a 'mapping handle'.
59 */
60 typedef struct {
61 u16 ref_and_flags; /* 0-2: GNTMAP_* ; 3-15: grant ref */
62 domid_t domid; /* granting domain */
63 } grant_mapping_t;
64 #define MAPTRACK_GNTMAP_MASK 7
65 #define MAPTRACK_REF_SHIFT 3
66 #define NR_MAPTRACK_ENTRIES (PAGE_SIZE / sizeof(grant_mapping_t))
68 /* Per-domain grant information. */
69 typedef struct {
70 /* Shared grant table (see include/public/grant_table.h). */
71 grant_entry_t *shared;
72 /* Active grant table. */
73 active_grant_entry_t *active;
74 /* Mapping tracking table. */
75 grant_mapping_t *maptrack;
76 unsigned int maptrack_head;
77 /* Lock protecting updates to active and shared grant tables. */
78 spinlock_t lock;
79 } grant_table_t;
81 /* Start-of-day system initialisation. */
82 void grant_table_init(
83 void);
85 /* Create/destroy per-domain grant table context. */
86 int grant_table_create(
87 struct domain *d);
88 void grant_table_destroy(
89 struct domain *d);
91 /* Destroy host-CPU mappings via a grant-table entry. */
92 int gnttab_check_unmap(
93 struct domain *rd, struct domain *ld, unsigned long frame, int readonly);
95 /*
96 * Check that the given grant reference (rd,ref) allows 'ld' to transfer
97 * ownership of a page frame. If so, lock down the grant entry.
98 */
99 int
100 gnttab_prepare_for_transfer(
101 struct domain *rd, struct domain *ld, grant_ref_t ref);
103 /* Notify 'rd' of a completed transfer via an already-locked grant entry. */
104 void
105 gnttab_notify_transfer(
106 struct domain *rd, grant_ref_t ref, unsigned long frame);
108 #endif /* __XEN_GRANT_H__ */