X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fxen%2Fcore%2Fgnttab.c;h=66c980274e5602359e18c618b709a43d160accc1;hb=80e3949c1f04888da4f1a229f053e5f2f8bcb628;hp=a8dc7121099754bf09675f07826fa787ec615930;hpb=1a79f0f3331294fd3a9416fcabbf24470955e314;p=linux-2.6.git diff --git a/drivers/xen/core/gnttab.c b/drivers/xen/core/gnttab.c index a8dc71210..66c980274 100644 --- a/drivers/xen/core/gnttab.c +++ b/drivers/xen/core/gnttab.c @@ -31,7 +31,6 @@ * IN THE SOFTWARE. */ -#include #include #include #include @@ -41,6 +40,8 @@ #include #include #include +#include +#include /* External tools reserve first few grant table entries. */ #define NR_RESERVED_ENTRIES 8 @@ -350,6 +351,8 @@ void gnttab_cancel_free_callback(struct gnttab_free_callback *callback) } EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback); +#ifdef CONFIG_XEN + #ifndef __ia64__ static int map_pte_fn(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data) @@ -410,17 +413,53 @@ int gnttab_resume(void) int gnttab_suspend(void) { - #ifndef __ia64__ apply_to_page_range(&init_mm, (unsigned long)shared, PAGE_SIZE * NR_GRANT_FRAMES, unmap_pte_fn, NULL); #endif + return 0; +} + +#else /* !CONFIG_XEN */ + +#include +int gnttab_resume(void) +{ + unsigned long frames; + struct xen_add_to_physmap xatp; + unsigned int i; + + frames = alloc_xen_mmio(PAGE_SIZE * NR_GRANT_FRAMES); + + for (i = 0; i < NR_GRANT_FRAMES; i++) { + xatp.domid = DOMID_SELF; + xatp.idx = i; + xatp.space = XENMAPSPACE_grant_table; + xatp.gpfn = (frames >> PAGE_SHIFT) + i; + if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) + BUG(); + } + + shared = ioremap(frames, PAGE_SIZE * NR_GRANT_FRAMES); + if (shared == NULL) { + printk("error to ioremap gnttab share frames\n"); + return -1; + } + + return 0; +} + +int gnttab_suspend(void) +{ + iounmap(shared); return 0; } -static int __init gnttab_init(void) +#endif /* !CONFIG_XEN */ + +int __init gnttab_init(void) { int i; @@ -439,4 +478,6 @@ static int __init gnttab_init(void) return 0; } +#ifdef CONFIG_XEN core_initcall(gnttab_init); +#endif