2020-01-18 05:11:03 +01:00
|
|
|
/*
|
2021-10-04 21:59:10 +02:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-01-18 05:11:03 +01:00
|
|
|
*
|
|
|
|
* 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
|
2020-02-23 08:05:14 +01:00
|
|
|
#include <vapours/common.hpp>
|
|
|
|
#include <vapours/assert.hpp>
|
2020-01-31 00:29:51 +01:00
|
|
|
#include <vapours/results.hpp>
|
2020-01-18 05:11:03 +01:00
|
|
|
|
|
|
|
namespace ams::svc {
|
|
|
|
|
|
|
|
/* TODO: C++ style handle? */
|
2020-02-23 15:51:32 +01:00
|
|
|
using Handle = u32;
|
2021-10-05 02:12:32 +02:00
|
|
|
#if defined(ATMOSPHERE_IS_STRATOSPHERE)
|
|
|
|
static_assert(std::same_as<::ams::svc::Handle, ::Handle>);
|
2020-01-18 05:11:03 +01:00
|
|
|
#endif
|
|
|
|
|
2020-04-08 11:21:35 +02:00
|
|
|
enum {
|
|
|
|
HandleWaitMask = (1u << 30),
|
|
|
|
};
|
|
|
|
|
2020-07-10 02:21:47 +02:00
|
|
|
constexpr inline s32 ArgumentHandleCountMax = 0x40;
|
2020-01-31 09:07:06 +01:00
|
|
|
|
2020-04-08 11:21:35 +02:00
|
|
|
constexpr inline s64 WaitInfinite = -1;
|
|
|
|
|
2020-02-20 18:05:01 +01:00
|
|
|
enum PseudoHandle : Handle {
|
2020-01-31 00:29:51 +01:00
|
|
|
CurrentThread = 0xFFFF8000,
|
|
|
|
CurrentProcess = 0xFFFF8001,
|
|
|
|
};
|
|
|
|
|
2020-03-10 07:23:38 +01:00
|
|
|
constexpr inline Handle InvalidHandle = Handle(0);
|
|
|
|
|
2020-01-31 00:29:51 +01:00
|
|
|
constexpr ALWAYS_INLINE bool operator==(const Handle &lhs, const PseudoHandle &rhs) {
|
|
|
|
return static_cast<Handle>(lhs) == static_cast<Handle>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr ALWAYS_INLINE bool operator==(const PseudoHandle &lhs, const Handle &rhs) {
|
|
|
|
return static_cast<Handle>(lhs) == static_cast<Handle>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr ALWAYS_INLINE bool operator!=(const Handle &lhs, const PseudoHandle &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr ALWAYS_INLINE bool operator!=(const PseudoHandle &lhs, const Handle &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr ALWAYS_INLINE bool IsPseudoHandle(const Handle &handle) {
|
|
|
|
return handle == PseudoHandle::CurrentProcess || handle == PseudoHandle::CurrentThread;
|
|
|
|
}
|
|
|
|
|
2020-03-15 07:13:40 +01:00
|
|
|
#if defined(ATMOSPHERE_ARCH_ARM64)
|
2020-01-18 05:11:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace lp64 { /* ... */ }
|
|
|
|
namespace aarch64 { /* ... */ }
|
|
|
|
using namespace ::ams::svc::lp64;
|
|
|
|
using namespace ::ams::svc::aarch64;
|
|
|
|
|
|
|
|
/* TODO: ifdef ATMOSPHERE_ABI_LP64 */
|
|
|
|
#if 1
|
|
|
|
namespace aarch64::lp64 { /* ... */ }
|
|
|
|
using namespace ::ams::svc::aarch64::lp64;
|
|
|
|
#else
|
|
|
|
namespace aarch64::ilp32 { /* ... */ }
|
|
|
|
using namespace ::ams::svc::aarch64::ilp32;
|
|
|
|
#endif
|
|
|
|
|
2020-03-15 07:13:40 +01:00
|
|
|
#elif defined(ATMOSPHERE_ARCH_ARM)
|
2020-01-18 05:11:03 +01:00
|
|
|
|
|
|
|
namespace ilp32 { /* ... */ }
|
|
|
|
namespace aarch32 { /* ... */ }
|
|
|
|
using namespace ::ams::svc::ilp32;
|
|
|
|
using namespace ::ams::svc::aarch32;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#error "Unknown Architecture"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|