From: Jack Lange Date: Mon, 25 Aug 2008 21:51:49 +0000 (+0000) Subject: added queue implementation X-Git-Tag: 1.0~61 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=7246e098eaeb10934569dd4c6ef12753a1637351 added queue implementation --- diff --git a/palacios/build/Makefile b/palacios/build/Makefile index b4a27c6..0d31d7e 100644 --- a/palacios/build/Makefile +++ b/palacios/build/Makefile @@ -1,6 +1,6 @@ # Makefile for GeekOS kernel, userspace, and tools # Copyright (c) 2004,2005 David H. Hovemeyer -# $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". @@ -49,7 +49,7 @@ DEBUG=1 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 @@ -216,7 +216,7 @@ VMM_C_SRCS := vm_guest.c \ 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 diff --git a/palacios/include/palacios/vmm_ctrl_regs.h b/palacios/include/palacios/vmm_ctrl_regs.h index f53034c..fad8cdd 100644 --- a/palacios/include/palacios/vmm_ctrl_regs.h +++ b/palacios/include/palacios/vmm_ctrl_regs.h @@ -164,7 +164,7 @@ struct rflags { - +/* // First opcode byte static const uchar_t cr_access_byte = 0x0f; @@ -176,7 +176,7 @@ static const uchar_t smsw_reg_byte = 0x4; 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); diff --git a/palacios/include/palacios/vmm_queue.h b/palacios/include/palacios/vmm_queue.h new file mode 100644 index 0000000..ee0e01a --- /dev/null +++ b/palacios/include/palacios/vmm_queue.h @@ -0,0 +1,42 @@ +#ifndef __VMM_QUEUE_H__ +#define __VMM_QUEUE_H__ + +#ifdef __V3VEE__ + +#include +#include + + + +/* 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 diff --git a/palacios/src/palacios/vmm_ctrl_regs.c b/palacios/src/palacios/vmm_ctrl_regs.c index 4575f99..39303aa 100644 --- a/palacios/src/palacios/vmm_ctrl_regs.c +++ b/palacios/src/palacios/vmm_ctrl_regs.c @@ -20,9 +20,6 @@ #endif - - - // First Attempt = 494 lines // current = 106 lines int handle_cr0_write(struct guest_info * info) { @@ -202,7 +199,7 @@ int handle_cr0_read(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; @@ -246,14 +243,12 @@ int handle_cr3_write(struct guest_info * info) { 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"); @@ -334,12 +329,7 @@ int handle_cr3_read(struct guest_info * info) { return -1; } - info->rip += dec_instr.instr_length; return 0; } - - - - diff --git a/palacios/src/palacios/vmm_queue.c b/palacios/src/palacios/vmm_queue.c new file mode 100644 index 0000000..da5176a --- /dev/null +++ b/palacios/src/palacios/vmm_queue.c @@ -0,0 +1,39 @@ +#include + + + +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; +}