# Makefile for GeekOS kernel, userspace, and tools
 # Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.64 $
+# $Revision: 1.65 $
 
 # This is free software.  You are permitted to use,
 # redistribute, and modify it as specified in the file "COPYING".
 DEBUG_SECTIONS= 
 
 ifeq ($(DEBUG_ALL),1)
-  DEBUG_SECTIONS:= $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_IO -DDEBUG_KEYBOARD -DDEBUG_PIC -DDEBUG_PIT -DDEBUG_NVRAM -DDEBUG_EMULATOR -DDEBUG_GENERIC 
+  DEBUG_SECTIONS:= $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_IO -DDEBUG_KEYBOARD -DDEBUG_PIC -DDEBUG_PIT -DDEBUG_NVRAM -DDEBUG_EMULATOR -DDEBUG_GENERIC -DDEBUG_RAMDISK
 endif
 ifeq ($(DEBUG_SHADOW_PAGING),1)
 DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
                 vm_dev.c vmm_dev_mgr.c vmm_decoder.c \
                 svm_halt.c svm_pause.c svm_wbinvd.c \
                vmm_config.c vmm_hashtable.c \
-               vmm_string.c vmm_emulator.c \
+               vmm_string.c vmm_emulator.c vmm_queue.c\
                 $(DECODER_SRCS)
 #              vmx.c vmcs_gen.c vmcs.c
 
 
 
 
 
-
+/*
 // First opcode byte
 static const uchar_t cr_access_byte = 0x0f;
 
 static const uchar_t clts_byte = 0x06;
 static const uchar_t mov_to_cr_byte = 0x22;
 static const uchar_t mov_from_cr_byte = 0x20;
-
+*/
 
 
 int handle_cr0_write(struct guest_info * info);
 
--- /dev/null
+#ifndef __VMM_QUEUE_H__
+#define __VMM_QUEUE_H__
+
+#ifdef __V3VEE__
+
+#include <palacios/vmm.h>
+#include <palacios/vmm_list.h>
+
+
+
+/* IMPORTANT:
+ * This implementation currently does no locking, and as such is not 
+ * SMP/thread/interrupt safe
+ */
+
+
+struct queue_entry {
+  addr_t entry;
+  struct list_head entry_list;
+};
+
+
+struct gen_queue {
+  uint_t num_entries;
+  struct list_head entries;
+
+  // We really need to implement this....
+  // void * lock;
+};
+
+
+struct gen_queue * create_queue();
+void init_queue(struct gen_queue * queue);
+
+void enqueue(struct gen_queue * queue, addr_t entry);
+addr_t dequeue(struct gen_queue * queue);
+
+
+
+#endif // ! __V3VEE__
+
+#endif
 
 #endif
 
 
-
-
-
 // First Attempt = 494 lines
 // current = 106 lines
 int handle_cr0_write(struct guest_info * info) {
 
 
 
-// First Attemp = 256 lines
+// First Attempt = 256 lines
 // current = 65 lines
 int handle_cr3_write(struct guest_info * info) {
   int ret;
       
 
       cached = cache_page_tables32(info, CR3_TO_PDE32(*(addr_t *)new_cr3));
+
       if (cached == -1) {
        PrintError("CR3 Cache failed\n");
        return -1;
       } else if (cached == 0) {
-
-
        addr_t shadow_pt;
-
        
        PrintDebug("New CR3 is different - flushing shadow page table\n");      
        
     return -1;
   }
 
-
   info->rip += dec_instr.instr_length;
 
   return 0;
 }
-
-
-
-
 
--- /dev/null
+#include <palacios/vmm_queue.h>
+
+
+
+void init_queue(struct gen_queue * queue) {
+  queue->num_entries = 0;
+  INIT_LIST_HEAD(&(queue->entries));
+}
+
+
+struct gen_queue * create_queue() {
+  struct gen_queue * tmp_queue = V3_Malloc(sizeof(struct gen_queue));
+  init_queue(tmp_queue);
+  return tmp_queue;
+}
+
+void enqueue(struct gen_queue * queue, addr_t entry) {
+  struct queue_entry * q_entry = V3_Malloc(sizeof(struct queue_entry));
+
+  q_entry->entry = entry;
+  list_add_tail(&(q_entry->entry_list), &(queue->entries));
+  queue->num_entries++;
+}
+
+
+addr_t dequeue(struct gen_queue * queue) {
+  addr_t entry_val = 0;
+
+  if (!list_empty(&(queue->entries))) {
+    struct list_head * q_entry = queue->entries.next;
+    struct queue_entry * tmp_entry = list_entry(q_entry, struct queue_entry, entry_list);
+
+    entry_val = tmp_entry->entry;
+    list_del(q_entry);
+    V3_Free(tmp_entry);
+  }
+
+  return entry_val;
+}