namespace sts -> namespace ams

namespace sts::ams -> ams::exosphere, ams::.

This is to facilitate future use of ams:: namespace code in
mesosphere, as we'll want to include ams::util, ams::result, ams::svc...
This commit is contained in:
Michael Scire
2019-10-24 02:30:10 -07:00
committed by SciresM
parent 4059dc6187
commit 8cb77ac136
397 changed files with 968 additions and 926 deletions

View File

@@ -15,14 +15,14 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
ServerDomainManager::Domain::~Domain() {
while (!this->entries.empty()) {
Entry *entry = &this->entries.front();
{
std::scoped_lock lk(this->manager->entry_owner_lock);
STS_ASSERT(entry->owner == this);
AMS_ASSERT(entry->owner == this);
entry->owner = nullptr;
}
entry->object.Reset();
@@ -35,7 +35,7 @@ namespace sts::sf::cmif {
for (size_t i = 0; i < count; i++) {
Entry *entry = this->manager->entry_manager.AllocateEntry();
R_UNLESS(entry != nullptr, sf::cmif::ResultOutOfDomainEntries());
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry->owner == nullptr);
out_ids[i] = this->manager->entry_manager.GetId(entry);
}
return ResultSuccess();
@@ -48,18 +48,18 @@ namespace sts::sf::cmif {
void ServerDomainManager::Domain::UnreserveIds(const DomainObjectId *ids, size_t count) {
for (size_t i = 0; i < count; i++) {
Entry *entry = this->manager->entry_manager.GetEntry(ids[i]);
STS_ASSERT(entry != nullptr);
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry != nullptr);
AMS_ASSERT(entry->owner == nullptr);
this->manager->entry_manager.FreeEntry(entry);
}
}
void ServerDomainManager::Domain::RegisterObject(DomainObjectId id, ServiceObjectHolder &&obj) {
Entry *entry = this->manager->entry_manager.GetEntry(id);
STS_ASSERT(entry != nullptr);
AMS_ASSERT(entry != nullptr);
{
std::scoped_lock lk(this->manager->entry_owner_lock);
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry->owner == nullptr);
entry->owner = this;
this->entries.push_back(*entry);
}
@@ -129,8 +129,8 @@ namespace sts::sf::cmif {
void ServerDomainManager::EntryManager::FreeEntry(Entry *entry) {
std::scoped_lock lk(this->lock);
STS_ASSERT(entry->owner == nullptr);
STS_ASSERT(!entry->object);
AMS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(!entry->object);
this->free_list.push_front(*entry);
}
@@ -142,8 +142,8 @@ namespace sts::sf::cmif {
const auto id = ids[i];
Entry *entry = this->GetEntry(id);
if (id != InvalidDomainObjectId) {
STS_ASSERT(entry != nullptr);
STS_ASSERT(entry->owner == nullptr);
AMS_ASSERT(entry != nullptr);
AMS_ASSERT(entry->owner == nullptr);
this->free_list.erase(this->free_list.iterator_to(*entry));
}
}

View File

@@ -16,7 +16,7 @@
#include <functional>
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
Result DomainServiceObjectDispatchTable::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
return this->ProcessMessageImpl(ctx, static_cast<DomainServiceObject *>(ctx.srv_obj)->GetServerDomain(), in_raw_data);
@@ -133,7 +133,7 @@ namespace sts::sf::cmif {
/* Write out header. */
constexpr size_t out_header_size = sizeof(CmifDomainOutHeader);
const size_t impl_out_data_total_size = this->GetImplOutDataTotalSize();
STS_ASSERT(out_header_size + impl_out_data_total_size + sizeof(DomainObjectId) * this->GetOutObjectCount() <= raw_data.GetSize());
AMS_ASSERT(out_header_size + impl_out_data_total_size + sizeof(DomainObjectId) * this->GetOutObjectCount() <= raw_data.GetSize());
*reinterpret_cast<CmifDomainOutHeader *>(raw_data.GetPointer()) = CmifDomainOutHeader{ .num_out_objects = static_cast<u32>(this->GetOutObjectCount()), };
/* Set output raw data. */
@@ -151,7 +151,7 @@ namespace sts::sf::cmif {
/* Write out header. */
constexpr size_t out_header_size = sizeof(CmifDomainOutHeader);
const size_t impl_out_data_total_size = this->GetImplOutDataTotalSize();
STS_ASSERT(out_header_size + impl_out_data_total_size <= raw_data.GetSize());
AMS_ASSERT(out_header_size + impl_out_data_total_size <= raw_data.GetSize());
*reinterpret_cast<CmifDomainOutHeader *>(raw_data.GetPointer()) = CmifDomainOutHeader{ .num_out_objects = 0, };
/* Set output raw data. */

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
Result impl::ServiceDispatchTableBase::ProcessMessageImpl(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const ServiceCommandMeta *entries, const size_t entry_count) const {
/* Get versioning info. */
@@ -46,7 +46,7 @@ namespace sts::sf::cmif {
/* Forward forwardable results, otherwise ensure we can send result to user. */
R_TRY_CATCH(command_result) {
R_CATCH(sf::impl::ResultRequestContextChanged) { return R_CURRENT_RESULT; }
R_CATCH_ALL() { STS_ASSERT(out_header != nullptr); }
R_CATCH_ALL() { AMS_ASSERT(out_header != nullptr); }
} R_END_TRY_CATCH;
/* Write output header to raw data. */
@@ -89,11 +89,11 @@ namespace sts::sf::cmif {
/* Forward forwardable results, otherwise ensure we can send result to user. */
R_TRY_CATCH(command_result) {
R_CATCH(ams::mitm::ResultShouldForwardToSession) {
R_CATCH(sm::mitm::ResultShouldForwardToSession) {
return ctx.session->ForwardRequest(ctx);
}
R_CATCH(sf::impl::ResultRequestContextChanged) { return R_CURRENT_RESULT; }
R_CATCH_ALL() { STS_ASSERT(out_header != nullptr); }
R_CATCH_ALL() { AMS_ASSERT(out_header != nullptr); }
} R_END_TRY_CATCH;
/* Write output header to raw data. */

View File

@@ -16,7 +16,7 @@
#include <functional>
#include <stratosphere.hpp>
namespace sts::sf::cmif {
namespace ams::sf::cmif {
Result ServiceObjectHolder::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const {
const auto ProcessHandler = this->dispatch_meta->ProcessHandler;

View File

@@ -15,14 +15,14 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
namespace {
NX_INLINE Result ReceiveImpl(Handle session_handle, void *message_buf, size_t message_buf_size) {
s32 unused_index;
if (message_buf == armGetTls()) {
/* Consider: STS_ASSERT(message_buf_size == TlsMessageBufferSize); */
/* Consider: AMS_ASSERT(message_buf_size == TlsMessageBufferSize); */
return svcReplyAndReceive(&unused_index, &session_handle, 1, INVALID_HANDLE, U64_MAX);
} else {
return svcReplyAndReceiveWithUserBuffer(&unused_index, message_buf, message_buf_size, &session_handle, 1, INVALID_HANDLE, U64_MAX);
@@ -32,7 +32,7 @@ namespace sts::sf::hipc {
NX_INLINE Result ReplyImpl(Handle session_handle, void *message_buf, size_t message_buf_size) {
s32 unused_index;
if (message_buf == armGetTls()) {
/* Consider: STS_ASSERT(message_buf_size == TlsMessageBufferSize); */
/* Consider: AMS_ASSERT(message_buf_size == TlsMessageBufferSize); */
return svcReplyAndReceive(&unused_index, &session_handle, 0, session_handle, 0);
} else {
return svcReplyAndReceiveWithUserBuffer(&unused_index, message_buf, message_buf_size, &session_handle, 0, session_handle, 0);
@@ -73,7 +73,7 @@ namespace sts::sf::hipc {
R_CONVERT(svc::ResultSessionClosed, ResultSuccess())
} R_END_TRY_CATCH;
/* ReplyImpl should *always* return an error. */
STS_ASSERT(false);
AMS_ASSERT(false);
}
Result CreateSession(Handle *out_server_handle, Handle *out_client_handle) {

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
namespace impl {
@@ -71,7 +71,7 @@ namespace sts::sf::hipc {
if (this->is_mitm_session) {
/* If we're a mitm session, we need to convert the remote session to domain. */
STS_ASSERT(session->forward_service->own_handle);
AMS_ASSERT(session->forward_service->own_handle);
R_TRY(serviceConvertToDomain(session->forward_service.get()));
/* The object ID reservation cannot fail here, as that would cause desynchronization from target domain. */
@@ -94,8 +94,8 @@ namespace sts::sf::hipc {
})));
}
STS_ASSERT(object_id != cmif::InvalidDomainObjectId);
STS_ASSERT(static_cast<bool>(new_holder));
AMS_ASSERT(object_id != cmif::InvalidDomainObjectId);
AMS_ASSERT(static_cast<bool>(new_holder));
/* We succeeded! */
domain_guard.Cancel();

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
ServerManagerBase::ServerBase::~ServerBase() { /* Pure virtual destructor, to prevent linker errors. */ }
@@ -65,14 +65,14 @@ namespace sts::sf::hipc {
void ServerManagerBase::AddUserWaitableHolder(os::WaitableHolder *waitable) {
const auto user_data_tag = static_cast<UserDataTag>(waitable->GetUserData());
STS_ASSERT(user_data_tag != UserDataTag::Server);
STS_ASSERT(user_data_tag != UserDataTag::MitmServer);
STS_ASSERT(user_data_tag != UserDataTag::Session);
AMS_ASSERT(user_data_tag != UserDataTag::Server);
AMS_ASSERT(user_data_tag != UserDataTag::MitmServer);
AMS_ASSERT(user_data_tag != UserDataTag::Session);
this->RegisterToWaitList(waitable);
}
Result ServerManagerBase::ProcessForServer(os::WaitableHolder *holder) {
STS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Server);
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Server);
ServerBase *server = static_cast<ServerBase *>(holder);
ON_SCOPE_EXIT { this->RegisterToWaitList(server); };
@@ -83,14 +83,14 @@ namespace sts::sf::hipc {
server->CreateSessionObjectHolder(&obj, &fsrv);
/* Not a mitm server, so we must have no forward service. */
STS_ASSERT(fsrv == nullptr);
AMS_ASSERT(fsrv == nullptr);
/* Try to accept. */
return this->AcceptSession(server->port_handle, std::move(obj));
}
Result ServerManagerBase::ProcessForMitmServer(os::WaitableHolder *holder) {
STS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::MitmServer);
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::MitmServer);
ServerBase *server = static_cast<ServerBase *>(holder);
ON_SCOPE_EXIT { this->RegisterToWaitList(server); };
@@ -101,20 +101,20 @@ namespace sts::sf::hipc {
server->CreateSessionObjectHolder(&obj, &fsrv);
/* Mitm server, so we must have forward service. */
STS_ASSERT(fsrv != nullptr);
AMS_ASSERT(fsrv != nullptr);
/* Try to accept. */
return this->AcceptMitmSession(server->port_handle, std::move(obj), std::move(fsrv));
}
Result ServerManagerBase::ProcessForSession(os::WaitableHolder *holder) {
STS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Session);
AMS_ASSERT(static_cast<UserDataTag>(holder->GetUserData()) == UserDataTag::Session);
ServerSession *session = static_cast<ServerSession *>(holder);
cmif::PointerAndSize tls_message(armGetTls(), hipc::TlsMessageBufferSize);
const cmif::PointerAndSize &saved_message = session->saved_message;
STS_ASSERT(tls_message.GetSize() == saved_message.GetSize());
AMS_ASSERT(tls_message.GetSize() == saved_message.GetSize());
if (!session->has_received) {
R_TRY(this->ReceiveRequest(session, tls_message));
session->has_received = true;
@@ -180,7 +180,7 @@ namespace sts::sf::hipc {
this->ProcessDeferredSessions();
return ResultSuccess();
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -15,7 +15,7 @@
*/
#include <stratosphere.hpp>
namespace sts::sf::hipc {
namespace ams::sf::hipc {
namespace {
@@ -40,10 +40,10 @@ namespace sts::sf::hipc {
}
Result ServerSession::ForwardRequest(const cmif::ServiceDispatchContext &ctx) const {
STS_ASSERT(this->IsMitmSession());
AMS_ASSERT(this->IsMitmSession());
/* TODO: Support non-TLS messages? */
STS_ASSERT(this->saved_message.GetPointer() != nullptr);
STS_ASSERT(this->saved_message.GetSize() == TlsMessageBufferSize);
AMS_ASSERT(this->saved_message.GetPointer() != nullptr);
AMS_ASSERT(this->saved_message.GetSize() == TlsMessageBufferSize);
/* Copy saved TLS in. */
std::memcpy(armGetTls(), this->saved_message.GetPointer(), this->saved_message.GetSize());
@@ -115,7 +115,7 @@ namespace sts::sf::hipc {
session_memory->pointer_buffer = this->GetSessionPointerBuffer(session_memory);
session_memory->saved_message = this->GetSessionSavedMessageBuffer(session_memory);
/* Validate session pointer buffer. */
STS_ASSERT(session_memory->pointer_buffer.GetSize() >= session_memory->forward_service->pointer_buffer_size);
AMS_ASSERT(session_memory->pointer_buffer.GetSize() >= session_memory->forward_service->pointer_buffer_size);
session_memory->pointer_buffer = cmif::PointerAndSize(session_memory->pointer_buffer.GetAddress(), session_memory->forward_service->pointer_buffer_size);
/* Register to wait list. */
this->RegisterSessionToWaitList(session_memory);
@@ -188,7 +188,7 @@ namespace sts::sf::hipc {
return ResultSuccess();
case hipc::ReceiveResult::NeedsRetry:
continue;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}