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
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
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
// 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));
}