ia64/xen-unstable

changeset 8250:002a8b5c98bb

Add map_domain_pages/unmap_domain_pages to map contiguous
multi-franme extents of domain memory.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Dec 06 15:52:51 2005 +0100 (2005-12-06)
parents c976c1ff806a
children 198828cc103b
files xen/arch/x86/x86_32/domain_page.c xen/include/xen/domain_page.h
line diff
     1.1 --- a/xen/arch/x86/x86_32/domain_page.c	Tue Dec 06 15:52:15 2005 +0100
     1.2 +++ b/xen/arch/x86/x86_32/domain_page.c	Tue Dec 06 15:52:51 2005 +0100
     1.3 @@ -40,10 +40,10 @@ static void flush_all_ready_maps(void)
     1.4              cache[i] = l1e_empty();
     1.5  }
     1.6  
     1.7 -void *map_domain_page(unsigned long pfn)
     1.8 +void *map_domain_pages(unsigned long pfn, unsigned int order)
     1.9  {
    1.10      unsigned long va;
    1.11 -    unsigned int idx, cpu = smp_processor_id();
    1.12 +    unsigned int idx, i, flags, cpu = smp_processor_id();
    1.13      l1_pgentry_t *cache = mapcache;
    1.14  #ifndef NDEBUG
    1.15      unsigned int flush_count = 0;
    1.16 @@ -72,10 +72,15 @@ void *map_domain_page(unsigned long pfn)
    1.17              local_flush_tlb();
    1.18              shadow_epoch[cpu] = ++epoch;
    1.19          }
    1.20 +
    1.21 +        flags = 0;
    1.22 +        for ( i = 0; i < (1U << order); i++ )
    1.23 +            flags |= l1e_get_flags(cache[idx+i]);
    1.24      }
    1.25 -    while ( l1e_get_flags(cache[idx]) & _PAGE_PRESENT );
    1.26 +    while ( flags & _PAGE_PRESENT );
    1.27  
    1.28 -    cache[idx] = l1e_from_pfn(pfn, __PAGE_HYPERVISOR);
    1.29 +    for ( i = 0; i < (1U << order); i++ )
    1.30 +        cache[idx+i] = l1e_from_pfn(pfn+i, __PAGE_HYPERVISOR);
    1.31  
    1.32      spin_unlock(&map_lock);
    1.33  
    1.34 @@ -83,11 +88,12 @@ void *map_domain_page(unsigned long pfn)
    1.35      return (void *)va;
    1.36  }
    1.37  
    1.38 -void unmap_domain_page(void *va)
    1.39 +void unmap_domain_pages(void *va, unsigned int order)
    1.40  {
    1.41 -    unsigned int idx;
    1.42 +    unsigned int idx, i;
    1.43      ASSERT((void *)MAPCACHE_VIRT_START <= va);
    1.44      ASSERT(va < (void *)MAPCACHE_VIRT_END);
    1.45      idx = ((unsigned long)va - MAPCACHE_VIRT_START) >> PAGE_SHIFT;
    1.46 -    l1e_add_flags(mapcache[idx], READY_FOR_TLB_FLUSH);
    1.47 +    for ( i = 0; i < (1U << order); i++ )
    1.48 +        l1e_add_flags(mapcache[idx+i], READY_FOR_TLB_FLUSH);
    1.49  }
     2.1 --- a/xen/include/xen/domain_page.h	Tue Dec 06 15:52:15 2005 +0100
     2.2 +++ b/xen/include/xen/domain_page.h	Tue Dec 06 15:52:51 2005 +0100
     2.3 @@ -10,19 +10,22 @@
     2.4  #include <xen/config.h>
     2.5  #include <xen/mm.h>
     2.6  
     2.7 +#define map_domain_page(pfn)   map_domain_pages(pfn,0)
     2.8 +#define unmap_domain_page(va)  unmap_domain_pages(va,0)
     2.9 +
    2.10  #ifdef CONFIG_DOMAIN_PAGE
    2.11  
    2.12  /*
    2.13 - * Maps a given page frame, returning the mmap'ed virtual address. The page is 
    2.14 - * now accessible until a corresponding call to unmap_domain_page().
    2.15 + * Maps a given range of page frames, returning the mapped virtual address. The
    2.16 + * pages are now accessible until a corresponding call to unmap_domain_page().
    2.17   */
    2.18 -extern void *map_domain_page(unsigned long pfn);
    2.19 +extern void *map_domain_pages(unsigned long pfn, unsigned int order);
    2.20  
    2.21  /*
    2.22 - * Pass a VA within a page previously mapped with map_domain_page().
    2.23 - * That page will then be removed from the mapping lists.
    2.24 + * Pass a VA within the first page of a range previously mapped with
    2.25 + * map_omain_pages(). Those pages will then be removed from the mapping lists.
    2.26   */
    2.27 -extern void unmap_domain_page(void *va);
    2.28 +extern void unmap_domain_pages(void *va, unsigned int order);
    2.29  
    2.30  #define DMCACHE_ENTRY_VALID 1U
    2.31  #define DMCACHE_ENTRY_HELD  2U
    2.32 @@ -84,8 +87,8 @@ domain_mmap_cache_destroy(struct domain_
    2.33  
    2.34  #else /* !CONFIG_DOMAIN_PAGE */
    2.35  
    2.36 -#define map_domain_page(pfn)                phys_to_virt((pfn)<<PAGE_SHIFT)
    2.37 -#define unmap_domain_page(va)               ((void)(va))
    2.38 +#define map_domain_pages(pfn,order)         phys_to_virt((pfn)<<PAGE_SHIFT)
    2.39 +#define unmap_domain_pages(va,order)        ((void)((void)(va),(void)(order)))
    2.40  
    2.41  struct domain_mmap_cache { 
    2.42  };