X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fvm8086.c;h=46daeefd4a7ad23ae4fbaeeed3b98d9cd3bfeaf3;hb=c575e49ea4543b45ccd2a47d57ec590ca995e707;hp=6d60d9b141f82227feec3da393257f982cf0b19a;hpb=c205f388f8722a5d73f71ee98b0232444c5c7e9d;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/vm8086.c b/Kernel/arch/x86/vm8086.c index 6d60d9b1..46daeefd 100644 --- a/Kernel/arch/x86/vm8086.c +++ b/Kernel/arch/x86/vm8086.c @@ -6,6 +6,7 @@ #include #include #include +#include // === CONSTANTS === #define VM8086_MAGIC_CS 0xFFFF @@ -28,9 +29,6 @@ enum eVM8086_Opcodes #define VM8086_BLOCKSIZE 128 #define VM8086_BLOCKCOUNT ((0x9F000-0x10000)/VM8086_BLOCKSIZE) -// === IMPORTS === - int Proc_Clone(Uint *Err, Uint Flags); - // === TYPES === struct sVM8086_InternalData { @@ -63,7 +61,7 @@ int VM8086_Install(char **Arguments) Mutex_Acquire( &glVM8086_Process ); // Create BIOS Call process - pid = Proc_Clone(NULL, CLONE_VM); + pid = Proc_Clone(CLONE_VM); if(pid == -1) { Log_Error("VM8086", "Unable to clone kernel into VM8086 worker"); @@ -74,22 +72,24 @@ int VM8086_Install(char **Arguments) Uint * volatile stacksetup; // Initialising Stack Uint16 * volatile rmstack; // Real Mode Stack int i; - + // Set Image Name Threads_SetName("VM8086"); - + + Log_Debug("VM8086", "Mapping memory"); + // Map ROM Area for(i=0xA0;i<0x100;i++) { MM_Map( i * 0x1000, i * 0x1000 ); - //MM_SetFlags( i * 0x1000, MM_PFLAG_RO, MM_PFLAG_RO ); // Set Read Only } + Log_Debug("VM8086", "ROM area mapped"); MM_Map( 0, 0 ); // IVT / BDA // Map (but allow allocation) of 0x1000 - 0x9F000 // - So much hack, it isn't funny for(i=1;i<0x9F;i++) { MM_Map( i * 0x1000, i * 0x1000 ); MM_DerefPhys( i * 0x1000 ); // Above - if(MM_GetRefCount(i*0x1000)) + while(MM_GetRefCount(i*0x1000)) MM_DerefPhys( i * 0x1000 ); // Phys setup } MM_Map( 0x9F000, 0x9F000 ); // Stack / EBDA @@ -99,6 +99,7 @@ int VM8086_Install(char **Arguments) gVM8086_WorkerPID = 0; Threads_Exit(0, 1); } + Log_Debug("VM8086", "Mapped low memory"); *(Uint8*)(0x100000) = VM8086_OP_IRET; *(Uint8*)(0x100001) = 0x07; // POP ES @@ -420,6 +421,8 @@ void VM8086_Int(tVM8086 *State, Uint8 Interrupt) { State->IP = *(Uint16*)(KERNEL_BASE+4*Interrupt); State->CS = *(Uint16*)(KERNEL_BASE+4*Interrupt+2); + +// Log_Debug("VM8086", "Software interrupt %i to %04x:%04x", Interrupt, State->CS, State->IP); Mutex_Acquire( &glVM8086_Process );