mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
kernel: avoid global storage usage for process/thread local variables
enables multiple guest processes emulation in single host process
This commit is contained in:
parent
05dee2c8e3
commit
aee92cce57
6 changed files with 97 additions and 102 deletions
|
|
@ -39,7 +39,8 @@ struct KernelMemoryResource {
|
|||
};
|
||||
|
||||
static KernelMemoryResource *sMemoryResource;
|
||||
static std::byte *sGlobalStorage;
|
||||
std::byte *g_globalStorage;
|
||||
|
||||
using GlobalStorage =
|
||||
kernel::StaticKernelObjectStorage<OrbisNamespace,
|
||||
kernel::detail::GlobalScope>;
|
||||
|
|
@ -69,15 +70,15 @@ void initializeAllocator() {
|
|||
rx::print(stderr, "global: size {}, alignment {}\n", GlobalStorage::GetSize(),
|
||||
GlobalStorage::GetAlignment());
|
||||
// allocate whole global storage
|
||||
sGlobalStorage = (std::byte *)sMemoryResource->kalloc(
|
||||
g_globalStorage = (std::byte *)sMemoryResource->kalloc(
|
||||
GlobalStorage::GetSize(), GlobalStorage::GetAlignment());
|
||||
}
|
||||
|
||||
void deinitializeAllocator() {
|
||||
sMemoryResource->kfree(sGlobalStorage, GlobalStorage::GetSize());
|
||||
sMemoryResource->kfree(g_globalStorage, GlobalStorage::GetSize());
|
||||
delete sMemoryResource;
|
||||
sMemoryResource = nullptr;
|
||||
sGlobalStorage = nullptr;
|
||||
g_globalStorage = nullptr;
|
||||
}
|
||||
|
||||
void *KernelMemoryResource::kalloc(std::size_t size, std::size_t align) {
|
||||
|
|
@ -213,9 +214,3 @@ void *kalloc(std::size_t size, std::size_t align) {
|
|||
return sMemoryResource->kalloc(size, align);
|
||||
}
|
||||
} // namespace orbis
|
||||
|
||||
template <>
|
||||
std::byte *
|
||||
kernel::getScopeStorage<orbis::OrbisNamespace, kernel::detail::GlobalScope>() {
|
||||
return orbis::sGlobalStorage;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue