x86:
* Renamed i386_context_switch() to x86_context_switch(). * x86_context_switch() no longer sets the page directory. arch_thread_context_switch() does that explicitly, now. This allows to solve the TODO by reordering releasing the previous paging structures reference and setting the new page directory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37024 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fabdf00e6a
commit
c3e021e862
@ -271,8 +271,8 @@ struct arch_thread;
|
||||
|
||||
void __x86_setup_system_time(uint32 conversionFactor,
|
||||
uint32 conversionFactorNsecs, bool conversionFactorNsecsShift);
|
||||
void i386_context_switch(struct arch_thread* oldState,
|
||||
struct arch_thread* newState, uint32 newPageDir);
|
||||
void x86_context_switch(struct arch_thread* oldState,
|
||||
struct arch_thread* newState);
|
||||
void x86_userspace_thread_exit(void);
|
||||
void x86_end_userspace_thread_exit(void);
|
||||
void x86_enter_userspace(addr_t entry, addr_t stackTop);
|
||||
|
@ -370,7 +370,6 @@ arch_thread_context_switch(struct thread *from, struct thread *to)
|
||||
= cpuData->arch.active_paging_structures;
|
||||
VMAddressSpace* toAddressSpace = to->team->address_space;
|
||||
|
||||
uint32 newPageDirectory;
|
||||
X86PagingStructures* toPagingStructures;
|
||||
if (toAddressSpace != NULL
|
||||
&& (toPagingStructures = static_cast<X86VMTranslationMap*>(
|
||||
@ -382,23 +381,21 @@ arch_thread_context_switch(struct thread *from, struct thread *to)
|
||||
~((uint32)1 << cpu));
|
||||
atomic_or(&toPagingStructures->active_on_cpus, (uint32)1 << cpu);
|
||||
|
||||
activePagingStructures->RemoveReference();
|
||||
// TODO: This might cause deferred deletion, which on SMP machines could happen
|
||||
// right now on another CPU!
|
||||
|
||||
// assign the new paging structures to the CPU
|
||||
toPagingStructures->AddReference();
|
||||
cpuData->arch.active_paging_structures = toPagingStructures;
|
||||
|
||||
// get the new page directory
|
||||
newPageDirectory = toPagingStructures->pgdir_phys;
|
||||
} else {
|
||||
newPageDirectory = 0;
|
||||
// this means no change
|
||||
// set the page directory, if it changes
|
||||
uint32 newPageDirectory = toPagingStructures->pgdir_phys;
|
||||
if (newPageDirectory != activePagingStructures->pgdir_phys)
|
||||
x86_swap_pgdir(newPageDirectory);
|
||||
|
||||
// This CPU no longer uses the previous paging structures.
|
||||
activePagingStructures->RemoveReference();
|
||||
}
|
||||
|
||||
gX86SwapFPUFunc(from->arch_info.fpu_state, to->arch_info.fpu_state);
|
||||
i386_context_switch(&from->arch_info, &to->arch_info, newPageDirectory);
|
||||
x86_context_switch(&from->arch_info, &to->arch_info);
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,25 +121,20 @@ FUNCTION(x86_write_msr):
|
||||
ret
|
||||
FUNCTION_END(x86_write_msr)
|
||||
|
||||
/* void i386_context_switch(struct arch_thread *old_state,
|
||||
struct arch_thread *new_state, uint32 new_pgdir); */
|
||||
FUNCTION(i386_context_switch):
|
||||
/* void x86_context_switch(struct arch_thread* oldState,
|
||||
struct arch_thread* newState); */
|
||||
FUNCTION(x86_context_switch):
|
||||
pusha /* pushes 8 words onto the stack */
|
||||
movl 36(%esp),%eax /* save old_state->current_stack */
|
||||
movl 36(%esp),%eax /* save oldState->current_stack */
|
||||
movl %esp,(%eax)
|
||||
pushl %ss
|
||||
popl %edx
|
||||
movl %edx,4(%eax)
|
||||
movl 44(%esp),%eax /* get possible new pgdir */
|
||||
orl %eax,%eax /* is it null? */
|
||||
je skip_pgdir_swap
|
||||
movl %eax,%cr3
|
||||
skip_pgdir_swap:
|
||||
movl 40(%esp),%eax /* get new new_state->current_stack */
|
||||
movl 40(%esp),%eax /* get new newState->current_stack */
|
||||
lss (%eax),%esp
|
||||
popa
|
||||
ret
|
||||
FUNCTION_END(i386_context_switch)
|
||||
FUNCTION_END(x86_context_switch)
|
||||
|
||||
/* void x86_swap_pgdir(uint32 newPageDir); */
|
||||
FUNCTION(x86_swap_pgdir):
|
||||
|
Loading…
Reference in New Issue
Block a user