X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86%2Fvm8086.c;h=f1b50059989a0590d0871a35b296d512f5912be1;hb=14d0ba44433f0f828aff710184fd3c597ab73999;hp=c1c48ce39684e9419616e6f53ca12dae2b285525;hpb=e2744a459d1c63435d7348d0bfd0e4b92b0ec9f9;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86/vm8086.c b/KernelLand/Kernel/arch/x86/vm8086.c index c1c48ce3..f1b50059 100644 --- a/KernelLand/Kernel/arch/x86/vm8086.c +++ b/KernelLand/Kernel/arch/x86/vm8086.c @@ -68,16 +68,14 @@ Uint32 gaVM8086_MemBitmap[VM8086_BLOCKCOUNT/32]; // === FUNCTIONS === int VM8086_Install(char **Arguments) { - tPID pid; - Semaphore_Init(&gVM8086_TasksToDo, 0, 10, "VM8086", "TasksToDo"); // Lock to avoid race conditions Mutex_Acquire( &glVM8086_Process ); // Create BIOS Call process - pid = Proc_Clone(CLONE_VM); - //Log_Debug("VM8086", "pid = %i", pid); + tPID pid = Proc_Clone(CLONE_VM); + LOG("pid = %i", pid); if(pid == -1) { Log_Error("VM8086", "Unable to clone kernel into VM8086 worker"); @@ -87,22 +85,24 @@ int VM8086_Install(char **Arguments) { Uint * volatile stacksetup; // Initialising Stack Uint16 * volatile rmstack; // Real Mode Stack - int i; - //Log_Debug("VM8086", "Initialising worker"); + LOG("Initialising worker"); // Set Image Name Threads_SetName("VM8086"); // Map ROM Area - for(i=0xA0;i<0x100;i++) { + for(unsigned int i = 0xA0;i<0x100;i++) { + MM_RefPhys(i * 0x1000); MM_Map( (void*)(i * 0x1000), i * 0x1000 ); } + MM_RefPhys(0); MM_Map( (void*)0, 0 ); // IVT / BDA if( MM_GetRefCount(0x00000) > 2 ) { Log_Notice("VM8086", "Ok, who's touched the IVT? (%i)", MM_GetRefCount(0x00000)); } + MM_RefPhys(0x9F000); MM_Map( (void*)0x9F000, 0x9F000 ); // Stack / EBDA if( MM_GetRefCount(0x9F000) > 2 ) { Log_Notice("VM8086", "And who's been playing with my EBDA? (%i)", @@ -147,6 +147,7 @@ int VM8086_Install(char **Arguments) stacksetup--; *stacksetup = 0x20|3; // ES - Kernel stacksetup--; *stacksetup = 0x20|3; // FS stacksetup--; *stacksetup = 0x20|3; // GS + LOG("stacksetup = %p, entering vm8086"); __asm__ __volatile__ ( "mov %%eax,%%esp;\n\t" // Set stack pointer "pop %%gs;\n\t" @@ -161,6 +162,7 @@ int VM8086_Install(char **Arguments) gVM8086_WorkerPID = pid; // It's released when the GPF fires + LOG("Waiting for worker %i to start", gVM8086_WorkerPID); Mutex_Acquire( &glVM8086_Process ); Mutex_Release( &glVM8086_Process ); @@ -222,6 +224,7 @@ void VM8086_GPF(tRegs *Regs) { if( !gpVM8086_State->Internal->AllocatedPages[i].VirtBase ) continue ; + MM_RefPhys( gpVM8086_State->Internal->AllocatedPages[i].PhysAddr ); MM_Map( (tPage*)VM8086_USER_BASE + i, gpVM8086_State->Internal->AllocatedPages[i].PhysAddr ); }