2 * Sharing page frames with other domains
5 #include "../port/lib.h"
11 Nframes = 1, // XXX don't increase this without setting up extra mappings in xengrant_init()
20 static grant_entry_t *granttab;
25 gnttab_setup_table_t setup;
26 ulong frames[Nframes];
29 setup.dom = DOMID_SELF;
30 setup.nr_frames = Nframes;
31 set_xen_guest_handle(setup.frame_list, frames);
32 if (HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1) != 0 || setup.status != 0)
33 panic("xen grant table setup");
34 granttab = (grant_entry_t*)mmumapframe(XENGRANTTAB, frames[0]);
35 nrefs = Nframes * BY2PG / sizeof(grant_entry_t);
36 refalloc.refs = (ushort*)malloc(nrefs*sizeof(ushort));
37 for (i = 0; i < nrefs; i++)
38 refalloc.refs[i] = i-1;
39 refalloc.free = nrefs-1;
50 refalloc.free = refalloc.refs[ref];
59 refalloc.refs[ref] = refalloc.free;
65 xengrant(domid_t domid, ulong frame, int flags)
70 if ((ref = allocref()) < 0)
71 panic("out of xengrant refs");
88 if (gt->flags>F_accept_transfer) {
89 if ((gt->flags>F_transfer_completed) == 0)
90 panic("xengrantend transfer in progress");
92 if (gt->flags&(GTF_reading|GTF_writing))
93 panic("xengrantend frame in use");
97 gt->flags = GTF_invalid;