- pages[ addr >> 12 ] = MM_AllocPhys();
- gaTmpTable[ (base + addr) >> 12 ] = pages[addr>>12] | 3;
- }
- *gpTmpCR3 = 0;
- // Release the temp mapping lock
- RELEASE(&gilTempFractal);
-
- // Copy the old stack
- oldstack = (esp + KERNEL_STACK_SIZE-1) & ~(KERNEL_STACK_SIZE-1);
- esp = oldstack - esp; // ESP as an offset in the stack
-
- // Make `base` be the top of the stack
- base += WORKER_STACK_SIZE;
-
- i = (WORKER_STACK_SIZE>>12) - 1;
- // Copy the contents of the old stack to the new one, altering the addresses
- // `addr` is refering to bytes from the stack base (mem downwards)
- for(addr = 0; addr < esp; addr += 0x1000)
- {
- Uint *stack = (Uint*)( oldstack-(addr+0x1000) );
- tmpPage = (void*)MM_MapTemp( pages[i] );
- // Copy old stack
- for(j = 0; j < 1024; j++)
- {
- // Possible Stack address?
- if(oldstack-esp < stack[j] && stack[j] < oldstack)
- tmpPage[j] = base - (oldstack - stack[j]);
- else // Seems not, best leave it alone
- tmpPage[j] = stack[j];
- }
- MM_FreeTemp((tVAddr)tmpPage);
- i --;