1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 16:32:05 +00:00

htc: begin skeletoning types for HtcmiscImpl

This commit is contained in:
Michael Scire 2021-02-09 06:16:43 -08:00 committed by SciresM
parent 889f144b27
commit 1963ae7ec0
13 changed files with 320 additions and 6 deletions

View file

@ -16,3 +16,4 @@
#pragma once
#include <stratosphere/htc/server/htc_htcmisc_hipc_server.hpp>
#include <stratosphere/htc/server/htc_htcmisc_channel_ids.hpp>

View file

@ -0,0 +1,25 @@
/*
* 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 <vapours.hpp>
#include <stratosphere/htclow/htclow_channel_types.hpp>
namespace ams::htc::server {
constexpr inline htclow::ChannelId HtcmiscClientChannelId = 1;
constexpr inline htclow::ChannelId HtcmiscServerChannelId = 2;
}

View file

@ -33,4 +33,8 @@ namespace ams::htclow {
constexpr inline s16 ProtocolVersion = 5;
enum ReceiveOption {
/* ... */
};
}

View file

@ -0,0 +1,29 @@
/*
* 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>
#include "htc_i_driver.hpp"
namespace ams::htc::server::driver {
class DriverManager {
private:
IDriver *m_driver;
public:
DriverManager(IDriver *driver) : m_driver(driver) { /* ... */ }
};
}

View file

@ -0,0 +1,47 @@
/*
* 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>
#include "../../../htclow/htclow_manager.hpp"
#include "htc_i_driver.hpp"
namespace ams::htc::server::driver {
class HtclowDriver final : public IDriver {
private:
static constexpr size_t DefaultBufferSize = 128_KB;
private:
u8 m_default_receive_buffer[DefaultBufferSize];
u8 m_default_send_buffer[DefaultBufferSize];
htclow::HtclowManager *m_manager;
bool m_disconnection_emulation_enabled;
htclow::ModuleId m_module_id;
public:
HtclowDriver(htclow::HtclowManager *manager, htclow::ModuleId module_id) : m_manager(manager), m_disconnection_emulation_enabled(false), m_module_id(module_id) { /* ... */ }
public:
virtual void SetDisconnectionEmulationEnabled(bool en) override;
virtual Result Open(htclow::ChannelId channel) override;
virtual Result Open(htclow::ChannelId channel, void *receive_buffer, size_t receive_buffer_size, void *send_buffer, size_t send_buffer_size) override;
virtual void Close(htclow::ChannelId channel) override;
virtual Result Connect(htclow::ChannelId channel) override;
virtual void Shutdown(htclow::ChannelId channel) override;
virtual Result Send(s64 *out, const void *src, s64 src_size, htclow::ChannelId channel) override;
virtual Result Receive(s64 *out, void *dst, s64 dst_size, htclow::ChannelId channel, htclow::ReceiveOption option) override;
virtual htclow::ChannelState GetChannelState(htclow::ChannelId channel) override;
virtual os::EventType *GetChannelStateEvent(htclow::ChannelId channel) override;
};
}

View file

