debuggers.hg

changeset 590:e923951ada95

bitkeeper revision 1.307 (3f0adedfLUBRI3eSZZ4MHK-Jhk6G1Q)

Merge new stuff from Keir.
author sos22@labyrinth.cl.cam.ac.uk
date Tue Jul 08 15:10:23 2003 +0000 (2003-07-08)
parents 46cafc527365 9b6ba16a7e32
children 2a6cc141dd5c
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 xenolinux-2.4.21-sparse/arch/xeno/mm/get_unmapped_area.c
line diff
     1.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c	Tue Jul 08 15:06:41 2003 +0000
     1.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c	Tue Jul 08 15:10:23 2003 +0000
     1.3 @@ -45,7 +45,7 @@ struct proc_dir_entry *xeno_base;
     1.4  static struct proc_dir_entry *dom0_cmd_intf;
     1.5  static struct proc_dir_entry *dom_list_intf;
     1.6  
     1.7 -unsigned long direct_mmap(unsigned long, unsigned long, pgprot_t, int);
     1.8 +int direct_unmap(unsigned long, unsigned long);
     1.9  int direct_unmap(struct mm_struct *, unsigned long, unsigned long);
    1.10  
    1.11  static ssize_t dom_usage_read(struct file * file, char * buff, size_t size, loff_t * off)
    1.12 @@ -145,6 +145,113 @@ static void create_proc_dom_entries(int 
    1.13      }
    1.14  }
    1.15  
    1.16 +static ssize_t dom_mem_write(struct file * file, const char * buff, 
    1.17 +                             size_t size , loff_t * off)
    1.18 +{
    1.19 +    dom_mem_t mem_data;
    1.20 +    
    1.21 +    printk("dom_mem_write called: Shouldn't happen.\n");
    1.22 +
    1.23 +    copy_from_user(&mem_data, (dom_mem_t *)buff, sizeof(dom_mem_t));
    1.24 +    
    1.25 +    if ( direct_unmap(mem_data.vaddr, 
    1.26 +                      mem_data.tot_pages << PAGE_SHIFT) == 0 ) {
    1.27 +        return sizeof(sizeof(dom_mem_t));
    1.28 +    } else {
    1.29 +        return -1;
    1.30 +    }
    1.31 +}
    1.32 +
    1.33 +static ssize_t dom_mem_read(struct file * file, char * buff, size_t size, loff_t * off)
    1.34 +{
    1.35 +    unsigned long addr;
    1.36 +    pgprot_t prot;
    1.37 +
    1.38 +    proc_memdata_t * mem_data = (proc_memdata_t *)((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
    1.39 +
    1.40 +    prot = PAGE_SHARED; 
    1.41 +
    1.42 +    /* remap the range using xen specific routines */
    1.43 +
    1.44 +    printk("Calling direct_mmap with pfn %x, tot pages %x.\n",
    1.45 +	   mem_data->pfn, mem_data->tot_pages);
    1.46 +
    1.47 +    addr = direct_mmap(mem_data->pfn << PAGE_SHIFT, mem_data->tot_pages << PAGE_SHIFT, prot, MAP_DISCONT, mem_data->tot_pages);
    1.48 +    
    1.49 +    copy_to_user((unsigned long *)buff, &addr, sizeof(addr));
    1.50 +
    1.51 +    return sizeof(addr);
    1.52 +}
    1.53 +
    1.54 +struct file_operations dom_mem_ops = {
    1.55 +    read:    dom_mem_read,
    1.56 +    write:   dom_mem_write,
    1.57 +};
    1.58 +
    1.59 +static int dom_map_mem(unsigned int dom, unsigned long pfn, int tot_pages)
    1.60 +{
    1.61 +    int ret = -ENOENT;
    1.62 +    struct proc_dir_entry * pd = xeno_base->subdir;
    1.63 +    struct proc_dir_entry * file;
    1.64 +    proc_memdata_t * memdata;
    1.65 +
    1.66 +    while(pd != NULL){
    1.67 +
    1.68 +        if((pd->mode & S_IFDIR) && ((dom_procdata_t *)pd->data)->domain == dom){
    1.69 +
    1.70 +            /* check if there is already an entry for mem and if so
    1.71 +             * remove it.
    1.72 +             */
    1.73 +	    /* XXX does this not leak the memdata? */
    1.74 +            remove_proc_entry("mem", pd);
    1.75 +
    1.76 +            /* create new entry with parameters describing what to do
    1.77 +             * when it is mmaped.
    1.78 +             */
    1.79 +            file = create_proc_entry("mem", 0600, pd);
    1.80 +            if(file != NULL)
    1.81 +            {
    1.82 +                file->owner = THIS_MODULE;
    1.83 +                file->nlink = 1;
    1.84 +                file->proc_fops = &dom_mem_ops;
    1.85 +
    1.86 +                memdata = (proc_memdata_t *)kmalloc(sizeof(proc_memdata_t), GFP_KERNEL);
    1.87 +                memdata->pfn = pfn;
    1.88 +                memdata->tot_pages = tot_pages;
    1.89 +                file->data = memdata;
    1.90 +
    1.91 +                ret = 0;
    1.92 +                break;
    1.93 +            }
    1.94 +
    1.95 +            ret = -EAGAIN;
    1.96 +            break;
    1.97 +        }                    
    1.98 +        pd = pd->next;
    1.99 +    }
   1.100 +
   1.101 +    return ret;
   1.102 +}
   1.103 +
   1.104 +/* function used to retrieve data associated with new domain */
   1.105 +static ssize_t dom_data_read(struct file * file, char * buff, size_t size, loff_t * off)
   1.106 +{
   1.107 +    dom0_newdomain_t * dom_data = (dom0_newdomain_t *)
   1.108 +        ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
   1.109 +
   1.110 +    copy_to_user((dom0_newdomain_t *)buff, dom_data, sizeof(dom0_newdomain_t));
   1.111 +
   1.112 +    remove_proc_entry("new_dom_data", xeno_base);
   1.113 +
   1.114 +    kfree(dom_data);
   1.115 +
   1.116 +    return sizeof(dom0_newdomain_t);
   1.117 +}
   1.118 +
   1.119 +struct file_operations newdom_data_fops = {
   1.120 +    read:    dom_data_read,
   1.121 +};
   1.122 +
   1.123  static int dom0_cmd_write(struct file *file, const char *buffer, size_t size,
   1.124  			  loff_t *off)
   1.125  {
     2.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Tue Jul 08 15:06:41 2003 +0000
     2.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_memory.c	Tue Jul 08 15:10:23 2003 +0000
     2.3 @@ -301,12 +301,12 @@ static void direct_zap_page_range(struct
     2.4  }
     2.5  
     2.6  
     2.7 -int direct_unmap(unsigned long addr, unsigned long size)
     2.8 +int direct_unmap(struct mm_struct *mm, unsigned long addr, unsigned long size)
     2.9  {
    2.10      int count = 0, tot_pages = (size+PAGE_SIZE-1) >> PAGE_SHIFT;
    2.11      direct_mmap_node_t * node;
    2.12      struct list_head * curr;
    2.13 -    struct list_head * direct_list = &current->mm->context.direct_list;    
    2.14 +    struct list_head * direct_list = &mm->context.direct_list;    
    2.15  
    2.16      curr = direct_list->next;
    2.17      while ( curr != direct_list )
    2.18 @@ -325,7 +325,7 @@ int direct_unmap(unsigned long addr, uns
    2.19  
    2.20      while ( count < tot_pages )
    2.21      {
    2.22 -        direct_zap_page_range(current->mm, addr, PAGE_SIZE);
    2.23 +        direct_zap_page_range(mm, addr, PAGE_SIZE);
    2.24          addr += PAGE_SIZE;
    2.25          count++;
    2.26      }
     3.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/mm/get_unmapped_area.c	Tue Jul 08 15:06:41 2003 +0000
     3.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/mm/get_unmapped_area.c	Tue Jul 08 15:10:23 2003 +0000
     3.3 @@ -14,8 +14,7 @@
     3.4  #include <asm/uaccess.h>
     3.5  #include <asm/pgalloc.h>
     3.6  
     3.7 -extern int direct_unmap(unsigned long, unsigned long);
     3.8 -
     3.9 +extern int direct_unmap(struct mm_struct *, unsigned long, unsigned long);
    3.10  
    3.11  int init_direct_list(struct mm_struct *mm)
    3.12  {
    3.13 @@ -30,7 +29,7 @@ void destroy_direct_list(struct mm_struc
    3.14      while ( (curr = direct_list->next) != direct_list )
    3.15      {
    3.16          direct_mmap_node_t *node = list_entry(curr, direct_mmap_node_t, list);
    3.17 -        if ( direct_unmap(node->vm_start, node->vm_end - node->vm_start) != 0 )
    3.18 +        if ( direct_unmap(mm, node->vm_start, node->vm_end - node->vm_start) )
    3.19              BUG();
    3.20      }
    3.21  }