/****************************************************************************** * grant_table.h * * Two sets of functionality: * 1. Granting foreign access to our memory reservation. * 2. Accessing others' memory reservations via grant references. * (i.e., mechanisms for both sender and recipient of grant references) * * Copyright (c) 2004-2005, K A Fraser * Copyright (c) 2005, Christopher Clark * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation; or, when distributed * separately from the Linux kernel or incorporated into other * software packages, subject to the following license: * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this source file (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE.
*/
/* * Technically there's no reliably invalid grant reference or grant handle, * so pick the value that is the most unlikely one to be observed valid.
*/ #define INVALID_GRANT_REF ((grant_ref_t)-1) #define INVALID_GRANT_HANDLE ((grant_handle_t)-1)
/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ #define NR_GRANT_FRAMES 4
int gnttab_init(void); int gnttab_suspend(void); int gnttab_resume(void);
int gnttab_grant_foreign_access(domid_t domid, unsignedlong frame, int readonly);
/* * End access through the given grant reference, iff the grant entry is no * longer in use. Return 1 if the grant entry was freed, 0 if it is still in * use.
*/ int gnttab_end_foreign_access_ref(grant_ref_t ref);
/* * Eventually end access through the given grant reference, and once that * access has been ended, free the given page too. Access will be ended * immediately iff the grant entry is not in use, otherwise it will happen * some time later. page may be NULL, in which case no freeing will occur. * Note that the granted page might still be accessed (read or write) by the * other side after gnttab_end_foreign_access() returns, so even if page was * specified as NULL it is not allowed to just reuse the page for other * purposes immediately. gnttab_end_foreign_access() will take an additional * reference to the granted page in this case, which is dropped only after * the grant is no longer in use. * This requires that multi page allocations for areas subject to * gnttab_end_foreign_access() are done via alloc_pages_exact() (and freeing * via free_pages_exact()) in order to avoid high order pages.
*/ void gnttab_end_foreign_access(grant_ref_t ref, struct page *page);
/* * End access through the given grant reference, iff the grant entry is * no longer in use. In case of success ending foreign access, the * grant reference is deallocated. * Return 1 if the grant entry was freed, 0 if it is still in use.
*/ int gnttab_try_end_foreign_access(grant_ref_t ref);
/* * operations on reserved batches of grant references
*/ int gnttab_alloc_grant_references(u16 count, grant_ref_t *pprivate_head);
int gnttab_alloc_grant_reference_seq(unsignedint count, grant_ref_t *first);
void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, unsignedlong frame, int readonly);
/* Give access to the first 4K of the page */ staticinlinevoid gnttab_page_grant_foreign_access_ref_one(
grant_ref_t ref, domid_t domid, struct page *page, int readonly)
{
gnttab_grant_foreign_access_ref(ref, domid, xen_page_to_gfn(page),
readonly);
}
#ifdef CONFIG_XEN_GRANT_DMA_ALLOC struct gnttab_dma_alloc_args { /* Device for which DMA memory will be/was allocated. */ struct device *dev; /* If set then DMA buffer is coherent and write-combine otherwise. */ bool coherent;
/* Perform a batch of grant map/copy operations. Retry every batch slot * for which the hypervisor returns GNTST_eagain. This is typically due * to paged out target frames. * * Will retry for 1, 2, ... 255 ms, i.e. 256 times during 32 seconds. * * Return value in each iand every status field of the batch guaranteed * to not be GNTST_eagain.
*/ void gnttab_batch_map(struct gnttab_map_grant_ref *batch, unsigned count); void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count);
/* Split Linux page in chunk of the size of the grant and call fn * * Parameters of fn: * gfn: guest frame number * offset: offset in the grant * len: length of the data in the grant. * data: internal information
*/ typedefvoid (*xen_grant_fn_t)(unsignedlong gfn, unsignedint offset, unsignedint len, void *data);
/* Helper to get to call fn only on the first "grant chunk" */ staticinlinevoid gnttab_for_one_grant(struct page *page, unsignedint offset, unsigned len, xen_grant_fn_t fn, void *data)
{ /* The first request is limited to the size of one grant */
len = min_t(unsignedint, XEN_PAGE_SIZE - (offset & ~XEN_PAGE_MASK),
len);
/* Get @nr_grefs grants from an array of page and call fn for each grant */ void gnttab_foreach_grant(struct page **pages, unsignedint nr_grefs,
xen_grant_fn_t fn, void *data);
/* Get the number of grant in a specified region * * start: Offset from the beginning of the first page * len: total length of data (can cross multiple page)
*/ staticinlineunsignedint gnttab_count_grant(unsignedint start, unsignedint len)
{ return XEN_PFN_UP(xen_offset_in_page(start) + len);
}
#endif/* __ASM_GNTTAB_H__ */
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.