libstrat: remove trailing whitespace

This commit is contained in:
Michael Scire 2019-06-20 12:59:48 -07:00
parent 4a120c3c16
commit 59b49c0e0c
50 changed files with 203 additions and 203 deletions

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <functional> #include <functional>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "stratosphere/utilities.hpp" #include "stratosphere/utilities.hpp"

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <cstdlib> #include <cstdlib>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "ipc/ipc_service_object.hpp" #include "ipc/ipc_service_object.hpp"

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <type_traits> #include <type_traits>
@ -39,12 +39,12 @@ struct InBuffer : public InBufferBase {
size_t num_elements; size_t num_elements;
BufferType type; BufferType type;
static const BufferType expected_type = e_t; static const BufferType expected_type = e_t;
/* Convenience. */ /* Convenience. */
T& operator[](size_t i) const { T& operator[](size_t i) const {
return buffer[i]; return buffer[i];
} }
InBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { } InBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { }
}; };
@ -57,12 +57,12 @@ struct OutBuffer : OutBufferBase {
size_t num_elements; size_t num_elements;
BufferType type; BufferType type;
static const BufferType expected_type = e_t; static const BufferType expected_type = e_t;
/* Convenience. */ /* Convenience. */
T& operator[](size_t i) const { T& operator[](size_t i) const {
return buffer[i]; return buffer[i];
} }
OutBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { } OutBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { }
}; };
@ -73,29 +73,29 @@ template <typename T>
struct InPointer : public InPointerBase { struct InPointer : public InPointerBase {
T *pointer; T *pointer;
size_t num_elements; size_t num_elements;
/* Convenience. */ /* Convenience. */
T& operator[](size_t i) const { T& operator[](size_t i) const {
return pointer[i]; return pointer[i];
} }
InPointer(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { } InPointer(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { }
}; };
/* Represents a C descriptor. */ /* Represents a C descriptor. */
struct OutPointerWithServerSizeBase : public IpcBufferBase {}; struct OutPointerWithServerSizeBase : public IpcBufferBase {};
template <typename T, size_t N> template <typename T, size_t N>
struct OutPointerWithServerSize : public OutPointerWithServerSizeBase { struct OutPointerWithServerSize : public OutPointerWithServerSizeBase {
T *pointer; T *pointer;
static const size_t num_elements = N; static const size_t num_elements = N;
static const size_t element_size = sizeof(T); static const size_t element_size = sizeof(T);
/* Convenience. */ /* Convenience. */
T& operator[](size_t i) const { T& operator[](size_t i) const {
return pointer[i]; return pointer[i];
} }
OutPointerWithServerSize(void *p) : pointer((T *)p) { } OutPointerWithServerSize(void *p) : pointer((T *)p) { }
OutPointerWithServerSize(void *p, size_t n) : pointer((T *)p) { } OutPointerWithServerSize(void *p, size_t n) : pointer((T *)p) { }
}; };
@ -107,11 +107,11 @@ template <typename T>
struct OutPointerWithClientSize : public OutPointerWithClientSizeBase { struct OutPointerWithClientSize : public OutPointerWithClientSizeBase {
T *pointer; T *pointer;
size_t num_elements; size_t num_elements;
/* Convenience. */ /* Convenience. */
T& operator[](size_t i) const { T& operator[](size_t i) const {
return pointer[i]; return pointer[i];
} }
OutPointerWithClientSize(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { } OutPointerWithClientSize(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { }
}; };

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <algorithm> #include <algorithm>
@ -43,39 +43,39 @@ class IDomainObject : public IServiceObject {
DomainManager *manager; DomainManager *manager;
public: public:
IDomainObject(DomainManager *m) : manager(m) {} IDomainObject(DomainManager *m) : manager(m) {}
virtual ~IDomainObject() override { virtual ~IDomainObject() override {
this->manager->FreeDomain(this); this->manager->FreeDomain(this);
} }
DomainManager *GetManager() { DomainManager *GetManager() {
return this->manager; return this->manager;
} }
ServiceObjectHolder *GetObject(u32 object_id) { ServiceObjectHolder *GetObject(u32 object_id) {
return this->manager->GetObject(this, object_id); return this->manager->GetObject(this, object_id);
} }
Result ReserveObject(u32 *out_object_id) { Result ReserveObject(u32 *out_object_id) {
return this->manager->ReserveObject(this, out_object_id); return this->manager->ReserveObject(this, out_object_id);
} }
Result ReserveSpecificObject(u32 object_id) { Result ReserveSpecificObject(u32 object_id) {
return this->manager->ReserveSpecificObject(this, object_id); return this->manager->ReserveSpecificObject(this, object_id);
} }
void SetObject(u32 object_id, ServiceObjectHolder&& holder) { void SetObject(u32 object_id, ServiceObjectHolder&& holder) {
this->manager->SetObject(this, object_id, std::move(holder)); this->manager->SetObject(this, object_id, std::move(holder));
} }
Result FreeObject(u32 object_id) { Result FreeObject(u32 object_id) {
return this->manager->FreeObject(this, object_id); return this->manager->FreeObject(this, object_id);
} }
Result ForceFreeObject(u32 object_id) { Result ForceFreeObject(u32 object_id) {
return this->manager->ForceFreeObject(object_id); return this->manager->ForceFreeObject(object_id);
} }
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
/* IDomainObject has no callable functions. */ /* IDomainObject has no callable functions. */
@ -94,36 +94,36 @@ static constexpr bool IsDomainObject(ServiceObjectHolder *holder) {
template <typename ServiceImpl> template <typename ServiceImpl>
class Out<std::shared_ptr<ServiceImpl>> : public OutSessionTag { class Out<std::shared_ptr<ServiceImpl>> : public OutSessionTag {
static_assert(std::is_base_of_v<IServiceObject, ServiceImpl>, "OutSessions must be shared_ptr<IServiceObject>!"); static_assert(std::is_base_of_v<IServiceObject, ServiceImpl>, "OutSessions must be shared_ptr<IServiceObject>!");
template<typename, typename> template<typename, typename>
friend class Out; friend class Out;
private: private:
std::shared_ptr<ServiceImpl> *srv; std::shared_ptr<ServiceImpl> *srv;
IDomainObject *domain = nullptr; IDomainObject *domain = nullptr;
u32 *object_id = nullptr; u32 *object_id = nullptr;
public: public:
Out<std::shared_ptr<ServiceImpl>>(std::shared_ptr<IServiceObject> *s, IDomainObject *dm, u32 *o) : srv(reinterpret_cast<std::shared_ptr<ServiceImpl> *>(s)), domain(dm), object_id(o) { } Out<std::shared_ptr<ServiceImpl>>(std::shared_ptr<IServiceObject> *s, IDomainObject *dm, u32 *o) : srv(reinterpret_cast<std::shared_ptr<ServiceImpl> *>(s)), domain(dm), object_id(o) { }
ServiceObjectHolder GetHolder() { ServiceObjectHolder GetHolder() {
std::shared_ptr<ServiceImpl> clone = *srv; std::shared_ptr<ServiceImpl> clone = *srv;
return ServiceObjectHolder(std::move(clone)); return ServiceObjectHolder(std::move(clone));
} }
bool IsDomain() { bool IsDomain() {
return domain != nullptr; return domain != nullptr;
} }
u32 GetObjectId() { u32 GetObjectId() {
return *object_id; return *object_id;
} }
void ChangeObjectId(u32 o) { void ChangeObjectId(u32 o) {
domain->ForceFreeObject(*object_id); domain->ForceFreeObject(*object_id);
domain->ReserveSpecificObject(o); domain->ReserveSpecificObject(o);
*object_id = o; *object_id = o;
} }
void SetValue(std::shared_ptr<ServiceImpl> &&s) { void SetValue(std::shared_ptr<ServiceImpl> &&s) {
*this->srv = std::move(s); *this->srv = std::move(s);
} }

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <type_traits> #include <type_traits>
@ -36,26 +36,26 @@ template <typename T>
class Out<T, typename std::enable_if<std::is_trivial<T>::value || AllowedOut<T>::value>::type> : public OutDataTag { class Out<T, typename std::enable_if<std::is_trivial<T>::value || AllowedOut<T>::value>::type> : public OutDataTag {
private: private:
T *obj; T *obj;
public: public:
Out(T *o) : obj(o) { } Out(T *o) : obj(o) { }
void SetValue(const T& t) { void SetValue(const T& t) {
*obj = t; *obj = t;
} }
const T& GetValue() { const T& GetValue() {
return *obj; return *obj;
} }
T *GetPointer() { T *GetPointer() {
return obj; return obj;
} }
/* Convenience operators. */ /* Convenience operators. */
T& operator*() { T& operator*() {
return *obj; return *obj;
} }
T* operator->() { T* operator->() {
return obj; return obj;
} }

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <memory> #include <memory>
@ -39,7 +39,7 @@ class IServiceObject {
}; };
#define SERVICE_DISPATCH_TABLE_NAME s_DispatchTable #define SERVICE_DISPATCH_TABLE_NAME s_DispatchTable
#define DEFINE_SERVICE_DISPATCH_TABLE static constexpr ServiceCommandMeta SERVICE_DISPATCH_TABLE_NAME[] #define DEFINE_SERVICE_DISPATCH_TABLE static constexpr ServiceCommandMeta SERVICE_DISPATCH_TABLE_NAME[]
template <typename T> template <typename T>
static constexpr size_t DispatchTableEntryCount() { static constexpr size_t DispatchTableEntryCount() {
@ -63,7 +63,7 @@ class ServiceObjectHolder {
std::shared_ptr<IServiceObject> srv; std::shared_ptr<IServiceObject> srv;
const ServiceCommandMeta *dispatch_table; const ServiceCommandMeta *dispatch_table;
size_t entry_count; size_t entry_count;
/* Private copy constructor. */ /* Private copy constructor. */
ServiceObjectHolder(const ServiceObjectHolder& other) : srv(other.srv), dispatch_table(other.dispatch_table), entry_count(other.entry_count) { } ServiceObjectHolder(const ServiceObjectHolder& other) : srv(other.srv), dispatch_table(other.dispatch_table), entry_count(other.entry_count) { }
ServiceObjectHolder& operator=(const ServiceObjectHolder& other); ServiceObjectHolder& operator=(const ServiceObjectHolder& other);
@ -71,7 +71,7 @@ class ServiceObjectHolder {
/* Templated constructor ensures correct type id at runtime. */ /* Templated constructor ensures correct type id at runtime. */
template <typename ServiceImpl> template <typename ServiceImpl>
explicit ServiceObjectHolder(std::shared_ptr<ServiceImpl>&& s) : srv(std::move(s)), dispatch_table(DispatchTable<ServiceImpl>()), entry_count(DispatchTableEntryCount<ServiceImpl>()) { } explicit ServiceObjectHolder(std::shared_ptr<ServiceImpl>&& s) : srv(std::move(s)), dispatch_table(DispatchTable<ServiceImpl>()), entry_count(DispatchTableEntryCount<ServiceImpl>()) { }
template <typename ServiceImpl> template <typename ServiceImpl>
ServiceImpl *GetServiceObject() const { ServiceImpl *GetServiceObject() const {
if (GetServiceId() == ServiceObjectId<ServiceImpl>()) { if (GetServiceId() == ServiceObjectId<ServiceImpl>()) {
@ -79,33 +79,33 @@ class ServiceObjectHolder {
} }
return nullptr; return nullptr;
} }
template<typename ServiceImpl> template<typename ServiceImpl>
ServiceImpl *GetServiceObjectUnsafe() const { ServiceImpl *GetServiceObjectUnsafe() const {
return static_cast<ServiceImpl *>(this->srv.get()); return static_cast<ServiceImpl *>(this->srv.get());
} }
const ServiceCommandMeta *GetDispatchTable() const { const ServiceCommandMeta *GetDispatchTable() const {
return this->dispatch_table; return this->dispatch_table;
} }
size_t GetDispatchTableEntryCount() const { size_t GetDispatchTableEntryCount() const {
return this->entry_count; return this->entry_count;
} }
constexpr uintptr_t GetServiceId() const { constexpr uintptr_t GetServiceId() const {
return reinterpret_cast<uintptr_t>(this->dispatch_table); return reinterpret_cast<uintptr_t>(this->dispatch_table);
} }
bool IsMitmObject() const { bool IsMitmObject() const {
return this->srv->IsMitmObject(); return this->srv->IsMitmObject();
} }
/* Default constructor, move constructor, move assignment operator. */ /* Default constructor, move constructor, move assignment operator. */
ServiceObjectHolder() : srv(nullptr), dispatch_table(nullptr) { } ServiceObjectHolder() : srv(nullptr), dispatch_table(nullptr) { }
ServiceObjectHolder(ServiceObjectHolder&& other) : srv(std::move(other.srv)), dispatch_table(std::move(other.dispatch_table)), entry_count(std::move(other.entry_count)) { } ServiceObjectHolder(ServiceObjectHolder&& other) : srv(std::move(other.srv)), dispatch_table(std::move(other.dispatch_table)), entry_count(std::move(other.entry_count)) { }
ServiceObjectHolder& operator=(ServiceObjectHolder&& other) { ServiceObjectHolder& operator=(ServiceObjectHolder&& other) {
this->srv = other.srv; this->srv = other.srv;
this->dispatch_table = other.dispatch_table; this->dispatch_table = other.dispatch_table;
@ -113,21 +113,21 @@ class ServiceObjectHolder {
other.Reset(); other.Reset();
return *this; return *this;
} }
explicit operator bool() const { explicit operator bool() const {
return this->srv != nullptr; return this->srv != nullptr;
} }
bool operator!() const { bool operator!() const {
return this->srv == nullptr; return this->srv == nullptr;
} }
void Reset() { void Reset() {
this->srv.reset(); this->srv.reset();
this->dispatch_table = nullptr; this->dispatch_table = nullptr;
this->entry_count = 0; this->entry_count = 0;
} }
ServiceObjectHolder Clone() const { ServiceObjectHolder Clone() const {
ServiceObjectHolder clone(*this); ServiceObjectHolder clone(*this);
return clone; return clone;

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <atomic> #include <atomic>
@ -23,10 +23,10 @@
class SessionManagerBase : public WaitableManagerBase, public DomainManager { class SessionManagerBase : public WaitableManagerBase, public DomainManager {
public: public:
SessionManagerBase() = default; SessionManagerBase() = default;
virtual ~SessionManagerBase() = default; virtual ~SessionManagerBase() = default;
virtual void AddSession(Handle server_h, ServiceObjectHolder &&service) = 0; virtual void AddSession(Handle server_h, ServiceObjectHolder &&service) = 0;
static Result CreateSessionHandles(Handle *server_h, Handle *client_h) { static Result CreateSessionHandles(Handle *server_h, Handle *client_h) {
return svcCreateSession(server_h, client_h, 0, 0); return svcCreateSession(server_h, client_h, 0, 0);
} }

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <type_traits> #include <type_traits>
@ -25,11 +25,11 @@ struct PidDescriptorTag{};
struct PidDescriptor : public PidDescriptorTag { struct PidDescriptor : public PidDescriptorTag {
u64 pid; u64 pid;
void operator=(u64 &p) { void operator=(u64 &p) {
pid = p; pid = p;
} }
PidDescriptor(u64 p) : pid(p) { } PidDescriptor(u64 p) : pid(p) { }
}; };
@ -44,12 +44,12 @@ struct MovedHandle : public IpcHandle {
void operator=(const Handle &h) { void operator=(const Handle &h) {
this->handle = h; this->handle = h;
} }
void operator=(const IpcHandle &o) { void operator=(const IpcHandle &o) {
this->handle = o.handle; this->handle = o.handle;
} }
MovedHandle(Handle h) { MovedHandle(Handle h) {
this->handle = h; this->handle = h;
} }
}; };
@ -59,12 +59,12 @@ struct CopiedHandle : public IpcHandle {
void operator=(const Handle &h) { void operator=(const Handle &h) {
handle = h; handle = h;
} }
void operator=(const IpcHandle &o) { void operator=(const IpcHandle &o) {
this->handle = o.handle; this->handle = o.handle;
} }
CopiedHandle(Handle h) { CopiedHandle(Handle h) {
this->handle = h; this->handle = h;
} }
}; };
@ -73,34 +73,34 @@ template <>
class Out<MovedHandle> : public OutHandleTag { class Out<MovedHandle> : public OutHandleTag {
private: private:
MovedHandle *obj; MovedHandle *obj;
public: public:
Out(IpcHandle *o) : obj(static_cast<MovedHandle *>(o)) { } Out(IpcHandle *o) : obj(static_cast<MovedHandle *>(o)) { }
void SetValue(const Handle& h) { void SetValue(const Handle& h) {
*obj = h; *obj = h;
} }
void SetValue(const MovedHandle& o) { void SetValue(const MovedHandle& o) {
*obj = o; *obj = o;
} }
const MovedHandle& GetValue() { const MovedHandle& GetValue() {
return *obj; return *obj;
} }
MovedHandle* GetPointer() { MovedHandle* GetPointer() {
return obj; return obj;
} }
Handle* GetHandlePointer() { Handle* GetHandlePointer() {
return &obj->handle; return &obj->handle;
} }
/* Convenience operators. */ /* Convenience operators. */
MovedHandle& operator*() { MovedHandle& operator*() {
return *obj; return *obj;
} }
MovedHandle* operator->() { MovedHandle* operator->() {
return obj; return obj;
} }
@ -110,34 +110,34 @@ template <>
class Out<CopiedHandle> : public OutHandleTag { class Out<CopiedHandle> : public OutHandleTag {
private: private:
CopiedHandle *obj; CopiedHandle *obj;
public: public:
Out(IpcHandle *o) : obj(static_cast<CopiedHandle *>(o)) { } Out(IpcHandle *o) : obj(static_cast<CopiedHandle *>(o)) { }
void SetValue(const Handle& h) { void SetValue(const Handle& h) {
*obj = h; *obj = h;
} }
void SetValue(const CopiedHandle& o) { void SetValue(const CopiedHandle& o) {
*obj = o; *obj = o;
} }
const CopiedHandle& GetValue() { const CopiedHandle& GetValue() {
return *obj; return *obj;
} }
CopiedHandle* GetPointer() { CopiedHandle* GetPointer() {
return obj; return obj;
} }
Handle* GetHandlePointer() { Handle* GetHandlePointer() {
return &obj->handle; return &obj->handle;
} }
/* Convenience operators. */ /* Convenience operators. */
CopiedHandle& operator*() { CopiedHandle& operator*() {
return *obj; return *obj;
} }
CopiedHandle* operator->() { CopiedHandle* operator->() {
return obj; return obj;
} }

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
@ -31,46 +31,46 @@ class IWaitable {
bool is_signaled = false; bool is_signaled = false;
public: public:
virtual ~IWaitable() = default; virtual ~IWaitable() = default;
virtual Result HandleDeferred() { virtual Result HandleDeferred() {
/* By default, HandleDeferred panics, because object shouldn't be deferrable. */ /* By default, HandleDeferred panics, because object shouldn't be deferrable. */
std::abort(); std::abort();
} }
bool IsSignaled() { bool IsSignaled() {
std::scoped_lock<HosMutex> lock(this->sig_lock); std::scoped_lock<HosMutex> lock(this->sig_lock);
return this->is_signaled; return this->is_signaled;
} }
virtual Handle GetHandle() = 0; virtual Handle GetHandle() = 0;
virtual Result HandleSignaled(u64 timeout) = 0; virtual Result HandleSignaled(u64 timeout) = 0;
WaitableManagerBase *GetManager() { WaitableManagerBase *GetManager() {
return this->manager; return this->manager;
} }
void SetManager(WaitableManagerBase *m) { void SetManager(WaitableManagerBase *m) {
this->manager = m; this->manager = m;
} }
void UpdatePriority() { void UpdatePriority() {
if (manager) { if (manager) {
this->wait_priority = this->manager->GetNextPriority(); this->wait_priority = this->manager->GetNextPriority();
} }
} }
bool IsDeferred() { bool IsDeferred() {
return this->is_deferred; return this->is_deferred;
} }
void SetDeferred(bool d) { void SetDeferred(bool d) {
this->is_deferred = d; this->is_deferred = d;
} }
static bool Compare(IWaitable *a, IWaitable *b) { static bool Compare(IWaitable *a, IWaitable *b) {
return (a->wait_priority < b->wait_priority) && !a->IsDeferred() && (a->GetHandle() != INVALID_HANDLE); return (a->wait_priority < b->wait_priority) && !a->IsDeferred() && (a->GetHandle() != INVALID_HANDLE);
} }
void NotifyManagerSignaled() { void NotifyManagerSignaled() {
if (this->manager) { if (this->manager) {
this->manager->NotifySignaled(this); this->manager->NotifySignaled(this);

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include "hossynch.hpp" #include "hossynch.hpp"
@ -26,31 +26,31 @@ class HosMessageQueue {
HosCondVar cv_not_empty; HosCondVar cv_not_empty;
std::unique_ptr<uintptr_t[]> buffer; std::unique_ptr<uintptr_t[]> buffer;
size_t capacity; size_t capacity;
size_t count = 0; size_t count = 0;
size_t offset = 0; size_t offset = 0;
public: public:
HosMessageQueue(size_t c) : capacity(c) { HosMessageQueue(size_t c) : capacity(c) {
this->buffer = std::make_unique<uintptr_t[]>(this->capacity); this->buffer = std::make_unique<uintptr_t[]>(this->capacity);
} }
HosMessageQueue(std::unique_ptr<uintptr_t[]> buf, size_t c) : buffer(std::move(buf)), capacity(c) { } HosMessageQueue(std::unique_ptr<uintptr_t[]> buf, size_t c) : buffer(std::move(buf)), capacity(c) { }
/* Sending (FIFO functionality) */ /* Sending (FIFO functionality) */
void Send(uintptr_t data); void Send(uintptr_t data);
bool TrySend(uintptr_t data); bool TrySend(uintptr_t data);
bool TimedSend(uintptr_t data, u64 timeout); bool TimedSend(uintptr_t data, u64 timeout);
/* Sending (LIFO functionality) */ /* Sending (LIFO functionality) */
void SendNext(uintptr_t data); void SendNext(uintptr_t data);
bool TrySendNext(uintptr_t data); bool TrySendNext(uintptr_t data);
bool TimedSendNext(uintptr_t data, u64 timeout); bool TimedSendNext(uintptr_t data, u64 timeout);
/* Receive functionality */ /* Receive functionality */
void Receive(uintptr_t *out); void Receive(uintptr_t *out);
bool TryReceive(uintptr_t *out); bool TryReceive(uintptr_t *out);
bool TimedReceive(uintptr_t *out, u64 timeout); bool TimedReceive(uintptr_t *out, u64 timeout);
/* Peek functionality */ /* Peek functionality */
void Peek(uintptr_t *out); void Peek(uintptr_t *out);
bool TryPeek(uintptr_t *out); bool TryPeek(uintptr_t *out);
@ -59,11 +59,11 @@ class HosMessageQueue {
bool IsFull() { bool IsFull() {
return this->count >= this->capacity; return this->count >= this->capacity;
} }
bool IsEmpty() { bool IsEmpty() {
return this->count == 0; return this->count == 0;
} }
void SendInternal(uintptr_t data); void SendInternal(uintptr_t data);
void SendNextInternal(uintptr_t data); void SendNextInternal(uintptr_t data);
uintptr_t ReceiveInternal(); uintptr_t ReceiveInternal();

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "mitm/sm_mitm.h" #include "mitm/sm_mitm.h"

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <atomic> #include <atomic>
@ -30,19 +30,19 @@ class IMitmServiceObject : public IServiceObject {
IMitmServiceObject(std::shared_ptr<Service> s, u64 pid) : forward_service(s), process_id(pid) { IMitmServiceObject(std::shared_ptr<Service> s, u64 pid) : forward_service(s), process_id(pid) {
MitmQueryUtils::GetAssociatedTidForPid(this->process_id, &this->title_id); MitmQueryUtils::GetAssociatedTidForPid(this->process_id, &this->title_id);
} }
virtual u64 GetTitleId() { virtual u64 GetTitleId() {
return this->title_id; return this->title_id;
} }
virtual u64 GetProcessId() { virtual u64 GetProcessId() {
return this->process_id; return this->process_id;
} }
virtual bool IsMitmObject() const override { return true; } virtual bool IsMitmObject() const override { return true; }
static bool ShouldMitm(u64 pid, u64 tid); static bool ShouldMitm(u64 pid, u64 tid);
protected: protected:
virtual ~IMitmServiceObject() = default; virtual ~IMitmServiceObject() = default;
}; };

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
@ -26,7 +26,7 @@ enum MitmQueryServiceCommand {
namespace MitmQueryUtils { namespace MitmQueryUtils {
Result GetAssociatedTidForPid(u64 pid, u64 *tid); Result GetAssociatedTidForPid(u64 pid, u64 *tid);
void AssociatePidToTid(u64 pid, u64 tid); void AssociatePidToTid(u64 pid, u64 tid);
} }
template <typename T> template <typename T>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include <cstdlib> #include <cstdlib>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
/* Utilities. */ /* Utilities. */

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "ipc.hpp" #include "ipc.hpp"

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <switch.h> #include <switch.h>
@ -25,23 +25,23 @@ static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u
if (R_FAILED(SmcGetConfig((SplConfigItem)65000, &exosphere_cfg))) { if (R_FAILED(SmcGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
fatalSimple(ResultAtmosphereExosphereNotPresent); fatalSimple(ResultAtmosphereExosphereNotPresent);
} }
if (mkey_rev) { if (mkey_rev) {
*mkey_rev = (u32)((exosphere_cfg >> 0x00) & 0xFF); *mkey_rev = (u32)((exosphere_cfg >> 0x00) & 0xFF);
} }
if (target_fw) { if (target_fw) {
*target_fw = (u32)((exosphere_cfg >> 0x08) & 0xFF); *target_fw = (u32)((exosphere_cfg >> 0x08) & 0xFF);
} }
if (micro) { if (micro) {
*micro = (u32)((exosphere_cfg >> 0x10) & 0xFF); *micro = (u32)((exosphere_cfg >> 0x10) & 0xFF);
} }
if (minor) { if (minor) {
*minor = (u32)((exosphere_cfg >> 0x18) & 0xFF); *minor = (u32)((exosphere_cfg >> 0x18) & 0xFF);
} }
if (major) { if (major) {
*major = (u32)((exosphere_cfg >> 0x20) & 0xFF); *major = (u32)((exosphere_cfg >> 0x20) & 0xFF);
} }
@ -54,7 +54,7 @@ static inline u32 MakeAtmosphereVersion(u32 major, u32 minor, u32 micro) {
static inline void CheckAtmosphereVersion(u32 expected_major, u32 expected_minor, u32 expected_micro) { static inline void CheckAtmosphereVersion(u32 expected_major, u32 expected_minor, u32 expected_micro) {
u32 major, minor, micro; u32 major, minor, micro;
GetAtmosphereApiVersion(&major, &minor, &micro, nullptr, nullptr); GetAtmosphereApiVersion(&major, &minor, &micro, nullptr, nullptr);
if (MakeAtmosphereVersion(major, minor, micro) < MakeAtmosphereVersion(expected_major, expected_minor, expected_micro)) { if (MakeAtmosphereVersion(major, minor, micro) < MakeAtmosphereVersion(expected_major, expected_minor, expected_micro)) {
fatalSimple(ResultAtmosphereVersionMismatch); fatalSimple(ResultAtmosphereVersionMismatch);
} }

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <atomic> #include <atomic>
@ -28,11 +28,11 @@ class WaitableManagerBase {
u64 GetNextPriority() { u64 GetNextPriority() {
return std::atomic_fetch_add(&cur_priority, (u64)1); return std::atomic_fetch_add(&cur_priority, (u64)1);
} }
virtual void AddWaitable(IWaitable *w) = 0; virtual void AddWaitable(IWaitable *w) = 0;
virtual void NotifySignaled(IWaitable *w) = 0; virtual void NotifySignaled(IWaitable *w) = 0;
virtual void RequestStop() = 0; virtual void RequestStop() = 0;
virtual void Process() = 0; virtual void Process() = 0;
}; };

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <switch.h> #include <switch.h>
#include <switch/arm/atomics.h> #include <switch/arm/atomics.h>
#include <stratosphere/services/bpc_ams.h> #include <stratosphere/services/bpc_ams.h>
@ -39,19 +39,19 @@ Result bpcAmsInitialize(void) {
void bpcAmsExit(void) { void bpcAmsExit(void) {
if (atomicDecrement64(&g_bpcAmsAmsRefcnt) == 0) if (atomicDecrement64(&g_bpcAmsAmsRefcnt) == 0)
serviceClose(&g_bpcAmsSrv); serviceClose(&g_bpcAmsSrv);
} }
Result bpcAmsRebootToFatalError(AtmosphereFatalErrorContext *ctx) { Result bpcAmsRebootToFatalError(AtmosphereFatalErrorContext *ctx) {
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
ipcAddSendBuffer(&c, ctx, sizeof(*ctx), BufferType_Normal); ipcAddSendBuffer(&c, ctx, sizeof(*ctx), BufferType_Normal);
struct { struct {
u64 magic; u64 magic;
u64 cmd_id; u64 cmd_id;
} *raw; } *raw;
raw = serviceIpcPrepareHeader(&g_bpcAmsSrv, &c, sizeof(*raw)); raw = serviceIpcPrepareHeader(&g_bpcAmsSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC; raw->magic = SFCI_MAGIC;

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <switch.h> #include <switch.h>
#include <switch/arm/atomics.h> #include <switch/arm/atomics.h>
#include <stratosphere/services/dmntcht.h> #include <stratosphere/services/dmntcht.h>

View File

@ -13,20 +13,20 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <mutex> #include <mutex>
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
void HosMessageQueue::Send(uintptr_t data) { void HosMessageQueue::Send(uintptr_t data) {
/* Acquire mutex, wait sendable. */ /* Acquire mutex, wait sendable. */
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
while (this->IsFull()) { while (this->IsFull()) {
this->cv_not_full.Wait(&this->queue_lock); this->cv_not_full.Wait(&this->queue_lock);
} }
/* Send, signal. */ /* Send, signal. */
this->SendInternal(data); this->SendInternal(data);
this->cv_not_empty.WakeAll(); this->cv_not_empty.WakeAll();
@ -37,7 +37,7 @@ bool HosMessageQueue::TrySend(uintptr_t data) {
if (this->IsFull()) { if (this->IsFull()) {
return false; return false;
} }
/* Send, signal. */ /* Send, signal. */
this->SendInternal(data); this->SendInternal(data);
this->cv_not_empty.WakeAll(); this->cv_not_empty.WakeAll();
@ -47,15 +47,15 @@ bool HosMessageQueue::TrySend(uintptr_t data) {
bool HosMessageQueue::TimedSend(uintptr_t data, u64 timeout) { bool HosMessageQueue::TimedSend(uintptr_t data, u64 timeout) {
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
TimeoutHelper timeout_helper(timeout); TimeoutHelper timeout_helper(timeout);
while (this->IsFull()) { while (this->IsFull()) {
if (timeout_helper.TimedOut()) { if (timeout_helper.TimedOut()) {
return false; return false;
} }
this->cv_not_full.TimedWait(timeout, &this->queue_lock); this->cv_not_full.TimedWait(timeout, &this->queue_lock);
} }
/* Send, signal. */ /* Send, signal. */
this->SendInternal(data); this->SendInternal(data);
this->cv_not_empty.WakeAll(); this->cv_not_empty.WakeAll();
@ -65,11 +65,11 @@ bool HosMessageQueue::TimedSend(uintptr_t data, u64 timeout) {
void HosMessageQueue::SendNext(uintptr_t data) { void HosMessageQueue::SendNext(uintptr_t data) {
/* Acquire mutex, wait sendable. */ /* Acquire mutex, wait sendable. */
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
while (this->IsFull()) { while (this->IsFull()) {
this->cv_not_full.Wait(&this->queue_lock); this->cv_not_full.Wait(&this->queue_lock);
} }
/* Send, signal. */ /* Send, signal. */
this->SendNextInternal(data); this->SendNextInternal(data);
this->cv_not_empty.WakeAll(); this->cv_not_empty.WakeAll();
@ -80,7 +80,7 @@ bool HosMessageQueue::TrySendNext(uintptr_t data) {
if (this->IsFull()) { if (this->IsFull()) {
return false; return false;
} }
/* Send, signal. */ /* Send, signal. */
this->SendNextInternal(data); this->SendNextInternal(data);
this->cv_not_empty.WakeAll(); this->cv_not_empty.WakeAll();
@ -90,15 +90,15 @@ bool HosMessageQueue::TrySendNext(uintptr_t data) {
bool HosMessageQueue::TimedSendNext(uintptr_t data, u64 timeout) { bool HosMessageQueue::TimedSendNext(uintptr_t data, u64 timeout) {
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
TimeoutHelper timeout_helper(timeout); TimeoutHelper timeout_helper(timeout);
while (this->IsFull()) { while (this->IsFull()) {
if (timeout_helper.TimedOut()) { if (timeout_helper.TimedOut()) {
return false; return false;
} }
this->cv_not_full.TimedWait(timeout, &this->queue_lock); this->cv_not_full.TimedWait(timeout, &this->queue_lock);
} }
/* Send, signal. */ /* Send, signal. */
this->SendNextInternal(data); this->SendNextInternal(data);
this->cv_not_empty.WakeAll(); this->cv_not_empty.WakeAll();
@ -108,11 +108,11 @@ bool HosMessageQueue::TimedSendNext(uintptr_t data, u64 timeout) {
void HosMessageQueue::Receive(uintptr_t *out) { void HosMessageQueue::Receive(uintptr_t *out) {
/* Acquire mutex, wait receivable. */ /* Acquire mutex, wait receivable. */
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
while (this->IsEmpty()) { while (this->IsEmpty()) {
this->cv_not_empty.Wait(&this->queue_lock); this->cv_not_empty.Wait(&this->queue_lock);
} }
/* Receive, signal. */ /* Receive, signal. */
*out = this->ReceiveInternal(); *out = this->ReceiveInternal();
this->cv_not_full.WakeAll(); this->cv_not_full.WakeAll();
@ -120,11 +120,11 @@ void HosMessageQueue::Receive(uintptr_t *out) {
bool HosMessageQueue::TryReceive(uintptr_t *out) { bool HosMessageQueue::TryReceive(uintptr_t *out) {
/* Acquire mutex, wait receivable. */ /* Acquire mutex, wait receivable. */
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
if (this->IsEmpty()) { if (this->IsEmpty()) {
return false; return false;
} }
/* Receive, signal. */ /* Receive, signal. */
*out = this->ReceiveInternal(); *out = this->ReceiveInternal();
this->cv_not_full.WakeAll(); this->cv_not_full.WakeAll();
@ -134,15 +134,15 @@ bool HosMessageQueue::TryReceive(uintptr_t *out) {
bool HosMessageQueue::TimedReceive(uintptr_t *out, u64 timeout) { bool HosMessageQueue::TimedReceive(uintptr_t *out, u64 timeout) {
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
TimeoutHelper timeout_helper(timeout); TimeoutHelper timeout_helper(timeout);
while (this->IsEmpty()) { while (this->IsEmpty()) {
if (timeout_helper.TimedOut()) { if (timeout_helper.TimedOut()) {
return false; return false;
} }
this->cv_not_empty.TimedWait(timeout, &this->queue_lock); this->cv_not_empty.TimedWait(timeout, &this->queue_lock);
} }
/* Receive, signal. */ /* Receive, signal. */
*out = this->ReceiveInternal(); *out = this->ReceiveInternal();
this->cv_not_full.WakeAll(); this->cv_not_full.WakeAll();
@ -152,11 +152,11 @@ bool HosMessageQueue::TimedReceive(uintptr_t *out, u64 timeout) {
void HosMessageQueue::Peek(uintptr_t *out) { void HosMessageQueue::Peek(uintptr_t *out) {
/* Acquire mutex, wait receivable. */ /* Acquire mutex, wait receivable. */
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
while (this->IsEmpty()) { while (this->IsEmpty()) {
this->cv_not_empty.Wait(&this->queue_lock); this->cv_not_empty.Wait(&this->queue_lock);
} }
/* Peek. */ /* Peek. */
*out = this->PeekInternal(); *out = this->PeekInternal();
} }
@ -164,11 +164,11 @@ void HosMessageQueue::Peek(uintptr_t *out) {
bool HosMessageQueue::TryPeek(uintptr_t *out) { bool HosMessageQueue::TryPeek(uintptr_t *out) {
/* Acquire mutex, wait receivable. */ /* Acquire mutex, wait receivable. */
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
if (this->IsEmpty()) { if (this->IsEmpty()) {
return false; return false;
} }
/* Peek. */ /* Peek. */
*out = this->PeekInternal(); *out = this->PeekInternal();
return true; return true;
@ -177,15 +177,15 @@ bool HosMessageQueue::TryPeek(uintptr_t *out) {
bool HosMessageQueue::TimedPeek(uintptr_t *out, u64 timeout) { bool HosMessageQueue::TimedPeek(uintptr_t *out, u64 timeout) {
std::scoped_lock<HosMutex> lock(this->queue_lock); std::scoped_lock<HosMutex> lock(this->queue_lock);
TimeoutHelper timeout_helper(timeout); TimeoutHelper timeout_helper(timeout);
while (this->IsEmpty()) { while (this->IsEmpty()) {
if (timeout_helper.TimedOut()) { if (timeout_helper.TimedOut()) {
return false; return false;
} }
this->cv_not_empty.TimedWait(timeout, &this->queue_lock); this->cv_not_empty.TimedWait(timeout, &this->queue_lock);
} }
/* Peek. */ /* Peek. */
*out = this->PeekInternal(); *out = this->PeekInternal();
return true; return true;
@ -196,7 +196,7 @@ void HosMessageQueue::SendInternal(uintptr_t data) {
if (this->count >= this->capacity) { if (this->count >= this->capacity) {
std::abort(); std::abort();
} }
/* Write data to tail of queue. */ /* Write data to tail of queue. */
this->buffer[(this->count++ + this->offset) % this->capacity] = data; this->buffer[(this->count++ + this->offset) % this->capacity] = data;
} }
@ -206,7 +206,7 @@ void HosMessageQueue::SendNextInternal(uintptr_t data) {
if (this->count >= this->capacity) { if (this->count >= this->capacity) {
std::abort(); std::abort();
} }
/* Write data to head of queue. */ /* Write data to head of queue. */
this->offset = (this->offset + this->capacity - 1) % this->capacity; this->offset = (this->offset + this->capacity - 1) % this->capacity;
this->buffer[this->offset] = data; this->buffer[this->offset] = data;
@ -218,7 +218,7 @@ uintptr_t HosMessageQueue::ReceiveInternal() {
if (this->count == 0) { if (this->count == 0) {
std::abort(); std::abort();
} }
uintptr_t data = this->buffer[this->offset]; uintptr_t data = this->buffer[this->offset];
this->offset = (this->offset + 1) % this->capacity; this->offset = (this->offset + 1) % this->capacity;
this->count--; this->count--;
@ -230,6 +230,6 @@ uintptr_t HosMessageQueue::PeekInternal() {
if (this->count == 0) { if (this->count == 0) {
std::abort(); std::abort();
} }
return this->buffer[this->offset]; return this->buffer[this->offset];
} }

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <switch.h> #include <switch.h>
#include <switch/arm/atomics.h> #include <switch/arm/atomics.h>
#include <stratosphere/mitm/sm_mitm.h> #include <stratosphere/mitm/sm_mitm.h>

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <switch.h> #include <switch.h>
#include <switch/arm/atomics.h> #include <switch/arm/atomics.h>
#include <stratosphere/services/smm_ams.h> #include <stratosphere/services/smm_ams.h>
@ -32,13 +32,13 @@ Result smManagerAmsInitialize(void) {
void smManagerAmsExit(void) { void smManagerAmsExit(void) {
if (atomicDecrement64(&g_smManagerAmsRefcnt) == 0) if (atomicDecrement64(&g_smManagerAmsRefcnt) == 0)
serviceClose(&g_smManagerAmsSrv); serviceClose(&g_smManagerAmsSrv);
} }
Result smManagerAmsEndInitialDefers(void) { Result smManagerAmsEndInitialDefers(void) {
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
struct { struct {
u64 magic; u64 magic;
u64 cmd_id; u64 cmd_id;
@ -48,22 +48,22 @@ Result smManagerAmsEndInitialDefers(void) {
raw->magic = SFCI_MAGIC; raw->magic = SFCI_MAGIC;
raw->cmd_id = 65000; raw->cmd_id = 65000;
Result rc = serviceIpcDispatch(&g_smManagerAmsSrv); Result rc = serviceIpcDispatch(&g_smManagerAmsSrv);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
IpcParsedCommand r; IpcParsedCommand r;
struct { struct {
u64 magic; u64 magic;
u64 result; u64 result;
} *resp; } *resp;
serviceIpcParse(&g_smManagerAmsSrv, &r, sizeof(*resp)); serviceIpcParse(&g_smManagerAmsSrv, &r, sizeof(*resp));
resp = r.Raw; resp = r.Raw;
rc = resp->result; rc = resp->result;
} }
return rc; return rc;
} }
@ -71,7 +71,7 @@ Result smManagerAmsEndInitialDefers(void) {
Result smManagerAmsHasMitm(bool *out, const char* name) { Result smManagerAmsHasMitm(bool *out, const char* name) {
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
struct { struct {
u64 magic; u64 magic;
u64 cmd_id; u64 cmd_id;
@ -82,9 +82,9 @@ Result smManagerAmsHasMitm(bool *out, const char* name) {
raw->magic = SFCI_MAGIC; raw->magic = SFCI_MAGIC;
raw->cmd_id = 65001; raw->cmd_id = 65001;
raw->service_name = smEncodeName(name); raw->service_name = smEncodeName(name);
Result rc = serviceIpcDispatch(&g_smManagerAmsSrv); Result rc = serviceIpcDispatch(&g_smManagerAmsSrv);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
IpcParsedCommand r; IpcParsedCommand r;
struct { struct {
@ -92,16 +92,16 @@ Result smManagerAmsHasMitm(bool *out, const char* name) {
u64 result; u64 result;
u8 has_mitm; u8 has_mitm;
} *resp; } *resp;
serviceIpcParse(&g_smManagerAmsSrv, &r, sizeof(*resp)); serviceIpcParse(&g_smManagerAmsSrv, &r, sizeof(*resp));
resp = r.Raw; resp = r.Raw;
rc = resp->result; rc = resp->result;
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
*out = resp->has_mitm != 0; *out = resp->has_mitm != 0;
} }
} }
return rc; return rc;
} }