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.


*** empty log message ***
Jack Lange [Tue, 22 Apr 2008 20:12:19 +0000 (20:12 +0000)]
palacios/include/devices/simple_pic.h [new file with mode: 0644]
palacios/include/devices/timer.h [new file with mode: 0644]
palacios/include/palacios/vmm_irq.h [new file with mode: 0644]
palacios/src/devices/simple_pic.c [new file with mode: 0644]
palacios/src/devices/timer.c [new file with mode: 0644]
palacios/src/palacios/vmm_irq.c [new file with mode: 0644]
palacios/src/palacios/vmm_lowlevel.asm [new file with mode: 0644]

diff --git a/palacios/include/devices/simple_pic.h b/palacios/include/devices/simple_pic.h
new file mode 100644 (file)
index 0000000..58a9080
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __SIMPLE_PIC_H
+#define __SIMPLE_PIC_H
+#include <palacios/vm_dev.h>
+
+struct vm_device * create_pic();
+
+#endif
diff --git a/palacios/include/devices/timer.h b/palacios/include/devices/timer.h
new file mode 100644 (file)
index 0000000..8d978a4
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __TIMER_H
+#define __TIMER_H
+
+#include <palacios/vm_dev.h>
+
+
+
+struct vm_device * create_timer();
+
+
+
+
+#endif
diff --git a/palacios/include/palacios/vmm_irq.h b/palacios/include/palacios/vmm_irq.h
new file mode 100644 (file)
index 0000000..26958e2
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef __VMM_IRQ_H
+#define __VMM_IRQ_H
+
+#if 0
+#include <palacios/vmm_types.h>
+
+
+struct vmm_irq_hook;
+
+
+
+
+struct vmm_irq_hook {
+  uint_t irq;
+  void * private_data;
+
+  int(*handler)(uint_t irq, void * private_data);
+
+  struct vmm_irq_hook *next, *prev;
+};
+
+
+void init_irq_map(struct vmm_irq_map * map);
+
+
+int hook_irq(struct vmm_irq_map * map, uint_t irq, 
+            int(*handler)(uint_t irq, void * private_data), 
+            void * private_data);
+
+
+int unhook_irq(struct vmm_irq_map * map, uint_t irq);
+
+struct vmm_irq_hook * get_irq_hook(struct vmm_irq_map * map, uint_t irq);
+
+#endif
+#endif
diff --git a/palacios/src/devices/simple_pic.c b/palacios/src/devices/simple_pic.c
new file mode 100644 (file)
index 0000000..a4e25f5
--- /dev/null
@@ -0,0 +1,78 @@
+#include <devices/simple_pic.h>
+#include <palacios/vmm_intr.h>
+#include <palacios/vmm_types.h>
+#include <palacios/vmm.h>
+
+struct pic_internal {
+  int pending_irq;
+  int error_code;
+};
+
+
+int pic_intr_pending(void * private_data) {
+  struct pic_internal * data = (struct pic_internal *)private_data;
+  
+  return (data->pending_irq > 0);
+}
+
+int pic_raise_intr(void * private_data, int irq, int error_code) {
+  struct pic_internal * data = (struct pic_internal *)private_data;
+
+  data->pending_irq = irq;
+  data->error_code = error_code;
+
+  return 0;
+}
+
+
+int pic_get_intr_number(void * private_data) {
+  struct pic_internal * data = (struct pic_internal *)private_data;
+
+  return data->pending_irq;
+}
+
+
+static struct intr_ctrl_ops intr_ops = {
+  .intr_pending = pic_intr_pending,
+  .get_intr_number = pic_get_intr_number,
+  .raise_intr = pic_raise_intr
+};
+
+
+
+
+int pic_init_device(struct vm_device * dev) {
+  struct pic_internal * data = (struct pic_internal *)dev->private_data;
+  set_intr_controller(dev->vm, &intr_ops, data);
+  data->pending_irq = 0;
+
+  return 0;
+}
+
+
+int pic_deinit_device(struct vm_device * dev) {
+  return 0;
+}
+
+
+
+
+
+static struct vm_device_ops dev_ops = {
+  .init = pic_init_device,
+  .deinit = pic_deinit_device,
+  .reset = NULL,
+  .start = NULL,
+  .stop = NULL
+};
+
+
+struct vm_device * create_pic() {
+  struct pic_internal * state = NULL;
+  VMMMalloc(struct pic_internal *, state, sizeof(struct pic_internal));
+
+  struct vm_device * pic_dev = create_device("Simple Pic", &dev_ops, state);
+
+
+  return pic_dev;
+}
diff --git a/palacios/src/devices/timer.c b/palacios/src/devices/timer.c
new file mode 100644 (file)
index 0000000..24c2a83
--- /dev/null
@@ -0,0 +1,48 @@
+#include <devices/timer.h>
+#include <palacios/vmm.h>
+
+
+#define TIMER_IRQ 32
+
+struct timer_state {
+  int foo;
+};
+
+
+
+int irq_handler(uint_t irq, struct vm_device * dev) {
+  PrintDebug("Timer interrupt\n");
+  return 0;
+
+}
+
+int timer_init(struct vm_device * dev) {
+  //dev_hook_irq(dev, TIMER_IRQ, &irq_handler);
+
+  return 0;
+}
+
+int timer_deinit(struct vm_device * dev) {
+
+  return 0;
+}
+
+
+static struct vm_device_ops dev_ops = {
+  .init = timer_init,
+  .deinit = timer_deinit,
+  .reset = NULL,
+  .start = NULL,
+  .stop = NULL,
+
+};
+
+
+struct vm_device * create_timer() {
+  struct timer_state * timer = NULL;
+  VMMMalloc(struct timer_state *, timer, sizeof(struct timer_state));
+  struct vm_device * dev = create_device("Timer", &dev_ops, timer);
+  
+  return dev;
+
+}
diff --git a/palacios/src/palacios/vmm_irq.c b/palacios/src/palacios/vmm_irq.c
new file mode 100644 (file)
index 0000000..8210c72
--- /dev/null
@@ -0,0 +1,122 @@
+#if 0
+#include <palacios/vmm_irq.h>
+#include <palacios/vmm.h>
+
+void init_irq_map(struct vmm_irq_map * map) {
+  map->head = NULL;
+  map->num_hooks = 0;
+}
+
+
+int add_irq_hook(struct vmm_irq_map * map, struct vmm_irq_hook * hook) {
+  if (!(map->head)) {
+    map->head = hook;
+    map->num_hooks = 1;
+    return 0;
+  } else if (map->head->irq > hook->irq) {
+    hook->next = map->head;
+
+    map->head->prev = hook;
+    map->head = hook;
+    map->num_hooks++;
+
+    return 0;
+  } else {
+    struct vmm_irq_hook * tmp_hook = map->head;
+    while ((tmp_hook->next) &&
+          (tmp_hook->next->irq <= hook->irq)) {
+      tmp_hook = tmp_hook->next;
+    }
+
+    if (tmp_hook->irq == hook->irq) {
+      return -1;
+    } else {
+      hook->prev = tmp_hook;
+      hook->next = tmp_hook->next;
+
+      if (tmp_hook->next) {
+       tmp_hook->next->prev = hook;
+      }
+
+      tmp_hook->next = hook;
+
+      map->num_hooks++;
+      return 0;
+    }
+  }
+  return -1;
+}
+
+
+int remove_irq_hook(struct vmm_irq_map * map, struct vmm_irq_hook * hook) {
+  if (map->head == hook) {
+    map->head = hook->next;
+  } else if (hook->prev) {
+    hook->prev->next = hook->next;
+  } else {
+    return -1;
+  }
+
+  if (hook->next) {
+    hook->next->prev = hook->prev;
+  }
+
+  map->num_hooks--;
+
+  return 0;
+}
+
+
+int hook_irq(struct vmm_irq_map * map, uint_t irq, 
+            int(*handler)(uint_t irq, void * private_data), 
+            void * private_data) {
+
+  struct vmm_irq_hook * hook = NULL;
+  VMMMalloc(struct vmm_irq_hook *, hook, sizeof(struct vmm_irq_hook));
+
+  if (!hook) {
+    // big problems
+    return -1;
+  }
+
+  hook->irq = irq;
+  hook->handler = handler;
+  hook->private_data = private_data;
+  hook->next = NULL;
+  hook->prev = NULL;
+  
+  if (add_irq_hook(map, hook) != 0) {
+    VMMFree(hook);
+    return -1;
+  }
+
+  return 0;
+}
+
+
+int unhook_irq(struct vmm_irq_map * map, uint_t irq) {
+  struct vmm_irq_hook * hook = get_irq_hook(map, irq);
+
+  if (!hook) {
+    return -1;
+  }
+
+  remove_irq_hook(map, hook);
+  return 0;
+}
+
+
+struct vmm_irq_hook * get_irq_hook(struct vmm_irq_map * map, uint_t irq) {
+  struct vmm_irq_hook * tmp_hook = map->head;
+  
+  while (tmp_hook) {
+    if (tmp_hook->irq == irq) {
+      return tmp_hook;
+    }
+    tmp_hook = tmp_hook->next;
+  }
+  return NULL;
+}
+
+
+#endif
diff --git a/palacios/src/palacios/vmm_lowlevel.asm b/palacios/src/palacios/vmm_lowlevel.asm
new file mode 100644 (file)
index 0000000..03f8294
--- /dev/null
@@ -0,0 +1,72 @@
+; -*- fundamental -*-
+
+
+%ifndef VMM_ASM
+%define VMM_ASM
+
+%include "vmm_symbol.asm"
+
+EXPORT DisableInts
+
+EXPORT GetGDTR
+EXPORT GetIDTR
+EXPORT GetTR
+
+
+
+
+
+
+align 8
+DisableInts:
+       cli
+       ret
+
+
+align 8
+GetGDTR:
+       push    ebp
+       mov     ebp, esp
+       pusha   
+       mov     ebx, [ebp + 8]
+       sgdt    [ebx]
+       
+       popa
+       pop     ebp
+       ret
+
+
+align 8
+GetIDTR:
+       push    ebp
+       mov     ebp, esp
+       pusha   
+
+       mov     ebx, [ebp + 8]
+       sidt    [ebx]
+       
+       popa
+       pop     ebp
+       ret
+
+
+
+align 8
+GetTR:
+       push    ebp
+       mov     ebp, esp
+       pusha   
+       mov     ebx, [ebp + 8]
+       str     [ebx]
+       
+       popa
+       pop     ebp
+       ret
+
+
+
+
+
+
+
+%endif
\ No newline at end of file