aboutsummaryrefslogtreecommitdiffstats
path: root/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0
diff options
context:
space:
mode:
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>2003-06-27 14:18:00 +0000
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>2003-06-27 14:18:00 +0000
commit6d56b5e5e2f3caed77003fb913cd9f71e06de7f3 (patch)
tree8bd2ebe9796f3e7951660e3cf06318a3d2d34a1d /xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0
parentc0535d5e52c6d6f5cb1d5b8cc3be1eb8f69244be (diff)
downloadxen-6d56b5e5e2f3caed77003fb913cd9f71e06de7f3.tar.gz
xen-6d56b5e5e2f3caed77003fb913cd9f71e06de7f3.tar.bz2
xen-6d56b5e5e2f3caed77003fb913cd9f71e06de7f3.zip
bitkeeper revision 1.258 (3efc5218v9et-leaVGHVRu-faTh56g)
update to official 2.4.21 kernel from 2.4.21-pre4
Diffstat (limited to 'xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0')
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/Makefile3
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_block.c27
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c522
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_memory.c368
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h57
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/sched_ops.c137
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c321
7 files changed, 0 insertions, 1435 deletions
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/Makefile b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/Makefile
deleted file mode 100644
index eeb3413842..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-O_TARGET := dom0.o
-obj-y := dom0_memory.o dom0_core.o vfr.o sched_ops.o
-include $(TOPDIR)/Rules.make
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_block.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_block.c
deleted file mode 100644
index 97d4a65b78..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_block.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * domain 0 block driver interface
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-
-static int __init init_module(void)
-{
- request_module("xl_block");
- printk("Successfully installed domain 0 block interface\n");
-
-
- return 0;
-}
-
-static void __exit cleanup_module(void)
-{
- printk("Successfully de-installed domain-0 block interface\n");
- return 0;
-}
-
-module_init(init_module);
-module_exit(cleanup_module);
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c
deleted file mode 100644
index b42abc45e4..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/******************************************************************************
- * dom0_core.c
- *
- * Interface to privileged domain-0 commands.
- *
- * Copyright (c) 2002, K A Fraser, B Dragovic
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/proc_fs.h>
-
-#include <linux/mm.h>
-#include <linux/mman.h>
-#include <linux/swap.h>
-#include <linux/smp_lock.h>
-#include <linux/swapctl.h>
-#include <linux/iobuf.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/seq_file.h>
-
-#include <asm/pgalloc.h>
-#include <asm/pgtable.h>
-#include <asm/uaccess.h>
-#include <asm/tlb.h>
-
-#include "dom0_ops.h"
-
-#define TRUE 1
-#define FALSE 0
-
-/* Private proc-file data structures. */
-typedef struct proc_data {
- unsigned int domain;
- unsigned long map_size;
-} dom_procdata_t;
-
-typedef struct proc_mem_data {
- unsigned long pfn;
- int tot_pages;
-} proc_memdata_t;
-
-#define XENO_BASE "xeno"
-#define DOM0_CMD_INTF "dom0_cmd"
-#define DOM0_NEWDOM "new_dom_data"
-#define DOM_LIST_INTF "domains"
-
-#define MAX_LEN 16
-#define DOM_DIR "dom"
-#define DOM_MEM "mem"
-#define DOM_VIF "vif"
-#define DOM_USAGE "usage"
-
-#define MAP_DISCONT 1
-
-struct proc_dir_entry *xeno_base;
-static struct proc_dir_entry *dom0_cmd_intf;
-static struct proc_dir_entry *proc_ft;
-static struct proc_dir_entry *dom_list_intf;
-
-unsigned long direct_mmap(unsigned long, unsigned long, pgprot_t, int, int);
-int direct_unmap(unsigned long, unsigned long);
-int direct_disc_unmap(unsigned long, unsigned long, int);
-
-static unsigned char readbuf[1204];
-
-static int cmd_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- strcpy(page, readbuf);
- *readbuf = '\0';
- *eof = 1;
- *start = page;
- return strlen(page);
-}
-
-static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off)
-{
- int hyp_buf[32];
- char buf[128];
- network_op_t op;
- static int finished = 0;
-
- if ( finished )
- {
- finished = 0;
- return 0;
- }
-
- op.cmd = NETWORK_OP_VIFQUERY;
- op.u.vif_query.domain = (unsigned int)
- ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
- op.u.vif_query.buf = hyp_buf;
-
- (void) HYPERVISOR_network_op(&op);
-
- if(hyp_buf[0] < 0) {
- strcpy(buf, "Error getting domain's vif list from hypervisor.\n");
- } else {
- int i;
- int len = 0;
- strcpy(buf, "No vif found");
-
- for(i = 1; i <= hyp_buf[0] && len < 127; i++)
- len += snprintf(buf + len, 127 - len, "%d\n", hyp_buf[i]);
- }
-
- if (*off >= (strlen(buf)+1)) return 0;
-
- copy_to_user(buff, buf, strlen(buf));
-
- finished = 1;
-
- return strlen(buf)+1;
-}
-
-struct file_operations dom_vif_ops = {
- read: dom_vif_read
-};
-
-static ssize_t dom_usage_read(struct file * file, char * buff, size_t size, loff_t * off)
-{
- char str[256];
- int vifs[32];
- dom0_op_t op;
- network_op_t netop;
- int i, end;
- unsigned int domain;
- static int finished = 0;
-
- if ( finished )
- {
- finished = 0;
- return 0;
- }
-
- domain = (unsigned int)
- ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
- op.cmd = DOM0_GETDOMAININFO;
-
- op.u.getdominfo.domain = domain;
-
- (void) HYPERVISOR_dom0_op(&op);
-
- end = snprintf(str, 256, "cpu: %lld\n", op.u.getdominfo.cpu_time);
-
- netop.cmd = NETWORK_OP_VIFQUERY;
- netop.u.vif_query.domain = domain;
- netop.u.vif_query.buf = vifs;
-
- (void) HYPERVISOR_network_op(&netop);
-
- for(i = 1; i <= vifs[0]; i++) {
- netop.cmd = NETWORK_OP_VIFGETINFO;
- netop.u.vif_getinfo.domain = domain;
- netop.u.vif_getinfo.vif = vifs[i];
-
- (void) HYPERVISOR_network_op(&netop);
-
- end += snprintf(str + end, 255 - end,
- "vif%d: sent %lld bytes (%lld packets) "
- "received %lld bytes (%lld packets)\n",
- vifs[i],
- netop.u.vif_getinfo.total_bytes_sent,
- netop.u.vif_getinfo.total_packets_sent,
- netop.u.vif_getinfo.total_bytes_received,
- netop.u.vif_getinfo.total_packets_received);
- }
-
- if (*off >= end + 1) return 0;
-
- copy_to_user(buff, str, end);
-
- finished = 1;
-
- return end + 1;
-}
-
-struct file_operations dom_usage_ops = {
- read: dom_usage_read
-};
-
-
-static void create_proc_dom_entries(int dom)
-{
- struct proc_dir_entry * dir;
- dom_procdata_t * dom_data;
- char dir_name[MAX_LEN];
- struct proc_dir_entry * file;
-
- snprintf(dir_name, MAX_LEN, "%s%d", DOM_DIR, dom);
-
- dom_data = (dom_procdata_t *)kmalloc(sizeof(dom_procdata_t), GFP_KERNEL);
- dom_data->domain = dom;
-
- dir = proc_mkdir(dir_name, xeno_base);
- dir->data = dom_data;
-
- file = create_proc_entry(DOM_VIF, 0600, dir);
- if (file != NULL)
- {
- file->owner = THIS_MODULE;
- file->nlink = 1;
- file->proc_fops = &dom_vif_ops;
- file->data = (void *) dom;
- }
-
- file = create_proc_entry(DOM_USAGE, 0600, dir);
- if (file != NULL)
- {
- file->owner = THIS_MODULE;
- file->nlink = 1;
- file->proc_fops = &dom_usage_ops;
- file->data = (void *) dom;
- }
-}
-
-static ssize_t dom_mem_write(struct file * file, const char * buff,
- size_t size , loff_t * off)
-{
- dom_mem_t mem_data;
-
- copy_from_user(&mem_data, (dom_mem_t *)buff, sizeof(dom_mem_t));
-
- if(direct_disc_unmap(mem_data.vaddr, mem_data.start_pfn,
- mem_data.tot_pages) == 0){
- return sizeof(sizeof(dom_mem_t));
- } else {
- return -1;
- }
-}
-
-static ssize_t dom_mem_read(struct file * file, char * buff, size_t size, loff_t * off)
-{
- unsigned long addr;
- pgprot_t prot;
-
- proc_memdata_t * mem_data = (proc_memdata_t *)((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
-
- prot = PAGE_SHARED;
-
- /* remap the range using xen specific routines */
-
- addr = direct_mmap(mem_data->pfn << PAGE_SHIFT, mem_data->tot_pages << PAGE_SHIFT, prot, MAP_DISCONT, mem_data->tot_pages);
-
- copy_to_user((unsigned long *)buff, &addr, sizeof(addr));
-
- return sizeof(addr);
-}
-
-struct file_operations dom_mem_ops = {
- read: dom_mem_read,
- write: dom_mem_write,
-};
-
-static int dom_map_mem(unsigned int dom, unsigned long pfn, int tot_pages)
-{
- int ret = -ENOENT;
- struct proc_dir_entry * pd = xeno_base->subdir;
- struct proc_dir_entry * file;
- proc_memdata_t * memdata;
-
- while(pd != NULL){
-
- if((pd->mode & S_IFDIR) && ((dom_procdata_t *)pd->data)->domain == dom){
-
- /* check if there is already an entry for mem and if so
- * remove it.
- */
- remove_proc_entry(DOM_MEM, pd);
-
- /* create new entry with parameters describing what to do
- * when it is mmaped.
- */
- file = create_proc_entry(DOM_MEM, 0600, pd);
- if(file != NULL)
- {
- file->owner = THIS_MODULE;
- file->nlink = 1;
- file->proc_fops = &dom_mem_ops;
-
- memdata = (proc_memdata_t *)kmalloc(sizeof(proc_memdata_t), GFP_KERNEL);
- memdata->pfn = pfn;
- memdata->tot_pages = tot_pages;
- file->data = memdata;
-
- ret = 0;
- break;
- }
-
- ret = -EAGAIN;
- break;
- }
- pd = pd->next;
- }
-
- return ret;
-}
-
-/* function used to retrieve data associated with new domain */
-static ssize_t dom_data_read(struct file * file, char * buff, size_t size, loff_t * off)
-{
- dom0_newdomain_t * dom_data = (dom0_newdomain_t *)
- ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
-
- copy_to_user((dom0_newdomain_t *)buff, dom_data, sizeof(dom0_newdomain_t));
-
- remove_proc_entry(DOM0_NEWDOM, xeno_base);
-
- kfree(dom_data);
-
- return sizeof(dom0_newdomain_t);
-}
-
-struct file_operations newdom_data_fops = {
- read: dom_data_read,
-};
-
-static int cmd_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- dom0_op_t op;
- int ret = 0;
- struct proc_dir_entry * new_dom_id;
- dom0_newdomain_t * params;
- int i;
- unsigned long p;
-
- copy_from_user(&op, buffer, sizeof(dom0_op_t));
-
- /* do some sanity checks */
- if(op.cmd > MAX_CMD){
- ret = -ENOSYS;
- goto out;
- }
-
- if ( op.cmd == MAP_DOM_MEM )
- {
- ret = dom_map_mem(op.u.dommem.domain, op.u.dommem.start_pfn,
- op.u.dommem.tot_pages);
- }
- else if ( op.cmd == DO_PGUPDATES )
- {
- ret = HYPERVISOR_pt_update(op.u.pgupdate.pgt_update_arr,
- op.u.pgupdate.num_pgt_updates);
- }
- else
- {
- ret = HYPERVISOR_dom0_op(&op);
-
- /* if new domain created, create proc entries */
- if(op.cmd == DOM0_CREATEDOMAIN) {
- create_proc_dom_entries(ret);
-
- params = (dom0_newdomain_t *)kmalloc(sizeof(dom0_newdomain_t),
- GFP_KERNEL);
- params->memory_kb = op.u.newdomain.memory_kb;
- params->pg_head = op.u.newdomain.pg_head;
- params->num_vifs = op.u.newdomain.num_vifs;
- params->domain = op.u.newdomain.domain;
-
- /* now notify user space of the new domain's id */
- new_dom_id = create_proc_entry(DOM0_NEWDOM, 0600, xeno_base);
- if ( new_dom_id != NULL )
- {
- new_dom_id->owner = THIS_MODULE;
- new_dom_id->nlink = 1;
- new_dom_id->proc_fops = &newdom_data_fops;
- new_dom_id->data = (void *)params;
- }
-
- }
-
- }
-
-out:
- return ret;
-
-}
-
-/***********************************************************************
- *
- * Implementation of /proc/xeno/domains
- */
-
-static dom0_op_t proc_domains_op;
-static int proc_domains_finished;
-static rwlock_t proc_xeno_domains_lock = RW_LOCK_UNLOCKED;
-
-static void *xeno_domains_next(struct seq_file *s, void *v, loff_t *pos)
-{
- int ret;
-
- if (pos != NULL) { ++ (*pos); }
- if (!proc_domains_finished) {
- proc_domains_op.u.getdominfo.domain ++;
- ret = HYPERVISOR_dom0_op(&proc_domains_op);
- if (ret < 0) proc_domains_finished = TRUE;
- }
-
- return (proc_domains_finished) ? NULL : &proc_domains_op;
-}
-
-static void *xeno_domains_start(struct seq_file *s, loff_t *ppos)
-{
- loff_t pos = *ppos;
-
- write_lock (&proc_xeno_domains_lock);
- proc_domains_op.cmd = DOM0_GETDOMAININFO;
- proc_domains_op.u.getdominfo.domain = 0;
- (void)HYPERVISOR_dom0_op(&proc_domains_op);
- proc_domains_finished = FALSE;
-
- while (pos > 0) {
- pos --;
- xeno_domains_next (s, NULL, NULL);
- }
-
- return (proc_domains_finished) ? NULL : &proc_domains_op;
-}
-
-static void xeno_domains_stop(struct seq_file *s, void *v)
-{
- write_unlock (&proc_xeno_domains_lock);
-}
-
-static int xeno_domains_show(struct seq_file *s, void *v)
-{
- dom0_op_t *di = v;
-
- /*
- * Output one domain's details to dom0.
- *
- * If you update this format string then change xi_list to match.
- */
-
- seq_printf (s,
- "%8d %2d %1d %2d %8d %8ld %p %8d %s\n",
- di -> u.getdominfo.domain,
- di -> u.getdominfo.processor,
- di -> u.getdominfo.has_cpu,
- di -> u.getdominfo.state,
- di -> u.getdominfo.hyp_events,
- di -> u.getdominfo.mcu_advance,
- di -> u.getdominfo.pg_head,
- di -> u.getdominfo.tot_pages,
- di -> u.getdominfo.name);
-
- return 0;
-}
-
-struct seq_operations xeno_domains_op = {
- .start = xeno_domains_start,
- .next = xeno_domains_next,
- .stop = xeno_domains_stop,
- .show = xeno_domains_show,
-};
-
-static int xeno_domains_open(struct inode *inode, struct file *file)
-{
- return seq_open(file, &xeno_domains_op);
-}
-
-static struct file_operations proc_xeno_domains_operations = {
- open: xeno_domains_open,
- read: seq_read,
- llseek: seq_lseek,
- release: seq_release,
-};
-
-/***********************************************************************/
-
-
-
-static int __init init_module(void)
-{
- /* xeno proc root setup */
- xeno_base = proc_mkdir(XENO_BASE, &proc_root);
-
- /* xeno control interface */
- *readbuf = '\0';
- dom0_cmd_intf = create_proc_entry (DOM0_CMD_INTF, 0600, xeno_base);
- if ( dom0_cmd_intf != NULL )
- {
- dom0_cmd_intf->owner = THIS_MODULE;
- dom0_cmd_intf->nlink = 1;
- dom0_cmd_intf->read_proc = cmd_read_proc;
- dom0_cmd_intf->write_proc = cmd_write_proc;
- }
-
- /* domain list interface */
- dom_list_intf = create_proc_entry (DOM_LIST_INTF, 0400, xeno_base);
- if ( dom_list_intf != NULL )
- {
- dom_list_intf -> owner = THIS_MODULE;
- dom_list_intf -> nlink = 1;
- dom_list_intf -> proc_fops = &proc_xeno_domains_operations;
- }
-
- /* set up /proc entries for dom 0 */
- create_proc_dom_entries(0);
-
- return 0;
-}
-
-
-static void __exit cleanup_module(void)
-{
- if ( dom0_cmd_intf == NULL ) return;
- remove_proc_entry("dom0", &proc_root);
- dom0_cmd_intf = NULL;
-}
-
-
-module_init(init_module);
-module_exit(cleanup_module);
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_memory.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_memory.c
deleted file mode 100644
index 9d14070a1e..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_memory.c
+++ /dev/null
@@ -1,368 +0,0 @@
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
-#include <linux/swap.h>
-#include <linux/smp_lock.h>
-#include <linux/swapctl.h>
-#include <linux/iobuf.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
-#include <linux/list.h>
-
-#include <asm/pgalloc.h>
-#include <asm/uaccess.h>
-#include <asm/tlb.h>
-#include <asm/mmu.h>
-
-#include "dom0_ops.h"
-
-#define MAP_CONT 0
-#define MAP_DISCONT 1
-
-extern struct list_head * find_direct(struct list_head *, unsigned long);
-
-/*
- * bd240: functions below perform direct mapping to the real physical pages
- * needed for mapping various hypervisor specific structures needed in dom0
- * userspace by various management applications such as domain builder etc.
- */
-
-#define direct_set_pte(pteptr, pteval) queue_l1_entry_update(__pa(pteptr)|PGREQ_UNCHECKED_UPDATE, (pteval).pte_low)
-
-#define direct_pte_clear(pteptr) queue_l1_entry_update(__pa(pteptr)|PGREQ_UNCHECKED_UPDATE, 0)
-
-#define __direct_pte(x) ((pte_t) { (x) } )
-#define __direct_mk_pte(page_nr,pgprot) __direct_pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
-#define direct_mk_pte_phys(physpage, pgprot) __direct_mk_pte((physpage) >> PAGE_SHIFT, pgprot)
-
-static inline void forget_pte(pte_t page)
-{
- if (!pte_none(page)) {
- printk("forget_pte: old mapping existed!\n");
- BUG();
- }
-}
-
-static inline void direct_remappte_range(pte_t * pte, unsigned long address, unsigned long size,
- unsigned long phys_addr, pgprot_t prot)
-{
- unsigned long end;
-
- address &= ~PMD_MASK;
- end = address + size;
- if (end > PMD_SIZE)
- end = PMD_SIZE;
- do {
- pte_t oldpage;
- oldpage = ptep_get_and_clear(pte);
-
- direct_set_pte(pte, direct_mk_pte_phys(phys_addr, prot));
-
- forget_pte(oldpage);
- address += PAGE_SIZE;
- phys_addr += PAGE_SIZE;
- pte++;
- } while (address && (address < end));
-
-}
-
-static inline int direct_remappmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
- unsigned long phys_addr, pgprot_t prot)
-{
- unsigned long end;
-
- address &= ~PGDIR_MASK;
- end = address + size;
- if (end > PGDIR_SIZE)
- end = PGDIR_SIZE;
- phys_addr -= address;
- do {
- pte_t * pte = pte_alloc(mm, pmd, address);
- if (!pte)
- return -ENOMEM;
- direct_remappte_range(pte, address, end - address, address + phys_addr, prot);
- address = (address + PMD_SIZE) & PMD_MASK;
- pmd++;
- } while (address && (address < end));
- return 0;
-}
-
-/* Note: this is only safe if the mm semaphore is held when called. */
-int direct_remap_page_range(unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
-{
- int error = 0;
- pgd_t * dir;
- unsigned long beg = from;
- unsigned long end = from + size;
- struct mm_struct *mm = current->mm;
-
- phys_addr -= from;
- dir = pgd_offset(mm, from);
- flush_cache_range(mm, beg, end);
- if (from >= end)
- BUG();
-
- spin_lock(&mm->page_table_lock);
- do {
- pmd_t *pmd = pmd_alloc(mm, dir, from);
- error = -ENOMEM;
- if (!pmd)
- break;
- error = direct_remappmd_range(mm, pmd, from, end - from, phys_addr + from, prot);
- if (error)
- break;
- from = (from + PGDIR_SIZE) & PGDIR_MASK;
- dir++;
- } while (from && (from < end));
- spin_unlock(&mm->page_table_lock);
- flush_tlb_range(mm, beg, end);
- return error;
-}
-
-/*
- * used for remapping discontiguous bits of domain's memory, pages to map are
- * found from frame table beginning at the given first_pg index
- */
-int direct_remap_disc_page_range(unsigned long from,
- unsigned long first_pg, int tot_pages, pgprot_t prot)
-{
- dom0_op_t dom0_op;
- unsigned long *pfns = get_free_page(GFP_KERNEL);
- unsigned long start = from;
- int pages, i;
-
- while ( tot_pages != 0 )
- {
- dom0_op.cmd = DOM0_GETMEMLIST;
- dom0_op.u.getmemlist.start_pfn = first_pg;
- pages = 1023;
- dom0_op.u.getmemlist.num_pfns = 1024;
- if ( tot_pages < 1024 )
- dom0_op.u.getmemlist.num_pfns = pages = tot_pages;
- dom0_op.u.getmemlist.buffer = pfns;
- (void)HYPERVISOR_dom0_op(&dom0_op);
- first_pg = pfns[1023];
-
- for ( i = 0; i < pages; i++ )
- {
- if(direct_remap_page_range(start, pfns[i] << PAGE_SHIFT,
- PAGE_SIZE, prot))
- goto out;
- start += PAGE_SIZE;
- tot_pages--;
- }
- }
-
-out:
- free_page(pfns);
- return tot_pages;
-}
-
-/* below functions replace standard sys_mmap and sys_munmap which are absolutely useless
- * for direct memory mapping. direct_zap* functions are minor ammendments to the
- * original versions in mm/memory.c. the changes are to enable unmapping of real physical
- * addresses.
- */
-
-unsigned long direct_mmap(unsigned long phys_addr, unsigned long size,
- pgprot_t prot, int flag, int tot_pages)
-{
- direct_mmap_node_t * dmmap;
- struct list_head * entry;
- unsigned long addr;
- int ret = 0;
-
- if(!capable(CAP_SYS_ADMIN)){
- ret = -EPERM;
- goto out;
- }
-
- /* get unmapped area invokes xen specific arch_get_unmapped_area */
- addr = get_unmapped_area(NULL, 0, size, 0, 0);
- if(addr & ~PAGE_MASK){
- ret = -ENOMEM;
- goto out;
- }
-
- /* add node on the list of directly mapped areas, make sure the
- * list remains sorted.
- */
- dmmap = (direct_mmap_node_t *)kmalloc(sizeof(direct_mmap_node_t), GFP_KERNEL);
- dmmap->vm_start = addr;
- dmmap->vm_end = addr + size;
- entry = find_direct(&current->mm->context.direct_list, addr);
- if(entry != &current->mm->context.direct_list){
- list_add_tail(&dmmap->list, entry);
- } else {
- list_add_tail(&dmmap->list, &current->mm->context.direct_list);
- }
-
- /* and perform the mapping */
- if(flag == MAP_DISCONT){
- ret = direct_remap_disc_page_range(addr, phys_addr >> PAGE_SHIFT,
- tot_pages, prot);
- } else {
- ret = direct_remap_page_range(addr, phys_addr, size, prot);
- }
-
- if(ret == 0)
- ret = addr;
-
-out:
- return ret;
-}
-
-/* most of the checks, refcnt updates, cache stuff have been thrown out as they are not
- * needed
- */
-static inline int direct_zap_pte_range(mmu_gather_t *tlb, pmd_t * pmd, unsigned long address,
- unsigned long size)
-{
- unsigned long offset;
- pte_t * ptep;
- int freed = 0;
-
- if (pmd_none(*pmd))
- return 0;
- if (pmd_bad(*pmd)) {
- pmd_ERROR(*pmd);
- pmd_clear(pmd);
- return 0;
- }
- ptep = pte_offset(pmd, address);
- offset = address & ~PMD_MASK;
- if (offset + size > PMD_SIZE)
- size = PMD_SIZE - offset;
- size &= PAGE_MASK;
- for (offset=0; offset < size; ptep++, offset += PAGE_SIZE) {
- pte_t pte = *ptep;
- if (pte_none(pte))
- continue;
- freed ++;
- direct_pte_clear(ptep);
- }
-
- return freed;
-}
-
-static inline int direct_zap_pmd_range(mmu_gather_t *tlb, pgd_t * dir,
- unsigned long address, unsigned long size)
-{
- pmd_t * pmd;
- unsigned long end;
- int freed;
-
- if (pgd_none(*dir))
- return 0;
- if (pgd_bad(*dir)) {
- pgd_ERROR(*dir);
- pgd_clear(dir);
- return 0;
- }
- pmd = pmd_offset(dir, address);
- end = address + size;
- if (end > ((address + PGDIR_SIZE) & PGDIR_MASK))
- end = ((address + PGDIR_SIZE) & PGDIR_MASK);
- freed = 0;
- do {
- freed += direct_zap_pte_range(tlb, pmd, address, end - address);
- address = (address + PMD_SIZE) & PMD_MASK;
- pmd++;
- } while (address < end);
- return freed;
-}
-
-/*
- * remove user pages in a given range.
- */
-void direct_zap_page_range(struct mm_struct *mm, unsigned long address, unsigned long size)
-{
- mmu_gather_t *tlb;
- pgd_t * dir;
- unsigned long start = address, end = address + size;
- int freed = 0;
-
- dir = pgd_offset(mm, address);
-
- /*
- * This is a long-lived spinlock. That's fine.
- * There's no contention, because the page table
- * lock only protects against kswapd anyway, and
- * even if kswapd happened to be looking at this
- * process we _want_ it to get stuck.
- */
- if (address >= end)
- BUG();
- spin_lock(&mm->page_table_lock);
- flush_cache_range(mm, address, end);
- tlb = tlb_gather_mmu(mm);
-
- do {
- freed += direct_zap_pmd_range(tlb, dir, address, end - address);
- address = (address + PGDIR_SIZE) & PGDIR_MASK;
- dir++;
- } while (address && (address < end));
-
- /* this will flush any remaining tlb entries */
- tlb_finish_mmu(tlb, start, end);
-
- /* decrementing rss removed */
-
- spin_unlock(&mm->page_table_lock);
-}
-
-int direct_unmap(unsigned long addr, unsigned long size)
-{
- direct_mmap_node_t * node;
- struct list_head * curr;
- struct list_head * direct_list = &current->mm->context.direct_list;
-
- curr = direct_list->next;
- while(curr != direct_list){
- node = list_entry(curr, direct_mmap_node_t, list);
- if(node->vm_start == addr)
- break;
- curr = curr->next;
- }
-
- if(curr == direct_list)
- return -1;
-
- list_del(&node->list);
- kfree(node);
-
- direct_zap_page_range(current->mm, addr, size);
-
- return 0;
-}
-
-int direct_disc_unmap(unsigned long from, unsigned long first_pg, int tot_pages)
-{
- int count = 0;
- direct_mmap_node_t * node;
- struct list_head * curr;
- struct list_head * direct_list = &current->mm->context.direct_list;
-
- curr = direct_list->next;
- while(curr != direct_list){
- node = list_entry(curr, direct_mmap_node_t, list);
-
- if(node->vm_start == from)
- break;
- curr = curr->next;
- }
-
- if(curr == direct_list)
- return -1;
-
- list_del(&node->list);
- kfree(node);
-
- while(count < tot_pages){
- direct_zap_page_range(current->mm, from, PAGE_SIZE);
- from += PAGE_SIZE;
- count++;
- }
-
- return 0;
-}
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h
deleted file mode 100644
index 8562591e1e..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/******************************************************************************
- * dom0_ops.h
- *
- * Process command requests from domain-0 guest OS.
- * This file includes the Xen part of the interface, plus the extra stuff
- * that is dealt with by Xenolinux without being handed down to Xen.
- *
- * Copyright (c) 2002-2003, K A Fraser, B Dragovic
- */
-
-#ifndef __DOM0_DOM0_OPS_H__
-#define __DOM0_DOM0_OPS_H__
-
-/* External users of this header file will include Xen's version separately. */
-#ifdef __KERNEL__
-#define NO_DOM0_OP_T
-#include <asm/hypervisor-ifs/dom0_ops.h>
-#endif
-
-/* Extra commands dealt with by Xenolinux. */
-#define MAP_DOM_MEM 14
-#define DO_PGUPDATES 15
-#define MAX_CMD 16
-
-typedef struct dom_mem
-{
- unsigned int domain;
- unsigned long vaddr;
- unsigned long start_pfn;
- int tot_pages;
-} dom_mem_t;
-
-typedef struct dom_pgupdate
-{
- unsigned long pgt_update_arr;
- unsigned long num_pgt_updates;
-} dom_pgupdate_t;
-
-typedef struct dom0_op_st
-{
- unsigned long cmd;
- union
- {
- dom0_newdomain_t newdomain;
- dom0_killdomain_t killdomain;
- dom0_getmemlist_t getmemlist;
- dom0_bvtctl_t bvtctl;
- dom0_adjustdom_t adjustdom;
- dom_mem_t dommem;
- dom_pgupdate_t pgupdate;
- dom_meminfo_t meminfo;
- dom0_getdominfo_t getdominfo;
- }
- u;
-} dom0_op_t;
-
-#endif /* __DOM0_DOM0_OPS_H__ */
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/sched_ops.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/sched_ops.c
deleted file mode 100644
index 9c5fce7857..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/sched_ops.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
- ****************************************************************************
- * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
- ****************************************************************************
- *
- * File: sched_ops.c
- * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
- * Changes:
- *
- * Date: Mar 2003
- *
- * Environment: XenoLinux
- * Description: Dom0 Control interface to scheduler in Xen
- *
- * code based on Andy's vfr parsing code
- *
- * Commands understood by the interface:
- *
- * C <context swith allowance>
- * S <did> <mcu advance> <warp> <warp limit> <unwarp limit>
- *
- ****************************************************************************
- * $Id: c-insert.c,v 1.7 2002/11/08 16:04:34 rn Exp $
- ****************************************************************************
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/ctype.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/proc_fs.h>
-
-#include "dom0_ops.h"
-
-#define SCHED_ENTRY "sched"
-extern struct proc_dir_entry *xeno_base;
-static struct proc_dir_entry *sched_pde;
-
-static unsigned char readbuf[1024];
-
-static int sched_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- strcpy(page, readbuf);
- *readbuf = '\0';
- *eof = 1;
- *start = page;
- return strlen(page);
-}
-
-
-static int sched_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- dom0_op_t op;
-
- int ret, len;
- int ts, te, tl; /* token start, end, and length */
-
- /* Only admin can adjust scheduling parameters */
- if ( !capable(CAP_SYS_ADMIN) )
- return -EPERM;
-
- /* parse the commands */
- len = count;
- ts = te = 0;
-
- while ( count && isspace(buffer[ts]) ) { ts++; count--; } /*skip spaces*/
- te = ts;
- while ( count && !isspace(buffer[te]) ) { te++; count--; } /*command end*/
- if ( te <= ts ) goto bad;
- tl = te - ts;
-
- if ( strncmp(&buffer[ts], "C", tl) == 0 ) {
- op.cmd = DOM0_BVTCTL;
- } else if ( strncmp(&buffer[ts], "S", tl) == 0 ) {
- op.cmd = DOM0_ADJUSTDOM;
- } else
- goto bad;
-
- /* skip whitspaces and get first parameter */
- ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; }
- te = ts; while ( count && !isspace(buffer[te]) ) { te++; count--; }
- if ( te <= ts ) goto bad;
- tl = te - ts;
- if ( !isdigit(buffer[ts]) ) goto bad;
-
- if (op.cmd == DOM0_BVTCTL) {
- /* get context switch allowance */
- sscanf(&buffer[ts], "%lu", &op.u.bvtctl.ctx_allow);
- } else if (op.cmd == DOM0_ADJUSTDOM) {
- sscanf(&buffer[ts], "%u %lu %lu %lu %lu",
- &op.u.adjustdom.domain,
- &op.u.adjustdom.mcu_adv,
- &op.u.adjustdom.warp,
- &op.u.adjustdom.warpl,
- &op.u.adjustdom.warpu);
- }
- ret = HYPERVISOR_dom0_op(&op);
- return sizeof(op);
-
- bad:
- return -EINVAL;
-
-}
-
-
-/*
- * main scheduler interface driver driver initialization function.
- */
-static int __init init_module(void)
-{
- printk(KERN_ALERT "Starting Domain Scheduler Control Interface\n");
-
- sched_pde = create_proc_entry(SCHED_ENTRY, 0600, xeno_base);
- if ( sched_pde == NULL )
- {
- printk(KERN_ALERT "Unable to create dom scheduler proc entry!");
- return -1;
- }
-
- sched_pde->read_proc = sched_read_proc;
- sched_pde->write_proc = sched_write_proc;
-
- return 0;
-}
-
-static void __exit cleanup_module(void)
-{
-}
-
-module_init(init_module);
-module_exit(cleanup_module);
-
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c
deleted file mode 100644
index 852f6943e2..0000000000
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/******************************************************************************
- * vfr.c
- *
- * Interface to the virtual firewall/router.
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/proc_fs.h>
-
-#include <asm/hypervisor-ifs/network.h>
-
-static struct proc_dir_entry *proc_vfr;
-
-static unsigned char readbuf[1024];
-
-/* Helpers, implemented at the bottom. */
-u32 getipaddr(const char *buff, unsigned int len);
-u16 antous(const char *buff, int len);
-int anton(const char *buff, int len);
-
-static int vfr_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- strcpy(page, readbuf);
- *readbuf = '\0';
- *eof = 1;
- *start = page;
- return strlen(page);
-}
-
-/* The format for the vfr interface is as follows:
- *
- * COMMAND <field>=<val> [<field>=<val> [...]]
- *
- * where:
- *
- * COMMAND = { ACCEPT | COUNT }
- *
- * field=val pairs are as follows:
- *
- * field = { srcaddr | dstaddr }
- * val is a dot seperated, numeric IP address.
- *
- * field = { srcport | dstport }
- * val is a (16-bit) unsigned int
- *
- * field = { proto }
- * val = { IP | TCP | UDP | ARP }
- *
- */
-
-#define isspace(_x) ( ((_x)==' ') || ((_x)=='\t') || ((_x)=='\v') || \
- ((_x)=='\f') || ((_x)=='\r') || ((_x)=='\n') )
-
-static int vfr_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- network_op_t op;
- int ret, len;
- int ts, te, tl; // token start, end, and length
- int fs, fe, fl; // field.
-
- len = count;
- ts = te = 0;
-
- memset(&op, 0, sizeof(network_op_t));
-
- // get the command:
- while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces.
- te = ts;
- while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end
- if ( te <= ts ) goto bad;
- tl = te - ts;
-
- if ( strncmp(&buffer[ts], "ADD", tl) == 0 )
- {
- op.cmd = NETWORK_OP_ADDRULE;
- }
- else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 )
- {
- op.cmd = NETWORK_OP_DELETERULE;
- }
- else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 )
- {
- op.cmd = NETWORK_OP_GETRULELIST;
- goto doneparsing;
- }
-
- ts = te;
-
- // get the action
- while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces.
- te = ts;
- while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end
- if ( te <= ts ) goto bad;
- tl = te - ts;
-
- if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 )
- {
- op.u.net_rule.action = NETWORK_ACTION_ACCEPT;
- goto keyval;
- }
- if ( strncmp(&buffer[ts], "COUNT", tl) == 0 )
- {
- op.u.net_rule.action = NETWORK_ACTION_COUNT;
- goto keyval;
- }
-
- // default case;
- return (len);
-
-
- // get the key=val pairs.
- keyval:
- while (count)
- {
- //get field
- ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; }
- te = ts;
- while ( count && !isspace(buffer[te]) && (buffer[te] != '=') )
- { te++; count--; }
- if ( te <= ts )
- goto doneparsing;
- tl = te - ts;
- fs = ts; fe = te; fl = tl; // save the field markers.
- // skip " = " (ignores extra equals.)
- while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) )
- { te++; count--; }
- ts = te;
- while ( count && !isspace(buffer[te]) ) { te++; count--; }
- tl = te - ts;
-
- if ( (fl <= 0) || (tl <= 0) ) goto bad;
-
- /* NB. Prefix matches must go first! */
- if (strncmp(&buffer[fs], "src", fl) == 0)
- {
- op.u.net_rule.src_vif = VIF_ANY_INTERFACE;
- }
- else if (strncmp(&buffer[fs], "dst", fl) == 0)
- {
- op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
- }
- else if (strncmp(&buffer[fs], "srcaddr", fl) == 0)
- {
- op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstaddr", fl) == 0)
- {
- op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0)
- {
- op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0)
- {
- op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "srcport", fl) == 0)
- {
- op.u.net_rule.src_port = antous(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstport", fl) == 0)
- {
- op.u.net_rule.dst_port = antous(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "srcportmask", fl) == 0)
- {
- op.u.net_rule.src_port_mask = antous(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstportmask", fl) == 0)
- {
- op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "srcdom", fl) == 0)
- {
- op.u.net_rule.src_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
- }
- else if (strncmp(&buffer[fs], "srcidx", fl) == 0)
- {
- op.u.net_rule.src_vif |= anton(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstdom", fl) == 0)
- {
- op.u.net_rule.dst_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
- }
- else if (strncmp(&buffer[fs], "dstidx", fl) == 0)
- {
- op.u.net_rule.dst_vif |= anton(&buffer[ts], tl);
- }
- else if ( (strncmp(&buffer[fs], "proto", fl) == 0))
- {
- if (strncmp(&buffer[ts], "any", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_ANY;
- if (strncmp(&buffer[ts], "ip", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_IP;
- if (strncmp(&buffer[ts], "tcp", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_TCP;
- if (strncmp(&buffer[ts], "udp", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_UDP;
- if (strncmp(&buffer[ts], "arp", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_ARP;
- }
- }
-
- doneparsing:
- ret = HYPERVISOR_network_op(&op);
- return(len);
-
- bad:
- return(len);
-
-
-}
-
-static int __init init_module(void)
-{
- *readbuf = '\0';
- proc_vfr = create_proc_entry ("vfr", 0600, &proc_root);
- if ( proc_vfr != NULL )
- {
- proc_vfr->owner = THIS_MODULE;
- proc_vfr->nlink = 1;
- proc_vfr->read_proc = vfr_read_proc;
- proc_vfr->write_proc = vfr_write_proc;
- printk("Successfully installed virtual firewall/router interface\n");
- }
- return 0;
-}
-
-static void __exit cleanup_module(void)
-{
- if ( proc_vfr == NULL ) return;
- remove_proc_entry("vfr", &proc_root);
- proc_vfr = NULL;
-}
-
-module_init(init_module);
-module_exit(cleanup_module);
-
-/* Helper functions start here: */
-
-int anton(const char *buff, int len)
-{
- int ret;
- char c;
- int sign = 1;
-
- ret = 0;
-
- if (len == 0) return 0;
- if (*buff == '-') { sign = -1; buff++; len--; }
-
- while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
- {
- ret *= 10;
- ret += c - '0';
- buff++; len--;
- }
-
- ret *= sign;
- return ret;
-}
-
-u16 antous(const char *buff, int len)
-{
- u16 ret;
- char c;
-
- ret = 0;
-
- while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
- {
- ret *= 10;
- ret += c - '0';
- buff++; len--;
- }
-
- return ret;
-}
-
-u32 getipaddr(const char *buff, unsigned int len)
-{
- char c;
- u32 ret, val;
-
- ret = 0; val = 0;
-
- while ( len )
- {
- if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) )
- {
- return(0); // malformed.
- }
-
- if ( c == '.' ) {
- if (val > 255) return (0); //malformed.
- ret = ret << 8;
- ret += val;
- val = 0;
- len--; buff++;
- continue;
- }
- val *= 10;
- val += c - '0';
- buff++; len--;
- }
- ret = ret << 8;
- ret += val;
-
- return (ret);
-}
-