ams: support building unit test programs on windows/linux/macos
This commit is contained in:
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include "../service_guard.h"
|
||||
#include "sm_ams.h"
|
||||
#include "sm_ams.os.horizon.h"
|
||||
|
||||
static Result _smAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
|
||||
u8 tmp;
|
||||
u8 tmp = 0;
|
||||
Result rc = tipcDispatchInOut(smGetServiceSessionTipc(), cmd_id, name, tmp);
|
||||
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
||||
return rc;
|
||||
@@ -5,6 +5,9 @@
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -31,4 +34,6 @@ Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *info_out, SmSe
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
namespace ams::sm {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
namespace {
|
||||
|
||||
constinit int g_ref_count = 0;
|
||||
@@ -45,8 +46,8 @@ namespace ams::sm {
|
||||
}
|
||||
|
||||
/* Ordinary SM API. */
|
||||
Result GetService(Service *out, ServiceName name) {
|
||||
return smGetServiceWrapper(out, impl::ConvertName(name));
|
||||
Result GetServiceHandle(os::NativeHandle *out, ServiceName name) {
|
||||
return smGetServiceOriginal(out, impl::ConvertName(name));
|
||||
}
|
||||
|
||||
Result RegisterService(os::NativeHandle *out, ServiceName name, size_t max_sessions, bool is_light) {
|
||||
@@ -65,5 +66,41 @@ namespace ams::sm {
|
||||
Result WaitService(ServiceName name) {
|
||||
return smAtmosphereWaitService(impl::ConvertName(name));
|
||||
}
|
||||
#else
|
||||
Result Initialize() {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Finalize() {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
/* Ordinary SM API. */
|
||||
Result GetServiceHandle(os::NativeHandle *out, ServiceName name) {
|
||||
AMS_UNUSED(out, name);
|
||||
AMS_ABORT("TODO?");
|
||||
}
|
||||
|
||||
Result RegisterService(os::NativeHandle *out, ServiceName name, size_t max_sessions, bool is_light) {
|
||||
AMS_UNUSED(out, name, max_sessions, is_light);
|
||||
AMS_ABORT("TODO?");
|
||||
}
|
||||
|
||||
Result UnregisterService(ServiceName name) {
|
||||
AMS_UNUSED(name);
|
||||
AMS_ABORT("TODO?");
|
||||
}
|
||||
|
||||
/* Atmosphere extensions. */
|
||||
Result HasService(bool *out, ServiceName name) {
|
||||
AMS_UNUSED(out, name);
|
||||
AMS_ABORT("TODO?");
|
||||
}
|
||||
|
||||
Result WaitService(ServiceName name) {
|
||||
AMS_UNUSED(name);
|
||||
AMS_ABORT("TODO?");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "sm_utils.hpp"
|
||||
#include "smm_ams.h"
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
#include "smm_ams.os.horizon.h"
|
||||
#endif
|
||||
|
||||
namespace ams::sm::manager {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
/* Manager API. */
|
||||
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size) {
|
||||
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition");
|
||||
@@ -37,5 +41,6 @@ namespace ams::sm::manager {
|
||||
Result HasMitm(bool *out, ServiceName name) {
|
||||
return smManagerAtmosphereHasMitm(out, impl::ConvertName(name));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
namespace ams::sm::mitm {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
#if AMS_SF_MITM_SUPPORTED
|
||||
/* Mitm API. */
|
||||
Result InstallMitm(os::NativeHandle *out_port, os::NativeHandle *out_query, ServiceName name) {
|
||||
return impl::DoWithPerThreadSession([&](TipcService *fwd) {
|
||||
@@ -50,5 +52,7 @@ namespace ams::sm::mitm {
|
||||
Result WaitMitm(ServiceName name) {
|
||||
return smAtmosphereWaitMitm(impl::ConvertName(name));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
#include "sm_ams.h"
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
#include "sm_ams.os.horizon.h"
|
||||
#endif
|
||||
|
||||
namespace ams::sm::impl {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
/* Utilities. */
|
||||
os::SdkRecursiveMutex &GetMitmAcknowledgementSessionMutex();
|
||||
os::SdkRecursiveMutex &GetPerThreadSessionMutex();
|
||||
@@ -52,5 +56,6 @@ namespace ams::sm::impl {
|
||||
static_assert(sizeof(SmServiceName) == sizeof(sm::ServiceName));
|
||||
return std::bit_cast<SmServiceName>(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "smm_ams.h"
|
||||
#include "smm_ams.os.horizon.h"
|
||||
|
||||
Result smManagerAtmosphereEndInitialDefers(void) {
|
||||
return tipcDispatch(smManagerTipcGetServiceSession(), 65000);
|
||||
@@ -5,6 +5,9 @@
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -22,4 +25,6 @@ Result smManagerAtmosphereHasMitm(bool *out, SmServiceName name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user