htclow: fix copyright headers, skeleton more manager types

This commit is contained in:
Michael Scire 2021-02-07 23:37:16 -08:00 committed by SciresM
parent cf99f54a34
commit 1687bf2e07
26 changed files with 152 additions and 33 deletions

View file

@ -26,7 +26,7 @@ namespace ams::htclow::impl {
};
static_assert(sizeof(ChannelInternalType) == 4);
ALWAYS_INLINE ChannelInternalType ConvertChannelType(ChannelType channel) {
constexpr ALWAYS_INLINE ChannelInternalType ConvertChannelType(ChannelType channel) {
return {
.channel_id = channel._channel_id,
.reserved = 0,
@ -34,27 +34,27 @@ namespace ams::htclow::impl {
};
}
ALWAYS_INLINE bool operator==(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
constexpr ALWAYS_INLINE bool operator==(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return lhs.module_id == rhs.module_id && lhs.reserved == rhs.reserved && lhs.channel_id == rhs.channel_id;
}
ALWAYS_INLINE bool operator!=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
constexpr ALWAYS_INLINE bool operator!=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return !(lhs == rhs);
}
ALWAYS_INLINE bool operator<(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
constexpr ALWAYS_INLINE bool operator<(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return lhs.module_id < rhs.module_id || lhs.reserved < rhs.reserved || lhs.channel_id < rhs.channel_id;
}
ALWAYS_INLINE bool operator>(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
constexpr ALWAYS_INLINE bool operator>(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return rhs < lhs;
}
ALWAYS_INLINE bool operator<=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
constexpr ALWAYS_INLINE bool operator<=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return !(lhs > rhs);
}
ALWAYS_INLINE bool operator>=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
constexpr ALWAYS_INLINE bool operator>=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return !(lhs < rhs);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,
@ -19,7 +19,7 @@
namespace ams::htclow::ctrl {
enum HtcctrlState : u32 {
/* ... */
HtcctrlState_Eleven = 11,
};
}

View file

@ -0,0 +1,57 @@
/*
* 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/>.
*/
#include <stratosphere.hpp>
#include "htclow_ctrl_state_machine.hpp"
namespace ams::htclow::ctrl {
namespace {
constexpr const impl::ChannelInternalType ServiceChannels[] = {
{
.channel_id = 0,
.module_id = static_cast<ModuleId>(1),
},
{
.channel_id = 1,
.module_id = static_cast<ModuleId>(3),
},
{
.channel_id = 2,
.module_id = static_cast<ModuleId>(3),
},
{
.channel_id = 0,
.module_id = static_cast<ModuleId>(4),
},
};
}
HtcctrlStateMachine::HtcctrlStateMachine() : m_map(), m_state(HtcctrlState_Eleven), m_prev_state(HtcctrlState_Eleven), m_mutex() {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Initialize our map. */
m_map.Initialize(MaxChannelCount, m_map_buffer, sizeof(m_map_buffer));
/* Insert each service channel the map. */
for (const auto &channel : ServiceChannels) {
m_map.insert(std::make_pair<impl::ChannelInternalType, ServiceChannelState>(impl::ChannelInternalType{channel}, ServiceChannelState{}));
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -0,0 +1,29 @@
/*
* 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/>.
*/
#include <stratosphere.hpp>
#include "htclow_mux.hpp"
namespace ams::htclow::mux {
Mux::Mux(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm)
: m_packet_factory(pf), m_state_machine(sm), m_task_manager(), m_wake_event(os::EventClearMode_ManualClear),
m_channel_impl_map(pf, sm, std::addressof(m_task_manager), std::addressof(m_wake_event)), m_global_send_buffer(pf),
m_mutex(), m_is_sleeping(false), m_version(5)
{
/* ... */
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,
@ -26,7 +26,7 @@ namespace ams::htclow::mux {
PacketFactory *m_packet_factory;
ctrl::HtcctrlStateMachine *m_state_machine;
TaskManager m_task_manager;
os::EventType m_wake_event;
os::Event m_wake_event;
ChannelImplMap m_channel_impl_map;
GlobalSendBuffer m_global_send_buffer;
os::SdkMutex m_mutex;

View file

@ -0,0 +1,33 @@
/*
* 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/>.
*/
#include <stratosphere.hpp>
#include "htclow_mux_channel_impl_map.hpp"
namespace ams::htclow::mux {
ChannelImplMap::ChannelImplMap(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::Event *ev)
: m_packet_factory(pf), m_state_machine(sm), m_task_manager(tm), m_event(ev), m_map()
{
/* Initialize the map. */
m_map.Initialize(MaxChannelCount, m_map_buffer, sizeof(m_map_buffer));
/* Set all storages as invalid. */
for (auto i = 0; i < MaxChannelCount; ++i) {
m_storage_valid[i] = false;
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,
@ -44,13 +44,13 @@ namespace ams::htclow::mux {
PacketFactory *m_packet_factory;
ctrl::HtcctrlStateMachine *m_state_machine;
TaskManager *m_task_manager;
os::EventType *m_event;
os::Event *m_event;
u8 m_map_buffer[MapRequiredMemorySize];
MapType m_map;
u8 m_storage[0x5200]; /* TODO */
bool m_storage_valid[MaxChannelCount];
public:
ChannelImplMap(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::EventType *ev);
ChannelImplMap(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::Event *ev);
};
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020 Adubbz, Atmosphère-NX
* 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,