2021-02-09 14:16:43 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2021-02-09 14:16:43 +00:00
|
|
|
*
|
|
|
|
* 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;
|
2021-02-10 04:43:40 +00:00
|
|
|
os::Event m_cancel_event;
|
|
|
|
bool m_cancelled;
|
2021-02-10 12:22:19 +00:00
|
|
|
mutable os::Event m_connection_event;
|
2021-02-09 14:16:43 +00:00
|
|
|
bool m_client_connected;
|
|
|
|
bool m_server_connected;
|
2021-02-10 04:43:40 +00:00
|
|
|
bool m_connected;
|
2021-02-10 12:22:19 +00:00
|
|
|
mutable os::SdkMutex m_connection_mutex;
|
2021-02-10 04:43:40 +00:00
|
|
|
private:
|
|
|
|
static void ClientThreadEntry(void *arg) { static_cast<HtcmiscImpl *>(arg)->ClientThread(); }
|
|
|
|
static void ServerThreadEntry(void *arg) { static_cast<HtcmiscImpl *>(arg)->ServerThread(); }
|
|
|
|
|
|
|
|
void ClientThread();
|
|
|
|
void ServerThread();
|
2021-02-09 14:16:43 +00:00
|
|
|
public:
|
|
|
|
HtcmiscImpl(htclow::HtclowManager *htclow_manager);
|
2021-02-10 04:43:40 +00:00
|
|
|
~HtcmiscImpl();
|
2021-02-10 12:22:19 +00:00
|
|
|
|
|
|
|
os::EventType *GetConnectionEvent() const;
|
|
|
|
bool IsConnected() const;
|
2021-02-10 09:29:40 +00:00
|
|
|
private:
|
|
|
|
void SetClientConnectionEvent(bool en);
|
|
|
|
void SetServerConnectionEvent(bool en);
|
|
|
|
|
|
|
|
void UpdateConnectionEvent();
|
2021-02-23 23:47:28 +00:00
|
|
|
|
|
|
|
void WaitTask(u32 task_id);
|
2021-02-09 14:16:43 +00:00
|
|
|
public:
|
2021-02-10 04:43:40 +00:00
|
|
|
void Cancel();
|
2021-02-23 23:47:28 +00:00
|
|
|
|
|
|
|
Result GetEnvironmentVariable(size_t *out_size, char *dst, size_t dst_size, const char *name, size_t name_size);
|
|
|
|
Result GetEnvironmentVariableLength(size_t *out_size, const char *name, size_t name_size);
|
|
|
|
|
2021-10-05 00:12:32 +00:00
|
|
|
Result RunOnHostBegin(u32 *out_task_id, os::NativeHandle *out_event, const char *args, size_t args_size);
|
2021-02-23 23:47:28 +00:00
|
|
|
Result RunOnHostEnd(s32 *out_result, u32 task_id);
|
2021-02-09 14:16:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|