X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86_64%2Fproc.c;h=50b5054894d8987eab5d9f46bbba4143b5d1ced6;hb=d7dcea0e5a8df0f479e99f168a10b9a9535c7ad6;hp=b35b5074d39a5cde3a6cfec1954355c2471899d9;hpb=be5123fe1f4aa66b76ce8ef589362ad21b6bbf72;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86_64/proc.c b/KernelLand/Kernel/arch/x86_64/proc.c index b35b5074..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"); } @@ -573,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)