From: Peter Dinda Date: Mon, 23 Jun 2008 17:15:02 +0000 (+0000) Subject: Fixed the FS/GS save/restore problem X-Git-Tag: boot386puppy-26-to-ide~17 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=3b49b57d1f3b8bccdf7390c26ea9cda1f8dac8c3 Fixed the FS/GS save/restore problem Added PCI Added Out/In_DWord Patched to compile Debugging? --- diff --git a/palacios/src/geekos/int.c b/palacios/src/geekos/int.c index 513240d..f83087e 100644 --- a/palacios/src/geekos/int.c +++ b/palacios/src/geekos/int.c @@ -1,7 +1,7 @@ /* * GeekOS interrupt handling data structures and functions * Copyright (c) 2001,2003 David H. Hovemeyer - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". @@ -396,7 +396,7 @@ void Dump_Interrupt_State(struct Interrupt_State* state) { uint_t errorCode = state->errorCode; - PrintBoth("eax=%08x ebx=%08x ecx=%08x edx=%08x\n" + SerialPrint("eax=%08x ebx=%08x ecx=%08x edx=%08x\n" "esi=%08x edi=%08x ebp=%08x\n" "eip=%08x cs=%08x eflags=%08x\n" "Interrupt number=%d (%s), error code=%d\n" diff --git a/palacios/src/geekos/io.c b/palacios/src/geekos/io.c index 3132733..1310cdc 100644 --- a/palacios/src/geekos/io.c +++ b/palacios/src/geekos/io.c @@ -1,7 +1,7 @@ /* * x86 port IO routines * Copyright (c) 2001, David H. Hovemeyer - * $Revision: 1.1 $ + * $Revision: 1.2 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". @@ -50,7 +50,7 @@ void Out_Word(ushort_t port, ushort_t value) } /* - * Read a byte from an I/O port. + * Read a word from an I/O port. */ ushort_t In_Word(ushort_t port) { @@ -66,6 +66,34 @@ ushort_t In_Word(ushort_t port) } /* + * Write a double word to an I/O port. + */ +void Out_DWord(ushort_t port, uint_t value) +{ + __asm__ __volatile__ ( + "outl %0, %1" + : + : "a" (value), "Nd" (port) + ); +} + +/* + * Read a double word from an I/O port. + */ +uint_t In_DWord(ushort_t port) +{ + uint_t value; + + __asm__ __volatile__ ( + "inl %1, %0" + : "=a" (value) + : "Nd" (port) + ); + + return value; +} + +/* * Short delay. May be needed when talking to some * (slow) I/O devices. */ diff --git a/palacios/src/geekos/kthread.c b/palacios/src/geekos/kthread.c index 9b614d2..1a67775 100644 --- a/palacios/src/geekos/kthread.c +++ b/palacios/src/geekos/kthread.c @@ -1,7 +1,7 @@ /* * Kernel threads * Copyright (c) 2001,2003 David H. Hovemeyer - * $Revision: 1.2 $ + * $Revision: 1.3 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". @@ -560,6 +560,8 @@ void Schedule(void) * will "return", and then Schedule() will return to wherever * it was called from. */ + + SerialPrint("Switch_To_Thread() in Schedule()\n"); Switch_To_Thread(runnable); } diff --git a/palacios/src/geekos/main.c b/palacios/src/geekos/main.c index a498a90..e557664 100644 --- a/palacios/src/geekos/main.c +++ b/palacios/src/geekos/main.c @@ -3,7 +3,7 @@ * Copyright (c) 2001,2003,2004 David H. Hovemeyer * Copyright (c) 2003, Jeffrey K. Hollingsworth * Copyright (c) 2004, Iulian Neamtiu - * $Revision: 1.36 $ + * $Revision: 1.37 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". @@ -36,6 +36,7 @@ #include +#include @@ -192,6 +193,9 @@ void Main(struct Boot_Info* bootInfo) Init_Keyboard(); Init_VM(bootInfo); Init_Paging(); + + Init_PCI(); + Init_Stubs(); // Init_IDE(); diff --git a/palacios/src/geekos/timer.c b/palacios/src/geekos/timer.c index dbda61f..766ce07 100644 --- a/palacios/src/geekos/timer.c +++ b/palacios/src/geekos/timer.c @@ -2,7 +2,7 @@ * GeekOS timer interrupt support * Copyright (c) 2001,2003 David H. Hovemeyer * Copyright (c) 2003, Jeffrey K. Hollingsworth - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". @@ -208,11 +208,20 @@ static void Timer_Interrupt_Handler(struct Interrupt_State* state) SerialPrint("Host Timer Interrupt Handler running\n"); + +#if 0 +#define STACK_LEN 256 + + SerialPrint("Timer====\n"); + Dump_Interrupt_State(state); + // SerialMemDump((unsigned char*)(¤t),STACK_LEN); + SerialPrint("Timer done===\n"); + +#endif /* Update global and per-thread number of ticks */ ++g_numTicks; ++current->numTicks; - /* * If thread has been running for an entire quantum, * inform the interrupt return code that we want diff --git a/palacios/src/geekos/vm.c b/palacios/src/geekos/vm.c index 92d61f1..0b69b6a 100644 --- a/palacios/src/geekos/vm.c +++ b/palacios/src/geekos/vm.c @@ -334,10 +334,34 @@ int RunVMM(struct Boot_Info * bootInfo) { struct vm_device * keyboard = create_keyboard(); struct vm_device * pit = create_pit(); - //generic_port_range_type range = {0,1024} ; // hook first 1024 ports if not already hooked - //struct vm_device * generic = create_generic(&range, 1, NULL, 0, NULL, 0); + +#if GENERIC + generic_port_range_type range[] = { + {0x00, 0x07}, // DMA 1 channels 0,1,2,3 (address, counter) + {0xc0, 0xc7}, // DMA 2 channels 4,5,6,7 (address, counter) + {0x87, 0x87}, // DMA 1 channel 0 page register + {0x83, 0x83}, // DMA 1 channel 1 page register + {0x81, 0x81}, // DMA 1 channel 2 page register + {0x82, 0x82}, // DMA 1 channel 3 page register + {0x8f, 0x8f}, // DMA 2 channel 4 page register + {0x8b, 0x8b}, // DMA 2 channel 5 page register + {0x89, 0x89}, // DMA 2 channel 6 page register + {0x8a, 0x8a}, // DMA 2 channel 7 page register + {0x08, 0x0f}, // DMA 1 misc registers (csr, req, smask,mode,clearff,reset,enable,mmask) + {0xd0, 0xde}, // DMA 2 misc registers + {0x3f0, 0x3f2}, // Primary floppy controller (base,statusa/statusb,DOR) + {0x3f4, 0x3f5}, // Primary floppy controller (mainstat/datarate,data) + {0x3f7, 0x3f7}, // Primary floppy controller (DIR) + {0x370, 0x372}, // Secondary floppy controller (base,statusa/statusb,DOR) + {0x374, 0x375}, // Secondary floppy controller (mainstat/datarate,data) + {0x377, 0x377}, // Secondary floppy controller (DIR) + {0x378, 0x400} + }; + + struct vm_device * generic = create_generic(range,19,NULL,0,NULL,0); +#endif attach_device(&(vm_info), nvram); //attach_device(&(vm_info), timer); @@ -345,8 +369,12 @@ int RunVMM(struct Boot_Info * bootInfo) { attach_device(&(vm_info), pit); attach_device(&(vm_info), keyboard); + +#if GENERIC // Important that this be attached last! - //attach_device(&(vm_info), generic); + attach_device(&(vm_info), generic); + +#endif PrintDebugDevMgr(&(vm_info.dev_mgr)); } diff --git a/palacios/src/palacios/svm_lowlevel.asm b/palacios/src/palacios/svm_lowlevel.asm index 503776f..77e8597 100644 --- a/palacios/src/palacios/svm_lowlevel.asm +++ b/palacios/src/palacios/svm_lowlevel.asm @@ -143,6 +143,8 @@ safe_svm_launch: push ebp mov ebp, esp pushf + push fs + push gs pusha ;; Save Host state @@ -166,6 +168,8 @@ safe_svm_launch: add esp, 4 ;; skip past the gpr ptr popa ;; Restore Host state + pop gs + pop fs popf pop ebp ret diff --git a/palacios/src/palacios/vmm_decoder.c b/palacios/src/palacios/vmm_decoder.c index 9b8d91e..a414691 100644 --- a/palacios/src/palacios/vmm_decoder.c +++ b/palacios/src/palacios/vmm_decoder.c @@ -10,16 +10,16 @@ int v3_parse_instr(struct guest_info * info, struct x86_operand * dst_operand, struct x86_operand * extra_operand) { - V3_Assert(src_operand != NULL); - V3_Assert(dst_operand != NULL); - V3_Assert(extra_operand != NULL); - V3_Assert(instr_length != NULL); - V3_Assert(info != NULL); + V3_ASSERT(src_operand != NULL); + V3_ASSERT(dst_operand != NULL); + V3_ASSERT(extra_operand != NULL); + V3_ASSERT(instr_length != NULL); + V3_ASSERT(info != NULL); // Ignore prefixes for now - while (is_prefix_byte(*instr)) { - instr++; + while (is_prefix_byte(*instr_ptr)) { + instr_ptr++; *instr_length++; }