X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=KernelLand%2FKernel%2Farch%2Fx86_64%2Fproc.c;h=46e2b21c21c2d55350decb24b81490c3267e2fba;hb=4b9cc52e8ceaa0213719aca66c521575620e6d09;hp=884babb3981ab3df5f7a77fbcfad24a09374483e;hpb=c040a99e085bfeaac5146ed68a44d8c1e2ce9936;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86_64/proc.c b/KernelLand/Kernel/arch/x86_64/proc.c index 884babb3..46e2b21c 100644 --- a/KernelLand/Kernel/arch/x86_64/proc.c +++ b/KernelLand/Kernel/arch/x86_64/proc.c @@ -37,7 +37,7 @@ extern void APStartup(void); // 16-bit AP startup code extern Uint GetRIP(void); // start.asm extern Uint SaveState(Uint *RSP, Uint *Regs); -extern Uint Proc_CloneInt(Uint *RSP, Uint *CR3); +extern Uint Proc_CloneInt(Uint *RSP, Uint *CR3, int bCopyUserVM); extern void NewTaskHeader(void); // Actually takes cdecl args extern void Proc_InitialiseSSE(void); extern void Proc_SaveSSE(Uint DestPtr); @@ -75,6 +75,7 @@ void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP) NO //void Proc_DumpThreadCPUState(tThread *Thread); //void Proc_Reschedule(void); void Proc_Scheduler(int CPU, Uint RSP, Uint RIP); +Uint Proc_int_SetIRQIP(Uint RIP); // === GLOBALS === //!\brief Used by desctab.asm in SyscallStub @@ -507,7 +508,7 @@ tTID Proc_Clone(Uint Flags) if(!newThread) return -1; // Save core machine state - rip = Proc_CloneInt(&newThread->SavedState.RSP, &newThread->Process->MemState.CR3); + rip = Proc_CloneInt(&newThread->SavedState.RSP, &newThread->Process->MemState.CR3, !!(Flags & CLONE_NOUSER)); if(rip == 0) return 0; // Child newThread->KernelStack = cur->KernelStack; newThread->SavedState.RIP = rip; @@ -725,7 +726,14 @@ void Proc_CallFaultHandler(tThread *Thread) void Proc_DumpThreadCPUState(tThread *Thread) { - Log(" At %04x:%016llx", Thread->SavedState.UserCS, Thread->SavedState.UserRIP); + if( Thread->CurCPU == GetCPUNum() ) { + // TODO: Backtrace to IRQ + Log(" IRQ %016llx", Thread->SavedState.UserRIP); + } + else { + Log(" At %016llx, SP=%016llx", Thread->SavedState.RIP, Thread->SavedState.RSP); + Log(" User %04x:%016llx", Thread->SavedState.UserCS, Thread->SavedState.UserRIP); + } } void Proc_Reschedule(void) @@ -825,5 +833,14 @@ void Proc_Scheduler(int CPU, Uint RSP, Uint RIP) #endif } +Uint Proc_int_SetIRQIP(Uint RIP) +{ + int cpu = GetCPUNum(); + tThread *thread = gaCPUs[cpu].Current; + Uint rv = thread->SavedState.UserRIP; + thread->SavedState.UserRIP = RIP; + return rv; +} + // === EXPORTS === EXPORT(Proc_SpawnWorker);