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,271
|
psc_remote_pm_module.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/psc/psc_remote_pm_module.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::psc {
class RemotePmModule {
NON_COPYABLE(RemotePmModule);
NON_MOVEABLE(RemotePmModule);
private:
::PscPmModule m_module;
public:
constexpr RemotePmModule(const ::PscPmModule &m) : m_module(m) { /* ... */ }
~RemotePmModule() {
::pscPmModuleClose(std::addressof(m_module));
}
Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) {
/* NOTE: This functionality is already implemented by the libnx command we use to instantiate the PscPmModule. */
AMS_UNUSED(out, module_id, child_list);
AMS_ABORT();
}
Result GetRequest(ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags) {
static_assert(sizeof(PmState) == sizeof(::PscPmState));
static_assert(sizeof(PmFlagSet) == sizeof(u32));
R_RETURN(::pscPmModuleGetRequest(std::addressof(m_module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast<u32 *>(out_flags.GetPointer())));
}
Result Acknowledge() {
/* NOTE: libnx does not separate acknowledge/acknowledgeEx. */
R_RETURN(::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(0)));
}
Result Finalize() {
R_RETURN(::pscPmModuleFinalize(std::addressof(m_module)));
}
Result AcknowledgeEx(PmState state) {
static_assert(sizeof(state) == sizeof(::PscPmState));
R_RETURN(::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(state)));
}
};
static_assert(psc::sf::IsIPmModule<RemotePmModule>);
}
| 2,530
|
C++
|
.h
| 52
| 39.480769
| 183
| 0.63537
|
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,272
|
htc_htc_service_object.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/htc_htc_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 "../../htclow/htclow_manager.hpp"
#include "htc_htcmisc_impl.hpp"
#include "htc_observer.hpp"
namespace ams::htc::server {
class HtcServiceObject {
private:
static constexpr inline auto MaxSetElements = 0x48;
using Set = util::FixedSet<u32>;
private:
u8 m_set_memory[Set::GetRequiredMemorySize(MaxSetElements)];
Set m_set;
HtcmiscImpl m_misc_impl;
Observer m_observer;
os::SdkMutex m_mutex;
public:
HtcServiceObject(htclow::HtclowManager *htclow_manager);
public:
HtcmiscImpl *GetHtcmiscImpl();
public:
Result GetEnvironmentVariable(sf::Out<s32> out_size, const sf::OutBuffer &out, const sf::InBuffer &name);
Result GetEnvironmentVariableLength(sf::Out<s32> out_size, const sf::InBuffer &name);
Result GetHostConnectionEvent(sf::OutCopyHandle out);
Result GetHostDisconnectionEvent(sf::OutCopyHandle out);
Result GetHostConnectionEventForSystem(sf::OutCopyHandle out);
Result GetHostDisconnectionEventForSystem(sf::OutCopyHandle out);
Result GetBridgeIpAddress(const sf::OutBuffer &out);
Result GetBridgePort(const sf::OutBuffer &out);
Result SetCradleAttached(bool attached);
Result GetBridgeSubnetMask(const sf::OutBuffer &out);
Result GetBridgeMacAddress(const sf::OutBuffer &out);
Result GetWorkingDirectoryPath(const sf::OutBuffer &out, s32 max_len);
Result GetWorkingDirectoryPathSize(sf::Out<s32> out_size);
Result RunOnHostStart(sf::Out<u32> out_id, sf::OutCopyHandle out, const sf::InBuffer &args);
Result RunOnHostResults(sf::Out<s32> out_result, u32 id);
Result SetBridgeIpAddress(const sf::InBuffer &arg);
Result SetBridgeSubnetMask(const sf::InBuffer &arg);
Result SetBridgePort(const sf::InBuffer &arg);
};
static_assert(tma::IsIHtcManager<HtcServiceObject>);
}
| 2,741
|
C++
|
.h
| 57
| 40.175439
| 117
| 0.68806
|
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,273
|
htc_htcmisc_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/htc_htcmisc_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 "driver/htc_htclow_driver.hpp"
#include "driver/htc_driver_manager.hpp"
#include "rpc/htc_rpc_client.hpp"
#include "rpc/htc_htcmisc_rpc_server.hpp"
namespace ams::htc::server {
class HtcmiscImpl {
private:
driver::HtclowDriver m_htclow_driver;
driver::DriverManager m_driver_manager;
rpc::RpcClient m_rpc_client;
rpc::HtcmiscRpcServer m_rpc_server;
os::ThreadType m_client_thread;
os::ThreadType m_server_thread;
os::Event m_cancel_event;
bool m_cancelled;
mutable os::Event m_connection_event;
bool m_client_connected;
bool m_server_connected;
bool m_connected;
mutable os::SdkMutex m_connection_mutex;
private:
static void ClientThreadEntry(void *arg) { static_cast<HtcmiscImpl *>(arg)->ClientThread(); }
static void ServerThreadEntry(void *arg) { static_cast<HtcmiscImpl *>(arg)->ServerThread(); }
void ClientThread();
void ServerThread();
public:
HtcmiscImpl(htclow::HtclowManager *htclow_manager);
~HtcmiscImpl();
os::EventType *GetConnectionEvent() const;
bool IsConnected() const;
private:
void SetClientConnectionEvent(bool en);
void SetServerConnectionEvent(bool en);
void UpdateConnectionEvent();
void WaitTask(u32 task_id);
public:
void Cancel();
Result GetEnvironmentVariable(size_t *out_size, char *dst, size_t dst_size, const char *name, size_t name_size);
Result GetEnvironmentVariableLength(size_t *out_size, const char *name, size_t name_size);
Result RunOnHostBegin(u32 *out_task_id, os::NativeHandle *out_event, const char *args, size_t args_size);
Result RunOnHostEnd(s32 *out_result, u32 task_id);
};
}
| 2,669
|
C++
|
.h
| 61
| 35.688525
| 124
| 0.659869
|
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,274
|
htc_observer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/htc_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>
#include "htc_htcmisc_impl.hpp"
namespace ams::htc::server {
class Observer {
private:
os::SystemEvent m_connect_event;
os::SystemEvent m_disconnect_event;
os::Event m_stop_event;
os::ThreadType m_observer_thread;
const HtcmiscImpl &m_misc_impl;
bool m_thread_running;
bool m_stopped;
bool m_connected;
bool m_is_service_available;
alignas(os::ThreadStackAlignment) u8 m_observer_thread_stack[os::MemoryPageSize];
public:
Observer(const HtcmiscImpl &misc_impl);
private:
static void ObserverThreadEntry(void *arg) { static_cast<Observer *>(arg)->ObserverThreadBody(); }
void ObserverThreadBody();
private:
Result Start();
void UpdateEvent();
public:
os::SystemEvent *GetConnectEvent() { return std::addressof(m_connect_event); }
os::SystemEvent *GetDisconnectEvent() { return std::addressof(m_disconnect_event); }
};
}
| 1,752
|
C++
|
.h
| 44
| 32.659091
| 110
| 0.662948
|
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,275
|
htc_htcmisc_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/htc_htcmisc_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 "htc_htc_service_object.hpp"
namespace ams::htc::server {
sf::SharedPointer<tma::IHtcManager> CreateHtcmiscManager(HtcServiceObject **out, htclow::HtclowManager *htclow_manager);
}
| 873
|
C++
|
.h
| 21
| 39.571429
| 124
| 0.766784
|
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,276
|
htc_i_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/driver/htc_i_driver.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::htc::server::driver {
class IDriver {
public:
virtual void SetDisconnectionEmulationEnabled(bool en) = 0;
virtual Result Open(htclow::ChannelId channel) = 0;
virtual Result Open(htclow::ChannelId channel, void *receive_buffer, size_t receive_buffer_size, void *send_buffer, size_t send_buffer_size) = 0;
virtual void Close(htclow::ChannelId channel) = 0;
virtual Result Connect(htclow::ChannelId channel) = 0;
virtual void Shutdown(htclow::ChannelId channel) = 0;
virtual Result Send(s64 *out, const void *src, s64 src_size, htclow::ChannelId channel) = 0;
virtual Result Receive(s64 *out, void *dst, s64 dst_size, htclow::ChannelId channel, htclow::ReceiveOption option) = 0;
virtual htclow::ChannelState GetChannelState(htclow::ChannelId channel) = 0;
virtual os::EventType *GetChannelStateEvent(htclow::ChannelId channel) = 0;
};
}
| 2,341
|
C++
|
.h
| 32
| 67.375
| 157
| 0.500867
|
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,277
|
htc_driver_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/driver/htc_driver_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 "htc_i_driver.hpp"
namespace ams::htc::server::driver {
class DriverManager {
private:
IDriver *m_driver;
public:
DriverManager(IDriver *driver) : m_driver(driver) { /* ... */ }
IDriver *GetDriver() { return m_driver; }
};
}
| 974
|
C++
|
.h
| 27
| 32.185185
| 76
| 0.700954
|
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,278
|
htc_htclow_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/driver/htc_htclow_driver.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_i_driver.hpp"
namespace ams::htc::server::driver {
class HtclowDriver final : public IDriver {
private:
static constexpr size_t DefaultBufferSize = 128_KB;
private:
u8 m_default_receive_buffer[DefaultBufferSize];
u8 m_default_send_buffer[DefaultBufferSize];
htclow::HtclowManager *m_manager;
bool m_disconnection_emulation_enabled;
htclow::ModuleId m_module_id;
public:
HtclowDriver(htclow::HtclowManager *manager, htclow::ModuleId module_id) : m_manager(manager), m_disconnection_emulation_enabled(false), m_module_id(module_id) { /* ... */ }
private:
void WaitTask(u32 task_id);
Result ReceiveInternal(size_t *out, void *dst, size_t dst_size, htclow::ChannelId channel, htclow::ReceiveOption option);
public:
virtual void SetDisconnectionEmulationEnabled(bool en) override;
virtual Result Open(htclow::ChannelId channel) override;
virtual Result Open(htclow::ChannelId channel, void *receive_buffer, size_t receive_buffer_size, void *send_buffer, size_t send_buffer_size) override;
virtual void Close(htclow::ChannelId channel) override;
virtual Result Connect(htclow::ChannelId channel) override;
virtual void Shutdown(htclow::ChannelId channel) override;
virtual Result Send(s64 *out, const void *src, s64 src_size, htclow::ChannelId channel) override;
virtual Result Receive(s64 *out, void *dst, s64 dst_size, htclow::ChannelId channel, htclow::ReceiveOption option) override;
virtual htclow::ChannelState GetChannelState(htclow::ChannelId channel) override;
virtual os::EventType *GetChannelStateEvent(htclow::ChannelId channel) override;
};
}
| 2,565
|
C++
|
.h
| 47
| 47.340426
| 185
| 0.703777
|
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,279
|
htc_rpc_tasks.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_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>
namespace ams::htc::server::rpc {
constexpr inline size_t MaxRpcCount = 0x48;
enum class PacketCategory : s16 {
Request = 0,
Response = 1,
Notification = 2,
};
struct RpcPacket {
s16 protocol;
s16 version;
PacketCategory category;
u16 type;
s64 body_size;
u32 task_id{};
u64 params[5];
char data[];
};
static_assert(sizeof(RpcPacket) == 0x40);
enum class RpcTaskCancelReason {
None = 0,
BySocket = 1,
ClientFinalized = 2,
QueueNotAvailable = 3,
};
enum class RpcTaskState {
Started = 0,
Completed = 1,
Cancelled = 2,
Notified = 3,
};
class Task {
private:
RpcTaskState m_state;
RpcTaskCancelReason m_cancel_reason;
os::Event m_event;
public:
Task() : m_state(RpcTaskState::Started), m_cancel_reason(RpcTaskCancelReason::None), m_event(os::EventClearMode_AutoClear) { /* ... */ }
virtual ~Task() { /* ... */ }
public:
void SetTaskState(RpcTaskState state) { m_state = state; }
RpcTaskState GetTaskState() const { return m_state; }
RpcTaskCancelReason GetTaskCancelReason() const { return m_cancel_reason; }
os::EventType *GetEvent() { return m_event.GetBase(); }
void Notify() {
AMS_ASSERT(m_state == RpcTaskState::Started);
m_state = RpcTaskState::Notified;
}
void Complete() {
AMS_ASSERT(m_state == RpcTaskState::Started || m_state == RpcTaskState::Notified);
m_state = RpcTaskState::Completed;
m_event.Signal();
}
public:
virtual void Cancel(RpcTaskCancelReason reason) {
m_state = RpcTaskState::Cancelled;
m_cancel_reason = reason;
m_event.Signal();
}
virtual Result ProcessResponse(const char *data, size_t size) {
AMS_UNUSED(data, size);
R_SUCCEED();
}
virtual Result CreateRequest(size_t *out, char *data, size_t size, u32 task_id) {
AMS_UNUSED(out, data, size, task_id);
R_SUCCEED();
}
virtual Result ProcessNotification(const char *data, size_t size) {
AMS_UNUSED(data, size);
R_SUCCEED();
}
virtual Result CreateNotification(size_t *out, char *data, size_t size, u32 task_id) {
AMS_UNUSED(out, data, size, task_id);
R_SUCCEED();
}
virtual bool IsReceiveBufferRequired() {
return false;
}
virtual bool IsSendBufferRequired() {
return false;
}
virtual os::SystemEventType *GetSystemEvent() {
return nullptr;
}
};
}
| 3,747
|
C++
|
.h
| 102
| 26.72549
| 148
| 0.562638
|
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,280
|
htc_rpc_task_table.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_task_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 "htc_rpc_tasks.hpp"
#include "htc_htcmisc_rpc_tasks.hpp"
namespace ams::htc::server::rpc {
/* For convenience. */
template<typename T>
concept IsTypeCheckableTask = std::derived_from<T, Task> && requires (T &t) {
{ t.GetTaskType() } -> std::convertible_to<decltype(T::TaskType)>;
};
static_assert(!IsTypeCheckableTask<Task>);
static_assert(IsTypeCheckableTask<GetEnvironmentVariableTask>);
class RpcTaskTable {
private:
/* htcs::ReceiveSmallTask/htcs::ReceiveSendTask are the largest tasks, containing an inline 0xE000 buffer. */
/* We allow for ~0x100 task overhead from the additional events those contain. */
/* NOTE: Nintendo hardcodes a maximum size of 0xE1D8, despite SendSmallTask being 0xE098 as of latest check. */
#if defined(ATMOSPHERE_OS_HORIZON)
static constexpr size_t MaxTaskSize = 0xE100;
#elif defined(ATMOSPHERE_OS_MACOS)
static constexpr size_t MaxTaskSize = 0xE400;
#else
static constexpr size_t MaxTaskSize = 0xE1D8;
#endif
struct TaskStorage { alignas(alignof(void *)) std::byte _storage[MaxTaskSize]; };
private:
bool m_valid[MaxRpcCount]{};
TaskStorage m_storages[MaxRpcCount]{};
private:
template<typename T>
ALWAYS_INLINE T *GetPointer(u32 index) {
static_assert(alignof(T) <= alignof(TaskStorage));
static_assert(sizeof(T) <= sizeof(TaskStorage));
return reinterpret_cast<T *>(std::addressof(m_storages[index]));
}
ALWAYS_INLINE bool IsValid(u32 index) {
return index < MaxRpcCount && m_valid[index];
}
public:
constexpr RpcTaskTable() = default;
template<typename T> requires std::derived_from<T, Task>
T *New(u32 index) {
/* Sanity check input. */
AMS_ASSERT(!this->IsValid(index));
/* Set valid. */
m_valid[index] = true;
/* Allocate the task. */
T *task = this->GetPointer<T>(index);
/* Create the task. */
std::construct_at(task);
/* Return the task. */
return task;
}
template<typename T> requires std::derived_from<T, Task>
T *Get(u32 index) {
/* Check that the task is valid. */
if (!this->IsValid(index)) {
return nullptr;
}
/* Get the task pointer. */
T *task = this->GetPointer<T>(index);
/* Type check the task. */
if constexpr (IsTypeCheckableTask<T>) {
if (task->GetTaskType() != T::TaskType) {
task = nullptr;
}
}
/* Return the task. */
return task;
}
template<typename T> requires std::derived_from<T, Task>
void Delete(u32 index) {
/* Check that the task is valid. */
if (!this->IsValid(index)) {
return;
}
/* Delete the task. */
std::destroy_at(this->GetPointer<T>(index));
/* Mark the task as invalid. */
m_valid[index] = false;
}
void Delete(u32 index) {
if (this->IsValid(index)) {
this->Delete<Task>(index);
}
}
};
}
| 4,355
|
C++
|
.h
| 103
| 30.436893
| 123
| 0.553981
|
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,281
|
htc_rpc_task_queue.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_task_queue.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_rpc_tasks.hpp"
#include "htc_htcmisc_rpc_tasks.hpp"
namespace ams::htc::server::rpc {
class RpcTaskQueue {
private:
u32 m_task_ids[MaxRpcCount];
PacketCategory m_task_categories[MaxRpcCount];
int m_offset;
int m_count;
os::SdkConditionVariable m_cv;
os::SdkMutex m_mutex;
bool m_cancelled;
public:
constexpr RpcTaskQueue() = default;
void Initialize() {
m_offset = 0;
m_count = 0;
m_cancelled = false;
}
void Finalize() {
m_offset = 0;
m_count = 0;
}
void Cancel() {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Cancel ourselves. */
m_cancelled = true;
/* Signal to consumers/producers. */
m_cv.Signal();
}
void Add(u32 task_id, PacketCategory category) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Check pre-conditions. */
AMS_ASSERT(m_count < static_cast<int>(MaxRpcCount));
/* Determine index. */
const auto index = ((m_count++) + m_offset) % MaxRpcCount;
/* Set task. */
m_task_ids[index] = task_id;
m_task_categories[index] = category;
/* Signal. */
if (m_count > 0) {
m_cv.Signal();
}
}
Result Take(u32 *out_id, PacketCategory *out_category) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Wait until we can take. */
while (m_count == 0 && !m_cancelled) {
m_cv.Wait(m_mutex);
}
/* Check that we're not cancelled. */
R_UNLESS(!m_cancelled, htc::ResultCancelled());
/* Determine index. */
const auto index = m_offset;
/* Advance the queue. */
m_offset = (m_offset + 1) % MaxRpcCount;
--m_count;
/* Return the task info. */
*out_id = m_task_ids[index];
*out_category = m_task_categories[index];
R_SUCCEED();
}
};
}
| 3,189
|
C++
|
.h
| 84
| 25.809524
| 76
| 0.502916
|
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,282
|
htc_htcmisc_rpc_server.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_htcmisc_rpc_server.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 "../driver/htc_i_driver.hpp"
#include "htc_htcmisc_rpc_tasks.hpp"
namespace ams::htc::server::rpc {
class HtcmiscRpcServer {
private:
/* TODO: where is this value coming from, again? */
static constexpr size_t BufferSize = 1_KB;
private:
mem::StandardAllocator *m_allocator;
driver::IDriver *m_driver;
htclow::ChannelId m_channel_id;
void *m_receive_thread_stack;
os::ThreadType m_receive_thread;
bool m_cancelled;
bool m_thread_running;
char m_receive_buffer[BufferSize];
char m_send_buffer[BufferSize];
u8 m_driver_receive_buffer[4_KB];
u8 m_driver_send_buffer[4_KB];
private:
static void ReceiveThreadEntry(void *arg) { static_cast<HtcmiscRpcServer *>(arg)->ReceiveThread(); }
Result ReceiveThread();
public:
HtcmiscRpcServer(driver::IDriver *driver, htclow::ChannelId channel);
public:
void Open();
void Close();
Result Start();
void Cancel();
void Wait();
int WaitAny(htclow::ChannelState state, os::EventType *event);
private:
Result ProcessSetTargetNameRequest(const char *name, size_t size, u32 task_id);
Result ReceiveHeader(HtcmiscRpcPacket *header);
Result ReceiveBody(char *dst, size_t size);
Result SendRequest(const char *src, size_t size);
};
}
| 2,220
|
C++
|
.h
| 55
| 32.290909
| 112
| 0.643188
|
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,283
|
htc_htcmisc_rpc_tasks.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_htcmisc_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_rpc_tasks.hpp"
namespace ams::htc::server::rpc {
enum class HtcmiscTaskType {
GetEnvironmentVariable = 0,
GetEnvironmentVariableLength = 1,
SetTargetStatus = 2,
RunOnHost = 3,
};
enum class HtcmiscResult {
Success = 0,
UnknownError = 1,
UnsupportedVersion = 2,
InvalidRequest = 3,
};
enum class HtcmiscPacketCategory : s16 {
Request = 0,
Response = 1,
};
enum class HtcmiscPacketType : s16 {
GetMaxProtocolVersion = 0,
SetProtocolVersion = 1,
GetEnvironmentVariable = 16,
GetEnvironmentVariableLength = 17,
SetTargetStatus = 18,
RunOnHost = 19,
GetWorkingDirectory = 20,
GetWorkingDirectorySize = 21,
SetTargetName = 22,
};
constexpr inline s16 HtcmiscProtocol = 4;
constexpr inline s16 HtcmiscMaxVersion = 2;
struct HtcmiscRpcPacket {
s16 protocol;
s16 version;
HtcmiscPacketCategory category;
HtcmiscPacketType type;
s64 body_size;
u32 task_id{};
u64 params[5];
char data[];
};
static_assert(sizeof(HtcmiscRpcPacket) == 0x40);
class HtcmiscTask : public Task {
private:
HtcmiscTaskType m_task_type;
public:
HtcmiscTask(HtcmiscTaskType type) : m_task_type(type) { /* ... */ }
HtcmiscTaskType GetTaskType() const { return m_task_type; }
};
class GetEnvironmentVariableTask : public HtcmiscTask {
public:
static constexpr inline HtcmiscTaskType TaskType = HtcmiscTaskType::GetEnvironmentVariable;
private:
char m_name[0x800];
int m_name_size;
Result m_result;
size_t m_value_size;
char m_value[0x8000];
public:
GetEnvironmentVariableTask() : HtcmiscTask(HtcmiscTaskType::GetEnvironmentVariable) { /* ... */ }
Result SetArguments(const char *args, size_t size);
void Complete(HtcmiscResult result, const char *data, size_t size);
Result GetResult(size_t *out, char *dst, size_t size) const;
const char *GetName() const { return m_name; }
int GetNameSize() const { return m_name_size; }
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 GetEnvironmentVariableLengthTask : public HtcmiscTask {
public:
static constexpr inline HtcmiscTaskType TaskType = HtcmiscTaskType::GetEnvironmentVariableLength;
private:
char m_name[0x800];
int m_name_size;
Result m_result;
size_t m_value_size;
public:
GetEnvironmentVariableLengthTask() : HtcmiscTask(HtcmiscTaskType::GetEnvironmentVariableLength) { /* ... */ }
Result SetArguments(const char *args, size_t size);
void Complete(HtcmiscResult result, const char *data, size_t size);
Result GetResult(size_t *out) const;
const char *GetName() const { return m_name; }
int GetNameSize() const { return m_name_size; }
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 RunOnHostTask : public HtcmiscTask {
public:
static constexpr inline HtcmiscTaskType TaskType = HtcmiscTaskType::RunOnHost;
private:
char m_command[0x2000];
int m_command_size;
Result m_result;
int m_host_result;
os::SystemEvent m_system_event;
public:
RunOnHostTask() : HtcmiscTask(HtcmiscTaskType::RunOnHost), m_system_event(os::EventClearMode_ManualClear, true) { /* ... */ }
Result SetArguments(const char *args, size_t size);
void Complete(int host_result);
Result GetResult(int *out) const;
const char *GetCommand() const { return m_command; }
int GetCommandSize() const { return m_command_size; }
public:
virtual void Cancel(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 os::SystemEventType *GetSystemEvent() override;
};
}
| 5,472
|
C++
|
.h
| 128
| 33.960938
| 137
| 0.623474
|
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,284
|
htc_rpc_task_id_free_list.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_task_id_free_list.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_rpc_tasks.hpp"
#include "htc_htcmisc_rpc_tasks.hpp"
namespace ams::htc::server::rpc {
class RpcTaskIdFreeList {
private:
u32 m_task_ids[MaxRpcCount];
u32 m_offset;
u32 m_free_count;
public:
constexpr RpcTaskIdFreeList() : m_task_ids(), m_offset(0), m_free_count(MaxRpcCount) {
for (auto i = 0; i < static_cast<int>(MaxRpcCount); ++i) {
m_task_ids[i] = i;
}
}
Result Allocate(u32 *out) {
/* Check that we have free tasks. */
R_UNLESS(m_free_count > 0, htc::ResultOutOfRpcTask());
/* Get index. */
const auto index = m_offset;
m_offset = (m_offset + 1) % MaxRpcCount;
--m_free_count;
/* Get the task id. */
*out = m_task_ids[index];
R_SUCCEED();
}
void Free(u32 task_id) {
/* Check pre-conditions. */
AMS_ASSERT(m_free_count < static_cast<int>(MaxRpcCount));
/* Determine index. */
const auto index = ((m_free_count++) + m_offset) % MaxRpcCount;
/* Set the task id. */
m_task_ids[index] = task_id;
}
};
}
| 2,026
|
C++
|
.h
| 52
| 29.365385
| 98
| 0.565394
|
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,285
|
htc_rpc_client.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/server/rpc/htc_rpc_client.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 "../driver/htc_i_driver.hpp"
#include "htc_rpc_task_table.hpp"
#include "htc_rpc_task_queue.hpp"
#include "htc_rpc_task_id_free_list.hpp"
#include "../../../htcs/impl/rpc/htcs_rpc_tasks.hpp"
namespace ams::htc::server::rpc {
template<typename T>
concept IsRpcTask = std::derived_from<T, Task>;
struct RpcTaskFunctionTraits {
public:
template<typename R, typename C, typename... A>
static std::tuple<A...> GetSetArgumentsImpl(R(C::*)(A...));
template<typename R, typename C, typename... A>
static std::tuple<A...> GetGetResultImpl(R(C::*)(A...) const);
};
template<typename T> requires IsRpcTask<T>
using RpcTaskArgumentsType = decltype(RpcTaskFunctionTraits::GetSetArgumentsImpl(&T::SetArguments));
template<typename T> requires IsRpcTask<T>
using RpcTaskResultsType = decltype(RpcTaskFunctionTraits::GetGetResultImpl(&T::GetResult));
template<typename T, size_t Ix> requires IsRpcTask<T>
using RpcTaskArgumentType = typename std::tuple_element<Ix, RpcTaskArgumentsType<T>>::type;
template<typename T, size_t Ix> requires IsRpcTask<T>
using RpcTaskResultType = typename std::tuple_element<Ix, RpcTaskResultsType<T>>::type;
class RpcClient {
private:
/* TODO: where is this value coming from, again? */
static constexpr size_t BufferSize = 0xE400;
private:
mem::StandardAllocator *m_allocator;
driver::IDriver *m_driver;
htclow::ChannelId m_channel_id;
void *m_receive_thread_stack;
void *m_send_thread_stack;
os::ThreadType m_receive_thread;
os::ThreadType m_send_thread;
os::SdkMutex &m_mutex;
RpcTaskIdFreeList &m_task_id_free_list;
RpcTaskTable &m_task_table;
bool m_task_active[MaxRpcCount];
bool m_is_htcs_task[MaxRpcCount];
RpcTaskQueue m_task_queue;
bool m_cancelled;
bool m_thread_running;
os::EventType m_receive_buffer_available_events[MaxRpcCount];
os::EventType m_send_buffer_available_events[MaxRpcCount];
char m_receive_buffer[BufferSize];
char m_send_buffer[BufferSize];
private:
static void ReceiveThreadEntry(void *arg) { static_cast<RpcClient *>(arg)->ReceiveThread(); }
static void SendThreadEntry(void *arg) { static_cast<RpcClient *>(arg)->SendThread(); }
Result ReceiveThread();
Result SendThread();
public:
RpcClient(driver::IDriver *driver, htclow::ChannelId channel);
RpcClient(mem::StandardAllocator *allocator, driver::IDriver *driver, htclow::ChannelId channel);
~RpcClient();
public:
void Open();
void Close();
Result Start();
void Cancel();
void Wait();
int WaitAny(htclow::ChannelState state, os::EventType *event);
private:
Result ReceiveHeader(RpcPacket *header);
Result ReceiveBody(char *dst, size_t size);
Result SendRequest(const char *src, size_t size);
private:
s32 GetTaskHandle(u32 task_id);
public:
void Wait(u32 task_id) {
os::WaitEvent(m_task_table.Get<Task>(task_id)->GetEvent());
}
os::NativeHandle DetachReadableHandle(u32 task_id) {
return os::DetachReadableHandleOfSystemEvent(m_task_table.Get<Task>(task_id)->GetSystemEvent());
}
void CancelBySocket(s32 handle);
template<typename T, typename... Args> requires (IsRpcTask<T> && sizeof...(Args) == std::tuple_size<RpcTaskArgumentsType<T>>::value)
Result Begin(u32 *out_task_id, Args &&... args) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Allocate a free task id. */
u32 task_id{};
R_TRY(m_task_id_free_list.Allocate(std::addressof(task_id)));
/* Create the new task. */
T *task = m_task_table.New<T>(task_id);
m_task_active[task_id] = true;
m_is_htcs_task[task_id] = htcs::impl::rpc::IsHtcsTask<T>;
/* Ensure we clean up the task, if we fail after this. */
auto task_guard = SCOPE_GUARD {
m_task_active[task_id] = false;
m_is_htcs_task[task_id] = false;
m_task_table.Delete<T>(task_id);
m_task_id_free_list.Free(task_id);
};
/* Set the task arguments. */
R_TRY(task->SetArguments(std::forward<Args>(args)...));
/* Clear the task's events. */
os::ClearEvent(std::addressof(m_receive_buffer_available_events[task_id]));
os::ClearEvent(std::addressof(m_send_buffer_available_events[task_id]));
/* Add the task to our queue if we can, or cancel it. */
if (m_thread_running) {
m_task_queue.Add(task_id, PacketCategory::Request);
} else {
task->Cancel(RpcTaskCancelReason::QueueNotAvailable);
}
/* Set the output task id. */
*out_task_id = task_id;
/* We succeeded. */
task_guard.Cancel();
R_SUCCEED();
}
template<typename T, typename... Args> requires (IsRpcTask<T> && sizeof...(Args) == std::tuple_size<RpcTaskResultsType<T>>::value)
Result GetResult(u32 task_id, Args &&... args) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
R_UNLESS(task != nullptr, htc::ResultInvalidTaskId());
/* Check that the task is completed. */
R_UNLESS(task->GetTaskState() == RpcTaskState::Completed, htc::ResultTaskNotCompleted());
/* Get the task's result. */
R_TRY(task->GetResult(std::forward<Args>(args)...));
R_SUCCEED();
}
template<typename T, typename... Args> requires (IsRpcTask<T> && sizeof...(Args) == std::tuple_size<RpcTaskResultsType<T>>::value)
Result End(u32 task_id, Args &&... args) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
R_UNLESS(task != nullptr, htc::ResultInvalidTaskId());
/* Ensure the task is freed if it needs to be, when we're done. */
auto task_guard = SCOPE_GUARD {
m_task_active[task_id] = false;
m_is_htcs_task[task_id] = false;
m_task_table.Delete<T>(task_id);
m_task_id_free_list.Free(task_id);
};
/* If the task was cancelled, handle that. */
if (task->GetTaskState() == RpcTaskState::Cancelled) {
switch (task->GetTaskCancelReason()) {
case RpcTaskCancelReason::BySocket:
task_guard.Cancel();
R_THROW(htc::ResultTaskCancelled());
case RpcTaskCancelReason::ClientFinalized:
R_THROW(htc::ResultCancelled());
case RpcTaskCancelReason::QueueNotAvailable:
R_THROW(htc::ResultTaskQueueNotAvailable());
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
/* Get the task's result. */
R_TRY(task->GetResult(std::forward<Args>(args)...));
R_SUCCEED();
}
template<typename T> requires IsRpcTask<T>
Result VerifyTaskIdWithHandle(u32 task_id, s32 handle) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
R_UNLESS(task != nullptr, htc::ResultInvalidTaskId());
/* Check the task handle. */
R_UNLESS(task->GetHandle() == handle, htc::ResultInvalidTaskId());
R_SUCCEED();
}
template<typename T> requires IsRpcTask<T>
Result Notify(u32 task_id) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Check that our queue is available. */
R_UNLESS(m_thread_running, htc::ResultTaskQueueNotAvailable());
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
R_UNLESS(task != nullptr, htc::ResultInvalidTaskId());
/* Add notification to our queue. */
m_task_queue.Add(task_id, PacketCategory::Notification);
R_SUCCEED();
}
template<typename T> requires IsRpcTask<T>
void WaitNotification(u32 task_id) {
/* Get the task from the table, releasing our lock afterwards. */
T *task;
{
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
task = m_task_table.Get<T>(task_id);
}
/* Wait for a notification. */
task->WaitNotification();
}
template<typename T> requires IsRpcTask<T>
bool IsCancelled(u32 task_id) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
/* Check the task state. */
return task != nullptr && task->GetTaskState() == RpcTaskState::Cancelled;
}
template<typename T> requires IsRpcTask<T>
bool IsCompleted(u32 task_id) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
/* Check the task state. */
return task != nullptr && task->GetTaskState() == RpcTaskState::Completed;
}
template<typename T> requires IsRpcTask<T>
Result SendContinue(u32 task_id, const void *buffer, s64 buffer_size) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
R_UNLESS(task != nullptr, htc::ResultInvalidTaskId());
/* If the task was cancelled, handle that. */
if (task->GetTaskState() == RpcTaskState::Cancelled) {
switch (task->GetTaskCancelReason()) {
case RpcTaskCancelReason::QueueNotAvailable:
R_THROW(htc::ResultTaskQueueNotAvailable());
default:
R_THROW(htc::ResultTaskCancelled());
}
}
/* Set the task's buffer. */
if (buffer_size > 0) {
task->SetBuffer(buffer, buffer_size);
os::SignalEvent(std::addressof(m_send_buffer_available_events[task_id]));
}
R_SUCCEED();
}
template<typename T> requires IsRpcTask<T>
Result ReceiveContinue(u32 task_id, void *buffer, s64 buffer_size) {
/* Get the task's buffer, and prepare to receive. */
const void *result_buffer;
s64 result_size;
{
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Get the task. */
T *task = m_task_table.Get<T>(task_id);
R_UNLESS(task != nullptr, htc::ResultInvalidTaskId());
/* If the task was cancelled, handle that. */
if (task->GetTaskState() == RpcTaskState::Cancelled) {
switch (task->GetTaskCancelReason()) {
case RpcTaskCancelReason::QueueNotAvailable:
R_THROW(htc::ResultTaskQueueNotAvailable());
default:
R_THROW(htc::ResultTaskCancelled());
}
}
/* Get the result size. */
result_size = task->GetResultSize();
R_SUCCEED_IF(result_size == 0);
/* Get the result buffer. */
result_buffer = task->GetBuffer();
}
/* Wait for the receive buffer to become available. */
os::WaitEvent(std::addressof(m_receive_buffer_available_events[task_id]));
/* Check that we weren't cancelled. */
R_UNLESS(!m_cancelled, htc::ResultCancelled());
/* Copy the received data. */
AMS_ASSERT(0 <= result_size && result_size <= buffer_size);
AMS_UNUSED(buffer_size);
std::memcpy(buffer, result_buffer, result_size);
R_SUCCEED();
}
};
}
| 14,368
|
C++
|
.h
| 289
| 34.539792
| 144
| 0.528119
|
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,286
|
htc_tenv_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/tenv/htc_tenv_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::htc::tenv {
class Service {
private:
os::ProcessId m_process_id;
public:
constexpr Service(os::ProcessId pid) : m_process_id(pid) { /* ... */ }
public:
Result GetVariable(sf::Out<s64> out_size, const sf::OutBuffer &out_buffer, const htc::tenv::VariableName &name);
Result GetVariableLength(sf::Out<s64> out_size,const htc::tenv::VariableName &name);
Result WaitUntilVariableAvailable(s64 timeout_ms);
};
static_assert(htc::tenv::IsIService<Service>);
}
| 1,243
|
C++
|
.h
| 30
| 36.666667
| 124
| 0.699174
|
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,287
|
htc_tenv_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/tenv/impl/htc_tenv_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::htc::tenv::impl {
void UnregisterDefinitionFilePath(u64 process_id);
}
| 769
|
C++
|
.h
| 20
| 36.4
| 76
| 0.761394
|
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,288
|
htc_tenv_allocator.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/tenv/impl/htc_tenv_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::htc::tenv::impl {
void InitializeAllocator(AllocateFunction allocate, DeallocateFunction deallocate);
void *Allocate(size_t size);
void Deallocate(void *p, size_t size);
class SfAllocator {
public:
constexpr ALWAYS_INLINE SfAllocator() { /* ... */ }
void *Allocate(size_t size) {
return ::ams::htc::tenv::impl::Allocate(size);
}
void Deallocate(void *p, size_t size) {
return ::ams::htc::tenv::impl::Deallocate(p, size);
}
};
using SfPolicy = sf::StatelessAllocationPolicy<SfAllocator>;
using SfObjectFactory = sf::ObjectFactory<SfPolicy>;
}
| 1,369
|
C++
|
.h
| 34
| 34.852941
| 87
| 0.687265
|
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,289
|
htc_tenv_definition_file_info.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htc/tenv/impl/htc_tenv_definition_file_info.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_tenv_allocator.hpp"
namespace ams::htc::tenv::impl {
struct DefinitionFileInfo : public util::IntrusiveListBaseNode<DefinitionFileInfo> {
u64 process_id;
Path path;
DefinitionFileInfo(u64 pid, Path *p) : process_id(pid) {
AMS_ASSERT(p != nullptr);
util::Strlcpy(this->path.str, p->str, PathLengthMax);
}
static void *operator new(size_t size) {
return Allocate(size);
}
static void operator delete(void *p, size_t size) {
Deallocate(p, size);
}
};
}
| 1,266
|
C++
|
.h
| 34
| 32.117647
| 88
| 0.685971
|
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,290
|
fssystem_lru_list_cache.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssystem/fssystem_lru_list_cache.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::fssystem {
template<typename Key, typename Value>
class LruListCache {
NON_COPYABLE(LruListCache);
NON_MOVEABLE(LruListCache);
public:
class Node : public ::ams::fs::impl::Newable {
NON_COPYABLE(Node);
NON_MOVEABLE(Node);
public:
Key m_key;
Value m_value;
util::IntrusiveListNode m_mru_list_node;
public:
explicit Node(const Value &value) : m_value(value) { /* ... */ }
};
private:
using MruList = typename util::IntrusiveListMemberTraits<&Node::m_mru_list_node>::ListType;
private:
MruList m_mru_list;
public:
constexpr LruListCache() : m_mru_list() { /* ... */ }
bool FindValueAndUpdateMru(Value *out, const Key &key) {
for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) {
if (it->m_key == key) {
*out = it->m_value;
m_mru_list.erase(it);
m_mru_list.push_front(*it);
return true;
}
}
return false;
}
std::unique_ptr<Node> PopLruNode() {
AMS_ABORT_UNLESS(!m_mru_list.empty());
Node *lru = std::addressof(*m_mru_list.rbegin());
m_mru_list.pop_back();
return std::unique_ptr<Node>(lru);
}
void PushMruNode(std::unique_ptr<Node> &&node, const Key &key) {
node->m_key = key;
m_mru_list.push_front(*node);
node.release();
}
void DeleteAllNodes() {
while (!m_mru_list.empty()) {
Node *lru = std::addressof(*m_mru_list.rbegin());
m_mru_list.erase(m_mru_list.iterator_to(*lru));
delete lru;
}
}
size_t GetSize() const {
return m_mru_list.size();
}
bool IsEmpty() const {
return m_mru_list.empty();
}
};
}
| 2,944
|
C++
|
.h
| 76
| 26.486842
| 103
| 0.516988
|
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,291
|
fssystem_hierarchical_sha256_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.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::fssystem {
template<typename BaseStorageType>
class HierarchicalSha256Storage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(HierarchicalSha256Storage);
NON_MOVEABLE(HierarchicalSha256Storage);
public:
static constexpr s32 LayerCount = 3;
static constexpr size_t HashSize = crypto::Sha256Generator::HashSize;
private:
BaseStorageType m_base_storage;
s64 m_base_storage_size;
char *m_hash_buffer;
size_t m_hash_buffer_size;
s32 m_hash_target_block_size;
s32 m_log_size_ratio;
fssystem::IHash256GeneratorFactory *m_hash_generator_factory;
os::SdkMutex m_mutex;
public:
HierarchicalSha256Storage() : m_mutex() { /* ... */ }
Result Initialize(BaseStorageType *base_storages, s32 layer_count, size_t htbs, void *hash_buf, size_t hash_buf_size, fssystem::IHash256GeneratorFactory *hgf);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
virtual Result GetSize(s64 *out) override {
R_RETURN(m_base_storage->GetSize(out));
}
virtual Result Flush() override {
R_RETURN(m_base_storage->Flush());
}
virtual Result SetSize(s64 size) override {
AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedSetSizeForHierarchicalSha256Storage());
}
};
}
| 2,464
|
C++
|
.h
| 52
| 38.884615
| 171
| 0.660982
|
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,292
|
fssystem_memory_resource_buffer_hold_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssystem/fssystem_memory_resource_buffer_hold_storage.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::fssystem {
class MemoryResourceBufferHoldStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(MemoryResourceBufferHoldStorage);
NON_MOVEABLE(MemoryResourceBufferHoldStorage);
private:
std::shared_ptr<fs::IStorage> m_storage;
MemoryResource *m_memory_resource;
void *m_buffer;
size_t m_buffer_size;
public:
MemoryResourceBufferHoldStorage(std::shared_ptr<fs::IStorage> storage, MemoryResource *mr, size_t buffer_size) : m_storage(std::move(storage)), m_memory_resource(mr), m_buffer(m_memory_resource->Allocate(buffer_size)), m_buffer_size(buffer_size) {
/* ... */
}
virtual ~MemoryResourceBufferHoldStorage() {
/* If we have a buffer, deallocate it. */
if (m_buffer != nullptr) {
m_memory_resource->Deallocate(m_buffer, m_buffer_size);
}
}
ALWAYS_INLINE bool IsValid() const { return m_buffer != nullptr; }
ALWAYS_INLINE void *GetBuffer() const { return m_buffer; }
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override {
/* Check pre-conditions. */
AMS_ASSERT(m_storage != nullptr);
R_RETURN(m_storage->Read(offset, buffer, size));
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
/* Check pre-conditions. */
AMS_ASSERT(m_storage != nullptr);
R_RETURN(m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
}
virtual Result GetSize(s64 *out) override {
/* Check pre-conditions. */
AMS_ASSERT(m_storage != nullptr);
R_RETURN(m_storage->GetSize(out));
}
virtual Result Flush() override {
/* Check pre-conditions. */
AMS_ASSERT(m_storage != nullptr);
R_RETURN(m_storage->Flush());
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
/* Check pre-conditions. */
AMS_ASSERT(m_storage != nullptr);
R_RETURN(m_storage->Write(offset, buffer, size));
}
virtual Result SetSize(s64 size) override {
/* Check pre-conditions. */
AMS_ASSERT(m_storage != nullptr);
R_RETURN(m_storage->SetSize(size));
}
};
}
| 3,387
|
C++
|
.h
| 71
| 36.647887
| 259
| 0.595152
|
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,293
|
fssystem_key_slot_cache.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.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::fssystem {
class KeySlotCacheAccessor : public ::ams::fs::impl::Newable {
NON_COPYABLE(KeySlotCacheAccessor);
NON_MOVEABLE(KeySlotCacheAccessor);
private:
util::unique_lock<os::SdkMutex> m_lk;
const s32 m_slot_index;
public:
KeySlotCacheAccessor(s32 idx, util::unique_lock<os::SdkMutex> &&l) : m_lk(std::move(l)), m_slot_index(idx) { /* ... */ }
s32 GetKeySlotIndex() const { return m_slot_index; }
};
class KeySlotCacheEntry : public util::IntrusiveListBaseNode<KeySlotCacheEntry> {
NON_COPYABLE(KeySlotCacheEntry);
NON_MOVEABLE(KeySlotCacheEntry);
public:
static constexpr size_t KeySize = crypto::AesDecryptor128::KeySize;
private:
const s32 m_slot_index;
u8 m_key1[KeySize];
s32 m_key2;
public:
explicit KeySlotCacheEntry(s32 idx) : m_slot_index(idx), m_key2(-1) {
std::memset(m_key1, 0, sizeof(m_key1));
}
bool Contains(const void *key, size_t key_size, s32 key2) const {
AMS_ASSERT(key_size == KeySize);
AMS_UNUSED(key_size);
return key2 == m_key2 && std::memcmp(m_key1, key, KeySize) == 0;
}
s32 GetKeySlotIndex() const { return m_slot_index; }
void SetKey(const void *key, size_t key_size, s32 key2) {
AMS_ASSERT(key_size == KeySize);
std::memcpy(m_key1, key, key_size);
m_key2 = key2;
}
};
class KeySlotCache {
NON_COPYABLE(KeySlotCache);
NON_MOVEABLE(KeySlotCache);
private:
using KeySlotCacheEntryList = util::IntrusiveListBaseTraits<KeySlotCacheEntry>::ListType;
private:
os::SdkMutex m_mutex;
KeySlotCacheEntryList m_high_priority_mru_list;
KeySlotCacheEntryList m_low_priority_mru_list;
public:
constexpr KeySlotCache() : m_mutex(), m_high_priority_mru_list(), m_low_priority_mru_list() { /* ... */ }
Result AllocateHighPriority(std::unique_ptr<KeySlotCacheAccessor> *out, const void *key, size_t key_size, s32 key2) {
R_RETURN(this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2));
}
Result AllocateLowPriority(std::unique_ptr<KeySlotCacheAccessor> *out, const void *key, size_t key_size, s32 key2) {
R_RETURN(this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2));
}
Result Find(std::unique_ptr<KeySlotCacheAccessor> *out, const void *key, size_t key_size, s32 key2) {
util::unique_lock lk(m_mutex);
KeySlotCacheEntryList *lists[2] = { std::addressof(m_high_priority_mru_list), std::addressof(m_low_priority_mru_list) };
for (auto list : lists) {
for (auto it = list->begin(); it != list->end(); ++it) {
if (it->Contains(key, key_size, key2)) {
std::unique_ptr accessor = std::make_unique<KeySlotCacheAccessor>(it->GetKeySlotIndex(), std::move(lk));
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailed());
*out = std::move(accessor);
this->UpdateMru(list, it);
R_SUCCEED();
}
}
}
R_THROW(fs::ResultTargetNotFound());
}
void AddEntry(KeySlotCacheEntry *entry) {
util::unique_lock lk(m_mutex);
m_low_priority_mru_list.push_front(*entry);
}
private:
Result AllocateFromLru(std::unique_ptr<KeySlotCacheAccessor> *out, KeySlotCacheEntryList &dst_list, const void *key, size_t key_size, s32 key2) {
util::unique_lock lk(m_mutex);
KeySlotCacheEntryList &src_list = m_low_priority_mru_list.empty() ? m_high_priority_mru_list : m_low_priority_mru_list;
AMS_ASSERT(!src_list.empty());
auto it = src_list.rbegin();
std::unique_ptr accessor = std::make_unique<KeySlotCacheAccessor>(it->GetKeySlotIndex(), std::move(lk));
*out = std::move(accessor);
it->SetKey(key, key_size, key2);
auto *entry = std::addressof(*it);
src_list.pop_back();
dst_list.push_front(*entry);
R_SUCCEED();
}
void UpdateMru(KeySlotCacheEntryList *list, KeySlotCacheEntryList::iterator it) {
auto *entry = std::addressof(*it);
list->erase(it);
list->push_front(*entry);
}
};
}
| 5,556
|
C++
|
.h
| 111
| 37.576577
| 157
| 0.58052
|
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,294
|
fssystem_read_only_block_cache_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.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 "fssystem_lru_list_cache.hpp"
namespace ams::fssystem {
class ReadOnlyBlockCacheStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(ReadOnlyBlockCacheStorage);
NON_MOVEABLE(ReadOnlyBlockCacheStorage);
private:
using BlockCache = LruListCache<s64, char *>;
private:
os::SdkMutex m_mutex;
BlockCache m_block_cache;
std::shared_ptr<fs::IStorage> m_base_storage;
s32 m_block_size;
public:
ReadOnlyBlockCacheStorage(std::shared_ptr<fs::IStorage> bs, s32 bsz, char *buf, size_t buf_size, s32 cache_block_count) : m_mutex(), m_block_cache(), m_base_storage(std::move(bs)), m_block_size(bsz) {
/* Validate preconditions. */
AMS_ASSERT(buf_size >= static_cast<size_t>(m_block_size));
AMS_ASSERT(util::IsPowerOfTwo(m_block_size));
AMS_ASSERT(cache_block_count > 0);
AMS_ASSERT(buf_size >= static_cast<size_t>(m_block_size * cache_block_count));
AMS_UNUSED(buf_size);
/* Create a node for each cache block. */
for (auto i = 0; i < cache_block_count; i++) {
std::unique_ptr node = std::make_unique<BlockCache::Node>(buf + m_block_size * i);
AMS_ASSERT(node != nullptr);
if (node != nullptr) {
m_block_cache.PushMruNode(std::move(node), -1);
}
}
}
~ReadOnlyBlockCacheStorage() {
m_block_cache.DeleteAllNodes();
}
virtual Result Read(s64 offset, void *buffer, size_t size) override {
/* Validate preconditions. */
AMS_ASSERT(util::IsAligned(offset, m_block_size));
AMS_ASSERT(util::IsAligned(size, m_block_size));
if (size == static_cast<size_t>(m_block_size)) {
char *cached_buffer = nullptr;
/* Try to find a cached copy of the data. */
{
std::scoped_lock lk(m_mutex);
bool found = m_block_cache.FindValueAndUpdateMru(std::addressof(cached_buffer), offset / m_block_size);
if (found) {
std::memcpy(buffer, cached_buffer, size);
R_SUCCEED();
}
}
/* We failed to get a cache hit, so read in the data. */
R_TRY(m_base_storage->Read(offset, buffer, size));
/* Add the block to the cache. */
{
std::scoped_lock lk(m_mutex);
auto lru = m_block_cache.PopLruNode();
std::memcpy(lru->m_value, buffer, m_block_size);
m_block_cache.PushMruNode(std::move(lru), offset / m_block_size);
}
R_SUCCEED();
} else {
R_RETURN(m_base_storage->Read(offset, buffer, size));
}
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
/* If invalidating cache, invalidate our blocks. */
if (op_id == fs::OperationId::Invalidate) {
std::scoped_lock lk(m_mutex);
const size_t cache_block_count = m_block_cache.GetSize();
for (size_t i = 0; i < cache_block_count; ++i) {
auto lru = m_block_cache.PopLruNode();
m_block_cache.PushMruNode(std::move(lru), -1);
}
R_SUCCEED();
} else {
/* Validate preconditions. */
AMS_ASSERT(util::IsAligned(offset, m_block_size));
AMS_ASSERT(util::IsAligned(size, m_block_size));
}
/* Operate on the base storage. */
R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
}
virtual Result GetSize(s64 *out) override {
R_RETURN(m_base_storage->GetSize(out));
}
virtual Result Flush() override {
R_SUCCEED();
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedWriteForReadOnlyBlockCacheStorage());
}
virtual Result SetSize(s64 size) override {
AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedSetSizeForReadOnlyBlockCacheStorage());
}
};
}
| 5,614
|
C++
|
.h
| 112
| 35.1875
| 212
| 0.53292
|
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,295
|
sf_hipc_mitm_query_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.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::sf::hipc::impl {
#if AMS_SF_MITM_SUPPORTED
void RegisterMitmQueryHandle(os::NativeHandle query_handle, ServerManagerBase::MitmQueryFunction query_func);
#endif
}
| 868
|
C++
|
.h
| 22
| 37.136364
| 113
| 0.762752
|
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,296
|
sf_i_hipc_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sf/hipc/sf_i_hipc_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/>.
*/
#include <stratosphere.hpp>
#pragma once
#define AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ConvertCurrentObjectToDomain, (ams::sf::Out<ams::sf::cmif::DomainObjectId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CopyFromCurrentDomain, (ams::sf::OutMoveHandle out, ams::sf::cmif::DomainObjectId object_id), (out, object_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, CloneCurrentObject, (ams::sf::OutMoveHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 3, void, QueryPointerBufferSize, (ams::sf::Out<u16> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, CloneCurrentObjectEx, (ams::sf::OutMoveHandle out, u32 tag), (out, tag))
AMS_SF_DEFINE_INTERFACE(ams::sf::hipc::impl, IHipcManager, AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO, 0xEC6BE3FF)
| 1,755
|
C++
|
.h
| 24
| 70.625
| 160
| 0.602082
|
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,297
|
socket_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/socket/impl/socket_api.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::socket::impl {
Errno GetLastError();
void SetLastError(Errno err);
bool HeapIsAvailable(int generation);
int GetHeapGeneration();
u32 InetHtonl(u32 host);
u16 InetHtons(u16 host);
u32 InetNtohl(u32 net);
u16 InetNtohs(u16 net);
Result Initialize(const Config &config);
Result Finalize();
Result InitializeAllocatorForInternal(void *buffer, size_t size);
ssize_t RecvFrom(s32 desc, void *buffer, size_t buffer_size, MsgFlag flags, SockAddr *out_address, SockLenT *out_addr_len);
ssize_t Recv(s32 desc, void *buffer, size_t buffer_size, MsgFlag flags);
ssize_t SendTo(s32 desc, const void *buffer, size_t buffer_size, MsgFlag flags, const SockAddr *address, SockLenT len);
ssize_t Send(s32 desc, const void *buffer, size_t buffer_size, MsgFlag flags);
s32 Shutdown(s32 desc, ShutdownMethod how);
s32 Socket(Family domain, Type type, Protocol protocol);
s32 SocketExempt(Family domain, Type type, Protocol protocol);
s32 Accept(s32 desc, SockAddr *out_address, SockLenT *out_addr_len);
s32 Bind(s32 desc, const SockAddr *address, SockLenT len);
s32 Connect(s32 desc, const SockAddr *address, SockLenT len);
s32 GetSockName(s32 desc, SockAddr *out_address, SockLenT *out_addr_len);
s32 SetSockOpt(s32 desc, Level level, Option option_name, const void *option_value, SockLenT option_size);
s32 Listen(s32 desc, s32 backlog);
s32 Close(s32 desc);
}
| 2,136
|
C++
|
.h
| 43
| 45.674419
| 127
| 0.740616
|
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,298
|
socket_allocator.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/socket/impl/socket_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::socket::impl {
constexpr inline auto MinimumHeapAlignment = 0x10;
void *Alloc(size_t size);
void *Calloc(size_t num, size_t size);
void Free(void *ptr);
}
| 866
|
C++
|
.h
| 23
| 35.173913
| 76
| 0.746126
|
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,299
|
fssrv_deferred_process_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssrv/fssrv_deferred_process_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>
namespace ams::fssrv {
using NotifyProcessDeferredFunction = void (*)(u64 process_id);
struct DeferredProcessEntryForDeviceError : public util::IntrusiveListBaseNode<DeferredProcessEntryForDeviceError>, public fs::impl::Newable {
os::MultiWaitHolderType *process_holder;
u64 process_id;
};
class DeferredProcessQueueForDeviceError {
NON_COPYABLE(DeferredProcessQueueForDeviceError);
NON_MOVEABLE(DeferredProcessQueueForDeviceError);
private:
using EntryList = util::IntrusiveListBaseTraits<DeferredProcessEntryForDeviceError>::ListType;
private:
EntryList m_list{};
os::SdkMutex m_mutex{};
public:
constexpr DeferredProcessQueueForDeviceError() = default;
};
class DeferredProcessEntryForPriority : public util::IntrusiveListBaseNode<DeferredProcessEntryForPriority>, public fs::impl::Newable {
private:
os::MultiWaitHolderType *m_process_holder;
FileSystemProxyServerSessionType m_session_type;
};
class DeferredProcessQueueForPriority {
NON_COPYABLE(DeferredProcessQueueForPriority);
NON_MOVEABLE(DeferredProcessQueueForPriority);
private:
using EntryList = util::IntrusiveListBaseTraits<DeferredProcessEntryForPriority>::ListType;
private:
EntryList m_list{};
os::SdkRecursiveMutex m_mutex{};
os::SdkConditionVariable m_cv{};
public:
constexpr DeferredProcessQueueForPriority() = default;
};
template<typename ServerManager, NotifyProcessDeferredFunction NotifyProcessDeferred>
class DeferredProcessManager {
NON_COPYABLE(DeferredProcessManager);
NON_MOVEABLE(DeferredProcessManager);
private:
DeferredProcessQueueForDeviceError m_queue_for_device_error{};
os::SdkMutex m_invoke_mutex_for_device_error{};
DeferredProcessQueueForPriority m_queue_for_priority{};
std::atomic_bool m_is_invoke_deferred_process_event_linked{};
os::EventType m_invoke_event{};
os::MultiWaitHolderType m_invoke_event_holder{};
bool m_initialized{false};
public:
constexpr DeferredProcessManager() = default;
void Initialize() {
/* Check pre-conditions. */
AMS_ASSERT(!m_initialized);
os::InitializeEvent(std::addressof(m_invoke_event), false, os::EventClearMode_ManualClear);
os::InitializeMultiWaitHolder(std::addressof(m_invoke_event_holder), std::addressof(m_invoke_event));
m_initialized = true;
}
};
}
| 3,388
|
C++
|
.h
| 74
| 37.5
| 146
| 0.695613
|
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,300
|
fssrv_retry_utility.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssrv/fssrv_retry_utility.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::fssrv::impl {
template<typename F>
ALWAYS_INLINE Result RetryFinitelyForDataCorrupted(F f) {
/* All official uses of this retry once, for two tries total. */
constexpr auto MaxTryCount = 2;
/* Perform the operation, retrying on fs::ResultDataCorrupted. */
auto tries = 0;
while (true) {
/* Try to perform the operation. */
const auto rc = f();
/* If we should, retry. */
if (fs::ResultDataCorrupted::Includes(rc)) {
if ((++tries) < MaxTryCount) {
continue;
}
}
/* Ensure the current attempt succeeded. */
R_TRY(rc);
/* Return success. */
R_SUCCEED();
}
}
}
| 1,475
|
C++
|
.h
| 40
| 29.85
| 76
| 0.628151
|
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,301
|
fssrv_allocator_for_service_framework.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssrv/impl/fssrv_allocator_for_service_framework.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::fssrv::impl {
class AllocatorForServiceFramework {
public:
using Policy = ams::sf::StatelessAllocationPolicy<AllocatorForServiceFramework>;
void *Allocate(size_t size) {
return fs::impl::Allocate(size);
}
void Deallocate(void *ptr, size_t size) {
return fs::impl::Deallocate(ptr, size);
}
};
using FileSystemObjectFactory = ams::sf::ObjectFactory<AllocatorForServiceFramework::Policy>;
}
| 1,197
|
C++
|
.h
| 30
| 34.5
| 97
| 0.70112
|
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,302
|
fssrv_program_info.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssrv/impl/fssrv_program_info.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::fssrv::impl {
class ProgramInfo : public ::ams::fs::impl::Newable {
private:
u64 m_process_id;
ncm::ProgramId m_program_id;
ncm::StorageId m_storage_id;
/* TODO: AccessControl m_access_control; */
public:
ProgramInfo(u64 process_id, u64 program_id, u8 storage_id, const void *data, s64 data_size, const void *desc, s64 desc_size) : m_process_id(process_id) /* TODO: m_access_control */ {
m_program_id.value = program_id;
m_storage_id = static_cast<ncm::StorageId>(storage_id);
/* TODO */
AMS_UNUSED(data, data_size, desc, desc_size);
}
bool Contains(u64 process_id) const { return m_process_id == process_id; }
u64 GetProcessId() const { return m_process_id; }
ncm::ProgramId GetProgramId() const { return m_program_id; }
u64 GetProgramIdValue() const { return m_program_id.value; }
ncm::StorageId GetStorageId() const { return m_storage_id; }
public:
static std::shared_ptr<ProgramInfo> GetProgramInfoForInitialProcess();
private:
ProgramInfo(const void *data, s64 data_size, const void *desc, s64 desc_size) : m_process_id(os::InvalidProcessId), m_program_id(ncm::InvalidProgramId), m_storage_id(static_cast<ncm::StorageId>(0)) /* TODO: m_access_control */ {
/* TODO */
AMS_UNUSED(data, data_size, desc, desc_size);
}
};
struct ProgramInfoNode : public util::IntrusiveListBaseNode<ProgramInfoNode>, public ::ams::fs::impl::Newable {
std::shared_ptr<ProgramInfo> program_info;
};
bool IsInitialProgram(u64 process_id);
bool IsCurrentProcess(u64 process_id);
}
| 2,493
|
C++
|
.h
| 50
| 41.88
| 240
| 0.650246
|
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,303
|
fssrv_utility.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssrv/impl/fssrv_utility.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::fssrv::impl {
const char *GetExecutionDirectoryPath();
const char *GetWorkingDirectoryPath();
}
| 798
|
C++
|
.h
| 21
| 35.809524
| 76
| 0.75969
|
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,304
|
fssrv_program_registry_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/fssrv/impl/fssrv_program_registry_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 "fssrv_program_info.hpp"
namespace ams::fssrv::impl {
class ProgramRegistryManager {
NON_COPYABLE(ProgramRegistryManager);
NON_MOVEABLE(ProgramRegistryManager);
private:
using ProgramInfoList = util::IntrusiveListBaseTraits<ProgramInfoNode>::ListType;
private:
ProgramInfoList m_program_info_list{};
os::SdkMutex m_mutex{};
public:
constexpr ProgramRegistryManager() = default;
Result RegisterProgram(u64 process_id, u64 program_id, u8 storage_id, const void *data, s64 data_size, const void *desc, s64 desc_size);
Result UnregisterProgram(u64 process_id);
Result GetProgramInfo(std::shared_ptr<ProgramInfo> *out, u64 process_id);
Result GetProgramInfoByProgramId(std::shared_ptr<ProgramInfo> *out, u64 program_id);
};
}
AMS_FSSYSTEM_ENABLE_PIMPL(::ams::fssrv::impl::ProgramRegistryManager);
| 1,627
|
C++
|
.h
| 36
| 39.638889
| 148
| 0.717981
|
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,305
|
dmntcht.h
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/dmnt/dmntcht.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 base;
u64 size;
} DmntMemoryRegionExtents;
typedef struct {
u64 process_id;
u64 title_id;
DmntMemoryRegionExtents main_nso_extents;
DmntMemoryRegionExtents heap_extents;
DmntMemoryRegionExtents alias_extents;
DmntMemoryRegionExtents address_space_extents;
u8 main_nso_build_id[0x20];
} DmntCheatProcessMetadata;
typedef struct {
char readable_name[0x40];
uint32_t num_opcodes;
uint32_t opcodes[0x100];
} DmntCheatDefinition;
typedef struct {
bool enabled;
uint32_t cheat_id;
DmntCheatDefinition definition;
} DmntCheatEntry;
typedef struct {
u64 value;
u8 width;
} DmntFrozenAddressValue;
typedef struct {
u64 address;
DmntFrozenAddressValue value;
} DmntFrozenAddressEntry;
Result dmntchtInitialize(void);
void dmntchtExit(void);
Service* dmntchtGetServiceSession(void);
Result dmntchtHasCheatProcess(bool *out);
Result dmntchtGetCheatProcessEvent(Event *event);
Result dmntchtGetCheatProcessMetadata(DmntCheatProcessMetadata *out_metadata);
Result dmntchtForceOpenCheatProcess(void);
Result dmntchtForceCloseCheatProcess(void);
Result dmntchtGetCheatProcessMappingCount(u64 *out_count);
Result dmntchtGetCheatProcessMappings(MemoryInfo *buffer, u64 max_count, u64 offset, u64 *out_count);
Result dmntchtReadCheatProcessMemory(u64 address, void *buffer, size_t size);
Result dmntchtWriteCheatProcessMemory(u64 address, const void *buffer, size_t size);
Result dmntchtQueryCheatProcessMemory(MemoryInfo *mem_info, u64 address);
Result dmntchtPauseCheatProcess(void);
Result dmntchtResumeCheatProcess(void);
Result dmntchtGetCheatCount(u64 *out_count);
Result dmntchtGetCheats(DmntCheatEntry *buffer, u64 max_count, u64 offset, u64 *out_count);
Result dmntchtGetCheatById(DmntCheatEntry *out_cheat, u32 cheat_id);
Result dmntchtToggleCheat(u32 cheat_id);
Result dmntchtAddCheat(DmntCheatDefinition *cheat, bool enabled, u32 *out_cheat_id);
Result dmntchtRemoveCheat(u32 cheat_id);
Result dmntchtReadStaticRegister(u64 *out, u8 which);
Result dmntchtWriteStaticRegister(u8 which, u64 value);
Result dmntchtResetStaticRegisters();
Result dmntchtSetMasterCheat(DmntCheatDefinition *cheat);
Result dmntchtGetFrozenAddressCount(u64 *out_count);
Result dmntchtGetFrozenAddresses(DmntFrozenAddressEntry *buffer, u64 max_count, u64 offset, u64 *out_count);
Result dmntchtGetFrozenAddress(DmntFrozenAddressEntry *out, u64 address);
Result dmntchtEnableFrozenAddress(u64 address, u64 width, u64 *out_value);
Result dmntchtDisableFrozenAddress(u64 address);
#ifdef __cplusplus
}
#endif
| 3,292
|
C++
|
.h
| 84
| 36.952381
| 108
| 0.812461
|
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,306
|
powctl_device_management.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/powctl_device_management.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 "powctl_i_power_control_driver.hpp"
namespace ams::powctl::impl {
void InitializeDrivers();
void FinalizeDrivers();
void RegisterDriver(IPowerControlDriver *driver);
void UnregisterDriver(IPowerControlDriver *driver);
Result RegisterDeviceCode(DeviceCode device_code, IDevice *device);
bool UnregisterDeviceCode(DeviceCode device_code);
void RegisterInterruptHandler(ddsf::IEventHandler *handler);
void UnregisterInterruptHandler(ddsf::IEventHandler *handler);
Result FindDevice(IDevice **out, DeviceCode device_code);
}
| 1,249
|
C++
|
.h
| 29
| 40.103448
| 76
| 0.774114
|
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,307
|
powctl_select_board_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/powctl_select_board_driver.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 "powctl_i_power_control_driver.hpp"
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
#include "board/nintendo/nx/powctl_board_impl.hpp"
namespace ams::powctl::impl::board {
using namespace ams::powctl::impl::board::nintendo::nx;
}
#else
// TODO #error "Unknown board for ams::powctl::impl"
namespace ams::powctl::impl::board {
inline void Initialize(bool) {
AMS_ABORT("TODO");
}
inline void Finalize() {
AMS_ABORT("TODO");
}
}
#endif
| 1,210
|
C++
|
.h
| 34
| 31.294118
| 76
| 0.701544
|
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,308
|
powctl_i_power_control_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/powctl_i_power_control_driver.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::powctl::impl {
class IDevice : public ::ams::ddsf::IDevice {
NON_COPYABLE(IDevice);
NON_MOVEABLE(IDevice);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::IDevice, ::ams::ddsf::IDevice);
public:
IDevice() : ddsf::IDevice(false) { /* ... */ }
virtual ~IDevice() { /* ... */ }
};
class IPowerControlDriver : public ::ams::ddsf::IDriver {
NON_COPYABLE(IPowerControlDriver);
NON_MOVEABLE(IPowerControlDriver);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::IPowerControlDriver, ::ams::ddsf::IDriver);
private:
bool m_event_handler_enabled;
os::SdkMutex m_mutex;
protected:
constexpr bool IsEventHandlerEnabled() const {
return m_event_handler_enabled;
}
ALWAYS_INLINE os::SdkMutex &GetMutex() {
return m_mutex;
}
public:
IPowerControlDriver(bool ev) : IDriver(), m_event_handler_enabled(ev), m_mutex() { /* ... */ }
virtual ~IPowerControlDriver() { /* ... */ }
virtual void InitializeDriver() = 0;
virtual void FinalizeDriver() = 0;
virtual Result GetDeviceSystemEvent(os::SystemEventType **out, IDevice *device) = 0;
virtual Result SetDeviceInterruptEnabled(IDevice *device, bool enable) = 0;
/* TODO: Eventually implement proper error status enum? */
virtual Result GetDeviceErrorStatus(u32 *out, IDevice *device) = 0;
virtual Result SetDeviceErrorStatus(IDevice *device, u32 status) = 0;
virtual Result GetBatteryChargePercentage(float *out_percent, IDevice *device) = 0;
virtual Result GetBatteryVoltageFuelGaugePercentage(float *out_percent, IDevice *device) = 0;
virtual Result GetBatteryFullCapacity(int *out_mah, IDevice *device) = 0;
virtual Result GetBatteryRemainingCapacity(int *out_mah, IDevice *device) = 0;
virtual Result SetBatteryChargePercentageMinimumAlertThreshold(IDevice *device, float percentage) = 0;
virtual Result SetBatteryChargePercentageMaximumAlertThreshold(IDevice *device, float percentage) = 0;
virtual Result SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(IDevice *device, float percentage) = 0;
virtual Result SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(IDevice *device, float percentage) = 0;
virtual Result SetBatteryFullChargeThreshold(IDevice *device, float percentage) = 0;
virtual Result GetChargerChargeCurrentState(ChargeCurrentState *out, IDevice *device) = 0;
virtual Result SetChargerChargeCurrentState(IDevice *device, ChargeCurrentState state) = 0;
virtual Result GetChargerFastChargeCurrentLimit(int *out_ma, IDevice *device) = 0;
virtual Result SetChargerFastChargeCurrentLimit(IDevice *device, int ma) = 0;
virtual Result GetChargerChargeVoltageLimit(int *out_mv, IDevice *device) = 0;
virtual Result SetChargerChargeVoltageLimit(IDevice *device, int mv) = 0;
virtual Result SetChargerChargerConfiguration(IDevice *device, ChargerConfiguration cfg) = 0;
virtual Result IsChargerHiZEnabled(bool *out, IDevice *device) = 0;
virtual Result SetChargerHiZEnabled(IDevice *device, bool en) = 0;
virtual Result GetBatteryAverageCurrent(int *out_ma, IDevice *device) = 0;
virtual Result GetBatteryCurrent(int *out_ma, IDevice *device) = 0;
virtual Result GetChargerInputCurrentLimit(int *out_ma, IDevice *device) = 0;
virtual Result SetChargerInputCurrentLimit(IDevice *device, int ma) = 0;
virtual Result SetChargerInputVoltageLimit(IDevice *device, int mv) = 0;
virtual Result SetChargerBoostModeCurrentLimit(IDevice *device, int ma) = 0;
virtual Result GetBatteryInternalState(void *dst, size_t *out_size, IDevice *device, size_t dst_size) = 0;
virtual Result SetBatteryInternalState(IDevice *device, const void *src, size_t src_size) = 0;
virtual Result GetBatteryNeedToRestoreParameters(bool *out, IDevice *device) = 0;
virtual Result SetBatteryNeedToRestoreParameters(IDevice *device, bool en) = 0;
virtual Result IsBatteryI2cShutdownEnabled(bool *out, IDevice *device) = 0;
virtual Result SetBatteryI2cShutdownEnabled(IDevice *device, bool en) = 0;
virtual Result IsBatteryPresent(bool *out, IDevice *device) = 0;
virtual Result GetChargerChargerStatus(ChargerStatus *out, IDevice *device) = 0;
virtual Result GetBatteryCycles(int *out, IDevice *device) = 0;
virtual Result SetBatteryCycles(IDevice *device, int cycles) = 0;
virtual Result GetBatteryAge(float *out_percent, IDevice *device) = 0;
virtual Result GetBatteryTemperature(float *out_c, IDevice *device) = 0;
virtual Result GetBatteryMaximumTemperature(float *out_c, IDevice *device) = 0;
virtual Result SetBatteryTemperatureMinimumAlertThreshold(IDevice *device, float c) = 0;
virtual Result SetBatteryTemperatureMaximumAlertThreshold(IDevice *device, float c) = 0;
virtual Result GetBatteryVCell(int *out_mv, IDevice *device) = 0;
virtual Result GetBatteryAverageVCell(int *out_mv, IDevice *device) = 0;
virtual Result GetBatteryAverageVCellTime(TimeSpan *out, IDevice *device) = 0;
virtual Result SetBatteryVoltageMinimumAlertThreshold(IDevice *device, int mv) = 0;
virtual Result GetBatteryOpenCircuitVoltage(int *out_mv, IDevice *device) = 0;
virtual Result SetBatteryVoltageMaximumAlertThreshold(IDevice *device, int mv) = 0;
virtual Result IsChargerWatchdogTimerEnabled(bool *out, IDevice *device) = 0;
virtual Result SetChargerWatchdogTimerEnabled(IDevice *device, bool en) = 0;
virtual Result SetChargerWatchdogTimerTimeout(IDevice *device, TimeSpan timeout) = 0;
virtual Result ResetChargerWatchdogTimer(IDevice *device) = 0;
virtual Result GetChargerBatteryCompensation(int *out_mo, IDevice *device) = 0;
virtual Result SetChargerBatteryCompensation(IDevice *device, int mo) = 0;
virtual Result GetChargerVoltageClamp(int *out_mv, IDevice *device) = 0;
virtual Result SetChargerVoltageClamp(IDevice *device, int mv) = 0;
};
}
| 7,260
|
C++
|
.h
| 105
| 58.409524
| 124
| 0.69234
|
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,309
|
powctl_battery_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.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 "../../../powctl_i_power_control_driver.hpp"
#include "powctl_interrupt_event_handler.hpp"
namespace ams::powctl::impl::board::nintendo::nx {
class BatteryDevice : public powctl::impl::IDevice {
NON_COPYABLE(BatteryDevice);
NON_MOVEABLE(BatteryDevice);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::BatteryDevice, ::ams::powctl::impl::IDevice);
private:
bool m_use_event_handler;
util::optional<BatteryInterruptEventHandler> m_event_handler;
os::SystemEventType m_system_event;
public:
BatteryDevice(bool ev);
os::SystemEventType *GetSystemEvent() { return std::addressof(m_system_event); }
void SetInterruptEnabled(bool en) {
if (m_use_event_handler) {
m_event_handler->SetInterruptEnabled(en);
}
}
};
class BatteryDriver : public IPowerControlDriver {
NON_COPYABLE(BatteryDriver);
NON_MOVEABLE(BatteryDriver);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::BatteryDriver, ::ams::powctl::impl::IPowerControlDriver);
public:
BatteryDriver(bool ev) : IPowerControlDriver(ev) { /* ... */ }
/* Generic API. */
virtual void InitializeDriver() override;
virtual void FinalizeDriver() override;
virtual Result GetDeviceSystemEvent(os::SystemEventType **out, IDevice *device) override;
virtual Result SetDeviceInterruptEnabled(IDevice *device, bool enable) override;
virtual Result GetDeviceErrorStatus(u32 *out, IDevice *device) override;
virtual Result SetDeviceErrorStatus(IDevice *device, u32 status) override;
/* Battery API. */
virtual Result GetBatteryChargePercentage(float *out_percent, IDevice *device) override;
virtual Result GetBatteryVoltageFuelGaugePercentage(float *out_percent, IDevice *device) override;
virtual Result GetBatteryFullCapacity(int *out_mah, IDevice *device) override;
virtual Result GetBatteryRemainingCapacity(int *out_mah, IDevice *device) override;
virtual Result SetBatteryChargePercentageMinimumAlertThreshold(IDevice *device, float percentage) override;
virtual Result SetBatteryChargePercentageMaximumAlertThreshold(IDevice *device, float percentage) override;
virtual Result SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(IDevice *device, float percentage) override;
virtual Result SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(IDevice *device, float percentage) override;
virtual Result SetBatteryFullChargeThreshold(IDevice *device, float percentage) override;
virtual Result GetBatteryAverageCurrent(int *out_ma, IDevice *device) override;
virtual Result GetBatteryCurrent(int *out_ma, IDevice *device) override;
virtual Result GetBatteryInternalState(void *dst, size_t *out_size, IDevice *device, size_t dst_size) override;
virtual Result SetBatteryInternalState(IDevice *device, const void *src, size_t src_size) override;
virtual Result GetBatteryNeedToRestoreParameters(bool *out, IDevice *device) override;
virtual Result SetBatteryNeedToRestoreParameters(IDevice *device, bool en) override;
virtual Result IsBatteryI2cShutdownEnabled(bool *out, IDevice *device) override;
virtual Result SetBatteryI2cShutdownEnabled(IDevice *device, bool en) override;
virtual Result IsBatteryPresent(bool *out, IDevice *device) override;
virtual Result GetBatteryCycles(int *out, IDevice *device) override;
virtual Result SetBatteryCycles(IDevice *device, int cycles) override;
virtual Result GetBatteryAge(float *out_percent, IDevice *device) override;
virtual Result GetBatteryTemperature(float *out_c, IDevice *device) override;
virtual Result GetBatteryMaximumTemperature(float *out_c, IDevice *device) override;
virtual Result SetBatteryTemperatureMinimumAlertThreshold(IDevice *device, float c) override;
virtual Result SetBatteryTemperatureMaximumAlertThreshold(IDevice *device, float c) override;
virtual Result GetBatteryVCell(int *out_mv, IDevice *device) override;
virtual Result GetBatteryAverageVCell(int *out_mv, IDevice *device) override;
virtual Result GetBatteryAverageVCellTime(TimeSpan *out, IDevice *device) override;
virtual Result SetBatteryVoltageMinimumAlertThreshold(IDevice *device, int mv) override;
virtual Result GetBatteryOpenCircuitVoltage(int *out_mv, IDevice *device) override;
virtual Result SetBatteryVoltageMaximumAlertThreshold(IDevice *device, int mv) override;
/* Unsupported Charger API. */
virtual Result GetChargerChargeCurrentState(ChargeCurrentState *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerChargeCurrentState(IDevice *device, ChargeCurrentState state) override { AMS_UNUSED(device, state); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetChargerFastChargeCurrentLimit(int *out_ma, IDevice *device) override { AMS_UNUSED(out_ma, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerFastChargeCurrentLimit(IDevice *device, int ma) override { AMS_UNUSED(device, ma); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetChargerChargeVoltageLimit(int *out_mv, IDevice *device) override { AMS_UNUSED(out_mv, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerChargeVoltageLimit(IDevice *device, int mv) override { AMS_UNUSED(device, mv); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerChargerConfiguration(IDevice *device, ChargerConfiguration cfg) override { AMS_UNUSED(device, cfg); R_THROW(powctl::ResultNotSupported()); }
virtual Result IsChargerHiZEnabled(bool *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerHiZEnabled(IDevice *device, bool en) override { AMS_UNUSED(device, en); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetChargerInputCurrentLimit(int *out_ma, IDevice *device) override { AMS_UNUSED(out_ma, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerInputCurrentLimit(IDevice *device, int ma) override { AMS_UNUSED(device, ma); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerInputVoltageLimit(IDevice *device, int mv) override { AMS_UNUSED(device, mv); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerBoostModeCurrentLimit(IDevice *device, int ma) override { AMS_UNUSED(device, ma); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetChargerChargerStatus(ChargerStatus *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result IsChargerWatchdogTimerEnabled(bool *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerWatchdogTimerEnabled(IDevice *device, bool en) override { AMS_UNUSED(device, en); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerWatchdogTimerTimeout(IDevice *device, TimeSpan timeout) override { AMS_UNUSED(device, timeout); R_THROW(powctl::ResultNotSupported()); }
virtual Result ResetChargerWatchdogTimer(IDevice *device) override { AMS_UNUSED(device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetChargerBatteryCompensation(int *out_mo, IDevice *device) override { AMS_UNUSED(out_mo, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerBatteryCompensation(IDevice *device, int mo) override { AMS_UNUSED(device, mo); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetChargerVoltageClamp(int *out_mv, IDevice *device) override { AMS_UNUSED(out_mv, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetChargerVoltageClamp(IDevice *device, int mv) override { AMS_UNUSED(device, mv); R_THROW(powctl::ResultNotSupported()); }
};
}
| 9,228
|
C++
|
.h
| 107
| 75.570093
| 177
| 0.723458
|
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,310
|
powctl_retry_helper.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_retry_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>
namespace ams::powctl::impl {
constexpr inline const TimeSpan PowerControlRetryTimeout = TimeSpan::FromSeconds(10);
constexpr inline const TimeSpan PowerControlRetryInterval = TimeSpan::FromMilliSeconds(20);
#define AMS_POWCTL_DRIVER_R_TRY_WITH_RETRY(__EXPR__) \
({ \
TimeSpan __powctl_retry_current_time = 0; \
while (true) { \
const Result __powctl_retry_result = ( __EXPR__ ); \
if (R_SUCCEEDED(__powctl_retry_result)) { \
break; \
} \
\
__powctl_retry_current_time += PowerControlRetryInterval; \
R_UNLESS(__powctl_retry_current_time < PowerControlRetryTimeout, __powctl_retry_result); \
\
os::SleepThread(PowerControlRetryInterval); \
} \
})
#define AMS_POWCTL_DRIVER_LOCKED_R_TRY_WITH_RETRY(__EXPR__) AMS_POWCTL_DRIVER_R_TRY_WITH_RETRY( ({ std::scoped_lock lk(this->GetMutex()); ( __EXPR__ ); }) )
}
| 2,570
|
C++
|
.h
| 37
| 57.297297
| 160
| 0.426028
|
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,311
|
powctl_max17050_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.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::powctl::impl::board::nintendo::nx {
namespace max17050 {
struct InternalState {
u16 rcomp0;
u16 tempco;
u16 fullcap;
u16 cycles;
u16 fullcapnom;
u16 iavgempty;
u16 qresidual00;
u16 qresidual10;
u16 qresidual20;
u16 qresidual30;
};
}
class Max17050Driver {
private:
os::SdkMutex m_mutex;
int m_init_count;
i2c::I2cSession m_i2c_session;
max17050::InternalState m_internal_state;
private:
Result InitializeSession(const char *battery_vendor, u8 battery_version);
Result SetMaximumShutdownTimerThreshold();
Result SetAlertByChargePercentage();
Result SetAlertByVoltageFuelGaugePercentage();
bool IsPowerOnReset();
Result LockVoltageFuelGauge();
Result UnlockVoltageFuelGauge();
Result LockModelTable();
Result UnlockModelTable();
bool IsModelTableLocked();
Result SetModelTable(const u16 *model_table);
bool IsModelTableSet(const u16 *model_table);
public:
constexpr Max17050Driver() : m_mutex(), m_init_count(0), m_i2c_session(), m_internal_state() {
/* ... */
}
void Initialize(const char *battery_vendor, u8 battery_version) {
std::scoped_lock lk(m_mutex);
if ((m_init_count++) == 0) {
/* Initialize i2c library. */
i2c::InitializeEmpty();
/* Open session. */
R_ABORT_UNLESS(i2c::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Max17050));
/* Initialize session. */
R_ABORT_UNLESS(this->InitializeSession(battery_vendor, battery_version));
/* Set shutdown timer threshold to the maximum value. */
R_ABORT_UNLESS(this->SetMaximumShutdownTimerThreshold());
}
}
void Finalize() {
std::scoped_lock lk(m_mutex);
if ((--m_init_count) == 0) {
/* Close session. */
i2c::CloseSession(m_i2c_session);
/* Finalize i2c library. */
i2c::Finalize();
}
}
Result ReadInternalState();
Result WriteInternalState();
void GetInternalState(max17050::InternalState *dst) {
*dst = m_internal_state;
}
void SetInternalState(const max17050::InternalState &src) {
m_internal_state = src;
}
Result GetChargePercentage(double *out);
Result GetVoltageFuelGaugePercentage(double *out);
Result GetFullCapacity(double *out, double sense_resistor);
Result GetRemainingCapacity(double *out, double sense_resistor);
Result SetChargePercentageMinimumAlertThreshold(int percentage);
Result SetChargePercentageMaximumAlertThreshold(int percentage);
Result SetVoltageFuelGaugePercentageMinimumAlertThreshold(int percentage);
Result SetVoltageFuelGaugePercentageMaximumAlertThreshold(int percentage);
Result SetFullChargeThreshold(double percentage);
Result GetAverageCurrent(double *out, double sense_resistor);
Result GetCurrent(double *out, double sense_resistor);
Result GetNeedToRestoreParameters(bool *out);
Result SetNeedToRestoreParameters(bool en);
Result IsI2cShutdownEnabled(bool *out);
Result SetI2cShutdownEnabled(bool en);
Result GetStatus(u16 *out);
Result GetCycles(u16 *out);
Result ResetCycles();
Result GetAge(double *out);
Result GetTemperature(double *out);
Result GetMaximumTemperature(u8 *out);
Result SetTemperatureMinimumAlertThreshold(int c);
Result SetTemperatureMaximumAlertThreshold(int c);
Result GetVCell(int *out);
Result GetAverageVCell(int *out);
Result GetAverageVCellTime(double *out);
Result GetOpenCircuitVoltage(int *out);
Result SetVoltageMinimumAlertThreshold(int mv);
Result SetVoltageMaximumAlertThreshold(int mv);
};
}
| 5,203
|
C++
|
.h
| 116
| 32.715517
| 110
| 0.608351
|
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,312
|
powctl_charger_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.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 "../../../powctl_i_power_control_driver.hpp"
#include "powctl_interrupt_event_handler.hpp"
namespace ams::powctl::impl::board::nintendo::nx {
class ChargerDevice : public powctl::impl::IDevice {
NON_COPYABLE(ChargerDevice);
NON_MOVEABLE(ChargerDevice);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::ChargerDevice, ::ams::powctl::impl::IDevice);
private:
gpio::GpioPadSession m_gpio_pad_session;
bool m_watchdog_timer_enabled;
TimeSpan m_watchdog_timer_timeout;
bool m_use_event_handler;
util::optional<ChargerInterruptEventHandler> m_event_handler;
os::SystemEventType m_system_event;
public:
ChargerDevice(bool ev);
bool IsWatchdogTimerEnabled() const { return m_watchdog_timer_enabled; }
void SetWatchdogTimerEnabled(bool en) { m_watchdog_timer_enabled = en; }
TimeSpan GetWatchdogTimerTimeout() const { return m_watchdog_timer_timeout; }
void SetWatchdogTimerTimeout(TimeSpan ts) { m_watchdog_timer_timeout = ts; }
gpio::GpioPadSession *GetPadSession() { return std::addressof(m_gpio_pad_session); }
os::SystemEventType *GetSystemEvent() { return std::addressof(m_system_event); }
void SetInterruptEnabled(bool en) {
if (m_use_event_handler) {
m_event_handler->SetInterruptEnabled(en);
}
}
};
class ChargerDriver : public IPowerControlDriver {
NON_COPYABLE(ChargerDriver);
NON_MOVEABLE(ChargerDriver);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::ChargerDriver, ::ams::powctl::impl::IPowerControlDriver);
public:
ChargerDriver(bool ev) : IPowerControlDriver(ev) { /* ... */ }
/* Generic API. */
virtual void InitializeDriver() override;
virtual void FinalizeDriver() override;
virtual Result GetDeviceSystemEvent(os::SystemEventType **out, IDevice *device) override;
virtual Result SetDeviceInterruptEnabled(IDevice *device, bool enable) override;
virtual Result GetDeviceErrorStatus(u32 *out, IDevice *device) override;
virtual Result SetDeviceErrorStatus(IDevice *device, u32 status) override;
/* Charger API. */
virtual Result GetChargerChargeCurrentState(ChargeCurrentState *out, IDevice *device) override;
virtual Result SetChargerChargeCurrentState(IDevice *device, ChargeCurrentState state) override;
virtual Result GetChargerFastChargeCurrentLimit(int *out_ma, IDevice *device) override;
virtual Result SetChargerFastChargeCurrentLimit(IDevice *device, int ma) override;
virtual Result GetChargerChargeVoltageLimit(int *out_mv, IDevice *device) override;
virtual Result SetChargerChargeVoltageLimit(IDevice *device, int mv) override;
virtual Result SetChargerChargerConfiguration(IDevice *device, ChargerConfiguration cfg) override;
virtual Result IsChargerHiZEnabled(bool *out, IDevice *device) override;
virtual Result SetChargerHiZEnabled(IDevice *device, bool en) override;
virtual Result GetChargerInputCurrentLimit(int *out_ma, IDevice *device) override;
virtual Result SetChargerInputCurrentLimit(IDevice *device, int ma) override;
virtual Result SetChargerInputVoltageLimit(IDevice *device, int mv) override;
virtual Result SetChargerBoostModeCurrentLimit(IDevice *device, int ma) override;
virtual Result GetChargerChargerStatus(ChargerStatus *out, IDevice *device) override;
virtual Result IsChargerWatchdogTimerEnabled(bool *out, IDevice *device) override;
virtual Result SetChargerWatchdogTimerEnabled(IDevice *device, bool en) override;
virtual Result SetChargerWatchdogTimerTimeout(IDevice *device, TimeSpan timeout) override;
virtual Result ResetChargerWatchdogTimer(IDevice *device) override;
virtual Result GetChargerBatteryCompensation(int *out_mo, IDevice *device) override;
virtual Result SetChargerBatteryCompensation(IDevice *device, int mo) override;
virtual Result GetChargerVoltageClamp(int *out_mv, IDevice *device) override;
virtual Result SetChargerVoltageClamp(IDevice *device, int mv) override;
/* Unsupported Battery API. */
virtual Result GetBatteryChargePercentage(float *out_percent, IDevice *device) override { AMS_UNUSED(out_percent, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryVoltageFuelGaugePercentage(float *out_percent, IDevice *device) override { AMS_UNUSED(out_percent, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryFullCapacity(int *out_mah, IDevice *device) override { AMS_UNUSED(out_mah, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryRemainingCapacity(int *out_mah, IDevice *device) override { AMS_UNUSED(out_mah, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryChargePercentageMinimumAlertThreshold(IDevice *device, float percentage) override { AMS_UNUSED(device, percentage); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryChargePercentageMaximumAlertThreshold(IDevice *device, float percentage) override { AMS_UNUSED(device, percentage); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(IDevice *device, float percentage) override { AMS_UNUSED(device, percentage); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(IDevice *device, float percentage) override { AMS_UNUSED(device, percentage); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryFullChargeThreshold(IDevice *device, float percentage) override { AMS_UNUSED(device, percentage); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryAverageCurrent(int *out_ma, IDevice *device) override { AMS_UNUSED(out_ma, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryCurrent(int *out_ma, IDevice *device) override { AMS_UNUSED(out_ma, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryInternalState(void *dst, size_t *out_size, IDevice *device, size_t dst_size) override { AMS_UNUSED(dst, out_size, device, dst_size); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryInternalState(IDevice *device, const void *src, size_t src_size) override { AMS_UNUSED(device, src, src_size); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryNeedToRestoreParameters(bool *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryNeedToRestoreParameters(IDevice *device, bool en) override { AMS_UNUSED(device, en); R_THROW(powctl::ResultNotSupported()); }
virtual Result IsBatteryI2cShutdownEnabled(bool *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryI2cShutdownEnabled(IDevice *device, bool en) override { AMS_UNUSED(device, en); R_THROW(powctl::ResultNotSupported()); }
virtual Result IsBatteryPresent(bool *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryCycles(int *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryCycles(IDevice *device, int cycles) override { AMS_UNUSED(device, cycles); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryAge(float *out_percent, IDevice *device) override { AMS_UNUSED(out_percent, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryTemperature(float *out_c, IDevice *device) override { AMS_UNUSED(out_c, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryMaximumTemperature(float *out_c, IDevice *device) override { AMS_UNUSED(out_c, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryTemperatureMinimumAlertThreshold(IDevice *device, float c) override { AMS_UNUSED(device, c); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryTemperatureMaximumAlertThreshold(IDevice *device, float c) override { AMS_UNUSED(device, c); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryVCell(int *out_mv, IDevice *device) override { AMS_UNUSED(out_mv, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryAverageVCell(int *out_mv, IDevice *device) override { AMS_UNUSED(out_mv, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryAverageVCellTime(TimeSpan *out, IDevice *device) override { AMS_UNUSED(out, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryVoltageMinimumAlertThreshold(IDevice *device, int mv) override { AMS_UNUSED(device, mv); R_THROW(powctl::ResultNotSupported()); }
virtual Result GetBatteryOpenCircuitVoltage(int *out_mv, IDevice *device) override { AMS_UNUSED(out_mv, device); R_THROW(powctl::ResultNotSupported()); }
virtual Result SetBatteryVoltageMaximumAlertThreshold(IDevice *device, int mv) override { AMS_UNUSED(device, mv); R_THROW(powctl::ResultNotSupported()); }
};
}
| 10,528
|
C++
|
.h
| 115
| 80.678261
| 210
| 0.720968
|
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,313
|
powctl_board_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_board_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 "powctl_interrupt_event_handler.hpp"
namespace ams::powctl::impl::board::nintendo::nx {
void Initialize(bool use_event_handlers);
void Finalize();
}
| 846
|
C++
|
.h
| 22
| 36.272727
| 76
| 0.757317
|
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,314
|
powctl_bq24193_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.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::powctl::impl::board::nintendo::nx {
namespace bq24193 {
enum ChargerConfiguration {
ChargerConfiguration_ChargeDisable = 0,
ChargerConfiguration_ChargeBattery = 1,
ChargerConfiguration_Otg = 2,
};
enum ChargerStatus {
ChargerStatus_NotCharging = 0,
ChargerStatus_PreCharge = 1,
ChargerStatus_FastCharging = 2,
ChargerStatus_ChargeTerminationDone = 3,
};
}
class Bq24193Driver {
private:
os::SdkMutex m_mutex;
int m_init_count;
i2c::I2cSession m_i2c_session;
private:
Result InitializeSession();
public:
constexpr Bq24193Driver() : m_mutex(), m_init_count(0), m_i2c_session() {
/* ... */
}
void Initialize() {
std::scoped_lock lk(m_mutex);
if ((m_init_count++) == 0) {
/* Initialize i2c library. */
i2c::InitializeEmpty();
/* Open session. */
R_ABORT_UNLESS(i2c::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Bq24193));
/* Initialize session. */
R_ABORT_UNLESS(this->InitializeSession());
}
}
void Finalize() {
std::scoped_lock lk(m_mutex);
if ((--m_init_count) == 0) {
/* Close session. */
i2c::CloseSession(m_i2c_session);
/* Finalize i2c library. */
i2c::Finalize();
}
}
Result SetPreChargeCurrentLimit(int ma);
Result SetTerminationCurrentLimit(int ma);
Result SetMinimumSystemVoltageLimit(int mv);
Result SetChargingSafetyTimerEnabled(bool en);
Result GetForce20PercentChargeCurrent(bool *out);
Result SetForce20PercentChargeCurrent(bool en);
Result GetFastChargeCurrentLimit(int *out_ma);
Result SetFastChargeCurrentLimit(int ma);
Result GetChargeVoltageLimit(int *out_mv);
Result SetChargeVoltageLimit(int mv);
Result SetChargerConfiguration(bq24193::ChargerConfiguration cfg);
Result IsHiZEnabled(bool *out);
Result SetHiZEnabled(bool en);
Result GetInputCurrentLimit(int *out_ma);
Result SetInputCurrentLimit(int ma);
Result SetInputVoltageLimit(int mv);
Result SetBoostModeCurrentLimit(int ma);
Result GetChargerStatus(bq24193::ChargerStatus *out);
Result ResetWatchdogTimer();
Result SetWatchdogTimerSetting(int seconds);
Result GetBatteryCompensation(int *out_mo);
Result SetBatteryCompensation(int mo);
Result GetVoltageClamp(int *out_mv);
Result SetVoltageClamp(int mv);
};
}
| 3,737
|
C++
|
.h
| 88
| 31.045455
| 109
| 0.590834
|
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,315
|
powctl_interrupt_event_handler.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_interrupt_event_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 "../../../powctl_i_power_control_driver.hpp"
namespace ams::powctl::impl::board::nintendo::nx {
template<typename Derived>
class InterruptEventHandler : public ddsf::IEventHandler {
private:
IDevice *m_device;
gpio::GpioPadSession m_gpio_session;
os::SystemEventType m_gpio_system_event;
os::SdkMutex m_mutex;
public:
InterruptEventHandler(IDevice *dv) : IEventHandler(), m_device(dv), m_mutex() {
/* Initialize the gpio session. */
Derived::Initialize(std::addressof(m_gpio_session), std::addressof(m_gpio_system_event));
/* Initialize ourselves as an event handler. */
IEventHandler::Initialize(std::addressof(m_gpio_system_event));
}
os::SystemEventType *GetSystemEvent() {
return std::addressof(m_gpio_system_event);
}
void SetInterruptEnabled(bool en) {
std::scoped_lock lk(m_mutex);
gpio::SetInterruptEnable(std::addressof(m_gpio_session), en);
}
virtual void HandleEvent() override final {
/* Acquire exclusive access to ourselves. */
std::scoped_lock lk(m_mutex);
/* Clear our interrupt status. */
gpio::ClearInterruptStatus(std::addressof(m_gpio_session));
/* Clear our system event. */
os::ClearSystemEvent(std::addressof(m_gpio_system_event));
/* Signal the event. */
static_cast<Derived *>(this)->SignalEvent(m_device);
}
};
class ChargerInterruptEventHandler : public InterruptEventHandler<ChargerInterruptEventHandler> {
friend class InterruptEventHandler<ChargerInterruptEventHandler>;
private:
static void Initialize(gpio::GpioPadSession *session, os::SystemEventType *event) {
/* Open the gpio session. */
R_ABORT_UNLESS(gpio::OpenSession(session, gpio::DeviceCode_Bq24190Irq));
/* Configure the gpio session. */
gpio::SetDirection(session, gpio::Direction_Input);
gpio::SetInterruptMode(session, gpio::InterruptMode_FallingEdge);
gpio::SetInterruptEnable(session, true);
/* Bind the interrupt event. */
R_ABORT_UNLESS(gpio::BindInterrupt(event, session));
}
void SignalEvent(IDevice *device);
public:
ChargerInterruptEventHandler(IDevice *dv) : InterruptEventHandler<ChargerInterruptEventHandler>(dv) { /* ... */ }
};
class BatteryInterruptEventHandler : public InterruptEventHandler<BatteryInterruptEventHandler> {
friend class InterruptEventHandler<BatteryInterruptEventHandler>;
private:
static void Initialize(gpio::GpioPadSession *session, os::SystemEventType *event) {
/* Open the gpio session. */
R_ABORT_UNLESS(gpio::OpenSession(session, gpio::DeviceCode_BattMgicIrq));
/* Configure the gpio session. */
gpio::SetDirection(session, gpio::Direction_Input);
gpio::SetInterruptMode(session, gpio::InterruptMode_LowLevel);
/* Bind the interrupt event. */
R_ABORT_UNLESS(gpio::BindInterrupt(event, session));
}
void SignalEvent(IDevice *device);
public:
BatteryInterruptEventHandler(IDevice *dv) : InterruptEventHandler<BatteryInterruptEventHandler>(dv) { /* ... */ }
};
}
| 4,309
|
C++
|
.h
| 85
| 39.764706
| 125
| 0.632905
|
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,316
|
mem_impl_platform.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/mem/impl/mem_impl_platform.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::mem::impl {
enum Prot {
Prot_none = (0 << 0),
Prot_read = (1 << 0),
Prot_write = (1 << 1),
Prot_exec = (1 << 2),
};
errno_t virtual_alloc(void **ptr, size_t size);
errno_t virtual_free(void *ptr, size_t size);
errno_t physical_alloc(void *ptr, size_t size, Prot prot);
errno_t physical_free(void *ptr, size_t size);
size_t strlcpy(char *dst, const char *src, size_t size);
errno_t gen_random(void *dst, size_t dst_size);
errno_t epochtime(s64 *dst);
errno_t getcpu(s32 *out);
}
| 1,252
|
C++
|
.h
| 33
| 34.090909
| 76
| 0.682081
|
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,317
|
mem_impl_heap_tls_heap_static.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_static.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 "mem_impl_heap_platform.hpp"
namespace ams::mem::impl::heap {
class TlsHeapStatic {
public:
struct ClassInfo {
u16 num_pages;
u16 chunk_size;
};
static constexpr size_t NumClassInfo = 57;
static constexpr size_t MaxSizeWithClass = 0xC00;
static constexpr size_t ChunkGranularity = 0x10;
static constexpr size_t PageSize = 4_KB;
static constexpr size_t PhysicalPageSize = 256_KB;
public:
static constexpr inline std::array<ClassInfo, NumClassInfo> ClassInfos = {
ClassInfo{ .num_pages = 0, .chunk_size = 0x000, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x010, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x020, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x030, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x040, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x050, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x060, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x070, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x080, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x090, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x0A0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x0B0, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x0C0, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x0D0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x0E0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x0F0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x100, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x110, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x120, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x130, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x140, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x150, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x160, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x170, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x180, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x190, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x1A0, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x1B0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x1C0, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x1D0, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x1E0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x200, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x210, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x220, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x240, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x260, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x270, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x280, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x2A0, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x2D0, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x2E0, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x300, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x330, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x360, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x380, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x3B0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x400, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x450, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x490, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x4C0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x550, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x600, },
ClassInfo{ .num_pages = 2, .chunk_size = 0x660, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x6D0, },
ClassInfo{ .num_pages = 1, .chunk_size = 0x800, },
ClassInfo{ .num_pages = 3, .chunk_size = 0x990, },
ClassInfo{ .num_pages = 2, .chunk_size = 0xAA0, },
};
static constexpr inline std::array<size_t, MaxSizeWithClass / ChunkGranularity> SizeToClass = [] {
std::array<size_t, MaxSizeWithClass / ChunkGranularity> arr = {};
arr[0] = 1;
for (size_t i = 1; i < arr.size(); i++) {
const size_t cur_size = i * ChunkGranularity;
for (size_t j = 0; j < ClassInfos.size(); j++) {
if (ClassInfos[j].chunk_size >= cur_size) {
arr[i] = j;
break;
}
}
}
return arr;
}();
public:
static constexpr ALWAYS_INLINE size_t GetClassFromSize(size_t size) {
AMS_ASSERT(size <= MaxSize);
const size_t idx = util::AlignUp(size, ChunkGranularity) / ChunkGranularity;
if (idx < MaxSizeWithClass / ChunkGranularity) {
return SizeToClass[idx];
} else {
return 0;
}
}
static constexpr ALWAYS_INLINE size_t GetRealSizeFromSizeAndAlignment(size_t size, size_t align) {
AMS_ASSERT(size <= MaxSize);
const size_t idx = util::AlignUp(size, ChunkGranularity) / ChunkGranularity;
if (size == 0 || idx >= MaxSizeWithClass / ChunkGranularity) {
return size;
}
const auto cls = SizeToClass[idx];
if (!cls) {
return PageSize;
}
AMS_ASSERT(align != 0);
const size_t mask = align - 1;
for (auto i = cls; i < ClassInfos.size(); i++) {
if ((ClassInfos[i].chunk_size & mask) == 0) {
return ClassInfos[i].chunk_size;
}
}
return PageSize;
}
static constexpr ALWAYS_INLINE bool IsPageAligned(uintptr_t ptr) {
return util::IsAligned(ptr, PageSize);
}
static ALWAYS_INLINE bool IsPageAligned(const void *ptr) {
return IsPageAligned(reinterpret_cast<uintptr_t>(ptr));
}
static constexpr ALWAYS_INLINE size_t GetPageIndex(uintptr_t ptr) {
return ptr / PageSize;
}
static constexpr ALWAYS_INLINE size_t GetPhysicalPageIndex(uintptr_t ptr) {
return ptr / PhysicalPageSize;
}
static constexpr ALWAYS_INLINE uintptr_t AlignUpPage(uintptr_t ptr) {
return util::AlignUp(ptr, PageSize);
}
template<typename T>
static ALWAYS_INLINE T *AlignUpPage(T *ptr) {
static_assert(util::is_pod<T>::value);
static_assert(util::IsAligned(PageSize, alignof(T)));
return reinterpret_cast<T *>(AlignUpPage(reinterpret_cast<uintptr_t>(ptr)));
}
static constexpr ALWAYS_INLINE uintptr_t AlignDownPage(uintptr_t ptr) {
return util::AlignDown(ptr, PageSize);
}
template<typename T>
static ALWAYS_INLINE T *AlignDownPage(T *ptr) {
static_assert(util::is_pod<T>::value);
static_assert(util::IsAligned(PageSize, alignof(T)));
return reinterpret_cast<T *>(AlignDownPage(reinterpret_cast<uintptr_t>(ptr)));
}
static constexpr ALWAYS_INLINE uintptr_t AlignUpPhysicalPage(uintptr_t ptr) {
return util::AlignUp(ptr, PhysicalPageSize);
}
template<typename T>
static ALWAYS_INLINE T *AlignUpPhysicalPage(T *ptr) {
static_assert(util::is_pod<T>::value);
static_assert(util::IsAligned(PhysicalPageSize, alignof(T)));
return reinterpret_cast<T *>(AlignUpPhysicalPage(reinterpret_cast<uintptr_t>(ptr)));
}
static constexpr ALWAYS_INLINE uintptr_t AlignDownPhysicalPage(uintptr_t ptr) {
return util::AlignDown(ptr, PhysicalPageSize);
}
template<typename T>
static ALWAYS_INLINE T *AlignDownPhysicalPage(T *ptr) {
static_assert(util::is_pod<T>::value);
static_assert(util::IsAligned(PhysicalPageSize, alignof(T)));
return reinterpret_cast<T *>(AlignDownPhysicalPage(reinterpret_cast<uintptr_t>(ptr)));
}
static constexpr ALWAYS_INLINE size_t GetChunkSize(size_t cls) {
return ClassInfos[cls].chunk_size;
}
static constexpr ALWAYS_INLINE size_t GetNumPages(size_t cls) {
return ClassInfos[cls].num_pages;
}
};
}
| 9,987
|
C++
|
.h
| 189
| 38.15873
| 110
| 0.530886
|
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,318
|
mem_impl_heap_tls_heap_central.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.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 "mem_impl_heap_platform.hpp"
#include "mem_impl_heap_tls_heap_static.hpp"
#include "mem_impl_heap_tls_heap_cache.hpp"
namespace ams::mem::impl::heap {
/* Simple intrusive list. */
template<typename T>
struct ListHeader {
T *list_next;
};
template<typename T>
struct ListElement : public ListHeader<T> {
T *list_prev;
};
template<typename T>
constexpr inline void ListClearLink(ListHeader<T> *l) {
l->list_next = nullptr;
}
template<typename T>
constexpr inline void ListClearLink(ListElement<T> *l) {
l->list_next = nullptr;
l->list_prev = nullptr;
}
template<typename T>
constexpr inline T *ListGetNext(const ListHeader<T> *l) {
return l->list_next;
}
template<typename T>
constexpr inline T *ListGetNext(const ListElement<T> *l) {
return l->list_next;
}
template<typename T>
constexpr inline T *ListGetPrev(const ListElement<T> *l) {
return l->list_prev;
}
template<typename T>
constexpr inline void ListInsertAfter(ListHeader<T> *hdr, T *e) {
e->list_next = hdr->list_next;
e->list_prev = static_cast<T *>(hdr);
if (hdr->list_next != nullptr) {
hdr->list_next->list_prev = e;
}
hdr->list_next = e;
}
template<typename T>
constexpr inline void ListRemoveSelf(T *e) {
if (e->list_next != nullptr) {
e->list_next->list_prev = e->list_prev;
}
if (e->list_prev != nullptr) {
e->list_prev->list_next = e->list_next;
}
e->list_next = nullptr;
e->list_prev = nullptr;
}
struct Span : public ListElement<Span> {
struct SmallMemory {
SmallMemory *next;
};
enum Status : u8 {
Status_NotUsed = 0,
Status_InUse = 1,
Status_InFreeList = 2,
Status_InUseSystem = 3,
};
u16 object_count;
u8 page_class;
u8 status;
s32 id;
union {
uintptr_t u;
void *p;
SmallMemory *sm;
char *cp;
} start;
uintptr_t num_pages;
union {
struct {
SmallMemory *objects;
u64 is_allocated[8];
} small;
struct {
u8 color[3];
char name[0x10];
} large;
struct {
u32 zero;
} large_clear;
} aux;
};
struct SpanPage : public ListElement<SpanPage> {
struct Info {
u64 alloc_bitmap;
u16 free_count;
u8 is_sticky;
Span span_of_spanpage;
} info;
Span spans[(TlsHeapStatic::PageSize - sizeof(Info) - sizeof(ListElement<SpanPage>)) / sizeof(Span)];
static constexpr size_t MaxSpanCount = sizeof(spans) / sizeof(spans[0]);
};
static_assert(sizeof(SpanPage) <= TlsHeapStatic::PageSize);
static constexpr ALWAYS_INLINE bool CanAllocateSpan(const SpanPage *span_page) {
return span_page->info.alloc_bitmap != ~(decltype(span_page->info.alloc_bitmap){});
}
struct SpanTable {
uintptr_t total_pages;
Span **page_to_span;
u8 *pageclass_cache;
};
struct TlsHeapMemStats {
size_t allocated_size;
size_t free_size;
size_t system_size;
size_t max_allocatable_size;
};
ALWAYS_INLINE Span *GetSpanFromPointer(const SpanTable *table, const void *ptr) {
const size_t idx = TlsHeapStatic::GetPageIndex(reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(table));
if (idx < table->total_pages) {
return table->page_to_span[idx];
} else {
return nullptr;
}
}
ALWAYS_INLINE SpanPage *GetSpanPage(Span *span) {
return reinterpret_cast<SpanPage *>(TlsHeapStatic::AlignDownPage(reinterpret_cast<uintptr_t>(span)));
}
ALWAYS_INLINE Span *GetSpanPageSpan(SpanPage *span_page) {
return std::addressof(span_page->info.span_of_spanpage);
}
ALWAYS_INLINE Span *GetPrevSpan(const SpanTable *span_table, const Span *span) {
return GetSpanFromPointer(span_table, reinterpret_cast<const void *>(span->start.u - 1));
}
ALWAYS_INLINE Span *GetNextSpan(const SpanTable *span_table, const Span *span) {
return GetSpanFromPointer(span_table, reinterpret_cast<const void *>(span->start.u + span->num_pages * TlsHeapStatic::PageSize));
}
class TlsHeapCentral {
private:
using FreeListAvailableWord = u64;
static constexpr size_t FreeListCount = 0x100;
static constexpr size_t NumFreeListBitmaps = FreeListCount / BITSIZEOF(FreeListAvailableWord);
static constexpr ALWAYS_INLINE size_t FreeListAvailableIndex(size_t which) {
return which / BITSIZEOF(FreeListAvailableWord);
}
static constexpr ALWAYS_INLINE size_t FreeListAvailableBit(size_t which) {
return which % BITSIZEOF(FreeListAvailableWord);
}
static constexpr ALWAYS_INLINE FreeListAvailableWord FreeListAvailableMask(size_t which) {
return static_cast<FreeListAvailableWord>(1) << FreeListAvailableBit(which);
}
static_assert(NumFreeListBitmaps * BITSIZEOF(FreeListAvailableWord) == FreeListCount);
private:
SpanTable m_span_table;
u8 *m_physical_page_flags;
s32 m_num_threads;
s32 m_static_thread_quota;
s32 m_dynamic_thread_quota;
bool m_use_virtual_memory;
os::SdkRecursiveMutex m_lock;
ListHeader<SpanPage> m_spanpage_list;
ListHeader<SpanPage> m_full_spanpage_list;
ListHeader<Span> m_freelists[FreeListCount];
FreeListAvailableWord m_freelists_bitmap[NumFreeListBitmaps];
ListHeader<Span> m_smallmem_lists[TlsHeapStatic::NumClassInfo];
public:
TlsHeapCentral() : m_lock() {
m_span_table.total_pages = 0;
}
errno_t Initialize(void *start, size_t size, bool use_virtual_memory);
bool IsClean();
errno_t ReallocateLargeMemory(void *ptr, size_t size, void **p);
errno_t ShrinkLargeMemory(void *ptr, size_t size);
void CalculateHeapHash(HeapHash *out);
errno_t AddThreadCache(TlsHeapCache *cache) {
AMS_UNUSED(cache);
std::scoped_lock lk(m_lock);
/* Add thread and recalculate. */
m_num_threads++;
m_dynamic_thread_quota = this->GetTotalHeapSize() / (2 * m_num_threads);
return 0;
}
errno_t RemoveThreadCache(TlsHeapCache *cache) {
AMS_UNUSED(cache);
std::scoped_lock lk(m_lock);
/* Remove thread and recalculate. */
m_num_threads--;
m_dynamic_thread_quota = this->GetTotalHeapSize() / (2 * m_num_threads);
return 0;
}
void *CacheLargeMemory(size_t size) {
std::scoped_lock lk(m_lock);
const size_t num_pages = util::AlignUp(size, TlsHeapStatic::PageSize) / TlsHeapStatic::PageSize;
if (Span *span = this->AllocatePagesImpl(num_pages); span != nullptr) {
return span->start.p;
} else {
return nullptr;
}
}
void *CacheLargeMemoryWithBigAlign(size_t size, size_t align) {
std::scoped_lock lk(m_lock);
const size_t num_pages = util::AlignUp(size, TlsHeapStatic::PageSize) / TlsHeapStatic::PageSize;
Span *span = nullptr;
if (align > TlsHeapStatic::PageSize) {
span = this->AllocatePagesWithBigAlignImpl(num_pages, align);
} else {
span = this->AllocatePagesImpl(num_pages);
}
if (span != nullptr) {
return span->start.p;
} else {
return nullptr;
}
}
void *CacheSmallMemory(size_t cls, size_t align = 0) {
std::scoped_lock lk(m_lock);
return this->CacheSmallMemoryImpl(cls, align, false);
}
void *CacheSmallMemoryForSystem(size_t cls) {
std::scoped_lock lk(m_lock);
return this->CacheSmallMemoryImpl(cls, 0, true);
}
size_t CacheSmallMemoryList(TlsHeapCache *cache, size_t *cls, size_t count, void **p, size_t align = 0) {
std::scoped_lock lk(m_lock);
s32 cpu_id = 0;
if (*cls < 8) {
getcpu(std::addressof(cpu_id));
}
return this->CacheSmallMemoryListImpl(cache, cls, count, p, cpu_id, align);
}
bool CheckCachedSize(s32 size) const {
return size < m_dynamic_thread_quota && size < m_static_thread_quota;
}
void Dump(DumpMode dump_mode, int fd, bool json) {
std::scoped_lock lk(m_lock);
return this->DumpImpl(dump_mode, fd, json);
}
size_t GetAllocationSize(const void *ptr) {
if (TlsHeapStatic::IsPageAligned(ptr)) {
Span *span = nullptr;
{
std::scoped_lock lk(m_lock);
span = GetSpanFromPointer(std::addressof(m_span_table), ptr);
}
if (span != nullptr) {
return span->num_pages * TlsHeapStatic::PageSize;
} else {
AMS_ASSERT(span != nullptr);
return 0;
}
} else {
/* TODO: Handle error? */
return 0;
}
}
s32 GetClassFromPointer(const void *ptr) {
std::atomic_thread_fence(std::memory_order_acquire);
const size_t idx = (reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(this)) / TlsHeapStatic::PageSize;
if (idx < m_span_table.total_pages) {
if (ptr != nullptr) {
std::scoped_lock lk(m_lock);
Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr);
if (span != nullptr) {
AMS_ASSERT(span->page_class == m_span_table.pageclass_cache[idx]);
} else {
AMS_ASSERT(span != nullptr);
}
}
return m_span_table.pageclass_cache[idx];
} else {
/* TODO: Handle error? */
return -1;
}
}
errno_t GetColor(const void *ptr, int *out) {
if (out == nullptr) {
return EINVAL;
}
std::scoped_lock lk(m_lock);
if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) {
*out = (span->aux.large.color[0] << 0) | (span->aux.large.color[1] << 8) | (span->aux.large.color[2] << 16);
return 0;
} else {
return EINVAL;
}
}
errno_t SetColor(const void *ptr, int color) {
std::scoped_lock lk(m_lock);
if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) {
span->aux.large.color[0] = (color >> 0) & 0xFF;
span->aux.large.color[1] = (color >> 8) & 0xFF;
span->aux.large.color[2] = (color >> 16) & 0xFF;
return 0;
} else {
return EINVAL;
}
}
errno_t GetMappedMemStats(size_t *out_free_size, size_t *out_max_allocatable_size) {
std::scoped_lock lk(m_lock);
return this->GetMappedMemStatsImpl(out_free_size, out_max_allocatable_size);
}
errno_t GetMemStats(TlsHeapMemStats *out) {
std::scoped_lock lk(m_lock);
return this->GetMemStatsImpl(out);
}
errno_t GetName(const void *ptr, char *dst, size_t dst_size) {
std::scoped_lock lk(m_lock);
if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) {
util::Strlcpy(dst, span->aux.large.name, dst_size);
return 0;
} else {
return EINVAL;
}
}
errno_t SetName(const void *ptr, const char *name) {
std::scoped_lock lk(m_lock);
if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) {
util::Strlcpy(span->aux.large.name, name, sizeof(span->aux.large.name));
return 0;
} else {
return EINVAL;
}
}
size_t GetTotalHeapSize() const {
return m_span_table.total_pages * TlsHeapStatic::PageSize;
}
errno_t UncacheLargeMemory(void *ptr) {
if (TlsHeapStatic::IsPageAligned(ptr)) {
std::scoped_lock lk(m_lock);
if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr) {
this->FreePagesImpl(span);
return 0;
} else {
return EFAULT;
}
} else {
return EFAULT;
}
}
errno_t UncacheSmallMemory(void *ptr) {
std::scoped_lock lk(m_lock);
return this->UncacheSmallMemoryImpl(ptr);
}
errno_t UncacheSmallMemoryList(TlsHeapCache *cache, void *ptr) {
std::scoped_lock lk(m_lock);
while (true) {
if (ptr == nullptr) {
return 0;
}
ptr = cache->ManglePointer(ptr);
void *next = *reinterpret_cast<void **>(ptr);
if (auto err = this->UncacheSmallMemoryImpl(ptr); err != 0) {
return err;
}
ptr = next;
}
}
errno_t WalkAllocatedPointers(HeapWalkCallback callback, void *user_data) {
/* Explicitly handle locking, as we will release the lock during callback. */
m_lock.lock();
ON_SCOPE_EXIT { m_lock.unlock(); };
return this->WalkAllocatedPointersImpl(callback, user_data);
}
private:
SpanPage *AllocateSpanPage();
Span *AllocateSpanFromSpanPage(SpanPage *sp);
Span *SplitSpan(Span *span, size_t num_pages, Span *new_span);
void MergeFreeSpans(Span *span, Span *span_to_merge, uintptr_t start);
bool DestroySpanPageIfEmpty(SpanPage *sp, bool full);
Span *GetFirstSpan() const;
Span *MakeFreeSpan(size_t num_pages);
Span *SearchFreeSpan(size_t num_pages) const;
void FreeSpanToSpanPage(Span *span, SpanPage *sp);
void FreeSpanToSpanPage(Span *span);
void MergeIntoFreeList(Span *&span);
errno_t AllocatePhysical(void *start, size_t size);
errno_t FreePhysical(void *start, size_t size);
private:
Span *AllocatePagesImpl(size_t num_pages);
Span *AllocatePagesWithBigAlignImpl(size_t num_pages, size_t align);
void FreePagesImpl(Span *span);
void *CacheSmallMemoryImpl(size_t cls, size_t align, bool for_system);
errno_t UncacheSmallMemoryImpl(void *ptr);
size_t CacheSmallMemoryListImpl(TlsHeapCache *cache, size_t *cls, size_t count, void **p, s32 cpu_id, size_t align);
errno_t WalkAllocatedPointersImpl(HeapWalkCallback callback, void *user_data);
errno_t GetMappedMemStatsImpl(size_t *out_free_size, size_t *out_max_allocatable_size);
errno_t GetMemStatsImpl(TlsHeapMemStats *out);
void DumpImpl(DumpMode dump_mode, int fd, bool json);
private:
size_t FreeListFirstNonEmpty(size_t start) const {
if (start < FreeListCount) {
for (size_t i = FreeListAvailableIndex(start); i < util::size(m_freelists_bitmap); i++) {
const FreeListAvailableWord masked = m_freelists_bitmap[i] & ~(FreeListAvailableMask(start) - 1);
if (masked) {
const size_t b = __builtin_ctzll(masked);
const size_t res = i * BITSIZEOF(FreeListAvailableWord) + b;
AMS_ASSERT(res < FreeListCount);
return res;
}
start = (i + 1) * BITSIZEOF(FreeListAvailableWord);
}
}
return FreeListCount;
}
ALWAYS_INLINE void AddToFreeBlockList(Span *span) {
AMS_ASSERT(GetSpanPageSpan(GetSpanPage(span)) != span);
AMS_ASSERT(span->status == Span::Status_InFreeList);
const size_t which = std::min(span->num_pages, FreeListCount) - 1;
ListInsertAfter(std::addressof(m_freelists[which]), span);
m_freelists_bitmap[FreeListAvailableIndex(which)] |= FreeListAvailableMask(which);
}
ALWAYS_INLINE void RemoveFromFreeBlockList(Span *span) {
const size_t which = std::min(span->num_pages, FreeListCount) - 1;
ListRemoveSelf(span);
if (!ListGetNext(std::addressof(m_freelists[which]))) {
m_freelists_bitmap[FreeListAvailableIndex(which)] &= ~FreeListAvailableMask(which);
}
}
Span *AllocateSpanStruct() {
SpanPage *sp = ListGetNext(std::addressof(m_spanpage_list));
while (sp && (sp->info.is_sticky || !CanAllocateSpan(sp))) {
sp = ListGetNext(sp);
}
if (sp == nullptr) {
sp = this->AllocateSpanPage();
}
if (sp != nullptr) {
return this->AllocateSpanFromSpanPage(sp);
} else {
return nullptr;
}
}
s32 CallWalkCallback(HeapWalkCallback callback, void *ptr, size_t size, void *user_data) {
m_lock.unlock();
int res = callback(ptr, size, user_data);
m_lock.lock();
if (res) {
return 0;
} else {
return -1;
}
}
};
}
| 20,307
|
C++
|
.h
| 458
| 30.382096
| 137
| 0.532216
|
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,319
|
mem_impl_heap_tls_heap_cache.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.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 "mem_impl_heap_platform.hpp"
#include "mem_impl_heap_tls_heap_static.hpp"
namespace ams::mem::impl::heap {
class TlsHeapCentral;
#define FOREACH_TLS_HEAP_CACHE_FUNC(HANDLER) \
HANDLER(void *, Allocate, m_allocate, size_t size); \
HANDLER(void *, AllocateAligned, m_allocate_aligned, size_t size, size_t align); \
HANDLER(errno_t, Free, m_free, void *ptr); \
HANDLER(errno_t, FreeWithSize, m_free_with_size, void *ptr, size_t size); \
HANDLER(size_t, GetAllocationSize, m_get_allocation_size, const void *ptr); \
HANDLER(errno_t, Reallocate, m_reallocate, void *ptr, size_t size, void **p); \
HANDLER(errno_t, Shrink, m_shrink, void *ptr, size_t size);
class TlsHeapCache {
public:
static constexpr size_t MaxChunkCount = BITSIZEOF(u64);
public:
#define TLS_HEAP_CACHE_DECLARE_TYPEDEF(RETURN, NAME, MEMBER_NAME, ...) \
using NAME##Func = RETURN (*)(TlsHeapCache *, ## __VA_ARGS__)
FOREACH_TLS_HEAP_CACHE_FUNC(TLS_HEAP_CACHE_DECLARE_TYPEDEF)
#undef TLS_HEAP_CACHE_DECLARE_TYPEDEF
private:
#define TLS_HEAP_CACHE_DECLARE_MEMBER(RETURN, NAME, MEMBER_NAME, ...) \
NAME##Func MEMBER_NAME;
FOREACH_TLS_HEAP_CACHE_FUNC(TLS_HEAP_CACHE_DECLARE_MEMBER)
#undef TLS_HEAP_CACHE_DECLARE_MEMBER
uintptr_t m_mangle_val;
TlsHeapCentral *m_central;
size_t m_total_heap_size;
u32 m_heap_option;
s32 m_total_cached_size;
s32 m_largest_class;
void *m_small_mem_lists[TlsHeapStatic::NumClassInfo];
s32 m_cached_size[TlsHeapStatic::NumClassInfo];
u8 m_chunk_count[TlsHeapStatic::NumClassInfo];
public:
TlsHeapCache(TlsHeapCentral *central, u32 option);
void Finalize();
void *ManglePointer(void *ptr) const {
return reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(ptr) ^ m_mangle_val);
}
bool CheckCache() const;
void ReleaseAllCache();
public:
/* TODO: Better handler with type info to macro this? */
ALWAYS_INLINE void *Allocate(size_t size) { return m_allocate(this, size); }
ALWAYS_INLINE void *Allocate(size_t size, size_t align) { return m_allocate_aligned(this, size, align); }
ALWAYS_INLINE errno_t Free(void *ptr) { return m_free(this, ptr); }
ALWAYS_INLINE errno_t FreeWithSize(void *ptr, size_t size) { return m_free_with_size(this, ptr, size); }
ALWAYS_INLINE size_t GetAllocationSize(const void *ptr) { return m_get_allocation_size(this, ptr); }
ALWAYS_INLINE errno_t Reallocate(void *ptr, size_t size, void **p) { return m_reallocate(this, ptr, size, p); }
ALWAYS_INLINE errno_t Shrink(void *ptr, size_t size) { return m_shrink(this, ptr, size); }
private:
#define TLS_HEAP_CACHE_DECLARE_TEMPLATE(RETURN, NAME, MEMBER_NAME, ...) \
template<bool Cache> static RETURN NAME##Impl(TlsHeapCache *tls_heap_cache, ## __VA_ARGS__ )
FOREACH_TLS_HEAP_CACHE_FUNC(TLS_HEAP_CACHE_DECLARE_TEMPLATE)
#undef TLS_HEAP_CACHE_DECLARE_TEMPLATE
size_t GetAllocationSizeCommonImpl(const void *ptr) const;
errno_t ShrinkCommonImpl(void *ptr, size_t size) const;
};
#define TLS_HEAP_CACHE_DECLARE_INSTANTIATION(RETURN, NAME, MEMBER_NAME, ...) \
template<> RETURN TlsHeapCache::NAME##Impl<false>(TlsHeapCache *tls_heap_cache, ##__VA_ARGS__); \
template<> RETURN TlsHeapCache::NAME##Impl<true>(TlsHeapCache *tls_heap_cache, ##__VA_ARGS__)
FOREACH_TLS_HEAP_CACHE_FUNC(TLS_HEAP_CACHE_DECLARE_INSTANTIATION)
#undef FOREACH_TLS_HEAP_CACHE_FUNC
}
| 4,996
|
C++
|
.h
| 82
| 51.865854
| 128
| 0.591011
|
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,320
|
mem_impl_heap_platform.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_platform.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 "../mem_impl_platform.hpp"
namespace ams::mem::impl::heap {
using Prot = mem::impl::Prot;
inline errno_t AllocateVirtualMemory(void **ptr, size_t size) {
return ::ams::mem::impl::virtual_alloc(ptr, size);
}
inline errno_t FreeVirtualMemory(void *ptr, size_t size) {
return ::ams::mem::impl::virtual_free(ptr, size);
}
inline errno_t AllocatePhysicalMemory(void *ptr, size_t size) {
return ::ams::mem::impl::physical_alloc(ptr, size, static_cast<Prot>(Prot_read | Prot_write));
}
inline errno_t FreePhysicalMemory(void *ptr, size_t size) {
return ::ams::mem::impl::physical_free(ptr, size);
}
}
| 1,353
|
C++
|
.h
| 33
| 37.333333
| 102
| 0.707763
|
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,321
|
pwm_driver_core.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pwm/driver/impl/pwm_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::pwm::driver::impl {
void InitializeDrivers();
void FinalizeDrivers();
void RegisterDriver(IPwmDriver *driver);
void UnregisterDriver(IPwmDriver *driver);
Result RegisterDeviceCode(DeviceCode device_code, IPwmDevice *device);
bool UnregisterDeviceCode(DeviceCode device_code);
Result FindDevice(IPwmDevice **out, DeviceCode device_code);
Result FindDeviceByChannelIndex(IPwmDevice **out, int channel);
}
| 1,132
|
C++
|
.h
| 27
| 39
| 76
| 0.766151
|
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,322
|
pwm_channel_session_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pwm/driver/impl/pwm_channel_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::pwm::driver::impl {
class ChannelSessionImpl : public ::ams::ddsf::ISession {
NON_COPYABLE(ChannelSessionImpl);
NON_MOVEABLE(ChannelSessionImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::impl::ChannelSessionImpl, ::ams::ddsf::ISession);
public:
ChannelSessionImpl() { /* ... */ }
~ChannelSessionImpl() {
this->Close();
}
Result Open(IPwmDevice *device, ddsf::AccessMode access_mode);
void Close();
Result SetPeriod(TimeSpan period);
Result GetPeriod(TimeSpan *out);
Result SetDuty(int duty);
Result GetDuty(int *out);
Result SetEnabled(bool en);
Result GetEnabled(bool *out);
Result SetScale(double scale);
Result GetScale(double *out);
};
static_assert( sizeof(ChannelSessionImpl) <= ChannelSessionSize);
static_assert(alignof(ChannelSessionImpl) <= ChannelSessionAlign);
struct alignas(ChannelSessionAlign) ChannelSessionImplPadded {
ChannelSessionImpl _impl;
u8 _padding[ChannelSessionSize - sizeof(ChannelSessionImpl)];
};
static_assert( sizeof(ChannelSessionImplPadded) == ChannelSessionSize);
static_assert(alignof(ChannelSessionImplPadded) == ChannelSessionAlign);
ALWAYS_INLINE ChannelSessionImpl &GetChannelSessionImpl(ChannelSession &session) {
return GetReference(session._impl)._impl;
}
ALWAYS_INLINE const ChannelSessionImpl &GetChannelSessionImpl(const ChannelSession &session) {
return GetReference(session._impl)._impl;
}
ALWAYS_INLINE ChannelSessionImpl &GetOpenChannelSessionImpl(ChannelSession &session) {
auto &ref = GetReference(session._impl)._impl;
AMS_ASSERT(ref.IsOpen());
return ref;
}
ALWAYS_INLINE const ChannelSessionImpl &GetOpenChannelSessionImpl(const ChannelSession &session) {
const auto &ref = GetReference(session._impl)._impl;
AMS_ASSERT(ref.IsOpen());
return ref;
}
}
| 2,761
|
C++
|
.h
| 63
| 36.857143
| 102
| 0.694858
|
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,323
|
pwm_impl_pwm_driver_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_impl_pwm_driver_api.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::pwm::driver::board::nintendo::nx::impl {
struct ChannelDefinition {
DeviceCode device_code;
int channel_id;
};
Result InitializePwmDriver();
}
| 866
|
C++
|
.h
| 24
| 33.166667
| 76
| 0.74105
|
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,324
|
pwm_pwm_driver_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_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 "pwm_impl_pwm_driver_api.hpp"
namespace ams::pwm::driver::board::nintendo::nx::impl {
class PwmDeviceImpl : public ::ams::pwm::driver::IPwmDevice {
NON_COPYABLE(PwmDeviceImpl);
NON_MOVEABLE(PwmDeviceImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::board::nintendo::nx::impl::PwmDeviceImpl, ::ams::pwm::driver::IPwmDevice);
private:
os::SdkMutex m_suspend_mutex;
u32 m_suspend_value;
public:
PwmDeviceImpl(int channel) : IPwmDevice(channel), m_suspend_mutex(), m_suspend_value() { /* ... */ }
void SetSuspendValue(u32 v) { m_suspend_value = v; }
u32 GetSuspendValue() const { return m_suspend_value; }
void lock() { return m_suspend_mutex.lock(); }
void unlock() { return m_suspend_mutex.unlock(); }
};
class PwmDriverImpl : public ::ams::pwm::driver::IPwmDriver {
NON_COPYABLE(PwmDriverImpl);
NON_MOVEABLE(PwmDriverImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::board::nintendo::nx::impl::PwmDriverImpl, ::ams::pwm::driver::IPwmDriver);
private:
dd::PhysicalAddress m_registers_phys_addr;
size_t m_registers_size;
const ChannelDefinition *m_channels;
size_t m_num_channels;
uintptr_t m_registers;
private:
ALWAYS_INLINE uintptr_t GetRegistersFor(IPwmDevice &device) {
return m_registers + PWM_CONTROLLER_PWM_CHANNEL_OFFSET(device.GetChannelIndex());
}
ALWAYS_INLINE uintptr_t GetRegistersFor(IPwmDevice *device) {
return this->GetRegistersFor(*device);
}
void PowerOn();
void PowerOff();
public:
PwmDriverImpl(dd::PhysicalAddress paddr, size_t sz, const ChannelDefinition *c, size_t nsc);
virtual void InitializeDriver() override;
virtual void FinalizeDriver() override;
virtual Result InitializeDevice(IPwmDevice *device) override;
virtual void FinalizeDevice(IPwmDevice *device) override;
virtual Result SetPeriod(IPwmDevice *device, TimeSpan period) override;
virtual Result GetPeriod(TimeSpan *out, IPwmDevice *device) override;
virtual Result SetDuty(IPwmDevice *device, int duty) override;
virtual Result GetDuty(int *out, IPwmDevice *device) override;
virtual Result SetScale(IPwmDevice *device, double scale) override;
virtual Result GetScale(double *out, IPwmDevice *device) override;
virtual Result SetEnabled(IPwmDevice *device, bool en) override;
virtual Result GetEnabled(bool *out, IPwmDevice *device) override;
virtual Result Suspend() override;
virtual void Resume() override;
};
}
| 3,534
|
C++
|
.h
| 70
| 41.471429
| 125
| 0.663381
|
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,325
|
pwm_server_manager_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pwm/server/pwm_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 "pwm_server_channel_session_impl.hpp"
namespace ams::pwm::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<pwm::sf::IChannelSession>> out, int channel);
Result OpenSession(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name);
Result OpenSession2(ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, DeviceCode device_code);
};
static_assert(pwm::sf::IsIManager<ManagerImpl>);
}
| 1,618
|
C++
|
.h
| 38
| 36.473684
| 130
| 0.682107
|
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,326
|
pwm_server_channel_session_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pwm/server/pwm_server_channel_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::pwm::server {
class ManagerImpl;
class ChannelSessionImpl {
private:
ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */
pwm::driver::ChannelSession m_internal_session;
bool m_has_session;
public:
explicit ChannelSessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ }
~ChannelSessionImpl() {
if (m_has_session) {
pwm::driver::CloseSession(m_internal_session);
}
}
Result OpenSession(DeviceCode device_code) {
AMS_ABORT_UNLESS(!m_has_session);
R_TRY(pwm::driver::OpenSession(std::addressof(m_internal_session), device_code));
m_has_session = true;
R_SUCCEED();
}
public:
/* Actual commands. */
Result SetPeriod(TimeSpanType period) {
pwm::driver::SetPeriod(m_internal_session, period);
R_SUCCEED();
}
Result GetPeriod(ams::sf::Out<TimeSpanType> out) {
out.SetValue(pwm::driver::GetPeriod(m_internal_session));
R_SUCCEED();
}
Result SetDuty(int duty) {
pwm::driver::SetDuty(m_internal_session, duty);
R_SUCCEED();
}
Result GetDuty(ams::sf::Out<int> out) {
out.SetValue(pwm::driver::GetDuty(m_internal_session));
R_SUCCEED();
}
Result SetEnabled(bool enabled) {
pwm::driver::SetEnabled(m_internal_session, enabled);
R_SUCCEED();
}
Result GetEnabled(ams::sf::Out<bool> out) {
out.SetValue(pwm::driver::GetEnabled(m_internal_session));
R_SUCCEED();
}
Result SetScale(double scale) {
pwm::driver::SetScale(m_internal_session, scale);
R_SUCCEED();
}
Result GetScale(ams::sf::Out<double> out) {
out.SetValue(pwm::driver::GetScale(m_internal_session));
R_SUCCEED();
}
};
static_assert(pwm::sf::IsIChannelSession<ChannelSessionImpl>);
}
| 3,001
|
C++
|
.h
| 74
| 29.554054
| 105
| 0.572262
|
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,327
|
sm_ams.os.horizon.h
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sm/sm_ams.os.horizon.h
|
/**
* @file sm_ams.h
* @brief Service manager (sm) IPC wrapper for Atmosphere extensions.
* @author SciresM
* @copyright libnx Authors
*/
#pragma once
#if defined(ATMOSPHERE_OS_HORIZON)
#include <switch.h>
#ifdef __cplusplus
extern "C" {
#endif
Result smAtmosphereHasService(bool *out, SmServiceName name);
Result smAtmosphereWaitService(SmServiceName name);
Result smAtmosphereHasMitm(bool *out, SmServiceName name);
Result smAtmosphereWaitMitm(SmServiceName name);
Result smAtmosphereMitmInitialize(void);
void smAtmosphereMitmExit(void);
TipcService *smAtmosphereMitmGetServiceSession();
Result smAtmosphereOpenSession(TipcService *out);
void smAtmosphereCloseSession(TipcService *srv);
Result smAtmosphereMitmInstall(TipcService *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name);
Result smAtmosphereMitmUninstall(SmServiceName name);
Result smAtmosphereMitmDeclareFuture(SmServiceName name);
Result smAtmosphereMitmClearFuture(SmServiceName name);
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *info_out, SmServiceName name);
#ifdef __cplusplus
}
#endif
#endif
| 1,116
|
C++
|
.h
| 30
| 35.766667
| 112
| 0.840445
|
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,328
|
sm_utils.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sm/sm_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>
#if defined(ATMOSPHERE_OS_HORIZON)
#include "sm_ams.os.horizon.h"
#endif
namespace ams::sm::impl {
#if defined(ATMOSPHERE_OS_HORIZON)
/* Utilities. */
os::SdkRecursiveMutex &GetMitmAcknowledgementSessionMutex();
os::SdkRecursiveMutex &GetPerThreadSessionMutex();
template<typename F>
Result DoWithMitmAcknowledgementSession(F f) {
std::scoped_lock lk(GetMitmAcknowledgementSessionMutex());
{
R_ABORT_UNLESS(smAtmosphereMitmInitialize());
ON_SCOPE_EXIT { smAtmosphereMitmExit(); };
R_RETURN(f());
}
}
template<typename F>
Result DoWithPerThreadSession(F f) {
TipcService srv;
{
std::scoped_lock lk(GetPerThreadSessionMutex());
R_ABORT_UNLESS(smAtmosphereOpenSession(std::addressof(srv)));
}
{
ON_SCOPE_EXIT { smAtmosphereCloseSession(std::addressof(srv)); };
R_RETURN(f(std::addressof(srv)));
}
}
constexpr ALWAYS_INLINE SmServiceName ConvertName(sm::ServiceName name) {
static_assert(sizeof(SmServiceName) == sizeof(sm::ServiceName));
return std::bit_cast<SmServiceName>(name);
}
#endif
}
| 1,890
|
C++
|
.h
| 52
| 30.75
| 77
| 0.690541
|
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,329
|
smm_ams.os.horizon.h
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sm/smm_ams.os.horizon.h
|
/**
* @file smm_ams.h
* @brief Service manager manager (sm:m) IPC wrapper for Atmosphere extensions.
* @author SciresM
* @copyright libnx Authors
*/
#pragma once
#if defined(ATMOSPHERE_OS_HORIZON)
#include <switch.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u64 keys_held;
u64 flags;
} CfgOverrideStatus;
Result smManagerAtmosphereEndInitialDefers(void);
Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideStatus *status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size);
Result smManagerAtmosphereHasMitm(bool *out, SmServiceName name);
#ifdef __cplusplus
}
#endif
#endif
| 670
|
C++
|
.h
| 23
| 27.304348
| 179
| 0.781591
|
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,330
|
updater_paths.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/updater/updater_paths.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::updater {
/* Path functionality. */
const char *GetMountName();
const char *GetBctPath(BootImageUpdateType boot_image_update_type);
const char *GetPackage1Path(BootImageUpdateType boot_image_update_type);
const char *GetPackage2Path(BootImageUpdateType boot_image_update_type);
}
| 994
|
C++
|
.h
| 24
| 38.875
| 76
| 0.764219
|
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,331
|
updater_files.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/updater/updater_files.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::updater {
/* File helpers. */
Result ReadFile(size_t *out_size, void *dst, size_t dst_size, const char *path);
Result GetFileHash(size_t *out_size, void *dst_hash, const char *path, void *work_buffer, size_t work_buffer_size);
}
| 935
|
C++
|
.h
| 22
| 40.181818
| 119
| 0.741758
|
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,332
|
updater_bis_management.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/updater/updater_bis_management.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::updater {
class BisAccessor {
NON_COPYABLE(BisAccessor);
public:
static constexpr size_t SectorAlignment = 0x200;
private:
std::unique_ptr<fs::IStorage> m_storage;
const fs::BisPartitionId m_partition_id;
public:
explicit BisAccessor(fs::BisPartitionId id) : m_partition_id(id) { /* ... */ }
public:
Result Initialize();
void Finalize();
protected:
Result Read(void *dst, size_t size, u64 offset);
Result Write(u64 offset, const void *src, size_t size);
Result Write(u64 offset, size_t size, const char *bip_path, void *work_buffer, size_t work_buffer_size);
Result Clear(u64 offset, u64 size, void *work_buffer, size_t work_buffer_size);
Result GetHash(void *dst, u64 offset, u64 size, u64 hash_size, void *work_buffer, size_t work_buffer_size);
};
template<typename EnumType>
struct OffsetSizeEntry {
EnumType which;
u64 offset;
size_t size;
};
enum class Boot0Partition {
BctNormalMain,
BctSafeMain,
BctNormalSub,
BctSafeSub,
BctSave,
Package1NormalMain,
Package1NormalSub,
Eks,
Count,
};
enum class Boot1Partition {
Package1SafeMain,
Package1SafeSub,
Package1RepairMain,
Package1RepairSub,
Count,
};
enum class Package2Partition {
BootConfig,
Package2,
Count,
};
struct Boot0Meta {
using EnumType = Boot0Partition;
using OffsetSizeType = OffsetSizeEntry<EnumType>;
static constexpr size_t NumEntries = static_cast<size_t>(EnumType::Count);
static constexpr OffsetSizeType Entries[NumEntries] = {
{Boot0Partition::BctNormalMain, 0 * BctSize, BctSize},
{Boot0Partition::BctSafeMain, 1 * BctSize, BctSize},
{Boot0Partition::BctNormalSub, 2 * BctSize, BctSize},
{Boot0Partition::BctSafeSub, 3 * BctSize, BctSize},
{Boot0Partition::BctSave, 63 * BctSize, BctSize},
{Boot0Partition::Package1NormalMain, 0x100000, 0x40000},
{Boot0Partition::Package1NormalSub, 0x140000, 0x40000},
{Boot0Partition::Eks, 0x180000, EksSize},
};
};
struct Boot1Meta {
using EnumType = Boot1Partition;
using OffsetSizeType = OffsetSizeEntry<EnumType>;
static constexpr size_t NumEntries = static_cast<size_t>(EnumType::Count);
static constexpr OffsetSizeType Entries[NumEntries] = {
{Boot1Partition::Package1SafeMain, 0x00000, 0x40000},
{Boot1Partition::Package1SafeSub, 0x40000, 0x40000},
{Boot1Partition::Package1RepairMain, 0x80000, 0x40000},
{Boot1Partition::Package1RepairSub, 0xC0000, 0x40000},
};
};
struct Package2Meta {
using EnumType = Package2Partition;
using OffsetSizeType = OffsetSizeEntry<EnumType>;
static constexpr size_t NumEntries = static_cast<size_t>(EnumType::Count);
static constexpr OffsetSizeType Entries[NumEntries] = {
{Package2Partition::BootConfig, 0x0000, 0x004000},
{Package2Partition::Package2, 0x4000, 0x7FC000},
};
};
template<typename Meta>
class PartitionAccessor : public BisAccessor {
NON_COPYABLE(PartitionAccessor);
public:
using EnumType = typename Meta::EnumType;
using OffsetSizeType = typename Meta::OffsetSizeType;
public:
explicit PartitionAccessor(fs::BisPartitionId id) : BisAccessor(id) { /* ... */ }
private:
constexpr const OffsetSizeType *FindEntry(EnumType which) {
const OffsetSizeType *entry = nullptr;
for (size_t i = 0; i < Meta::NumEntries; i++) {
if (Meta::Entries[i].which == which) {
entry = std::addressof(Meta::Entries[i]);
break;
}
}
AMS_ABORT_UNLESS(entry != nullptr);
return entry;
}
public:
Result Read(size_t *out_size, void *dst, size_t size, EnumType which) {
const auto entry = FindEntry(which);
AMS_ABORT_UNLESS(size >= entry->size);
ON_RESULT_SUCCESS { *out_size = entry->size; };
R_RETURN(BisAccessor::Read(dst, entry->size, entry->offset));
}
Result Write(const void *src, size_t size, EnumType which) {
const auto entry = FindEntry(which);
AMS_ABORT_UNLESS(size <= entry->size);
AMS_ABORT_UNLESS((size % BisAccessor::SectorAlignment) == 0);
R_RETURN(BisAccessor::Write(entry->offset, src, size));
}
Result Write(const char *bip_path, void *work_buffer, size_t work_buffer_size, EnumType which) {
const auto entry = FindEntry(which);
R_RETURN(BisAccessor::Write(entry->offset, entry->size, bip_path, work_buffer, work_buffer_size));
}
Result Clear(void *work_buffer, size_t work_buffer_size, EnumType which) {
const auto entry = FindEntry(which);
R_RETURN(BisAccessor::Clear(entry->offset, entry->size, work_buffer, work_buffer_size));
}
Result GetHash(void *dst, u64 hash_size, void *work_buffer, size_t work_buffer_size, EnumType which) {
const auto entry = FindEntry(which);
R_RETURN(BisAccessor::GetHash(dst, entry->offset, entry->size, hash_size, work_buffer, work_buffer_size));
}
};
enum class Package2Type {
NormalMain,
NormalSub,
SafeMain,
SafeSub,
RepairMain,
RepairSub,
};
static constexpr fs::BisPartitionId GetPackage2StorageId(Package2Type which) {
switch (which) {
case Package2Type::NormalMain:
return fs::BisPartitionId::BootConfigAndPackage2Part1;
case Package2Type::NormalSub:
return fs::BisPartitionId::BootConfigAndPackage2Part2;
case Package2Type::SafeMain:
return fs::BisPartitionId::BootConfigAndPackage2Part3;
case Package2Type::SafeSub:
return fs::BisPartitionId::BootConfigAndPackage2Part4;
case Package2Type::RepairMain:
return fs::BisPartitionId::BootConfigAndPackage2Part5;
case Package2Type::RepairSub:
return fs::BisPartitionId::BootConfigAndPackage2Part6;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
class Boot0Accessor : public PartitionAccessor<Boot0Meta> {
public:
static constexpr fs::BisPartitionId PartitionId = fs::BisPartitionId::BootPartition1Root;
static constexpr size_t BctPubkOffsetErista = 0x210;
static constexpr size_t BctPubkOffsetMariko = 0x10;
static constexpr size_t BctPubkSize = 0x100;
static constexpr size_t BctEksOffset = 0x450;
static constexpr size_t BctVersionOffset = 0x2330;
static constexpr size_t BctVersionMax = 0x20;
public:
Boot0Accessor() : PartitionAccessor<Boot0Meta>(PartitionId) { }
private:
static size_t GetBootloaderVersion(void *bct);
static size_t GetEksIndex(size_t bootloader_version);
static void CopyEks(void *dst_bct, const void *src_eks, size_t eks_index);
static size_t GetBctPubkOffset(BootImageUpdateType boot_image_update_type) {
switch (boot_image_update_type) {
case BootImageUpdateType::Erista:
return BctPubkOffsetErista;
case BootImageUpdateType::Mariko:
return BctPubkOffsetMariko;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
public:
Result UpdateEks(void *dst_bct, void *eks_work_buffer);
Result UpdateEksManually(void *dst_bct, const void *src_eks);
Result PreserveAutoRcm(void *dst_bct, void *work_buffer, Boot0Partition which);
Result DetectCustomPublicKey(bool *out, void *work_buffer, BootImageUpdateType boot_image_update_type);
};
class Boot1Accessor : public PartitionAccessor<Boot1Meta> {
public:
static constexpr fs::BisPartitionId PartitionId = fs::BisPartitionId::BootPartition2Root;
public:
Boot1Accessor() : PartitionAccessor<Boot1Meta>(PartitionId) { }
};
class Package2Accessor : public PartitionAccessor<Package2Meta> {
public:
Package2Accessor(Package2Type which) : PartitionAccessor<Package2Meta>(GetPackage2StorageId(which)) { }
};
}
| 9,713
|
C++
|
.h
| 213
| 34.816901
| 122
| 0.620697
|
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,333
|
updater_bis_save.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/updater/updater_bis_save.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 "updater_bis_management.hpp"
namespace ams::updater {
class BisSave {
public:
static constexpr size_t SaveSize = BctSize;
private:
Boot0Accessor m_accessor;
void *m_save_buffer;
public:
BisSave() : m_accessor(), m_save_buffer(nullptr) { }
private:
static size_t GetVerificationFlagOffset(BootModeType mode);
public:
Result Initialize(void *work_buffer, size_t work_buffer_size);
void Finalize();
Result Load();
Result Save();
bool GetNeedsVerification(BootModeType mode);
void SetNeedsVerification(BootModeType mode, bool needs_verification);
};
}
| 1,390
|
C++
|
.h
| 37
| 31.189189
| 82
| 0.676558
|
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,334
|
sprofile_srv_profile_controller_for_debug_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_controller_for_debug_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 "sprofile_srv_i_profile_controller_for_debug.hpp"
namespace ams::sprofile::srv {
class ProfileManager;
class ProfileControllerForDebugImpl {
private:
ProfileManager *m_manager;
public:
ProfileControllerForDebugImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ }
public:
Result Reset();
Result GetRaw(sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::Identifier profile, sprofile::Identifier key);
};
static_assert(IsIProfileControllerForDebug<ProfileControllerForDebugImpl>);
}
| 1,274
|
C++
|
.h
| 31
| 36.677419
| 128
| 0.724778
|
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,335
|
sprofile_srv_profile_importer_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer_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 "sprofile_srv_i_profile_importer.hpp"
namespace ams::sprofile::srv {
class ProfileManager;
class ProfileImporterImpl {
private:
ProfileManager *m_manager;
public:
ProfileImporterImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ }
~ProfileImporterImpl() {
m_manager->CloseProfileImporter();
}
public:
Result ImportProfile(const sprofile::srv::ProfileDataForImportData &import);
Result Commit();
Result ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &import);
};
static_assert(IsIProfileImporter<ProfileImporterImpl>);
}
| 1,384
|
C++
|
.h
| 35
| 34
| 97
| 0.704613
|
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,336
|
sprofile_srv_i_profile_reader.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_profile_reader.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_SPROFILE_I_PROFILE_READER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetSigned64, (sf::Out<s64> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetUnsigned64, (sf::Out<u64> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetSigned32, (sf::Out<s32> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetUnsigned32, (sf::Out<u32> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetByte, (sf::Out<u8> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key))
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileReader, AMS_SPROFILE_I_PROFILE_READER_INTERFACE_INFO, 0x97090D4D)
| 1,625
|
C++
|
.h
| 24
| 65.208333
| 153
| 0.729831
|
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,337
|
sprofile_srv_i_service_for_bg_agent.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_service_for_bg_agent.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 "sprofile_srv_i_profile_importer.hpp"
#define AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_BG_AGENT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 100, Result, OpenProfileImporter, (sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileImporter>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 200, Result, GetImportableProfileUrls, (sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::ProfileMetadataForImportMetadata &arg), (out_count, out, arg)) \
AMS_SF_METHOD_INFO(C, H, 201, Result, IsUpdateNeeded, (sf::Out<bool> out, sprofile::Identifier revision_key), (out, revision_key)) \
AMS_SF_METHOD_INFO(C, H, 2000, Result, Reset, (), ())
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, ISprofileServiceForBgAgent, AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_BG_AGENT_INTERFACE_INFO, 0xCCD828EC)
| 2,009
|
C++
|
.h
| 24
| 81.375
| 231
| 0.561775
|
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,338
|
sprofile_srv_i_profile_importer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_profile_importer.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 "sprofile_srv_types.hpp"
#define AMS_SPROFILE_I_PROFILE_IMPORTER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ImportProfile, (const sprofile::srv::ProfileDataForImportData &import), (import)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Commit, (), ()) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ImportMetadata, (const sprofile::srv::ProfileMetadataForImportMetadata &import), (import)) \
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileImporter, AMS_SPROFILE_I_PROFILE_IMPORTER_INTERFACE_INFO, 0x1629C4E6)
| 1,294
|
C++
|
.h
| 23
| 54.043478
| 132
| 0.702916
|
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,339
|
sprofile_srv_fs_utils.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_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::sprofile::srv {
Result ReadFile(const char *path, void *dst, size_t size, s64 offset);
Result WriteFile(const char *path, const void *src, size_t size);
Result MoveFile(const char *src_path, const char *dst_path);
Result DeleteFile(const char *path);
Result EnsureDirectory(const char *path);
}
| 1,009
|
C++
|
.h
| 24
| 39.5
| 76
| 0.747454
|
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,340
|
sprofile_srv_service_getter.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_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 "sprofile_srv_i_service_getter.hpp"
namespace ams::sprofile::srv {
class ServiceGetter {
private:
sf::SharedPointer<::ams::sprofile::srv::ISprofileServiceForBgAgent> m_service_for_bg_agent;
sf::SharedPointer<::ams::sprofile::srv::ISprofileServiceForSystemProcess> m_service_for_system_process;
public:
constexpr ServiceGetter(sf::SharedPointer<::ams::sprofile::srv::ISprofileServiceForBgAgent> bg, sf::SharedPointer<::ams::sprofile::srv::ISprofileServiceForSystemProcess> sp) : m_service_for_bg_agent(bg), m_service_for_system_process(sp) { /* ... */ }
public:
Result GetServiceForSystemProcess(sf::Out<sf::SharedPointer<sprofile::srv::ISprofileServiceForSystemProcess>> out);
Result GetServiceForBgAgent(sf::Out<sf::SharedPointer<sprofile::srv::ISprofileServiceForBgAgent>> out);
};
static_assert(sprofile::srv::IsIServiceGetter<ServiceGetter>);
}
| 1,633
|
C++
|
.h
| 31
| 48.032258
| 262
| 0.73671
|
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,341
|
sprofile_srv_i_service_for_system_process.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_service_for_system_process.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 "sprofile_srv_i_profile_reader.hpp"
#include "sprofile_srv_i_profile_update_observer.hpp"
#include "sprofile_srv_i_profile_controller_for_debug.hpp"
#define AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_SYSTEM_PROCESS_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 100, Result, OpenProfileReader, (sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileReader>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 101, Result, OpenProfileUpdateObserver, (sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileUpdateObserver>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 900, Result, OpenProfileControllerForDebug, (sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileControllerForDebug>> out), (out))
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, ISprofileServiceForSystemProcess, AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_SYSTEM_PROCESS_INTERFACE_INFO, 0x919612FB)
| 1,574
|
C++
|
.h
| 25
| 60.84
| 166
| 0.745314
|
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,342
|
sprofile_srv_profile_reader_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_reader_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 "sprofile_srv_i_profile_reader.hpp"
namespace ams::sprofile::srv {
class ProfileManager;
class ProfileReaderImpl {
private:
ProfileManager *m_manager;
public:
ProfileReaderImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ }
public:
Result GetSigned64(sf::Out<s64> out, sprofile::Identifier profile, sprofile::Identifier key);
Result GetUnsigned64(sf::Out<u64> out, sprofile::Identifier profile, sprofile::Identifier key);
Result GetSigned32(sf::Out<s32> out, sprofile::Identifier profile, sprofile::Identifier key);
Result GetUnsigned32(sf::Out<u32> out, sprofile::Identifier profile, sprofile::Identifier key);
Result GetByte(sf::Out<u8> out, sprofile::Identifier profile, sprofile::Identifier key);
};
static_assert(IsIProfileReader<ProfileReaderImpl>);
}
| 1,584
|
C++
|
.h
| 34
| 41.411765
| 107
| 0.716688
|
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,343
|
sprofile_srv_profile_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_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 "sprofile_srv_types.hpp"
#include "sprofile_srv_profile_update_observer_impl.hpp"
#include "sprofile_srv_profile_importer.hpp"
namespace ams::sprofile::srv {
class ProfileManager {
public:
struct SaveDataInfo {
u64 id;
const char *mount_name;
size_t size;
size_t journal_size;
u32 flags;
};
private:
private:
os::SdkMutex m_general_mutex{};
os::SdkMutex m_fs_mutex{};
SaveDataInfo m_save_data_info;
bool m_save_file_mounted;
util::optional<ProfileImporter> m_profile_importer;
os::SdkMutex m_profile_importer_mutex{};
util::optional<ProfileMetadata> m_profile_metadata;
os::SdkMutex m_profile_metadata_mutex{};
util::optional<ServiceProfile> m_service_profile;
os::SdkMutex m_service_profile_mutex{};
ProfileUpdateObserverManager m_update_observer_manager;
public:
ProfileManager(const SaveDataInfo &save_data_info);
public:
void InitializeSaveData();
Result ResetSaveData();
Result OpenProfileImporter();
void CloseProfileImporter();
Result ImportProfile(const sprofile::srv::ProfileDataForImportData &data);
Result Commit();
Result ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &data);
Result LoadPrimaryMetadata(ProfileMetadata *out);
Result GetSigned64(s64 *out, Identifier profile, Identifier key);
Result GetUnsigned64(u64 *out, Identifier profile, Identifier key);
Result GetSigned32(s32 *out, Identifier profile, Identifier key);
Result GetUnsigned32(u32 *out, Identifier profile, Identifier key);
Result GetByte(u8 *out, Identifier profile, Identifier key);
Result GetRaw(u8 *out_type, u64 *out_value, Identifier profile, Identifier key);
ProfileUpdateObserverManager &GetUpdateObserverManager() { return m_update_observer_manager; }
private:
Result CommitImportedProfiles();
Result CleanupOrphanedProfiles();
Result LoadPrimaryMetadataImpl();
void CloseProfileImporterImpl();
void OnCommitted();
Result GetDataEntry(ProfileDataEntry *out, Identifier profile, Identifier key);
Result LoadProfile(Identifier profile);
Result EnsurePrimaryDirectories();
Result EnsureTemporaryDirectories();
};
}
| 3,317
|
C++
|
.h
| 73
| 35.945205
| 106
| 0.662539
|
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,344
|
sprofile_srv_i_service_getter.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_service_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 "sprofile_srv_i_service_for_system_process.hpp"
#include "sprofile_srv_i_service_for_bg_agent.hpp"
#define AMS_SPROFILE_I_SERVICE_GETTER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetServiceForSystemProcess, (sf::Out<sf::SharedPointer<sprofile::srv::ISprofileServiceForSystemProcess>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetServiceForBgAgent, (sf::Out<sf::SharedPointer<sprofile::srv::ISprofileServiceForBgAgent>> out), (out))
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IServiceGetter, AMS_SPROFILE_I_SERVICE_GETTER_INTERFACE_INFO, 0x2CFB8417)
| 1,375
|
C++
|
.h
| 23
| 57.782609
| 159
| 0.705403
|
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,345
|
sprofile_srv_service_for_system_process.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_system_process.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 "sprofile_srv_i_service_for_system_process.hpp"
namespace ams::sprofile::srv {
class ProfileManager;
class ServiceForSystemProcess {
private:
MemoryResource *m_memory_resource;
ProfileManager *m_profile_manager;
public:
constexpr ServiceForSystemProcess(MemoryResource *mr, ProfileManager *pm) : m_memory_resource(mr), m_profile_manager(pm) { /* ... */ }
public:
Result OpenProfileReader(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileReader>> out);
Result OpenProfileUpdateObserver(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileUpdateObserver>> out);
Result OpenProfileControllerForDebug(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileControllerForDebug>> out);
};
static_assert(sprofile::srv::IsISprofileServiceForSystemProcess<ServiceForSystemProcess>);
}
| 1,588
|
C++
|
.h
| 33
| 43.181818
| 146
| 0.730496
|
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,346
|
sprofile_srv_profile_importer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_importer.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 "sprofile_srv_types.hpp"
namespace ams::sprofile::srv {
class ProfileImporter {
private:
struct ImportingProfile {
Identifier identifier_0;
Identifier identifier_1;
bool is_new_import;
};
private:
bool m_committed;
bool m_imported_metadata;
int m_importing_count;
util::optional<ProfileMetadata> m_metadata;
ImportingProfile m_importing_profiles[50];
util::BitFlagSet<50> m_is_profile_importable;
Identifier m_revision_key;
public:
ProfileImporter(const util::optional<ProfileMetadata> &meta) : m_committed(false), m_imported_metadata(false), m_importing_count(0), m_metadata(util::nullopt), m_is_profile_importable(), m_revision_key() {
if (meta.has_value()) {
m_metadata = *meta;
}
}
public:
bool HasProfile(Identifier id0, Identifier id1) {
/* Require that we have metadata. */
if (m_metadata.has_value()) {
for (auto i = 0u; i < std::min<size_t>(m_metadata->num_entries, util::size(m_metadata->entries)); ++i) {
const auto &entry = m_metadata->entries[i];
if (entry.identifier_0 == id0 && entry.identifier_1 == id1) {
return true;
}
}
}
/* We don't have the desired profile. */
return false;
}
bool CanImportMetadata() {
/* We can only import metadata if we haven't already imported metadata. */
return !m_imported_metadata;
}
void ImportMetadata(const ProfileMetadata &meta) {
/* Set that we've imported metadata. */
m_imported_metadata = true;
/* Import the service revision key. */
m_revision_key = meta.revision_key;
/* Set importing count. */
m_importing_count = static_cast<int>(std::min<size_t>(meta.num_entries, util::size(meta.entries)));
/* Set all profiles as importable. */
for (auto i = 0; i < m_importing_count; ++i) {
m_is_profile_importable[i] = true;
}
/* Determine import status for all profiles. */
for (auto i = 0; i < m_importing_count; ++i) {
const auto &import_entry = meta.entries[i];
const bool is_new_import = !this->HasProfile(import_entry.identifier_0, import_entry.identifier_1);
m_importing_profiles[i] = {
.identifier_0 = import_entry.identifier_0,
.identifier_1 = import_entry.identifier_1,
.is_new_import = is_new_import,
};
m_is_profile_importable[i] = is_new_import;
}
}
bool CanImportProfile(Identifier profile) {
/* Require that we imported metadata. */
if (m_imported_metadata) {
/* Find the specified profile. */
for (auto i = 0; i < m_importing_count; ++i) {
if (m_importing_profiles[i].identifier_0 == profile) {
/* Require the profile be importable. */
return m_is_profile_importable[i];
}
}
}
/* We can't import the desired profile. */
return false;
}
void OnImportProfile(Identifier profile) {
/* Set the profile as not importable (as it's imported). */
for (auto i = 0; i < m_importing_count; ++i) {
if (m_importing_profiles[i].identifier_0 == profile) {
m_is_profile_importable[i] = false;
break;
}
}
}
bool CanCommit() {
/* We can't commit if we've already committed. */
if (m_committed) {
return false;
}
/* We need metadata in order to commit. */
if (!m_imported_metadata) {
return false;
}
/* We need to have imported everything we intended to import. */
return m_is_profile_importable.IsAllOff();
}
int GetImportingCount() const { return m_importing_count; }
const ImportingProfile &GetImportingProfile(int i) const { return m_importing_profiles[i]; }
Identifier GetRevisionKey() const { return m_revision_key; }
Result CleanupOrphanedProfiles(auto cleanup_impl) const {
/* Cleanup any orphaned profiles in our metadata. */
if (m_metadata.has_value()) {
for (auto i = 0u; i < std::min<size_t>(m_metadata->num_entries, util::size(m_metadata->entries)); ++i) {
const auto &entry = m_metadata->entries[i];
if (!this->IsImportingProfile(entry.identifier_0)) {
R_TRY(cleanup_impl(entry.identifier_0));
}
}
}
R_SUCCEED();
}
private:
bool IsImportingProfile(Identifier profile) const {
/* Check if we're importing the desired profile. */
for (auto i = 0; i < m_importing_count; ++i) {
if (m_importing_profiles[i].identifier_0 == profile) {
return true;
}
}
/* We're not importing the desired profile. */
return false;
}
};
}
| 6,723
|
C++
|
.h
| 144
| 31.263889
| 217
| 0.509457
|
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,347
|
sprofile_srv_i_profile_update_observer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_profile_update_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>
#define AMS_SPROFILE_I_PROFILE_UPDATE_OBSERVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Listen, (sprofile::Identifier profile), (profile)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Unlisten, (sprofile::Identifier profile), (profile)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetEventHandle, (ams::sf::OutCopyHandle out), (out))
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileUpdateObserver, AMS_SPROFILE_I_PROFILE_UPDATE_OBSERVER_INTERFACE_INFO, 0xB52A765C)
| 1,180
|
C++
|
.h
| 22
| 51.363636
| 134
| 0.739619
|
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,348
|
sprofile_srv_profile_update_observer_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_update_observer_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 "sprofile_srv_i_profile_update_observer.hpp"
namespace ams::sprofile::srv {
class ProfileUpdateObserverImpl {
public:
static constexpr auto MaxProfiles = 4;
private:
os::SystemEvent m_event;
Identifier m_profiles[MaxProfiles];
int m_profile_count;
os::SdkMutex m_mutex;
public:
ProfileUpdateObserverImpl() : m_event(os::EventClearMode_ManualClear, true), m_profile_count(0), m_mutex() { /* ... */ }
virtual ~ProfileUpdateObserverImpl() { /* ... */ }
public:
os::SystemEvent &GetEvent() { return m_event; }
const os::SystemEvent &GetEvent() const { return m_event; }
public:
Result Listen(Identifier profile) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Check if we can listen. */
R_UNLESS(m_profile_count < MaxProfiles, sprofile::ResultMaxListeners());
/* Check if we're already listening. */
for (auto i = 0; i < m_profile_count; ++i) {
R_UNLESS(m_profiles[i] != profile, sprofile::ResultAlreadyListening());
}
/* Add the profile. */
m_profiles[m_profile_count++] = profile;
R_SUCCEED();
}
Result Unlisten(Identifier profile) {
/* Check that we're listening. */
for (auto i = 0; i < m_profile_count; ++i) {
if (m_profiles[i] == profile) {
m_profiles[i] = m_profiles[--m_profile_count];
AMS_ABORT_UNLESS(m_profile_count >= 0);
R_SUCCEED();
}
}
R_THROW(sprofile::ResultNotListening());
}
Result GetEventHandle(sf::OutCopyHandle out) {
out.SetValue(m_event.GetReadableHandle(), false);
R_SUCCEED();
}
public:
void OnUpdate(Identifier profile) {
for (auto i = 0; i < m_profile_count; ++i) {
if (m_profiles[i] == profile) {
m_event.Signal();
break;
}
}
}
};
static_assert(sprofile::srv::IsIProfileUpdateObserver<ProfileUpdateObserverImpl>);
class ProfileUpdateObserverManager {
public:
static constexpr auto MaxObservers = 10;
private:
ProfileUpdateObserverImpl *m_observers[MaxObservers];
int m_observer_count;
os::SdkMutex m_mutex;
public:
ProfileUpdateObserverManager() : m_observer_count(0), m_mutex() { /* ... */ }
public:
Result OpenObserver(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileUpdateObserver>> &out, MemoryResource *memory_resource);
void CloseObserver(ProfileUpdateObserverImpl *observer);
void OnUpdate(Identifier profile) {
std::scoped_lock lk(m_mutex);
for (auto i = 0; i < m_observer_count; ++i) {
m_observers[i]->OnUpdate(profile);
}
}
};
}
| 3,967
|
C++
|
.h
| 93
| 30.752688
| 144
| 0.55593
|
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,349
|
sprofile_srv_i_profile_controller_for_debug.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_i_profile_controller_for_debug.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_SPROFILE_I_PROFILE_CONTROLLER_FOR_DEBUG_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 2000, Result, Reset, (), ()) \
AMS_SF_METHOD_INFO(C, H, 2001, Result, GetRaw, (sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::Identifier profile, sprofile::Identifier key), (out_type, out_value, profile, key))
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileControllerForDebug, AMS_SPROFILE_I_PROFILE_CONTROLLER_FOR_DEBUG_INTERFACE_INFO, 0xA8C14F64)
| 1,283
|
C++
|
.h
| 21
| 58.904762
| 192
| 0.671168
|
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,350
|
sprofile_srv_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_types.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::sprofile::srv {
constexpr inline const u32 ProfileFormatVersion = 1;
constexpr inline bool IsValidProfileFormatVersion(u32 version) {
return version == ProfileFormatVersion;
}
enum ValueType : u8 {
ValueType_Byte = 0,
ValueType_U32 = 1,
ValueType_S32 = 2,
ValueType_U64 = 3,
ValueType_S64 = 4,
};
struct ProfileDataEntry {
Identifier key;
ValueType type;
union {
s64 value_s64;
u64 value_u64;
s32 value_s32;
u32 value_u32;
u8 value_u8;
};
};
static_assert(util::is_pod<ProfileDataEntry>::value);
static_assert(sizeof(ProfileDataEntry) == 0x10);
static_assert(AMS_OFFSETOF(ProfileDataEntry, key) == 0x00);
static_assert(AMS_OFFSETOF(ProfileDataEntry, type) == 0x07);
static_assert(AMS_OFFSETOF(ProfileDataEntry, value_s64) == 0x08);
struct ProfileData {
u32 num_entries;
u8 unk_04[0x0C];
u8 unk_10[0x20];
ProfileDataEntry entries[(0x4000 - 0x30) / sizeof(ProfileDataEntry)];
};
static_assert(util::is_pod<ProfileData>::value);
static_assert(sizeof(ProfileData) == 0x4000);
static_assert(AMS_OFFSETOF(ProfileData, num_entries) == 0x00);
static_assert(AMS_OFFSETOF(ProfileData, unk_04) == 0x04);
static_assert(AMS_OFFSETOF(ProfileData, unk_10) == 0x10);
static_assert(AMS_OFFSETOF(ProfileData, entries) == 0x30);
struct ServiceProfile {
Identifier name;
ProfileData data;
};
static_assert(util::is_pod<ServiceProfile>::value);
static_assert(sizeof(ServiceProfile) == 0x4008);
static_assert(AMS_OFFSETOF(ServiceProfile, name) == 0x00);
static_assert(AMS_OFFSETOF(ServiceProfile, data) == 0x08);
struct ProfileDataForImportData : public sf::LargeData, public sf::PrefersMapAliasTransferMode {
struct {
Identifier identifier_0;
Identifier identifier_1;
u8 unk_0E[2];
u32 version;
u8 unk_14[0x1C];
} header;
u8 hash[crypto::Md5Generator::HashSize];
ProfileData data;
u8 unk_4040[0x4400 - 0x4040];
};
static_assert(util::is_pod<ProfileDataForImportData>::value);
static_assert(sizeof(ProfileDataForImportData) == 0x4400);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, header) == 0x00);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, hash) == 0x30);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, data) == 0x40);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, unk_4040) == 0x4040);
struct ProfileMetadataEntry {
Identifier identifier_0;
Identifier identifier_1;
u8 unk_0E[0x32];
};
static_assert(util::is_pod<ProfileMetadataEntry>::value);
static_assert(sizeof(ProfileMetadataEntry) == 0x40);
static_assert(AMS_OFFSETOF(ProfileMetadataEntry, identifier_0) == 0x00);
static_assert(AMS_OFFSETOF(ProfileMetadataEntry, identifier_1) == 0x07);
static_assert(AMS_OFFSETOF(ProfileMetadataEntry, unk_0E) == 0x0E);
struct ProfileUrl : public sf::PrefersMapAliasTransferMode {
char url[0x100];
};
static_assert(util::is_pod<ProfileUrl>::value);
static_assert(sizeof(ProfileUrl) == 0x100);
struct ProfileMetadata {
u32 num_entries;
u32 unk_04;
Identifier revision_key;
u8 unk_0F[0x1];
u8 unk_10[0x30];
ProfileMetadataEntry entries[50];
};
static_assert(util::is_pod<ProfileMetadata>::value);
static_assert(sizeof(ProfileMetadata) == 0xCC0);
static_assert(AMS_OFFSETOF(ProfileMetadata, num_entries) == 0x00);
static_assert(AMS_OFFSETOF(ProfileMetadata, unk_04) == 0x04);
static_assert(AMS_OFFSETOF(ProfileMetadata, revision_key) == 0x08);
static_assert(AMS_OFFSETOF(ProfileMetadata, unk_0F) == 0x0F);
static_assert(AMS_OFFSETOF(ProfileMetadata, unk_10) == 0x10);
static_assert(AMS_OFFSETOF(ProfileMetadata, entries) == 0x40);
struct ProfileMetadataForImportMetadata : public sf::LargeData, public sf::PrefersMapAliasTransferMode {
struct {
u32 version;
u8 unk_04[0x1C];
} header;
u8 hash[crypto::Md5Generator::HashSize];
ProfileMetadata metadata;
ProfileUrl profile_urls[50];
u8 unk_3EF0[0x8000 - 0x3EF0];
};
static_assert(util::is_pod<ProfileMetadataForImportMetadata>::value);
static_assert(sizeof(ProfileMetadataForImportMetadata) == 0x8000);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, header) == 0x00);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, hash) == 0x20);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, metadata) == 0x30);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, profile_urls) == 0xCF0);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, unk_3EF0) == 0x3EF0);
}
| 5,760
|
C++
|
.h
| 132
| 37.106061
| 108
| 0.682061
|
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,351
|
sprofile_srv_service_for_bg_agent.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_service_for_bg_agent.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 "sprofile_srv_i_service_for_bg_agent.hpp"
namespace ams::sprofile::srv {
class ProfileManager;
class ServiceForBgAgent {
private:
MemoryResource *m_memory_resource;
ProfileManager *m_profile_manager;
public:
constexpr ServiceForBgAgent(MemoryResource *mr, ProfileManager *pm) : m_memory_resource(mr), m_profile_manager(pm) { /* ... */ }
public:
Result OpenProfileImporter(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileImporter>> out);
Result GetImportableProfileUrls(sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::ProfileMetadataForImportMetadata &arg);
Result IsUpdateNeeded(sf::Out<bool> out, Identifier revision_key);
Result Reset();
};
static_assert(sprofile::srv::IsISprofileServiceForBgAgent<ServiceForBgAgent>);
}
| 1,594
|
C++
|
.h
| 34
| 41.705882
| 180
| 0.719152
|
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,352
|
pinmux_select_board_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pinmux/driver/pinmux_select_board_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>
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
#include "board/nintendo/nx/pinmux_board_driver_api.hpp"
namespace ams::pinmux::driver::board {
using namespace ams::pinmux::driver::board::nintendo::nx;
}
#else
// TODO: #error "Unknown board for pinmux driver"
namespace ams::pinmux::driver::board {
inline void Initialize() {
AMS_ABORT("TODO");
}
inline void Finalize() {
AMS_ABORT("TODO");
}
inline bool IsInitialized() {
AMS_ABORT("TODO");
}
inline void SetInitialConfig() {
AMS_ABORT("TODO");
}
inline void SetInitialDrivePadConfig() {
AMS_ABORT("TODO");
}
}
#endif
| 1,422
|
C++
|
.h
| 42
| 28.166667
| 76
| 0.663258
|
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,353
|
pinmux_pad_index.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_pad_index.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/>.
*/
/* NOTE: This file is auto-generated by pinmux_character_gen.py, do not edit manually. */
#pragma once
enum PinmuxPadIndex {
PinmuxPadIndex_Sdmmc1Clk = 0,
PinmuxPadIndex_Sdmmc1Cmd = 1,
PinmuxPadIndex_Sdmmc1Dat3 = 2,
PinmuxPadIndex_Sdmmc1Dat2 = 3,
PinmuxPadIndex_Sdmmc1Dat1 = 4,
PinmuxPadIndex_Sdmmc1Dat0 = 5,
PinmuxPadIndex_Sdmmc3Clk = 6,
PinmuxPadIndex_Sdmmc3Cmd = 7,
PinmuxPadIndex_Sdmmc3Dat0 = 8,
PinmuxPadIndex_Sdmmc3Dat1 = 9,
PinmuxPadIndex_Sdmmc3Dat2 = 10,
PinmuxPadIndex_Sdmmc3Dat3 = 11,
PinmuxPadIndex_PexL0RstN = 12,
PinmuxPadIndex_PexL0ClkreqN = 13,
PinmuxPadIndex_PexWakeN = 14,
PinmuxPadIndex_PexL1RstN = 15,
PinmuxPadIndex_PexL1ClkreqN = 16,
PinmuxPadIndex_SataLedActive = 17,
PinmuxPadIndex_Spi1Mosi = 18,
PinmuxPadIndex_Spi1Miso = 19,
PinmuxPadIndex_Spi1Sck = 20,
PinmuxPadIndex_Spi1Cs0 = 21,
PinmuxPadIndex_Spi1Cs1 = 22,
PinmuxPadIndex_Spi2Mosi = 23,
PinmuxPadIndex_Spi2Miso = 24,
PinmuxPadIndex_Spi2Sck = 25,
PinmuxPadIndex_Spi2Cs0 = 26,
PinmuxPadIndex_Spi2Cs1 = 27,
PinmuxPadIndex_Spi4Mosi = 28,
PinmuxPadIndex_Spi4Miso = 29,
PinmuxPadIndex_Spi4Sck = 30,
PinmuxPadIndex_Spi4Cs0 = 31,
PinmuxPadIndex_QspiSck = 32,
PinmuxPadIndex_QspiCsN = 33,
PinmuxPadIndex_QspiIo0 = 34,
PinmuxPadIndex_QspiIo1 = 35,
PinmuxPadIndex_QspiIo2 = 36,
PinmuxPadIndex_QspiIo3 = 37,
PinmuxPadIndex_Dmic1Clk = 38,
PinmuxPadIndex_Dmic1Dat = 39,
PinmuxPadIndex_Dmic2Clk = 40,
PinmuxPadIndex_Dmic2Dat = 41,
PinmuxPadIndex_Dmic3Clk = 42,
PinmuxPadIndex_Dmic3Dat = 43,
PinmuxPadIndex_Gen1I2cScl = 44,
PinmuxPadIndex_Gen1I2cSda = 45,
PinmuxPadIndex_Gen2I2cScl = 46,
PinmuxPadIndex_Gen2I2cSda = 47,
PinmuxPadIndex_Gen3I2cScl = 48,
PinmuxPadIndex_Gen3I2cSda = 49,
PinmuxPadIndex_CamI2cScl = 50,
PinmuxPadIndex_CamI2cSda = 51,
PinmuxPadIndex_PwrI2cScl = 52,
PinmuxPadIndex_PwrI2cSda = 53,
PinmuxPadIndex_Uart1Tx = 54,
PinmuxPadIndex_Uart1Rx = 55,
PinmuxPadIndex_Uart1Rts = 56,
PinmuxPadIndex_Uart1Cts = 57,
PinmuxPadIndex_Uart2Tx = 58,
PinmuxPadIndex_Uart2Rx = 59,
PinmuxPadIndex_Uart2Rts = 60,
PinmuxPadIndex_Uart2Cts = 61,
PinmuxPadIndex_Uart3Tx = 62,
PinmuxPadIndex_Uart3Rx = 63,
PinmuxPadIndex_Uart3Rts = 64,
PinmuxPadIndex_Uart3Cts = 65,
PinmuxPadIndex_Uart4Tx = 66,
PinmuxPadIndex_Uart4Rx = 67,
PinmuxPadIndex_Uart4Rts = 68,
PinmuxPadIndex_Uart4Cts = 69,
PinmuxPadIndex_Dap1Fs = 70,
PinmuxPadIndex_Dap1Din = 71,
PinmuxPadIndex_Dap1Dout = 72,
PinmuxPadIndex_Dap1Sclk = 73,
PinmuxPadIndex_Dap2Fs = 74,
PinmuxPadIndex_Dap2Din = 75,
PinmuxPadIndex_Dap2Dout = 76,
PinmuxPadIndex_Dap2Sclk = 77,
PinmuxPadIndex_Dap4Fs = 78,
PinmuxPadIndex_Dap4Din = 79,
PinmuxPadIndex_Dap4Dout = 80,
PinmuxPadIndex_Dap4Sclk = 81,
PinmuxPadIndex_Cam1Mclk = 82,
PinmuxPadIndex_Cam2Mclk = 83,
PinmuxPadIndex_JtagRtck = 84,
PinmuxPadIndex_Clk32kIn = 85,
PinmuxPadIndex_Clk32kOut = 86,
PinmuxPadIndex_BattBcl = 87,
PinmuxPadIndex_ClkReq = 88,
PinmuxPadIndex_CpuPwrReq = 89,
PinmuxPadIndex_PwrIntN = 90,
PinmuxPadIndex_Shutdown = 91,
PinmuxPadIndex_CorePwrReq = 92,
PinmuxPadIndex_AudMclk = 93,
PinmuxPadIndex_DvfsPwm = 94,
PinmuxPadIndex_DvfsClk = 95,
PinmuxPadIndex_GpioX1Aud = 96,
PinmuxPadIndex_GpioX3Aud = 97,
PinmuxPadIndex_GpioPcc7 = 98,
PinmuxPadIndex_HdmiCec = 99,
PinmuxPadIndex_HdmiIntDpHpd = 100,
PinmuxPadIndex_SpdifOut = 101,
PinmuxPadIndex_SpdifIn = 102,
PinmuxPadIndex_UsbVbusEn0 = 103,
PinmuxPadIndex_UsbVbusEn1 = 104,
PinmuxPadIndex_DpHpd0 = 105,
PinmuxPadIndex_WifiEn = 106,
PinmuxPadIndex_WifiRst = 107,
PinmuxPadIndex_WifiWakeAp = 108,
PinmuxPadIndex_ApWakeBt = 109,
PinmuxPadIndex_BtRst = 110,
PinmuxPadIndex_BtWakeAp = 111,
PinmuxPadIndex_ApWakeNfc = 112,
PinmuxPadIndex_NfcEn = 113,
PinmuxPadIndex_NfcInt = 114,
PinmuxPadIndex_GpsEn = 115,
PinmuxPadIndex_GpsRst = 116,
PinmuxPadIndex_CamRst = 117,
PinmuxPadIndex_CamAfEn = 118,
PinmuxPadIndex_CamFlashEn = 119,
PinmuxPadIndex_Cam1Pwdn = 120,
PinmuxPadIndex_Cam2Pwdn = 121,
PinmuxPadIndex_Cam1Strobe = 122,
PinmuxPadIndex_LcdTe = 123,
PinmuxPadIndex_LcdBlPwm = 124,
PinmuxPadIndex_LcdBlEn = 125,
PinmuxPadIndex_LcdRst = 126,
PinmuxPadIndex_LcdGpio1 = 127,
PinmuxPadIndex_LcdGpio2 = 128,
PinmuxPadIndex_ApReady = 129,
PinmuxPadIndex_TouchRst = 130,
PinmuxPadIndex_TouchClk = 131,
PinmuxPadIndex_ModemWakeAp = 132,
PinmuxPadIndex_TouchInt = 133,
PinmuxPadIndex_MotionInt = 134,
PinmuxPadIndex_AlsProxInt = 135,
PinmuxPadIndex_TempAlert = 136,
PinmuxPadIndex_ButtonPowerOn = 137,
PinmuxPadIndex_ButtonVolUp = 138,
PinmuxPadIndex_ButtonVolDown = 139,
PinmuxPadIndex_ButtonSlideSw = 140,
PinmuxPadIndex_ButtonHome = 141,
PinmuxPadIndex_GpioPa6 = 142,
PinmuxPadIndex_GpioPe6 = 143,
PinmuxPadIndex_GpioPe7 = 144,
PinmuxPadIndex_GpioPh6 = 145,
PinmuxPadIndex_GpioPk0 = 146,
PinmuxPadIndex_GpioPk1 = 147,
PinmuxPadIndex_GpioPk2 = 148,
PinmuxPadIndex_GpioPk3 = 149,
PinmuxPadIndex_GpioPk4 = 150,
PinmuxPadIndex_GpioPk5 = 151,
PinmuxPadIndex_GpioPk6 = 152,
PinmuxPadIndex_GpioPk7 = 153,
PinmuxPadIndex_GpioPl0 = 154,
PinmuxPadIndex_GpioPl1 = 155,
PinmuxPadIndex_GpioPz0 = 156,
PinmuxPadIndex_GpioPz1 = 157,
PinmuxPadIndex_GpioPz2 = 158,
PinmuxPadIndex_GpioPz3 = 159,
PinmuxPadIndex_GpioPz4 = 160,
PinmuxPadIndex_GpioPz5 = 161,
PinmuxPadIndex_Sdmmc2Dat0 = 162,
PinmuxPadIndex_Sdmmc2Dat1 = 163,
PinmuxPadIndex_Sdmmc2Dat2 = 164,
PinmuxPadIndex_Sdmmc2Dat3 = 165,
PinmuxPadIndex_Sdmmc2Dat4 = 166,
PinmuxPadIndex_Sdmmc2Dat5 = 167,
PinmuxPadIndex_Sdmmc2Dat6 = 168,
PinmuxPadIndex_Sdmmc2Dat7 = 169,
PinmuxPadIndex_Sdmmc2Clk = 170,
PinmuxPadIndex_Sdmmc2Clkb = 171,
PinmuxPadIndex_Sdmmc2Cmd = 172,
PinmuxPadIndex_Sdmmc2Dqs = 173,
PinmuxPadIndex_Sdmmc2Dqsb = 174,
};
enum PinmuxDrivePadIndex {
PinmuxDrivePadIndex_AlsProxInt = 0,
PinmuxDrivePadIndex_ApReady = 1,
PinmuxDrivePadIndex_ApWakeBt = 2,
PinmuxDrivePadIndex_ApWakeNfc = 3,
PinmuxDrivePadIndex_AudMclk = 4,
PinmuxDrivePadIndex_BattBcl = 5,
PinmuxDrivePadIndex_BtRst = 6,
PinmuxDrivePadIndex_BtWakeAp = 7,
PinmuxDrivePadIndex_ButtonHome = 8,
PinmuxDrivePadIndex_ButtonPowerOn = 9,
PinmuxDrivePadIndex_ButtonSlideSw = 10,
PinmuxDrivePadIndex_ButtonVolDown = 11,
PinmuxDrivePadIndex_ButtonVolUp = 12,
PinmuxDrivePadIndex_Cam1Mclk = 13,
PinmuxDrivePadIndex_Cam1Pwdn = 14,
PinmuxDrivePadIndex_Cam1Strobe = 15,
PinmuxDrivePadIndex_Cam2Mclk = 16,
PinmuxDrivePadIndex_Cam2Pwdn = 17,
PinmuxDrivePadIndex_CamAfEn = 18,
PinmuxDrivePadIndex_CamFlashEn = 19,
PinmuxDrivePadIndex_CamI2cScl = 20,
PinmuxDrivePadIndex_CamI2cSda = 21,
PinmuxDrivePadIndex_CamRst = 22,
PinmuxDrivePadIndex_Clk32kIn = 23,
PinmuxDrivePadIndex_Clk32kOut = 24,
PinmuxDrivePadIndex_ClkReq = 25,
PinmuxDrivePadIndex_CorePwrReq = 26,
PinmuxDrivePadIndex_CpuPwrReq = 27,
PinmuxDrivePadIndex_Dap1Din = 28,
PinmuxDrivePadIndex_Dap1Dout = 29,
PinmuxDrivePadIndex_Dap1Fs = 30,
PinmuxDrivePadIndex_Dap1Sclk = 31,
PinmuxDrivePadIndex_Dap2Din = 32,
PinmuxDrivePadIndex_Dap2Dout = 33,
PinmuxDrivePadIndex_Dap2Fs = 34,
PinmuxDrivePadIndex_Dap2Sclk = 35,
PinmuxDrivePadIndex_Dap4Din = 36,
PinmuxDrivePadIndex_Dap4Dout = 37,
PinmuxDrivePadIndex_Dap4Fs = 38,
PinmuxDrivePadIndex_Dap4Sclk = 39,
PinmuxDrivePadIndex_Dmic1Clk = 40,
PinmuxDrivePadIndex_Dmic1Dat = 41,
PinmuxDrivePadIndex_Dmic2Clk = 42,
PinmuxDrivePadIndex_Dmic2Dat = 43,
PinmuxDrivePadIndex_Dmic3Clk = 44,
PinmuxDrivePadIndex_Dmic3Dat = 45,
PinmuxDrivePadIndex_DpHpd = 46,
PinmuxDrivePadIndex_DvfsClk = 47,
PinmuxDrivePadIndex_DvfsPwm = 48,
PinmuxDrivePadIndex_Gen1I2cScl = 49,
PinmuxDrivePadIndex_Gen1I2cSda = 50,
PinmuxDrivePadIndex_Gen2I2cScl = 51,
PinmuxDrivePadIndex_Gen2I2cSda = 52,
PinmuxDrivePadIndex_Gen3I2cScl = 53,
PinmuxDrivePadIndex_Gen3I2cSda = 54,
PinmuxDrivePadIndex_GpioPa6 = 55,
PinmuxDrivePadIndex_GpioPcc7 = 56,
PinmuxDrivePadIndex_GpioPe6 = 57,
PinmuxDrivePadIndex_GpioPe7 = 58,
PinmuxDrivePadIndex_GpioPh6 = 59,
PinmuxDrivePadIndex_GpioPk0 = 60,
PinmuxDrivePadIndex_GpioPk1 = 61,
PinmuxDrivePadIndex_GpioPk2 = 62,
PinmuxDrivePadIndex_GpioPk3 = 63,
PinmuxDrivePadIndex_GpioPk4 = 64,
PinmuxDrivePadIndex_GpioPk5 = 65,
PinmuxDrivePadIndex_GpioPk6 = 66,
PinmuxDrivePadIndex_GpioPk7 = 67,
PinmuxDrivePadIndex_GpioPl0 = 68,
PinmuxDrivePadIndex_GpioPl1 = 69,
PinmuxDrivePadIndex_GpioPz0 = 70,
PinmuxDrivePadIndex_GpioPz1 = 71,
PinmuxDrivePadIndex_GpioPz2 = 72,
PinmuxDrivePadIndex_GpioPz3 = 73,
PinmuxDrivePadIndex_GpioPz4 = 74,
PinmuxDrivePadIndex_GpioPz5 = 75,
PinmuxDrivePadIndex_GpioX1Aud = 76,
PinmuxDrivePadIndex_GpioX3Aud = 77,
PinmuxDrivePadIndex_GpsEn = 78,
PinmuxDrivePadIndex_GpsRst = 79,
PinmuxDrivePadIndex_HdmiCec = 80,
PinmuxDrivePadIndex_HdmiIntDpHpd = 81,
PinmuxDrivePadIndex_JtagRtck = 82,
PinmuxDrivePadIndex_LcdBlEn = 83,
PinmuxDrivePadIndex_LcdBlPwm = 84,
PinmuxDrivePadIndex_LcdGpio1 = 85,
PinmuxDrivePadIndex_LcdGpio2 = 86,
PinmuxDrivePadIndex_LcdRst = 87,
PinmuxDrivePadIndex_LcdTe = 88,
PinmuxDrivePadIndex_ModemWakeAp = 89,
PinmuxDrivePadIndex_MotionInt = 90,
PinmuxDrivePadIndex_NfcEn = 91,
PinmuxDrivePadIndex_NfcInt = 92,
PinmuxDrivePadIndex_PexL0ClkReqN = 93,
PinmuxDrivePadIndex_PexL0RstN = 94,
PinmuxDrivePadIndex_PexL1ClkreqN = 95,
PinmuxDrivePadIndex_PexL1RstN = 96,
PinmuxDrivePadIndex_PexWakeN = 97,
PinmuxDrivePadIndex_PwrI2cScl = 98,
PinmuxDrivePadIndex_PwrI2cSda = 99,
PinmuxDrivePadIndex_PwrIntN = 100,
PinmuxDrivePadIndex_QspiComp = 101,
PinmuxDrivePadIndex_QspiSck = 102,
PinmuxDrivePadIndex_SataLedActive = 103,
PinmuxDrivePadIndex_Sdmmc1Pad = 104,
PinmuxDrivePadIndex_Sdmmc3Pad = 105,
PinmuxDrivePadIndex_Shutdown = 106,
PinmuxDrivePadIndex_SpdifIn = 107,
PinmuxDrivePadIndex_SpdifOut = 108,
PinmuxDrivePadIndex_Spi1Cs0 = 109,
PinmuxDrivePadIndex_Spi1Cs1 = 110,
PinmuxDrivePadIndex_Spi1Miso = 111,
PinmuxDrivePadIndex_Spi1Mosi = 112,
PinmuxDrivePadIndex_Spi1Sck = 113,
PinmuxDrivePadIndex_Spi2Cs0 = 114,
PinmuxDrivePadIndex_Spi2Cs1 = 115,
PinmuxDrivePadIndex_Spi2Miso = 116,
PinmuxDrivePadIndex_Spi2Mosi = 117,
PinmuxDrivePadIndex_Spi2Sck = 118,
PinmuxDrivePadIndex_Spi4Cs0 = 119,
PinmuxDrivePadIndex_Spi4Miso = 120,
PinmuxDrivePadIndex_Spi4Mosi = 121,
PinmuxDrivePadIndex_Spi4Sck = 122,
PinmuxDrivePadIndex_TempAlert = 123,
PinmuxDrivePadIndex_TouchClk = 124,
PinmuxDrivePadIndex_TouchInt = 125,
PinmuxDrivePadIndex_TouchRst = 126,
PinmuxDrivePadIndex_Uart1Cts = 127,
PinmuxDrivePadIndex_Uart1Rts = 128,
PinmuxDrivePadIndex_Uart1Rx = 129,
PinmuxDrivePadIndex_Uart1Tx = 130,
PinmuxDrivePadIndex_Uart2Cts = 131,
PinmuxDrivePadIndex_Uart2Rts = 132,
PinmuxDrivePadIndex_Uart2Rx = 133,
PinmuxDrivePadIndex_Uart2Tx = 134,
PinmuxDrivePadIndex_Uart3Cts = 135,
PinmuxDrivePadIndex_Uart3Rts = 136,
PinmuxDrivePadIndex_Uart3Rx = 137,
PinmuxDrivePadIndex_Uart3Tx = 138,
PinmuxDrivePadIndex_Uart4Cts = 139,
PinmuxDrivePadIndex_Uart4Rts = 140,
PinmuxDrivePadIndex_Uart4Rx = 141,
PinmuxDrivePadIndex_Uart4Tx = 142,
PinmuxDrivePadIndex_UsbVbusEn0 = 143,
PinmuxDrivePadIndex_UsbVbusEn1 = 144,
PinmuxDrivePadIndex_WifiEn = 145,
PinmuxDrivePadIndex_WifiRst = 146,
PinmuxDrivePadIndex_WifiWakeAp = 147,
};
| 14,357
|
C++
|
.h
| 344
| 36.927326
| 89
| 0.657577
|
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,354
|
pinmux_platform_pads.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.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::pinmux::driver::board::nintendo::nx {
struct PinmuxPadConfig {
u32 index;
u32 option;
u32 option_mask;
};
struct PinmuxDrivePadConfig {
u32 index;
u32 option;
u32 option_mask;
};
void InitializePlatformPads();
void UpdateSinglePinmuxPad(const PinmuxPadConfig &config);
void UpdateSinglePinmuxDrivePad(const PinmuxDrivePadConfig &config);
}
| 1,113
|
C++
|
.h
| 32
| 30.78125
| 76
| 0.730233
|
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,355
|
pinmux_board_driver_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_board_driver_api.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::pinmux::driver::board::nintendo::nx {
bool IsInitialized();
void Initialize();
void Finalize();
void SetInitialConfig();
void SetInitialDrivePadConfig();
}
| 872
|
C++
|
.h
| 24
| 33.708333
| 76
| 0.748517
|
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,356
|
ams_bpc.os.horizon.h
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/ams/ams_bpc.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
Result amsBpcInitialize(void);
void amsBpcExit(void);
Service *amsBpcGetServiceSession(void);
Result amsBpcRebootToFatalError(void *ctx);
Result amsBpcSetRebootPayload(const void *src, size_t src_size);
#ifdef __cplusplus
}
#endif
| 942
|
C++
|
.h
| 28
| 32
| 76
| 0.774725
|
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,357
|
dd_device_address_space_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/dd/impl/dd_device_address_space_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>
#if defined(ATMOSPHERE_OS_HORIZON)
#include "dd_device_address_space_impl.os.horizon.hpp"
#else
#include "dd_device_address_space_impl.generic.hpp"
#endif
| 840
|
C++
|
.h
| 22
| 36.136364
| 76
| 0.761322
|
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,358
|
dd_device_address_space_impl.generic.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/dd/impl/dd_device_address_space_impl.generic.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::dd::impl {
class DeviceAddressSpaceImplByWindows {
public:
static Result Create(DeviceAddressSpaceHandle *, u64, u64) {
R_THROW(dd::ResultNotSupported());
}
static void Close(DeviceAddressSpaceHandle) {
/* ... */
}
static Result MapAligned(DeviceAddressSpaceHandle, ProcessHandle, u64, size_t, DeviceVirtualAddress, dd::MemoryPermission) {
R_THROW(dd::ResultNotSupported());
}
static Result MapNotAligned(DeviceAddressSpaceHandle, ProcessHandle, u64, size_t, DeviceVirtualAddress, dd::MemoryPermission) {
R_THROW(dd::ResultNotSupported());
}
static void Unmap(DeviceAddressSpaceHandle, ProcessHandle, u64, size_t, DeviceVirtualAddress) {
/* ... */
}
static Result Attach(DeviceAddressSpaceType *, DeviceName) {
R_THROW(dd::ResultNotSupported());
}
static void Detach(DeviceAddressSpaceType *, DeviceName) {
/* ... */
}
};
using DeviceAddressSpaceImpl = DeviceAddressSpaceImplByWindows;
}
| 1,888
|
C++
|
.h
| 44
| 34.568182
| 139
| 0.654496
|
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,359
|
dd_device_address_space_impl.os.horizon.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/dd/impl/dd_device_address_space_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::dd::impl {
class DeviceAddressSpaceImplByHorizon {
public:
static Result Create(DeviceAddressSpaceHandle *out, u64 address, u64 size);
static void Close(DeviceAddressSpaceHandle handle);
static Result MapAligned(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address, dd::MemoryPermission device_perm);
static Result MapNotAligned(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address, dd::MemoryPermission device_perm);
static void Unmap(DeviceAddressSpaceHandle handle, ProcessHandle process_handle, u64 process_address, size_t process_size, DeviceVirtualAddress device_address);
static Result Attach(DeviceAddressSpaceType *das, DeviceName device_name);
static void Detach(DeviceAddressSpaceType *das, DeviceName device_name);
};
using DeviceAddressSpaceImpl = DeviceAddressSpaceImplByHorizon;
}
| 1,778
|
C++
|
.h
| 30
| 54.166667
| 216
| 0.765347
|
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,360
|
decodersrv_software_jpeg_shrinker.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_shrinker.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::capsrv::server::jpeg {
struct SoftwareJpegShrinkerInput {
const void *jpeg;
size_t jpeg_size;
u32 width;
u32 height;
bool fancy_upsampling;
bool block_smoothing;
};
struct SoftwareJpegShrinkerOutput {
u64 *out_size;
s32 *out_width;
s32 *out_height;
void *dst;
size_t dst_size;
};
class SoftwareJpegShrinker {
public:
static Result ShrinkRgba8(SoftwareJpegShrinkerOutput &output, const SoftwareJpegShrinkerInput &input, int quality, void *work, size_t work_size);
};
}
| 1,295
|
C++
|
.h
| 38
| 29.131579
| 157
| 0.699122
|
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,361
|
capsrv_server_jpeg_error_handler.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/jpeg/capsrv_server_jpeg_error_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 <csetjmp>
#include "capsrv_server_jpeg_library_types.hpp"
namespace ams::capsrv::server::jpeg {
struct JpegErrorHandler : public JpegLibraryType::jpeg_error_mgr {
public:
std::jmp_buf jmp_buf;
Result result;
public:
static void HandleError(JpegLibraryType::jpeg_common_struct *common) {
/* Retrieve the handler. */
JpegErrorHandler *handler = reinterpret_cast<JpegErrorHandler *>(common->err);
/* Set the result. */
handler->result = GetResult(handler->msg_code, handler->msg_parm.i[0]);
/* Return to the caller. */
longjmp(handler->jmp_buf, -1);
}
static Result GetResult(int msg_code, int msg_param) {
/* NOTE: Nintendo uses msg_param for error codes that we never trigger. */
/* TODO: Fully support all J_MESSAGE_CODEs that Nintendo handles? */
AMS_UNUSED(msg_param);
switch (msg_code) {
case JpegLibraryType::J_MESSAGE_CODE::JERR_BUFFER_SIZE:
case JpegLibraryType::J_MESSAGE_CODE::JERR_NO_BACKING_STORE:
case JpegLibraryType::J_MESSAGE_CODE::JERR_OUT_OF_MEMORY:
case JpegLibraryType::J_MESSAGE_CODE::JERR_TFILE_CREATE:
case JpegLibraryType::J_MESSAGE_CODE::JERR_TFILE_READ:
case JpegLibraryType::J_MESSAGE_CODE::JERR_TFILE_SEEK:
case JpegLibraryType::J_MESSAGE_CODE::JERR_TFILE_WRITE:
R_THROW(capsrv::ResultInternalJpegWorkMemoryShortage());
default:
R_THROW(capsrv::ResultInternalJpegEncoderError());
}
}
};
}
| 2,487
|
C++
|
.h
| 52
| 37.192308
| 94
| 0.621911
|
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,362
|
decodersrv_software_jpeg_decoder.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/jpeg/decodersrv_software_jpeg_decoder.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::capsrv::server::jpeg {
struct SoftwareJpegDecoderInput {
const void *jpeg;
size_t jpeg_size;
u32 width;
u32 height;
bool fancy_upsampling;
bool block_smoothing;
};
struct SoftwareJpegDecoderOutput {
s32 *out_width;
s32 *out_height;
void *dst;
size_t dst_size;
};
class SoftwareJpegDecoder {
public:
static Result DecodeRgba8(SoftwareJpegDecoderOutput &output, const SoftwareJpegDecoderInput &input, void *work, size_t work_size);
};
}
| 1,254
|
C++
|
.h
| 37
| 29.054054
| 142
| 0.701566
|
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,363
|
capsrv_server_jpeg_library_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/jpeg/capsrv_server_jpeg_library_types.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 <jpeglib.h>
#include <jerror.h>
namespace ams::capsrv::server::jpeg {
class JpegLibraryType {
public:
using jpeg_common_struct = ::jpeg_common_struct;
using jpeg_compress_struct = ::jpeg_compress_struct;
using jpeg_decompress_struct = ::jpeg_decompress_struct;
using jpeg_error_mgr = ::jpeg_error_mgr;
using jpeg_destination_mgr = ::jpeg_destination_mgr;
using j_common_ptr = ::j_common_ptr;
using j_compress_ptr = ::j_compress_ptr;
using boolean = ::boolean;
using JOCTET = ::JOCTET;
using JDIMENSION = ::JDIMENSION;
using JSAMPARRAY = ::JSAMPARRAY;
using JSAMPROW = ::JSAMPROW;
using J_COLOR_SPACE = ::J_COLOR_SPACE;
using J_DCT_METHOD = ::J_DCT_METHOD;
using J_MESSAGE_CODE = ::J_MESSAGE_CODE;
};
}
| 1,721
|
C++
|
.h
| 39
| 37.538462
| 76
| 0.608722
|
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,364
|
decodersrv_decoder_server_object.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_server_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 "decodersrv_decoder_work_memory.hpp"
#include "decodersrv_decoder_control_server_manager.hpp"
namespace ams::capsrv::server {
extern DecoderWorkMemory g_work_memory;
extern DecoderControlServerManager g_decoder_control_server_manager;
}
| 933
|
C++
|
.h
| 23
| 38.478261
| 76
| 0.776185
|
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,365
|
decodersrv_decoder_control_server_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_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 "decodersrv_decoder_control_service.hpp"
namespace ams::capsrv::server {
class DecoderControlServerManager {
public:
/* NOTE: Nintendo only allows one session. */
static constexpr inline size_t NumServers = 1;
static constexpr inline size_t MaxSessions = 2;
static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("caps:dc");
using ServiceHolderType = ams::sf::UnmanagedServiceObject<capsrv::sf::IDecoderControlService, DecoderControlService>;
using ServerOptions = ams::sf::hipc::DefaultServerManagerOptions;
using ServerManager = ams::sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
private:
util::optional<ServiceHolderType> m_service_holder;
util::optional<ServerManager> m_server_manager_holder;
os::EventType m_idle_event;
public:
constexpr DecoderControlServerManager() : m_service_holder(), m_server_manager_holder(), m_idle_event{} { /* ... */ }
Result Initialize();
void Finalize();
void StartServer();
void StopServer();
void RunServer();
};
}
| 1,932
|
C++
|
.h
| 41
| 40.121951
| 129
| 0.680297
|
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,366
|
decodersrv_decoder_control_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_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_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 3001, Result, DecodeJpeg, (const ams::sf::OutNonSecureBuffer &out, const ams::sf::InBuffer &in, u32 width, u32 height, const capsrv::ScreenShotDecodeOption &option), (out, in, width, height, option)) \
AMS_SF_METHOD_INFO(C, H, 4001, Result, ShrinkJpeg, (ams::sf::Out<u64> out_size, const ams::sf::OutNonSecureBuffer &out, const ams::sf::InBuffer &in, u32 width, u32 height, const capsrv::ScreenShotDecodeOption &option), (out_size, out, in, width, height, option))
AMS_SF_DEFINE_INTERFACE(ams::capsrv::sf, IDecoderControlService, AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO, 0xD168E90B)
namespace ams::capsrv::server {
class DecoderControlService final {
public:
Result DecodeJpeg(const ams::sf::OutNonSecureBuffer &out, const ams::sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option);
Result ShrinkJpeg(ams::sf::Out<u64> out_size, const ams::sf::OutNonSecureBuffer &out, const ams::sf::InBuffer &in, u32 width, u32 height, const capsrv::ScreenShotDecodeOption &option);
};
static_assert(capsrv::sf::IsIDecoderControlService<DecoderControlService>);
}
| 1,936
|
C++
|
.h
| 29
| 63.310345
| 266
| 0.735542
|
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,367
|
decodersrv_decoder_work_memory.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_work_memory.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::capsrv::server {
struct DecoderWorkMemory {
alignas(os::MemoryPageSize) u8 jpeg_decoder_memory[SoftwareJpegDecoderWorkMemorySize];
};
static_assert(sizeof(DecoderWorkMemory) == SoftwareJpegDecoderWorkMemorySize);
static_assert(alignof(DecoderWorkMemory) == os::MemoryPageSize);
static_assert(util::is_pod<DecoderWorkMemory>::value);
}
| 1,058
|
C++
|
.h
| 25
| 39.52
| 94
| 0.763107
|
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,368
|
lm_remote_log_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/lm_remote_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>
#include "sf/lm_i_log_service.hpp"
namespace ams::lm {
#if defined(ATMOSPHERE_OS_HORIZON)
/* TODO: Real libnx primitives? */
#define NX_SERVICE_ASSUME_NON_DOMAIN
class RemoteLogger {
private:
::Service m_srv;
public:
RemoteLogger(::Service &s) : m_srv(s) { /* ... */ }
~RemoteLogger() { ::serviceClose(std::addressof(m_srv)); }
public:
/* Actual commands. */
Result Log(const sf::InAutoSelectBuffer &message) {
return serviceDispatch(std::addressof(m_srv), 0,
.buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcAutoSelect },
.buffers = { { message.GetPointer(), message.GetSize() } },
);
}
Result SetDestination(u32 destination) {
R_RETURN(serviceDispatchIn(std::addressof(m_srv), 1, destination));
}
};
static_assert(lm::IsILogger<RemoteLogger>);
class RemoteLogService {
private:
::Service m_srv;
public:
RemoteLogService(os::NativeHandle h) {
::serviceCreate(std::addressof(m_srv), h);
}
~RemoteLogService() { ::serviceClose(std::addressof(m_srv)); }
public:
/* Actual commands. */
Result OpenLogger(sf::Out<sf::SharedPointer<::ams::lm::ILogger>> out, const sf::ClientProcessId &client_process_id);
};
static_assert(lm::IsILogService<RemoteLogService>);
#undef NX_SERVICE_ASSUME_NON_DOMAIN
#endif
sf::SharedPointer<ILogService> CreateLogService();
}
| 2,308
|
C++
|
.h
| 58
| 32.051724
| 128
| 0.630522
|
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,369
|
lm_service_name.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/lm_service_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::lm {
constexpr inline const sm::ServiceName LogServiceName = sm::ServiceName::Encode("lm");
constexpr inline const sm::ServiceName LogGetterServiceName = sm::ServiceName::Encode("lm:get");
}
| 894
|
C++
|
.h
| 21
| 40.333333
| 100
| 0.759494
|
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,370
|
lm_log_packet_transmitter.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/lm/impl/lm_log_packet_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>
#include "lm_log_packet_transmitter_base.hpp"
namespace ams::lm::impl {
class LogPacketTransmitter : public LogPacketTransmitterBase {
public:
LogPacketTransmitter(void *buffer, size_t buffer_size, FlushFunction flush_func, u8 severity, u8 verbosity, u64 process_id, bool head, bool tail)
: LogPacketTransmitterBase(buffer, buffer_size, flush_func, severity, verbosity, process_id, head, tail) { /* ... */ }
void PushLogSessionBegin() {
bool value = true;
this->PushDataChunk(LogDataChunkKey_LogSessionBegin, std::addressof(value), sizeof(value));
}
void PushLogSessionEnd() {
bool value = true;
this->PushDataChunk(LogDataChunkKey_LogSessionEnd, std::addressof(value), sizeof(value));
}
void PushTextLog(const char *str, size_t len) {
this->PushDataChunk(LogDataChunkKey_TextLog, str, len);
}
void PushLineNumber(u32 line) {
this->PushDataChunk(LogDataChunkKey_LineNumber, std::addressof(line), sizeof(line));
}
void PushFileName(const char *str, size_t len) {
this->PushDataChunk(LogDataChunkKey_FileName, str, len);
}
void PushFunctionName(const char *str, size_t len) {
this->PushDataChunk(LogDataChunkKey_FunctionName, str, len);
}
void PushModuleName(const char *str, size_t len) {
this->PushDataChunk(LogDataChunkKey_ModuleName, str, len);
}
void PushThreadName(const char *str, size_t len) {
this->PushDataChunk(LogDataChunkKey_ThreadName, str, len);
}
void PushLogPacketDropCount(u64 count) {
this->PushDataChunk(LogDataChunkKey_LineNumber, std::addressof(count), sizeof(count));
}
void PushUserSystemClock(s64 posix_time) {
this->PushDataChunk(LogDataChunkKey_LineNumber, std::addressof(posix_time), sizeof(posix_time));
}
void PushProcessName(const char *str, size_t len) {
this->PushDataChunk(LogDataChunkKey_ProcessName, str, len);
}
};
}
| 2,958
|
C++
|
.h
| 60
| 39.233333
| 157
| 0.643204
|
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.