Added Signals; more runtime fixes
This commit is contained in:
parent
e4f05884c3
commit
8abc5525be
17 changed files with 118 additions and 56 deletions
|
@ -23,6 +23,9 @@ KernelSystem::KernelSystem(Memory::MemorySystem& memory, Core::Timing& timing,
|
|||
std::function<void()> prepare_reschedule_callback, u32 system_mode)
|
||||
: memory(memory), timing(timing),
|
||||
prepare_reschedule_callback(std::move(prepare_reschedule_callback)) {
|
||||
for (auto i = 0; i < memory_regions.size(); i++) {
|
||||
memory_regions[i] = std::make_shared<MemoryRegionInfo>();
|
||||
}
|
||||
MemoryInit(system_mode);
|
||||
|
||||
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
||||
|
@ -107,7 +110,7 @@ template <class Archive>
|
|||
void KernelSystem::serialize(Archive& ar, const unsigned int file_version) {
|
||||
ar& memory_regions;
|
||||
ar& named_ports;
|
||||
ar&* current_cpu.get();
|
||||
// current_cpu set externally
|
||||
// NB: subsystem references and prepare_reschedule_callback are constant
|
||||
ar&* resource_limits.get();
|
||||
ar& next_object_id;
|
||||
|
|
|
@ -134,7 +134,8 @@ public:
|
|||
*/
|
||||
ResultVal<std::shared_ptr<Thread>> CreateThread(std::string name, VAddr entry_point,
|
||||
u32 priority, u32 arg, s32 processor_id,
|
||||
VAddr stack_top, std::shared_ptr<Process> owner_process);
|
||||
VAddr stack_top,
|
||||
std::shared_ptr<Process> owner_process);
|
||||
|
||||
/**
|
||||
* Creates a semaphore.
|
||||
|
@ -232,11 +233,11 @@ public:
|
|||
IPCDebugger::Recorder& GetIPCRecorder();
|
||||
const IPCDebugger::Recorder& GetIPCRecorder() const;
|
||||
|
||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
|
||||
std::shared_ptr<MemoryRegionInfo> GetMemoryRegion(MemoryRegion region);
|
||||
|
||||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping);
|
||||
|
||||
std::array<MemoryRegionInfo, 3> memory_regions;
|
||||
std::array<std::shared_ptr<MemoryRegionInfo>, 3> memory_regions{};
|
||||
|
||||
/// Adds a port to the named port table
|
||||
void AddNamedPort(std::string name, std::shared_ptr<ClientPort> port);
|
||||
|
|
|
@ -49,9 +49,9 @@ void KernelSystem::MemoryInit(u32 mem_type) {
|
|||
// the sizes specified in the memory_region_sizes table.
|
||||
VAddr base = 0;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
memory_regions[i].Reset(base, memory_region_sizes[mem_type][i]);
|
||||
memory_regions[i]->Reset(base, memory_region_sizes[mem_type][i]);
|
||||
|
||||
base += memory_regions[i].size;
|
||||
base += memory_regions[i]->size;
|
||||
}
|
||||
|
||||
// We must've allocated the entire FCRAM by the end
|
||||
|
@ -63,20 +63,20 @@ void KernelSystem::MemoryInit(u32 mem_type) {
|
|||
// app_mem_malloc does not always match the configured size for memory_region[0]: in case the
|
||||
// n3DS type override is in effect it reports the size the game expects, not the real one.
|
||||
config_mem.app_mem_alloc = memory_region_sizes[mem_type][0];
|
||||
config_mem.sys_mem_alloc = memory_regions[1].size;
|
||||
config_mem.base_mem_alloc = memory_regions[2].size;
|
||||
config_mem.sys_mem_alloc = memory_regions[1]->size;
|
||||
config_mem.base_mem_alloc = memory_regions[2]->size;
|
||||
|
||||
shared_page_handler = std::make_shared<SharedPage::Handler>(timing);
|
||||
}
|
||||
|
||||
MemoryRegionInfo* KernelSystem::GetMemoryRegion(MemoryRegion region) {
|
||||
std::shared_ptr<MemoryRegionInfo> KernelSystem::GetMemoryRegion(MemoryRegion region) {
|
||||
switch (region) {
|
||||
case MemoryRegion::APPLICATION:
|
||||
return &memory_regions[0];
|
||||
return memory_regions[0];
|
||||
case MemoryRegion::SYSTEM:
|
||||
return &memory_regions[1];
|
||||
return memory_regions[1];
|
||||
case MemoryRegion::BASE:
|
||||
return &memory_regions[2];
|
||||
return memory_regions[2];
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ public:
|
|||
|
||||
u32 memory_used = 0;
|
||||
|
||||
MemoryRegionInfo* memory_region = nullptr;
|
||||
std::shared_ptr<MemoryRegionInfo> memory_region = nullptr;
|
||||
|
||||
/// The Thread Local Storage area is allocated as processes create threads,
|
||||
/// each TLS area is 0x200 bytes, so one page (0x1000) is split up in 8 parts, and each part
|
||||
|
|
|
@ -42,7 +42,7 @@ ResultVal<std::shared_ptr<SharedMemory>> KernelSystem::CreateSharedMemory(
|
|||
if (address == 0) {
|
||||
// We need to allocate a block from the Linear Heap ourselves.
|
||||
// We'll manually allocate some memory from the linear heap in the specified region.
|
||||
MemoryRegionInfo* memory_region = GetMemoryRegion(region);
|
||||
auto memory_region = GetMemoryRegion(region);
|
||||
auto offset = memory_region->LinearAllocate(size);
|
||||
|
||||
ASSERT_MSG(offset, "Not enough space in region to allocate shared memory!");
|
||||
|
@ -79,7 +79,7 @@ std::shared_ptr<SharedMemory> KernelSystem::CreateSharedMemoryForApplet(
|
|||
auto shared_memory{std::make_shared<SharedMemory>(*this)};
|
||||
|
||||
// Allocate memory in heap
|
||||
MemoryRegionInfo* memory_region = GetMemoryRegion(MemoryRegion::SYSTEM);
|
||||
auto memory_region = GetMemoryRegion(MemoryRegion::SYSTEM);
|
||||
auto backing_blocks = memory_region->HeapAllocate(size);
|
||||
ASSERT_MSG(!backing_blocks.empty(), "Not enough space in region to allocate shared memory!");
|
||||
shared_memory->holding_memory = backing_blocks;
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Kernel {
|
|||
|
||||
template <class Archive>
|
||||
void Thread::serialize(Archive& ar, const unsigned int file_version) {
|
||||
ar& boost::serialization::base_object<Object>(*this);
|
||||
ar& boost::serialization::base_object<WaitObject>(*this);
|
||||
ar&* context.get();
|
||||
ar& thread_id;
|
||||
ar& status;
|
||||
|
@ -363,7 +363,7 @@ ResultVal<std::shared_ptr<Thread>> KernelSystem::CreateThread(
|
|||
if (needs_allocation) {
|
||||
// There are no already-allocated pages with free slots, lets allocate a new one.
|
||||
// TLS pages are allocated from the BASE region in the linear heap.
|
||||
MemoryRegionInfo* memory_region = GetMemoryRegion(MemoryRegion::BASE);
|
||||
auto memory_region = GetMemoryRegion(MemoryRegion::BASE);
|
||||
|
||||
// Allocate some memory from the end of the linear heap for this region.
|
||||
auto offset = memory_region->LinearAllocate(Memory::PAGE_SIZE);
|
||||
|
|
|
@ -824,10 +824,6 @@ std::unique_ptr<Kernel::SessionRequestHandler::SessionDataBase> GSP_GPU::MakeSes
|
|||
return std::make_unique<SessionData>(this);
|
||||
}
|
||||
|
||||
SessionData::SessionData() {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
SessionData::SessionData(GSP_GPU* gsp) : gsp(gsp) {
|
||||
// Assign a new thread id to this session when it connects. Note: In the real GSP service this
|
||||
// is done through a real thread (svcCreateThread) but we have to simulate it since our HLE
|
||||
|
|
|
@ -187,7 +187,7 @@ class GSP_GPU;
|
|||
|
||||
class SessionData : public Kernel::SessionRequestHandler::SessionDataBase {
|
||||
public:
|
||||
SessionData();
|
||||
SessionData() = default;
|
||||
SessionData(GSP_GPU* gsp);
|
||||
~SessionData();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
SERVICE_CONSTRUCT_IMPL(Service::LDR::RO)
|
||||
SERIALIZE_EXPORT_IMPL(Service::LDR::RO)
|
||||
SERIALIZE_EXPORT_IMPL(Service::LDR::ClientSlot)
|
||||
|
||||
namespace Service::LDR {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue