mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Improvements to the address space switching function.
It now only switches when needed and returns the old addr space.
This commit is contained in:
parent
66c058fba1
commit
90ebfe7f0a
2 changed files with 9 additions and 4 deletions
|
@ -226,7 +226,7 @@ namespace Sortix
|
|||
Table* BootstrapCreateTable(Dir* dir, addr_t where);
|
||||
void BootstrapMap(Dir* dir, addr_t where, addr_t physical);
|
||||
void BootstrapMapStructures(Dir* dir);
|
||||
void SwitchDirectory(addr_t dir);
|
||||
addr_t SwitchDirectory(addr_t dir);
|
||||
addr_t CreateDirectory();
|
||||
#endif
|
||||
|
||||
|
@ -356,16 +356,21 @@ namespace Sortix
|
|||
return CreateDirectory();
|
||||
}
|
||||
|
||||
void SwitchAddressSpace(addr_t addrspace)
|
||||
addr_t SwitchAddressSpace(addr_t addrspace)
|
||||
{
|
||||
return SwitchDirectory(addrspace);
|
||||
}
|
||||
|
||||
void SwitchDirectory(addr_t dir)
|
||||
addr_t SwitchDirectory(addr_t dir)
|
||||
{
|
||||
// Don't switch if we are already there.
|
||||
if ( dir == currentDirPhysical ) { return currentDirPhysical; }
|
||||
|
||||
addr_t previous = currentDirPhysical;
|
||||
asm volatile("mov %0, %%cr3":: "r"(dir));
|
||||
currentDirPhysical = dir;
|
||||
Flush();
|
||||
return previous;
|
||||
}
|
||||
|
||||
addr_t CreateDirectory()
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Sortix
|
|||
void Init();
|
||||
void Flush();
|
||||
addr_t CreateAddressSpace();
|
||||
void SwitchAddressSpace(addr_t addrspace);
|
||||
addr_t SwitchAddressSpace(addr_t addrspace);
|
||||
void MapKernel(addr_t where, addr_t physical);
|
||||
bool MapUser(addr_t where, addr_t physical);
|
||||
addr_t UnmapKernel(addr_t where);
|
||||
|
|
Loading…
Reference in a new issue