sf: Change interface definition methodology (#1074)

* sf: Begin experimenting with new interface declaration format

* sf: convert fs interfaces to new format

* sf: finish conversion of libstrat to new definitions

* sf: convert loader to new format

* sf: convert spl to new format

* sf: update ncm for new format

* sf: convert pm to new format

* sf: convert ro/sm to new format

* sf: update fatal for new format

* sf: support building dmnt under new scheme

* sf: update ams.mitm for new format

* sf: correct invocation def for pointer holder

* fs: correct 10.x+ user bindings for Get*SpaceSize
This commit is contained in:
SciresM
2020-07-07 17:07:23 -07:00
committed by GitHub
parent 94eb2195d3
commit 9fde97cfdd
190 changed files with 3220 additions and 3172 deletions

View File

@@ -14,20 +14,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "sm_dmnt_service.hpp"
#include "sm_debug_monitor_service.hpp"
#include "impl/sm_service_manager.hpp"
namespace ams::sm {
Result DmntService::AtmosphereGetRecord(sf::Out<ServiceRecord> record, ServiceName service) {
Result DebugMonitorService::AtmosphereGetRecord(sf::Out<ServiceRecord> record, ServiceName service) {
return impl::GetServiceRecord(record.GetPointer(), service);
}
void DmntService::AtmosphereListRecords(const sf::OutArray<ServiceRecord> &records, sf::Out<u64> out_count, u64 offset) {
void DebugMonitorService::AtmosphereListRecords(const sf::OutArray<ServiceRecord> &records, sf::Out<u64> out_count, u64 offset) {
R_ABORT_UNLESS(impl::ListServiceRecords(records.GetPointer(), out_count.GetPointer(), offset, records.GetSize()));
}
void DmntService::AtmosphereGetRecordSize(sf::Out<u64> record_size) {
void DebugMonitorService::AtmosphereGetRecordSize(sf::Out<u64> record_size) {
record_size.SetValue(sizeof(ServiceRecord));
}

View File

@@ -0,0 +1,31 @@
/*
* 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 <stratosphere.hpp>
namespace ams::sm {
/* Service definition. */
class DebugMonitorService final {
public:
Result AtmosphereGetRecord(sf::Out<ServiceRecord> record, ServiceName service);
void AtmosphereListRecords(const sf::OutArray<ServiceRecord> &records, sf::Out<u64> out_count, u64 offset);
void AtmosphereGetRecordSize(sf::Out<u64> record_size);
};
static_assert(sm::impl::IsIDebugMonitorInterface<DebugMonitorService>);
}

View File

@@ -1,44 +0,0 @@
/*
* 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 <stratosphere.hpp>
namespace ams::sm {
/* Service definition. */
class DmntService final : public sf::IServiceObject {
protected:
/* Command IDs. */
enum class CommandId {
AtmosphereGetRecord = 65000,
AtmosphereListRecords = 65001,
AtmosphereGetRecordSize = 65002,
};
private:
/* Actual commands. */
virtual Result AtmosphereGetRecord(sf::Out<ServiceRecord> record, ServiceName service);
virtual void AtmosphereListRecords(const sf::OutArray<ServiceRecord> &records, sf::Out<u64> out_count, u64 offset);
virtual void AtmosphereGetRecordSize(sf::Out<u64> record_size);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(AtmosphereGetRecord),
MAKE_SERVICE_COMMAND_META(AtmosphereListRecords),
MAKE_SERVICE_COMMAND_META(AtmosphereGetRecordSize),
};
};
}

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "sm_user_service.hpp"
#include "sm_manager_service.hpp"
#include "sm_dmnt_service.hpp"
#include "sm_debug_monitor_service.hpp"
#include "impl/sm_service_manager.hpp"
extern "C" {
@@ -101,14 +101,14 @@ int main(int argc, char **argv)
{
Handle sm_h;
R_ABORT_UNLESS(svcManageNamedPort(&sm_h, "sm:", 0x40));
g_server_manager.RegisterServer<sm::UserService>(sm_h);
g_server_manager.RegisterServer<sm::impl::IUserInterface, sm::UserService>(sm_h);
}
/* Create sm:m manually. */
{
Handle smm_h;
R_ABORT_UNLESS(sm::impl::RegisterServiceForSelf(&smm_h, sm::ServiceName::Encode("sm:m"), 1));
g_server_manager.RegisterServer<sm::ManagerService>(smm_h);
g_server_manager.RegisterServer<sm::impl::IManagerInterface, sm::ManagerService>(smm_h);
}
/*===== ATMOSPHERE EXTENSION =====*/
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
{
Handle smdmnt_h;
R_ABORT_UNLESS(sm::impl::RegisterServiceForSelf(&smdmnt_h, sm::ServiceName::Encode("sm:dmnt"), 1));
g_server_manager.RegisterServer<sm::DmntService>(smdmnt_h);
g_server_manager.RegisterServer<sm::impl::IDebugMonitorInterface, sm::DebugMonitorService>(smdmnt_h);
}
/*================================*/

View File

@@ -19,33 +19,14 @@
namespace ams::sm {
/* Service definition. */
class ManagerService final : public sf::IServiceObject {
protected:
/* Command IDs. */
enum class CommandId {
RegisterProcess = 0,
UnregisterProcess = 1,
AtmosphereEndInitDefers = 65000,
AtmosphereHasMitm = 65001,
AtmosphereRegisterProcess = 65002,
};
private:
/* Actual commands. */
virtual Result RegisterProcess(os::ProcessId process_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac);
virtual Result UnregisterProcess(os::ProcessId process_id);
virtual void AtmosphereEndInitDefers();
virtual void AtmosphereHasMitm(sf::Out<bool> out, ServiceName service);
virtual Result AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac);
class ManagerService final {
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(RegisterProcess),
MAKE_SERVICE_COMMAND_META(UnregisterProcess),
MAKE_SERVICE_COMMAND_META(AtmosphereEndInitDefers),
MAKE_SERVICE_COMMAND_META(AtmosphereHasMitm),
MAKE_SERVICE_COMMAND_META(AtmosphereRegisterProcess),
};
Result RegisterProcess(os::ProcessId process_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac);
Result UnregisterProcess(os::ProcessId process_id);
void AtmosphereEndInitDefers();
void AtmosphereHasMitm(sf::Out<bool> out, ServiceName service);
Result AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac);
};
static_assert(sm::impl::IsIManagerInterface<ManagerService>);
}

View File

@@ -19,20 +19,18 @@
namespace ams::sm {
Result UserService::Initialize(const sf::ClientProcessId &client_process_id) {
Result UserService::RegisterClient(const sf::ClientProcessId &client_process_id) {
this->process_id = client_process_id.GetValue();
this->has_initialized = true;
return ResultSuccess();
}
Result UserService::EnsureInitialized() {
if (!this->has_initialized) {
return sm::ResultInvalidClient();
}
R_UNLESS(this->has_initialized, sm::ResultInvalidClient());
return ResultSuccess();
}
Result UserService::GetService(sf::OutMoveHandle out_h, ServiceName service) {
Result UserService::GetServiceHandle(sf::OutMoveHandle out_h, ServiceName service) {
R_TRY(this->EnsureInitialized());
return impl::GetServiceHandle(out_h.GetHandlePointer(), this->process_id, service);
}

View File

@@ -20,26 +20,7 @@
namespace ams::sm {
/* Service definition. */
class UserService final : public sf::IServiceObject {
protected:
/* Command IDs. */
enum class CommandId {
Initialize = 0,
GetService = 1,
RegisterService = 2,
UnregisterService = 3,
AtmosphereInstallMitm = 65000,
AtmosphereUninstallMitm = 65001,
/* Deprecated: AtmosphereAssociatePidTidForMitm = 65002 */
AtmosphereAcknowledgeMitmSession = 65003,
AtmosphereHasMitm = 65004,
AtmosphereWaitMitm = 65005,
AtmosphereDeclareFutureMitm = 65006,
AtmosphereHasService = 65100,
AtmosphereWaitService = 65101,
};
class UserService final {
private:
os::ProcessId process_id = os::InvalidProcessId;
bool has_initialized = false;
@@ -47,38 +28,22 @@ namespace ams::sm {
Result EnsureInitialized();
public:
/* Official commands. */
virtual Result Initialize(const sf::ClientProcessId &client_process_id);
virtual Result GetService(sf::OutMoveHandle out_h, ServiceName service);
virtual Result RegisterService(sf::OutMoveHandle out_h, ServiceName service, u32 max_sessions, bool is_light);
virtual Result UnregisterService(ServiceName service);
Result RegisterClient(const sf::ClientProcessId &client_process_id);
Result GetServiceHandle(sf::OutMoveHandle out_h, ServiceName service);
Result RegisterService(sf::OutMoveHandle out_h, ServiceName service, u32 max_sessions, bool is_light);
Result UnregisterService(ServiceName service);
/* Atmosphere commands. */
virtual Result AtmosphereInstallMitm(sf::OutMoveHandle srv_h, sf::OutMoveHandle qry_h, ServiceName service);
virtual Result AtmosphereUninstallMitm(ServiceName service);
virtual Result AtmosphereAcknowledgeMitmSession(sf::Out<MitmProcessInfo> client_info, sf::OutMoveHandle fwd_h, ServiceName service);
virtual Result AtmosphereHasMitm(sf::Out<bool> out, ServiceName service);
virtual Result AtmosphereWaitMitm(ServiceName service);
virtual Result AtmosphereDeclareFutureMitm(ServiceName service);
Result AtmosphereInstallMitm(sf::OutMoveHandle srv_h, sf::OutMoveHandle qry_h, ServiceName service);
Result AtmosphereUninstallMitm(ServiceName service);
Result AtmosphereAcknowledgeMitmSession(sf::Out<MitmProcessInfo> client_info, sf::OutMoveHandle fwd_h, ServiceName service);
Result AtmosphereHasMitm(sf::Out<bool> out, ServiceName service);
Result AtmosphereWaitMitm(ServiceName service);
Result AtmosphereDeclareFutureMitm(ServiceName service);
virtual Result AtmosphereHasService(sf::Out<bool> out, ServiceName service);
virtual Result AtmosphereWaitService(ServiceName service);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(Initialize),
MAKE_SERVICE_COMMAND_META(GetService),
MAKE_SERVICE_COMMAND_META(RegisterService),
MAKE_SERVICE_COMMAND_META(UnregisterService),
MAKE_SERVICE_COMMAND_META(AtmosphereInstallMitm),
MAKE_SERVICE_COMMAND_META(AtmosphereUninstallMitm),
MAKE_SERVICE_COMMAND_META(AtmosphereAcknowledgeMitmSession),
MAKE_SERVICE_COMMAND_META(AtmosphereHasMitm),
MAKE_SERVICE_COMMAND_META(AtmosphereWaitMitm),
MAKE_SERVICE_COMMAND_META(AtmosphereDeclareFutureMitm),
MAKE_SERVICE_COMMAND_META(AtmosphereHasService),
MAKE_SERVICE_COMMAND_META(AtmosphereWaitService),
};
Result AtmosphereHasService(sf::Out<bool> out, ServiceName service);
Result AtmosphereWaitService(ServiceName service);
};
static_assert(sm::impl::IsIUserInterface<UserService>);
}