erpt: reimplement the sysmodule (#875)

* erpt: reimplement the sysmodule

* fatal: update for latest bindings

* erpt: amend logic for culling orphan attachments
This commit is contained in:
SciresM
2020-04-13 17:07:37 -07:00
committed by GitHub
parent eca5ac01b8
commit 79b9e07ee9
117 changed files with 6716 additions and 59 deletions

View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#if defined(ATMOSPHERE_OS_HORIZON)
#include <stratosphere/psc/psc_pm_module.os.horizon.hpp>
#else
#error "Unknown OS for psc::PmModule"
#endif

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
namespace ams::psc {
class PmModule {
NON_COPYABLE(PmModule);
NON_MOVEABLE(PmModule);
private:
std::shared_ptr<psc::sf::IPmModule> intf;
os::SystemEvent system_event;
bool initialized;
PmModuleId module_id;
uintptr_t reserved;
public:
PmModule();
~PmModule();
Result Initialize(const PmModuleId mid, const PmModuleId *dependencies, u32 dependency_count, os::EventClearMode clear_mode);
Result Finalize();
constexpr PmModuleId GetId() const { return this->module_id; }
Result GetRequest(PmState *out_state, PmFlagSet *out_flags);
Result Acknowledge(PmState state, Result res);
os::SystemEvent *GetEventPointer();
};
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::psc {
enum PmModuleId : u16 {
PmModuleId_Usb = 4,
PmModuleId_Ethernet = 5,
PmModuleId_Fgm = 6,
PmModuleId_PcvClock = 7,
PmModuleId_PcvVoltage = 8,
PmModuleId_Gpio = 9,
PmModuleId_Pinmux = 10,
PmModuleId_Uart = 11,
PmModuleId_I2c = 12,
PmModuleId_I2cPcv = 13,
PmModuleId_Spi = 14,
PmModuleId_Pwm = 15,
PmModuleId_Psm = 16,
PmModuleId_Tc = 17,
PmModuleId_Omm = 18,
PmModuleId_Pcie = 19,
PmModuleId_Lbl = 20,
PmModuleId_Display = 21,
PmModuleId_Hid = 24,
PmModuleId_WlanSockets = 25,
PmModuleId_Fs = 27,
PmModuleId_Audio = 28,
PmModuleId_TmaHostIo = 30,
PmModuleId_Bluetooth = 31,
PmModuleId_Bpc = 32,
PmModuleId_Fan = 33,
PmModuleId_Pcm = 34,
PmModuleId_Nfc = 35,
PmModuleId_Apm = 36,
PmModuleId_Btm = 37,
PmModuleId_Nifm = 38,
PmModuleId_GpioLow = 39,
PmModuleId_Npns = 40,
PmModuleId_Lm = 41,
PmModuleId_Bcat = 42,
PmModuleId_Time = 43,
PmModuleId_Pctl = 44,
PmModuleId_Erpt = 45,
PmModuleId_Eupld = 46,
PmModuleId_Friends = 47,
PmModuleId_Bgtc = 48,
PmModuleId_Account = 49,
PmModuleId_Sasbus = 50,
PmModuleId_Ntc = 51,
PmModuleId_Idle = 52,
PmModuleId_Tcap = 53,
PmModuleId_PsmLow = 54,
PmModuleId_Ndd = 55,
PmModuleId_Olsc = 56,
PmModuleId_Ns = 61,
PmModuleId_Nvservices = 101,
PmModuleId_Spsm = 127,
};
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::psc {
enum PmState {
PmState_Awake = 0,
PmState_ReadyAwaken = 1,
PmState_ReadySleep = 2,
PmState_ReadySleepCritical = 3,
PmState_ReadyAwakenCritical = 4,
PmState_ReadyShutdown = 5,
};
constexpr inline u32 MaximumDependencyLevels = 20;
struct PmFlag {
};
using PmFlagSet = util::BitFlagSet<BITSIZEOF(u32), PmFlag>;
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
namespace ams::psc::sf {
class IPmModule : public ams::sf::IServiceObject {
protected:
enum class CommandId {
Initialize = 0,
GetRequest = 1,
Acknowledge = 2,
Finalize = 3,
AcknowledgeEx = 4,
};
public:
/* Actual commands. */
virtual Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) = 0;
virtual Result GetRequest(ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags) = 0;
virtual Result Acknowledge() = 0;
virtual Result Finalize() = 0;
virtual Result AcknowledgeEx(PmState state) = 0;
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(Initialize),
MAKE_SERVICE_COMMAND_META(GetRequest),
MAKE_SERVICE_COMMAND_META(Acknowledge),
MAKE_SERVICE_COMMAND_META(Finalize),
MAKE_SERVICE_COMMAND_META(AcknowledgeEx, hos::Version_600), /* TODO: This is really 5.1.0... */
};
};
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
namespace ams::psc::sf {
class IPmService : public ams::sf::IServiceObject {
protected:
enum class CommandId {
Initialize = 0,
};
public:
/* Actual commands. */
virtual Result Initialize(ams::sf::Out<std::shared_ptr<psc::sf::IPmModule>> out) = 0;
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(Initialize),
};
};
}