ia64/xen-unstable

changeset 9978:5f0bdd0ef9dc

[IA64] linux: drivers/xen/util.c for ia64

xen/ia64 counter part of linux-2.6-xen-sparse/drivers/xen/util.c

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Tue May 09 11:46:00 2006 -0600 (2006-05-09)
parents e891c49c7bc0
children 873a3451a81a
files linux-2.6-xen-sparse/arch/ia64/xen/Makefile linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile linux-2.6-xen-sparse/arch/ia64/xen/util.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Tue May 09 11:44:26 2006 -0600
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Tue May 09 11:46:00 2006 -0600
     1.3 @@ -4,5 +4,5 @@
     1.4  
     1.5  obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o xen_ksyms.o
     1.6  
     1.7 -obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o
     1.8 +obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o util.o
     1.9  pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
    1.10 \ No newline at end of file
     2.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile	Tue May 09 11:44:26 2006 -0600
     2.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile	Tue May 09 11:46:00 2006 -0600
     2.3 @@ -1,5 +1,7 @@
     2.4  
     2.5 +ifneq ($(CONFIG_XEN_IA64_DOM0_VP),y)
     2.6  obj-y   += util.o
     2.7 +endif
     2.8  
     2.9  obj-y	+= core/
    2.10  obj-y	+= console/
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Tue May 09 11:46:00 2006 -0600
     3.3 @@ -0,0 +1,110 @@
     3.4 +/******************************************************************************
     3.5 + * arch/ia64/xen/util.c
     3.6 + * This file is the ia64 counterpart of drivers/xen/util.c
     3.7 + *
     3.8 + * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
     3.9 + *                    VA Linux Systems Japan K.K.
    3.10 + *
    3.11 + * This program is free software; you can redistribute it and/or modify
    3.12 + * it under the terms of the GNU General Public License as published by
    3.13 + * the Free Software Foundation; either version 2 of the License, or
    3.14 + * (at your option) any later version.
    3.15 + *
    3.16 + * This program is distributed in the hope that it will be useful,
    3.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.19 + * GNU General Public License for more details.
    3.20 + *
    3.21 + * You should have received a copy of the GNU General Public License
    3.22 + * along with this program; if not, write to the Free Software
    3.23 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.24 + *
    3.25 + */
    3.26 +
    3.27 +#include <linux/config.h>
    3.28 +#include <linux/mm.h>
    3.29 +#include <linux/module.h>
    3.30 +#include <linux/slab.h>
    3.31 +#include <linux/vmalloc.h>
    3.32 +#include <asm/uaccess.h>
    3.33 +#include <xen/driver_util.h>
    3.34 +
    3.35 +struct vm_struct *alloc_vm_area(unsigned long size)
    3.36 +{
    3.37 +	int order;
    3.38 +	unsigned long virt;
    3.39 +	unsigned long nr_pages;
    3.40 +	struct vm_struct* area;
    3.41 +	
    3.42 +	order = get_order(size);
    3.43 +	virt = __get_free_pages(GFP_KERNEL, order);
    3.44 +	if (virt == 0) {
    3.45 +		goto err0;
    3.46 +	}
    3.47 +	nr_pages = 1 << order;
    3.48 +	scrub_pages(virt, nr_pages);
    3.49 +	
    3.50 +	area = kmalloc(sizeof(*area), GFP_KERNEL);
    3.51 +	if (area == NULL) {
    3.52 +		goto err1;
    3.53 +	}
    3.54 +	
    3.55 +        area->flags = VM_IOREMAP;//XXX
    3.56 +        area->addr = (void*)virt;
    3.57 +        area->size = size;
    3.58 +        area->pages = NULL; //XXX
    3.59 +        area->nr_pages = nr_pages;
    3.60 +        area->phys_addr = __pa(virt);
    3.61 +
    3.62 +	return area;
    3.63 +
    3.64 +err1:
    3.65 +	free_pages(virt, order);
    3.66 +err0:
    3.67 +	return NULL;
    3.68 +	
    3.69 +}
    3.70 +EXPORT_SYMBOL_GPL(alloc_vm_area);
    3.71 +
    3.72 +void free_vm_area(struct vm_struct *area)
    3.73 +{
    3.74 +	unsigned int order = get_order(area->size);
    3.75 +	unsigned long i;
    3.76 +
    3.77 +	// This area is used for foreign page mappping.
    3.78 +	// So underlying machine page may not be assigned.
    3.79 +	for (i = 0; i < (1 << order); i++) {
    3.80 +		unsigned long error;
    3.81 +		error = HYPERVISOR_populate_physmap(
    3.82 +			(area->phys_addr >> PAGE_SHIFT) + i, 0, 0);
    3.83 +		if (error) {
    3.84 +			BUG();//XXX
    3.85 +			return;
    3.86 +		}
    3.87 +	}
    3.88 +	free_pages((unsigned long)area->addr, order);
    3.89 +	kfree(area);
    3.90 +}
    3.91 +EXPORT_SYMBOL_GPL(free_vm_area);
    3.92 +
    3.93 +void lock_vm_area(struct vm_struct *area)
    3.94 +{
    3.95 +	// nothing
    3.96 +}
    3.97 +EXPORT_SYMBOL_GPL(lock_vm_area);
    3.98 +
    3.99 +void unlock_vm_area(struct vm_struct *area)
   3.100 +{
   3.101 +	// nothing
   3.102 +}
   3.103 +EXPORT_SYMBOL_GPL(unlock_vm_area);
   3.104 +
   3.105 +/*
   3.106 + * Local variables:
   3.107 + *  c-file-style: "linux"
   3.108 + *  indent-tabs-mode: t
   3.109 + *  c-indent-level: 8
   3.110 + *  c-basic-offset: 8
   3.111 + *  tab-width: 8
   3.112 + * End:
   3.113 + */