[tma2] [Ongoing] Continue implementing modules for tma2. (#1388)

* cs: add stub sysmodule to host command shell server

* cs: implement logic for main (linker error paradise, for now)

* cs: implement more of the system module's skeleton

* htcs: update client type names for libnx pr merge
This commit is contained in:
SciresM
2021-03-16 17:13:30 -07:00
committed by GitHub
parent 021d4c88fa
commit 5362ee9450
44 changed files with 1785 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2018-2020 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>
#include "impl/htc_tenv_allocator.hpp"
namespace ams::htc::tenv {
void Initialize(AllocateFunction allocate, DeallocateFunction deallocate) {
/* Initialize the library allocator. */
impl::InitializeAllocator(allocate, deallocate);
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018-2020 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>
#include "htc_tenv_service.hpp"
namespace ams::htc::tenv {
Result Service::GetVariable(sf::Out<s64> out_size, const sf::OutBuffer &out_buffer, const htc::tenv::VariableName &name) {
/* TODO */
AMS_ABORT("Service::GetVariable");
}
Result Service::GetVariableLength(sf::Out<s64> out_size,const htc::tenv::VariableName &name) {
/* TODO */
AMS_ABORT("Service::GetVariableLength");
}
Result Service::WaitUntilVariableAvailable(s64 timeout_ms) {
/* TODO */
AMS_ABORT("Service::WaitUntilVariableAvailable");
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018-2020 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/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htc::tenv {
class Service {
private:
os::ProcessId m_process_id;
public:
constexpr Service(os::ProcessId pid) : m_process_id(pid) { /* ... */ }
public:
Result GetVariable(sf::Out<s64> out_size, const sf::OutBuffer &out_buffer, const htc::tenv::VariableName &name);
Result GetVariableLength(sf::Out<s64> out_size,const htc::tenv::VariableName &name);
Result WaitUntilVariableAvailable(s64 timeout_ms);
};
static_assert(htc::tenv::IsIService<Service>);
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2018-2020 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>
#include "impl/htc_tenv_allocator.hpp"
#include "htc_tenv_service.hpp"
namespace ams::htc::tenv {
Result ServiceManager::GetServiceInterface(sf::Out<sf::SharedPointer<htc::tenv::IService>> out, const sf::ClientProcessId &process_id) {
*out = impl::SfObjectFactory::CreateSharedEmplaced<htc::tenv::IService, Service>(process_id.GetValue());
return ResultSuccess();
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 2018-2020 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>
#include "htc_tenv_allocator.hpp"
namespace ams::htc::tenv::impl {
namespace {
constinit AllocateFunction g_allocate = nullptr;
constinit DeallocateFunction g_deallocate = nullptr;
}
void InitializeAllocator(AllocateFunction allocate, DeallocateFunction deallocate) {
/* Check that we don't already have allocator functions. */
AMS_ASSERT(g_allocate == nullptr);
AMS_ASSERT(g_deallocate == nullptr);
/* Set our allocator functions. */
g_allocate = allocate;
g_deallocate = deallocate;
/* Check that we have allocator functions. */
AMS_ASSERT(g_allocate != nullptr);
AMS_ASSERT(g_deallocate != nullptr);
}
void *Allocate(size_t size) {
/* Check that we have an allocator. */
AMS_ASSERT(g_allocate != nullptr);
return g_allocate(size);
}
void Deallocate(void *p, size_t size) {
/* Check that we have a deallocator. */
AMS_ASSERT(g_deallocate != nullptr);
return g_deallocate(p, size);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2018-2020 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/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htc::tenv::impl {
void InitializeAllocator(AllocateFunction allocate, DeallocateFunction deallocate);
void *Allocate(size_t size);
void Deallocate(void *p, size_t size);
class SfAllocator {
public:
constexpr ALWAYS_INLINE SfAllocator() { /* ... */ }
void *Allocate(size_t size) {
return ::ams::htc::tenv::impl::Allocate(size);
}
void Deallocate(void *p, size_t size) {
return ::ams::htc::tenv::impl::Deallocate(p, size);
}
};
using SfPolicy = sf::StatelessAllocationPolicy<SfAllocator>;
using SfObjectFactory = sf::ObjectFactory<SfPolicy>;
}