1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-23 12:22:08 +00:00
Atmosphere/libraries/libstratosphere/source/htclow/htclow_channel.hpp

59 lines
2.1 KiB
C++
Raw Normal View History

2021-02-11 06:52:12 +00:00
/*
* 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_manager.hpp"
namespace ams::htclow {
class Channel final {
private:
HtclowManager *m_manager;
ChannelType m_channel;
public:
constexpr Channel(HtclowManager *manager) : m_manager(manager), m_channel() { /* ... */ }
constexpr ~Channel() { m_channel = {}; }
ChannelType *GetBase() { return std::addressof(m_channel); }
public:
Result Open(const Module *module, ChannelId id);
void Close();
ChannelState GetChannelState();
os::EventType *GetChannelStateEvent();
Result Connect();
Result Flush();
void Shutdown();
Result Receive(s64 *out, void *dst, s64 size, ReceiveOption option);
2021-02-13 06:07:34 +00:00
Result Send(s64 *out, const void *src, s64 size);
2021-02-11 06:52:12 +00:00
void SetConfig(const ChannelConfig &config);
void SetReceiveBuffer(void *buf, size_t size);
void SetSendBuffer(void *buf, size_t size);
void SetSendBufferWithData(const void *buf, size_t size);
Result WaitReceive(s64 size);
Result WaitReceive(s64 size, os::EventType *event);
private:
void WaitEvent(os::EventType *event, bool);
Result ReceiveInternal(s64 *out, void *dst, s64 size, ReceiveOption option);
Result WaitReceiveInternal(s64 size, os::EventType *event);
};
}