mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-27 21:42:49 +02:00
sm/tipc: minor cleanup
This commit is contained in:
parent
02c1d19605
commit
15b3f9545f
@ -20,10 +20,6 @@
|
|||||||
|
|
||||||
namespace ams::cfg {
|
namespace ams::cfg {
|
||||||
|
|
||||||
/* Privileged Process configuration. */
|
|
||||||
bool IsInitialProcess();
|
|
||||||
void GetInitialProcessRange(os::ProcessId *out_min, os::ProcessId *out_max);
|
|
||||||
|
|
||||||
/* SD card configuration. */
|
/* SD card configuration. */
|
||||||
bool IsSdCardRequiredServicesReady();
|
bool IsSdCardRequiredServicesReady();
|
||||||
void WaitSdCardRequiredServicesReady();
|
void WaitSdCardRequiredServicesReady();
|
||||||
|
@ -71,9 +71,9 @@ namespace ams::pgl {
|
|||||||
explicit EventObserverByTipc(Args &&... args) : m_tipc_interface(std::forward<Args>(args)...) { /* ... */ }
|
explicit EventObserverByTipc(Args &&... args) : m_tipc_interface(std::forward<Args>(args)...) { /* ... */ }
|
||||||
public:
|
public:
|
||||||
virtual Result GetSystemEvent(os::SystemEventType *out) override {
|
virtual Result GetSystemEvent(os::SystemEventType *out) override {
|
||||||
ams::tipc::CopyHandle handle;
|
os::NativeHandle handle;
|
||||||
R_TRY(m_tipc_interface.GetProcessEventHandle(std::addressof(handle)));
|
R_TRY(m_tipc_interface.GetProcessEventHandle(std::addressof(handle)));
|
||||||
os::AttachReadableHandleToSystemEvent(out, handle.GetValue(), true, os::EventClearMode_AutoClear);
|
os::AttachReadableHandleToSystemEvent(out, handle, true, os::EventClearMode_AutoClear);
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,16 @@ namespace ams::tipc::impl {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define AMS_TIPC_IMPL_IS_FIRMWARE_VERSION_ALWAYS_VALID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
|
||||||
|
{ \
|
||||||
|
constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \
|
||||||
|
constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \
|
||||||
|
if (!MinValid || !MaxValid) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define AMS_TIPC_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \
|
#define AMS_TIPC_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \
|
||||||
namespace NAMESPACE { \
|
namespace NAMESPACE { \
|
||||||
\
|
\
|
||||||
@ -117,6 +127,11 @@ namespace ams::tipc::impl {
|
|||||||
CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID) \
|
CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID) \
|
||||||
\
|
\
|
||||||
return this->ProcessDefaultMethod<ImplType>(impl, message_buffer); \
|
return this->ProcessDefaultMethod<ImplType>(impl, message_buffer); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static consteval bool IsFirmwareVersionAlwaysValid() { \
|
||||||
|
CMD_MACRO(ImplType, AMS_TIPC_IMPL_IS_FIRMWARE_VERSION_ALWAYS_VALID); \
|
||||||
|
return true; \
|
||||||
} \
|
} \
|
||||||
public: \
|
public: \
|
||||||
virtual Result ProcessRequest() override { \
|
virtual Result ProcessRequest() override { \
|
||||||
@ -132,7 +147,7 @@ namespace ams::tipc::impl {
|
|||||||
\
|
\
|
||||||
/* Get decision variables. */ \
|
/* Get decision variables. */ \
|
||||||
const auto tag = svc::ipc::MessageBuffer::MessageHeader(message_buffer).GetTag(); \
|
const auto tag = svc::ipc::MessageBuffer::MessageHeader(message_buffer).GetTag(); \
|
||||||
const auto fw_ver = hos::GetVersion(); \
|
const auto fw_ver = IsFirmwareVersionAlwaysValid() ? hos::Version_Current : hos::GetVersion(); \
|
||||||
\
|
\
|
||||||
/* Process against the command ids. */ \
|
/* Process against the command ids. */ \
|
||||||
if (false) { } \
|
if (false) { } \
|
||||||
|
@ -76,9 +76,9 @@ namespace ams::tipc::impl {
|
|||||||
constexpr inline ArgumentType GetArgumentType = [] {
|
constexpr inline ArgumentType GetArgumentType = [] {
|
||||||
if constexpr (tipc::IsBuffer<T>) {
|
if constexpr (tipc::IsBuffer<T>) {
|
||||||
return ArgumentType::Buffer;
|
return ArgumentType::Buffer;
|
||||||
} else if constexpr (std::is_base_of<tipc::impl::InHandleTag, T>::value) {
|
} else if constexpr (std::same_as<T, tipc::CopyHandle> || std::same_as<T, tipc::MoveHandle>) {
|
||||||
return ArgumentType::InHandle;
|
return ArgumentType::InHandle;
|
||||||
} else if constexpr (std::is_base_of<tipc::impl::OutHandleTag, T>::value) {
|
} else if constexpr (std::same_as<T, tipc::OutCopyHandle> || std::same_as<T, tipc::OutMoveHandle>) {
|
||||||
return ArgumentType::OutHandle;
|
return ArgumentType::OutHandle;
|
||||||
} else if constexpr (std::is_base_of<tipc::impl::OutBaseTag, T>::value) {
|
} else if constexpr (std::is_base_of<tipc::impl::OutBaseTag, T>::value) {
|
||||||
return ArgumentType::OutData;
|
return ArgumentType::OutData;
|
||||||
@ -126,10 +126,10 @@ namespace ams::tipc::impl {
|
|||||||
using InCopyHandleFilter = TypeEqualityFilter<T, tipc::CopyHandle>;
|
using InCopyHandleFilter = TypeEqualityFilter<T, tipc::CopyHandle>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using OutMoveHandleFilter = TypeEqualityFilter<T, tipc::Out<tipc::MoveHandle>>;
|
using OutMoveHandleFilter = TypeEqualityFilter<T, tipc::OutMoveHandle>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using OutCopyHandleFilter = TypeEqualityFilter<T, tipc::Out<tipc::CopyHandle>>;
|
using OutCopyHandleFilter = TypeEqualityFilter<T, tipc::OutCopyHandle>;
|
||||||
|
|
||||||
template<typename>
|
template<typename>
|
||||||
struct BufferAttributeArrayGetter;
|
struct BufferAttributeArrayGetter;
|
||||||
@ -267,6 +267,8 @@ namespace ams::tipc::impl {
|
|||||||
static_assert(NumInHandles <= 8, "Methods must take in <= 8 Handles");
|
static_assert(NumInHandles <= 8, "Methods must take in <= 8 Handles");
|
||||||
static_assert(NumOutHandles <= 8, "Methods must output <= 8 Handles");
|
static_assert(NumOutHandles <= 8, "Methods must output <= 8 Handles");
|
||||||
|
|
||||||
|
static_assert(NumInHandles == 0, "In Handles not yet implemented!");
|
||||||
|
|
||||||
/* Buffer marshalling. */
|
/* Buffer marshalling. */
|
||||||
static constexpr std::array<u32, NumBuffers> BufferAttributes = BufferAttributeArrayGetter<Buffers>::value;
|
static constexpr std::array<u32, NumBuffers> BufferAttributes = BufferAttributeArrayGetter<Buffers>::value;
|
||||||
static constexpr size_t NumInBuffers = BufferAttributeCounter<InBufferPredicate>::GetCount(BufferAttributes);
|
static constexpr size_t NumInBuffers = BufferAttributeCounter<InBufferPredicate>::GetCount(BufferAttributes);
|
||||||
@ -340,18 +342,18 @@ namespace ams::tipc::impl {
|
|||||||
current_info.out_raw_data_index++;
|
current_info.out_raw_data_index++;
|
||||||
} else if constexpr (arg_type == ArgumentType::InHandle) {
|
} else if constexpr (arg_type == ArgumentType::InHandle) {
|
||||||
/* New InHandle, increment the appropriate index. */
|
/* New InHandle, increment the appropriate index. */
|
||||||
if constexpr (std::is_same<T, tipc::MoveHandle>::value) {
|
if constexpr (std::same_as<T, tipc::MoveHandle>) {
|
||||||
current_info.in_move_handle_index++;
|
current_info.in_move_handle_index++;
|
||||||
} else if constexpr (std::is_same<T, tipc::CopyHandle>::value) {
|
} else if constexpr (std::same_as<T, tipc::CopyHandle>) {
|
||||||
current_info.in_copy_handle_index++;
|
current_info.in_copy_handle_index++;
|
||||||
} else {
|
} else {
|
||||||
static_assert(!std::is_same<T, T>::value, "Invalid InHandle kind");
|
static_assert(!std::is_same<T, T>::value, "Invalid InHandle kind");
|
||||||
}
|
}
|
||||||
} else if constexpr (arg_type == ArgumentType::OutHandle) {
|
} else if constexpr (arg_type == ArgumentType::OutHandle) {
|
||||||
/* New OutHandle, increment the appropriate index. */
|
/* New OutHandle, increment the appropriate index. */
|
||||||
if constexpr (std::is_same<T, tipc::Out<tipc::MoveHandle>>::value) {
|
if constexpr (std::same_as<T, tipc::OutMoveHandle>) {
|
||||||
current_info.out_move_handle_index++;
|
current_info.out_move_handle_index++;
|
||||||
} else if constexpr (std::is_same<T, tipc::Out<tipc::CopyHandle>>::value) {
|
} else if constexpr (std::same_as<T, tipc::OutCopyHandle>) {
|
||||||
current_info.out_copy_handle_index++;
|
current_info.out_copy_handle_index++;
|
||||||
} else {
|
} else {
|
||||||
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
|
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
|
||||||
@ -418,25 +420,25 @@ namespace ams::tipc::impl {
|
|||||||
static constexpr size_t NumMove = _NumMove;
|
static constexpr size_t NumMove = _NumMove;
|
||||||
static constexpr size_t NumCopy = _NumCopy;
|
static constexpr size_t NumCopy = _NumCopy;
|
||||||
private:
|
private:
|
||||||
MoveHandle move_handles[NumMove];
|
os::NativeHandle move_handles[NumMove];
|
||||||
CopyHandle copy_handles[NumCopy];
|
os::NativeHandle copy_handles[NumCopy];
|
||||||
public:
|
public:
|
||||||
constexpr ALWAYS_INLINE OutHandleHolder() : move_handles(), copy_handles() { /* ... */ }
|
ALWAYS_INLINE OutHandleHolder() { /* ... */ }
|
||||||
|
|
||||||
template<size_t Index>
|
template<size_t Index>
|
||||||
constexpr ALWAYS_INLINE MoveHandle *GetMoveHandlePointer() {
|
constexpr ALWAYS_INLINE os::NativeHandle *GetMoveHandlePointer() {
|
||||||
static_assert(Index < NumMove, "Index < NumMove");
|
static_assert(Index < NumMove, "Index < NumMove");
|
||||||
return move_handles + Index;
|
return move_handles + Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t Index>
|
template<size_t Index>
|
||||||
constexpr ALWAYS_INLINE CopyHandle *GetCopyHandlePointer() {
|
constexpr ALWAYS_INLINE os::NativeHandle *GetCopyHandlePointer() {
|
||||||
static_assert(Index < NumCopy, "Index < NumCopy");
|
static_assert(Index < NumCopy, "Index < NumCopy");
|
||||||
return copy_handles + Index;
|
return copy_handles + Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE void CopyTo(const svc::ipc::MessageBuffer &buffer) const {
|
ALWAYS_INLINE void CopyTo(const svc::ipc::MessageBuffer &buffer) const {
|
||||||
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { buffer.SetHandle(OutIndex + n, copy_handles[n].GetValue()); } } while (0)
|
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { buffer.SetHandle(OutIndex + n, copy_handles[n]); } } while (0)
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(0);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(0);
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(1);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(1);
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(2);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(2);
|
||||||
@ -446,7 +448,7 @@ namespace ams::tipc::impl {
|
|||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(6);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(6);
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(7);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(7);
|
||||||
#undef _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE
|
#undef _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE
|
||||||
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { buffer.SetHandle(OutIndex + NumCopy + n, move_handles[n].GetValue()); } } while (0)
|
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { buffer.SetHandle(OutIndex + NumCopy + n, move_handles[n]); } } while (0)
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(0);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(0);
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(1);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(1);
|
||||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(2);
|
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(2);
|
||||||
@ -507,10 +509,10 @@ namespace ams::tipc::impl {
|
|||||||
return T(out_raw_holder.template GetAddress<Offset, T::TypeSize>());
|
return T(out_raw_holder.template GetAddress<Offset, T::TypeSize>());
|
||||||
} else if constexpr (Info.arg_type == ArgumentType::InHandle) {
|
} else if constexpr (Info.arg_type == ArgumentType::InHandle) {
|
||||||
/* New InHandle. */
|
/* New InHandle. */
|
||||||
if constexpr (std::is_same<T, tipc::MoveHandle>::value) {
|
if constexpr (std::same_as<T, tipc::MoveHandle>) {
|
||||||
constexpr auto HandleIndex = CommandMeta::InMessageHandleIndex + CommandMeta::NumInCopyHandles + Info.in_move_handle_index;
|
constexpr auto HandleIndex = CommandMeta::InMessageHandleIndex + CommandMeta::NumInCopyHandles + Info.in_move_handle_index;
|
||||||
return T(message_buffer.GetHandle(HandleIndex));
|
return T(message_buffer.GetHandle(HandleIndex));
|
||||||
} else if constexpr (std::is_same<T, tipc::CopyHandle>::value) {
|
} else if constexpr (std::same_as<T, tipc::CopyHandle>) {
|
||||||
constexpr auto HandleIndex = CommandMeta::InMessageHandleIndex + Info.in_copy_handle_index;
|
constexpr auto HandleIndex = CommandMeta::InMessageHandleIndex + Info.in_copy_handle_index;
|
||||||
return T(message_buffer.GetHandle(HandleIndex));
|
return T(message_buffer.GetHandle(HandleIndex));
|
||||||
} else {
|
} else {
|
||||||
@ -518,10 +520,14 @@ namespace ams::tipc::impl {
|
|||||||
}
|
}
|
||||||
} else if constexpr (Info.arg_type == ArgumentType::OutHandle) {
|
} else if constexpr (Info.arg_type == ArgumentType::OutHandle) {
|
||||||
/* New OutHandle. */
|
/* New OutHandle. */
|
||||||
if constexpr (std::is_same<T, tipc::Out<tipc::MoveHandle>>::value) {
|
if constexpr (std::same_as<T, tipc::OutMoveHandle>) {
|
||||||
return T(out_handles_holder.template GetMoveHandlePointer<Info.out_move_handle_index>());
|
os::NativeHandle * const ptr = out_handles_holder.template GetMoveHandlePointer<Info.out_move_handle_index>();
|
||||||
} else if constexpr (std::is_same<T, tipc::Out<tipc::CopyHandle>>::value) {
|
*ptr = os::InvalidNativeHandle;
|
||||||
return T(out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>());
|
return T(ptr);
|
||||||
|
} else if constexpr (std::same_as<T, tipc::OutCopyHandle>) {
|
||||||
|
os::NativeHandle * const ptr = out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>();
|
||||||
|
*ptr = os::InvalidNativeHandle;
|
||||||
|
return T(ptr);
|
||||||
} else {
|
} else {
|
||||||
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
|
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
|
||||||
}
|
}
|
||||||
|
@ -20,147 +20,72 @@
|
|||||||
|
|
||||||
namespace ams::tipc {
|
namespace ams::tipc {
|
||||||
|
|
||||||
namespace impl {
|
/* TODO: How do InHandles work in tipc? No examples to work off of. */
|
||||||
|
class CopyHandle {
|
||||||
struct InHandleTag{};
|
|
||||||
struct OutHandleTag{};
|
|
||||||
|
|
||||||
template<u32 Attribute>
|
|
||||||
struct InHandle : public InHandleTag {
|
|
||||||
os::NativeHandle handle;
|
|
||||||
|
|
||||||
constexpr InHandle() : handle(os::InvalidNativeHandle) { /* ... */ }
|
|
||||||
constexpr InHandle(os::NativeHandle h) : handle(h) { /* ... */ }
|
|
||||||
constexpr InHandle(const InHandle &o) : handle(o.handle) { /* ... */ }
|
|
||||||
|
|
||||||
constexpr void operator=(const os::NativeHandle &h) { this->handle = h; }
|
|
||||||
constexpr void operator=(const InHandle &o) { this->handle = o.handle; }
|
|
||||||
|
|
||||||
constexpr /* TODO: explicit? */ operator os::NativeHandle() const { return this->handle; }
|
|
||||||
constexpr os::NativeHandle GetValue() const { return this->handle; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class OutHandleImpl : public OutHandleTag {
|
|
||||||
static_assert(std::is_base_of<InHandleTag, T>::value, "OutHandleImpl requires InHandle base");
|
|
||||||
private:
|
|
||||||
T *m_ptr;
|
|
||||||
public:
|
|
||||||
constexpr OutHandleImpl(T *p) : m_ptr(p) { /* ... */ }
|
|
||||||
|
|
||||||
constexpr void SetValue(const os::NativeHandle &value) {
|
|
||||||
*m_ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void SetValue(const T &value) {
|
|
||||||
*m_ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const T &GetValue() const {
|
|
||||||
return *m_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T *GetPointer() const {
|
|
||||||
return m_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr os::NativeHandle *GetHandlePointer() const {
|
|
||||||
return &m_ptr->handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T &operator *() const {
|
|
||||||
return *m_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T *operator ->() const {
|
|
||||||
return m_ptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
using MoveHandle = typename impl::InHandle<SfOutHandleAttr_HipcMove>;
|
|
||||||
using CopyHandle = typename impl::InHandle<SfOutHandleAttr_HipcCopy>;
|
|
||||||
|
|
||||||
static_assert(sizeof(MoveHandle) == sizeof(os::NativeHandle), "sizeof(MoveHandle)");
|
|
||||||
static_assert(sizeof(CopyHandle) == sizeof(os::NativeHandle), "sizeof(CopyHandle)");
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class IsOutForceEnabled<MoveHandle> : public std::true_type{};
|
|
||||||
template<>
|
|
||||||
class IsOutForceEnabled<CopyHandle> : public std::true_type{};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class Out<MoveHandle> : public impl::OutHandleImpl<MoveHandle> {
|
|
||||||
private:
|
private:
|
||||||
using T = MoveHandle;
|
CopyHandle();
|
||||||
using Base = impl::OutHandleImpl<T>;
|
};
|
||||||
|
|
||||||
|
class MoveHandle {
|
||||||
|
private:
|
||||||
|
MoveHandle();
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class Out<CopyHandle> {
|
||||||
|
private:
|
||||||
|
os::NativeHandle * const m_ptr;
|
||||||
public:
|
public:
|
||||||
constexpr Out<T>(T *p) : Base(p) { /* ... */ }
|
ALWAYS_INLINE Out(os::NativeHandle *p) : m_ptr(p) { /* ... */ }
|
||||||
|
|
||||||
constexpr void SetValue(const os::NativeHandle &value) {
|
ALWAYS_INLINE void SetValue(os::NativeHandle v) const {
|
||||||
Base::SetValue(value);
|
*m_ptr = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void SetValue(const T &value) {
|
ALWAYS_INLINE const os::NativeHandle &GetValue() const {
|
||||||
Base::SetValue(value);
|
return *m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const T &GetValue() const {
|
ALWAYS_INLINE os::NativeHandle *GetPointer() const {
|
||||||
return Base::GetValue();
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr T *GetPointer() const {
|
/* Convenience operators. */
|
||||||
return Base::GetPointer();
|
ALWAYS_INLINE os::NativeHandle &operator*() const {
|
||||||
|
return *m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr os::NativeHandle *GetHandlePointer() const {
|
ALWAYS_INLINE os::NativeHandle *operator->() const {
|
||||||
return Base::GetHandlePointer();
|
return m_ptr;
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T &operator *() const {
|
|
||||||
return Base::operator*();
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T *operator ->() const {
|
|
||||||
return Base::operator->();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
class Out<CopyHandle> : public impl::OutHandleImpl<CopyHandle> {
|
class Out<MoveHandle> {
|
||||||
private:
|
private:
|
||||||
using T = CopyHandle;
|
os::NativeHandle * const m_ptr;
|
||||||
using Base = impl::OutHandleImpl<T>;
|
|
||||||
public:
|
public:
|
||||||
constexpr Out<T>(T *p) : Base(p) { /* ... */ }
|
ALWAYS_INLINE Out(os::NativeHandle *p) : m_ptr(p) { /* ... */ }
|
||||||
|
|
||||||
constexpr void SetValue(const os::NativeHandle &value) {
|
ALWAYS_INLINE void SetValue(os::NativeHandle v) const {
|
||||||
Base::SetValue(value);
|
*m_ptr = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void SetValue(const T &value) {
|
ALWAYS_INLINE const os::NativeHandle &GetValue() const {
|
||||||
Base::SetValue(value);
|
return *m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const T &GetValue() const {
|
ALWAYS_INLINE os::NativeHandle *GetPointer() const {
|
||||||
return Base::GetValue();
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr T *GetPointer() const {
|
/* Convenience operators. */
|
||||||
return Base::GetPointer();
|
ALWAYS_INLINE os::NativeHandle &operator*() const {
|
||||||
|
return *m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr os::NativeHandle *GetHandlePointer() const {
|
ALWAYS_INLINE os::NativeHandle *operator->() const {
|
||||||
return Base::GetHandlePointer();
|
return m_ptr;
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T &operator *() const {
|
|
||||||
return Base::operator*();
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr T *operator ->() const {
|
|
||||||
return Base::operator->();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 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/>.
|
|
||||||
*/
|
|
||||||
#include <stratosphere.hpp>
|
|
||||||
|
|
||||||
namespace ams::cfg {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
constinit os::SdkMutex g_lock;
|
|
||||||
constinit bool g_got_privileged_process_status = false;
|
|
||||||
constinit os::ProcessId g_min_initial_process_id = os::InvalidProcessId, g_max_initial_process_id = os::InvalidProcessId;
|
|
||||||
constinit os::ProcessId g_cur_process_id = os::InvalidProcessId;
|
|
||||||
|
|
||||||
ALWAYS_INLINE void EnsurePrivilegedProcessStatusCached() {
|
|
||||||
if (AMS_LIKELY(g_got_privileged_process_status)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::scoped_lock lk(g_lock);
|
|
||||||
|
|
||||||
if (AMS_LIKELY(!g_got_privileged_process_status)) {
|
|
||||||
R_ABORT_UNLESS(svc::GetSystemInfo(std::addressof(g_min_initial_process_id.value), svc::SystemInfoType_InitialProcessIdRange, svc::InvalidHandle, svc::InitialProcessIdRangeInfo_Minimum));
|
|
||||||
R_ABORT_UNLESS(svc::GetSystemInfo(std::addressof(g_max_initial_process_id.value), svc::SystemInfoType_InitialProcessIdRange, svc::InvalidHandle, svc::InitialProcessIdRangeInfo_Maximum));
|
|
||||||
g_cur_process_id = os::GetCurrentProcessId();
|
|
||||||
|
|
||||||
g_got_privileged_process_status = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsInitialProcess() {
|
|
||||||
/* Cache initial process range and extents. */
|
|
||||||
EnsurePrivilegedProcessStatusCached();
|
|
||||||
|
|
||||||
/* Determine if we're Initial. */
|
|
||||||
return g_min_initial_process_id <= g_cur_process_id && g_cur_process_id <= g_max_initial_process_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetInitialProcessRange(os::ProcessId *out_min, os::ProcessId *out_max) {
|
|
||||||
/* Cache initial process range and extents. */
|
|
||||||
EnsurePrivilegedProcessStatusCached();
|
|
||||||
|
|
||||||
/* Set output. */
|
|
||||||
*out_min = g_min_initial_process_id;
|
|
||||||
*out_max = g_max_initial_process_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -171,7 +171,7 @@ namespace ams::pgl::srv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result ShellInterfaceTipc::GetShellEventObserver(ams::tipc::OutMoveHandle out) {
|
Result ShellInterfaceTipc::GetShellEventObserver(ams::tipc::OutMoveHandle out) {
|
||||||
return pgl::srv::AllocateShellEventObserverForTipc(out.GetHandlePointer());
|
return pgl::srv::AllocateShellEventObserverForTipc(out.GetPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user