mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-11-17 02:01:18 +01:00
NOTE: This work is not yet fully complete; kernel is done, but it was taking an exceedingly long time to get through libstratosphere. Thus, I've temporarily added -Wno-error=unused-result for libstratosphere/stratosphere. All warnings should be fixed to do the same thing Nintendo does as relevant, but this is taking a phenomenally long time and is not actually the most important work to do, so it can be put off for some time to prioritize other tasks for 21.0.0 support.
63 lines
2.2 KiB
C++
63 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 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"
|
|
#include "htc_htcmisc_rpc_tasks.hpp"
|
|
|
|
namespace ams::htc::server::rpc {
|
|
|
|
class HtcmiscRpcServer {
|
|
private:
|
|
/* TODO: where is this value coming from, again? */
|
|
static constexpr size_t BufferSize = 1_KB;
|
|
private:
|
|
mem::StandardAllocator *m_allocator;
|
|
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;
|
|
char m_receive_buffer[BufferSize];
|
|
char m_send_buffer[BufferSize];
|
|
u8 m_driver_receive_buffer[4_KB];
|
|
u8 m_driver_send_buffer[4_KB];
|
|
private:
|
|
static void ReceiveThreadEntry(void *arg) { static_cast<void>(static_cast<HtcmiscRpcServer *>(arg)->ReceiveThread()); }
|
|
|
|
Result ReceiveThread();
|
|
public:
|
|
HtcmiscRpcServer(driver::IDriver *driver, htclow::ChannelId channel);
|
|
public:
|
|
void Open();
|
|
void Close();
|
|
|
|
Result Start();
|
|
void Cancel();
|
|
void Wait();
|
|
|
|
int WaitAny(htclow::ChannelState state, os::EventType *event);
|
|
private:
|
|
Result ProcessSetTargetNameRequest(const char *name, size_t size, u32 task_id);
|
|
|
|
Result ReceiveHeader(HtcmiscRpcPacket *header);
|
|
Result ReceiveBody(char *dst, size_t size);
|
|
Result SendRequest(const char *src, size_t size);
|
|
};
|
|
|
|
}
|