ia64/xen-unstable

changeset 547:c917764fdbc0

bitkeeper revision 1.303.1.1 (3f0ad7bb7chMizq8X4T9zaX-xWILmA)

Misc. minor code cleanups.
author sos22@labyrinth.cl.cam.ac.uk
date Tue Jul 08 14:39:55 2003 +0000 (2003-07-08)
parents 43143729d373
children 7ddc307ecc6a
files xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_memory.c
line diff
     1.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c	Tue Jul 08 14:13:58 2003 +0000
     1.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c	Tue Jul 08 14:39:55 2003 +0000
     1.3 @@ -38,20 +38,14 @@ typedef struct proc_data {
     1.4      unsigned long map_size;
     1.5  } dom_procdata_t;
     1.6  
     1.7 -typedef struct proc_mem_data {
     1.8 -    unsigned long pfn;
     1.9 -    int tot_pages;
    1.10 -} proc_memdata_t;
    1.11 -
    1.12 -#define MAP_DISCONT     1
    1.13 -
    1.14 +/* XXX this certainly shouldn't be here. */
    1.15  extern struct file_operations dom0_phd_fops;
    1.16  
    1.17  struct proc_dir_entry *xeno_base;
    1.18  static struct proc_dir_entry *dom0_cmd_intf;
    1.19  static struct proc_dir_entry *dom_list_intf;
    1.20  
    1.21 -unsigned long direct_mmap(unsigned long, unsigned long, pgprot_t, int, int);
    1.22 +unsigned long direct_mmap(unsigned long, unsigned long, pgprot_t, int);
    1.23  int direct_unmap(unsigned long, unsigned long);
    1.24  int direct_disc_unmap(unsigned long, unsigned long, int);
    1.25  
    1.26 @@ -113,7 +107,7 @@ static ssize_t dom_usage_read(struct fil
    1.27      return end + 1;
    1.28  }
    1.29  
    1.30 -struct file_operations dom_usage_ops = {
    1.31 +static struct file_operations dom_usage_ops = {
    1.32      read:    dom_usage_read
    1.33  };
    1.34  
    1.35 @@ -152,113 +146,6 @@ static void create_proc_dom_entries(int 
    1.36      }
    1.37  }
    1.38  
    1.39 -static ssize_t dom_mem_write(struct file * file, const char * buff, 
    1.40 -                             size_t size , loff_t * off)
    1.41 -{
    1.42 -    dom_mem_t mem_data;
    1.43 -    
    1.44 -    printk("dom_mem_write called: Shouldn't happen.\n");
    1.45 -
    1.46 -    copy_from_user(&mem_data, (dom_mem_t *)buff, sizeof(dom_mem_t));
    1.47 -    
    1.48 -    if(direct_disc_unmap(mem_data.vaddr, mem_data.start_pfn, 
    1.49 -                         mem_data.tot_pages) == 0){
    1.50 -        return sizeof(sizeof(dom_mem_t));
    1.51 -    } else {
    1.52 -        return -1;
    1.53 -    }
    1.54 -}
    1.55 -
    1.56 -static ssize_t dom_mem_read(struct file * file, char * buff, size_t size, loff_t * off)
    1.57 -{
    1.58 -    unsigned long addr;
    1.59 -    pgprot_t prot;
    1.60 -
    1.61 -    proc_memdata_t * mem_data = (proc_memdata_t *)((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
    1.62 -
    1.63 -    prot = PAGE_SHARED; 
    1.64 -
    1.65 -    /* remap the range using xen specific routines */
    1.66 -
    1.67 -    printk("Calling direct_mmap with pfn %x, tot pages %x.\n",
    1.68 -	   mem_data->pfn, mem_data->tot_pages);
    1.69 -
    1.70 -    addr = direct_mmap(mem_data->pfn << PAGE_SHIFT, mem_data->tot_pages << PAGE_SHIFT, prot, MAP_DISCONT, mem_data->tot_pages);
    1.71 -    
    1.72 -    copy_to_user((unsigned long *)buff, &addr, sizeof(addr));
    1.73 -
    1.74 -    return sizeof(addr);
    1.75 -}
    1.76 -
    1.77 -struct file_operations dom_mem_ops = {
    1.78 -    read:    dom_mem_read,
    1.79 -    write:   dom_mem_write,
    1.80 -};
    1.81 -
    1.82 -static int dom_map_mem(unsigned int dom, unsigned long pfn, int tot_pages)
    1.83 -{
    1.84 -    int ret = -ENOENT;
    1.85 -    struct proc_dir_entry * pd = xeno_base->subdir;
    1.86 -    struct proc_dir_entry * file;
    1.87 -    proc_memdata_t * memdata;
    1.88 -
    1.89 -    while(pd != NULL){
    1.90 -
    1.91 -        if((pd->mode & S_IFDIR) && ((dom_procdata_t *)pd->data)->domain == dom){
    1.92 -
    1.93 -            /* check if there is already an entry for mem and if so
    1.94 -             * remove it.
    1.95 -             */
    1.96 -	    /* XXX does this not leak the memdata? */
    1.97 -            remove_proc_entry("mem", pd);
    1.98 -
    1.99 -            /* create new entry with parameters describing what to do
   1.100 -             * when it is mmaped.
   1.101 -             */
   1.102 -            file = create_proc_entry("mem", 0600, pd);
   1.103 -            if(file != NULL)
   1.104 -            {
   1.105 -                file->owner = THIS_MODULE;
   1.106 -                file->nlink = 1;
   1.107 -                file->proc_fops = &dom_mem_ops;
   1.108 -
   1.109 -                memdata = (proc_memdata_t *)kmalloc(sizeof(proc_memdata_t), GFP_KERNEL);
   1.110 -                memdata->pfn = pfn;
   1.111 -                memdata->tot_pages = tot_pages;
   1.112 -                file->data = memdata;
   1.113 -
   1.114 -                ret = 0;
   1.115 -                break;
   1.116 -            }
   1.117 -
   1.118 -            ret = -EAGAIN;
   1.119 -            break;
   1.120 -        }                    
   1.121 -        pd = pd->next;
   1.122 -    }
   1.123 -
   1.124 -    return ret;
   1.125 -}
   1.126 -
   1.127 -/* function used to retrieve data associated with new domain */
   1.128 -static ssize_t dom_data_read(struct file * file, char * buff, size_t size, loff_t * off)
   1.129 -{
   1.130 -    dom0_newdomain_t * dom_data = (dom0_newdomain_t *)
   1.131 -        ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
   1.132 -
   1.133 -    copy_to_user((dom0_newdomain_t *)buff, dom_data, sizeof(dom0_newdomain_t));
   1.134 -
   1.135 -    remove_proc_entry("new_dom_data", xeno_base);
   1.136 -
   1.137 -    kfree(dom_data);
   1.138 -
   1.139 -    return sizeof(dom0_newdomain_t);
   1.140 -}
   1.141 -
   1.142 -struct file_operations newdom_data_fops = {
   1.143 -    read:    dom_data_read,
   1.144 -};
   1.145 -
   1.146  static int dom0_cmd_write(struct file *file, const char *buffer, size_t size,
   1.147  			  loff_t *off)
   1.148  {
   1.149 @@ -269,12 +156,9 @@ static int dom0_cmd_write(struct file *f
   1.150  
   1.151      if ( op.cmd == MAP_DOM_MEM )
   1.152      {
   1.153 -        ret = dom_map_mem(op.u.dommem.domain, op.u.dommem.start_pfn, 
   1.154 -                          op.u.dommem.tot_pages); 
   1.155 -      /* This is now an ioctl, and shouldn't be being written to
   1.156 -	 the command file. */
   1.157 -	//      printk("map_dom_mem dom0_cmd used!\n");
   1.158 -	//      ret = -EOPNOTSUPP;
   1.159 +        /* This is now an ioctl, and shouldn't be being written to the
   1.160 +	   command file. */
   1.161 +        ret = -EOPNOTSUPP;
   1.162      }
   1.163      else if ( op.cmd == DO_PGUPDATES )
   1.164      {
   1.165 @@ -371,7 +255,7 @@ static int xeno_domains_show(struct seq_
   1.166      return 0;
   1.167  }
   1.168  
   1.169 -struct seq_operations xeno_domains_op = {
   1.170 +static struct seq_operations xeno_domains_op = {
   1.171      .start          = xeno_domains_start,
   1.172      .next           = xeno_domains_next,
   1.173      .stop           = xeno_domains_stop,
   1.174 @@ -403,7 +287,8 @@ static int handle_dom0_cmd_createdomain(
   1.175    op.cmd = DOM0_CREATEDOMAIN;
   1.176    op.u.newdomain.domain = -666;
   1.177    op.u.newdomain.memory_kb = argbuf.kb_mem;
   1.178 -  op.u.newdomain.num_vifs = 0; /* Not used anymore, I hope... */
   1.179 +  op.u.newdomain.num_vifs = 0; /* Not used anymore -- it's done in
   1.180 +				  BUILDDOMAIN. */
   1.181    namelen = strnlen_user(argbuf.name, MAX_DOMAIN_NAME);
   1.182    if (copy_from_user(op.u.newdomain.name, argbuf.name, namelen + 1))
   1.183      return -EFAULT;
   1.184 @@ -438,19 +323,13 @@ static unsigned long handle_dom0_cmd_map
   1.185      return -EFAULT;
   1.186    /* This seems to be assuming that the root of the page table is in
   1.187       the first frame of the new domain's physical memory? */
   1.188 -  /* XXX do I really mean this? */
   1.189    /* XXX what happens if userspace forgets to do the unmap? */
   1.190 -  printk("direct_maping w/ start pfn %x, tot_pages %x.\n",
   1.191 -	 argbuf.start_pfn, argbuf.tot_pages);
   1.192  
   1.193    addr = direct_mmap(argbuf.start_pfn << PAGE_SHIFT,
   1.194  		     argbuf.tot_pages << PAGE_SHIFT,
   1.195  		     PAGE_SHARED,
   1.196 -		     MAP_DISCONT,
   1.197  		     argbuf.tot_pages);
   1.198  
   1.199 -  printk("Picked vaddr %x.\n", addr);
   1.200 -
   1.201    return addr;
   1.202  }
   1.203  
     2.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Tue Jul 08 14:13:58 2003 +0000
     2.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Tue Jul 08 14:39:55 2003 +0000
     2.3 @@ -16,9 +16,6 @@
     2.4  
     2.5  #include "dom0_ops.h"
     2.6  
     2.7 -#define MAP_CONT    0
     2.8 -#define MAP_DISCONT 1
     2.9 -
    2.10  extern struct list_head * find_direct(struct list_head *, unsigned long);
    2.11  
    2.12  /*
    2.13 @@ -165,24 +162,20 @@ out:
    2.14   */
    2.15  
    2.16  unsigned long direct_mmap(unsigned long phys_addr, unsigned long size, 
    2.17 -                pgprot_t prot, int flag, int tot_pages)
    2.18 +			  pgprot_t prot, int tot_pages)
    2.19  {
    2.20      direct_mmap_node_t * dmmap;
    2.21      struct list_head * entry;
    2.22      unsigned long addr;
    2.23      int ret = 0;
    2.24      
    2.25 -    if(!capable(CAP_SYS_ADMIN)){
    2.26 -        ret = -EPERM;
    2.27 -        goto out;
    2.28 -    }
    2.29 +    if(!capable(CAP_SYS_ADMIN))
    2.30 +        return -EPERM;
    2.31  
    2.32      /* get unmapped area invokes xen specific arch_get_unmapped_area */
    2.33      addr = get_unmapped_area(NULL, 0, size, 0, 0);
    2.34 -    if(addr & ~PAGE_MASK){
    2.35 -        ret = -ENOMEM;
    2.36 -        goto out;
    2.37 -    }
    2.38 +    if(addr & ~PAGE_MASK)
    2.39 +        return -ENOMEM;
    2.40  
    2.41      /* add node on the list of directly mapped areas, make sure the
    2.42       * list remains sorted.
    2.43 @@ -190,26 +183,23 @@ unsigned long direct_mmap(unsigned long 
    2.44      dmmap = (direct_mmap_node_t *)kmalloc(sizeof(direct_mmap_node_t), GFP_KERNEL);
    2.45      dmmap->vm_start = addr;
    2.46      dmmap->vm_end = addr + size;
    2.47 -	entry = find_direct(&current->mm->context.direct_list, addr);
    2.48 -	if(entry != &current->mm->context.direct_list){
    2.49 -		list_add_tail(&dmmap->list, entry);
    2.50 -	} else {
    2.51 -    	list_add_tail(&dmmap->list, &current->mm->context.direct_list);
    2.52 -	}
    2.53 +    entry = find_direct(&current->mm->context.direct_list, addr);
    2.54 +    if(entry != &current->mm->context.direct_list){
    2.55 +      list_add_tail(&dmmap->list, entry);
    2.56 +    } else {
    2.57 +      list_add_tail(&dmmap->list, &current->mm->context.direct_list);
    2.58 +    }
    2.59 +
    2.60 +    /* XXX kfree(dmmap)? */
    2.61  
    2.62      /* and perform the mapping */
    2.63 -    if(flag == MAP_DISCONT){
    2.64 -        ret = direct_remap_disc_page_range(addr, phys_addr >> PAGE_SHIFT, 
    2.65 -            tot_pages, prot);
    2.66 -    } else {
    2.67 -        ret = direct_remap_page_range(addr, phys_addr, size, prot);
    2.68 -    }
    2.69 +    ret = direct_remap_disc_page_range(addr, phys_addr >> PAGE_SHIFT, 
    2.70 +				       tot_pages, prot);
    2.71  
    2.72      if(ret == 0)
    2.73 -        ret = addr;
    2.74 -
    2.75 -out: 
    2.76 -    return ret;
    2.77 +        return addr;
    2.78 +    else
    2.79 +        return ret;
    2.80  }
    2.81  
    2.82  /* most of the checks, refcnt updates, cache stuff have been thrown out as they are not