htc: skeleton much of the type hierarchy for htclow manager

This commit is contained in:
Michael Scire 2021-02-07 23:13:04 -08:00 committed by SciresM
parent 83c1c175ba
commit cf99f54a34
26 changed files with 942 additions and 14 deletions

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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::ctrl {
class HtcctrlPacket : public util::IntrusiveListBaseNode<HtcctrlPacket> {
/* TODO */
};
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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::ctrl {
class HtcctrlPacketFactory {
private:
mem::StandardAllocator *m_allocator;
u32 m_seed;
public:
HtcctrlPacketFactory(mem::StandardAllocator *allocator) : m_allocator(allocator) {
/* Get the current time. */
const u64 time = os::GetSystemTick().GetInt64Value();
/* Set the random seed. */
{
util::TinyMT rng;
rng.Initialize(reinterpret_cast<const u32 *>(std::addressof(time)), sizeof(time) / sizeof(u32));
m_seed = rng.GenerateRandomU32();
}
}
};
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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_ctrl_packet.hpp"
namespace ams::htclow::ctrl {
class HtcctrlPacketFactory;
class HtcctrlSendBuffer {
private:
using PacketList = util::IntrusiveListBaseTraits<HtcctrlPacket>::ListType;
private:
HtcctrlPacketFactory *m_packet_factory;
PacketList m_packet_list;
public:
HtcctrlSendBuffer(HtcctrlPacketFactory *pf) : m_packet_factory(pf), m_packet_list() { /* ... */ }
};
}

View file

@ -0,0 +1,58 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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_ctrl_settings_holder.hpp"
#include "htclow_ctrl_send_buffer.hpp"
namespace ams::htclow {
namespace ctrl {
class HtcctrlPacketFactory;
class HtcctrlStateMachine;
}
namespace mux {
class Mux;
}
}
namespace ams::htclow::ctrl {
class HtcctrlService {
private:
SettingsHolder m_settings_holder;
u8 m_beacon_response[0x1000];
u8 m_1100[0x1000];
HtcctrlPacketFactory *m_packet_factory;
HtcctrlStateMachine *m_state_machine;
mux::Mux *m_mux;
os::EventType m_event;
HtcctrlSendBuffer m_send_buffer;
os::SdkMutex m_mutex;
os::SdkConditionVariable m_condvar;
u8 m_2170[0x1000];
u16 m_version;
public:
HtcctrlService(HtcctrlPacketFactory *pf, HtcctrlStateMachine *sm, mux::Mux *mux);
};
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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::ctrl {
class SettingsHolder {
private:
char m_hardware_type[0x40];
char m_target_name[0x40];
char m_serial_number[0x40];
char m_firmware_version[0x40];
public:
SettingsHolder() { /* ... */ }
};
}

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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::ctrl {
enum HtcctrlState : u32 {
/* ... */
};
}

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2019-2020 Adubbz, 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_ctrl_state.hpp"
namespace ams::htclow::ctrl {
class HtcctrlStateMachine {
private:
struct ServiceChannelState {
u32 _00;
u32 _04;
};
static constexpr int MaxChannelCount = 10;
using MapType = util::FixedMap<impl::ChannelInternalType, ServiceChannelState>;
static constexpr size_t MapRequiredMemorySize = MapType::GetRequiredMemorySize(MaxChannelCount);
private:
u8 m_map_buffer[MapRequiredMemorySize];
MapType m_map;
HtcctrlState m_state;
HtcctrlState m_prev_state;
os::SdkMutex m_mutex;
public:
HtcctrlStateMachine();
};
}