@ -0,0 +1,35 @@
/*
* 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::server::driver {
class IDriver {
public:
virtual void SetDisconnectionEmulationEnabled(bool en) = 0;
virtual Result Open(htclow::ChannelId channel) = 0;
virtual Result Open(htclow::ChannelId channel, void *receive_buffer, size_t receive_buffer_size, void *send_buffer, size_t send_buffer_size) = 0;
virtual void Close(htclow::ChannelId channel) = 0;
virtual Result Connect(htclow::ChannelId channel) = 0;
virtual void Shutdown(htclow::ChannelId channel) = 0;
virtual Result Send(s64 *out, const void *src, s64 src_size, htclow::ChannelId channel) = 0;
virtual Result Receive(s64 *out, void *dst, s64 dst_size, htclow::ChannelId channel, htclow::ReceiveOption option) = 0;
virtual htclow::ChannelState GetChannelState(htclow::ChannelId channel) = 0;
virtual os::EventType *GetChannelStateEvent(htclow::ChannelId channel) = 0;
};
}

View file

@ -18,13 +18,14 @@
namespace ams::htc::server {
HtcServiceObject::HtcServiceObject(htclow::HtclowManager *htclow_manager) {
AMS_ABORT("HtcServiceObject::HtcServiceObject");
HtcServiceObject::HtcServiceObject(htclow::HtclowManager *htclow_manager) : m_set(), m_misc_impl(htclow_manager), m_observer(m_misc_impl), m_mutex(){
/* Initialize our set. */
m_set.Initialize(MaxSetElements, m_set_memory, sizeof(m_set_memory));
}
HtcmiscImpl *HtcServiceObject::GetHtcmiscImpl() {
AMS_ABORT("HtcServiceObject::GetHtcmiscImpl");
return std::addressof(m_misc_impl);
}
Result HtcServiceObject::GetEnvironmentVariable(sf::Out<s32> out_size, const sf::OutBuffer &out, const sf::InBuffer &name) {

View file

@ -16,12 +16,21 @@
#pragma once
#include <stratosphere.hpp>
#include "../../htclow/htclow_manager.hpp"
#include "htc_htcmisc_impl.hpp"
#include "htc_observer.hpp"
namespace ams::htc::server {
class HtcServiceObject {
private:
/* TODO */
static constexpr inline auto MaxSetElements = 0x48;
using Set = util::FixedSet<u32>;
private:
u8 m_set_memory[Set::GetRequiredMemorySize(MaxSetElements)];
Set m_set;
HtcmiscImpl m_misc_impl;
Observer m_observer;
os::SdkMutex m_mutex;
public:
HtcServiceObject(htclow::HtclowManager *htclow_manager);
public:

View file

@ -0,0 +1,47 @@
/*
* 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>
#include "../../htclow/htclow_manager.hpp"
#include "driver/htc_htclow_driver.hpp"
#include "driver/htc_driver_manager.hpp"
#include "rpc/htc_rpc_client.hpp"
#include "rpc/htc_htcmisc_rpc_server.hpp"
namespace ams::htc::server {
class HtcmiscImpl {
private:
driver::HtclowDriver m_htclow_driver;
driver::DriverManager m_driver_manager;
rpc::RpcClient m_rpc_client;
rpc::HtcmiscRpcServer m_rpc_server;
os::ThreadType m_client_thread;
os::ThreadType m_server_thread;
os::Event m_event_61200;
u8 m_61228;
os::Event m_event_61230;
bool m_client_connected;
bool m_server_connected;
u8 m_6125A;
os::SdkMutex m_connection_mutex;
public:
HtcmiscImpl(htclow::HtclowManager *htclow_manager);
public:
/* TODO */
};
}

View file

@ -0,0 +1,37 @@
/*
* 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>
#include "htc_htcmisc_impl.hpp"
namespace ams::htc::server {
class Observer {
private:
os::SystemEvent m_connect_event;
os::SystemEvent m_disconnect_event;
os::Event m_event_60;
os::ThreadType m_observer_thread;
const HtcmiscImpl &m_misc_impl;
bool m_thread_running;
bool m_stopped;
bool m_connected;
bool m_is_service_available;
public:
Observer(const HtcmiscImpl &misc_impl);
};
}

View file

@ -0,0 +1,35 @@
/*
* 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>
#include "../driver/htc_i_driver.hpp"
namespace ams::htc::server::rpc {
class HtcmiscRpcServer {
private:
u64 m_00;
driver::IDriver *m_driver;
htclow::ChannelId m_channel_id;
void *m_receive_thread_stack;
os::ThreadType m_receive_thread;
bool m_cancelled;
bool m_thread_running;
public:
HtcmiscRpcServer(driver::IDriver *driver, htclow::ChannelId channel);
};
}

View file

@ -0,0 +1,44 @@
/*
* 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>
#include "../driver/htc_i_driver.hpp"
namespace ams::htc::server::rpc {
class RpcClient {
private:
u64 m_00;
driver::IDriver *m_driver;
htclow::ChannelId m_channel_id;
void *m_receive_thread_stack;
void *m_send_thread_stack;
os::ThreadType m_receive_thread;
os::ThreadType m_send_thread;
os::SdkMutex *m_p_mutex;
/* TODO: m_task_id_free_list */
/* TODO: m_task_table */
/* TODO: m_3C0[0x48] */
/* TODO: m_rpc_task_queue */
bool m_cancelled;
bool m_thread_running;
os::EventType m_5F8_events[0x48];
os::EventType m_1138_events[0x48];
public:
RpcClient(driver::IDriver *driver, htclow::ChannelId channel);
};
}

View file

@ -24,11 +24,11 @@ namespace ams::htclow::ctrl {
.module_id = ModuleId::Htcfs,
},
{
.channel_id = 1, /* TODO: htcmisc::ServerChannelId? */
.channel_id = 1, /* TODO: htcmisc::ClientChannelId? */
.module_id = ModuleId::Htcmisc,
},
{
.channel_id = 2, /* TODO: htcmisc::ClientChannelId? */
.channel_id = 2, /* TODO: htcmisc::ServerChannelId? */
.module_id = ModuleId::Htcmisc,
},
{