Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_task_manager.hpp

66 lines
2.1 KiB
C++
Raw Normal View History

/*
* 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::htclow::mux {
constexpr inline int MaxTaskCount = 0x80;
2021-02-08 13:45:23 +00:00
enum EventTrigger : u8 {
EventTrigger_Disconnect = 1,
EventTrigger_ReceiveData = 2,
EventTrigger_SendReady = 5,
EventTrigger_SendBufferEmpty = 10,
EventTrigger_ConnectReady = 11,
2021-02-08 13:45:23 +00:00
};
class TaskManager {
private:
2021-02-08 13:45:23 +00:00
enum TaskType : u8 {
TaskType_Receive = 0,
TaskType_Send = 1,
TaskType_Flush = 6,
TaskType_Connect = 7,
};
struct Task {
impl::ChannelInternalType channel;
os::EventType event;
2021-02-08 13:45:23 +00:00
bool has_event_trigger;
EventTrigger event_trigger;
TaskType type;
size_t size;
};
private:
bool m_valid[MaxTaskCount];
Task m_tasks[MaxTaskCount];
public:
TaskManager() : m_valid() { /* ... */ }
2021-02-08 13:45:23 +00:00
os::EventType *GetTaskEvent(u32 task_id);
2021-02-08 13:45:23 +00:00
void NotifyDisconnect(impl::ChannelInternalType channel);
void NotifyReceiveData(impl::ChannelInternalType channel, size_t size);
void NotifySendReady();
void NotifySendBufferEmpty(impl::ChannelInternalType channel);
2021-02-08 13:45:23 +00:00
void NotifyConnectReady();
private:
void CompleteTask(int index, EventTrigger trigger);
};
}