#pragma once #include #include #include "common.h" #include "kernel/ipc.h" #include "kernel/types/KProcess.h" #include "kernel/types/KThread.h" #include "kernel/services/serviceman.h" #include "nce.h" namespace skyline::kernel { /** * @brief The OS class manages the interaction between Skyline components and the underlying OS in NCE */ class OS { private: DeviceState state; //!< The state of the device public: std::unordered_map> threadMap; //!< A mapping from a threat's PID to it's KProcess object std::vector processVec; //!< A vector of all processes by their main thread's PID std::shared_ptr thisProcess; //!< The corresponding KProcess object of the process that's called an SVC std::shared_ptr thisThread; //!< The corresponding KThread object of the thread that's called an SVC service::ServiceManager serviceManager; //!< This manages all of the service functions /** * @param logger An instance of the Logger class * @param settings An instance of the Settings class */ OS(std::shared_ptr &logger, std::shared_ptr &settings); /** * @brief Execute a particular ROM file. This launches a the main processes and calls the NCE class to handle execution. * @param romFile The path to the ROM file to execute */ void Execute(const std::string &romFile); /** * @brief Creates a new process * @param address The address of the initial function * @param stackSize The size of the main stack * @return An instance of the KProcess of the created process */ std::shared_ptr CreateProcess(u64 address, size_t stackSize); /** * @brief Kill a particular thread * @param pid The PID of the thread */ void KillThread(pid_t pid); /** * @brief Handles a particular SuperVisor Call * @param svc The ID of the SVC to be called * @param pid The PID of the process/thread calling the SVC */ void SvcHandler(u16 svc, pid_t pid); }; }