id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
8,371
lm_log_packet_header.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/impl/lm_log_packet_header.hpp
/* * 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> namespace ams::lm::impl { constexpr inline size_t LogPacketHeaderSize = 0x18; class LogPacketHeader { private: u64 m_process_id; u64 m_thread_id; u8 m_flags; u8 m_padding; u8 m_severity; u8 m_verbosity; u32 m_payload_size; public: constexpr u64 GetProcessId() const { return m_process_id; } constexpr void SetProcessId(u64 v) { m_process_id = v; } constexpr u64 GetThreadId() const { return m_thread_id; } constexpr void SetThreadId(u64 v) { m_thread_id = v; } constexpr bool IsHead() const { return (m_flags & (1 << 0)) != 0; } constexpr void SetHead(bool v) { m_flags = (m_flags & ~(1 << 0)) | ((v ? 1 : 0) << 0); } constexpr bool IsTail() const { return (m_flags & (1 << 1)) != 0; } constexpr void SetTail(bool v) { m_flags = (m_flags & ~(1 << 1)) | ((v ? 1 : 0) << 1); } constexpr bool IsLittleEndian() const { return (m_flags & (1 << 2)) != 0; } constexpr void SetLittleEndian(bool v) { m_flags = (m_flags & ~(1 << 2)) | ((v ? 1 : 0) << 2); } constexpr u8 GetSeverity() const { return m_severity; } constexpr void SetSeverity(u8 v) { m_severity = v; } constexpr u8 GetVerbosity() const { return m_verbosity; } constexpr void SetVerbosity(u8 v) { m_verbosity = v; } constexpr u32 GetPayloadSize() const { return m_payload_size; } constexpr void SetPayloadSize(u32 v) { m_payload_size = v; } }; static_assert(sizeof(LogPacketHeader) == LogPacketHeaderSize); }
2,358
C++
.h
48
41.1875
108
0.613745
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,372
lm_log_packet_transmitter_base.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/impl/lm_log_packet_transmitter_base.hpp
/* * 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 "lm_log_packet_header.hpp" #include "lm_log_data_chunk.hpp" namespace ams::lm::impl { class LogPacketTransmitterBase { public: using FlushFunction = bool (*)(const u8 *data, size_t size); private: LogPacketHeader *m_header; u8 *m_start; u8 *m_end; u8 *m_payload; u8 *m_current; bool m_is_tail; FlushFunction m_flush_function; protected: LogPacketTransmitterBase(void *buffer, size_t buffer_size, FlushFunction flush_func, u8 severity, u8 verbosity, u64 process_id, bool head, bool tail); ~LogPacketTransmitterBase() { this->Flush(m_is_tail); } void PushDataChunk(LogDataChunkKey key, const void *data, size_t size) { this->PushDataChunkImpl(key, data, size, false); } void PushDataChunk(LogDataChunkKey key, const char *str, size_t size) { this->PushDataChunkImpl(key, str, size, true); } public: bool Flush(bool is_tail); private: size_t GetRemainSize(); size_t GetPushableDataSize(size_t uleb_size); size_t GetRequiredSizeToPushUleb128(u64 v); void PushUleb128(u64 v); void PushDataChunkImpl(LogDataChunkKey key, const void *data, size_t size, bool is_text); void PushData(const void *data, size_t size); }; }
2,164
C++
.h
53
32.641509
162
0.641635
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,373
lm_log_data_chunk.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/impl/lm_log_data_chunk.hpp
/* * 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> namespace ams::lm::impl { enum LogDataChunkKey { LogDataChunkKey_LogSessionBegin = 0, LogDataChunkKey_LogSessionEnd = 1, LogDataChunkKey_TextLog = 2, LogDataChunkKey_LineNumber = 3, LogDataChunkKey_FileName = 4, LogDataChunkKey_FunctionName = 5, LogDataChunkKey_ModuleName = 6, LogDataChunkKey_ThreadName = 7, LogDataChunkKey_LogPacketDropCount = 8, LogDataChunkKey_UserSystemClock = 9, LogDataChunkKey_ProcessName = 10, }; }
1,280
C++
.h
32
35.46875
76
0.677912
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,374
lm_i_log_getter.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/sf/lm_i_log_getter.hpp
/* * 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> #define AMS_LM_I_LOG_GETTER_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, StartLogging, (), ()) \ AMS_SF_METHOD_INFO(C, H, 1, Result, StopLogging, (), ()) \ AMS_SF_METHOD_INFO(C, H, 2, Result, GetLog, (const sf::OutAutoSelectBuffer &message, sf::Out<s64> out_size, sf::Out<u32> out_drop_count), (message, out_size, out_drop_count)) AMS_SF_DEFINE_INTERFACE(ams::lm, ILogGetter, AMS_LM_I_LOG_GETTER_INTERFACE_INFO, 0x565EA15C)
1,517
C++
.h
22
66.681818
186
0.539183
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,375
lm_i_log_service.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/sf/lm_i_log_service.hpp
/* * 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> #define AMS_LM_I_LOGGER_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, Log, (const sf::InAutoSelectBuffer &message), (message)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, SetDestination, (u32 destination), (destination)) AMS_SF_DEFINE_INTERFACE(ams::lm, ILogger, AMS_LM_I_LOGGER_INTERFACE_INFO, 0x3E81DAD2) #define AMS_LM_I_LOG_SERVICE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, OpenLogger, (sf::Out<sf::SharedPointer<::ams::lm::ILogger>> out, const sf::ClientProcessId &client_process_id), (out, client_process_id)) AMS_SF_DEFINE_INTERFACE(ams::lm, ILogService, AMS_LM_I_LOG_SERVICE_INTERFACE_INFO, 0xE1D7F748)
1,431
C++
.h
24
57.375
177
0.688525
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,376
lm_log_getter.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_log_getter.hpp
/* * 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 "../sf/lm_i_log_getter.hpp" namespace ams::lm::srv { class LogGetter { public: Result StartLogging(); Result StopLogging(); Result GetLog(const sf::OutAutoSelectBuffer &message, sf::Out<s64> out_size, sf::Out<u32> out_drop_count); }; static_assert(lm::IsILogGetter<LogGetter>); }
1,024
C++
.h
27
34.222222
118
0.716298
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,377
lm_sd_card_logger.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_sd_card_logger.hpp
/* * 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> namespace ams::lm::srv { class SdCardLogger { AMS_SINGLETON_TRAITS(SdCardLogger); public: using LoggingObserver = void (*)(bool available); private: os::SdkMutex m_logging_observer_mutex; bool m_is_enabled; bool m_is_sd_card_mounted; bool m_is_sd_card_status_unknown; char m_log_file_path[0x80]; s64 m_log_file_offset; LoggingObserver m_logging_observer; public: void Finalize(); void SetLoggingObserver(LoggingObserver observer); bool Write(const u8 *data, size_t size); private: bool GetEnabled() const; void SetEnabled(bool enabled); bool Initialize(); }; }
1,459
C++
.h
40
29.575
76
0.658882
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,378
lm_log_packet_parser.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_log_packet_parser.hpp
/* * 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 "../impl/lm_log_data_chunk.hpp" #include "../impl/lm_log_packet_header.hpp" namespace ams::lm::srv { class LogPacketParser { public: using ParsePacketCallback = bool (*)(const impl::LogPacketHeader &header, const void *payload, size_t payload_size, void *arg); using ParseDataChunkCallback = bool (*)(impl::LogDataChunkKey key, const void *chunk, size_t chunk_size, void *arg); using ParseTextLogCallback = void (*)(const char *txt, size_t size, void *arg); public: static bool ParsePacket(const void *buffer, size_t buffer_size, ParsePacketCallback callback, void *arg); static bool ParseDataChunk(const void *payload, size_t payload_size, ParseDataChunkCallback callback, void *arg); static bool FindDataChunk(const void **out, size_t *out_size, impl::LogDataChunkKey key, const void *buffer, size_t buffer_size); static size_t ParseModuleName(char *dst, size_t dst_size, const void *buffer, size_t buffer_size); static void ParseTextLogWithContext(const void *buffer, size_t buffer_size, ParseTextLogCallback callback, void *arg); }; }
1,855
C++
.h
33
50.969697
142
0.71641
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,379
lm_event_log_transmitter.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_event_log_transmitter.hpp
/* * 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> namespace ams::lm::srv { class EventLogTransmitter { NON_COPYABLE(EventLogTransmitter); NON_MOVEABLE(EventLogTransmitter); public: using FlushFunction = bool (*)(const u8 *data, size_t size); private: FlushFunction m_flush_function; size_t m_log_packet_drop_count; os::SdkMutex m_log_packet_drop_count_mutex; public: constexpr explicit EventLogTransmitter(FlushFunction f) : m_flush_function(f), m_log_packet_drop_count(0), m_log_packet_drop_count_mutex() { AMS_ASSERT(f != nullptr); } static EventLogTransmitter &GetDefaultInstance(); bool PushLogSessionBegin(u64 process_id); bool PushLogSessionEnd(u64 process_id); bool PushLogPacketDropCountIfExists(); void IncreaseLogPacketDropCount(); }; }
1,576
C++
.h
38
34.763158
152
0.685173
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,380
lm_log_service_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_log_service_impl.hpp
/* * 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 "../sf/lm_i_log_service.hpp" namespace ams::lm::srv { class LogServiceImpl { public: Result OpenLogger(sf::Out<sf::SharedPointer<::ams::lm::ILogger>> out, const sf::ClientProcessId &client_process_id); }; static_assert(lm::IsILogService<LogServiceImpl>); }
977
C++
.h
25
36.12
128
0.734457
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,381
lm_time_util.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_time_util.hpp
/* * 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> namespace ams::lm::srv { time::PosixTime GetCurrentTime(); }
744
C++
.h
20
35.15
76
0.755895
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,382
lm_log_getter_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_log_getter_impl.hpp
/* * 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 "lm_custom_sink_buffer.hpp" namespace ams::lm::srv { class LogGetterImpl { NON_COPYABLE(LogGetterImpl); NON_MOVEABLE(LogGetterImpl); private: static constinit inline const u8 *s_message = nullptr; static constinit inline size_t s_buffer_size = 0; static constinit inline size_t s_log_packet_drop_count = 0; private: LogGetterImpl(); public: static CustomSinkBuffer &GetBuffer(); static s64 GetLog(void *buffer, size_t buffer_size, u32 *out_drop_count); static void IncreaseLogPacketDropCount() { ++s_log_packet_drop_count; } private: static bool FlushFunction(const u8 *buffer, size_t buffer_size) { s_message = buffer; s_buffer_size = buffer_size; return true; } }; }
1,574
C++
.h
40
32.6
85
0.664052
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,383
lm_log_buffer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_log_buffer.hpp
/* * 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> namespace ams::lm::srv { class LogBuffer { NON_COPYABLE(LogBuffer); NON_MOVEABLE(LogBuffer); private: struct BufferInfo { u8 *m_head; size_t m_stored_size; size_t m_reference_count; }; public: using FlushFunction = bool (*)(const u8 *data, size_t size); private: BufferInfo m_buffers[2]; BufferInfo *m_push_buffer; BufferInfo *m_flush_buffer; size_t m_buffer_size; FlushFunction m_flush_function; os::SdkMutex m_push_buffer_mutex; os::SdkMutex m_flush_buffer_mutex; os::SdkConditionVariable m_cv_push_ready; os::SdkConditionVariable m_cv_flush_ready; bool m_push_canceled; size_t m_push_ready_wait_count; public: constexpr explicit LogBuffer(u8 *buffer, size_t buffer_size, FlushFunction f) : m_buffers{}, m_push_buffer(m_buffers + 0), m_flush_buffer(m_buffers + 1), m_buffer_size(buffer_size / 2), m_flush_function(f), m_push_buffer_mutex{}, m_flush_buffer_mutex{}, m_cv_push_ready{}, m_cv_flush_ready{}, m_push_canceled(false), m_push_ready_wait_count(0) { AMS_ASSERT(buffer != nullptr); AMS_ASSERT(buffer_size > 0); AMS_ASSERT(f != nullptr); m_buffers[0].m_head = buffer; m_buffers[1].m_head = buffer + (buffer_size / 2); } static LogBuffer &GetDefaultInstance(); bool Push(const void *data, size_t size) { return this->PushImpl(data, size, true); } bool TryPush(const void *data, size_t size) { return this->PushImpl(data, size, false); } void CancelPush(); bool Flush() { return this->FlushImpl(true); } bool TryFlush() { return this->FlushImpl(false); } private: bool PushImpl(const void *data, size_t size, bool blocking); bool FlushImpl(bool blocking); }; }
2,812
C++
.h
65
33.276923
101
0.598394
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,384
lm_log_server_proxy.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_log_server_proxy.hpp
/* * 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> namespace ams::lm::srv { class LogServerProxy { AMS_SINGLETON_TRAITS(LogServerProxy); public: using ConnectionObserver = void (*)(bool connected); private: alignas(os::ThreadStackAlignment) u8 m_thread_stack[4_KB]; os::ThreadType m_thread; os::SdkConditionVariable m_cv_connected; os::Event m_stop_event; os::SdkMutex m_connection_mutex; os::SdkMutex m_observer_mutex; std::atomic<int> m_server_socket; std::atomic<int> m_client_socket; ConnectionObserver m_connection_observer; public: void Start(); void Stop(); bool IsConnected(); void SetConnectionObserver(ConnectionObserver observer); bool Send(const u8 *data, size_t size); private: void LoopAuto(); void SignalConnection(); void InvokeConnectionObserver(bool connected); }; void StartLogServerProxy(); void StopLogServerProxy(); }
1,744
C++
.h
46
30.543478
76
0.660556
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,385
lm_custom_sink_buffer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_custom_sink_buffer.hpp
/* * 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> namespace ams::lm::srv { class CustomSinkBuffer { NON_COPYABLE(CustomSinkBuffer); NON_MOVEABLE(CustomSinkBuffer); public: using FlushFunction = bool (*)(const u8 *buffer, size_t buffer_size); private: u8 *m_buffer; size_t m_buffer_size; size_t m_used_buffer_size; FlushFunction m_flush_function; public: constexpr explicit CustomSinkBuffer(u8 *buffer, size_t buffer_size, FlushFunction f) : m_buffer(buffer), m_buffer_size(buffer_size), m_used_buffer_size(0), m_flush_function(f) { AMS_ASSERT(m_buffer != nullptr); AMS_ASSERT(m_buffer_size > 0); AMS_ASSERT(m_flush_function != nullptr); } bool TryPush(const void *data, size_t size); bool TryFlush(); }; }
1,540
C++
.h
38
33.684211
189
0.659546
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,386
lm_logger_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/srv/lm_logger_impl.hpp
/* * 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 "lm_log_service_impl.hpp" namespace ams::lm::srv { class LoggerImpl { private: LogServiceImpl *m_parent; u64 m_process_id; public: explicit LoggerImpl(LogServiceImpl *parent, os::ProcessId process_id); ~LoggerImpl(); public: Result Log(const sf::InAutoSelectBuffer &message); Result SetDestination(u32 destination); }; static_assert(lm::IsILogger<LoggerImpl>); }
1,159
C++
.h
32
31.3125
82
0.701068
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,387
lmem_impl_common_heap.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp
/* * 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> namespace ams::lmem::impl { constexpr inline u32 ExpHeapMagic = util::ReverseFourCC<'E','X','P','H'>::Code; constexpr inline u32 FrameHeapMagic = util::ReverseFourCC<'F','R','M','H'>::Code; constexpr inline u32 UnitHeapMagic = util::ReverseFourCC<'U','N','T','H'>::Code; class ScopedHeapLock { NON_COPYABLE(ScopedHeapLock); NON_MOVEABLE(ScopedHeapLock); private: HeapHandle m_handle; public: explicit ScopedHeapLock(HeapHandle h) : m_handle(h) { if (m_handle->option & CreateOption_ThreadSafe) { os::LockSdkMutex(std::addressof(m_handle->mutex)); } } ~ScopedHeapLock() { if (m_handle->option & CreateOption_ThreadSafe) { os::UnlockSdkMutex(std::addressof(m_handle->mutex)); } } }; ALWAYS_INLINE MemoryRange MakeMemoryRange(void *address, size_t size) { return MemoryRange{ .address = reinterpret_cast<uintptr_t>(address), .size = size }; } ALWAYS_INLINE void *GetHeapStartAddress(HeapHandle handle) { return handle->heap_start; } ALWAYS_INLINE size_t GetPointerDifference(const void *start, const void *end) { return reinterpret_cast<uintptr_t>(end) - reinterpret_cast<uintptr_t>(start); } constexpr ALWAYS_INLINE size_t GetPointerDifference(uintptr_t start, uintptr_t end) { return end - start; } void InitializeHeapHead(HeapHead *out, u32 magic, void *start, void *end, u32 option); void FinalizeHeap(HeapHead *heap); bool ContainsAddress(HeapHandle handle, const void *address); size_t GetHeapTotalSize(HeapHandle handle); /* Debug Fill */ u32 GetDebugFillValue(FillType type); u32 SetDebugFillValue(FillType type, u32 value); inline void FillMemory(void *dst, u32 fill_value, size_t size) { /* All heap blocks must be at least 32-bit aligned. */ AMS_ASSERT(util::IsAligned(reinterpret_cast<uintptr_t>(dst), alignof(u32))); AMS_ASSERT(util::IsAligned(size, sizeof(u32))); for (size_t i = 0; i < size / sizeof(fill_value); i++) { reinterpret_cast<u32 *>(dst)[i] = fill_value; } } inline void FillUnallocatedMemory(HeapHead *heap, void *address, size_t size) { if (heap->option & CreateOption_DebugFill) { FillMemory(address, impl::GetDebugFillValue(FillType_Unallocated), size); } } inline void FillAllocatedMemory(HeapHead *heap, void *address, size_t size) { if (heap->option & CreateOption_ZeroClear) { FillMemory(address, 0, size); } else if (heap->option & CreateOption_DebugFill) { FillMemory(address, impl::GetDebugFillValue(FillType_Allocated), size); } } inline void FillFreedMemory(HeapHead *heap, void *address, size_t size) { if (heap->option & CreateOption_DebugFill) { FillMemory(address, impl::GetDebugFillValue(FillType_Freed), size); } } }
3,751
C++
.h
83
37.879518
92
0.660099
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,388
lmem_impl_exp_heap.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.hpp
/* * 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 "lmem_impl_common_heap.hpp" namespace ams::lmem::impl { HeapHandle CreateExpHeap(void *address, size_t size, u32 option); void DestroyExpHeap(HeapHandle handle); MemoryRange AdjustExpHeap(HeapHandle handle); void *AllocateFromExpHeap(HeapHandle handle, size_t size, s32 alignment); void FreeToExpHeap(HeapHandle handle, void *block); size_t ResizeExpHeapMemoryBlock(HeapHandle handle, void *block, size_t size); size_t GetExpHeapTotalFreeSize(HeapHandle handle); size_t GetExpHeapAllocatableSize(HeapHandle handle, s32 alignment); AllocationMode GetExpHeapAllocationMode(HeapHandle handle); AllocationMode SetExpHeapAllocationMode(HeapHandle handle, AllocationMode new_mode); bool GetExpHeapUseMarginsOfAlignment(HeapHandle handle); bool SetExpHeapUseMarginsOfAlignment(HeapHandle handle, bool use_margins); u16 GetExpHeapGroupId(HeapHandle handle); u16 SetExpHeapGroupId(HeapHandle handle, u16 group_id); size_t GetExpHeapMemoryBlockSize(const void *memory_block); u16 GetExpHeapMemoryBlockGroupId(const void *memory_block); AllocationDirection GetExpHeapMemoryBlockAllocationDirection(const void *memory_block); void VisitExpHeapAllocatedBlocks(HeapHandle handle, HeapVisitor visitor, uintptr_t user_data); }
1,989
C++
.h
38
48.815789
98
0.788253
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,389
lmem_impl_unit_heap.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lmem/impl/lmem_impl_unit_heap.hpp
/* * 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 "lmem_impl_common_heap.hpp" namespace ams::lmem::impl { HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, s32 alignment, u16 option, InfoPlacement info_placement, HeapCommonHead *heap_head); void DestroyUnitHeap(HeapHandle handle); void InvalidateUnitHeap(HeapHandle handle); void ExtendUnitHeap(HeapHandle handle, size_t size); void *AllocateFromUnitHeap(HeapHandle handle); void FreeToUnitHeap(HeapHandle handle, void *block); size_t GetUnitHeapUnitSize(HeapHandle handle); s32 GetUnitHeapAlignment(HeapHandle handle); size_t GetUnitHeapFreeCount(HeapHandle handle); size_t GetUnitHeapUsedCount(HeapHandle handle); size_t GetUnitHeapRequiredSize(size_t unit_size, size_t unit_count, s32 alignment, bool internal_metadata); }
1,496
C++
.h
31
45.193548
161
0.76902
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,390
mitm_pm.os.horizon.h
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/mitm/mitm_pm.os.horizon.h
/* * 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 <switch.h> #ifdef __cplusplus extern "C" { #endif typedef struct { u64 keys_down; u64 flags; } CfgOverrideStatus; Result amsMitmPmInitialize(void); void amsMitmPmExit(void); Service *amsMitmPmGetServiceSession(void); Result amsMitmPmPrepareLaunchProgram(u64 *out, u64 program_id, const CfgOverrideStatus *status, bool is_application); #ifdef __cplusplus } #endif
1,033
C++
.h
31
31.451613
117
0.774323
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,391
gpio_remote_manager_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/gpio_remote_manager_impl.hpp
/* * 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 "gpio_remote_pad_session_impl.hpp" namespace ams::gpio { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteManagerImpl { public: RemoteManagerImpl() { /* ... */ } ~RemoteManagerImpl() { /* ... */ } public: /* Actual commands. */ Result OpenSessionForDev(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, s32 pad_descriptor) { /* TODO: libnx bindings */ AMS_UNUSED(out, pad_descriptor); AMS_ABORT(); } Result OpenSession(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name); Result OpenSessionForTest(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name) { /* TODO: libnx bindings */ AMS_UNUSED(out, pad_name); AMS_ABORT(); } Result IsWakeEventActive(ams::sf::Out<bool> out, gpio::GpioPadName pad_name) { R_RETURN(::gpioIsWakeEventActive2(out.GetPointer(), static_cast<::GpioPadName>(static_cast<u32>(pad_name)))); } Result GetWakeEventActiveFlagSet(ams::sf::Out<gpio::WakeBitFlag> out) { /* TODO: libnx bindings */ AMS_UNUSED(out); AMS_ABORT(); } Result SetWakeEventActiveFlagSetForDebug(gpio::GpioPadName pad_name, bool is_enabled) { /* TODO: libnx bindings */ AMS_UNUSED(pad_name, is_enabled); AMS_ABORT(); } Result SetWakePinDebugMode(s32 mode) { /* TODO: libnx bindings */ AMS_UNUSED(mode); AMS_ABORT(); } Result OpenSession2(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, DeviceCode device_code, ddsf::AccessMode access_mode); Result IsWakeEventActive2(ams::sf::Out<bool> out, DeviceCode device_code) { R_RETURN(::gpioIsWakeEventActive2(out.GetPointer(), device_code.GetInternalValue())); } Result SetWakeEventActiveFlagSetForDebug2(DeviceCode device_code, bool is_enabled) { /* TODO: libnx bindings */ AMS_UNUSED(device_code, is_enabled); AMS_ABORT(); } Result SetRetryValues(u32 arg0, u32 arg1) { /* TODO: libnx bindings */ AMS_UNUSED(arg0, arg1); AMS_ABORT(); } }; static_assert(gpio::sf::IsIManager<RemoteManagerImpl>); #endif }
3,327
C++
.h
73
34.863014
151
0.597407
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,392
gpio_remote_pad_session_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp
/* * 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> namespace ams::gpio { #if defined(ATMOSPHERE_OS_HORIZON) class RemotePadSessionImpl { private: ::GpioPadSession m_srv; public: RemotePadSessionImpl(::GpioPadSession &p) : m_srv(p) { /* ... */ } ~RemotePadSessionImpl() { ::gpioPadClose(std::addressof(m_srv)); } public: /* Actual commands. */ Result SetDirection(gpio::Direction direction) { R_RETURN(::gpioPadSetDirection(std::addressof(m_srv), static_cast<::GpioDirection>(static_cast<u32>(direction)))); } Result GetDirection(ams::sf::Out<gpio::Direction> out) { static_assert(sizeof(gpio::Direction) == sizeof(::GpioDirection)); R_RETURN(::gpioPadGetDirection(std::addressof(m_srv), reinterpret_cast<::GpioDirection *>(out.GetPointer()))); } Result SetInterruptMode(gpio::InterruptMode mode) { R_RETURN(::gpioPadSetInterruptMode(std::addressof(m_srv), static_cast<::GpioInterruptMode>(static_cast<u32>(mode)))); } Result GetInterruptMode(ams::sf::Out<gpio::InterruptMode> out) { static_assert(sizeof(gpio::InterruptMode) == sizeof(::GpioInterruptMode)); R_RETURN(::gpioPadGetInterruptMode(std::addressof(m_srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer()))); } Result SetInterruptEnable(bool enable) { R_RETURN(::gpioPadSetInterruptEnable(std::addressof(m_srv), enable)); } Result GetInterruptEnable(ams::sf::Out<bool> out) { R_RETURN(::gpioPadGetInterruptEnable(std::addressof(m_srv), out.GetPointer())); } Result GetInterruptStatus(ams::sf::Out<gpio::InterruptStatus> out) { static_assert(sizeof(gpio::InterruptStatus) == sizeof(::GpioInterruptStatus)); R_RETURN(::gpioPadGetInterruptStatus(std::addressof(m_srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer()))); } Result ClearInterruptStatus() { R_RETURN(::gpioPadClearInterruptStatus(std::addressof(m_srv))); } Result SetValue(gpio::GpioValue value) { R_RETURN(::gpioPadSetValue(std::addressof(m_srv), static_cast<::GpioValue>(static_cast<u32>(value)))); } Result GetValue(ams::sf::Out<gpio::GpioValue> out) { static_assert(sizeof(gpio::GpioValue) == sizeof(::GpioValue)); R_RETURN(::gpioPadGetValue(std::addressof(m_srv), reinterpret_cast<::GpioValue *>(out.GetPointer()))); } Result BindInterrupt(ams::sf::OutCopyHandle out) { ::Event ev; R_TRY(::gpioPadBindInterrupt(std::addressof(m_srv), std::addressof(ev))); out.SetValue(ev.revent, true); R_SUCCEED(); } Result UnbindInterrupt() { R_RETURN(::gpioPadUnbindInterrupt(std::addressof(m_srv))); } Result SetDebounceEnabled(bool enable) { R_RETURN(::gpioPadSetDebounceEnabled(std::addressof(m_srv), enable)); } Result GetDebounceEnabled(ams::sf::Out<bool> out) { R_RETURN(::gpioPadGetDebounceEnabled(std::addressof(m_srv), out.GetPointer())); } Result SetDebounceTime(s32 ms) { R_RETURN(::gpioPadSetDebounceTime(std::addressof(m_srv), ms)); } Result GetDebounceTime(ams::sf::Out<s32> out) { R_RETURN(::gpioPadGetDebounceTime(std::addressof(m_srv), out.GetPointer())); } Result SetValueForSleepState(gpio::GpioValue value) { /* TODO: libnx bindings. */ AMS_UNUSED(value); AMS_ABORT(); } Result GetValueForSleepState(ams::sf::Out<gpio::GpioValue> out) { /* TODO: libnx bindings. */ AMS_UNUSED(out); AMS_ABORT(); } }; static_assert(gpio::sf::IsIPadSession<RemotePadSessionImpl>); #endif }
4,857
C++
.h
96
38.9375
138
0.604219
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,393
gpio_driver_core.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/impl/gpio_driver_core.hpp
/* * 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> namespace ams::gpio::driver::impl { void InitializeDrivers(); void FinalizeDrivers(); void RegisterDriver(IGpioDriver *driver); void UnregisterDriver(IGpioDriver *driver); Result RegisterDeviceCode(DeviceCode device_code, Pad *pad); bool UnregisterDeviceCode(DeviceCode device_code); void RegisterInterruptHandler(ddsf::IEventHandler *handler); void UnregisterInterruptHandler(ddsf::IEventHandler *handler); Result FindPad(Pad **out, DeviceCode device_code); Result FindPadByNumber(Pad **out, int pad_number); }
1,235
C++
.h
29
39.482759
76
0.764804
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,394
gpio_driver_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.hpp
/* * 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 "gpio_tegra_pad.hpp" #include "gpio_register_accessor.hpp" #include "gpio_suspend_handler.hpp" namespace ams::gpio::driver::board::nintendo::nx::impl { class DriverImpl; class InterruptEventHandler : public ddsf::IEventHandler { private: DriverImpl *m_driver; os::InterruptName m_interrupt_name; os::InterruptEventType m_interrupt_event; int m_controller_number; private: bool CheckAndHandleInterrupt(TegraPad &pad); public: InterruptEventHandler() : IEventHandler(), m_driver(nullptr), m_interrupt_name(), m_interrupt_event(), m_controller_number() { /* ... */ } void Initialize(DriverImpl *drv, os::InterruptName intr, int ctlr); virtual void HandleEvent() override; }; class DriverImpl : public ::ams::gpio::driver::IGpioDriver { NON_COPYABLE(DriverImpl); NON_MOVEABLE(DriverImpl); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::board::nintendo::nx::impl::DriverImpl, ::ams::gpio::driver::IGpioDriver); friend class InterruptEventHandler; private: dd::PhysicalAddress m_gpio_physical_address; uintptr_t m_gpio_virtual_address; SuspendHandler m_suspend_handler; TegraPad::InterruptList m_interrupt_pad_list; mutable os::SdkMutex m_interrupt_control_mutex; public: DriverImpl(dd::PhysicalAddress reg_paddr, size_t size); virtual void InitializeDriver() override; virtual void FinalizeDriver() override; virtual Result InitializePad(Pad *pad) override; virtual void FinalizePad(Pad *pad) override; virtual Result GetDirection(Direction *out, Pad *pad) const override; virtual Result SetDirection(Pad *pad, Direction direction) override; virtual Result GetValue(GpioValue *out, Pad *pad) const override; virtual Result SetValue(Pad *pad, GpioValue value) override; virtual Result GetInterruptMode(InterruptMode *out, Pad *pad) const override; virtual Result SetInterruptMode(Pad *pad, InterruptMode mode) override; virtual Result SetInterruptEnabled(Pad *pad, bool en) override; virtual Result GetInterruptStatus(InterruptStatus *out, Pad *pad) override; virtual Result ClearInterruptStatus(Pad *pad) override; virtual os::SdkMutex &GetInterruptControlMutex(const Pad &pad) const override { AMS_UNUSED(pad); return m_interrupt_control_mutex; } virtual Result GetDebounceEnabled(bool *out, Pad *pad) const override; virtual Result SetDebounceEnabled(Pad *pad, bool en) override; virtual Result GetDebounceTime(s32 *out_ms, Pad *pad) const override; virtual Result SetDebounceTime(Pad *pad, s32 ms) override; virtual Result GetUnknown22(u32 *out) override; virtual void Unknown23() override; virtual Result SetValueForSleepState(Pad *pad, GpioValue value) override; virtual Result IsWakeEventActive(bool *out, Pad *pad) const override; virtual Result SetWakeEventActiveFlagSetForDebug(Pad *pad, bool en) override; virtual Result SetWakePinDebugMode(WakePinDebugMode mode) override; virtual Result Suspend() override; virtual Result SuspendLow() override; virtual Result Resume() override; virtual Result ResumeLow() override; private: static constexpr ALWAYS_INLINE TegraPad &GetTegraPad(Pad *pad) { AMS_ASSERT(pad != nullptr); return static_cast<TegraPad &>(*pad); } static ALWAYS_INLINE const PadInfo &GetInfo(Pad *pad) { return GetTegraPad(pad).GetInfo(); } static ALWAYS_INLINE PadStatus &GetStatus(Pad *pad) { return GetTegraPad(pad).GetStatus(); } void AddInterruptPad(TegraPad *pad) { AMS_ASSERT(pad != nullptr); if (!pad->IsLinkedToInterruptBoundPadList()) { m_interrupt_pad_list.push_back(*pad); } } void RemoveInterruptPad(TegraPad *pad) { AMS_ASSERT(pad != nullptr); if (pad->IsLinkedToInterruptBoundPadList()) { m_interrupt_pad_list.erase(m_interrupt_pad_list.iterator_to(*pad)); } } }; }
5,338
C++
.h
104
40.644231
150
0.641198
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,395
gpio_tegra_pad.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_tegra_pad.hpp
/* * 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> namespace ams::gpio::driver::board::nintendo::nx::impl { enum GpioPadPort { GpioPadPort_A = 0, GpioPadPort_B = 1, GpioPadPort_C = 2, GpioPadPort_D = 3, GpioPadPort_E = 4, GpioPadPort_F = 5, GpioPadPort_G = 6, GpioPadPort_H = 7, GpioPadPort_I = 8, GpioPadPort_J = 9, GpioPadPort_K = 10, GpioPadPort_L = 11, GpioPadPort_M = 12, GpioPadPort_N = 13, GpioPadPort_O = 14, GpioPadPort_P = 15, GpioPadPort_Q = 16, GpioPadPort_R = 17, GpioPadPort_S = 18, GpioPadPort_T = 19, GpioPadPort_U = 20, GpioPadPort_V = 21, GpioPadPort_W = 22, GpioPadPort_X = 23, GpioPadPort_Y = 24, GpioPadPort_Z = 25, GpioPadPort_AA = 26, GpioPadPort_BB = 27, GpioPadPort_CC = 28, GpioPadPort_DD = 29, GpioPadPort_EE = 30, GpioPadPort_FF = 31, GpioPadPort_Count = 32, }; using InternalGpioPadNumber = int; constexpr unsigned int GetInternalGpioPadNumber(GpioPadPort port, unsigned int which) { AMS_ASSERT(which < 8); return (static_cast<unsigned int>(port) * 8) + which; } constexpr inline InternalGpioPadNumber InternalGpioPadNumber_None = -1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_0 = 0x00; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_1 = 0x01; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_2 = 0x02; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_3 = 0x03; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_4 = 0x04; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_5 = 0x05; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_6 = 0x06; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_7 = 0x07; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_0 = 0x08; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_1 = 0x09; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_2 = 0x0A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_3 = 0x0B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_4 = 0x0C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_5 = 0x0D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_6 = 0x0E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_7 = 0x0F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_0 = 0x10; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_1 = 0x11; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_2 = 0x12; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_3 = 0x13; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_4 = 0x14; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_5 = 0x15; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_6 = 0x16; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_7 = 0x17; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_0 = 0x18; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_1 = 0x19; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_2 = 0x1A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_3 = 0x1B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_4 = 0x1C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_5 = 0x1D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_6 = 0x1E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_7 = 0x1F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_0 = 0x20; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_1 = 0x21; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_2 = 0x22; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_3 = 0x23; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_4 = 0x24; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_5 = 0x25; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_6 = 0x26; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_7 = 0x27; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_0 = 0x28; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_1 = 0x29; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_2 = 0x2A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_3 = 0x2B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_4 = 0x2C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_5 = 0x2D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_6 = 0x2E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_7 = 0x2F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_0 = 0x30; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_1 = 0x31; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_2 = 0x32; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_3 = 0x33; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_4 = 0x34; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_5 = 0x35; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_6 = 0x36; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_7 = 0x37; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_0 = 0x38; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_1 = 0x39; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_2 = 0x3A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_3 = 0x3B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_4 = 0x3C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_5 = 0x3D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_6 = 0x3E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_7 = 0x3F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_0 = 0x40; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_1 = 0x41; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_2 = 0x42; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_3 = 0x43; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_4 = 0x44; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_5 = 0x45; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_6 = 0x46; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_7 = 0x47; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_0 = 0x48; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_1 = 0x49; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_2 = 0x4A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_3 = 0x4B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_4 = 0x4C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_5 = 0x4D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_6 = 0x4E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_7 = 0x4F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_0 = 0x50; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_1 = 0x51; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_2 = 0x52; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_3 = 0x53; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_4 = 0x54; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_5 = 0x55; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_6 = 0x56; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_7 = 0x57; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_0 = 0x58; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_1 = 0x59; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_2 = 0x5A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_3 = 0x5B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_4 = 0x5C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_5 = 0x5D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_6 = 0x5E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_7 = 0x5F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_0 = 0x60; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_1 = 0x61; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_2 = 0x62; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_3 = 0x63; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_4 = 0x64; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_5 = 0x65; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_6 = 0x66; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_7 = 0x67; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_0 = 0x68; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_1 = 0x69; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_2 = 0x6A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_3 = 0x6B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_4 = 0x6C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_5 = 0x6D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_6 = 0x6E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_7 = 0x6F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_0 = 0x70; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_1 = 0x71; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_2 = 0x72; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_3 = 0x73; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_4 = 0x74; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_5 = 0x75; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_6 = 0x76; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_7 = 0x77; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_0 = 0x78; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_1 = 0x79; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_2 = 0x7A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_3 = 0x7B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_4 = 0x7C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_5 = 0x7D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_6 = 0x7E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_7 = 0x7F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_0 = 0x80; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_1 = 0x81; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_2 = 0x82; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_3 = 0x83; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_4 = 0x84; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_5 = 0x85; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_6 = 0x86; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_7 = 0x87; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_0 = 0x88; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_1 = 0x89; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_2 = 0x8A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_3 = 0x8B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_4 = 0x8C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_5 = 0x8D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_6 = 0x8E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_7 = 0x8F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_0 = 0x90; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_1 = 0x91; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_2 = 0x92; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_3 = 0x93; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_4 = 0x94; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_5 = 0x95; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_6 = 0x96; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_7 = 0x97; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_0 = 0x98; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_1 = 0x99; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_2 = 0x9A; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_3 = 0x9B; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_4 = 0x9C; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_5 = 0x9D; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_6 = 0x9E; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_7 = 0x9F; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_0 = 0xA0; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_1 = 0xA1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_2 = 0xA2; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_3 = 0xA3; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_4 = 0xA4; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_5 = 0xA5; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_6 = 0xA6; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_7 = 0xA7; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_0 = 0xA8; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_1 = 0xA9; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_2 = 0xAA; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_3 = 0xAB; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_4 = 0xAC; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_5 = 0xAD; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_6 = 0xAE; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_7 = 0xAF; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_0 = 0xB0; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_1 = 0xB1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_2 = 0xB2; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_3 = 0xB3; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_4 = 0xB4; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_5 = 0xB5; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_6 = 0xB6; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_7 = 0xB7; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_0 = 0xB8; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_1 = 0xB9; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_2 = 0xBA; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_3 = 0xBB; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_4 = 0xBC; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_5 = 0xBD; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_6 = 0xBE; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_7 = 0xBF; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_0 = 0xC0; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_1 = 0xC1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_2 = 0xC2; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_3 = 0xC3; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_4 = 0xC4; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_5 = 0xC5; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_6 = 0xC6; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_7 = 0xC7; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_0 = 0xC8; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_1 = 0xC9; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_2 = 0xCA; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_3 = 0xCB; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_4 = 0xCC; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_5 = 0xCD; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_6 = 0xCE; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_7 = 0xCF; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_0 = 0xD0; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_1 = 0xD1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_2 = 0xD2; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_3 = 0xD3; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_4 = 0xD4; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_5 = 0xD5; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_6 = 0xD6; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_7 = 0xD7; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_0 = 0xD8; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_1 = 0xD9; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_2 = 0xDA; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_3 = 0xDB; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_4 = 0xDC; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_5 = 0xDD; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_6 = 0xDE; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_7 = 0xDF; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_0 = 0xE0; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_1 = 0xE1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_2 = 0xE2; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_3 = 0xE3; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_4 = 0xE4; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_5 = 0xE5; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_6 = 0xE6; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_7 = 0xE7; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_0 = 0xE8; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_1 = 0xE9; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_2 = 0xEA; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_3 = 0xEB; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_4 = 0xEC; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_5 = 0xED; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_6 = 0xEE; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_7 = 0xEF; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_0 = 0xF0; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_1 = 0xF1; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_2 = 0xF2; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_3 = 0xF3; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_4 = 0xF4; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_5 = 0xF5; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_6 = 0xF6; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_7 = 0xF7; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_0 = 0xF8; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_1 = 0xF9; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_2 = 0xFA; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_3 = 0xFB; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_4 = 0xFC; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_5 = 0xFD; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_6 = 0xFE; constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_7 = 0xFF; struct PadMapCombination { DeviceCode device_code; InternalGpioPadNumber internal_number; wec::WakeEvent wake_event; }; #include "gpio_internal_pad_map_combination.inc" struct PadInfo { wec::WakeEvent wake_event; constexpr PadInfo() : wake_event(wec::WakeEvent_None) { /* ... */ } constexpr explicit PadInfo(wec::WakeEvent we) : wake_event(we) { /* ... */ } constexpr bool operator ==(const PadInfo &rhs) const { return this->wake_event == rhs.wake_event; } constexpr bool operator !=(const PadInfo &rhs) const { return !(*this == rhs); } }; struct PadStatus { bool is_wake_active; bool is_wake_active_debug; constexpr PadStatus() : is_wake_active(false), is_wake_active_debug(false) { /* ... */ } }; class TegraPad : public ::ams::gpio::driver::Pad { AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::board::nintendo::nx::impl::TegraPad, ::ams::gpio::driver::Pad); private: using Base = ::ams::gpio::driver::Pad; private: util::IntrusiveListNode m_interrupt_list_node; PadInfo m_info; PadStatus m_status; public: using InterruptListTraits = util::IntrusiveListMemberTraits<&TegraPad::m_interrupt_list_node>; using InterruptList = typename InterruptListTraits::ListType; friend class util::IntrusiveList<TegraPad, util::IntrusiveListMemberTraits<&TegraPad::m_interrupt_list_node>>; public: TegraPad() : Pad(), m_interrupt_list_node(), m_info(), m_status() { /* ... */ } const PadInfo &GetInfo() const { return m_info; } PadStatus &GetStatus() { return m_status; } void SetParameters(int pad, const PadInfo &i) { Base::SetPadNumber(pad); m_info = i; } bool IsLinkedToInterruptBoundPadList() const { return m_interrupt_list_node.IsLinked(); } }; }
25,423
C++
.h
358
65.150838
122
0.783638
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,396
gpio_wake_pin_config.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_wake_pin_config.hpp
/* * 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> namespace ams::gpio::driver::board::nintendo::nx::impl { struct WakePinConfig { wec::WakeEvent wake_event; bool enable; wec::WakeEventLevel level; }; }
863
C++
.h
24
32.916667
76
0.73445
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,397
gpio_suspend_handler.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.hpp
/* * 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 "gpio_tegra_pad.hpp" namespace ams::gpio::driver::board::nintendo::nx::impl { class SuspendHandler { NON_COPYABLE(SuspendHandler); NON_MOVEABLE(SuspendHandler); private: struct RegisterValues { u16 conf; u8 oe; u8 out; u8 int_enb; u32 int_lvl; u8 db_ctrl; u8 db_cnt; void Reset() { this->conf = 0; this->oe = 0; this->out = 0; this->int_enb = 0; this->int_lvl = 0; this->db_ctrl = 0; this->db_cnt = 0; } }; struct ValuesForSleepState { u8 force_set; u8 out; void Reset() { this->force_set = 0; this->out = 0; } }; private: ddsf::IDriver &m_driver; uintptr_t m_gpio_virtual_address; RegisterValues m_register_values[GpioPadPort_Count]; ValuesForSleepState m_values_for_sleep_state[GpioPadPort_Count]; private: uintptr_t GetGpioVirtualAddress() const { AMS_ASSERT(m_gpio_virtual_address != 0); return m_gpio_virtual_address; } public: explicit SuspendHandler(ddsf::IDriver *drv) : m_driver(*drv), m_gpio_virtual_address(0) { for (auto &rv : m_register_values) { rv.Reset(); } for (auto &v : m_values_for_sleep_state) { v.Reset(); } } void Initialize(uintptr_t gpio_vaddr); void SetValueForSleepState(TegraPad *pad, GpioValue value); Result IsWakeEventActive(bool *out, TegraPad *pad) const; Result SetWakeEventActiveFlagSetForDebug(TegraPad *pad, bool en); void SetWakePinDebugMode(WakePinDebugMode mode); void Suspend(); void SuspendLow(); void Resume(); void ResumeLow(); }; }
2,928
C++
.h
79
25.227848
101
0.532582
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,398
gpio_register_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_register_accessor.hpp
/* * 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 "gpio_tegra_pad.hpp" namespace ams::gpio::driver::board::nintendo::nx::impl { constexpr inline dd::PhysicalAddress GpioRegistersPhysicalAddress = 0x6000D000; constexpr inline size_t GpioRegistersSize = 4_KB; constexpr inline int GpioPerControllerBitWidth = 5; constexpr inline int GpioControllerBitWidth = 3; constexpr inline int PortPerControllerBitWidth = 2; constexpr inline int PortPerController = (1 << PortPerControllerBitWidth); constexpr inline int GpioPerPortBitWidth = 3; constexpr inline int GpioPerPort = (1 << GpioPerPortBitWidth); static_assert(PortPerControllerBitWidth + GpioPerPortBitWidth == GpioPerControllerBitWidth); static_assert(PortPerController * GpioPerPort == (1 << GpioPerControllerBitWidth)); constexpr int ConvertInternalGpioPadNumberToController(InternalGpioPadNumber number) { return (number >> GpioPerControllerBitWidth); } constexpr int ConvertInternalGpioPadNumberToPort(InternalGpioPadNumber number) { return (number >> GpioControllerBitWidth); } constexpr InternalGpioPadNumber ConvertPortToInternalGpioPadNumber(int port) { return static_cast<InternalGpioPadNumber>(port << GpioControllerBitWidth); } constexpr int ConvertInternalGpioPadNumberToBitIndex(InternalGpioPadNumber number) { return (number & (GpioPerPort - 1)); } constexpr int ConvertPortNumberToOffset(int port_number) { return (port_number & (PortPerController - 1)); } enum GpioController { GpioController_1 = 0, GpioController_2 = 1, GpioController_3 = 2, GpioController_4 = 3, GpioController_5 = 4, GpioController_6 = 5, GpioController_7 = 6, GpioController_8 = 7, GpioController_Count = 8, }; static_assert(GpioController_Count == static_cast<GpioController>(1 << GpioControllerBitWidth)); constexpr inline os::InterruptName InterruptNameTable[GpioController_Count] = { 64, /* GpioController_1 */ 65, /* GpioController_2 */ 66, /* GpioController_3 */ 67, /* GpioController_4 */ 87, /* GpioController_5 */ 119, /* GpioController_6 */ 121, /* GpioController_7 */ 157, /* GpioController_8 */ }; enum InternalInterruptMode { InternalInterruptMode_LowLevel = 0x000000, InternalInterruptMode_HighLevel = 0x000001, InternalInterruptMode_RisingEdge = 0x000101, InternalInterruptMode_FallingEdge = 0x000100, InternalInterruptMode_AnyEdge = 0x010100, InternalInterruptMode_Mask = 0x010101, }; enum GpioRegisterType { GpioRegisterType_GPIO_CNF = 0, GpioRegisterType_GPIO_OE = 1, GpioRegisterType_GPIO_OUT = 2, GpioRegisterType_GPIO_IN = 3, GpioRegisterType_GPIO_INT_STA = 4, GpioRegisterType_GPIO_INT_ENB = 5, GpioRegisterType_GPIO_INT_LVL = 6, GpioRegisterType_GPIO_INT_CLR = 7, GpioRegisterType_GPIO_DB_CTRL = 8, GpioRegisterType_GPIO_DB_CNT = 9, }; constexpr inline uintptr_t MaskedWriteAddressOffset = 0x80; constexpr inline int MaskedWriteBitOffset = 8; constexpr inline uintptr_t GetGpioRegisterAddress(uintptr_t gpio_address, GpioRegisterType reg_type, InternalGpioPadNumber pad_number) { const auto controller = ConvertInternalGpioPadNumberToController(pad_number); const auto port = ConvertInternalGpioPadNumberToPort(pad_number); const auto offset = ConvertPortNumberToOffset(port); switch (reg_type) { default: return gpio_address + (0x100 * controller) + (0x10 * reg_type) + (0x4 * offset); case GpioRegisterType_GPIO_DB_CTRL: return gpio_address + (0x100 * controller) + (0x10 * GpioRegisterType_GPIO_IN) + (0x4 * offset); case GpioRegisterType_GPIO_DB_CNT: return gpio_address + (0x100 * controller) + MaskedWriteAddressOffset + (0x10 * GpioRegisterType_GPIO_INT_CLR) + (0x4 * offset); } } inline void SetMaskedBit(uintptr_t pad_address, int index, int value) { const uintptr_t mask_address = pad_address + MaskedWriteAddressOffset; reg::Write(mask_address, (1u << (MaskedWriteBitOffset + index)) | (static_cast<unsigned int>(value) << index)); } inline void SetMaskedBits(uintptr_t pad_address, unsigned int mask, unsigned int value) { const uintptr_t mask_address = pad_address + MaskedWriteAddressOffset; reg::Write(mask_address, (mask << MaskedWriteBitOffset) | (value)); } }
5,455
C++
.h
110
42.663636
144
0.68609
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,399
gpio_initial_config.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_initial_config.hpp
/* * 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> namespace ams::gpio::driver::board::nintendo::nx::impl { struct GpioInitialConfig { DeviceCode device_code; gpio::Direction direction; gpio::GpioValue value; }; void SetInitialGpioConfig(); void SetInitialWakePinConfig(); }
949
C++
.h
26
33.269231
76
0.735582
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,400
gpio_server_manager_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.hpp
/* * 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 "gpio_server_pad_session_impl.hpp" namespace ams::gpio::server { class ManagerImpl : public ams::sf::ISharedObject { private: using Allocator = ams::sf::ExpHeapAllocator; using Factory = ams::sf::ObjectFactory<Allocator::Policy>; private: lmem::HeapHandle m_heap_handle; Allocator m_pad_allocator; u8 m_heap_buffer[12_KB]; public: ManagerImpl(); ~ManagerImpl(); public: /* Actual commands. */ Result OpenSessionForDev(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, s32 pad_descriptor); Result OpenSession(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name); Result OpenSessionForTest(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name); Result IsWakeEventActive(ams::sf::Out<bool> out, gpio::GpioPadName pad_name); Result GetWakeEventActiveFlagSet(ams::sf::Out<gpio::WakeBitFlag> out); Result SetWakeEventActiveFlagSetForDebug(gpio::GpioPadName pad_name, bool is_enabled); Result SetWakePinDebugMode(s32 mode); Result OpenSession2(ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, DeviceCode device_code, ddsf::AccessMode access_mode); Result IsWakeEventActive2(ams::sf::Out<bool> out, DeviceCode device_code); Result SetWakeEventActiveFlagSetForDebug2(DeviceCode device_code, bool is_enabled); Result SetRetryValues(u32 arg0, u32 arg1); }; static_assert(gpio::sf::IsIManager<ManagerImpl>); }
2,372
C++
.h
46
44.23913
151
0.689789
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,401
gpio_server_pad_session_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/gpio/server/gpio_server_pad_session_impl.hpp
/* * 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> namespace ams::gpio::server { class ManagerImpl; class PadSessionImpl { private: ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ gpio::driver::GpioPadSession m_internal_pad_session; bool m_has_session; os::SystemEvent m_system_event; public: explicit PadSessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ } ~PadSessionImpl() { if (m_has_session) { gpio::driver::CloseSession(std::addressof(m_internal_pad_session)); } } Result OpenSession(DeviceCode device_code, ddsf::AccessMode access_mode) { AMS_ABORT_UNLESS(!m_has_session); R_TRY(gpio::driver::OpenSession(std::addressof(m_internal_pad_session), device_code, access_mode)); m_has_session = true; R_SUCCEED(); } public: /* Actual commands. */ Result SetDirection(gpio::Direction direction) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* Validate the direction. */ R_UNLESS((direction == Direction_Input || direction == Direction_Output), gpio::ResultInvalidArgument()); /* Invoke the driver library. */ R_TRY(gpio::driver::SetDirection(std::addressof(m_internal_pad_session), direction)); R_SUCCEED(); } Result GetDirection(ams::sf::Out<gpio::Direction> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* Invoke the driver library. */ R_TRY(gpio::driver::GetDirection(out.GetPointer(), std::addressof(m_internal_pad_session))); R_SUCCEED(); } Result SetInterruptMode(gpio::InterruptMode mode) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(mode); AMS_ABORT(); } Result GetInterruptMode(ams::sf::Out<gpio::InterruptMode> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } Result SetInterruptEnable(bool enable) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(enable); AMS_ABORT(); } Result GetInterruptEnable(ams::sf::Out<bool> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } Result GetInterruptStatus(ams::sf::Out<gpio::InterruptStatus> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } Result ClearInterruptStatus() { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_ABORT(); } Result SetValue(gpio::GpioValue value) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* Validate the value. */ R_UNLESS((value == GpioValue_Low || value == GpioValue_High), gpio::ResultInvalidArgument()); /* Invoke the driver library. */ R_TRY(gpio::driver::SetValue(std::addressof(m_internal_pad_session), value)); R_SUCCEED(); } Result GetValue(ams::sf::Out<gpio::GpioValue> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* Invoke the driver library. */ R_TRY(gpio::driver::GetValue(out.GetPointer(), std::addressof(m_internal_pad_session))); R_SUCCEED(); } Result BindInterrupt(ams::sf::OutCopyHandle out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } Result UnbindInterrupt() { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_ABORT(); } Result SetDebounceEnabled(bool enable) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(enable); AMS_ABORT(); } Result GetDebounceEnabled(ams::sf::Out<bool> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } Result SetDebounceTime(s32 ms) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(ms); AMS_ABORT(); } Result GetDebounceTime(ams::sf::Out<s32> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } Result SetValueForSleepState(gpio::GpioValue value) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(value); AMS_ABORT(); } Result GetValueForSleepState(ams::sf::Out<gpio::GpioValue> out) { /* Validate our state. */ AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); AMS_ABORT(); } }; static_assert(gpio::sf::IsIPadSession<PadSessionImpl>); }
6,932
C++
.h
171
26.426901
121
0.494712
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,402
pgl_remote_event_observer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp
/* * 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> namespace ams::pgl { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteEventObserver { NON_COPYABLE(RemoteEventObserver); NON_MOVEABLE(RemoteEventObserver); private: ::PglEventObserver m_observer; public: constexpr RemoteEventObserver(const ::PglEventObserver &o) : m_observer(o) { /* ... */ } ~RemoteEventObserver() { ::pglEventObserverClose(std::addressof(m_observer)); } Result GetProcessEventHandle(ams::sf::OutCopyHandle out) { ::Event ev; ON_RESULT_SUCCESS { out.SetValue(ev.revent, true); }; R_RETURN(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); } Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); R_RETURN(::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()))); } Result GetProcessEventHandle(ams::tipc::OutCopyHandle out) { ::Event ev; ON_RESULT_SUCCESS { out.SetValue(ev.revent); }; R_RETURN(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); } Result GetProcessEventInfo(ams::tipc::Out<pm::ProcessEventInfo> out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); R_RETURN(::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()))); } }; static_assert(pgl::sf::IsIEventObserver<RemoteEventObserver>); static_assert(pgl::tipc::IsIEventObserver<RemoteEventObserver>); #endif }
2,573
C++
.h
52
40.826923
152
0.662953
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,403
pgl_srv_shell_host_utils.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.hpp
/* * 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> namespace ams::pgl::srv { Result LaunchProgramFromHost(os::ProcessId *out, const char *content_path, u32 pm_flags); Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path); }
889
C++
.h
21
40.142857
93
0.76185
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,404
pgl_srv_shell.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.hpp
/* * 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> namespace ams::pgl::srv { void InitializeProcessControlTask(); class ShellEventObserverHolder; void RegisterShellEventObserver(ShellEventObserverHolder *holder); void UnregisterShellEventObserver(ShellEventObserverHolder *holder); Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags); Result TerminateProcess(os::ProcessId process_id); Result GetApplicationProcessId(os::ProcessId *out); Result BoostSystemMemoryResourceLimit(u64 size); bool IsProcessTracked(os::ProcessId process_id); void EnableApplicationCrashReport(bool enabled); bool IsApplicationCrashReportEnabled(); void EnableApplicationAllThreadDumpOnCrash(bool enabled); Result TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const char *arg); }
1,504
C++
.h
32
43.75
106
0.786494
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,405
pgl_srv_tipc_utils.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pgl/srv/pgl_srv_tipc_utils.hpp
/* * 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> namespace ams::pgl::srv { Result AllocateShellEventObserverForTipc(os::NativeHandle *out); }
776
C++
.h
20
36.75
76
0.763612
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,406
pgl_srv_shell_event_observer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp
/* * 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> namespace ams::pgl::srv { class IShellEventObserver { public: virtual void Notify(const pm::ProcessEventInfo &info) = 0; }; class ShellEventObserverHolder : public util::IntrusiveListBaseNode<ShellEventObserverHolder> { private: IShellEventObserver *m_observer; public: explicit ShellEventObserverHolder(IShellEventObserver *observer) : m_observer(observer) { /* ... */ } void Notify(const pm::ProcessEventInfo &info) { m_observer->Notify(info); } }; class ShellEventObserverImpl : public IShellEventObserver { private: static constexpr size_t QueueCapacity = 0x20; private: os::MessageQueue m_message_queue; uintptr_t m_queue_buffer[QueueCapacity]; os::SystemEvent m_event; util::TypedStorage<lmem::HeapCommonHead> m_heap_head; lmem::HeapHandle m_heap_handle; pm::ProcessEventInfo m_event_info_data[QueueCapacity]; util::TypedStorage<ShellEventObserverHolder> m_holder; public: ShellEventObserverImpl(); ~ShellEventObserverImpl(); os::SystemEvent &GetEvent() { return m_event; } Result PopEventInfo(pm::ProcessEventInfo *out); virtual void Notify(const pm::ProcessEventInfo &info) override final; }; class ShellEventObserverCmif : public ShellEventObserverImpl { public: Result GetProcessEventHandle(ams::sf::OutCopyHandle out); Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out); }; static_assert(pgl::sf::IsIEventObserver<ShellEventObserverCmif>); class ShellEventObserverTipc : public ShellEventObserverImpl { public: Result GetProcessEventHandle(ams::tipc::OutCopyHandle out); Result GetProcessEventInfo(ams::tipc::Out<pm::ProcessEventInfo> out); }; static_assert(pgl::tipc::IsIEventObserver<ShellEventObserverTipc>); }
2,748
C++
.h
64
34.984375
113
0.678638
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,407
usb_remote_ds_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/usb/usb_remote_ds_interface.hpp
/* * 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> namespace ams::usb { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteDsInterface { private: using Allocator = sf::ExpHeapAllocator; using ObjectFactory = sf::ObjectFactory<Allocator::Policy>; private: Service m_srv; Allocator *m_allocator; public: RemoteDsInterface(Service &srv, sf::ExpHeapAllocator *allocator) : m_srv(srv), m_allocator(allocator) { /* ... */ } virtual ~RemoteDsInterface() { serviceClose(std::addressof(m_srv)); } public: Result RegisterEndpoint(u8 endpoint_address, sf::Out<sf::SharedPointer<usb::ds::IDsEndpoint>> out); Result GetSetupEvent(sf::OutCopyHandle out); Result GetSetupPacket(const sf::OutBuffer & out); Result CtrlInAsync(sf::Out<u32> out_urb_id, u64 address, u32 size); Result CtrlOutAsync(sf::Out<u32> out_urb_id, u64 address, u32 size); Result GetCtrlInCompletionEvent(sf::OutCopyHandle out); Result GetCtrlInUrbReport(sf::Out<usb::UrbReport> out); Result GetCtrlOutCompletionEvent(sf::OutCopyHandle out); Result GetCtrlOutUrbReport(sf::Out<usb::UrbReport> out); Result CtrlStall(); Result AppendConfigurationData(u8 bInterfaceNumber, usb::UsbDeviceSpeed device_speed, const sf::InBuffer &data); Result Enable(); Result Disable(); }; static_assert(ds::IsIDsInterface<RemoteDsInterface>); #endif }
2,196
C++
.h
47
39.404255
127
0.67987
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,408
usb_remote_ds_endpoint.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.hpp
/* * 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> namespace ams::usb { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteDsEndpoint { private: Service m_srv; public: RemoteDsEndpoint(Service &srv) : m_srv(srv) { /* ... */ } virtual ~RemoteDsEndpoint() { serviceClose(std::addressof(m_srv)); } public: Result PostBufferAsync(sf::Out<u32> out_urb_id, u64 address, u32 size); Result Cancel(); Result GetCompletionEvent(sf::OutCopyHandle out); Result GetUrbReport(sf::Out<usb::UrbReport> out); Result Stall(); Result SetZlt(bool zlt); }; static_assert(ds::IsIDsEndpoint<RemoteDsEndpoint>); #endif }
1,373
C++
.h
36
32.444444
83
0.676912
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,409
usb_remote_ds_root_session.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/usb/usb_remote_ds_root_session.hpp
/* * 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> namespace ams::usb { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteDsRootSession { private: using Allocator = sf::ExpHeapAllocator; using ObjectFactory = sf::ObjectFactory<Allocator::Policy>; private: Service m_srv; Allocator *m_allocator; public: RemoteDsRootSession(Service &srv, sf::ExpHeapAllocator *allocator) : m_srv(srv), m_allocator(allocator) { /* ... */ } virtual ~RemoteDsRootSession() { serviceClose(std::addressof(m_srv)); } public: Result GetService(sf::Out<sf::SharedPointer<usb::ds::IDsService>> out); }; static_assert(ds::IsIDsRootSession<RemoteDsRootSession>); #endif }
1,408
C++
.h
35
34.857143
129
0.691971
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,410
usb_remote_ds_service.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/usb/usb_remote_ds_service.hpp
/* * 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> namespace ams::usb { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteDsService { private: using Allocator = sf::ExpHeapAllocator; using ObjectFactory = sf::ObjectFactory<Allocator::Policy>; private: Service m_srv; Allocator *m_allocator; public: RemoteDsService(Service &srv, sf::ExpHeapAllocator *allocator) : m_srv(srv), m_allocator(allocator) { /* ... */ } virtual ~RemoteDsService() { serviceClose(std::addressof(m_srv)); } public: Result Bind(usb::ComplexId complex_id, sf::CopyHandle &&process_h); Result RegisterInterface(sf::Out<sf::SharedPointer<usb::ds::IDsInterface>> out, u8 bInterfaceNumber); Result GetStateChangeEvent(sf::OutCopyHandle out); Result GetState(sf::Out<usb::UsbState> out); Result ClearDeviceData(); Result AddUsbStringDescriptor(sf::Out<u8> out, const sf::InBuffer &desc); Result DeleteUsbStringDescriptor(u8 index); Result SetUsbDeviceDescriptor(const sf::InBuffer &desc, usb::UsbDeviceSpeed speed); Result SetBinaryObjectStore(const sf::InBuffer &bos); Result Enable(); Result Disable(); }; static_assert(ds::IsIDsService<RemoteDsService>); #endif }
2,019
C++
.h
45
37.8
125
0.677829
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,411
usb_util.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/usb/impl/usb_util.hpp
/* * 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> namespace ams::usb::impl { constexpr int GetEndpointIndex(u8 address) { int idx = address & UsbEndpointAddressMask_EndpointNumber; if ((address & UsbEndpointAddressMask_Dir) == UsbEndpointAddressMask_DirDevicetoHost) { idx += 0x10; } return idx; } template<typename T> class ScopedRefCount { NON_COPYABLE(ScopedRefCount); NON_MOVEABLE(ScopedRefCount); private: T &m_obj; public: ALWAYS_INLINE ScopedRefCount(T &o) : m_obj(o) { ++m_obj; } ALWAYS_INLINE ~ScopedRefCount() { --m_obj; } }; }
1,357
C++
.h
40
27.75
95
0.658537
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,412
err_string_util.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/err/impl/err_string_util.hpp
/* * 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> namespace ams::err::impl { void MakeErrorCodeString(char *dst, size_t dst_size, ErrorCode error_code); }
788
C++
.h
20
37.35
79
0.75817
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,413
ldr_ams.os.horizon.h
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/ldr/ldr_ams.os.horizon.h
/** * @file ldr_ams.h * @brief Loader (ldr:*) IPC wrapper for Atmosphere extensions. * @author SciresM * @copyright libnx Authors */ #pragma once #include <switch.h> #ifdef __cplusplus extern "C" { #endif typedef struct { u64 keys_down; u64 flags; } CfgOverrideStatus; Result ldrPmAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id); Result ldrDmntAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id); Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out, CfgOverrideStatus *out_status, const NcmProgramLocation *loc); Result ldrPmAtmospherePinProgram(u64 *out, const NcmProgramLocation *loc, const CfgOverrideStatus *status); #ifdef __cplusplus } #endif
694
C++
.h
22
29.772727
123
0.799401
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,414
settings_configuration_id_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_configuration_id_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetConfigurationId1(settings::factory::ConfigurationId1 *out); }
787
C++
.h
20
37.3
76
0.764398
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,415
settings_spl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_spl.hpp
/* * 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> namespace ams::settings::impl { enum SplHardwareType : u8 { SplHardwareType_None = 0x0, SplHardwareType_Icosa = 0x1, SplHardwareType_IcosaMariko = 0x2, SplHardwareType_Copper = 0x3, SplHardwareType_Hoag = 0x4, SplHardwareType_Calcio = 0x5, SplHardwareType_Aula = 0x6, }; bool IsSplDevelopment(); SplHardwareType GetSplHardwareType(); bool IsSplRetailInteractiveDisplayStateEnabled(); u64 GetSplDeviceIdLow(); }
1,208
C++
.h
32
33.6875
76
0.708191
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,416
settings_system_save_data.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_system_save_data.hpp
/* * 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> namespace ams::settings::impl { class SystemSaveData { NON_COPYABLE(SystemSaveData); private: fs::SystemSaveDataId m_system_save_data_id; fs::SaveDataSpaceId m_save_data_space_id; s64 m_total_size; s64 m_journal_size; u32 m_flags; char m_mount_name[fs::MountNameLengthMax + 1]; public: SystemSaveData() : m_system_save_data_id(0), m_save_data_space_id(fs::SaveDataSpaceId::System), m_total_size(0), m_journal_size(0), m_flags(0) { /* ... */ } SystemSaveData(u64 id, s64 total_size, s64 journal_size, u32 flags, const char *mn) : SystemSaveData() { this->SetSystemSaveDataId(id); this->SetTotalSize(total_size); this->SetJournalSize(journal_size); this->SetFlags(flags); this->SetMountName(mn); } void SetSystemSaveDataId(u64 id); void SetTotalSize(s64 size); void SetJournalSize(s64 size); void SetFlags(u32 flags); void SetMountName(const char *name); Result Mount(bool create_save); Result Commit(bool synchronous); Result Create(s64 size); Result OpenToRead(); Result OpenToWrite(); void Close(); Result Read(s64 offset, void *buf, size_t size); Result Write(s64 offset, const void *buf, size_t size); Result Flush(); Result SetFileSize(s64 size); }; }
2,238
C++
.h
53
33.301887
168
0.626434
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,417
settings_product_model_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_product_model_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetProductModel(s32 *out); }
751
C++
.h
20
35.5
76
0.758242
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,418
settings_key_value_store.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_key_value_store.hpp
/* * 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 "settings_system_save_data.hpp" namespace ams::settings::impl { struct KeyValueStoreItemForDebug { const char *key; u8 type; size_t current_value_size; size_t default_value_size; void *current_value; void *default_value; }; static_assert(sizeof(KeyValueStoreItemForDebug) == 0x30); struct KeyValueStoreKeyIterator { size_t header_size; size_t entire_size; char *map_key; }; static_assert(sizeof(KeyValueStoreKeyIterator) == 0x18); class KeyValueStore { private: const SettingsName &m_name; public: explicit KeyValueStore(const SettingsName &name) : m_name(name) { /* ... */ } Result CreateKeyIterator(KeyValueStoreKeyIterator *out); Result GetValue(u64 *out_count, char *out_buffer, size_t out_buffer_size, const SettingsItemKey &item_key); Result GetValueSize(u64 *out_value_size, const SettingsItemKey &item_key); Result ResetValue(const SettingsItemKey &item_key); Result SetValue(const SettingsItemKey &item_key, const void *buffer, size_t buffer_size); }; Result AddKeyValueStoreItemForDebug(const KeyValueStoreItemForDebug * const items, size_t items_count); Result AdvanceKeyValueStoreKeyIterator(KeyValueStoreKeyIterator *out); Result DestroyKeyValueStoreKeyIterator(KeyValueStoreKeyIterator *out); Result GetKeyValueStoreItemCountForDebug(u64 *out_count); Result GetKeyValueStoreItemForDebug(u64 *out_count, KeyValueStoreItemForDebug * const out_items, size_t out_items_count); Result GetKeyValueStoreKeyIteratorKey(u64 *out_count, char *out_buffer, size_t out_buffer_size, const KeyValueStoreKeyIterator &iterator); Result GetKeyValueStoreKeyIteratorKeySize(u64 *out_count, const KeyValueStoreKeyIterator &iterator); Result ReadKeyValueStoreFirmwareDebug(u64 *out_count, char * const out_buffer, size_t out_buffer_size); Result ReadKeyValueStorePlatformConfiguration(u64 *out_count, char * const out_buffer, size_t out_buffer_size); Result ReadKeyValueStoreSaveData(u64 *out_count, char * const out_buffer, size_t out_buffer_size); Result ReloadKeyValueStoreForDebug(SystemSaveData *system_save_data, SystemSaveData *fwdbg_system_data, SystemSaveData *pfcfg_system_data); Result ReloadKeyValueStoreForDebug(); Result ResetKeyValueStoreSaveData(); Result SaveKeyValueStoreAllForDebug(SystemSaveData *data); }
3,170
C++
.h
60
47.15
143
0.745408
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,419
settings_error_report_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_error_report_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetErrorReportSharePermission(s32 *out); }
765
C++
.h
20
36.2
76
0.762803
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,420
settings_serial_number_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_serial_number_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetSerialNumber(settings::factory::SerialNumber *out); Result GetSerialNumber(settings::system::SerialNumber *out); }
844
C++
.h
21
38
76
0.763415
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,421
settings_platform_region_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_platform_region_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetPlatformRegion(s32 *out); }
753
C++
.h
20
35.6
76
0.758904
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,422
settings_region_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_region_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetRegionCode(s32 *out); }
749
C++
.h
20
35.4
76
0.757576
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,423
settings_firmware_version_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_firmware_version_impl.hpp
/* * 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> namespace ams::settings::impl { Result GetFirmwareVersion(settings::system::FirmwareVersion *out); }
784
C++
.h
20
37.15
76
0.763469
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,424
settings_system_data.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_system_data.hpp
/* * 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> namespace ams::settings::impl { class SystemData { NON_COPYABLE(SystemData); NON_MOVEABLE(SystemData); private: static constexpr size_t FileNameLengthMax = 31; private: ncm::SystemDataId m_system_data_id; char m_mount_name[fs::MountNameLengthMax + 1]; char m_file_path[fs::MountNameLengthMax + 1 + 1 + FileNameLengthMax + 1]; public: SystemData() : m_system_data_id(), m_mount_name(), m_file_path() { /* ... */ } SystemData(ncm::SystemDataId id, const char *mn) : SystemData() { this->SetSystemDataId(id); this->SetMountName(mn); } void SetSystemDataId(ncm::SystemDataId id); void SetMountName(const char *name); Result Mount(); Result OpenToRead(); void Close(); Result Read(s64 offset, void *dst, size_t size); }; }
1,635
C++
.h
41
32.658537
90
0.643172
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,425
settings_static_object.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/settings/impl/settings_static_object.hpp
/* * 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/>. */ #include <stratosphere.hpp> namespace ams::settings::impl { template<typename T, typename Tag> class StaticObject final { NON_COPYABLE(StaticObject); NON_MOVEABLE(StaticObject); private: StaticObject(); public: static T &Get() { AMS_FUNCTION_LOCAL_STATIC(T, s_object); return s_object; } }; }
1,040
C++
.h
30
29.466667
76
0.684891
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,426
htcs_manager_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/htcs_manager_impl.hpp
/* * 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 "../../htclow/htclow_manager.hpp" #include "../../htc/server/driver/htc_htclow_driver.hpp" #include "../../htc/server/driver/htc_driver_manager.hpp" #include "../../htc/server/rpc/htc_rpc_client.hpp" #include "rpc/htcs_data_channel_manager.hpp" #include "htcs_service.hpp" #include "htcs_monitor.hpp" namespace ams::htcs::impl { class HtcsManagerImpl { private: mem::StandardAllocator *m_allocator; htc::server::driver::HtclowDriver m_driver; htc::server::driver::DriverManager m_driver_manager; htc::server::rpc::RpcClient m_rpc_client; rpc::DataChannelManager m_data_channel_manager; HtcsService m_service; HtcsMonitor m_monitor; public: HtcsManagerImpl(mem::StandardAllocator *allocator, htclow::HtclowManager *htclow_manager); ~HtcsManagerImpl(); public: os::EventType *GetServiceAvailabilityEvent(); bool IsServiceAvailable(); public: Result CreateSocket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation); Result DestroySocket(s32 desc); Result Connect(s32 *out_err, s32 desc, const SockAddrHtcs &address); Result Bind(s32 *out_err, s32 desc, const SockAddrHtcs &address); Result Listen(s32 *out_err, s32 desc, s32 backlog_count); Result Receive(s32 *out_err, s64 *out_size, char *buffer, size_t size, s32 desc, s32 flags); Result Send(s32 *out_err, s64 *out_size, const char *buffer, size_t size, s32 desc, s32 flags); Result Shutdown(s32 *out_err, s32 desc, s32 how); Result Fcntl(s32 *out_err, s32 *out_res, s32 desc, s32 command, s32 value); Result AcceptStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc); Result AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc); Result RecvStart(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags); Result RecvResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result SendStart(u32 *out_task_id, os::NativeHandle *out_handle, const char *buffer, s64 size, s32 desc, s32 flags); Result SendLargeStart(u32 *out_task_id, os::NativeHandle *out_handle, const char **buffers, const s64 *sizes, s32 count, s32 desc, s32 flags); Result SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc); Result StartSend(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc, s64 size, s32 flags); Result ContinueSend(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result EndSend(s32 *out_err, s64 *out_size, u32 task_id, s32 desc); Result StartRecv(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags); Result EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result StartSelect(u32 *out_task_id, os::NativeHandle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec); Result EndSelect(s32 *out_err, bool *out_empty, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id); }; }
4,112
C++
.h
66
54.151515
200
0.676412
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,427
htcs_util.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/htcs_util.hpp
/* * 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> namespace ams::htcs::impl { s32 ConvertResultToErrorCode(const Result result); constexpr bool IsValidName(const char *name) { static_assert(PeerNameBufferLength == PortNameBufferLength); return util::Strnlen(name, PeerNameBufferLength) < PeerNameBufferLength; } constexpr bool IsValidName(const HtcsPeerName &name) { return IsValidName(name.name); } constexpr bool IsValidName(const HtcsPortName &name) { return IsValidName(name.name); } }
1,182
C++
.h
30
35.733333
80
0.746073
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,428
htcs_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/htcs_impl.hpp
/* * 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> namespace ams::htcs::impl { const htcs::HtcsPeerName GetPeerNameAny(); const htcs::HtcsPeerName GetDefaultHostName(); }
807
C++
.h
21
36.238095
76
0.759898
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,429
htcs_manager.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/htcs_manager.hpp
/* * 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 "../../htclow/htclow_manager.hpp" namespace ams::htcs::impl { class HtcsManagerImpl; class HtcsManager { private: mem::StandardAllocator *m_allocator; HtcsManagerImpl *m_impl; public: HtcsManager(mem::StandardAllocator *allocator, htclow::HtclowManager *htclow_manager); ~HtcsManager(); public: os::EventType *GetServiceAvailabilityEvent(); bool IsServiceAvailable(); public: void Socket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation); void Close(s32 *out_err, s32 *out_res, s32 desc); void Connect(s32 *out_err, s32 *out_res, const SockAddrHtcs &address, s32 desc); void Bind(s32 *out_err, s32 *out_res, const SockAddrHtcs &address, s32 desc); void Listen(s32 *out_err, s32 *out_res, s32 backlog_count, s32 desc); void Recv(s32 *out_err, s64 *out_size, char *buffer, size_t size, s32 flags, s32 desc); void Send(s32 *out_err, s64 *out_size, const char *buffer, size_t size, s32 flags, s32 desc); void Shutdown(s32 *out_err, s32 *out_res, s32 how, s32 desc); void Fcntl(s32 *out_err, s32 *out_res, s32 command, s32 value, s32 desc); Result AcceptStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc); void AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc); Result RecvStart(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags); void RecvResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result SendStart(u32 *out_task_id, os::NativeHandle *out_handle, const char *buffer, s64 size, s32 desc, s32 flags); Result SendLargeStart(u32 *out_task_id, os::NativeHandle *out_handle, const char **buffers, const s64 *sizes, s32 count, s32 desc, s32 flags); void SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc); Result StartSend(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc, s64 size, s32 flags); Result ContinueSend(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc); void EndSend(s32 *out_err, s64 *out_size, u32 task_id, s32 desc); Result StartRecv(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags); void EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result StartSelect(u32 *out_task_id, os::NativeHandle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec); Result EndSelect(s32 *out_err, s32 *out_count, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id); }; }
3,631
C++
.h
56
56.392857
200
0.670314
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,430
htcs_monitor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/htcs_monitor.hpp
/* * 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 "../../htc/server/driver/htc_i_driver.hpp" #include "../../htc/server/rpc/htc_rpc_client.hpp" #include "htcs_service.hpp" namespace ams::htcs::impl { class HtcsMonitor { private: mem::StandardAllocator *m_allocator; htc::server::driver::IDriver *m_driver; htc::server::rpc::RpcClient *m_rpc_client; HtcsService *m_service; void *m_monitor_thread_stack; os::ThreadType m_monitor_thread; os::SdkMutex m_mutex; os::Event m_cancel_event; os::Event m_service_availability_event; bool m_cancelled; bool m_is_service_available; private: static void ThreadEntry(void *arg) { static_cast<HtcsMonitor *>(arg)->ThreadBody(); } void ThreadBody(); public: HtcsMonitor(mem::StandardAllocator *allocator, htc::server::driver::IDriver *drv, htc::server::rpc::RpcClient *rc, HtcsService *srv); ~HtcsMonitor(); public: void Start(); void Cancel(); void Wait(); os::EventType *GetServiceAvailabilityEvent() { return m_service_availability_event.GetBase(); } bool IsServiceAvailable() { /* Lock ourselves. */ std::scoped_lock lk(m_mutex); /* Get availability. */ return m_is_service_available; } private: void SetServiceAvailability(bool available) { /* Lock ourselves. */ std::scoped_lock lk(m_mutex); /* Set availability. */ m_is_service_available = available; /* Signal availability change. */ m_service_availability_event.Signal(); } }; }
2,529
C++
.h
64
30.15625
145
0.603013
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,431
htcs_service.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/htcs_service.hpp
/* * 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 "../../htc/server/driver/htc_i_driver.hpp" #include "../../htc/server/rpc/htc_rpc_client.hpp" #include "rpc/htcs_data_channel_manager.hpp" namespace ams::htcs::impl { class HtcsService { private: mem::StandardAllocator *m_allocator; htc::server::driver::IDriver *m_driver; htc::server::rpc::RpcClient *m_rpc_client; rpc::DataChannelManager *m_data_channel_manager; public: HtcsService(mem::StandardAllocator *allocator, htc::server::driver::IDriver *drv, htc::server::rpc::RpcClient *rc, rpc::DataChannelManager *dcm) : m_allocator(allocator), m_driver(drv), m_rpc_client(rc), m_data_channel_manager(dcm) { /* ... */ } public: Result CreateSocket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation); Result DestroySocket(s32 desc); Result Connect(s32 *out_err, s32 desc, const SockAddrHtcs &address); Result Bind(s32 *out_err, s32 desc, const SockAddrHtcs &address); Result Listen(s32 *out_err, s32 desc, s32 backlog_count); Result Receive(s32 *out_err, s64 *out_size, char *buffer, s64 size, s32 desc, s32 flags); Result Send(s32 *out_err, s64 *out_size, const char *buffer, s64 size, s32 desc, s32 flags); Result Shutdown(s32 *out_err, s32 desc, s32 how); Result Fcntl(s32 *out_err, s32 *out_res, s32 desc, s32 command, s32 value); Result AcceptStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc); Result AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc); Result ReceiveSmallStart(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags); Result ReceiveSmallResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result SendSmallStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc, s64 size, s32 flags); Result SendSmallContinue(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result SendSmallResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc); Result SendStart(u32 *out_task_id, os::NativeHandle *out_handle, s32 desc, s64 size, s32 flags); Result SendContinue(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc); Result ReceiveStart(u32 *out_task_id, os::NativeHandle *out_handle, s64 size, s32 desc, s32 flags); Result ReceiveResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc); Result SelectStart(u32 *out_task_id, os::NativeHandle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec); Result SelectEnd(s32 *out_err, bool *out_empty, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id); private: void WaitTask(u32 task_id); }; }
3,863
C++
.h
58
58.241379
200
0.674658
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,432
htcs_rpc_tasks.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/rpc/htcs_rpc_tasks.hpp
/* * 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 "../../../htc/server/rpc/htc_rpc_tasks.hpp" namespace ams::htcs::impl::rpc { enum class HtcsTaskType { Receive = 0, Send = 1, Shutdown = 2, Close = 3, Connect = 4, Listen = 5, Accept = 6, Socket = 7, Bind = 8, Fcntl = 9, ReceiveSmall = 10, SendSmall = 11, Select = 12, }; constexpr inline s16 HtcsProtocol = 5; constexpr inline const s16 HtcsMaxVersion = 4; enum class HtcsPacketCategory : s16 { Request = 0, Response = 1, Notification = 2, }; enum class HtcsPacketType : s16 { Receive = 32, Send = 33, Shutdown = 34, Close = 35, Connect = 36, Listen = 37, Accept = 38, Socket = 39, Bind = 40, Fcntl = 41, ReceiveLarge = 42, SendLarge = 43, Select = 44, }; struct HtcsRpcPacket { s16 protocol; s16 version; HtcsPacketCategory category; HtcsPacketType type; s64 body_size; u32 task_id{}; s64 params[5]; char data[]; }; static_assert(sizeof(HtcsRpcPacket) == 0x40); constexpr inline u16 ReceiveDataChannelIdBegin = htc::server::rpc::MaxRpcCount; constexpr inline u16 ReceiveDataChannelIdEnd = ReceiveDataChannelIdBegin + htc::server::rpc::MaxRpcCount; static_assert(ReceiveDataChannelIdEnd - ReceiveDataChannelIdBegin == htc::server::rpc::MaxRpcCount); constexpr inline u16 SendDataChannelIdBegin = ReceiveDataChannelIdEnd; constexpr inline u16 SendDataChannelIdEnd = SendDataChannelIdBegin + htc::server::rpc::MaxRpcCount; static_assert(SendDataChannelIdEnd - SendDataChannelIdBegin == htc::server::rpc::MaxRpcCount); constexpr inline u16 GetReceiveDataChannelId(u32 task_id) { const u16 channel_id = task_id + ReceiveDataChannelIdBegin; AMS_ASSERT(ReceiveDataChannelIdBegin <= channel_id && channel_id < ReceiveDataChannelIdEnd); return channel_id; } constexpr inline u16 GetSendDataChannelId(u32 task_id) { const u16 channel_id = task_id + SendDataChannelIdBegin; AMS_ASSERT(SendDataChannelIdBegin <= channel_id && channel_id < SendDataChannelIdEnd); return channel_id; } class HtcsTask : public htc::server::rpc::Task { private: HtcsTaskType m_task_type; s16 m_version; public: HtcsTask(HtcsTaskType type); /* Defined in socket_task.cpp, for namespacing reasons. */ HtcsTaskType GetTaskType() const { return m_task_type; } s16 GetVersion() const { return m_version; } }; template<typename T> concept IsHtcsTask = std::derived_from<T, HtcsTask>; class HtcsSignalingTask : public HtcsTask { private: os::SystemEventType m_system_event; bool m_is_valid; public: HtcsSignalingTask(HtcsTaskType type); virtual ~HtcsSignalingTask(); bool IsValid() const { return m_is_valid; } void Complete() { os::SignalSystemEvent(std::addressof(m_system_event)); HtcsTask::Complete(); } public: virtual void Cancel(htc::server::rpc::RpcTaskCancelReason reason) override { HtcsTask::Cancel(reason); os::SignalSystemEvent(std::addressof(m_system_event)); } virtual os::SystemEventType *GetSystemEvent() override { return std::addressof(m_system_event); } }; class ReceiveTask : public HtcsSignalingTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Receive; private: s32 m_handle; s64 m_size; htcs::MessageFlag m_flags; void *m_buffer; s64 m_buffer_size; htcs::SocketError m_err; s64 m_result_size; public: ReceiveTask() : HtcsSignalingTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } s64 GetSize() const { return m_size; } htcs::MessageFlag GetFlags() const { return m_flags; } void *GetBuffer() const { return m_buffer; } s64 GetBufferSize() const { return m_buffer_size; } s64 GetResultSize() const { AMS_ASSERT(this->GetTaskState() == htc::server::rpc::RpcTaskState::Completed); return m_result_size; } public: Result SetArguments(s32 handle, s64 size, htcs::MessageFlag flags); void Complete(htcs::SocketError err, s64 size); Result GetResult(htcs::SocketError *out_err, s64 *out_size) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; virtual Result CreateNotification(size_t *out, char *data, size_t size, u32 task_id) override; }; class SendTask : public HtcsSignalingTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Send; private: os::Event m_ready_event; s32 m_handle; s64 m_size; htcs::MessageFlag m_flags; const void *m_buffer; s64 m_buffer_size; htcs::SocketError m_err; s64 m_result_size; public: SendTask() : HtcsSignalingTask(TaskType), m_ready_event(os::EventClearMode_ManualClear) { /* ... */ } s32 GetHandle() const { return m_handle; } s64 GetSize() const { return m_size; } htcs::MessageFlag GetFlags() const { return m_flags; } const void *GetBuffer() const { return m_buffer; } s64 GetBufferSize() const { return m_buffer_size; } void SetBuffer(const void *buffer, s64 buffer_size); void NotifyDataChannelReady(); void WaitNotification(); public: Result SetArguments(s32 handle, s64 size, htcs::MessageFlag flags); void Complete(htcs::SocketError err, s64 size); Result GetResult(htcs::SocketError *out_err, s64 *out_size) const; public: virtual void Cancel(htc::server::rpc::RpcTaskCancelReason reason) override; virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; virtual Result ProcessNotification(const char *data, size_t size) override; virtual Result CreateNotification(size_t *out, char *data, size_t size, u32 task_id) override; }; class ShutdownTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Shutdown; private: s32 m_handle; ShutdownType m_how; htcs::SocketError m_err; public: ShutdownTask() : HtcsTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } ShutdownType GetHow() const { return m_how; } public: Result SetArguments(s32 handle, ShutdownType how); void Complete(htcs::SocketError err); Result GetResult(htcs::SocketError *out_err) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class CloseTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Close; private: s32 m_handle; htcs::SocketError m_err; public: CloseTask() : HtcsTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } public: Result SetArguments(s32 handle); void Complete(htcs::SocketError err); Result GetResult(htcs::SocketError *out_err) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class ConnectTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Connect; private: s32 m_handle; HtcsPeerName m_peer_name; HtcsPortName m_port_name; htcs::SocketError m_err; public: ConnectTask() : HtcsTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } const HtcsPeerName &GetPeerName() const { return m_peer_name; } const HtcsPortName &GetPortName() const { return m_port_name; } public: Result SetArguments(s32 handle, const HtcsPeerName &peer_name, const HtcsPortName &port_name); void Complete(htcs::SocketError err); Result GetResult(htcs::SocketError *out_err) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class ListenTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Listen; private: s32 m_handle; s32 m_backlog; htcs::SocketError m_err; public: ListenTask() : HtcsTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } s32 GetBacklog() const { return m_backlog; } public: Result SetArguments(s32 handle, s32 backlog); void Complete(htcs::SocketError err); Result GetResult(htcs::SocketError *out_err) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class AcceptTask : public HtcsSignalingTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Accept; private: s32 m_server_handle; htcs::SocketError m_err; s32 m_desc; public: AcceptTask() : HtcsSignalingTask(TaskType) { /* ... */ } s32 GetServerHandle() const { return m_server_handle; } public: Result SetArguments(s32 server_handle); void Complete(htcs::SocketError err, s32 desc); Result GetResult(htcs::SocketError *out_err, s32 *out_desc, s32 server_handle) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class SocketTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Socket; private: htcs::SocketError m_err; s32 m_desc; public: SocketTask() : HtcsTask(TaskType) { /* ... */ } public: Result SetArguments(); void Complete(htcs::SocketError err, s32 desc); Result GetResult(htcs::SocketError *out_err, s32 *out_desc) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class BindTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Bind; private: s32 m_handle; HtcsPeerName m_peer_name; HtcsPortName m_port_name; htcs::SocketError m_err; public: BindTask() : HtcsTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } const HtcsPeerName &GetPeerName() const { return m_peer_name; } const HtcsPortName &GetPortName() const { return m_port_name; } public: Result SetArguments(s32 handle, const HtcsPeerName &peer_name, const HtcsPortName &port_name); void Complete(htcs::SocketError err); Result GetResult(htcs::SocketError *out_err) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class FcntlTask : public HtcsTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Fcntl; private: s32 m_handle; s32 m_command; s32 m_value; htcs::SocketError m_err; s32 m_res; public: FcntlTask() : HtcsTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } s32 GetCommand() const { return m_command; } s32 GetValue() const { return m_value; } public: Result SetArguments(s32 handle, s32 command, s32 value); void Complete(htcs::SocketError err, s32 res); Result GetResult(htcs::SocketError *out_err, s32 *out_res) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; class ReceiveSmallTask : public HtcsSignalingTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::ReceiveSmall; private: s32 m_handle; s64 m_size; htcs::MessageFlag m_flags; char m_buffer[0xE000]; htcs::SocketError m_err; s64 m_result_size; public: ReceiveSmallTask() : HtcsSignalingTask(TaskType) { /* ... */ } s32 GetHandle() const { return m_handle; } s64 GetSize() const { return m_size; } htcs::MessageFlag GetFlags() const { return m_flags; } void *GetBuffer() { return m_buffer; } s64 GetBufferSize() const { return static_cast<s64>(sizeof(m_buffer)); } s64 GetResultSize() const { AMS_ASSERT(this->GetTaskState() == htc::server::rpc::RpcTaskState::Completed); return m_result_size; } public: Result SetArguments(s32 handle, s64 size, htcs::MessageFlag flags); void Complete(htcs::SocketError err, s64 size); Result GetResult(htcs::SocketError *out_err, s64 *out_size) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; virtual bool IsReceiveBufferRequired() override; }; class SendSmallTask : public HtcsSignalingTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::SendSmall; private: os::Event m_ready_event; s32 m_handle; s64 m_size; htcs::MessageFlag m_flags; char m_buffer[0xE000]; s64 m_buffer_size; htcs::SocketError m_err; s64 m_result_size; public: SendSmallTask() : HtcsSignalingTask(TaskType), m_ready_event(os::EventClearMode_ManualClear) { /* ... */ } s32 GetHandle() const { return m_handle; } s64 GetSize() const { return m_size; } htcs::MessageFlag GetFlags() const { return m_flags; } void *GetBuffer() { return m_buffer; } s64 GetBufferSize() const { return m_buffer_size; } void SetBuffer(const void *buffer, s64 buffer_size); void NotifyDataChannelReady(); void WaitNotification(); public: Result SetArguments(s32 handle, s64 size, htcs::MessageFlag flags); void Complete(htcs::SocketError err, s64 size); Result GetResult(htcs::SocketError *out_err, s64 *out_size) const; public: virtual void Cancel(htc::server::rpc::RpcTaskCancelReason reason) override; virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; virtual bool IsSendBufferRequired() override; }; class SelectTask : public HtcsSignalingTask { public: static constexpr inline HtcsTaskType TaskType = HtcsTaskType::Select; private: s32 m_handles[SocketCountMax * 3]; s32 m_read_handle_count; s32 m_write_handle_count; s32 m_exception_handle_count; s64 m_tv_sec; s64 m_tv_usec; htcs::SocketError m_err; s32 m_out_handles[SocketCountMax * 3]; s32 m_out_read_handle_count; s32 m_out_write_handle_count; s32 m_out_exception_handle_count; public: SelectTask() : HtcsSignalingTask(TaskType) { /* ... */ } const s32 *GetHandles() const { return m_handles; } s32 GetReadHandleCount() const { return m_read_handle_count; } s32 GetWriteHandleCount() const { return m_write_handle_count; } s32 GetExceptionHandleCount() const { return m_exception_handle_count; } s64 GetTimeoutSeconds() const { return m_tv_sec; } s64 GetTimeoutMicroSeconds() const { return m_tv_usec; } public: Result SetArguments(Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec); void Complete(htcs::SocketError err, s32 read_handle_count, s32 write_handle_count, s32 exception_handle_count, const void *body, s64 body_size); Result GetResult(htcs::SocketError *out_err, bool *out_empty, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles) const; public: virtual Result ProcessResponse(const char *data, size_t size) override; virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) override; }; }
19,523
C++
.h
424
35.45283
158
0.607874
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,433
htcs_data_channel_manager.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/impl/rpc/htcs_data_channel_manager.hpp
/* * 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 "../../../htclow/htclow_manager.hpp" #include "../../../htc/server/rpc/htc_rpc_client.hpp" namespace ams::htcs::impl::rpc { class DataChannelManager { private: htc::server::rpc::RpcClient* m_rpc_client; htclow::HtclowManager *m_htclow_manager; htclow::Module m_module; public: DataChannelManager(htc::server::rpc::RpcClient *client, htclow::HtclowManager *htclow_manager) : m_rpc_client(client), m_htclow_manager(htclow_manager), m_module(htclow::ModuleId::Htcs) { /* ... */ } public: Result Receive(void *buffer, s64 buffer_size, u32 task_id); Result Send(const void *buffer, s64 buffer_size, u32 task_id); }; }
1,405
C++
.h
32
39.125
211
0.692701
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,434
htcs_service_object_allocator.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/server/htcs_service_object_allocator.hpp
/* * 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> namespace ams::htcs::server { struct ServiceObjectAllocatorTag; using ServiceObjectAllocator = ams::sf::ExpHeapStaticAllocator<32_KB, ServiceObjectAllocatorTag>; using ServiceObjectFactory = ams::sf::ObjectFactory<typename ServiceObjectAllocator::Policy>; }
951
C++
.h
22
40.909091
101
0.773218
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,435
htcs_manager_service_object.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.hpp
/* * 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> namespace ams::htcs::server { class ManagerServiceObject : public sf::ISharedObject { public: Result Socket(sf::Out<s32> out_err, sf::Out<s32> out_sock); Result Close(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc); Result Connect(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address); Result Bind(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address); Result Listen(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 backlog_count); Result Accept(sf::Out<s32> out_err, sf::Out<s32> out_res, sf::Out<htcs::SockAddrHtcs> out_address, s32 desc); Result Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutBuffer &buffer, s32 desc, s32 flags); Result Send(sf::Out<s32> out_err, sf::Out<s64> out_size, s32 desc, const sf::InBuffer &buffer, s32 flags); Result Shutdown(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 how); Result Fcntl(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 command, s32 value); Result GetPeerNameAny(sf::Out<htcs::HtcsPeerName> out); Result GetDefaultHostName(sf::Out<htcs::HtcsPeerName> out); Result CreateSocketOld(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out); Result CreateSocket(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, bool enable_disconnection_emulation); Result RegisterProcessId(const sf::ClientProcessId &client_pid); Result MonitorManager(const sf::ClientProcessId &client_pid); Result StartSelect(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InMapAliasArray<s32> &read_handles, const sf::InMapAliasArray<s32> &write_handles, const sf::InMapAliasArray<s32> &exception_handles, s64 tv_sec, s64 tv_usec); Result EndSelect(sf::Out<s32> out_err, sf::Out<s32> out_count, const sf::OutMapAliasArray<s32> &read_handles, const sf::OutMapAliasArray<s32> &write_handles, const sf::OutMapAliasArray<s32> &exception_handles, u32 task_id); }; static_assert(tma::IsIHtcsManager<ManagerServiceObject>); }
2,921
C++
.h
41
64.073171
255
0.69204
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,436
htcs_socket_service_object.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.hpp
/* * 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 "htcs_manager_service_object.hpp" namespace ams::htcs::server { class SocketServiceObject { private: sf::SharedPointer<ManagerServiceObject> m_manager; s32 m_desc; public: SocketServiceObject(ManagerServiceObject *manager, s32 desc); ~SocketServiceObject(); public: Result Close(sf::Out<s32> out_err, sf::Out<s32> out_res); Result Connect(sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address); Result Bind(sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address); Result Listen(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 backlog_count); Result Accept(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address); Result Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags); Result Send(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::InAutoSelectBuffer &buffer, s32 flags); Result Shutdown(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 how); Result Fcntl(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 command, s32 value); Result AcceptStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event); Result AcceptResults(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id); Result RecvStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags); Result RecvResults(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id); Result RecvLargeStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags); Result SendStartOld(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags); Result SendLargeStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags); Result SendResults(sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id); Result StartSend(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> out_max_size, s64 size, s32 flags); Result ContinueSendOld(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id); Result EndSend(sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id); Result StartRecv(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags); Result EndRecv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id); Result SendStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags); Result ContinueSend(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id); Result GetPrimitive(sf::Out<s32> out); }; static_assert(tma::IsISocket<SocketServiceObject>); }
4,076
C++
.h
55
65.818182
233
0.684918
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,437
htcs_virtual_socket_collection.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.hpp
/* * 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> namespace ams::htcs::client { struct VirtualSocket; class VirtualSocketCollection { private: void *m_buffer; size_t m_buffer_size; VirtualSocket *m_socket_list; s32 m_list_count; s32 m_list_size; s32 m_next_id; os::SdkMutex m_mutex; public: static size_t GetWorkingMemorySize(int num_sockets); public: explicit VirtualSocketCollection(); ~VirtualSocketCollection(); public: void Init(void *buffer, size_t buffer_size); void Clear(); s32 Socket(s32 &error_code); s32 Close(s32 id, s32 &error_code); s32 Bind(s32 id, const htcs::SockAddrHtcs *address, s32 &error_code); s32 Listen(s32 id, s32 backlog_count, s32 &error_code); s32 Accept(s32 id, htcs::SockAddrHtcs *address, s32 &error_code); s32 Fcntl(s32 id, s32 command, s32 value, s32 &error_code); s32 Shutdown(s32 id, s32 how, s32 &error_code); ssize_t Recv(s32 id, void *buffer, size_t buffer_size, s32 flags, s32 &error_code); ssize_t Send(s32 id, const void *buffer, size_t buffer_size, s32 flags, s32 &error_code); s32 Connect(s32 id, const htcs::SockAddrHtcs *address, s32 &error_code); s32 Select(htcs::FdSet *read, htcs::FdSet *write, htcs::FdSet *except, htcs::TimeVal *timeout, s32 &error_code); private: s32 CreateId(); s32 Add(sf::SharedPointer<tma::ISocket> socket); void Insert(s32 id, sf::SharedPointer<tma::ISocket> socket); void SetSize(s32 size); s32 Find(s32 id, s32 *error_code = nullptr); s32 FindByPrimitive(s32 primitive); bool HasAddr(const htcs::SockAddrHtcs *address); sf::SharedPointer<tma::ISocket> GetSocket(s32 id, s32 *error_code = nullptr); sf::SharedPointer<tma::ISocket> FetchSocket(s32 id, s32 &error_code); sf::SharedPointer<tma::ISocket> RealizeSocket(s32 id); sf::SharedPointer<tma::ISocket> DoAccept(sf::SharedPointer<tma::ISocket> socket, s32 id, htcs::SockAddrHtcs *address, s32 &error_code); s32 GetSockets(s32 * const out_primitives, htcs::FdSet *set, s32 &error_code); void SetSockets(htcs::FdSet *set, s32 * const primitives, s32 count); s32 CreateSocket(sf::SharedPointer<tma::ISocket> socket, s32 &error_code); }; }
3,204
C++
.h
64
40.828125
147
0.642972
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,438
htcs_session.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htcs/client/htcs_session.hpp
/* * 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> namespace ams::htcs::client { void InitializeSessionManager(tma::IHtcsManager **out_manager, tma::IHtcsManager **out_monitor, u32 num_sessions); void FinalizeSessionManager(); }
865
C++
.h
21
39
118
0.762188
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,439
i2c_command_list_format.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/impl/i2c_command_list_format.hpp
/* * 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> namespace ams::i2c::impl { enum CommandId { CommandId_Send = 0, CommandId_Receive = 1, CommandId_Extension = 2, CommandId_Count = 3, }; enum SubCommandId { SubCommandId_Sleep = 0, }; struct CommonCommandFormat { using CommandId = util::BitPack8::Field<0, 2>; using SubCommandId = util::BitPack8::Field<2, 6>; }; struct ReceiveCommandFormat { using StartCondition = util::BitPack8::Field<6, 1, bool>; using StopCondition = util::BitPack8::Field<7, 1, bool>; using Size = util::BitPack8::Field<0, 8>; }; struct SendCommandFormat { using StartCondition = util::BitPack8::Field<6, 1, bool>; using StopCondition = util::BitPack8::Field<7, 1, bool>; using Size = util::BitPack8::Field<0, 8>; }; struct SleepCommandFormat { using MicroSeconds = util::BitPack8::Field<0, 8>; }; }
1,652
C++
.h
45
31.666667
76
0.661038
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,440
i2c_driver_core.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/driver/impl/i2c_driver_core.hpp
/* * 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> namespace ams::i2c::driver::impl { void InitializeDrivers(); void FinalizeDrivers(); void RegisterDriver(II2cDriver *driver); void UnregisterDriver(II2cDriver *driver); Result RegisterDeviceCode(DeviceCode device_code, I2cDeviceProperty *device); bool UnregisterDeviceCode(DeviceCode device_code); Result FindDevice(I2cDeviceProperty **out, DeviceCode device_code); Result FindDeviceByBusIndexAndAddress(I2cDeviceProperty **out, i2c::I2cBus bus_index, u16 slave_address); }
1,188
C++
.h
27
41.074074
109
0.771429
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,441
i2c_device_property_manager.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp
/* * 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 "i2c_i_allocator.hpp" namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cDevicePropertyManager : public IAllocator<I2cDeviceProperty::DevicePropertyList> { public: using IAllocator<I2cDeviceProperty::DevicePropertyList>::IAllocator; }; }
968
C++
.h
24
37.458333
95
0.754516
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,442
i2c_bus_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp
/* * 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 "i2c_i2c_registers.hpp" namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cBusAccessor : public ::ams::i2c::driver::II2cDriver { NON_COPYABLE(I2cBusAccessor); NON_MOVEABLE(I2cBusAccessor); AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::board::nintendo::nx::impl::I2cBusAccessor, ::ams::i2c::driver::II2cDriver); private: enum class State { NotInitialized = 0, Initializing = 1, Initialized = 2, Suspended = 3, PowerBusSuspended = 4, }; enum Xfer { Xfer_Write = 0, Xfer_Read = 1, }; private: volatile I2cRegisters *m_registers; SpeedMode m_speed_mode; os::InterruptEventType m_interrupt_event; int m_user_count; os::SdkMutex m_user_count_mutex; os::SdkMutex m_register_mutex; regulator::RegulatorSession m_regulator_session; bool m_has_regulator_session; State m_state; os::SdkMutex m_transaction_order_mutex; bool m_is_power_bus; dd::PhysicalAddress m_registers_phys_addr; size_t m_registers_size; os::InterruptName m_interrupt_name; DeviceCode m_device_code; util::IntrusiveListNode m_bus_accessor_list_node; public: using BusAccessorListTraits = util::IntrusiveListMemberTraits<&I2cBusAccessor::m_bus_accessor_list_node>; using BusAccessorList = typename BusAccessorListTraits::ListType; friend class util::IntrusiveList<I2cBusAccessor, util::IntrusiveListMemberTraits<&I2cBusAccessor::m_bus_accessor_list_node>>; public: I2cBusAccessor() : m_registers(nullptr), m_speed_mode(SpeedMode_Fast), m_user_count(0), m_user_count_mutex(), m_register_mutex(), m_has_regulator_session(false), m_state(State::NotInitialized), m_transaction_order_mutex(), m_is_power_bus(false), m_registers_phys_addr(0), m_registers_size(0), m_interrupt_name(), m_device_code(-1), m_bus_accessor_list_node() { /* ... */ } void Initialize(dd::PhysicalAddress reg_paddr, size_t reg_size, os::InterruptName intr, bool pb, SpeedMode sm); void RegisterDeviceCode(DeviceCode device_code); SpeedMode GetSpeedMode() const { return m_speed_mode; } dd::PhysicalAddress GetRegistersPhysicalAddress() const { return m_registers_phys_addr; } size_t GetRegistersSize() const { return m_registers_size; } os::InterruptName GetInterruptName() const { return m_interrupt_name; } private: Result TryOpenRegulatorSession(); void ExecuteInitialConfig(); Result Send(const u8 *src, size_t src_size, TransactionOption option, u16 slave_address, AddressingMode addressing_mode); Result Receive(u8 *dst, size_t dst_size, TransactionOption option, u16 slave_address, AddressingMode addressing_mode); void WriteHeader(Xfer xfer, size_t size, TransactionOption option, u16 slave_address, AddressingMode addressing_mode); void ResetController() const; void ClearBus() const; void SetClockRegisters(SpeedMode speed_mode); void SetPacketModeRegisters(); Result FlushFifos(); Result GetTransactionResult() const; void HandleTransactionError(Result result); void DisableInterruptMask() { reg::Write(m_registers->interrupt_mask_register, 0); reg::Read(m_registers->interrupt_mask_register); } Result CheckAndHandleError() { const Result result = this->GetTransactionResult(); this->HandleTransactionError(result); if (R_FAILED(result)) { this->DisableInterruptMask(); os::ClearInterruptEvent(std::addressof(m_interrupt_event)); } R_RETURN(result); } public: virtual void InitializeDriver() override; virtual void FinalizeDriver() override; virtual Result InitializeDevice(I2cDeviceProperty *device) override; virtual void FinalizeDevice(I2cDeviceProperty *device) override; virtual Result Send(I2cDeviceProperty *device, const void *src, size_t src_size, TransactionOption option) override; virtual Result Receive(void *dst, size_t dst_size, I2cDeviceProperty *device, TransactionOption option) override; virtual os::SdkMutex &GetTransactionOrderMutex() override { return m_transaction_order_mutex; } virtual void SuspendBus() override; virtual void SuspendPowerBus() override; virtual void ResumeBus() override; virtual void ResumePowerBus() override; virtual const DeviceCode &GetDeviceCode() const override { return m_device_code; } }; }
5,915
C++
.h
115
39.808696
152
0.631187
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,443
i2c_bus_manager.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp
/* * 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 "i2c_bus_accessor.hpp" #include "i2c_i_allocator.hpp" namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cBusAccessorManager : public IAllocator<I2cBusAccessor::BusAccessorList> { public: using IAllocator<I2cBusAccessor::BusAccessorList>::IAllocator; }; }
985
C++
.h
25
36.6
86
0.751306
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,444
i2c_i_allocator.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp
/* * 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> namespace ams::i2c::driver::board::nintendo::nx::impl { template<typename ListType> class IAllocator { NON_COPYABLE(IAllocator); NON_MOVEABLE(IAllocator); private: using T = typename ListType::value_type; private: ams::MemoryResource *m_memory_resource; ListType m_list; mutable os::SdkMutex m_list_lock; public: IAllocator(ams::MemoryResource *mr) : m_memory_resource(mr), m_list(), m_list_lock() { /* ... */ } ~IAllocator() { std::scoped_lock lk(m_list_lock); /* Remove all entries. */ auto it = m_list.begin(); while (it != m_list.end()) { T *obj = std::addressof(*it); it = m_list.erase(it); std::destroy_at(obj); m_memory_resource->Deallocate(obj, sizeof(T)); } } template<typename ...Args> T *Allocate(Args &&...args) { std::scoped_lock lk(m_list_lock); /* Allocate space for the object. */ void *storage = m_memory_resource->Allocate(sizeof(T), alignof(T)); AMS_ABORT_UNLESS(storage != nullptr); /* Construct the object. */ T *t = std::construct_at(static_cast<T *>(storage), std::forward<Args>(args)...); /* Link the object into our list. */ m_list.push_back(*t); return t; } template<typename F> T *Find(F f) { std::scoped_lock lk(m_list_lock); for (T &it : m_list) { if (f(static_cast<const T &>(it))) { return std::addressof(it); } } return nullptr; } /* TODO: Support free */ }; }
2,636
C++
.h
66
28.621212
110
0.537378
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,445
i2c_i2c_registers.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i2c_registers.hpp
/* * 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> namespace ams::i2c::driver::board::nintendo::nx::impl { struct I2cRegisters { volatile u32 cnfg; volatile u32 cmd_addr0; volatile u32 cmd_addr1; volatile u32 cmd_data1; volatile u32 cmd_data2; volatile u32 _14; volatile u32 _18; volatile u32 status; volatile u32 sl_cnfg; volatile u32 sl_rcvd; volatile u32 sl_status; volatile u32 sl_addr1; volatile u32 sl_addr2; volatile u32 tlow_sext; volatile u32 _38; volatile u32 sl_delay_count; volatile u32 sl_int_mask; volatile u32 sl_int_source; volatile u32 sl_int_set; volatile u32 _4c; volatile u32 tx_packet_fifo; volatile u32 rx_fifo; volatile u32 packet_transfer_status; volatile u32 fifo_control; volatile u32 fifo_status; volatile u32 interrupt_mask_register; volatile u32 interrupt_status_register; volatile u32 clk_divisor_register; volatile u32 interrupt_source_register; volatile u32 interrupt_set_register; volatile u32 slv_tx_packet_fifo; volatile u32 slv_rx_fifo; volatile u32 slv_packet_status; volatile u32 bus_clear_config; volatile u32 bus_clear_status; volatile u32 config_load; volatile u32 _90; volatile u32 interface_timing_0; volatile u32 interface_timing_1; volatile u32 hs_interface_timing_0; volatile u32 hs_interface_timing_1; }; static_assert(sizeof(I2cRegisters) == 0xA4); }
2,267
C++
.h
63
29.31746
76
0.675602
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,446
i2c_server_session_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp
/* * 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> namespace ams::i2c::server { class ManagerImpl; class SessionImpl { private: ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ i2c::driver::I2cSession m_internal_session; bool m_has_session; public: explicit SessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ } ~SessionImpl() { if (m_has_session) { i2c::driver::CloseSession(m_internal_session); } } Result OpenSession(DeviceCode device_code) { AMS_ABORT_UNLESS(!m_has_session); R_TRY(i2c::driver::OpenSession(std::addressof(m_internal_session), device_code)); m_has_session = true; R_SUCCEED(); } public: /* Actual commands. */ Result SendOld(const ams::sf::InBuffer &in_data, i2c::TransactionOption option) { R_RETURN(i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option)); } Result ReceiveOld(const ams::sf::OutBuffer &out_data, i2c::TransactionOption option) { R_RETURN(i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option)); } Result ExecuteCommandListOld(const ams::sf::OutBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list){ R_RETURN(i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand))); } Result Send(const ams::sf::InAutoSelectBuffer &in_data, i2c::TransactionOption option) { R_RETURN(i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option)); } Result Receive(const ams::sf::OutAutoSelectBuffer &out_data, i2c::TransactionOption option) { R_RETURN(i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option)); } Result ExecuteCommandList(const ams::sf::OutAutoSelectBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list) { R_RETURN(i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand))); } Result SetRetryPolicy(s32 max_retry_count, s32 retry_interval_us) { R_RETURN(i2c::driver::SetRetryPolicy(m_internal_session, max_retry_count, retry_interval_us)); } }; static_assert(i2c::sf::IsISession<SessionImpl>); }
3,482
C++
.h
63
45.206349
196
0.639166
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,447
i2c_server_manager_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.hpp
/* * 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 "i2c_server_session_impl.hpp" namespace ams::i2c::server { class ManagerImpl { private: using Allocator = ams::sf::ExpHeapAllocator; using Factory = ams::sf::ObjectFactory<Allocator::Policy>; private: lmem::HeapHandle m_heap_handle; Allocator m_allocator; u8 m_heap_buffer[4_KB]; public: ManagerImpl(); ~ManagerImpl(); public: /* Actual commands. */ Result OpenSessionForDev(ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, s32 bus_idx, u16 slave_address, i2c::AddressingMode addressing_mode, i2c::SpeedMode speed_mode); Result OpenSession(ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, i2c::I2cDevice device); Result HasDevice(ams::sf::Out<bool> out, i2c::I2cDevice device); Result HasDeviceForDev(ams::sf::Out<bool> out, i2c::I2cDevice device); Result OpenSession2(ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, DeviceCode device_code); }; static_assert(i2c::sf::IsIManager<ManagerImpl>); }
1,824
C++
.h
40
39.15
194
0.678652
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,448
cal_crc_utils.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/cal/cal_crc_utils.hpp
/* * 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> namespace ams::cal::impl { u16 CalculateCrc16(const void *data, size_t size); Result ValidateCalibrationCrc(const void *data, size_t size); }
829
C++
.h
21
37.285714
76
0.756522
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,449
cal_fs_utils.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/cal/cal_fs_utils.hpp
/* * 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> namespace ams::cal::impl { Result ReadCalibrationBlock(s64 offset, void *dst, size_t block_size); }
783
C++
.h
20
37.1
76
0.757895
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,450
fs_file_path_hash.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fs_file_path_hash.hpp
/* * 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> namespace ams::fs::impl { constexpr inline size_t FilePathHashSize = 4; struct FilePathHash : public Newable { u8 data[FilePathHashSize]; }; static_assert(util::is_pod<FilePathHash>::value); inline bool operator==(const FilePathHash &lhs, const FilePathHash &rhs) { return std::memcmp(lhs.data, rhs.data, FilePathHashSize) == 0; } inline bool operator!=(const FilePathHash &lhs, const FilePathHash &rhs) { return !(lhs == rhs); } }
1,170
C++
.h
30
35.466667
78
0.723986
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,451
fs_remote_file_system_proxy.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy.hpp
/* * 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 <stratosphere/fssrv/fssrv_interface_adapters.hpp> #include "../fssrv/impl/fssrv_allocator_for_service_framework.hpp" #include "impl/fs_remote_event_notifier.hpp" #include "impl/fs_remote_device_operator.hpp" namespace ams::fs { #if defined(ATMOSPHERE_OS_HORIZON) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" class RemoteFileSystemProxy { NON_COPYABLE(RemoteFileSystemProxy); NON_MOVEABLE(RemoteFileSystemProxy); private: using ObjectFactory = fssrv::impl::FileSystemObjectFactory; public: RemoteFileSystemProxy(int session_count); ~RemoteFileSystemProxy(); public: /* Command interface */ Result OpenFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, const fssrv::sf::FspPath &path, u32 type) { AMS_ABORT("TODO"); } Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid) { /* Libnx does this for us automatically. */ AMS_UNUSED(client_pid); R_SUCCEED(); } Result OpenDataFileSystemByCurrentProcess(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out) { AMS_ABORT("TODO"); } Result OpenFileSystemWithPatch(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, ncm::ProgramId program_id, u32 type) { AMS_ABORT("TODO"); } Result OpenFileSystemWithIdObsolete(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type) { R_RETURN(this->OpenFileSystemWithId(out, path, fs::ContentAttributes_None, program_id, type)); } Result OpenFileSystemWithId(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u64 program_id, u32 type) { ::FsFileSystem fs; R_TRY(fsOpenFileSystemWithId(std::addressof(fs), program_id, static_cast<::FsFileSystemType>(type), path.str, static_cast<::FsContentAttributes>(static_cast<u8>(attr)))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result OpenDataFileSystemByProgramId(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, ncm::ProgramId program_id) { AMS_ABORT("TODO"); } Result OpenBisFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, const fssrv::sf::FspPath &path, u32 id) { AMS_ABORT("TODO"); } Result OpenBisStorage(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, u32 id) { FsStorage s; R_TRY(fsOpenBisStorage(std::addressof(s), static_cast<::FsBisPartitionId>(id))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IStorage, fssrv::impl::RemoteStorage>(s)); R_SUCCEED(); } Result InvalidateBisCache() { AMS_ABORT("TODO"); } Result OpenHostFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, const fssrv::sf::FspPath &path) { AMS_ABORT("TODO"); } Result OpenSdCardFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out) { ::FsFileSystem fs; R_TRY(fsOpenSdCardFileSystem(std::addressof(fs))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result FormatSdCardFileSystem() { AMS_ABORT("TODO"); } Result DeleteSaveDataFileSystem(u64 save_data_id) { AMS_UNUSED(save_data_id); AMS_ABORT("TODO: libnx binding"); } Result CreateSaveDataFileSystem(const fs::SaveDataAttribute &attribute, const fs::SaveDataCreationInfo &creation_info, const fs::SaveDataMetaInfo &meta_info) { AMS_ABORT("TODO"); } Result CreateSaveDataFileSystemBySystemSaveDataId(const fs::SaveDataAttribute &attribute, const fs::SaveDataCreationInfo &creation_info) { static_assert(sizeof(attribute) == sizeof(::FsSaveDataAttribute)); static_assert(sizeof(creation_info) == sizeof(::FsSaveDataCreationInfo)); R_RETURN(fsCreateSaveDataFileSystemBySystemSaveDataId(reinterpret_cast<const ::FsSaveDataAttribute *>(std::addressof(attribute)), reinterpret_cast<const ::FsSaveDataCreationInfo *>(std::addressof(creation_info)))); } Result RegisterSaveDataFileSystemAtomicDeletion(const ams::sf::InBuffer &save_data_ids) { AMS_ABORT("TODO"); } Result DeleteSaveDataFileSystemBySaveDataSpaceId(u8 indexer_space_id, u64 save_data_id) { R_RETURN(fsDeleteSaveDataFileSystemBySaveDataSpaceId(static_cast<::FsSaveDataSpaceId>(indexer_space_id), save_data_id)); } Result FormatSdCardDryRun() { AMS_ABORT("TODO"); } Result IsExFatSupported(ams::sf::Out<bool> out) { AMS_ABORT("TODO"); } Result DeleteSaveDataFileSystemBySaveDataAttribute(u8 space_id, const fs::SaveDataAttribute &attribute) { static_assert(sizeof(attribute) == sizeof(::FsSaveDataAttribute)); R_RETURN(fsDeleteSaveDataFileSystemBySaveDataAttribute(static_cast<::FsSaveDataSpaceId>(space_id), reinterpret_cast<const ::FsSaveDataAttribute *>(std::addressof(attribute)))); } Result OpenGameCardStorage(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, u32 handle, u32 partition) { AMS_ABORT("TODO"); } Result OpenGameCardFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u32 handle, u32 partition) { ::FsFileSystem fs; const ::FsGameCardHandle _hnd = {handle}; R_TRY(fsOpenGameCardFileSystem(std::addressof(fs), std::addressof(_hnd), static_cast<::FsGameCardPartition>(partition))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result ExtendSaveDataFileSystem(u8 space_id, u64 save_data_id, s64 available_size, s64 journal_size) { R_RETURN(::fsExtendSaveDataFileSystem(static_cast<::FsSaveDataSpaceId>(space_id), save_data_id, available_size, journal_size)); } Result DeleteCacheStorage(u16 index) { AMS_ABORT("TODO"); } Result GetCacheStorageSize(ams::sf::Out<s64> out_size, ams::sf::Out<s64> out_journal_size, u16 index) { AMS_ABORT("TODO"); } Result CreateSaveDataFileSystemWithHashSalt(const fs::SaveDataAttribute &attribute, const fs::SaveDataCreationInfo &creation_info, const fs::SaveDataMetaInfo &meta_info, const fs::HashSalt &salt) { AMS_ABORT("TODO"); } Result OpenHostFileSystemWithOption(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, const fssrv::sf::FspPath &path, u32 option) { AMS_ABORT("TODO"); } Result OpenSaveDataFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u8 space_id, const fs::SaveDataAttribute &attribute) { ::FsFileSystem fs; R_TRY(fsOpenSaveDataFileSystem(std::addressof(fs), static_cast<::FsSaveDataSpaceId>(space_id), reinterpret_cast<const ::FsSaveDataAttribute *>(std::addressof(attribute)))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result OpenSaveDataFileSystemBySystemSaveDataId(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u8 space_id, const fs::SaveDataAttribute &attribute) { ::FsFileSystem fs; R_TRY(fsOpenSaveDataFileSystemBySystemSaveDataId(std::addressof(fs), static_cast<::FsSaveDataSpaceId>(space_id), reinterpret_cast<const ::FsSaveDataAttribute *>(std::addressof(attribute)))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result OpenReadOnlySaveDataFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u8 space_id, const fs::SaveDataAttribute &attribute) { AMS_ABORT("TODO"); } Result ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(const ams::sf::OutBuffer &buffer, u8 space_id, u64 save_data_id) { R_RETURN(fsReadSaveDataFileSystemExtraDataBySaveDataSpaceId(buffer.GetPointer(), buffer.GetSize(), static_cast<::FsSaveDataSpaceId>(space_id), save_data_id)); } Result ReadSaveDataFileSystemExtraData(const ams::sf::OutBuffer &buffer, u64 save_data_id) { R_RETURN(fsReadSaveDataFileSystemExtraData(buffer.GetPointer(), buffer.GetSize(), save_data_id)); } Result WriteSaveDataFileSystemExtraData(u64 save_data_id, u8 space_id, const ams::sf::InBuffer &buffer) { R_RETURN(fsWriteSaveDataFileSystemExtraData(buffer.GetPointer(), buffer.GetSize(), static_cast<::FsSaveDataSpaceId>(space_id), save_data_id)); } /* ... */ Result OpenImageDirectoryFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u32 id) { ::FsFileSystem fs; R_TRY(fsOpenImageDirectoryFileSystem(std::addressof(fs), static_cast<::FsImageDirectoryId>(id))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } /* ... */ Result OpenContentStorageFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u32 id) { ::FsFileSystem fs; R_TRY(fsOpenContentStorageFileSystem(std::addressof(fs), static_cast<::FsContentStorageId>(id))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } /* ... */ Result OpenDataStorageByCurrentProcess(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out) { AMS_ABORT("TODO"); } Result OpenDataStorageByProgramId(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, ncm::ProgramId program_id) { AMS_ABORT("TODO"); } Result OpenDataStorageByDataId(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, ncm::DataId data_id, u8 storage_id) { ::FsStorage s; R_TRY(fsOpenDataStorageByDataId(std::addressof(s), data_id.value, static_cast<::NcmStorageId>(storage_id))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IStorage, fssrv::impl::RemoteStorage>(s)); R_SUCCEED(); } Result OpenPatchDataStorageByCurrentProcess(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out) { AMS_ABORT("TODO"); } Result OpenDataFileSystemWithProgramIndex(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out, u8 index) { AMS_ABORT("TODO"); } Result OpenDataStorageWithProgramIndex(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, u8 index) { AMS_ABORT("TODO"); } Result OpenDataStorageByPathObsolete(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, const fssrv::sf::FspPath &path, u32 type) { AMS_ABORT("TODO"); } Result OpenDataStorageByPath(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IStorage>> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u32 type) { AMS_ABORT("TODO"); } Result OpenDeviceOperator(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IDeviceOperator>> out) { ::FsDeviceOperator d; R_TRY(fsOpenDeviceOperator(std::addressof(d))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IDeviceOperator, impl::RemoteDeviceOperator>(d)); R_SUCCEED(); } Result OpenSdCardDetectionEventNotifier(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IEventNotifier>> out) { ::FsEventNotifier e; R_TRY(fsOpenSdCardDetectionEventNotifier(std::addressof(e))); out.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IEventNotifier, impl::RemoteEventNotifier>(e)); R_SUCCEED(); } Result OpenGameCardDetectionEventNotifier(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IEventNotifier>> out) { AMS_ABORT("TODO"); } Result OpenSystemDataUpdateEventNotifier(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IEventNotifier>> out) { AMS_ABORT("TODO"); } Result NotifySystemDataUpdateEvent() { AMS_ABORT("TODO"); } /* ... */ Result SetCurrentPosixTime(s64 posix_time) { AMS_ABORT("TODO"); } /* ... */ Result GetRightsId(ams::sf::Out<fs::RightsId> out, ncm::ProgramId program_id, ncm::StorageId storage_id) { AMS_ABORT("TODO"); } Result RegisterExternalKey(const fs::RightsId &rights_id, const spl::AccessKey &access_key) { AMS_ABORT("TODO"); } Result UnregisterAllExternalKey() { AMS_ABORT("TODO"); } Result GetProgramId(ams::sf::Out<ncm::ProgramId> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr) { static_assert(sizeof(ncm::ProgramId) == sizeof(u64)); R_RETURN(fsGetProgramId(reinterpret_cast<u64 *>(out.GetPointer()), path.str, static_cast<::FsContentAttributes>(static_cast<u8>(attr)))); } Result GetRightsIdByPath(ams::sf::Out<fs::RightsId> out, const fssrv::sf::FspPath &path) { static_assert(sizeof(RightsId) == sizeof(::FsRightsId)); R_RETURN(fsGetRightsIdByPath(path.str, reinterpret_cast<::FsRightsId *>(out.GetPointer()))); } Result GetRightsIdAndKeyGenerationByPathObsolete(ams::sf::Out<fs::RightsId> out, ams::sf::Out<u8> out_key_generation, const fssrv::sf::FspPath &path) { R_RETURN(this->GetRightsIdAndKeyGenerationByPath(out, out_key_generation, path, fs::ContentAttributes_None)) } Result GetRightsIdAndKeyGenerationByPath(ams::sf::Out<fs::RightsId> out, ams::sf::Out<u8> out_key_generation, const fssrv::sf::FspPath &path, fs::ContentAttributes attr) { static_assert(sizeof(RightsId) == sizeof(::FsRightsId)); R_RETURN(fsGetRightsIdAndKeyGenerationByPath(path.str, static_cast<::FsContentAttributes>(static_cast<u8>(attr)), out_key_generation.GetPointer(), reinterpret_cast<::FsRightsId *>(out.GetPointer()))); } Result SetCurrentPosixTimeWithTimeDifference(s64 posix_time, s32 time_difference) { AMS_ABORT("TODO"); } Result GetFreeSpaceSizeForSaveData(ams::sf::Out<s64> out, u8 space_id) { AMS_ABORT("TODO"); } Result VerifySaveDataFileSystemBySaveDataSpaceId() { AMS_ABORT("TODO"); } Result CorruptSaveDataFileSystemBySaveDataSpaceId() { AMS_ABORT("TODO"); } Result QuerySaveDataInternalStorageTotalSize() { AMS_ABORT("TODO"); } Result GetSaveDataCommitId() { AMS_ABORT("TODO"); } Result UnregisterExternalKey(const fs::RightsId &rights_id) { AMS_ABORT("TODO"); } Result SetSdCardEncryptionSeed(const fs::EncryptionSeed &seed) { AMS_ABORT("TODO"); } Result SetSdCardAccessibility(bool accessible) { AMS_ABORT("TODO"); } Result IsSdCardAccessible(ams::sf::Out<bool> out) { AMS_ABORT("TODO"); } Result IsSignedSystemPartitionOnSdCardValid(ams::sf::Out<bool> out) { R_RETURN(fsIsSignedSystemPartitionOnSdCardValid(out.GetPointer())); } Result OpenAccessFailureDetectionEventNotifier() { AMS_ABORT("TODO"); } /* ... */ Result GetAndClearErrorInfo(ams::sf::Out<fs::FileSystemProxyErrorInfo> out) { static_assert(sizeof(fs::FileSystemProxyErrorInfo) == sizeof(::FsFileSystemProxyErrorInfo)); R_RETURN(::fsGetAndClearErrorInfo(reinterpret_cast<::FsFileSystemProxyErrorInfo *>(out.GetPointer()))); } Result RegisterProgramIndexMapInfo(const ams::sf::InBuffer &buffer, s32 count) { AMS_ABORT("TODO"); } Result SetBisRootForHost(u32 id, const fssrv::sf::FspPath &path) { AMS_ABORT("TODO"); } Result SetSaveDataSize(s64 size, s64 journal_size) { AMS_ABORT("TODO"); } Result SetSaveDataRootPath(const fssrv::sf::FspPath &path) { AMS_ABORT("TODO"); } Result DisableAutoSaveDataCreation() { R_RETURN(::fsDisableAutoSaveDataCreation()); } Result SetGlobalAccessLogMode(u32 mode) { R_RETURN(::fsSetGlobalAccessLogMode(mode)); } Result GetGlobalAccessLogMode(sf::Out<u32> out) { R_RETURN(::fsGetGlobalAccessLogMode(out.GetPointer())); } Result OutputAccessLogToSdCard(const ams::sf::InBuffer &buf) { R_RETURN(::fsOutputAccessLogToSdCard(reinterpret_cast<const char *>(buf.GetPointer()), buf.GetSize())); } Result RegisterUpdatePartition() { AMS_ABORT("TODO"); } Result OpenRegisteredUpdatePartition(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out) { AMS_ABORT("TODO"); } Result GetAndClearMemoryReportInfo(ams::sf::Out<fs::MemoryReportInfo> out) { static_assert(sizeof(fs::MemoryReportInfo) == sizeof(::FsMemoryReportInfo)); R_RETURN(::fsGetAndClearMemoryReportInfo(reinterpret_cast<::FsMemoryReportInfo *>(out.GetPointer()))); } /* ... */ Result GetProgramIndexForAccessLog(ams::sf::Out<u32> out_idx, ams::sf::Out<u32> out_count) { R_RETURN(::fsGetProgramIndexForAccessLog(out_idx.GetPointer(), out_count.GetPointer())); } Result GetFsStackUsage(ams::sf::Out<u32> out, u32 type) { AMS_ABORT("TODO"); } Result UnsetSaveDataRootPath() { AMS_ABORT("TODO"); } Result OutputMultiProgramTagAccessLog() { AMS_ABORT("TODO"); } Result FlushAccessLogOnSdCard() { AMS_ABORT("TODO"); } Result OutputApplicationInfoAccessLog() { AMS_ABORT("TODO"); } Result RegisterDebugConfiguration(u32 key, s64 value) { AMS_ABORT("TODO"); } Result UnregisterDebugConfiguration(u32 key) { AMS_ABORT("TODO"); } Result OverrideSaveDataTransferTokenSignVerificationKey(const ams::sf::InBuffer &buf) { AMS_ABORT("TODO"); } Result CorruptSaveDataFileSystemByOffset(u8 space_id, u64 save_data_id, s64 offset) { AMS_ABORT("TODO"); } /* ... */ }; static_assert(fssrv::sf::IsIFileSystemProxy<RemoteFileSystemProxy>); #pragma GCC diagnostic pop #endif }
21,590
C++
.h
366
45.103825
230
0.611717
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,452
fs_remote_file_system_proxy_for_loader.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy_for_loader.hpp
/* * 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 <stratosphere/fssrv/fssrv_interface_adapters.hpp> #include "../fssrv/impl/fssrv_allocator_for_service_framework.hpp" namespace ams::fs { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteFileSystemProxyForLoader { NON_COPYABLE(RemoteFileSystemProxyForLoader); NON_MOVEABLE(RemoteFileSystemProxyForLoader); private: using ObjectFactory = fssrv::impl::FileSystemObjectFactory; public: RemoteFileSystemProxyForLoader(); ~RemoteFileSystemProxyForLoader(); public: Result OpenCodeFileSystemDeprecated(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id) { ::FsCodeInfo dummy; ::FsFileSystem fs; R_TRY(fsldrOpenCodeFileSystem(std::addressof(dummy), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast<u8>(fs::ContentAttributes_None)), std::addressof(fs))); out_fs.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result OpenCodeFileSystemDeprecated2(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out_fs, ams::sf::Out<fs::CodeVerificationData> out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { ::FsFileSystem fs; R_TRY(fsldrOpenCodeFileSystem(reinterpret_cast<::FsCodeInfo *>(out_verif.GetPointer()), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast<u8>(fs::ContentAttributes_None)), std::addressof(fs))); out_fs.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result OpenCodeFileSystemDeprecated3(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out_fs, ams::sf::Out<fs::CodeVerificationData> out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id) { ::FsFileSystem fs; R_TRY(fsldrOpenCodeFileSystem(reinterpret_cast<::FsCodeInfo *>(out_verif.GetPointer()), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast<u8>(attr)), std::addressof(fs))); out_fs.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result OpenCodeFileSystem(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFileSystem>> out_fs, const ams::sf::OutBuffer &out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id) { ::FsFileSystem fs; R_TRY(fsldrOpenCodeFileSystem(reinterpret_cast<::FsCodeInfo *>(out_verif.GetPointer()), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast<u8>(attr)), std::addressof(fs))); out_fs.SetValue(ObjectFactory::CreateSharedEmplaced<fssrv::sf::IFileSystem, fssrv::impl::RemoteFileSystem>(fs)); R_SUCCEED(); } Result IsArchivedProgram(ams::sf::Out<bool> out, u64 process_id) { R_RETURN(fsldrIsArchivedProgram(process_id, out.GetPointer())); } Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid) { /* Libnx does this for us automatically. */ AMS_UNUSED(client_pid); R_SUCCEED(); } }; static_assert(fssrv::sf::IsIFileSystemProxyForLoader<RemoteFileSystemProxyForLoader>); #endif }
4,358
C++
.h
67
55.059701
253
0.678196
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,453
fs_scoped_setter.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fs_scoped_setter.hpp
/* * 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> namespace ams::fs { template<typename T> class ScopedSetter { NON_COPYABLE(ScopedSetter); private: T *m_ptr; T m_value; public: constexpr ALWAYS_INLINE ScopedSetter(T &p, T v) : m_ptr(std::addressof(p)), m_value(v) { /* ... */ } ALWAYS_INLINE ~ScopedSetter() { if (m_ptr) { *m_ptr = m_value; } } ALWAYS_INLINE ScopedSetter(ScopedSetter &&rhs) { m_ptr = rhs.ptr; m_value = rhs.value; rhs.Reset(); } ALWAYS_INLINE ScopedSetter &operator=(ScopedSetter &&rhs) { m_ptr = rhs.ptr; m_value = rhs.value; rhs.Reset(); return *this; } ALWAYS_INLINE void Set(T v) { m_value = v; } private: ALWAYS_INLINE void Reset() { m_ptr = nullptr; } }; template<typename T> ALWAYS_INLINE ScopedSetter<T> MakeScopedSetter(T &p, T v) { return ScopedSetter<T>(p, v); } }
1,816
C++
.h
53
25.54717
112
0.574032
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,454
fs_remote_device_operator.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/impl/fs_remote_device_operator.hpp
/* * 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> namespace ams::fs::impl { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteDeviceOperator { private: ::FsDeviceOperator m_operator; public: RemoteDeviceOperator(::FsDeviceOperator &o) : m_operator(o) { /* ... */ } virtual ~RemoteDeviceOperator() { fsDeviceOperatorClose(std::addressof(m_operator)); } public: Result IsSdCardInserted(ams::sf::Out<bool> out) { R_RETURN(fsDeviceOperatorIsSdCardInserted(std::addressof(m_operator), out.GetPointer())); } Result GetSdCardSpeedMode(ams::sf::Out<s64> out) { R_RETURN(fsDeviceOperatorGetSdCardSpeedMode(std::addressof(m_operator), out.GetPointer())); } Result GetSdCardCid(ams::sf::OutBuffer out, s64 size) { R_RETURN(fsDeviceOperatorGetSdCardCid(std::addressof(m_operator), out.GetPointer(), out.GetSize(), size)); } Result GetSdCardUserAreaSize(ams::sf::Out<s64> out) { R_RETURN(fsDeviceOperatorGetSdCardUserAreaSize(std::addressof(m_operator), out.GetPointer())); } Result GetSdCardProtectedAreaSize(ams::sf::Out<s64> out) { R_RETURN(fsDeviceOperatorGetSdCardProtectedAreaSize(std::addressof(m_operator), out.GetPointer())); } Result GetAndClearSdCardErrorInfo(ams::sf::Out<fs::StorageErrorInfo> out_sei, ams::sf::Out<s64> out_size, ams::sf::OutBuffer out_buf, s64 size) { static_assert(sizeof(::FsStorageErrorInfo) == sizeof(fs::StorageErrorInfo)); R_RETURN(fsDeviceOperatorGetAndClearSdCardErrorInfo(std::addressof(m_operator), reinterpret_cast<::FsStorageErrorInfo *>(out_sei.GetPointer()), out_size.GetPointer(), out_buf.GetPointer(), out_buf.GetSize(), size)); } Result GetMmcCid(ams::sf::OutBuffer out, s64 size) { R_RETURN(fsDeviceOperatorGetMmcCid(std::addressof(m_operator), out.GetPointer(), out.GetSize(), size)); } Result GetMmcSpeedMode(ams::sf::Out<s64> out) { R_RETURN(fsDeviceOperatorGetMmcSpeedMode(std::addressof(m_operator), out.GetPointer())); } Result GetMmcPatrolCount(ams::sf::Out<u32> out) { R_RETURN(fsDeviceOperatorGetMmcPatrolCount(std::addressof(m_operator), out.GetPointer())); } Result GetAndClearMmcErrorInfo(ams::sf::Out<fs::StorageErrorInfo> out_sei, ams::sf::Out<s64> out_size, ams::sf::OutBuffer out_buf, s64 size) { static_assert(sizeof(::FsStorageErrorInfo) == sizeof(fs::StorageErrorInfo)); R_RETURN(fsDeviceOperatorGetAndClearMmcErrorInfo(std::addressof(m_operator), reinterpret_cast<::FsStorageErrorInfo *>(out_sei.GetPointer()), out_size.GetPointer(), out_buf.GetPointer(), out_buf.GetSize(), size)); } Result GetMmcExtendedCsd(ams::sf::OutBuffer out, s64 size) { R_RETURN(fsDeviceOperatorGetMmcExtendedCsd(std::addressof(m_operator), out.GetPointer(), out.GetSize(), size)); } Result IsGameCardInserted(ams::sf::Out<bool> out) { R_RETURN(fsDeviceOperatorIsGameCardInserted(std::addressof(m_operator), out.GetPointer())); } Result GetGameCardHandle(ams::sf::Out<u32> out) { static_assert(sizeof(::FsGameCardHandle) == sizeof(u32)); R_RETURN(fsDeviceOperatorGetGameCardHandle(std::addressof(m_operator), reinterpret_cast<::FsGameCardHandle *>(out.GetPointer()))); } Result GetGameCardIdSet(ams::sf::OutBuffer out, s64 size) { R_RETURN(fsDeviceOperatorGetGameCardIdSet(std::addressof(m_operator), out.GetPointer(), out.GetSize(), size)); } Result GetGameCardErrorReportInfo(ams::sf::Out<fs::GameCardErrorReportInfo> out) { static_assert(sizeof(::FsGameCardErrorReportInfo) == sizeof(fs::GameCardErrorReportInfo)); R_RETURN(fsDeviceOperatorGetGameCardErrorReportInfo(std::addressof(m_operator), reinterpret_cast<::FsGameCardErrorReportInfo *>(out.GetPointer()))); } Result GetGameCardDeviceId(ams::sf::OutBuffer out, s64 size) { R_RETURN(fsDeviceOperatorGetGameCardDeviceId(std::addressof(m_operator), out.GetPointer(), out.GetSize(), size)); } }; static_assert(fssrv::sf::IsIDeviceOperator<RemoteDeviceOperator>); #endif }
5,213
C++
.h
84
51
231
0.658904
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,455
fs_file_system_service_object_adapter.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/impl/fs_file_system_service_object_adapter.hpp
/* * 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> namespace ams::fs::impl { class FileServiceObjectAdapter : public ::ams::fs::impl::Newable, public ::ams::fs::fsa::IFile { NON_COPYABLE(FileServiceObjectAdapter); NON_MOVEABLE(FileServiceObjectAdapter); private: sf::SharedPointer<fssrv::sf::IFile> m_x; public: explicit FileServiceObjectAdapter(sf::SharedPointer<fssrv::sf::IFile> &&o) : m_x(o) { /* ... */} virtual ~FileServiceObjectAdapter() { /* ... */ } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { s64 read_size = 0; R_TRY(m_x->Read(std::addressof(read_size), offset, sf::OutNonSecureBuffer(buffer, size), static_cast<s64>(size), option)); *out = static_cast<size_t>(read_size); R_SUCCEED(); } virtual Result DoGetSize(s64 *out) override final { R_RETURN(m_x->GetSize(out)); } virtual Result DoFlush() override final { R_RETURN(m_x->Flush()); } virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final { R_RETURN(m_x->Write(offset, sf::InNonSecureBuffer(buffer, size), static_cast<s64>(size), option)); } virtual Result DoSetSize(s64 size) override final { R_RETURN(m_x->SetSize(size)); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { switch (op_id) { case OperationId::Invalidate: { fs::QueryRangeInfo dummy_range_info; R_RETURN(m_x->OperateRange(std::addressof(dummy_range_info), static_cast<s32>(op_id), offset, size)); } case OperationId::QueryRange: { R_UNLESS(dst != nullptr, fs::ResultNullptrArgument()); R_UNLESS(dst_size == sizeof(fs::QueryRangeInfo), fs::ResultInvalidSize()); R_RETURN(m_x->OperateRange(reinterpret_cast<fs::QueryRangeInfo *>(dst), static_cast<s32>(op_id), offset, size)); } default: { R_RETURN(m_x->OperateRangeWithBuffer(sf::OutNonSecureBuffer(dst, dst_size), sf::InNonSecureBuffer(src, src_size), static_cast<s32>(op_id), offset, size)); } } } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override final { AMS_ABORT("Invalid GetDomainObjectId call"); } }; class DirectoryServiceObjectAdapter : public ::ams::fs::impl::Newable, public ::ams::fs::fsa::IDirectory { NON_COPYABLE(DirectoryServiceObjectAdapter); NON_MOVEABLE(DirectoryServiceObjectAdapter); private: sf::SharedPointer<fssrv::sf::IDirectory> m_x; public: explicit DirectoryServiceObjectAdapter(sf::SharedPointer<fssrv::sf::IDirectory> &&o) : m_x(o) { /* ... */} virtual ~DirectoryServiceObjectAdapter() { /* ... */ } public: virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override final { R_RETURN(m_x->Read(out_count, sf::OutBuffer(out_entries, max_entries * sizeof(*out_entries)))); } virtual Result DoGetEntryCount(s64 *out) override final { R_RETURN(m_x->GetEntryCount(out)); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override final { AMS_ABORT("Invalid GetDomainObjectId call"); } }; class FileSystemServiceObjectAdapter : public ::ams::fs::impl::Newable, public ::ams::fs::fsa::IFileSystem { NON_COPYABLE(FileSystemServiceObjectAdapter); NON_MOVEABLE(FileSystemServiceObjectAdapter); private: sf::SharedPointer<fssrv::sf::IFileSystem> m_x; public: explicit FileSystemServiceObjectAdapter(sf::SharedPointer<fssrv::sf::IFileSystem> &&o) : m_x(o) { /* ... */} virtual ~FileSystemServiceObjectAdapter() { /* ... */ } sf::SharedPointer<fssrv::sf::IFileSystem> GetFileSystem() const { return m_x; } private: static Result GetPathForServiceObject(fssrv::sf::Path *out, const fs::Path &path) { const size_t len = util::Strlcpy<char>(out->str, path.GetString(), sizeof(out->str)); R_UNLESS(len < sizeof(out->str), fs::ResultTooLongPath()); R_SUCCEED(); } private: virtual Result DoOpenFile(std::unique_ptr<fsa::IFile> *out_file, const fs::Path &path, OpenMode mode) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); /* Open the file. */ sf::SharedPointer<fssrv::sf::IFile> file; R_TRY(m_x->OpenFile(std::addressof(file), fsp_path, mode)); /* Create the output fsa file. */ out_file->reset(new FileServiceObjectAdapter(std::move(file))); R_UNLESS(out_file != nullptr, fs::ResultAllocationMemoryFailedNew()); R_SUCCEED(); } virtual Result DoOpenDirectory(std::unique_ptr<fsa::IDirectory> *out_dir, const fs::Path &path, OpenDirectoryMode mode) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); /* Open the directory. */ sf::SharedPointer<fssrv::sf::IDirectory> dir; R_TRY(m_x->OpenDirectory(std::addressof(dir), fsp_path, mode)); /* Create the output fsa directory. */ out_dir->reset(new DirectoryServiceObjectAdapter(std::move(dir))); R_UNLESS(out_dir != nullptr, fs::ResultAllocationMemoryFailedNew()); R_SUCCEED(); } virtual Result DoGetEntryType(DirectoryEntryType *out, const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->GetEntryType(out, fsp_path)); } virtual Result DoCommit() override final { R_RETURN(m_x->Commit()); } virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->CreateFile(fsp_path, size, flags)); } virtual Result DoDeleteFile(const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->DeleteFile(fsp_path)); } virtual Result DoCreateDirectory(const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->CreateDirectory(fsp_path)); } virtual Result DoDeleteDirectory(const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->DeleteDirectory(fsp_path)); } virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->DeleteDirectoryRecursively(fsp_path)); } virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override final { /* Convert the path. */ fssrv::sf::Path fsp_old_path; fssrv::sf::Path fsp_new_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_old_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(fsp_new_path), new_path)); R_RETURN(m_x->RenameFile(fsp_old_path, fsp_new_path)); } virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override final { /* Convert the path. */ fssrv::sf::Path fsp_old_path; fssrv::sf::Path fsp_new_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_old_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(fsp_new_path), new_path)); R_RETURN(m_x->RenameDirectory(fsp_old_path, fsp_new_path)); } virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->CleanDirectoryRecursively(fsp_path)); } virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->GetFreeSpaceSize(out, fsp_path)); } virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->GetTotalSpaceSize(out, fsp_path)); } virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const fs::Path &path) override final { /* Convert the path. */ fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->GetFileTimeStampRaw(out, fsp_path)); } virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const fs::Path &path) override { fssrv::sf::Path fsp_path; R_TRY(GetPathForServiceObject(std::addressof(fsp_path), path)); R_RETURN(m_x->QueryEntry(sf::OutNonSecureBuffer(dst, dst_size), sf::InNonSecureBuffer(src, src_size), static_cast<s32>(query), fsp_path)); } }; }
12,085
C++
.h
215
41.916279
182
0.575537
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,456
fs_file_system_proxy_service_object.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/impl/fs_file_system_proxy_service_object.hpp
/* * 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> namespace ams::fs::impl { sf::SharedPointer<fssrv::sf::IFileSystemProxy> GetFileSystemProxyServiceObject(); sf::SharedPointer<fssrv::sf::IFileSystemProxyForLoader> GetFileSystemProxyForLoaderServiceObject(); }
897
C++
.h
21
40.52381
103
0.773196
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,457
fs_library.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/impl/fs_library.hpp
/* * 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> namespace ams::fs::impl { void InitializeFileSystemLibrary(); }
747
C++
.h
20
35.3
76
0.759669
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,458
fs_event_notifier_service_object_adapter.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/impl/fs_event_notifier_service_object_adapter.hpp
/* * 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> namespace ams::fs::impl { class EventNotifierObjectAdapter final : public ::ams::fs::IEventNotifier, public ::ams::fs::impl::Newable { private: sf::SharedPointer<fssrv::sf::IEventNotifier> m_object; public: EventNotifierObjectAdapter(sf::SharedPointer<fssrv::sf::IEventNotifier> &&obj) : m_object(obj) { /* ... */ } virtual ~EventNotifierObjectAdapter() { /* ... */ } private: virtual Result DoBindEvent(os::SystemEventType *out, os::EventClearMode clear_mode) override { /* Get the handle. */ sf::NativeHandle handle; AMS_FS_R_TRY(m_object->GetEventHandle(std::addressof(handle))); /* Create the system event. */ os::AttachReadableHandleToSystemEvent(out, handle.GetOsHandle(), handle.IsManaged(), clear_mode); handle.Detach(); R_SUCCEED(); } }; }
1,634
C++
.h
36
38.194444
120
0.658506
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,459
fs_remote_event_notifier.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/impl/fs_remote_event_notifier.hpp
/* * 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> namespace ams::fs::impl { #if defined(ATMOSPHERE_OS_HORIZON) class RemoteEventNotifier { private: ::FsEventNotifier m_notifier; public: RemoteEventNotifier(::FsEventNotifier &n) : m_notifier(n) { /* ... */ } virtual ~RemoteEventNotifier() { fsEventNotifierClose(std::addressof(m_notifier)); } public: Result GetEventHandle(ams::sf::OutCopyHandle out) { ::Event e; R_TRY(fsEventNotifierGetEventHandle(std::addressof(m_notifier), std::addressof(e), false)); out.SetValue(e.revent, true); R_SUCCEED(); } }; static_assert(fssrv::sf::IsIEventNotifier<RemoteEventNotifier>); #endif }
1,455
C++
.h
38
31.631579
107
0.661473
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,460
fs_mount_name.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_mount_name.hpp
/* * 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> namespace ams::fs { struct MountName { char str[MountNameLengthMax + 1]; }; static_assert(util::is_pod<MountName>::value); }
824
C++
.h
23
33.217391
76
0.740602
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,461
fs_mount_utils.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_mount_utils.hpp
/* * 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> namespace ams::fs::impl { class FileSystemAccessor; Result FindFileSystem(FileSystemAccessor **out_accessor, const char **out_sub_path, const char *path); bool IsWindowsDrive(const char *name); bool IsReservedMountName(const char *name); bool IsValidMountName(const char *name); Result CheckMountName(const char *name); Result CheckMountNameAllowingReserved(const char *name); }
1,088
C++
.h
26
39.038462
106
0.761589
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,462
fs_directory_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.hpp
/* * 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> namespace ams::fs::impl { class FileSystemAccessor; class DirectoryAccessor : public util::IntrusiveListBaseNode<DirectoryAccessor>, public Newable { NON_COPYABLE(DirectoryAccessor); private: std::unique_ptr<fsa::IDirectory> m_impl; FileSystemAccessor &m_parent; public: DirectoryAccessor(std::unique_ptr<fsa::IDirectory>&& d, FileSystemAccessor &p); ~DirectoryAccessor(); Result Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries); Result GetEntryCount(s64 *out); FileSystemAccessor *GetParent() const { return std::addressof(m_parent); } }; }
1,362
C++
.h
32
37.1875
101
0.70997
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,463
fs_mount_table.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_mount_table.hpp
/* * 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 "fs_filesystem_accessor.hpp" namespace ams::fs::impl { class MountTable : public Newable { NON_COPYABLE(MountTable); NON_MOVEABLE(MountTable); private: using FileSystemList = util::IntrusiveListBaseTraits<FileSystemAccessor>::ListType; private: FileSystemList m_fs_list; os::SdkMutex m_mutex; public: constexpr MountTable() : m_fs_list(), m_mutex() { /* ... */ } private: bool CanAcceptMountName(const char *name); public: Result Mount(std::unique_ptr<FileSystemAccessor> &&fs); Result Find(FileSystemAccessor **out, const char *name); void Unmount(const char *name); }; }
1,421
C++
.h
37
32.621622
95
0.679942
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,464
fs_user_mount_table.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.hpp
/* * 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> namespace ams::fs::impl { class FileSystemAccessor; Result Register(std::unique_ptr<FileSystemAccessor> &&fs); Result Find(FileSystemAccessor **out, const char *name); void Unregister(const char *name); }
901
C++
.h
23
36.695652
76
0.754005
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,465
fs_filesystem_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp
/* * 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 <stratosphere/fssrv/fssrv_interface_adapters.hpp> #include "fs_mount_name.hpp" namespace ams::fs::impl { class FileAccessor; class DirectoryAccessor; class FileSystemAccessor : public util::IntrusiveListBaseNode<FileSystemAccessor>, public Newable { NON_COPYABLE(FileSystemAccessor); friend class FileAccessor; friend class DirectoryAccessor; private: using FileList = util::IntrusiveListBaseTraits<FileAccessor>::ListType; using DirList = util::IntrusiveListBaseTraits<DirectoryAccessor>::ListType; private: MountName m_name; std::unique_ptr<fsa::IFileSystem> m_impl; FileList m_open_file_list; DirList m_open_dir_list; os::SdkMutex m_open_list_lock; std::unique_ptr<fsa::ICommonMountNameGenerator> m_mount_name_generator; bool m_access_log_enabled; bool m_data_cache_attachable; bool m_path_cache_attachable; bool m_path_cache_attached; bool m_multi_commit_supported; PathFlags m_path_flags; public: FileSystemAccessor(const char *name, std::unique_ptr<fsa::IFileSystem> &&fs, std::unique_ptr<fsa::ICommonMountNameGenerator> &&generator = nullptr); virtual ~FileSystemAccessor(); Result CreateFile(const char *path, s64 size, int option); Result DeleteFile(const char *path); Result CreateDirectory(const char *path); Result DeleteDirectory(const char *path); Result DeleteDirectoryRecursively(const char *path); Result RenameFile(const char *old_path, const char *new_path); Result RenameDirectory(const char *old_path, const char *new_path); Result GetEntryType(DirectoryEntryType *out, const char *path); Result OpenFile(std::unique_ptr<FileAccessor> *out_file, const char *path, OpenMode mode); Result OpenDirectory(std::unique_ptr<DirectoryAccessor> *out_dir, const char *path, OpenDirectoryMode mode); Result Commit(); Result GetFreeSpaceSize(s64 *out, const char *path); Result GetTotalSpaceSize(s64 *out, const char *path); Result CleanDirectoryRecursively(const char *path); Result GetFileTimeStampRaw(FileTimeStampRaw *out, const char *path); Result QueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path); const char *GetName() const { return m_name.str; } Result GetCommonMountName(char *dst, size_t dst_size) const; void SetAccessLogEnabled(bool en) { m_access_log_enabled = en; } void SetFileDataCacheAttachable(bool en) { m_data_cache_attachable = en; } void SetPathBasedFileDataCacheAttachable(bool en) { m_path_cache_attachable = en; } void SetMultiCommitSupported(bool en) { m_multi_commit_supported = en; } bool IsEnabledAccessLog() const { return m_access_log_enabled; } bool IsFileDataCacheAttachable() const { return m_data_cache_attachable; } bool IsPathBasedFileDataCacheAttachable() const { return m_path_cache_attachable; } void AttachPathBasedFileDataCache() { if (this->IsPathBasedFileDataCacheAttachable()) { m_path_cache_attached = true; } } void DetachPathBasedFileDataCache() { m_path_cache_attached = false; } std::shared_ptr<fssrv::impl::FileSystemInterfaceAdapter> GetMultiCommitTarget(); fsa::IFileSystem *GetRawFileSystemUnsafe() { return m_impl.get(); } private: void NotifyCloseFile(FileAccessor *f); void NotifyCloseDirectory(DirectoryAccessor *d); public: Result SetUpPath(fs::Path *out, const char *p); }; }
4,682
C++
.h
89
42.595506
160
0.663174
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,466
fs_file_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp
/* * 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> namespace ams::fs::impl { struct FilePathHash; class FileSystemAccessor; enum class WriteState { None, NeedsFlush, Failed, }; class FileAccessor : public util::IntrusiveListBaseNode<FileAccessor>, public Newable { NON_COPYABLE(FileAccessor); private: std::unique_ptr<fsa::IFile> m_impl; FileSystemAccessor * const m_parent; WriteState m_write_state; Result m_write_result; const OpenMode m_open_mode; std::unique_ptr<FilePathHash> m_file_path_hash; s32 m_path_hash_index; public: FileAccessor(std::unique_ptr<fsa::IFile>&& f, FileSystemAccessor *p, OpenMode mode); ~FileAccessor(); Result Read(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option); Result Write(s64 offset, const void *buf, size_t size, const WriteOption &option); Result Flush(); Result SetSize(s64 size); Result GetSize(s64 *out); Result OperateRange(void *dst, size_t dst_size, OperationId operation, s64 offset, s64 size, const void *src, size_t src_size); OpenMode GetOpenMode() const { return m_open_mode; } WriteState GetWriteState() const { return m_write_state; } FileSystemAccessor *GetParent() const { return m_parent; } void SetFilePathHash(std::unique_ptr<FilePathHash>&& file_path_hash, s32 index); Result ReadWithoutCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option); private: Result ReadWithCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option, bool use_path_cache, bool use_data_cache); ALWAYS_INLINE Result UpdateLastResult(Result r) { if (!fs::ResultNotEnoughFreeSpace::Includes(r)) { m_write_result = r; } R_RETURN(r); } }; }
2,718
C++
.h
59
37.491525
159
0.650943
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,467
cs_command_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/cs/cs_command_impl.hpp
/* * 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> namespace ams::cs { struct CommandDataTakeScreenShot { vi::LayerStack layer_stack; u8 *buffer; size_t buffer_size; }; Result DoGetFirmwareVersionCommand(settings::system::FirmwareVersion *out); template<typename SendHeader, typename SendData> Result DoTakeScreenShotCommand(const CommandDataTakeScreenShot &params, SendHeader send_header, SendData send_data); }
1,087
C++
.h
27
36.925926
120
0.757346
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,468
os_stack_guard_manager_impl.os.windows.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/os/impl/os_stack_guard_manager_impl.os.windows.hpp
/* * 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> namespace ams::os::impl { class StackGuardManagerWindowsImpl { public: static u64 GetStackGuardBeginAddress() { return 256_MB; } static u64 GetStackGuardEndAddress() { return 256_MB + 1_GB; } }; using StackGuardManagerImpl = StackGuardManagerWindowsImpl; }
983
C++
.h
25
35.84
76
0.736897
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,469
os_cache_impl.os.horizon.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/os/impl/os_cache_impl.os.horizon.hpp
/* * 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> namespace ams::os::impl { inline void FlushDataCacheImpl(const void *addr, size_t size) { #if defined(ATMOSPHERE_ARCH_ARM64) { /* Declare helper variables. */ uintptr_t cache_type_register = 0; uintptr_t cache_line_size = 0; const uintptr_t end_addr = reinterpret_cast<uintptr_t>(addr) + size; /* Get the cache type register. */ __asm__ __volatile__("mrs %[cache_type_register], ctr_el0" : [cache_type_register]"=r"(cache_type_register)); /* Calculate cache line size. */ cache_line_size = 4 << ((cache_type_register >> 16) & 0xF); /* Get the thread local region. */ auto * const tlr = svc::GetThreadLocalRegion(); /* Note to the kernel that we're performing cache maintenance, in case we get interrupted while touching cache lines. */ tlr->cache_maintenance_flag = 1; ON_SCOPE_EXIT { tlr->cache_maintenance_flag = 0; }; /* Iterate, flushing cache lines. */ for (uintptr_t cur = reinterpret_cast<uintptr_t>(addr) & ~(cache_line_size - 1); cur < end_addr; cur += cache_line_size) { __asm__ __volatile__ ("dc civac, %[cur]" :: [cur]"r"(cur)); } /* Insert a memory barrier, now that memory has been flushed. */ __asm__ __volatile__("dsb sy" ::: "memory"); } #else const auto result = svc::FlushProcessDataCache(svc::PseudoHandle::CurrentProcess, reinterpret_cast<uintptr_t>(addr), size); R_ASSERT(result); AMS_UNUSED(result); #endif } inline void FlushEntireDataCacheImpl() { svc::FlushEntireDataCache(); } }
2,432
C++
.h
51
39.72549
135
0.623103
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
8,470
os_timeout_helper.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/os/impl/os_timeout_helper.hpp
/* * 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 "os_tick_manager.hpp" #if defined(ATMOSPHERE_OS_HORIZON) #include "os_timeout_helper_impl.os.horizon.hpp" #elif defined(ATMOSPHERE_OS_WINDOWS) #include "os_timeout_helper_impl.os.windows.hpp" #elif defined(ATMOSPHERE_OS_LINUX) #include "os_timeout_helper_impl.os.linux.hpp" #elif defined(ATMOSPHERE_OS_MACOS) #include "os_timeout_helper_impl.os.macos.hpp" #else #error "Unknown OS for ams::os::TimeoutHelper" #endif namespace ams::os::impl { class TimeoutHelper { private: Tick m_absolute_end_tick; public: explicit TimeoutHelper(TimeSpan timeout) { if (timeout == 0) { /* If timeout is zero, don't do relative tick calculations. */ m_absolute_end_tick = Tick(0); } else { const auto &tick_manager = impl::GetTickManager(); const u64 cur_tick = tick_manager.GetTick().GetInt64Value(); const u64 timeout_tick = tick_manager.ConvertToTick(timeout).GetInt64Value(); const u64 end_tick = cur_tick + timeout_tick + 1; m_absolute_end_tick = Tick(std::min<u64>(std::numeric_limits<s64>::max(), end_tick)); } } static void Sleep(TimeSpan tm) { TimeoutHelperImpl::Sleep(tm); } bool TimedOut() const { if (m_absolute_end_tick.GetInt64Value() == 0) { return true; } const Tick cur_tick = impl::GetTickManager().GetTick(); return cur_tick >= m_absolute_end_tick; } TargetTimeSpan GetTimeLeftOnTarget() const; }; }
2,434
C++
.h
59
32.576271
105
0.621827
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false