X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86_64%2Fproc.c;h=50b5054894d8987eab5d9f46bbba4143b5d1ced6;hb=7b0611393a98399063aefaa87583b05fef13f6e3;hp=46e2b21c21c2d55350decb24b81490c3267e2fba;hpb=c1b768104a3458d08e7c7240aaac82fc7e70e3df;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86_64/proc.c b/KernelLand/Kernel/arch/x86_64/proc.c index 46e2b21c..50b50548 100644 --- a/KernelLand/Kernel/arch/x86_64/proc.c +++ b/KernelLand/Kernel/arch/x86_64/proc.c @@ -324,7 +324,7 @@ void ArchThreads_Init(void) outb(0x40, (PIT_TIMER_DIVISOR>>8)&0xFF); // High Byte // Create Per-Process Data Block - if( !MM_Allocate(MM_PPD_CFG) ) + if( !MM_Allocate( (void*)MM_PPD_CFG ) ) { Warning("Oh, hell, Unable to allocate PPD for Thread#0"); } @@ -458,9 +458,8 @@ void Proc_ClearThread(tThread *Thread) tTID Proc_NewKThread(void (*Fcn)(void*), void *Data) { Uint rsp; - tThread *newThread, *cur; + tThread *newThread; - cur = Proc_GetCurThread(); newThread = Threads_CloneTCB(0); if(!newThread) return -1; @@ -537,11 +536,9 @@ tTID Proc_Clone(Uint Flags) */ tThread *Proc_SpawnWorker(void (*Fcn)(void*), void *Data) { - tThread *new, *cur; + tThread *new; Uint stack_contents[3]; - cur = Proc_GetCurThread(); - // Create new thread new = Threads_CloneThreadZero(); if(!new) { @@ -576,39 +573,39 @@ tThread *Proc_SpawnWorker(void (*Fcn)(void*), void *Data) */ Uint Proc_MakeUserStack(void) { - int i; - Uint base = USER_STACK_TOP - USER_STACK_SZ; + tPage *base = (void*)(USER_STACK_TOP - USER_STACK_SZ); // Check Prospective Space - for( i = USER_STACK_SZ >> 12; i--; ) + for( int i = USER_STACK_SZ/PAGE_SIZE; i--; ) { - if( MM_GetPhysAddr( (void*)(base + (i<<12)) ) != 0 ) - break; + if( MM_GetPhysAddr( base + i ) != 0 ) + { + return 0; + } } - if(i != -1) return 0; - // Allocate Stack - Allocate incrementally to clean up MM_Dump output // - Most of the user stack is the zero page - for( i = 0; i < (USER_STACK_SZ-USER_STACK_PREALLOC)/0x1000; i++ ) + int i = 0; + for( ; i < (USER_STACK_SZ-USER_STACK_PREALLOC)/PAGE_SIZE; i++ ) { - MM_AllocateZero( base + (i<<12) ); + MM_AllocateZero( base + i ); } // - but the top USER_STACK_PREALLOC pages are actually allocated - for( ; i < USER_STACK_SZ/0x1000; i++ ) + for( ; i < USER_STACK_SZ/PAGE_SIZE; i++ ) { - tPAddr alloc = MM_Allocate( base + (i<<12) ); + tPAddr alloc = MM_Allocate( base + i ); if( !alloc ) { // Error - Log_Error("Proc", "Unable to allocate user stack (%i pages requested)", USER_STACK_SZ/0x1000); + Log_Error("Proc", "Unable to allocate user stack (%i pages requested)", USER_STACK_SZ/PAGE_SIZE); while( i -- ) - MM_Deallocate( base + (i<<12) ); + MM_Deallocate( base + i ); return 0; } } - return base + USER_STACK_SZ; + return (tVAddr)( base + USER_STACK_SZ/PAGE_SIZE ); } void Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, const char **ArgV, int DataSize)