Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


large scale namespace changes
[palacios.git] / palacios / src / devices / generic.c
index 905a9a7..130c708 100644 (file)
@@ -1,6 +1,23 @@
-/* (c) 2008, Peter Dinda <pdinda@northwestern.edu> */
-/* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
-
+/* 
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National 
+ * Science Foundation and the Department of Energy.  
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico.  You can find out more at 
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Peter Dinda <pdinda@northwestern.edu>
+ * Contributor: 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ *        
+ *
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
 
 #include <devices/generic.h>
 #include <palacios/vmm.h>
@@ -53,27 +70,22 @@ struct irq_range {
 
 
 
-int generic_reset_device(struct vm_device * dev)
-{
+static int generic_reset_device(struct vm_device * dev) {
   PrintDebug("generic: reset device\n");
   return 0;
-
 }
 
 
 
 
 
-int generic_start_device(struct vm_device * dev)
-{
+static int generic_start_device(struct vm_device * dev) {
   PrintDebug("generic: start device\n");
   return 0;
 }
 
 
-int generic_stop_device(struct vm_device * dev)
-{
+static int generic_stop_device(struct vm_device * dev) {
   PrintDebug("generic: stop device\n");
   return 0;
 }
@@ -81,11 +93,10 @@ int generic_stop_device(struct vm_device * dev)
 
 
 
-int generic_write_port_passthrough(ushort_t port,
-                                  void * src, 
-                                  uint_t length,
-                                  struct vm_device * dev)
-{
+static int generic_write_port_passthrough(ushort_t port,
+                                         void * src, 
+                                         uint_t length,
+                                         struct vm_device * dev) {
   uint_t i;
 
   PrintDebug("generic: writing 0x");
@@ -99,7 +110,6 @@ int generic_write_port_passthrough(ushort_t port,
 
   switch (length) {
   case 1:
-
     v3_outb(port,((uchar_t*)src)[0]);
     break;
   case 2:
@@ -107,7 +117,6 @@ int generic_write_port_passthrough(ushort_t port,
     break;
   case 4:
     v3_outdw(port,((uint_t*)src)[0]);
-
     break;
   default:
     for (i = 0; i < length; i++) { 
@@ -121,11 +130,10 @@ int generic_write_port_passthrough(ushort_t port,
   return length;
 }
 
-int generic_read_port_passthrough(ushort_t port,
-                                 void * src, 
-                                 uint_t length,
-                                 struct vm_device * dev)
-{
+static int generic_read_port_passthrough(ushort_t port,
+                                        void * src, 
+                                        uint_t length,
+                                        struct vm_device * dev) {
   uint_t i;
 
   PrintDebug("generic: reading 0x%x bytes from port 0x%x ...", length, port);
@@ -158,11 +166,10 @@ int generic_read_port_passthrough(ushort_t port,
   return length;
 }
 
-int generic_write_port_ignore(ushort_t port,
-                             void * src, 
-                             uint_t length,
-                             struct vm_device * dev)
-{
+static int generic_write_port_ignore(ushort_t port,
+                                    void * src, 
+                                    uint_t length,
+                                    struct vm_device * dev) {
   uint_t i;
 
   PrintDebug("generic: writing 0x");
@@ -176,11 +183,10 @@ int generic_write_port_ignore(ushort_t port,
   return length;
 }
 
-int generic_read_port_ignore(ushort_t port,
-                            void * src, 
-                            uint_t length,
-                            struct vm_device * dev)
-{
+static int generic_read_port_ignore(ushort_t port,
+                                   void * src, 
+                                   uint_t length,
+                                   struct vm_device * dev) {
 
   PrintDebug("generic: reading 0x%x bytes from port 0x%x ...", length, port);
 
@@ -192,16 +198,16 @@ int generic_read_port_ignore(ushort_t port,
 
 
 
-int generic_interrupt(uint_t irq, struct vm_device * dev) {
+static int generic_interrupt(uint_t irq, struct vm_device * dev) {
   PrintDebug("generic: interrupt 0x%x - injecting into VM\n", irq);
 
-  dev->vm->vm_ops.raise_irq(dev->vm, irq);
+  v3_raise_irq(dev->vm, irq);
 
   return 0;
 }
 
 
-int generic_init_device(struct vm_device * dev) {
+static int generic_init_device(struct vm_device * dev) {
   struct generic_internal * state = (struct generic_internal *)(dev->private_data);
 
   PrintDebug("generic: init_device\n");
@@ -221,13 +227,13 @@ int generic_init_device(struct vm_device * dev) {
       for (i = tmp->start; i <= tmp->end; i++) { 
        if (tmp->type == GENERIC_PRINT_AND_PASSTHROUGH) { 
          
-         if (dev_hook_io(dev, i, &generic_read_port_passthrough, &generic_write_port_passthrough)) { 
+         if (v3_dev_hook_io(dev, i, &generic_read_port_passthrough, &generic_write_port_passthrough)) { 
            PrintDebug("generic: can't hook port 0x%x (already hooked?)\n", i);
          }
          
        } else if (tmp->type == GENERIC_PRINT_AND_IGNORE) { 
          
-         if (dev_hook_io(dev, i, &generic_read_port_ignore, &generic_write_port_ignore)) { 
+         if (v3_dev_hook_io(dev, i, &generic_read_port_ignore, &generic_write_port_ignore)) { 
            PrintDebug("generic: can't hook port 0x%x (already hooked?)\n", i);
          }
        } 
@@ -249,7 +255,7 @@ int generic_init_device(struct vm_device * dev) {
                 tmp->start, tmp->end); 
       
       
-      if (dev_hook_mem(dev, tmp->start, tmp->end)) {
+      if (v3_dev_hook_mem(dev, tmp->start, tmp->end)) {
        PrintDebug("generic: Can't hook addresses 0x%x to 0x%x (already hooked?)\n",
                   tmp->start, tmp->end); 
       }
@@ -271,7 +277,7 @@ int generic_init_device(struct vm_device * dev) {
                 tmp->start, tmp->end);
       
       for (i = tmp->start; i <= tmp->end; i++) { 
-       if (dev_hook_irq(dev, i, &generic_interrupt)) { 
+       if (v3_dev_hook_irq(dev, i, &generic_interrupt)) { 
          PrintDebug("generic: can't hook irq  0x%x (already hooked?)\n", i);
        }
       }
@@ -286,7 +292,7 @@ int generic_init_device(struct vm_device * dev) {
   return 0;
 }
 
-int generic_deinit_device(struct vm_device * dev) {
+static int generic_deinit_device(struct vm_device * dev) {
   struct generic_internal * state = (struct generic_internal *)(dev->private_data);
 
 
@@ -305,7 +311,7 @@ int generic_deinit_device(struct vm_device * dev) {
       
 
       for (i = cur->start; i <= cur->end; i++) { 
-       if (dev_unhook_irq(dev, i)) {
+       if (v3_dev_unhook_irq(dev, i)) {
          PrintDebug("generic: can't unhook irq 0x%x (already unhooked?)\n", i);
        }
       }
@@ -328,7 +334,7 @@ int generic_deinit_device(struct vm_device * dev) {
       PrintDebug("generic: unhooking addresses 0x%x to 0x%x\n",
                 cur->start, cur->end); 
 
-      if (dev_unhook_mem(dev, cur->start, cur->end)) {
+      if (v3_dev_unhook_mem(dev, cur->start, cur->end)) {
        PrintDebug("generic: Can't unhook addresses 0x%x to 0x%x (already unhooked?)\n",
                   cur->start, cur->end); 
       }
@@ -353,7 +359,7 @@ int generic_deinit_device(struct vm_device * dev) {
                   cur->start, cur->end);
                
       for (i = cur->start; i <= cur->end; i++) {
-       if (dev_unhook_io(dev, i)) {
+       if (v3_dev_unhook_io(dev, i)) {
          PrintDebug("generic: can't unhook port 0x%x (already unhooked?)\n", i);
        }
       }
@@ -455,7 +461,7 @@ int v3_generic_add_irq_range(struct vm_device * dev, uint_t start, uint_t end, u
 
 
 
-struct vm_device * create_generic() {
+struct vm_device * v3_create_generic() {
   struct generic_internal * generic_state = (struct generic_internal *)V3_Malloc(sizeof(struct generic_internal));
   
   generic_state->num_port_ranges = 0;
@@ -466,7 +472,7 @@ struct vm_device * create_generic() {
   INIT_LIST_HEAD(&(generic_state->mem_list));
   INIT_LIST_HEAD(&(generic_state->irq_list));
     
-  struct vm_device * device = create_device("GENERIC", &dev_ops, generic_state);
+  struct vm_device * device = v3_create_device("GENERIC", &dev_ops, generic_state);
 
   return device;
 }