1
0
Fork 0
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:
Jonas 'Sortie' Termansen 2011-08-07 00:47:36 +02:00
parent 66c058fba1
commit 90ebfe7f0a
2 changed files with 9 additions and 4 deletions

View file

@ -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()

View file

@ -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);