Speedups to physical memory allocation, fixed a stupid error in the
authorJohn Hodge <[email protected]>
Mon, 31 May 2010 15:12:33 +0000 (23:12 +0800)
committerJohn Hodge <[email protected]>
Mon, 31 May 2010 15:12:33 +0000 (23:12 +0800)
stack moving code

Kernel/arch/x86_64/mm_phys.c
Kernel/arch/x86_64/proc.c

index 68701b2..5d9f2ef 100644 (file)
@@ -372,11 +372,11 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
                                continue;
                        }
                        // Check page block (64 pages)
-                       if( gaSuperBitmap[addr >> (6+6)] & (1 << (addr>>6)&63)) {
+                       if( gaMainBitmap[addr >> 6] == -1) {
                                LOG("nFree = %i = 0 (main) (0x%x)", nFree, addr);
                                nFree = 0;
-                               addr += 1 << (12+6);
-                               addr &= ~( (1 << (12+6)) - 1 );
+                               addr += 1 << (6);
+                               addr &= ~( (1 << (6)) - 1 );
                                continue;
                        }
                        // Check individual page
@@ -425,7 +425,7 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
                gaMainBitmap[addr >> 6] |= 1 << (addr & 63);
                rangeID = MM_int_GetRangeID(addr << 12);
                giPhysRangeFree[ rangeID ] --;
-               if(addr << 12 == giPhysRangeFirst[ rangeID ])
+               if(addr == giPhysRangeFirst[ rangeID ])
                        giPhysRangeFirst[ rangeID ] += 1;
        }
        ret = addr;     // Save the return address
index a1d5c86..1c81991 100644 (file)
@@ -381,11 +381,11 @@ void Proc_ChangeStack()
 
        curBase = (Uint)&gInitialKernelStack;
        
-       LOG("curBase = 0x%x, newBase = 0x%x", curBase, newBase);
+       Log("curBase = 0x%x, newBase = 0x%x", curBase, newBase);
 
        // Get ESP as a used size
        rsp = curBase - rsp;
-       LOG("memcpy( %p, %p, 0x%x )", (void*)(newBase - rsp), (void*)(curBase - rsp), rsp );
+       Log("memcpy( %p, %p, 0x%x )", (void*)(newBase - rsp), (void*)(curBase - rsp), rsp );
        // Copy used stack
        memcpy( (void*)(newBase - rsp), (void*)(curBase - rsp), rsp );
        // Get ESP as an offset in the new stack
@@ -393,16 +393,17 @@ void Proc_ChangeStack()
        // Adjust EBP
        rbp = newBase - (curBase - rbp);
 
+       Log("Update stack");
        // Repair EBPs & Stack Addresses
        // Catches arguments also, but may trash stack-address-like values
-       for(tmp_rbp = rsp; tmp_rbp < newBase; tmp_rbp += 4)
+       for(tmp_rbp = rsp; tmp_rbp < newBase; tmp_rbp += sizeof(Uint))
        {
                if(old_rsp < *(Uint*)tmp_rbp && *(Uint*)tmp_rbp < curBase)
                        *(Uint*)tmp_rbp += newBase - curBase;
        }
        
+       Log("Applying Changes");
        Proc_GetCurThread()->KernelStack = newBase;
-       
        __asm__ __volatile__ ("mov %0, %%rsp"::"r"(rsp));
        __asm__ __volatile__ ("mov %0, %%rbp"::"r"(rbp));
 }

UCC git Repository :: git.ucc.asn.au