Xiaofeng Ling
2005-Sep-05 09:09 UTC
[Xen-devel] [PATCH] make gnttab.c can be used in para-driver for unmodified guest
make gnttab.c can be used in para-driver for unmodified guest changes are: 1. export one more symbols, include more files 2. A different implementation for setup grant table share page use ioremap to map the physical address returned by hypercall. 3. remove static for gnttab_init so that it can be called from module init function in event channel pci driver. Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com> Signed-off-by: Arun Sharma <arun.sharma@intel.com> diff -r 287d36b46fa3 linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c Tue Aug 30 20:36:49 2005 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c Fri Sep 2 22:47:27 2005 @@ -17,9 +17,13 @@ #include <asm/fixmap.h> #include <asm/uaccess.h> #include <asm-xen/xen_proc.h> +#include <xen-public/xen.h> #include <asm-xen/linux-public/privcmd.h> #include <asm-xen/gnttab.h> #include <asm-xen/synch_bitops.h> +#ifndef CONFIG_XEN +#include <asm/io.h> +#endif #if 1 #define ASSERT(_p) \ @@ -47,6 +51,7 @@ EXPORT_SYMBOL(gnttab_release_grant_reference); EXPORT_SYMBOL(gnttab_grant_foreign_access_ref); EXPORT_SYMBOL(gnttab_grant_foreign_transfer_ref); +EXPORT_SYMBOL(gnttab_request_free_callback); #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t)) #define GNTTAB_LIST_END (NR_GRANT_ENTRIES + 1) @@ -404,9 +409,19 @@ gnttab_resume(void) { gnttab_setup_table_t setup; +#ifdef CONFIG_XEN + int i; unsigned long frames[NR_GRANT_FRAMES]; - int i; - +#else + unsigned long *frames; + unsigned long alloc_xen_mmio(unsigned long len); + frames = (unsigned long *)alloc_xen_mmio(PAGE_SIZE * NR_GRANT_FRAMES); + shared = ioremap((unsigned long)frames, PAGE_SIZE * NR_GRANT_FRAMES); + if(!shared){ + printk("error to ioremap gnttab share frames\n"); + return -1; + } +#endif setup.dom = DOMID_SELF; setup.nr_frames = NR_GRANT_FRAMES; setup.frame_list = frames; @@ -414,8 +429,10 @@ BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1) != 0); BUG_ON(setup.status != 0); +#ifdef CONFIG_XEN for ( i = 0; i < NR_GRANT_FRAMES; i++ ) set_fixmap(FIX_GNTTAB_END - i, frames[i] << PAGE_SHIFT); +#endif return 0; } @@ -423,22 +440,27 @@ int gnttab_suspend(void) { +#ifdef CONFIG_XEN int i; for ( i = 0; i < NR_GRANT_FRAMES; i++ ) clear_fixmap(FIX_GNTTAB_END - i); - +#else + iounmap(shared); +#endif return 0; } -static int __init +int __init gnttab_init(void) { int i; BUG_ON(gnttab_resume()); +#ifdef CONFIG_XEN shared = (grant_entry_t *)fix_to_virt(FIX_GNTTAB_END); +#endif for ( i = 0; i < NR_GRANT_ENTRIES; i++ ) gnttab_list[i] = i + 1; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel