ams: support building unit test programs on windows/linux/macos
This commit is contained in:
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include "pm_ams.h"
|
||||
#include "pm_ams.os.horizon.h"
|
||||
|
||||
Result pminfoAtmosphereGetProcessId(u64 *out_pid, u64 program_id) {
|
||||
return serviceDispatchInOut(pminfoGetServiceSession(), 65000, program_id, *out_pid);
|
||||
}
|
||||
|
||||
Result pminfoAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id) {
|
||||
u8 tmp;
|
||||
u8 tmp = 0;
|
||||
Result rc = serviceDispatchInOut(pminfoGetServiceSession(), 65001, program_id, 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
|
||||
@@ -25,4 +28,6 @@ Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,7 @@ namespace ams::pm::bm {
|
||||
|
||||
/* Boot Mode API. */
|
||||
/* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
BootMode WEAK_SYMBOL GetBootMode() {
|
||||
PmBootMode boot_mode = PmBootMode_Normal;
|
||||
R_ABORT_UNLESS(pmbmGetBootMode(std::addressof(boot_mode)));
|
||||
@@ -28,5 +29,14 @@ namespace ams::pm::bm {
|
||||
void WEAK_SYMBOL SetMaintenanceBoot() {
|
||||
R_ABORT_UNLESS(pmbmSetMaintenanceBoot());
|
||||
}
|
||||
#else
|
||||
BootMode WEAK_SYMBOL GetBootMode() {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
|
||||
void WEAK_SYMBOL SetMaintenanceBoot() {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#include "pm_ams.h"
|
||||
#include "pm_ams.os.horizon.h"
|
||||
|
||||
namespace ams::pm::dmnt {
|
||||
|
||||
/* Debug Monitor API. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
Result StartProcess(os::ProcessId process_id) {
|
||||
return pmdmntStartProcess(static_cast<u64>(process_id));
|
||||
}
|
||||
@@ -52,5 +53,6 @@ namespace ams::pm::dmnt {
|
||||
*out_limit_value = 0;
|
||||
return pmdmntAtmosphereGetCurrentLimitInfo(out_current_value, out_limit_value, group, resource);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "pm_ams.h"
|
||||
#include "pm_ams.os.horizon.h"
|
||||
|
||||
namespace ams::pm::info {
|
||||
|
||||
/* Information API. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id) {
|
||||
return pminfoGetProgramId(reinterpret_cast<u64 *>(out_program_id), static_cast<u64>(process_id));
|
||||
}
|
||||
@@ -56,5 +57,6 @@ namespace ams::pm::info {
|
||||
|
||||
return IsHblProcessId(out, process_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -14,16 +14,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "pm_ams.h"
|
||||
#include "pm_ams.os.horizon.h"
|
||||
|
||||
namespace ams::pm::info {
|
||||
|
||||
/* Information API. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
Result WEAK_SYMBOL HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) {
|
||||
bool has_launched = false;
|
||||
R_TRY(pminfoAtmosphereHasLaunchedBootProgram(std::addressof(has_launched), static_cast<u64>(program_id)));
|
||||
*out = has_launched;
|
||||
return ResultSuccess();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
namespace ams::pm::shell {
|
||||
|
||||
/* Shell API. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) {
|
||||
static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation));
|
||||
static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation));
|
||||
@@ -52,5 +53,6 @@ namespace ams::pm::shell {
|
||||
Result EnableApplicationExtraThread() {
|
||||
return ::pmshellEnableApplicationExtraThread();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user