mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-08 13:43:33 +01:00
![Minty-Meeo](/assets/img/avatar_default.png)
Changed several enums from Memmap.h to be static vars and implemented Get functions to query them. This seems to have boosted speed a bit in some titles? The new variables and some previously statically initialized items are now initialized via Memory::Init() and the new AddressSpace::Init(). s_ram_size_real and the new s_exram_size_real in particular are initialized from new OnionConfig values "MAIN_MEM1_SIZE" and "MAIN_MEM2_SIZE", only if "MAIN_RAM_OVERRIDE_ENABLE" is true. GUI features have been added to Config > Advanced to adjust the new OnionConfig values. A check has been added to State::doState to ensure savestates with memory configurations different from the current settings aren't loaded. The STATE_VERSION is now 115. FIFO Files have been updated from version 4 to version 5, now including the MEM1 and MEM2 sizes from the time of DFF creation. FIFO Logs not using the new features (OnionConfig MAIN_RAM_OVERRIDE_ENABLE is false) are still backwards compatible. FIFO Logs that do use the new features have a MIN_LOADER_VERSION of 5. Thanks to the order of function calls, FIFO logs are able to automatically configure the new OnionConfig settings to match what is needed. This is a bit hacky, though, so I also threw in a failsafe for if the conditions that allow this to work ever go away. I took the liberty of adding a log message to explain why the core fails to initialize if the MIN_LOADER_VERSION is too great. Some IOS code has had the function "RAMOverrideForIOSMemoryValues" appended to it to recalculate IOS Memory Values from retail IOSes/apploaders to fit the extended memory sizes. Worry not, if MAIN_RAM_OVERRIDE_ENABLE is false, this function does absolutely nothing. A hotfix in DolphinQt/MenuBar.cpp has been implemented for RAM Override.
156 lines
3.8 KiB
C++
156 lines
3.8 KiB
C++
// Copyright 2017 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <deque>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
#include "Core/CoreTiming.h"
|
|
#include "Core/HW/SystemTimers.h"
|
|
#include "Core/IOS/IOSC.h"
|
|
|
|
class PointerWrap;
|
|
|
|
namespace IOS::HLE
|
|
{
|
|
namespace FS
|
|
{
|
|
class FileSystem;
|
|
}
|
|
|
|
namespace Device
|
|
{
|
|
class Device;
|
|
class ES;
|
|
} // namespace Device
|
|
|
|
struct Request;
|
|
struct OpenRequest;
|
|
|
|
struct IPCCommandResult
|
|
{
|
|
s32 return_value;
|
|
bool send_reply;
|
|
u64 reply_delay_ticks;
|
|
};
|
|
|
|
enum IPCCommandType : u32
|
|
{
|
|
IPC_CMD_OPEN = 1,
|
|
IPC_CMD_CLOSE = 2,
|
|
IPC_CMD_READ = 3,
|
|
IPC_CMD_WRITE = 4,
|
|
IPC_CMD_SEEK = 5,
|
|
IPC_CMD_IOCTL = 6,
|
|
IPC_CMD_IOCTLV = 7,
|
|
// This is used for replies to commands.
|
|
IPC_REPLY = 8,
|
|
};
|
|
|
|
enum class MemorySetupType
|
|
{
|
|
IOSReload,
|
|
Full,
|
|
};
|
|
|
|
void RAMOverrideForIOSMemoryValues(MemorySetupType setup_type);
|
|
|
|
void WriteReturnValue(s32 value, u32 address);
|
|
|
|
// HLE for the IOS kernel: IPC, device management, syscalls, and Dolphin-specific, IOS-wide calls.
|
|
class Kernel
|
|
{
|
|
public:
|
|
Kernel();
|
|
virtual ~Kernel();
|
|
|
|
void DoState(PointerWrap& p);
|
|
void HandleIPCEvent(u64 userdata);
|
|
void UpdateIPC();
|
|
void UpdateDevices();
|
|
void UpdateWantDeterminism(bool new_want_determinism);
|
|
|
|
// These are *always* part of the IOS kernel and always available.
|
|
// They are also the only available resource managers even before loading any module.
|
|
std::shared_ptr<FS::FileSystem> GetFS();
|
|
std::shared_ptr<Device::ES> GetES();
|
|
|
|
void SDIO_EventNotify();
|
|
|
|
void EnqueueIPCRequest(u32 address);
|
|
void EnqueueIPCReply(const Request& request, s32 return_value, int cycles_in_future = 0,
|
|
CoreTiming::FromThread from = CoreTiming::FromThread::CPU);
|
|
|
|
void SetUidForPPC(u32 uid);
|
|
u32 GetUidForPPC() const;
|
|
void SetGidForPPC(u16 gid);
|
|
u16 GetGidForPPC() const;
|
|
|
|
bool BootstrapPPC(const std::string& boot_content_path);
|
|
bool BootIOS(u64 ios_title_id, const std::string& boot_content_path = "");
|
|
u32 GetVersion() const;
|
|
|
|
IOSC& GetIOSC();
|
|
|
|
protected:
|
|
explicit Kernel(u64 title_id);
|
|
|
|
void ExecuteIPCCommand(u32 address);
|
|
IPCCommandResult HandleIPCCommand(const Request& request);
|
|
void EnqueueIPCAcknowledgement(u32 address, int cycles_in_future = 0);
|
|
|
|
void AddDevice(std::unique_ptr<Device::Device> device);
|
|
void AddCoreDevices();
|
|
void AddStaticDevices();
|
|
std::shared_ptr<Device::Device> GetDeviceByName(const std::string& device_name);
|
|
s32 GetFreeDeviceID();
|
|
IPCCommandResult OpenDevice(OpenRequest& request);
|
|
|
|
bool m_is_responsible_for_nand_root = false;
|
|
u64 m_title_id = 0;
|
|
static constexpr u8 IPC_MAX_FDS = 0x18;
|
|
std::map<std::string, std::shared_ptr<Device::Device>> m_device_map;
|
|
std::mutex m_device_map_mutex;
|
|
// TODO: make this fdmap per process.
|
|
std::array<std::shared_ptr<Device::Device>, IPC_MAX_FDS> m_fdmap;
|
|
|
|
u32 m_ppc_uid = 0;
|
|
u16 m_ppc_gid = 0;
|
|
|
|
using IPCMsgQueue = std::deque<u32>;
|
|
IPCMsgQueue m_request_queue; // ppc -> arm
|
|
IPCMsgQueue m_reply_queue; // arm -> ppc
|
|
IPCMsgQueue m_ack_queue; // arm -> ppc
|
|
u64 m_last_reply_time = 0;
|
|
|
|
IOSC m_iosc;
|
|
std::shared_ptr<FS::FileSystem> m_fs;
|
|
};
|
|
|
|
// HLE for an IOS tied to emulation: base kernel which may have additional modules loaded.
|
|
class EmulationKernel : public Kernel
|
|
{
|
|
public:
|
|
explicit EmulationKernel(u64 ios_title_id);
|
|
~EmulationKernel();
|
|
|
|
// Get a resource manager by name.
|
|
// This only works for devices which are part of the device map.
|
|
std::shared_ptr<Device::Device> GetDeviceByName(const std::string& device_name);
|
|
};
|
|
|
|
// Used for controlling and accessing an IOS instance that is tied to emulation.
|
|
void Init();
|
|
void Shutdown();
|
|
EmulationKernel* GetIOS();
|
|
|
|
} // namespace IOS::HLE
|