htc: skeleton HtcsManagerImpl, implement HtcsMonitor
This commit is contained in:
@@ -24,6 +24,8 @@ namespace ams::htc::server::driver {
|
||||
IDriver *m_driver;
|
||||
public:
|
||||
DriverManager(IDriver *driver) : m_driver(driver) { /* ... */ }
|
||||
|
||||
IDriver *GetDriver() { return m_driver; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace ams::htc::server {
|
||||
m_rpc_client.Close();
|
||||
m_rpc_client.Cancel();
|
||||
m_rpc_client.Wait();
|
||||
this->SetClientConnectionEvent(false);
|
||||
};
|
||||
|
||||
/* Wait to become disconnected. */
|
||||
@@ -111,12 +112,7 @@ namespace ams::htc::server {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set ourselves as disconnected. */
|
||||
this->SetClientConnectionEvent(false);
|
||||
}
|
||||
|
||||
/* Set ourselves as disconnected. */
|
||||
this->SetClientConnectionEvent(false);
|
||||
}
|
||||
|
||||
void HtcmiscImpl::ServerThread() {
|
||||
@@ -147,6 +143,7 @@ namespace ams::htc::server {
|
||||
m_rpc_server.Close();
|
||||
m_rpc_server.Cancel();
|
||||
m_rpc_server.Wait();
|
||||
this->SetServerConnectionEvent(false);
|
||||
};
|
||||
|
||||
/* Wait to become disconnected. */
|
||||
@@ -154,12 +151,7 @@ namespace ams::htc::server {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set ourselves as disconnected. */
|
||||
this->SetServerConnectionEvent(false);
|
||||
}
|
||||
|
||||
/* Set ourselves as disconnected. */
|
||||
this->SetServerConnectionEvent(false);
|
||||
}
|
||||
|
||||
void HtcmiscImpl::SetClientConnectionEvent(bool en) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htc_observer.hpp"
|
||||
#include "../../htcs/impl/htcs_manager.hpp"
|
||||
|
||||
namespace ams::htc::server {
|
||||
|
||||
@@ -29,7 +30,7 @@ namespace ams::htc::server {
|
||||
m_is_service_available(false)
|
||||
{
|
||||
/* Initialize htcs library. */
|
||||
/* TODO: AMS_ABORT("htcs::impl::HtcsManagerHolder::AddReference();"); */
|
||||
htcs::impl::HtcsManagerHolder::AddReference();
|
||||
|
||||
/* Update our event state. */
|
||||
this->UpdateEvent();
|
||||
@@ -76,10 +77,13 @@ namespace ams::htc::server {
|
||||
this->UpdateEvent();
|
||||
};
|
||||
|
||||
/* Get the htcs manager. */
|
||||
auto * const htcs_manager = htcs::impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Get the events we're waiting on. */
|
||||
os::EventType * const stop_event = m_stop_event.GetBase();
|
||||
os::EventType * const conn_event = m_misc_impl.GetConnectionEvent();
|
||||
os::EventType * const htcs_event = nullptr /* TODO: htcs::impl::HtcsManagerHolder::GetHtcsManager()->GetServiceAvailabilityEvent() */;
|
||||
os::EventType * const htcs_event = htcs_manager->GetServiceAvailabilityEvent();
|
||||
|
||||
/* Loop until we're asked to stop. */
|
||||
while (!m_stopped) {
|
||||
@@ -98,7 +102,7 @@ namespace ams::htc::server {
|
||||
case 2:
|
||||
/* Htcs event, update our service status. */
|
||||
os::ClearEvent(htcs_event);
|
||||
m_is_service_available = false /* TODO: htcs::impl::HtcsManagerHolder::GetHtcsManager()->IsServiceAvailable() */;
|
||||
m_is_service_available = htcs_manager->IsServiceAvailable();
|
||||
break;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ams::htc::server::rpc {
|
||||
}
|
||||
|
||||
HtcmiscRpcServer::HtcmiscRpcServer(driver::IDriver *driver, htclow::ChannelId channel)
|
||||
: m_00(0),
|
||||
: m_allocator(nullptr),
|
||||
m_driver(driver),
|
||||
m_channel_id(channel),
|
||||
m_receive_thread_stack(g_receive_thread_stack),
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ams::htc::server::rpc {
|
||||
/* TODO: where is this value coming from, again? */
|
||||
static constexpr size_t BufferSize = 1_KB;
|
||||
private:
|
||||
u64 m_00;
|
||||
mem::StandardAllocator *m_allocator;
|
||||
driver::IDriver *m_driver;
|
||||
htclow::ChannelId m_channel_id;
|
||||
void *m_receive_thread_stack;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ams::htc::server::rpc {
|
||||
}
|
||||
|
||||
RpcClient::RpcClient(driver::IDriver *driver, htclow::ChannelId channel)
|
||||
: m_00(0),
|
||||
: m_allocator(nullptr),
|
||||
m_driver(driver),
|
||||
m_channel_id(channel),
|
||||
m_receive_thread_stack(g_receive_thread_stack),
|
||||
@@ -53,6 +53,53 @@ namespace ams::htc::server::rpc {
|
||||
}
|
||||
}
|
||||
|
||||
RpcClient::RpcClient(mem::StandardAllocator *allocator, driver::IDriver *driver, htclow::ChannelId channel)
|
||||
: m_allocator(allocator),
|
||||
m_driver(driver),
|
||||
m_channel_id(channel),
|
||||
m_receive_thread_stack(m_allocator->Allocate(ThreadStackSize, os::ThreadStackAlignment)),
|
||||
m_send_thread_stack(m_allocator->Allocate(ThreadStackSize, os::ThreadStackAlignment)),
|
||||
m_mutex(g_rpc_mutex),
|
||||
m_task_id_free_list(g_task_id_free_list),
|
||||
m_task_table(g_task_table),
|
||||
m_task_active(),
|
||||
m_task_queue(),
|
||||
m_cancelled(false),
|
||||
m_thread_running(false)
|
||||
{
|
||||
/* Initialize all events. */
|
||||
for (size_t i = 0; i < MaxRpcCount; ++i) {
|
||||
os::InitializeEvent(std::addressof(m_receive_buffer_available_events[i]), false, os::EventClearMode_AutoClear);
|
||||
os::InitializeEvent(std::addressof(m_send_buffer_available_events[i]), false, os::EventClearMode_AutoClear);
|
||||
}
|
||||
}
|
||||
|
||||
RpcClient::~RpcClient() {
|
||||
/* Finalize all events. */
|
||||
for (size_t i = 0; i < MaxRpcCount; ++i) {
|
||||
os::FinalizeEvent(std::addressof(m_receive_buffer_available_events[i]));
|
||||
os::FinalizeEvent(std::addressof(m_send_buffer_available_events[i]));
|
||||
}
|
||||
|
||||
/* Free the thread stacks. */
|
||||
if (m_allocator != nullptr) {
|
||||
m_allocator->Free(m_receive_thread_stack);
|
||||
m_allocator->Free(m_send_thread_stack);
|
||||
}
|
||||
m_receive_thread_stack = nullptr;
|
||||
m_send_thread_stack = nullptr;
|
||||
|
||||
/* Free all tasks. */
|
||||
for (u32 i = 0; i < MaxRpcCount; ++i) {
|
||||
if (m_task_active[i]) {
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
m_task_table.Delete(i);
|
||||
m_task_id_free_list.Free(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RpcClient::Open() {
|
||||
R_ABORT_UNLESS(m_driver->Open(m_channel_id));
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ams::htc::server::rpc {
|
||||
/* TODO: where is this value coming from, again? */
|
||||
static constexpr size_t BufferSize = 0xE400;
|
||||
private:
|
||||
u64 m_00;
|
||||
mem::StandardAllocator *m_allocator;
|
||||
driver::IDriver *m_driver;
|
||||
htclow::ChannelId m_channel_id;
|
||||
void *m_receive_thread_stack;
|
||||
@@ -53,6 +53,8 @@ namespace ams::htc::server::rpc {
|
||||
Result SendThread();
|
||||
public:
|
||||
RpcClient(driver::IDriver *driver, htclow::ChannelId channel);
|
||||
RpcClient(mem::StandardAllocator *allocator, driver::IDriver *driver, htclow::ChannelId channel);
|
||||
~RpcClient();
|
||||
public:
|
||||
void Open();
|
||||
void Close();
|
||||
|
||||
Reference in New Issue
Block a user