From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiaofeng Ling Subject: [PATCH] make gnttab.c can be used in para-driver for unmodified guest Date: Mon, 05 Sep 2005 17:09:40 +0800 Message-ID: <431C0B54.8080300@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Pratt , Keir Fraser Cc: xen-devel List-Id: xen-devel@lists.xenproject.org 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 Signed-off-by: Arun Sharma 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 #include #include +#include #include #include #include +#ifndef CONFIG_XEN +#include +#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;