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
7,734
lmem_unit_heap.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lmem/lmem_unit_heap.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/lmem/lmem_common.hpp> namespace ams::lmem { enum InfoPlacement { InfoPlacement_Head, InfoPlacement_Tail, }; HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option); HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option, s32 alignment, InfoPlacement info_placement); HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option, s32 alignment, HeapCommonHead *heap_head); void DestroyUnitHeap(HeapHandle handle); void InvalidateUnitHeap(HeapHandle handle); void ExtendUnitHeap(HeapHandle handle, size_t size); void *AllocateFromUnitHeap(HeapHandle handle); void FreeToUnitHeap(HeapHandle handle, void *block); size_t GetUnitHeapUnitSize(HeapHandle handle); s32 GetUnitHeapAlignment(HeapHandle handle); size_t GetUnitHeapFreeCount(HeapHandle handle); size_t GetUnitHeapUsedCount(HeapHandle handle); size_t GetUnitHeapRequiredSize(size_t unit_size, size_t unit_count, s32 alignment, bool internal_metadata); }
1,779
C++
.h
37
44.405405
134
0.759377
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
7,735
lmem_impl_common.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lmem/impl/lmem_impl_common.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 <vapours.hpp> #include <stratosphere/os.hpp> namespace ams::lmem::impl { /* NOTE: Nintendo does not use util::IntrusiveListNode. */ /* They seem to manually manage linked list pointers. */ /* This is pretty gross, so we're going to use util::IntrusiveListNode. */ struct ExpHeapMemoryBlockHead { u16 magic; u32 attributes; size_t block_size; util::IntrusiveListNode list_node; }; static_assert(std::is_trivially_destructible<ExpHeapMemoryBlockHead>::value); using ExpHeapMemoryBlockList = typename util::IntrusiveListMemberTraits<&ExpHeapMemoryBlockHead::list_node>::ListType; struct ExpHeapHead { ExpHeapMemoryBlockList free_list; ExpHeapMemoryBlockList used_list; u16 group_id; u16 mode; bool use_alignment_margins; char pad[3]; }; static_assert(sizeof(ExpHeapHead) == 0x28); static_assert(std::is_trivially_destructible<ExpHeapHead>::value); struct FrameHeapHead { void *next_block_head; void *next_block_tail; }; static_assert(sizeof(FrameHeapHead) == 0x10); static_assert(std::is_trivially_destructible<FrameHeapHead>::value); struct UnitHead { UnitHead *next; }; struct UnitHeapList { UnitHead *head; }; struct UnitHeapHead { UnitHeapList free_list; size_t unit_size; s32 alignment; s32 num_units; }; static_assert(sizeof(UnitHeapHead) == 0x18); static_assert(std::is_trivially_destructible<UnitHeapHead>::value); union ImplementationHeapHead { ExpHeapHead exp_heap_head; FrameHeapHead frame_heap_head; UnitHeapHead unit_heap_head; }; struct HeapHead { u32 magic; util::IntrusiveListNode list_node; using ChildListTraits = util::IntrusiveListMemberTraits<&HeapHead::list_node>; using ChildList = ChildListTraits::ListType; ChildList child_list; void *heap_start; void *heap_end; os::SdkMutexType mutex; u8 option; ImplementationHeapHead impl_head; }; static_assert(std::is_trivially_destructible<HeapHead>::value); }
2,861
C++
.h
79
30.291139
122
0.692085
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
7,736
nim_network_install_manager_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/nim/nim_network_install_manager_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/nim/nim_system_update_task_id.hpp> namespace ams::nim { /* Management. */ void InitializeForNetworkInstallManager(); void FinalizeForNetworkInstallManager(); /* Service API. */ Result DestroySystemUpdateTask(const SystemUpdateTaskId &id); s32 ListSystemUpdateTask(SystemUpdateTaskId *out_list, size_t out_list_size); }
1,020
C++
.h
25
38.04
81
0.760364
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
7,737
nim_task_id_common.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/nim/nim_task_id_common.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 <vapours.hpp> #include <stratosphere/nim/nim_task_id_common.hpp> namespace ams::nim { #define AMS_NIM_DEFINE_TASK_ID(ID, ALIGN) \ struct alignas(ALIGN) ID { \ util::Uuid uuid; \ \ ALWAYS_INLINE bool IsValid() const { \ return this->uuid != util::InvalidUuid; \ } \ }; \ \ static_assert(alignof(ID) == ALIGN); \ \ ALWAYS_INLINE bool operator==(const ID &lhs, const ID &rhs) { \ return lhs.uuid == rhs.uuid; \ } \ \ ALWAYS_INLINE bool operator!=(const ID &lhs, const ID &rhs) { \ return lhs.uuid != rhs.uuid; \ } \ \ constexpr inline ID Invalid##ID = { util::InvalidUuid } }
2,138
C++
.h
40
41.325
76
0.413365
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
7,738
nim_system_update_task_id.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/nim/nim_system_update_task_id.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 <vapours.hpp> #include <stratosphere/nim/nim_task_id_common.hpp> namespace ams::nim { AMS_NIM_DEFINE_TASK_ID(SystemUpdateTaskId, 8); }
799
C++
.h
21
36.047619
76
0.75871
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
7,739
mitm_pm_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mitm/mitm_pm_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 <vapours.hpp> #include <stratosphere/ncm/ncm_program_id.hpp> namespace ams::mitm::pm { /* PM API. */ void Initialize(); void Finalize(); Result PrepareLaunchProgram(u64 *out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, bool is_application); }
939
C++
.h
24
36.666667
125
0.747253
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
7,740
mitm_pm_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mitm/impl/mitm_pm_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/ncm/ncm_program_id.hpp> #include <stratosphere/cfg/cfg_types.hpp> #include <stratosphere/sf.hpp> #define AMS_MITM_PM_IMPL_I_PM_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 65000, Result, PrepareLaunchProgram, (sf::Out<u64> out_boost_size, ncm::ProgramId program_id, const cfg::OverrideStatus &override_status, bool is_application), (out_boost_size, program_id, override_status, is_application)) AMS_SF_DEFINE_INTERFACE(ams::mitm::pm::impl, IPmInterface, AMS_MITM_PM_IMPL_I_PM_INTERFACE_INFO, 0xEA88789C)
1,209
C++
.h
23
50.608696
251
0.762267
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
7,741
clkrst_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/clkrst/clkrst_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 <vapours.hpp> namespace ams::clkrst { /* ... */ }
714
C++
.h
20
33.65
76
0.743849
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
7,742
clkrst_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/clkrst/clkrst_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 <vapours.hpp> #include <stratosphere/clkrst/clkrst_types.hpp> namespace ams::clkrst { void Initialize(); void Finalize(); }
792
C++
.h
22
33.863636
76
0.754889
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
7,743
clkrst_session_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/clkrst/clkrst_session_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 <vapours.hpp> #include <stratosphere/clkrst/clkrst_types.hpp> namespace ams::clkrst { struct ClkRstSession { void *_session; }; Result OpenSession(ClkRstSession *out, DeviceCode device_code); void CloseSession(ClkRstSession *session); void SetResetAsserted(ClkRstSession *session); void SetResetDeasserted(ClkRstSession *session); void SetClockRate(ClkRstSession *session, u32 hz); void SetClockDisabled(ClkRstSession *session); }
1,135
C++
.h
29
36.034483
76
0.759782
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
7,744
kvdb_memory_key_value_store.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <stratosphere/fs/fs_file.hpp> #include <stratosphere/fs/fs_directory.hpp> #include <stratosphere/fs/fs_filesystem.hpp> #include <stratosphere/kvdb/kvdb_auto_buffer.hpp> #include <stratosphere/kvdb/kvdb_archive.hpp> #include <stratosphere/kvdb/kvdb_bounded_string.hpp> namespace ams::kvdb { template<class Key> class MemoryKeyValueStore { static_assert(util::is_pod<Key>::value, "KeyValueStore Keys must be pod!"); NON_COPYABLE(MemoryKeyValueStore); NON_MOVEABLE(MemoryKeyValueStore); public: /* Subtypes. */ class Entry { private: Key m_key; void *m_value; size_t m_value_size; public: constexpr Entry(const Key &k, void *v, size_t s) : m_key(k), m_value(v), m_value_size(s) { /* ... */ } const Key &GetKey() const { return m_key; } template<typename Value = void> Value *GetValuePointer() { /* Size check. Note: Nintendo does not size check. */ if constexpr (!std::is_same<Value, void>::value) { AMS_ABORT_UNLESS(sizeof(Value) <= m_value_size); /* Ensure we only get pod. */ static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod"); } return reinterpret_cast<Value *>(m_value); } template<typename Value = void> const Value *GetValuePointer() const { /* Size check. Note: Nintendo does not size check. */ if constexpr (!std::is_same<Value, void>::value) { AMS_ABORT_UNLESS(sizeof(Value) <= m_value_size); /* Ensure we only get pod. */ static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod"); } return reinterpret_cast<Value *>(m_value); } template<typename Value> Value &GetValue() { return *(this->GetValuePointer<Value>()); } template<typename Value> const Value &GetValue() const { return *(this->GetValuePointer<Value>()); } size_t GetValueSize() const { return m_value_size; } constexpr inline bool operator<(const Key &rhs) const { return m_key < rhs; } constexpr inline bool operator==(const Key &rhs) const { return m_key == rhs; } }; class Index { private: size_t m_count; size_t m_capacity; Entry *m_entries; MemoryResource *m_memory_resource; public: Index() : m_count(0), m_capacity(0), m_entries(nullptr), m_memory_resource(nullptr) { /* ... */ } ~Index() { if (m_entries != nullptr) { this->ResetEntries(); m_memory_resource->Deallocate(m_entries, sizeof(Entry) * m_capacity); m_entries = nullptr; } } size_t GetCount() const { return m_count; } size_t GetCapacity() const { return m_capacity; } void ResetEntries() { for (size_t i = 0; i < m_count; i++) { m_memory_resource->Deallocate(m_entries[i].GetValuePointer(), m_entries[i].GetValueSize()); } m_count = 0; } Result Initialize(size_t capacity, MemoryResource *mr) { m_entries = reinterpret_cast<Entry *>(mr->Allocate(sizeof(Entry) * capacity)); R_UNLESS(m_entries != nullptr, kvdb::ResultAllocationFailed()); m_capacity = capacity; m_memory_resource = mr; R_SUCCEED(); } Result Set(const Key &key, const void *value, size_t value_size) { /* Find entry for key. */ Entry *it = this->lower_bound(key); if (it != this->end() && it->GetKey() == key) { /* Entry already exists. Free old value. */ m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize()); } else { /* We need to add a new entry. Check we have room, move future keys forward. */ R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource()); std::memmove(it + 1, it, sizeof(*it) * (this->end() - it)); m_count++; } /* Allocate new value. */ void *new_value = m_memory_resource->Allocate(value_size); R_UNLESS(new_value != nullptr, kvdb::ResultAllocationFailed()); std::memcpy(new_value, value, value_size); /* Save the new Entry in the map. */ *it = Entry(key, new_value, value_size); R_SUCCEED(); } Result AddUnsafe(const Key &key, void *value, size_t value_size) { R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource()); m_entries[m_count++] = Entry(key, value, value_size); R_SUCCEED(); } Result Remove(const Key &key) { /* Find entry for key. */ Entry *it = this->find(key); R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); /* Free the value, move entries back. */ m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize()); std::memmove(it, it + 1, sizeof(*it) * (this->end() - (it + 1))); m_count--; R_SUCCEED(); } Entry *begin() { return this->GetBegin(); } const Entry *begin() const { return this->GetBegin(); } Entry *end() { return this->GetEnd(); } const Entry *end() const { return this->GetEnd(); } const Entry *cbegin() const { return this->begin(); } const Entry *cend() const { return this->end(); } Entry *lower_bound(const Key &key) { return this->GetLowerBound(key); } const Entry *lower_bound(const Key &key) const { return this->GetLowerBound(key); } Entry *find(const Key &key) { return this->Find(key); } const Entry *find(const Key &key) const { return this->Find(key); } private: Entry *GetBegin() { return m_entries; } const Entry *GetBegin() const { return m_entries; } Entry *GetEnd() { return this->GetBegin() + m_count; } const Entry *GetEnd() const { return this->GetBegin() + m_count; } Entry *GetLowerBound(const Key &key) { return std::lower_bound(this->GetBegin(), this->GetEnd(), key); } const Entry *GetLowerBound(const Key &key) const { return std::lower_bound(this->GetBegin(), this->GetEnd(), key); } Entry *Find(const Key &key) { auto it = this->GetLowerBound(key); auto end = this->GetEnd(); if (it != end && it->GetKey() == key) { return it; } return end; } const Entry *Find(const Key &key) const { auto it = this->GetLowerBound(key); auto end = this->GetEnd(); if (it != end && it->GetKey() == key) { return it; } return end; } }; private: using Path = kvdb::BoundedString<fs::EntryNameLengthMax>; private: Index m_index; Path m_path; Path m_temp_path; MemoryResource *m_memory_resource; public: MemoryKeyValueStore() { /* ... */ } Result Initialize(const char *dir, size_t capacity, MemoryResource *mr) { /* Ensure that the passed path is a directory. */ fs::DirectoryEntryType entry_type; R_TRY(fs::GetEntryType(std::addressof(entry_type), dir)); R_UNLESS(entry_type == fs::DirectoryEntryType_Directory, fs::ResultPathNotFound()); /* Set paths. */ m_path.AssignFormat("%s%s", dir, "/imkvdb.arc"); m_temp_path.AssignFormat("%s%s", dir, "/imkvdb.tmp"); /* Initialize our index. */ R_TRY(m_index.Initialize(capacity, mr)); m_memory_resource = mr; R_SUCCEED(); } Result InitializeForReadOnlyArchiveFile(const char *path, size_t capacity, MemoryResource *mr) { /* Ensure that the passed path is a directory. */ fs::DirectoryEntryType entry_type; R_TRY(fs::GetEntryType(std::addressof(entry_type), path)); R_UNLESS(entry_type == fs::DirectoryEntryType_File, fs::ResultPathNotFound()); /* Set paths. */ m_path.Assign(path); m_temp_path.Assign(""); /* Initialize our index. */ R_TRY(m_index.Initialize(capacity, mr)); m_memory_resource = mr; R_SUCCEED(); } Result Initialize(size_t capacity, MemoryResource *mr) { /* This initializes without an archive file. */ /* A store initialized this way cannot have its contents loaded from or flushed to disk. */ m_path.Assign(""); m_temp_path.Assign(""); /* Initialize our index. */ R_TRY(m_index.Initialize(capacity, mr)); m_memory_resource = mr; R_SUCCEED(); } size_t GetCount() const { return m_index.GetCount(); } size_t GetCapacity() const { return m_index.GetCapacity(); } Result Load() { /* Reset any existing entries. */ m_index.ResetEntries(); /* Try to read the archive -- note, path not found is a success condition. */ /* This is because no archive file = no entries, so we're in the right state. */ AutoBuffer buffer; R_TRY_CATCH(this->ReadArchiveFile(std::addressof(buffer))) { R_CONVERT(fs::ResultPathNotFound, ResultSuccess()); } R_END_TRY_CATCH; /* Parse entries from the buffer. */ { ArchiveReader reader(buffer); size_t entry_count = 0; R_TRY(reader.ReadEntryCount(std::addressof(entry_count))); for (size_t i = 0; i < entry_count; i++) { /* Get size of key/value. */ size_t key_size = 0, value_size = 0; R_TRY(reader.GetEntrySize(std::addressof(key_size), std::addressof(value_size))); /* Allocate memory for value. */ void *new_value = m_memory_resource->Allocate(value_size); R_UNLESS(new_value != nullptr, kvdb::ResultAllocationFailed()); /* If we fail before adding to the index, deallocate our value. */ ON_RESULT_FAILURE { m_memory_resource->Deallocate(new_value, value_size); }; /* Read key and value. */ Key key; R_TRY(reader.ReadEntry(std::addressof(key), sizeof(key), new_value, value_size)); R_TRY(m_index.AddUnsafe(key, new_value, value_size)); } } R_SUCCEED(); } Result Save(bool destructive = false) { /* Create a buffer to hold the archive. */ AutoBuffer buffer; R_TRY(buffer.Initialize(this->GetArchiveSize())); /* Write the archive to the buffer. */ { ArchiveWriter writer(buffer); writer.WriteHeader(this->GetCount()); for (const auto &it : m_index) { const auto &key = it.GetKey(); writer.WriteEntry(std::addressof(key), sizeof(Key), it.GetValuePointer(), it.GetValueSize()); } } /* Save the buffer to disk. */ R_RETURN(this->Commit(buffer, destructive)); } Result Set(const Key &key, const void *value, size_t value_size) { R_RETURN(m_index.Set(key, value, value_size)); } template<typename Value> Result Set(const Key &key, const Value &value) { /* Only allow setting pod. */ static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod"); R_RETURN(this->Set(key, std::addressof(value), sizeof(Value))); } template<typename Value> Result Set(const Key &key, const Value *value) { /* Only allow setting pod. */ static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod"); R_RETURN(this->Set(key, value, sizeof(Value))); } Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { /* Find entry. */ auto it = this->find(key); R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); size_t size = std::min(max_out_size, it->GetValueSize()); std::memcpy(out_value, it->GetValuePointer(), size); *out_size = size; R_SUCCEED(); } template<typename Value = void> Result GetValuePointer(Value **out_value, const Key &key) { /* Find entry. */ auto it = this->find(key); R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); *out_value = it->template GetValuePointer<Value>(); R_SUCCEED(); } template<typename Value = void> Result GetValuePointer(const Value **out_value, const Key &key) const { /* Find entry. */ auto it = this->find(key); R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); *out_value = it->template GetValuePointer<Value>(); R_SUCCEED(); } template<typename Value> Result GetValue(Value *out_value, const Key &key) const { /* Find entry. */ auto it = this->find(key); R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); *out_value = it->template GetValue<Value>(); R_SUCCEED(); } Result GetValueSize(size_t *out_size, const Key &key) const { /* Find entry. */ auto it = this->find(key); R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); *out_size = it->GetValueSize(); R_SUCCEED(); } Result Remove(const Key &key) { R_RETURN(m_index.Remove(key)); } Entry *begin() { return m_index.begin(); } const Entry *begin() const { return m_index.begin(); } Entry *end() { return m_index.end(); } const Entry *end() const { return m_index.end(); } const Entry *cbegin() const { return m_index.cbegin(); } const Entry *cend() const { return m_index.cend(); } Entry *lower_bound(const Key &key) { return m_index.lower_bound(key); } const Entry *lower_bound(const Key &key) const { return m_index.lower_bound(key); } Entry *find(const Key &key) { return m_index.find(key); } const Entry *find(const Key &key) const { return m_index.find(key); } private: Result SaveArchiveToFile(const char *path, const void *buf, size_t size) { /* Try to delete the archive, but allow deletion failure. */ fs::DeleteFile(path); /* Create new archive. */ R_TRY(fs::CreateFile(path, size)); /* Write data to the archive. */ { fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), path, fs::OpenMode_Write)); ON_SCOPE_EXIT { fs::CloseFile(file); }; R_TRY(fs::WriteFile(file, 0, buf, size, fs::WriteOption::Flush)); } R_SUCCEED(); } Result Commit(const AutoBuffer &buffer, bool destructive) { if (destructive) { /* Delete and save to the real archive. */ R_TRY(SaveArchiveToFile(m_path.Get(), buffer.Get(), buffer.GetSize())); } else { /* Delete and save to a temporary archive. */ R_TRY(SaveArchiveToFile(m_temp_path.Get(), buffer.Get(), buffer.GetSize())); /* Try to delete the saved archive, but allow deletion failure. */ fs::DeleteFile(m_path.Get()); /* Rename the path. */ R_TRY(fs::RenameFile(m_temp_path.Get(), m_path.Get())); } R_SUCCEED(); } size_t GetArchiveSize() const { ArchiveSizeHelper size_helper; for (const auto &it : m_index) { size_helper.AddEntry(sizeof(Key), it.GetValueSize()); } return size_helper.GetSize(); } Result ReadArchiveFile(AutoBuffer *dst) const { /* Open the file. */ fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Get the archive file size. */ s64 archive_size; R_TRY(fs::GetFileSize(std::addressof(archive_size), file)); /* Make a new buffer, read the file. */ R_TRY(dst->Initialize(static_cast<size_t>(archive_size))); R_TRY(fs::ReadFile(file, 0, dst->Get(), dst->GetSize())); R_SUCCEED(); } }; }
21,644
C++
.h
450
29.602222
122
0.455597
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
7,745
kvdb_bounded_string.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.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 <vapours.hpp> namespace ams::kvdb { /* Represents a string with a backing buffer of N bytes. */ template<size_t N> class BoundedString { static_assert(N > 0, "BoundedString requires non-zero backing buffer!"); private: char m_buffer[N]; public: /* Constructors. */ constexpr BoundedString() { m_buffer[0] = 0; } explicit constexpr BoundedString(const char *s) { AMS_ABORT_UNLESS(static_cast<size_t>(util::Strnlen(s, N)) < N); util::Strlcpy(m_buffer, s, N); } /* Static constructors. */ static constexpr BoundedString<N> Make(const char *s) { return BoundedString<N>(s); } static BoundedString<N> MakeFormat(const char *format, ...) __attribute__((format (printf, 1, 2))) { BoundedString<N> string; std::va_list vl; va_start(vl, format); AMS_ABORT_UNLESS(static_cast<size_t>(util::VSNPrintf(string.m_buffer, N, format, vl)) < N); va_end(vl); return string; } /* Getters. */ constexpr size_t GetLength() const { return util::Strnlen(m_buffer, N); } constexpr const char *Get() const { return m_buffer; } constexpr operator const char *() const { return m_buffer; } /* Assignment. */ constexpr BoundedString<N> &Assign(const char *s) { AMS_ABORT_UNLESS(static_cast<size_t>(util::Strnlen(s, N)) < N); util::Strlcpy(m_buffer, s, N); return *this; } BoundedString<N> &AssignFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) { std::va_list vl; va_start(vl, format); AMS_ABORT_UNLESS(static_cast<size_t>(util::VSNPrintf(m_buffer, N, format, vl)) < N); va_end(vl); return *this; } /* Append to existing. */ BoundedString<N> &Append(const char *s) { const size_t length = GetLength(); AMS_ABORT_UNLESS(length + static_cast<size_t>(util::Strnlen(s, N)) < N); std::strncat(m_buffer, s, N - length - 1); return *this; } BoundedString<N> &Append(char c) { const size_t length = GetLength(); AMS_ABORT_UNLESS(length + 1 < N); m_buffer[length] = c; m_buffer[length + 1] = 0; return *this; } BoundedString<N> &AppendFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) { const size_t length = GetLength(); std::va_list vl; va_start(vl, format); AMS_ABORT_UNLESS(static_cast<size_t>(util::VSNPrintf(m_buffer + length, N - length, format, vl)) < static_cast<size_t>(N - length)); va_end(vl); return *this; } /* Substring utilities. */ void GetSubString(char *dst, size_t dst_size, size_t offset, size_t length) const { /* Make sure output buffer can hold the substring. */ AMS_ABORT_UNLESS(offset + length <= GetLength()); AMS_ABORT_UNLESS(dst_size > length); /* Copy substring to dst. */ std::strncpy(dst, m_buffer + offset, length); dst[length] = 0; } BoundedString<N> MakeSubString(size_t offset, size_t length) const { BoundedString<N> string; GetSubString(string.m_buffer, N, offset, length); return string; } /* Comparison. */ constexpr bool Equals(const char *s, size_t offset = 0) const { if (std::is_constant_evaluated()) { return util::Strncmp(m_buffer + offset, s, N - offset) == 0; } else { return std::strncmp(m_buffer + offset, s, N - offset) == 0; } } constexpr bool operator==(const BoundedString<N> &rhs) const { return this->Equals(rhs.m_buffer); } constexpr bool operator!=(const BoundedString<N> &rhs) const { return !(*this == rhs); } constexpr bool EqualsPostfix(const char *s) const { const size_t suffix_length = util::Strnlen(s, N); const size_t length = GetLength(); return suffix_length <= length && this->Equals(s, length - suffix_length); } }; }
5,537
C++
.h
125
31.312
148
0.525632
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
7,746
kvdb_file_key_value_cache.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_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/>. */ #include <stratosphere/fs/fs_filesystem.hpp> #include <stratosphere/fs/fs_file.hpp> #include <stratosphere/kvdb/kvdb_bounded_string.hpp> #include <stratosphere/kvdb/kvdb_file_key_value_store.hpp> namespace ams::kvdb { namespace impl { template<class Key, size_t Capacity> class LruList { private: /* Subtypes. */ struct LruHeader { u32 entry_count; }; public: static constexpr size_t BufferSize = sizeof(Key) * Capacity; static constexpr size_t FileSize = sizeof(LruHeader) + BufferSize; using Path = FileKeyValueStore::Path; private: Path m_file_path; Key *m_keys; LruHeader m_header; public: static Result CreateNewList(const char *path) { /* Create new lru_list.dat. */ R_TRY(fs::CreateFile(path, FileSize)); /* Open the file. */ fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), path, fs::OpenMode_Write)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Write new header with zero entries to the file. */ LruHeader new_header = { .entry_count = 0, }; R_TRY(fs::WriteFile(file, 0, std::addressof(new_header), sizeof(new_header), fs::WriteOption::Flush)); R_SUCCEED(); } private: void RemoveIndex(size_t i) { AMS_ABORT_UNLESS(i < this->GetCount()); std::memmove(m_keys + i, m_keys + i + 1, sizeof(*m_keys) * (this->GetCount() - (i + 1))); this->DecrementCount(); } void IncrementCount() { m_header.entry_count++; } void DecrementCount() { m_header.entry_count--; } public: LruList() : m_keys(nullptr), m_header() { /* ... */ } Result Initialize(const char *path, void *buf, size_t size) { /* Only initialize once, and ensure we have sufficient memory. */ AMS_ABORT_UNLESS(m_keys == nullptr); AMS_ABORT_UNLESS(size >= BufferSize); /* Setup member variables. */ m_keys = static_cast<Key *>(buf); m_file_path.Assign(path); std::memset(m_keys, 0, BufferSize); /* Open file. */ fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), m_file_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Read header. */ R_TRY(fs::ReadFile(file, 0, std::addressof(m_header), sizeof(m_header))); /* Read entries. */ R_TRY(fs::ReadFile(file, sizeof(m_header), m_keys, BufferSize)); R_SUCCEED(); } Result Save() { /* Open file. */ fs::FileHandle file; R_TRY(fs::OpenFile(std::addressof(file), m_file_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Write header. */ R_TRY(fs::WriteFile(file, 0, std::addressof(m_header), sizeof(m_header), fs::WriteOption::None)); /* Write entries. */ R_TRY(fs::WriteFile(file, sizeof(m_header), m_keys, BufferSize, fs::WriteOption::None)); /* Flush. */ R_TRY(fs::FlushFile(file)); R_SUCCEED(); } size_t GetCount() const { return m_header.entry_count; } bool IsEmpty() const { return this->GetCount() == 0; } bool IsFull() const { return this->GetCount() >= Capacity; } Key Get(size_t i) const { AMS_ABORT_UNLESS(i < this->GetCount()); return m_keys[i]; } Key Peek() const { AMS_ABORT_UNLESS(!this->IsEmpty()); return this->Get(0); } void Push(const Key &key) { AMS_ABORT_UNLESS(!this->IsFull()); m_keys[this->GetCount()] = key; this->IncrementCount(); } Key Pop() { AMS_ABORT_UNLESS(!this->IsEmpty()); this->RemoveIndex(0); } bool Remove(const Key &key) { const size_t count = this->GetCount(); /* Iterate over the list, removing the last entry that matches the key. */ for (size_t i = 0; i < count; i++) { if (m_keys[count - 1 - i] == key) { this->RemoveIndex(count - 1 - i); return true; } } return false; } bool Contains(const Key &key) const { const size_t count = this->GetCount(); /* Iterate over the list, checking to see if we have the key. */ for (size_t i = 0; i < count; i++) { if (m_keys[count - 1 - i] == key) { return true; } } return false; } bool Update(const Key &key) { if (this->Remove(key)) { this->Push(key); return true; } return false; } }; } template<class Key, size_t Capacity> class FileKeyValueCache { static_assert(util::is_pod<Key>::value, "FileKeyValueCache Key must be pod!"); static_assert(sizeof(Key) <= FileKeyValueStore::MaxKeySize, "FileKeyValueCache Key is too big!"); public: using LeastRecentlyUsedList = impl::LruList<Key, Capacity>; /* Note: Nintendo code in NS uses Path = BoundedString<0x180> here. */ /* It's unclear why, since they use 0x300 everywhere else. */ /* We'll just use 0x300, since it shouldn't make a difference, */ /* as FileKeyValueStore paths are limited to 0x100 anyway. */ using Path = typename LeastRecentlyUsedList::Path; private: FileKeyValueStore m_kvs; LeastRecentlyUsedList m_lru_list; private: static constexpr Path GetLeastRecentlyUsedListPath(const char *dir) { return Path::MakeFormat("%s/%s", dir, "lru_list.dat"); } static constexpr Path GetFileKeyValueStorePath(const char *dir) { return Path::MakeFormat("%s/%s", dir, "kvs"); } static Result Exists(bool *out, const char *path, fs::DirectoryEntryType type) { /* Set out to false initially. */ *out = false; /* Try to get the entry type. */ fs::DirectoryEntryType entry_type; R_TRY_CATCH(fs::GetEntryType(std::addressof(entry_type), path)) { /* If the path doesn't exist, nothing has gone wrong. */ R_CONVERT(fs::ResultPathNotFound, ResultSuccess()); } R_END_TRY_CATCH; /* Check that the entry type is correct. */ R_UNLESS(entry_type == type, kvdb::ResultInvalidFilesystemState()); /* The entry exists and is the correct type. */ *out = true; R_SUCCEED(); } static Result DirectoryExists(bool *out, const char *path) { R_RETURN(Exists(out, path, fs::DirectoryEntryType_Directory)); } static Result FileExists(bool *out, const char *path) { R_RETURN(Exists(out, path, fs::DirectoryEntryType_File)); } public: static Result CreateNewCache(const char *dir) { /* Make a new key value store filesystem, and a new lru_list.dat. */ R_TRY(LeastRecentlyUsedList::CreateNewList(GetLeastRecentlyUsedListPath(dir))); R_TRY(fs::CreateDirectory(dir)); R_SUCCEED(); } static Result ValidateExistingCache(const char *dir) { /* Check for existence. */ bool has_lru = false, has_kvs = false; R_TRY(FileExists(std::addressof(has_lru), GetLeastRecentlyUsedListPath(dir))); R_TRY(DirectoryExists(std::addressof(has_kvs), GetFileKeyValueStorePath(dir))); /* If neither exists, CreateNewCache was never called. */ R_UNLESS(has_lru || has_kvs, kvdb::ResultNotCreated()); /* If one exists but not the other, we have an invalid state. */ R_UNLESS(has_lru && has_kvs, kvdb::ResultInvalidFilesystemState()); R_SUCCEED(); } private: void RemoveOldestKey() { const Key &oldest_key = m_lru_list.Peek(); m_lru_list.Pop(); m_kvs.Remove(oldest_key); } public: Result Initialize(const char *dir, void *buf, size_t size) { /* Initialize list. */ R_TRY(m_lru_list.Initialize(GetLeastRecentlyUsedListPath(dir), buf, size)); /* Initialize kvs. */ /* NOTE: Despite creating the kvs folder and returning an error if it does not exist, */ /* Nintendo does not use the kvs folder, and instead uses the passed dir. */ /* This causes lru_list.dat to be in the same directory as the store's .val files */ /* instead of in the same directory as a folder containing the store's .val files. */ /* This is probably a Nintendo bug, but because system saves contain data in the wrong */ /* layout it can't really be fixed without breaking existing devices... */ R_TRY(m_kvs.Initialize(dir)); R_SUCCEED(); } size_t GetCount() const { return m_lru_list.GetCount(); } size_t GetCapacity() const { return Capacity; } Key GetKey(size_t i) const { return m_lru_list.Get(i); } bool Contains(const Key &key) const { return m_lru_list.Contains(key); } Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { /* Note that we accessed the key. */ m_lru_list.Update(key); R_RETURN(m_kvs.Get(out_size, out_value, max_out_size, key)); } template<typename Value> Result Get(Value *out_value, const Key &key) { /* Note that we accessed the key. */ m_lru_list.Update(key); R_RETURN(m_kvs.Get(out_value, key)); } Result GetSize(size_t *out_size, const Key &key) { R_RETURN(m_kvs.GetSize(out_size, key)); } Result Set(const Key &key, const void *value, size_t value_size) { if (m_lru_list.Update(key)) { /* If an entry for the key exists, delete the existing value file. */ m_kvs.Remove(key); } else { /* If the list is full, we need to remove the oldest key. */ if (m_lru_list.IsFull()) { this->RemoveOldestKey(); } /* Add the key to the list. */ m_lru_list.Push(key); } /* Loop, trying to save the new value to disk. */ while (true) { /* Try to set the key. */ R_TRY_CATCH(m_kvs.Set(key, value, value_size)) { R_CATCH(fs::ResultNotEnoughFreeSpace) { /* If our entry is the only thing in the Lru list, remove it. */ if (m_lru_list.GetCount() == 1) { m_lru_list.Pop(); R_TRY(m_lru_list.Save()); R_THROW(fs::ResultNotEnoughFreeSpace()); } /* Otherwise, remove the oldest element from the cache and try again. */ this->RemoveOldestKey(); continue; } } R_END_TRY_CATCH; /* If we got here, we succeeded. */ break; } /* Save the list. */ R_TRY(m_lru_list.Save()); R_SUCCEED(); } template<typename Value> Result Set(const Key &key, const Value &value) { R_RETURN(this->Set(key, &value, sizeof(Value))); } Result Remove(const Key &key) { /* Remove the key. */ m_lru_list.Remove(key); R_TRY(m_kvs.Remove(key)); R_TRY(m_lru_list.Save()); R_SUCCEED(); } Result RemoveAll() { /* TODO: Nintendo doesn't check errors here. Should we? */ while (!m_lru_list.IsEmpty()) { this->RemoveOldestKey(); } R_TRY(m_lru_list.Save()); R_SUCCEED(); } }; }
14,830
C++
.h
312
30.737179
122
0.481105
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
7,747
kvdb_file_key_value_store.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <stratosphere/os.hpp> #include <stratosphere/fs/fs_directory.hpp> #include <stratosphere/kvdb/kvdb_bounded_string.hpp> namespace ams::kvdb { class FileKeyValueStore { NON_COPYABLE(FileKeyValueStore); NON_MOVEABLE(FileKeyValueStore); public: static constexpr size_t MaxFileLength = 0xFF; static constexpr char FileExtension[5] = ".val"; static constexpr size_t FileExtensionLength = sizeof(FileExtension) - 1; static constexpr size_t MaxKeySize = (MaxFileLength - FileExtensionLength) / 2; using Path = kvdb::BoundedString<fs::EntryNameLengthMax>; using FileName = kvdb::BoundedString<MaxFileLength>; private: /* Subtypes. */ struct Entry { u8 key[MaxKeySize]; void *value; size_t key_size; size_t value_size; }; static_assert(util::is_pod<Entry>::value, "FileKeyValueStore::Entry definition!"); class Cache { private: u8 *m_backing_buffer = nullptr; size_t m_backing_buffer_size = 0; size_t m_backing_buffer_free_offset = 0; Entry *m_entries = nullptr; size_t m_count = 0; size_t m_capacity = 0; private: void *Allocate(size_t size); bool HasEntries() const { return m_entries != nullptr && m_capacity != 0; } public: Result Initialize(void *buffer, size_t buffer_size, size_t capacity); void Invalidate(); util::optional<size_t> TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size); util::optional<size_t> TryGetSize(const void *key, size_t key_size); void Set(const void *key, size_t key_size, const void *value, size_t value_size); bool Contains(const void *key, size_t key_size); }; private: os::SdkMutex m_lock; Path m_dir_path; Cache m_cache; private: Path GetPath(const void *key, size_t key_size); Result GetKey(size_t *out_size, void *out_key, size_t max_out_size, const FileName &file_name); public: FileKeyValueStore() : m_lock() { /* ... */ } /* Basic accessors. */ Result Initialize(const char *dir); Result InitializeWithCache(const char *dir, void *cache_buffer, size_t cache_buffer_size, size_t cache_capacity); Result Get(size_t *out_size, void *out_value, size_t max_out_size, const void *key, size_t key_size); Result GetSize(size_t *out_size, const void *key, size_t key_size); Result Set(const void *key, size_t key_size, const void *value, size_t value_size); Result Remove(const void *key, size_t key_size); /* Niceties. */ template<typename Key> Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { static_assert(util::is_pod<Key>::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); R_RETURN(this->Get(out_size, out_value, max_out_size, std::addressof(key), sizeof(Key))); } template<typename Key, typename Value> Result Get(Value *out_value, const Key &key) { static_assert(util::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!"); size_t size = 0; R_TRY(this->Get(std::addressof(size), out_value, sizeof(Value), key)); AMS_ABORT_UNLESS(size >= sizeof(Value)); R_SUCCEED(); } template<typename Key> Result GetSize(size_t *out_size, const Key &key) { R_RETURN(this->GetSize(out_size, std::addressof(key), sizeof(Key))); } template<typename Key> Result Set(const Key &key, const void *value, size_t value_size) { static_assert(util::is_pod<Key>::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); R_RETURN(this->Set(std::addressof(key), sizeof(Key), value, value_size)); } template<typename Key, typename Value> Result Set(const Key &key, const Value &value) { static_assert(util::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!"); R_RETURN(this->Set(key, std::addressof(value), sizeof(Value))); } template<typename Key> Result Remove(const Key &key) { R_RETURN(this->Remove(std::addressof(key), sizeof(Key))); } }; }
5,626
C++
.h
110
38.681818
128
0.5802
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
7,748
kvdb_auto_buffer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> namespace ams::kvdb { class AutoBuffer { NON_COPYABLE(AutoBuffer); private: u8 *m_buffer; size_t m_size; public: AutoBuffer() : m_buffer(nullptr), m_size(0) { /* ... */ } ~AutoBuffer() { this->Reset(); } AutoBuffer(AutoBuffer &&rhs) { m_buffer = rhs.m_buffer; m_size = rhs.m_size; rhs.m_buffer = nullptr; rhs.m_size = 0; } AutoBuffer &operator=(AutoBuffer &&rhs) { AutoBuffer(std::move(rhs)).Swap(*this); return *this; } void Swap(AutoBuffer &rhs) { std::swap(m_buffer, rhs.m_buffer); std::swap(m_size, rhs.m_size); } void Reset() { if (m_buffer != nullptr) { delete[] m_buffer; m_buffer = nullptr; m_size = 0; } } u8 *Get() const { return m_buffer; } size_t GetSize() const { return m_size; } Result Initialize(size_t size) { /* Check that we're not already initialized. */ AMS_ABORT_UNLESS(m_buffer == nullptr); /* Allocate a buffer. */ m_buffer = new (std::nothrow) u8[size]; R_UNLESS(m_buffer != nullptr, kvdb::ResultAllocationFailed()); m_size = size; R_SUCCEED(); } Result Initialize(const void *buf, size_t size) { /* Create a new buffer of the right size. */ R_TRY(this->Initialize(size)); /* Copy the input data in. */ std::memcpy(m_buffer, buf, size); R_SUCCEED(); } }; }
2,611
C++
.h
73
24.191781
78
0.507528
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
7,749
kvdb_archive.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.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/kvdb/kvdb_auto_buffer.hpp> namespace ams::kvdb { /* Functionality for parsing/generating a key value archive. */ class ArchiveReader { private: AutoBuffer &m_buffer; size_t m_offset; public: ArchiveReader(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ } private: Result Peek(void *dst, size_t size); Result Read(void *dst, size_t size); public: Result ReadEntryCount(size_t *out); Result GetEntrySize(size_t *out_key_size, size_t *out_value_size); Result ReadEntry(void *out_key, size_t key_size, void *out_value, size_t value_size); }; class ArchiveWriter { private: AutoBuffer &m_buffer; size_t m_offset; public: ArchiveWriter(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ } private: Result Write(const void *src, size_t size); public: void WriteHeader(size_t entry_count); void WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size); }; class ArchiveSizeHelper { private: size_t m_size; public: ArchiveSizeHelper(); void AddEntry(size_t key_size, size_t value_size); size_t GetSize() const { return m_size; } }; }
2,089
C++
.h
56
29.660714
100
0.621115
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
7,750
time_standard_steady_clock.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_standard_steady_clock.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> #include <stratosphere/time/time_steady_clock_time_point.hpp> namespace ams::time { class StandardSteadyClock { public: using rep = s64; using period = std::ratio<1>; using duration = std::chrono::duration<rep, period>; using time_point = std::chrono::time_point<StandardSteadyClock>; static constexpr bool is_steady = true; public: static time_point now(); public: static Result GetCurrentTimePoint(SteadyClockTimePoint *out); }; Result GetStandardSteadyClockCurrentTimePoint(SteadyClockTimePoint *out); TimeSpan GetStandardSteadyClockInternalOffset(); }
1,413
C++
.h
35
35.314286
77
0.709607
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
7,751
time_steady_clock_time_point.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_steady_clock_time_point.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> namespace ams::time { struct SteadyClockTimePoint { s64 value; SourceId source_id; constexpr SteadyClockTimePoint &operator+=(const TimeSpan &ts) { this->value += ts.GetSeconds(); return *this; } constexpr SteadyClockTimePoint &operator-=(const TimeSpan &ts) { this->value -= ts.GetSeconds(); return *this; } constexpr friend SteadyClockTimePoint operator+(const SteadyClockTimePoint &lhs, const TimeSpan &rhs) { return { .value = lhs.value + rhs.GetSeconds(), .source_id = lhs.source_id }; } constexpr friend SteadyClockTimePoint operator-(const SteadyClockTimePoint &lhs, const TimeSpan &rhs) { return { .value = lhs.value - rhs.GetSeconds(), .source_id = lhs.source_id }; } constexpr friend bool operator==(const SteadyClockTimePoint &lhs, const SteadyClockTimePoint &rhs) { return lhs.value == rhs.value && lhs.source_id == rhs.source_id; } constexpr friend bool operator!=(const SteadyClockTimePoint &lhs, const SteadyClockTimePoint &rhs) { return !(lhs == rhs); } }; }
1,769
C++
.h
30
54.9
191
0.728217
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
7,752
time_calendar_time.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_calendar_time.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> namespace ams::time { struct CalendarTime { s16 year; s8 month; s8 day; s8 hour; s8 minute; s8 second; bool IsValid() const; CalendarTime &operator+=(const TimeSpan &ts); CalendarTime &operator-=(const TimeSpan &ts); friend CalendarTime operator+(const CalendarTime &lhs, const TimeSpan &rhs); friend CalendarTime operator-(const CalendarTime &lhs, const TimeSpan &rhs); friend TimeSpan operator-(const CalendarTime &lhs, const CalendarTime &rhs); constexpr friend bool operator==(const CalendarTime &lhs, const CalendarTime &rhs) { return lhs.year == rhs.year && lhs.month == rhs.month && lhs.day == rhs.day && lhs.hour == rhs.hour && lhs.minute == rhs.minute && lhs.second == rhs.second; } constexpr friend bool operator!=(const CalendarTime &lhs, const CalendarTime &rhs) { return !(lhs == rhs); } constexpr friend bool operator<=(const CalendarTime &lhs, const CalendarTime &rhs) { return !(rhs < lhs); } constexpr friend bool operator>=(const CalendarTime &lhs, const CalendarTime &rhs) { return !(lhs < rhs); } constexpr friend bool operator> (const CalendarTime &lhs, const CalendarTime &rhs) { return rhs < lhs; } constexpr friend bool operator< (const CalendarTime &lhs, const CalendarTime &rhs) { if (!std::is_constant_evaluated()) { AMS_ASSERT(lhs.IsValid()); AMS_ASSERT(rhs.IsValid()); } constexpr auto ToUint64 = [](const time::CalendarTime &time) ALWAYS_INLINE_LAMBDA { return (static_cast<u64>(time.year) << 40) | (static_cast<u64>(time.month) << 32) | (static_cast<u64>(time.day) << 24) | (static_cast<u64>(time.hour) << 16) | (static_cast<u64>(time.minute) << 8) | (static_cast<u64>(time.second) << 0); }; return ToUint64(lhs) < ToUint64(rhs); } }; static_assert(sizeof(CalendarTime) == sizeof(u64)); }
2,845
C++
.h
55
43.218182
251
0.635709
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
7,753
time_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> #include <stratosphere/time/time_posix_time.hpp> #include <stratosphere/time/time_steady_clock_time_point.hpp> namespace ams::time { Result Initialize(); Result InitializeForSystem(); Result InitializeForSystemUser(); Result Finalize(); bool IsInitialized(); bool IsValidDate(int year, int month, int day); Result GetElapsedSecondsBetween(s64 *out, const SteadyClockTimePoint &from, const SteadyClockTimePoint &to); }
1,169
C++
.h
29
37.62069
112
0.764342
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
7,754
time_timezone_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_timezone_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 <vapours.hpp> #include <stratosphere/time/time_calendar_time.hpp> #include <stratosphere/time/time_posix_time.hpp> namespace ams::time { CalendarTime ToCalendarTimeInUtc(const PosixTime &posix_time); PosixTime ToPosixTimeFromUtc(const CalendarTime &calendar_time); }
935
C++
.h
23
38.565217
76
0.773377
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
7,755
time_standard_network_system_clock.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_standard_network_system_clock.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> #include <stratosphere/time/time_system_clock_common.hpp> #include <stratosphere/time/time_posix_time.hpp> namespace ams::time { class StandardNetworkSystemClock { public: using rep = SystemClockTraits::rep; using period = SystemClockTraits::period; using duration = SystemClockTraits::duration; using time_point = SystemClockTraits::time_point; static constexpr bool is_steady = false; public: static time_point now(); static std::time_t to_time_t(const StandardUserSystemClock::time_point &t); static time_point from_time_t(std::time_t t); public: static Result GetCurrentTime(PosixTime *out); /* TODO: static Result GetSystemClockContext(SystemClockContext *out); */ }; }
1,559
C++
.h
37
36.567568
87
0.698486
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
7,756
time_common.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_common.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 <vapours.hpp> namespace ams::time { using SourceId = util::Uuid; }
731
C++
.h
20
34.5
76
0.752825
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
7,757
time_standard_user_system_clock.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_standard_user_system_clock.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> #include <stratosphere/time/time_system_clock_common.hpp> #include <stratosphere/time/time_posix_time.hpp> namespace ams::time { class StandardUserSystemClock { public: using rep = SystemClockTraits::rep; using period = SystemClockTraits::period; using duration = SystemClockTraits::duration; using time_point = SystemClockTraits::time_point; static constexpr bool is_steady = false; public: static time_point now(); static std::time_t to_time_t(const StandardUserSystemClock::time_point &t); static time_point from_time_t(std::time_t t); public: static Result GetCurrentTime(PosixTime *out); /* TODO: static Result GetSystemClockContext(SystemClockContext *out); */ }; }
1,556
C++
.h
37
36.486486
87
0.697889
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
7,758
time_system_clock_common.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_system_clock_common.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> namespace ams::time { class SystemClockTraits { public: using rep = s64; using period = std::ratio<1>; using duration = std::chrono::duration<rep, period>; using time_point = std::chrono::time_point<SystemClockTraits>; }; }
1,020
C++
.h
27
33.777778
76
0.70202
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
7,759
time_posix_time.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/time_posix_time.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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> namespace ams::time { struct PosixTime { s64 value; constexpr PosixTime &operator+=(const TimeSpan &ts) { this->value += ts.GetSeconds(); return *this; } constexpr PosixTime &operator-=(const TimeSpan &ts) { this->value -= ts.GetSeconds(); return *this; } constexpr friend PosixTime operator+(const PosixTime &lhs, const TimeSpan &rhs) { return { .value = lhs.value + rhs.GetSeconds() }; } constexpr friend PosixTime operator-(const PosixTime &lhs, const TimeSpan &rhs) { return { .value = lhs.value - rhs.GetSeconds() }; } constexpr friend TimeSpan operator-(const PosixTime &lhs, const PosixTime &rhs) { return TimeSpan::FromSeconds(lhs.value - rhs.value); } constexpr friend bool operator==(const PosixTime &lhs, const PosixTime &rhs) { return lhs.value == rhs.value; } constexpr friend bool operator!=(const PosixTime &lhs, const PosixTime &rhs) { return lhs.value != rhs.value; } constexpr friend bool operator<=(const PosixTime &lhs, const PosixTime &rhs) { return lhs.value <= rhs.value; } constexpr friend bool operator>=(const PosixTime &lhs, const PosixTime &rhs) { return lhs.value >= rhs.value; } constexpr friend bool operator< (const PosixTime &lhs, const PosixTime &rhs) { return lhs.value < rhs.value; } constexpr friend bool operator> (const PosixTime &lhs, const PosixTime &rhs) { return lhs.value > rhs.value; } }; static_assert(sizeof(PosixTime) == sizeof(s64)); }
2,218
C++
.h
35
58.685714
144
0.711857
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
7,760
time_impl_util_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time/impl/util/time_impl_util_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 <vapours.hpp> #include <stratosphere/time/time_common.hpp> #include <stratosphere/time/time_posix_time.hpp> #include <stratosphere/time/time_steady_clock_time_point.hpp> namespace ams::time::impl::util { Result GetSpanBetween(s64 *out, const SteadyClockTimePoint &from, const SteadyClockTimePoint &to); bool IsLeapYear(int year); bool IsValidDate(int year, int month, int day); int GetDaysInMonth(int year, int month); int DateToDays(int year, int month, int day); void DaysToDate(int *out_year, int *out_month, int *out_day, int days); CalendarTime ToCalendarTimeInUtc(const PosixTime &posix_time); PosixTime ToPosixTimeFromUtc(const CalendarTime &calendar_time); }
1,363
C++
.h
30
42.666667
102
0.762443
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
7,761
gpio_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/gpio_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 <vapours.hpp> namespace ams::gpio { enum InterruptMode : u32 { InterruptMode_LowLevel = 0, InterruptMode_HighLevel = 1, InterruptMode_RisingEdge = 2, InterruptMode_FallingEdge = 3, InterruptMode_AnyEdge = 4, }; enum Direction : u32 { Direction_Input = 0, Direction_Output = 1, }; enum GpioValue : u32 { GpioValue_Low = 0, GpioValue_High = 1, }; enum InterruptStatus : u32 { InterruptStatus_Inactive = 0, InterruptStatus_Active = 1, }; enum WakePinDebugMode { WakePinDebugMode_AutoImmediateWake = 1, WakePinDebugMode_NoWake = 2, }; using WakeBitFlag = util::BitFlagSet<128>; }
1,414
C++
.h
43
27.930233
76
0.671313
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
7,762
gpio_pad_name.generic.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/gpio_pad_name.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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> namespace ams::gpio { enum GpioPadName : u32 { GpioPadName_EnableSdCardPower = 2, }; constexpr inline const DeviceCode DeviceCode_EnableSdCardPower = 0x3C000001; constexpr inline GpioPadName ConvertToGpioPadName(DeviceCode dc) { switch (dc.GetInternalValue()) { case DeviceCode_EnableSdCardPower.GetInternalValue(): return GpioPadName_EnableSdCardPower; AMS_UNREACHABLE_DEFAULT_CASE(); } } constexpr inline DeviceCode ConvertToDeviceCode(GpioPadName gpn) { switch (gpn) { case GpioPadName_EnableSdCardPower: return DeviceCode_EnableSdCardPower; AMS_UNREACHABLE_DEFAULT_CASE(); } } }
1,419
C++
.h
36
34.666667
103
0.730044
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
7,763
gpio_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/gpio_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/sf/gpio_sf_i_manager.hpp> namespace ams::gpio { void Initialize(); void Finalize(); void InitializeWith(ams::sf::SharedPointer<gpio::sf::IManager> sp); }
913
C++
.h
24
35.791667
76
0.753672
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
7,764
gpio_pad_name.board.nintendo_nx.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/gpio_pad_name.board.nintendo_nx.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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> namespace ams::gpio { enum GpioPadName : u32 { GpioPadName_CodecLdoEnTemp = 1, GpioPadName_PowSdEn = 2, GpioPadName_BtRst = 3, GpioPadName_RamCode3 = 4, GpioPadName_GameCardReset = 5, GpioPadName_CodecAlert = 6, GpioPadName_PowGc = 7, GpioPadName_DebugControllerDet = 8, GpioPadName_BattChgStatus = 9, GpioPadName_BattChgEnableN = 10, GpioPadName_FanTach = 11, GpioPadName_ExtconDetS = 12, GpioPadName_Vdd50AEn = 13, GpioPadName_SdevCoaxSel1 = 14, GpioPadName_GameCardCd = 15, GpioPadName_ProdType0 = 16, GpioPadName_ProdType1 = 17, GpioPadName_ProdType2 = 18, GpioPadName_ProdType3 = 19, GpioPadName_TempAlert = 20, GpioPadName_CodecHpDetIrq = 21, GpioPadName_MotionInt = 22, GpioPadName_TpIrq = 23, GpioPadName_ButtonSleep2 = 24, GpioPadName_ButtonVolUp = 25, GpioPadName_ButtonVolDn = 26, GpioPadName_BattMgicIrq = 27, GpioPadName_RecoveryKey = 28, GpioPadName_PowLcdBlEn = 29, GpioPadName_LcdReset = 30, GpioPadName_PdVconnEn = 31, GpioPadName_PdRstN = 32, GpioPadName_Bq24190Irq = 33, GpioPadName_SdevCoaxSel0 = 34, GpioPadName_SdWp = 35, GpioPadName_TpReset = 36, GpioPadName_BtGpio2 = 37, GpioPadName_BtGpio3 = 38, GpioPadName_BtGpio4 = 39, GpioPadName_CradleIrq = 40, GpioPadName_PowVcpuInt = 41, GpioPadName_Max77621GpuInt = 42, GpioPadName_ExtconChgU = 43, GpioPadName_ExtconChgS = 44, GpioPadName_WifiRfDisable = 45, GpioPadName_WifiReset = 46, GpioPadName_ApWakeBt = 47, GpioPadName_BtWakeAp = 48, GpioPadName_BtGpio5 = 49, GpioPadName_PowLcdVddPEn = 50, GpioPadName_PowLcdVddNEn = 51, GpioPadName_ExtconDetU = 52, GpioPadName_RamCode2 = 53, GpioPadName_Vdd50BEn = 54, GpioPadName_WifiWakeHost = 55, GpioPadName_SdCd = 56, GpioPadName_OtgFet1ForSdev = 57, GpioPadName_OtgFet2ForSdev = 58, GpioPadName_ExtConWakeU = 59, GpioPadName_ExtConWakeS = 60, GpioPadName_PmuIrq = 61, GpioPadName_ExtUart2Cts = 62, GpioPadName_ExtUart3Cts = 63, GpioPadName_5VStepDownEn = 64, GpioPadName_UsbSwitchB2Oc = 65, GpioPadName_5VStepDownPg = 66, GpioPadName_UsbSwitchAEn = 67, GpioPadName_UsbSwitchAFlag = 68, GpioPadName_UsbSwitchB3Oc = 69, GpioPadName_UsbSwitchB3En = 70, GpioPadName_UsbSwitchB2En = 71, GpioPadName_Hdmi5VEn = 72, GpioPadName_UsbSwitchB1En = 73, GpioPadName_HdmiPdTrEn = 74, GpioPadName_FanEn = 75, GpioPadName_UsbSwitchB1Oc = 76, GpioPadName_PwmFan = 77, GpioPadName_HdmiHpd = 78, GpioPadName_Max77812Irq = 79, GpioPadName_Debug0 = 80, GpioPadName_Debug1 = 81, GpioPadName_Debug2 = 82, GpioPadName_Debug3 = 83, GpioPadName_NfcIrq = 84, GpioPadName_NfcRst = 85, GpioPadName_McuIrq = 86, GpioPadName_McuBoot = 87, GpioPadName_McuRst = 88, GpioPadName_Vdd5V3En = 89, GpioPadName_McuPor = 90, GpioPadName_LcdGpio1 = 91, GpioPadName_NfcEn = 92, }; constexpr inline const DeviceCode DeviceCode_CodecLdoEnTemp = 0x33000002; constexpr inline const DeviceCode DeviceCode_PowSdEn = 0x3C000001; constexpr inline const DeviceCode DeviceCode_BtRst = 0x37000002; constexpr inline const DeviceCode DeviceCode_RamCode3 = 0xC9000402; constexpr inline const DeviceCode DeviceCode_GameCardReset = 0x3C000402; constexpr inline const DeviceCode DeviceCode_CodecAlert = 0x33000003; constexpr inline const DeviceCode DeviceCode_PowGc = 0x3C000401; constexpr inline const DeviceCode DeviceCode_DebugControllerDet = 0x350000CA; constexpr inline const DeviceCode DeviceCode_BattChgStatus = 0x39000407; constexpr inline const DeviceCode DeviceCode_BattChgEnableN = 0x39000003; constexpr inline const DeviceCode DeviceCode_FanTach = 0x3D000002; constexpr inline const DeviceCode DeviceCode_ExtconDetS = 0x3500040B; constexpr inline const DeviceCode DeviceCode_Vdd50AEn = 0x39000401; constexpr inline const DeviceCode DeviceCode_SdevCoaxSel1 = 0xCA000406; constexpr inline const DeviceCode DeviceCode_GameCardCd = 0x3C000403; constexpr inline const DeviceCode DeviceCode_ProdType0 = 0xC900040B; constexpr inline const DeviceCode DeviceCode_ProdType1 = 0xC900040C; constexpr inline const DeviceCode DeviceCode_ProdType2 = 0xC900040D; constexpr inline const DeviceCode DeviceCode_ProdType3 = 0xC900040E; constexpr inline const DeviceCode DeviceCode_TempAlert = 0x3E000002; constexpr inline const DeviceCode DeviceCode_CodecHpDetIrq = 0x33000004; constexpr inline const DeviceCode DeviceCode_MotionInt = 0x35000041; constexpr inline const DeviceCode DeviceCode_TpIrq = 0x35000036; constexpr inline const DeviceCode DeviceCode_ButtonSleep2 = 0x35000001; constexpr inline const DeviceCode DeviceCode_ButtonVolUp = 0x35000002; constexpr inline const DeviceCode DeviceCode_ButtonVolDn = 0x35000003; constexpr inline const DeviceCode DeviceCode_BattMgicIrq = 0x39000034; constexpr inline const DeviceCode DeviceCode_RecoveryKey = 0x35000004; constexpr inline const DeviceCode DeviceCode_PowLcdBlEn = 0x3400003E; constexpr inline const DeviceCode DeviceCode_LcdReset = 0x34000033; constexpr inline const DeviceCode DeviceCode_PdVconnEn = 0x040000CC; constexpr inline const DeviceCode DeviceCode_PdRstN = 0x040000CA; constexpr inline const DeviceCode DeviceCode_Bq24190Irq = 0x39000002; constexpr inline const DeviceCode DeviceCode_SdevCoaxSel0 = 0xCA000405; constexpr inline const DeviceCode DeviceCode_SdWp = 0x3C000003; constexpr inline const DeviceCode DeviceCode_TpReset = 0x35000035; constexpr inline const DeviceCode DeviceCode_BtGpio2 = 0x37000401; constexpr inline const DeviceCode DeviceCode_BtGpio3 = 0x37000402; constexpr inline const DeviceCode DeviceCode_BtGpio4 = 0x37000403; constexpr inline const DeviceCode DeviceCode_CradleIrq = 0x040000CB; constexpr inline const DeviceCode DeviceCode_PowVcpuInt = 0x3E000003; constexpr inline const DeviceCode DeviceCode_Max77621GpuInt = 0x3E000004; constexpr inline const DeviceCode DeviceCode_ExtconChgU = 0x35000402; constexpr inline const DeviceCode DeviceCode_ExtconChgS = 0x3500040C; constexpr inline const DeviceCode DeviceCode_WifiRfDisable = 0x38000003; constexpr inline const DeviceCode DeviceCode_WifiReset = 0x38000002; constexpr inline const DeviceCode DeviceCode_ApWakeBt = 0x37000003; constexpr inline const DeviceCode DeviceCode_BtWakeAp = 0x37000004; constexpr inline const DeviceCode DeviceCode_BtGpio5 = 0x37000404; constexpr inline const DeviceCode DeviceCode_PowLcdVddPEn = 0x34000034; constexpr inline const DeviceCode DeviceCode_PowLcdVddNEn = 0x34000035; constexpr inline const DeviceCode DeviceCode_ExtconDetU = 0x35000401; constexpr inline const DeviceCode DeviceCode_RamCode2 = 0xC9000401; constexpr inline const DeviceCode DeviceCode_Vdd50BEn = 0x39000402; constexpr inline const DeviceCode DeviceCode_WifiWakeHost = 0x38000004; constexpr inline const DeviceCode DeviceCode_SdCd = 0x3C000002; constexpr inline const DeviceCode DeviceCode_OtgFet1ForSdev = 0x39000404; constexpr inline const DeviceCode DeviceCode_OtgFet2ForSdev = 0x39000405; constexpr inline const DeviceCode DeviceCode_ExtConWakeU = 0x35000403; constexpr inline const DeviceCode DeviceCode_ExtConWakeS = 0x3500040D; constexpr inline const DeviceCode DeviceCode_PmuIrq = 0x39000406; constexpr inline const DeviceCode DeviceCode_ExtUart2Cts = 0x35000404; constexpr inline const DeviceCode DeviceCode_ExtUart3Cts = 0x3500040E; constexpr inline const DeviceCode DeviceCode_5VStepDownEn = 0x39000408; constexpr inline const DeviceCode DeviceCode_UsbSwitchB2Oc = 0x04000401; constexpr inline const DeviceCode DeviceCode_5VStepDownPg = 0x39000409; constexpr inline const DeviceCode DeviceCode_UsbSwitchAEn = 0x04000402; constexpr inline const DeviceCode DeviceCode_UsbSwitchAFlag = 0x04000403; constexpr inline const DeviceCode DeviceCode_UsbSwitchB3Oc = 0x04000404; constexpr inline const DeviceCode DeviceCode_UsbSwitchB3En = 0x04000405; constexpr inline const DeviceCode DeviceCode_UsbSwitchB2En = 0x04000406; constexpr inline const DeviceCode DeviceCode_Hdmi5VEn = 0x34000004; constexpr inline const DeviceCode DeviceCode_UsbSwitchB1En = 0x04000407; constexpr inline const DeviceCode DeviceCode_HdmiPdTrEn = 0x34000005; constexpr inline const DeviceCode DeviceCode_FanEn = 0x3D000003; constexpr inline const DeviceCode DeviceCode_UsbSwitchB1Oc = 0x04000408; constexpr inline const DeviceCode DeviceCode_PwmFan = 0x3D000001; constexpr inline const DeviceCode DeviceCode_HdmiHpd = 0x34000006; constexpr inline const DeviceCode DeviceCode_Max77812Irq = 0x3E000003; constexpr inline const DeviceCode DeviceCode_Debug0 = 0xCA000001; constexpr inline const DeviceCode DeviceCode_Debug1 = 0xCA000002; constexpr inline const DeviceCode DeviceCode_Debug2 = 0xCA000003; constexpr inline const DeviceCode DeviceCode_Debug3 = 0xCA000004; constexpr inline const DeviceCode DeviceCode_NfcIrq = 0x36000004; constexpr inline const DeviceCode DeviceCode_NfcRst = 0x36000003; constexpr inline const DeviceCode DeviceCode_McuIrq = 0x35000415; constexpr inline const DeviceCode DeviceCode_McuBoot = 0x35000416; constexpr inline const DeviceCode DeviceCode_McuRst = 0x35000417; constexpr inline const DeviceCode DeviceCode_Vdd5V3En = 0x39000403; constexpr inline const DeviceCode DeviceCode_McuPor = 0x35000418; constexpr inline const DeviceCode DeviceCode_LcdGpio1 = 0x35000005; constexpr inline const DeviceCode DeviceCode_NfcEn = 0x36000002; constexpr inline const DeviceCode DeviceCode_ExtUart2Rts = 0x35000406; constexpr inline const DeviceCode DeviceCode_ExtUart3Rts = 0x35000410; constexpr inline const DeviceCode DeviceCode_GpioPortC7 = 0x3500041B; constexpr inline const DeviceCode DeviceCode_GpioPortD0 = 0x3500041C; constexpr inline const DeviceCode DeviceCode_GpioPortC5 = 0x3500041D; constexpr inline const DeviceCode DeviceCode_GpioPortC6 = 0x3500041E; constexpr inline const DeviceCode DeviceCode_GpioPortY7 = 0x35000065; constexpr inline const DeviceCode DeviceCode_GpioPortF1 = 0x04000409; constexpr inline const DeviceCode DeviceCode_GpioPortH0 = 0x34000401; constexpr inline const DeviceCode DeviceCode_GpioPortI6 = 0x37000405; constexpr inline GpioPadName ConvertToGpioPadName(DeviceCode dc) { switch (dc.GetInternalValue()) { case DeviceCode_CodecLdoEnTemp .GetInternalValue(): return GpioPadName_CodecLdoEnTemp; case DeviceCode_PowSdEn .GetInternalValue(): return GpioPadName_PowSdEn; case DeviceCode_BtRst .GetInternalValue(): return GpioPadName_BtRst; case DeviceCode_RamCode3 .GetInternalValue(): return GpioPadName_RamCode3; case DeviceCode_GameCardReset .GetInternalValue(): return GpioPadName_GameCardReset; case DeviceCode_CodecAlert .GetInternalValue(): return GpioPadName_CodecAlert; case DeviceCode_PowGc .GetInternalValue(): return GpioPadName_PowGc; case DeviceCode_DebugControllerDet.GetInternalValue(): return GpioPadName_DebugControllerDet; case DeviceCode_BattChgStatus .GetInternalValue(): return GpioPadName_BattChgStatus; case DeviceCode_BattChgEnableN .GetInternalValue(): return GpioPadName_BattChgEnableN; case DeviceCode_FanTach .GetInternalValue(): return GpioPadName_FanTach; case DeviceCode_ExtconDetS .GetInternalValue(): return GpioPadName_ExtconDetS; case DeviceCode_Vdd50AEn .GetInternalValue(): return GpioPadName_Vdd50AEn; case DeviceCode_SdevCoaxSel1 .GetInternalValue(): return GpioPadName_SdevCoaxSel1; case DeviceCode_GameCardCd .GetInternalValue(): return GpioPadName_GameCardCd; case DeviceCode_ProdType0 .GetInternalValue(): return GpioPadName_ProdType0; case DeviceCode_ProdType1 .GetInternalValue(): return GpioPadName_ProdType1; case DeviceCode_ProdType2 .GetInternalValue(): return GpioPadName_ProdType2; case DeviceCode_ProdType3 .GetInternalValue(): return GpioPadName_ProdType3; case DeviceCode_TempAlert .GetInternalValue(): return GpioPadName_TempAlert; case DeviceCode_CodecHpDetIrq .GetInternalValue(): return GpioPadName_CodecHpDetIrq; case DeviceCode_MotionInt .GetInternalValue(): return GpioPadName_MotionInt; case DeviceCode_TpIrq .GetInternalValue(): return GpioPadName_TpIrq; case DeviceCode_ButtonSleep2 .GetInternalValue(): return GpioPadName_ButtonSleep2; case DeviceCode_ButtonVolUp .GetInternalValue(): return GpioPadName_ButtonVolUp; case DeviceCode_ButtonVolDn .GetInternalValue(): return GpioPadName_ButtonVolDn; case DeviceCode_BattMgicIrq .GetInternalValue(): return GpioPadName_BattMgicIrq; case DeviceCode_RecoveryKey .GetInternalValue(): return GpioPadName_RecoveryKey; case DeviceCode_PowLcdBlEn .GetInternalValue(): return GpioPadName_PowLcdBlEn; case DeviceCode_LcdReset .GetInternalValue(): return GpioPadName_LcdReset; case DeviceCode_PdVconnEn .GetInternalValue(): return GpioPadName_PdVconnEn; case DeviceCode_PdRstN .GetInternalValue(): return GpioPadName_PdRstN; case DeviceCode_Bq24190Irq .GetInternalValue(): return GpioPadName_Bq24190Irq; case DeviceCode_SdevCoaxSel0 .GetInternalValue(): return GpioPadName_SdevCoaxSel0; case DeviceCode_SdWp .GetInternalValue(): return GpioPadName_SdWp; case DeviceCode_TpReset .GetInternalValue(): return GpioPadName_TpReset; case DeviceCode_BtGpio2 .GetInternalValue(): return GpioPadName_BtGpio2; case DeviceCode_BtGpio3 .GetInternalValue(): return GpioPadName_BtGpio3; case DeviceCode_BtGpio4 .GetInternalValue(): return GpioPadName_BtGpio4; case DeviceCode_CradleIrq .GetInternalValue(): return GpioPadName_CradleIrq; /* case DeviceCode_PowVcpuInt .GetInternalValue(): return GpioPadName_PowVcpuInt; */ case DeviceCode_Max77621GpuInt .GetInternalValue(): return GpioPadName_Max77621GpuInt; case DeviceCode_ExtconChgU .GetInternalValue(): return GpioPadName_ExtconChgU; case DeviceCode_ExtconChgS .GetInternalValue(): return GpioPadName_ExtconChgS; case DeviceCode_WifiRfDisable .GetInternalValue(): return GpioPadName_WifiRfDisable; case DeviceCode_WifiReset .GetInternalValue(): return GpioPadName_WifiReset; case DeviceCode_ApWakeBt .GetInternalValue(): return GpioPadName_ApWakeBt; case DeviceCode_BtWakeAp .GetInternalValue(): return GpioPadName_BtWakeAp; case DeviceCode_BtGpio5 .GetInternalValue(): return GpioPadName_BtGpio5; case DeviceCode_PowLcdVddPEn .GetInternalValue(): return GpioPadName_PowLcdVddPEn; case DeviceCode_PowLcdVddNEn .GetInternalValue(): return GpioPadName_PowLcdVddNEn; case DeviceCode_ExtconDetU .GetInternalValue(): return GpioPadName_ExtconDetU; case DeviceCode_RamCode2 .GetInternalValue(): return GpioPadName_RamCode2; case DeviceCode_Vdd50BEn .GetInternalValue(): return GpioPadName_Vdd50BEn; case DeviceCode_WifiWakeHost .GetInternalValue(): return GpioPadName_WifiWakeHost; case DeviceCode_SdCd .GetInternalValue(): return GpioPadName_SdCd; case DeviceCode_OtgFet1ForSdev .GetInternalValue(): return GpioPadName_OtgFet1ForSdev; case DeviceCode_OtgFet2ForSdev .GetInternalValue(): return GpioPadName_OtgFet2ForSdev; case DeviceCode_ExtConWakeU .GetInternalValue(): return GpioPadName_ExtConWakeU; case DeviceCode_ExtConWakeS .GetInternalValue(): return GpioPadName_ExtConWakeS; case DeviceCode_PmuIrq .GetInternalValue(): return GpioPadName_PmuIrq; case DeviceCode_ExtUart2Cts .GetInternalValue(): return GpioPadName_ExtUart2Cts; case DeviceCode_ExtUart3Cts .GetInternalValue(): return GpioPadName_ExtUart3Cts; case DeviceCode_5VStepDownEn .GetInternalValue(): return GpioPadName_5VStepDownEn; case DeviceCode_UsbSwitchB2Oc .GetInternalValue(): return GpioPadName_UsbSwitchB2Oc; case DeviceCode_5VStepDownPg .GetInternalValue(): return GpioPadName_5VStepDownPg; case DeviceCode_UsbSwitchAEn .GetInternalValue(): return GpioPadName_UsbSwitchAEn; case DeviceCode_UsbSwitchAFlag .GetInternalValue(): return GpioPadName_UsbSwitchAFlag; case DeviceCode_UsbSwitchB3Oc .GetInternalValue(): return GpioPadName_UsbSwitchB3Oc; case DeviceCode_UsbSwitchB3En .GetInternalValue(): return GpioPadName_UsbSwitchB3En; case DeviceCode_UsbSwitchB2En .GetInternalValue(): return GpioPadName_UsbSwitchB2En; case DeviceCode_Hdmi5VEn .GetInternalValue(): return GpioPadName_Hdmi5VEn; case DeviceCode_UsbSwitchB1En .GetInternalValue(): return GpioPadName_UsbSwitchB1En; case DeviceCode_HdmiPdTrEn .GetInternalValue(): return GpioPadName_HdmiPdTrEn; case DeviceCode_FanEn .GetInternalValue(): return GpioPadName_FanEn; case DeviceCode_UsbSwitchB1Oc .GetInternalValue(): return GpioPadName_UsbSwitchB1Oc; case DeviceCode_PwmFan .GetInternalValue(): return GpioPadName_PwmFan; case DeviceCode_HdmiHpd .GetInternalValue(): return GpioPadName_HdmiHpd; case DeviceCode_Max77812Irq .GetInternalValue(): return GpioPadName_Max77812Irq; case DeviceCode_Debug0 .GetInternalValue(): return GpioPadName_Debug0; case DeviceCode_Debug1 .GetInternalValue(): return GpioPadName_Debug1; case DeviceCode_Debug2 .GetInternalValue(): return GpioPadName_Debug2; case DeviceCode_Debug3 .GetInternalValue(): return GpioPadName_Debug3; case DeviceCode_NfcIrq .GetInternalValue(): return GpioPadName_NfcIrq; case DeviceCode_NfcRst .GetInternalValue(): return GpioPadName_NfcRst; case DeviceCode_McuIrq .GetInternalValue(): return GpioPadName_McuIrq; case DeviceCode_McuBoot .GetInternalValue(): return GpioPadName_McuBoot; case DeviceCode_McuRst .GetInternalValue(): return GpioPadName_McuRst; case DeviceCode_Vdd5V3En .GetInternalValue(): return GpioPadName_Vdd5V3En; case DeviceCode_McuPor .GetInternalValue(): return GpioPadName_McuPor; case DeviceCode_LcdGpio1 .GetInternalValue(): return GpioPadName_LcdGpio1; case DeviceCode_NfcEn .GetInternalValue(): return GpioPadName_NfcEn; AMS_UNREACHABLE_DEFAULT_CASE(); } } constexpr inline DeviceCode ConvertToDeviceCode(GpioPadName gpn) { switch (gpn) { case GpioPadName_CodecLdoEnTemp: return DeviceCode_CodecLdoEnTemp; case GpioPadName_PowSdEn: return DeviceCode_PowSdEn; case GpioPadName_BtRst: return DeviceCode_BtRst; case GpioPadName_RamCode3: return DeviceCode_RamCode3; case GpioPadName_GameCardReset: return DeviceCode_GameCardReset; case GpioPadName_CodecAlert: return DeviceCode_CodecAlert; case GpioPadName_PowGc: return DeviceCode_PowGc; case GpioPadName_DebugControllerDet: return DeviceCode_DebugControllerDet; case GpioPadName_BattChgStatus: return DeviceCode_BattChgStatus; case GpioPadName_BattChgEnableN: return DeviceCode_BattChgEnableN; case GpioPadName_FanTach: return DeviceCode_FanTach; case GpioPadName_ExtconDetS: return DeviceCode_ExtconDetS; case GpioPadName_Vdd50AEn: return DeviceCode_Vdd50AEn; case GpioPadName_SdevCoaxSel1: return DeviceCode_SdevCoaxSel1; case GpioPadName_GameCardCd: return DeviceCode_GameCardCd; case GpioPadName_ProdType0: return DeviceCode_ProdType0; case GpioPadName_ProdType1: return DeviceCode_ProdType1; case GpioPadName_ProdType2: return DeviceCode_ProdType2; case GpioPadName_ProdType3: return DeviceCode_ProdType3; case GpioPadName_TempAlert: return DeviceCode_TempAlert; case GpioPadName_CodecHpDetIrq: return DeviceCode_CodecHpDetIrq; case GpioPadName_MotionInt: return DeviceCode_MotionInt; case GpioPadName_TpIrq: return DeviceCode_TpIrq; case GpioPadName_ButtonSleep2: return DeviceCode_ButtonSleep2; case GpioPadName_ButtonVolUp: return DeviceCode_ButtonVolUp; case GpioPadName_ButtonVolDn: return DeviceCode_ButtonVolDn; case GpioPadName_BattMgicIrq: return DeviceCode_BattMgicIrq; case GpioPadName_RecoveryKey: return DeviceCode_RecoveryKey; case GpioPadName_PowLcdBlEn: return DeviceCode_PowLcdBlEn; case GpioPadName_LcdReset: return DeviceCode_LcdReset; case GpioPadName_PdVconnEn: return DeviceCode_PdVconnEn; case GpioPadName_PdRstN: return DeviceCode_PdRstN; case GpioPadName_Bq24190Irq: return DeviceCode_Bq24190Irq; case GpioPadName_SdevCoaxSel0: return DeviceCode_SdevCoaxSel0; case GpioPadName_SdWp: return DeviceCode_SdWp; case GpioPadName_TpReset: return DeviceCode_TpReset; case GpioPadName_BtGpio2: return DeviceCode_BtGpio2; case GpioPadName_BtGpio3: return DeviceCode_BtGpio3; case GpioPadName_BtGpio4: return DeviceCode_BtGpio4; case GpioPadName_CradleIrq: return DeviceCode_CradleIrq; case GpioPadName_PowVcpuInt: return DeviceCode_PowVcpuInt; case GpioPadName_Max77621GpuInt: return DeviceCode_Max77621GpuInt; case GpioPadName_ExtconChgU: return DeviceCode_ExtconChgU; case GpioPadName_ExtconChgS: return DeviceCode_ExtconChgS; case GpioPadName_WifiRfDisable: return DeviceCode_WifiRfDisable; case GpioPadName_WifiReset: return DeviceCode_WifiReset; case GpioPadName_ApWakeBt: return DeviceCode_ApWakeBt; case GpioPadName_BtWakeAp: return DeviceCode_BtWakeAp; case GpioPadName_BtGpio5: return DeviceCode_BtGpio5; case GpioPadName_PowLcdVddPEn: return DeviceCode_PowLcdVddPEn; case GpioPadName_PowLcdVddNEn: return DeviceCode_PowLcdVddNEn; case GpioPadName_ExtconDetU: return DeviceCode_ExtconDetU; case GpioPadName_RamCode2: return DeviceCode_RamCode2; case GpioPadName_Vdd50BEn: return DeviceCode_Vdd50BEn; case GpioPadName_WifiWakeHost: return DeviceCode_WifiWakeHost; case GpioPadName_SdCd: return DeviceCode_SdCd; case GpioPadName_OtgFet1ForSdev: return DeviceCode_OtgFet1ForSdev; case GpioPadName_OtgFet2ForSdev: return DeviceCode_OtgFet2ForSdev; case GpioPadName_ExtConWakeU: return DeviceCode_ExtConWakeU; case GpioPadName_ExtConWakeS: return DeviceCode_ExtConWakeS; case GpioPadName_PmuIrq: return DeviceCode_PmuIrq; case GpioPadName_ExtUart2Cts: return DeviceCode_ExtUart2Cts; case GpioPadName_ExtUart3Cts: return DeviceCode_ExtUart3Cts; case GpioPadName_5VStepDownEn: return DeviceCode_5VStepDownEn; case GpioPadName_UsbSwitchB2Oc: return DeviceCode_UsbSwitchB2Oc; case GpioPadName_5VStepDownPg: return DeviceCode_5VStepDownPg; case GpioPadName_UsbSwitchAEn: return DeviceCode_UsbSwitchAEn; case GpioPadName_UsbSwitchAFlag: return DeviceCode_UsbSwitchAFlag; case GpioPadName_UsbSwitchB3Oc: return DeviceCode_UsbSwitchB3Oc; case GpioPadName_UsbSwitchB3En: return DeviceCode_UsbSwitchB3En; case GpioPadName_UsbSwitchB2En: return DeviceCode_UsbSwitchB2En; case GpioPadName_Hdmi5VEn: return DeviceCode_Hdmi5VEn; case GpioPadName_UsbSwitchB1En: return DeviceCode_UsbSwitchB1En; case GpioPadName_HdmiPdTrEn: return DeviceCode_HdmiPdTrEn; case GpioPadName_FanEn: return DeviceCode_FanEn; case GpioPadName_UsbSwitchB1Oc: return DeviceCode_UsbSwitchB1Oc; case GpioPadName_PwmFan: return DeviceCode_PwmFan; case GpioPadName_HdmiHpd: return DeviceCode_HdmiHpd; case GpioPadName_Max77812Irq: return DeviceCode_Max77812Irq; case GpioPadName_Debug0: return DeviceCode_Debug0; case GpioPadName_Debug1: return DeviceCode_Debug1; case GpioPadName_Debug2: return DeviceCode_Debug2; case GpioPadName_Debug3: return DeviceCode_Debug3; case GpioPadName_NfcIrq: return DeviceCode_NfcIrq; case GpioPadName_NfcRst: return DeviceCode_NfcRst; case GpioPadName_McuIrq: return DeviceCode_McuIrq; case GpioPadName_McuBoot: return DeviceCode_McuBoot; case GpioPadName_McuRst: return DeviceCode_McuRst; case GpioPadName_Vdd5V3En: return DeviceCode_Vdd5V3En; case GpioPadName_McuPor: return DeviceCode_McuPor; case GpioPadName_LcdGpio1: return DeviceCode_LcdGpio1; case GpioPadName_NfcEn: return DeviceCode_NfcEn; AMS_UNREACHABLE_DEFAULT_CASE(); } } }
29,785
C++
.h
410
63.234146
105
0.665225
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
7,765
gpio_select_pad_name.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/gpio_select_pad_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #if defined(ATMOSPHERE_BOARD_NINTENDO_NX) #include <stratosphere/gpio/gpio_pad_name.board.nintendo_nx.hpp> #else #include <stratosphere/gpio/gpio_pad_name.generic.hpp> #endif
899
C++
.h
23
37.086957
76
0.765714
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
7,766
gpio_pad_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/gpio_pad_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 <vapours.hpp> #include <stratosphere/ddsf/ddsf_types.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/gpio_select_pad_name.hpp> #include <stratosphere/gpio/driver/gpio_pad.hpp> namespace ams::gpio { struct GpioPadSession { void *_session; os::SystemEventType *_event; }; Result OpenSession(GpioPadSession *out_session, ams::DeviceCode device_code); void CloseSession(GpioPadSession *session); Direction GetDirection(GpioPadSession *session); void SetDirection(GpioPadSession *session, Direction direction); GpioValue GetValue(GpioPadSession *session); void SetValue(GpioPadSession *session, GpioValue value); InterruptMode GetInterruptMode(GpioPadSession *session); void SetInterruptMode(GpioPadSession *session, InterruptMode mode); bool GetInterruptEnable(GpioPadSession *session); void SetInterruptEnable(GpioPadSession *session, bool en); InterruptStatus GetInterruptStatus(GpioPadSession *session); void ClearInterruptStatus(GpioPadSession *session); int GetDebounceTime(GpioPadSession *session); void SetDebounceTime(GpioPadSession *session, int ms); bool GetDebounceEnabled(GpioPadSession *session); void SetDebounceEnabled(GpioPadSession *session, bool en); Result BindInterrupt(os::SystemEventType *event, GpioPadSession *session); void UnbindInterrupt(GpioPadSession *session); Result IsWakeEventActive(bool *out_is_active, ams::DeviceCode device_code); }
2,164
C++
.h
46
43.282609
81
0.778147
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
7,767
gpio_sf_i_pad_session.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/sf/gpio_sf_i_pad_session.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #define AMS_GPIO_I_PAD_SESSION_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, SetDirection, (gpio::Direction direction), (direction) ) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetDirection, (ams::sf::Out<gpio::Direction> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 2, Result, SetInterruptMode, (gpio::InterruptMode mode), (mode) ) \ AMS_SF_METHOD_INFO(C, H, 3, Result, GetInterruptMode, (ams::sf::Out<gpio::InterruptMode> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 4, Result, SetInterruptEnable, (bool enable), (enable) ) \ AMS_SF_METHOD_INFO(C, H, 5, Result, GetInterruptEnable, (ams::sf::Out<bool> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 6, Result, GetInterruptStatus, (ams::sf::Out<gpio::InterruptStatus> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 7, Result, ClearInterruptStatus, (), () ) \ AMS_SF_METHOD_INFO(C, H, 8, Result, SetValue, (gpio::GpioValue value), (value) ) \ AMS_SF_METHOD_INFO(C, H, 9, Result, GetValue, (ams::sf::Out<gpio::GpioValue> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 10, Result, BindInterrupt, (ams::sf::OutCopyHandle out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 11, Result, UnbindInterrupt, (), () ) \ AMS_SF_METHOD_INFO(C, H, 12, Result, SetDebounceEnabled, (bool enable), (enable) ) \ AMS_SF_METHOD_INFO(C, H, 13, Result, GetDebounceEnabled, (ams::sf::Out<bool> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 14, Result, SetDebounceTime, (s32 ms), (ms) ) \ AMS_SF_METHOD_INFO(C, H, 15, Result, GetDebounceTime, (ams::sf::Out<s32> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 16, Result, SetValueForSleepState, (gpio::GpioValue value), (value), hos::Version_4_0_0) \ AMS_SF_METHOD_INFO(C, H, 16, Result, GetValueForSleepState, (ams::sf::Out<gpio::GpioValue> out), (out), hos::Version_6_0_0) AMS_SF_DEFINE_INTERFACE(ams::gpio::sf, IPadSession, AMS_GPIO_I_PAD_SESSION_INTERFACE_INFO, 0x7448A8A7)
3,517
C++
.h
38
89.210526
141
0.506904
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
7,768
gpio_sf_i_manager.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/sf/gpio_sf_i_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 <vapours.hpp> #include <stratosphere/ddsf/ddsf_types.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/gpio_select_pad_name.hpp> #include <stratosphere/gpio/sf/gpio_sf_i_pad_session.hpp> #define AMS_GPIO_I_MANAGER_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, s32 pad_descriptor), (out, pad_descriptor) ) \ AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name), (out, pad_name) ) \ AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSessionForTest, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, gpio::GpioPadName pad_name), (out, pad_name) ) \ AMS_SF_METHOD_INFO(C, H, 3, Result, IsWakeEventActive, (ams::sf::Out<bool> out, gpio::GpioPadName pad_name), (out, pad_name), hos::Version_Min, hos::Version_6_2_0) \ AMS_SF_METHOD_INFO(C, H, 4, Result, GetWakeEventActiveFlagSet, (ams::sf::Out<gpio::WakeBitFlag> out), (out), hos::Version_Min, hos::Version_6_2_0) \ AMS_SF_METHOD_INFO(C, H, 5, Result, SetWakeEventActiveFlagSetForDebug, (gpio::GpioPadName pad_name, bool is_enabled), (pad_name, is_enabled), hos::Version_Min, hos::Version_6_2_0) \ AMS_SF_METHOD_INFO(C, H, 6, Result, SetWakePinDebugMode, (s32 mode), (mode) ) \ AMS_SF_METHOD_INFO(C, H, 7, Result, OpenSession2, (ams::sf::Out<ams::sf::SharedPointer<gpio::sf::IPadSession>> out, DeviceCode device_code, ddsf::AccessMode access_mode), (out, device_code, access_mode), hos::Version_5_0_0 ) \ AMS_SF_METHOD_INFO(C, H, 8, Result, IsWakeEventActive2, (ams::sf::Out<bool> out, DeviceCode device_code), (out, device_code), hos::Version_5_0_0 ) \ AMS_SF_METHOD_INFO(C, H, 9, Result, SetWakeEventActiveFlagSetForDebug2, (DeviceCode device_code, bool is_enabled), (device_code, is_enabled), hos::Version_5_0_0 ) \ AMS_SF_METHOD_INFO(C, H, 10, Result, SetRetryValues, (u32 arg0, u32 arg1), (arg0, arg1), hos::Version_6_0_0 ) AMS_SF_DEFINE_INTERFACE(ams::gpio::sf, IManager, AMS_GPIO_I_MANAGER_INTERFACE_INFO, 0xD219501E)
4,237
C++
.h
34
121.823529
272
0.472619
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
7,769
gpio_driver_service_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_driver_service_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp> namespace ams::gpio::driver { void RegisterDriver(IGpioDriver *driver); void UnregisterDriver(IGpioDriver *driver); Result RegisterDeviceCode(DeviceCode device_code, Pad *pad); bool UnregisterDeviceCode(DeviceCode device_code); void RegisterInterruptHandler(ddsf::IEventHandler *handler); void UnregisterInterruptHandler(ddsf::IEventHandler *handler); void SetInitialGpioConfig(); void SetInitialWakePinConfig(); }
1,227
C++
.h
29
39.517241
76
0.774329
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
7,770
gpio_select_driver_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_select_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp> #include <stratosphere/gpio/driver/gpio_driver_service_api.hpp> #include <stratosphere/gpio/driver/gpio_driver_client_api.hpp> #if defined(ATMOSPHERE_BOARD_NINTENDO_NX) #include <stratosphere/gpio/driver/board/nintendo/nx/gpio_driver_api.hpp> namespace ams::gpio::driver::board { using namespace ams::gpio::driver::board::nintendo::nx; } #else // TODO: #error "Unknown board for ams::gpio::driver::" #endif
1,214
C++
.h
29
39.241379
77
0.756803
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
7,771
gpio_i_gpio_driver.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_i_gpio_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/ddsf.hpp> namespace ams::gpio::driver { class Pad; class IGpioDriver : public ::ams::ddsf::IDriver { NON_COPYABLE(IGpioDriver); NON_MOVEABLE(IGpioDriver); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::IGpioDriver, ::ams::ddsf::IDriver); public: IGpioDriver() : IDriver() { /* ... */ } virtual ~IGpioDriver() { /* ... */ } virtual void InitializeDriver() = 0; virtual void FinalizeDriver() = 0; virtual Result InitializePad(Pad *pad) = 0; virtual void FinalizePad(Pad *pad) = 0; virtual Result GetDirection(Direction *out, Pad *pad) const = 0; virtual Result SetDirection(Pad *pad, Direction direction) = 0; virtual Result GetValue(GpioValue *out, Pad *pad) const = 0; virtual Result SetValue(Pad *pad, GpioValue value) = 0; virtual Result GetInterruptMode(InterruptMode *out, Pad *pad) const = 0; virtual Result SetInterruptMode(Pad *pad, InterruptMode mode) = 0; virtual Result SetInterruptEnabled(Pad *pad, bool en) = 0; virtual Result GetInterruptStatus(InterruptStatus *out, Pad *pad) = 0; virtual Result ClearInterruptStatus(Pad *pad) = 0; virtual os::SdkMutex &GetInterruptControlMutex(const Pad &pad) const = 0; virtual Result GetDebounceEnabled(bool *out, Pad *pad) const = 0; virtual Result SetDebounceEnabled(Pad *pad, bool en) = 0; virtual Result GetDebounceTime(s32 *out_ms, Pad *pad) const = 0; virtual Result SetDebounceTime(Pad *pad, s32 ms) = 0; virtual Result GetUnknown22(u32 *out) = 0; virtual void Unknown23() = 0; virtual Result SetValueForSleepState(Pad *pad, GpioValue value) = 0; virtual Result IsWakeEventActive(bool *out, Pad *pad) const = 0; virtual Result SetWakeEventActiveFlagSetForDebug(Pad *pad, bool en) = 0; virtual Result SetWakePinDebugMode(WakePinDebugMode mode) = 0; virtual Result Suspend() = 0; virtual Result SuspendLow() = 0; virtual Result Resume() = 0; virtual Result ResumeLow() = 0; }; }
3,056
C++
.h
58
44.189655
87
0.643408
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
7,772
gpio_driver_client_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_driver_client_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp> namespace ams::gpio::driver { void Initialize(); void Finalize(); }
853
C++
.h
23
35
76
0.756953
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
7,773
gpio_pad.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_pad.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/ddsf.hpp> namespace ams::gpio::driver { class Pad : public ::ams::ddsf::IDevice { NON_COPYABLE(Pad); NON_MOVEABLE(Pad); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::Pad, ::ams::ddsf::IDevice); private: int m_pad_number; bool m_is_interrupt_enabled; public: explicit Pad(int pad) : IDevice(true), m_pad_number(pad), m_is_interrupt_enabled(false) { /* ... */ } Pad() : Pad(0) { /* ... */ } virtual ~Pad() { /* ... */ } int GetPadNumber() const { return m_pad_number; } void SetPadNumber(int p) { m_pad_number = p; } bool IsInterruptEnabled() const { return m_is_interrupt_enabled; } void SetInterruptEnabled(bool en) { m_is_interrupt_enabled = en; } bool IsInterruptRequiredForDriver() const { return this->IsInterruptEnabled() && this->IsAnySessionBoundToInterrupt(); } bool IsAnySessionBoundToInterrupt() const; void SignalInterruptBoundEvent(); }; }
1,931
C++
.h
50
30.48
113
0.614439
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
7,774
gpio_pad_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_pad_accessor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> namespace ams::gpio::driver { namespace impl { constexpr inline size_t GpioPadSessionSize = 0x60; constexpr inline size_t GpioPadSessionAlign = 8; struct alignas(GpioPadSessionAlign) GpioPadSessionImplPadded; } struct GpioPadSession { util::TypedStorage<impl::GpioPadSessionImplPadded, impl::GpioPadSessionSize, impl::GpioPadSessionAlign> _impl; }; Result OpenSession(GpioPadSession *out, DeviceCode device_code, ddsf::AccessMode access_mode); void CloseSession(GpioPadSession *session); Result SetDirection(GpioPadSession *session, gpio::Direction direction); Result GetDirection(gpio::Direction *out, GpioPadSession *session); Result SetValue(GpioPadSession *session, gpio::GpioValue value); Result GetValue(gpio::GpioValue *out, GpioPadSession *session); /* TODO */ }
1,573
C++
.h
35
41.085714
118
0.756545
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
7,775
gpio_pad_session_impl.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_pad_session_impl.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/driver/gpio_pad_accessor.hpp> #include <stratosphere/gpio/driver/impl/gpio_event_holder.hpp> #include <stratosphere/ddsf.hpp> namespace ams::gpio::driver { class Pad; } namespace ams::gpio::driver::impl { class PadSessionImpl : public ::ams::ddsf::ISession { NON_COPYABLE(PadSessionImpl); NON_MOVEABLE(PadSessionImpl); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::impl::PadSessionImpl, ::ams::ddsf::ISession); private: EventHolder m_event_holder; private: Result UpdateDriverInterruptEnabled(); public: PadSessionImpl() : m_event_holder() { /* ... */ } ~PadSessionImpl() { this->Close(); } bool IsInterruptBound() const { return m_event_holder.IsBound(); } Result Open(Pad *pad, ddsf::AccessMode access_mode); void Close(); Result BindInterrupt(os::SystemEventType *event); void UnbindInterrupt(); Result GetInterruptEnabled(bool *out) const; Result SetInterruptEnabled(bool en); void SignalInterruptBoundEvent(); }; static_assert( sizeof(PadSessionImpl) <= GpioPadSessionSize); static_assert(alignof(PadSessionImpl) <= GpioPadSessionAlign); struct alignas(GpioPadSessionAlign) GpioPadSessionImplPadded { PadSessionImpl _impl; u8 _padding[GpioPadSessionSize - sizeof(PadSessionImpl)]; }; static_assert( sizeof(GpioPadSessionImplPadded) == GpioPadSessionSize); static_assert(alignof(GpioPadSessionImplPadded) == GpioPadSessionAlign); ALWAYS_INLINE PadSessionImpl &GetPadSessionImpl(GpioPadSession &session) { return GetReference(session._impl)._impl; } ALWAYS_INLINE const PadSessionImpl &GetPadSessionImpl(const GpioPadSession &session) { return GetReference(session._impl)._impl; } ALWAYS_INLINE PadSessionImpl &GetOpenPadSessionImpl(GpioPadSession &session) { auto &ref = GetReference(session._impl)._impl; AMS_ASSERT(ref.IsOpen()); return ref; } ALWAYS_INLINE const PadSessionImpl &GetOpenPadSessionImpl(const GpioPadSession &session) { const auto &ref = GetReference(session._impl)._impl; AMS_ASSERT(ref.IsOpen()); return ref; } }
3,089
C++
.h
74
34.986486
97
0.690897
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
7,776
gpio_event_holder.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_event_holder.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 <vapours.hpp> #include <stratosphere/os.hpp> namespace ams::gpio::driver::impl { class EventHolder { NON_COPYABLE(EventHolder); NON_MOVEABLE(EventHolder); private: os::SystemEventType *m_event; public: constexpr EventHolder() : m_event(nullptr) { /* ... */ } void AttachEvent(os::SystemEventType *event) { m_event = event; } os::SystemEventType *DetachEvent() { auto ev = m_event; m_event = nullptr; return ev; } os::SystemEventType *GetSystemEvent() { return m_event; } bool IsBound() const { return m_event != nullptr; } }; }
1,448
C++
.h
42
26.880952
76
0.616154
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
7,777
gpio_driver_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/driver/board/nintendo/nx/gpio_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp> namespace ams::gpio::driver::board::nintendo::nx { void Initialize(bool enable_interrupt_handlers); void SetInitialGpioConfig(); void SetInitialWakePinConfig(); }
953
C++
.h
24
37.458333
76
0.764324
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
7,778
gpio_server_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio/server/gpio_server_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 <vapours.hpp> #include <stratosphere/gpio/gpio_types.hpp> #include <stratosphere/gpio/sf/gpio_sf_i_manager.hpp> namespace ams::gpio::server { ams::sf::SharedPointer<gpio::sf::IManager> GetServiceObject(); }
871
C++
.h
22
37.636364
76
0.760047
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
7,779
init_malloc.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/init/init_malloc.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 <vapours.hpp> namespace ams::mem { class StandardAllocator; } namespace ams::init { void InitializeAllocator(void *address, size_t size, bool cache_enabled); void InitializeAllocator(void *address, size_t size); mem::StandardAllocator *GetAllocator(); }
934
C++
.h
25
34.88
77
0.757206
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
7,782
memorystream.h
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/rapidjson/memorystream.h
// Tencent is pleased to support the open source community by making RapidJSON available. // // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. // // Licensed under the MIT License (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // http://opensource.org/licenses/MIT // // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. #ifndef RAPIDJSON_MEMORYSTREAM_H_ #define RAPIDJSON_MEMORYSTREAM_H_ #include "stream.h" #ifdef __clang__ RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(unreachable-code) RAPIDJSON_DIAG_OFF(missing-noreturn) #endif RAPIDJSON_NAMESPACE_BEGIN //! Represents an in-memory input byte stream. /*! This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. Differences between MemoryStream and StringStream: 1. StringStream has encoding but MemoryStream is a byte stream. 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). \note implements Stream concept */ struct MemoryStream { typedef char Ch; // byte MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } size_t Tell() const { return static_cast<size_t>(src_ - begin_); } Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } void Put(Ch) { RAPIDJSON_ASSERT(false); } void Flush() { RAPIDJSON_ASSERT(false); } size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } // For encoding detection only. const Ch* Peek4() const { return Tell() + 4 <= size_ ? src_ : 0; } const Ch* src_; //!< Current read position. const Ch* begin_; //!< Original head of the string. const Ch* end_; //!< End of stream. size_t size_; //!< Size of the stream. }; RAPIDJSON_NAMESPACE_END #ifdef __clang__ RAPIDJSON_DIAG_POP #endif #endif // RAPIDJSON_MEMORYBUFFER_H_
2,646
C++
.h
56
44.125
154
0.71767
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
7,816
en.h
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/rapidjson/error/en.h
// Tencent is pleased to support the open source community by making RapidJSON available. // // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. // // Licensed under the MIT License (the "License"); you may not use this file except // in compliance with the License. You may obtain a copy of the License at // // http://opensource.org/licenses/MIT // // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. #ifndef RAPIDJSON_ERROR_EN_H_ #define RAPIDJSON_ERROR_EN_H_ #include "error.h" #ifdef __clang__ RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(switch-enum) RAPIDJSON_DIAG_OFF(covered-switch-default) #endif RAPIDJSON_NAMESPACE_BEGIN //! Maps error code of parsing into error message. /*! \ingroup RAPIDJSON_ERRORS \param parseErrorCode Error code obtained in parsing. \return the error message. \note User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes. */ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) { switch (parseErrorCode) { case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error."); case kParseErrorDocumentEmpty: return RAPIDJSON_ERROR_STRING("The document is empty."); case kParseErrorDocumentRootNotSingular: return RAPIDJSON_ERROR_STRING("The document root must not be followed by other values."); case kParseErrorValueInvalid: return RAPIDJSON_ERROR_STRING("Invalid value."); case kParseErrorObjectMissName: return RAPIDJSON_ERROR_STRING("Missing a name for object member."); case kParseErrorObjectMissColon: return RAPIDJSON_ERROR_STRING("Missing a colon after a name of object member."); case kParseErrorObjectMissCommaOrCurlyBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or '}' after an object member."); case kParseErrorArrayMissCommaOrSquareBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or ']' after an array element."); case kParseErrorStringUnicodeEscapeInvalidHex: return RAPIDJSON_ERROR_STRING("Incorrect hex digit after \\u escape in string."); case kParseErrorStringUnicodeSurrogateInvalid: return RAPIDJSON_ERROR_STRING("The surrogate pair in string is invalid."); case kParseErrorStringEscapeInvalid: return RAPIDJSON_ERROR_STRING("Invalid escape character in string."); case kParseErrorStringMissQuotationMark: return RAPIDJSON_ERROR_STRING("Missing a closing quotation mark in string."); case kParseErrorStringInvalidEncoding: return RAPIDJSON_ERROR_STRING("Invalid encoding in string."); case kParseErrorNumberTooBig: return RAPIDJSON_ERROR_STRING("Number too big to be stored in double."); case kParseErrorNumberMissFraction: return RAPIDJSON_ERROR_STRING("Miss fraction part in number."); case kParseErrorNumberMissExponent: return RAPIDJSON_ERROR_STRING("Miss exponent in number."); case kParseErrorTermination: return RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error."); case kParseErrorUnspecificSyntaxError: return RAPIDJSON_ERROR_STRING("Unspecific syntax error."); default: return RAPIDJSON_ERROR_STRING("Unknown error."); } } //! Maps error code of validation into error message. /*! \ingroup RAPIDJSON_ERRORS \param validateErrorCode Error code obtained from validator. \return the error message. \note User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes. */ inline const RAPIDJSON_ERROR_CHARTYPE* GetValidateError_En(ValidateErrorCode validateErrorCode) { switch (validateErrorCode) { case kValidateErrors: return RAPIDJSON_ERROR_STRING("One or more validation errors have occurred"); case kValidateErrorNone: return RAPIDJSON_ERROR_STRING("No error."); case kValidateErrorMultipleOf: return RAPIDJSON_ERROR_STRING("Number '%actual' is not a multiple of the 'multipleOf' value '%expected'."); case kValidateErrorMaximum: return RAPIDJSON_ERROR_STRING("Number '%actual' is greater than the 'maximum' value '%expected'."); case kValidateErrorExclusiveMaximum: return RAPIDJSON_ERROR_STRING("Number '%actual' is greater than or equal to the 'exclusiveMaximum' value '%expected'."); case kValidateErrorMinimum: return RAPIDJSON_ERROR_STRING("Number '%actual' is less than the 'minimum' value '%expected'."); case kValidateErrorExclusiveMinimum: return RAPIDJSON_ERROR_STRING("Number '%actual' is less than or equal to the 'exclusiveMinimum' value '%expected'."); case kValidateErrorMaxLength: return RAPIDJSON_ERROR_STRING("String '%actual' is longer than the 'maxLength' value '%expected'."); case kValidateErrorMinLength: return RAPIDJSON_ERROR_STRING("String '%actual' is shorter than the 'minLength' value '%expected'."); case kValidateErrorPattern: return RAPIDJSON_ERROR_STRING("String '%actual' does not match the 'pattern' regular expression."); case kValidateErrorMaxItems: return RAPIDJSON_ERROR_STRING("Array of length '%actual' is longer than the 'maxItems' value '%expected'."); case kValidateErrorMinItems: return RAPIDJSON_ERROR_STRING("Array of length '%actual' is shorter than the 'minItems' value '%expected'."); case kValidateErrorUniqueItems: return RAPIDJSON_ERROR_STRING("Array has duplicate items at indices '%duplicates' but 'uniqueItems' is true."); case kValidateErrorAdditionalItems: return RAPIDJSON_ERROR_STRING("Array has an additional item at index '%disallowed' that is not allowed by the schema."); case kValidateErrorMaxProperties: return RAPIDJSON_ERROR_STRING("Object has '%actual' members which is more than 'maxProperties' value '%expected'."); case kValidateErrorMinProperties: return RAPIDJSON_ERROR_STRING("Object has '%actual' members which is less than 'minProperties' value '%expected'."); case kValidateErrorRequired: return RAPIDJSON_ERROR_STRING("Object is missing the following members required by the schema: '%missing'."); case kValidateErrorAdditionalProperties: return RAPIDJSON_ERROR_STRING("Object has an additional member '%disallowed' that is not allowed by the schema."); case kValidateErrorPatternProperties: return RAPIDJSON_ERROR_STRING("Object has 'patternProperties' that are not allowed by the schema."); case kValidateErrorDependencies: return RAPIDJSON_ERROR_STRING("Object has missing property or schema dependencies, refer to following errors."); case kValidateErrorEnum: return RAPIDJSON_ERROR_STRING("Property has a value that is not one of its allowed enumerated values."); case kValidateErrorType: return RAPIDJSON_ERROR_STRING("Property has a type '%actual' that is not in the following list: '%expected'."); case kValidateErrorOneOf: return RAPIDJSON_ERROR_STRING("Property did not match any of the sub-schemas specified by 'oneOf', refer to following errors."); case kValidateErrorOneOfMatch: return RAPIDJSON_ERROR_STRING("Property matched more than one of the sub-schemas specified by 'oneOf'."); case kValidateErrorAllOf: return RAPIDJSON_ERROR_STRING("Property did not match all of the sub-schemas specified by 'allOf', refer to following errors."); case kValidateErrorAnyOf: return RAPIDJSON_ERROR_STRING("Property did not match any of the sub-schemas specified by 'anyOf', refer to following errors."); case kValidateErrorNot: return RAPIDJSON_ERROR_STRING("Property matched the sub-schema specified by 'not'."); default: return RAPIDJSON_ERROR_STRING("Unknown error."); } } RAPIDJSON_NAMESPACE_END #ifdef __clang__ RAPIDJSON_DIAG_POP #endif #endif // RAPIDJSON_ERROR_EN_H_
8,831
C++
.h
98
84.214286
184
0.697827
Atmosphere-NX/Atmosphere
14,324
1,207
54
GPL-2.0
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
7,817
ro_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ro/ro_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 <vapours.hpp> #include <stratosphere/ncm/ncm_ids.hpp> namespace ams::ro { enum NrrKind : u8 { NrrKind_User = 0, NrrKind_JitPlugin = 1, NrrKind_Count, }; static constexpr size_t ModuleIdSize = 0x20; struct ModuleId { u8 data[ModuleIdSize]; }; static_assert(sizeof(ModuleId) == ModuleIdSize); struct NrrCertification { static constexpr size_t RsaKeySize = 0x100; static constexpr size_t SignedSize = 0x120; u64 program_id_mask; u64 program_id_pattern; u8 reserved_10[0x10]; u8 modulus[RsaKeySize]; u8 signature[RsaKeySize]; }; static_assert(sizeof(NrrCertification) == NrrCertification::RsaKeySize + NrrCertification::SignedSize); class NrrHeader { public: static constexpr u32 Magic = util::FourCC<'N','R','R','0'>::Code; private: u32 m_magic; u32 m_key_generation; u8 m_reserved_08[0x08]; NrrCertification m_certification; u8 m_signature[0x100]; ncm::ProgramId m_program_id; u32 m_size; u8 m_nrr_kind; /* 7.0.0+ */ u8 m_reserved_33D[3]; u32 m_hashes_offset; u32 m_num_hashes; u8 m_reserved_348[8]; public: bool IsMagicValid() const { return m_magic == Magic; } bool IsProgramIdValid() const { return (m_program_id.value & m_certification.program_id_mask) == m_certification.program_id_pattern; } NrrKind GetNrrKind() const { const NrrKind kind = static_cast<NrrKind>(m_nrr_kind); AMS_ABORT_UNLESS(kind < NrrKind_Count); return kind; } ncm::ProgramId GetProgramId() const { return m_program_id; } u32 GetSize() const { return m_size; } u32 GetNumHashes() const { return m_num_hashes; } size_t GetHashesOffset() const { return m_hashes_offset; } uintptr_t GetHashes() const { return reinterpret_cast<uintptr_t>(this) + this->GetHashesOffset(); } u32 GetKeyGeneration() const { return m_key_generation; } const u8 *GetCertificationSignature() const { return m_certification.signature; } const u8 *GetCertificationSignedArea() const { return reinterpret_cast<const u8 *>(std::addressof(m_certification)); } const u8 *GetCertificationModulus() const { return m_certification.modulus; } const u8 *GetSignature() const { return m_signature; } const u8 *GetSignedArea() const { return reinterpret_cast<const u8 *>(std::addressof(m_program_id)); } size_t GetSignedAreaSize() const { return m_size - GetSignedAreaOffset(); } static constexpr size_t GetSignedAreaOffset(); }; static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader definition!"); constexpr size_t NrrHeader::GetSignedAreaOffset() { return AMS_OFFSETOF(NrrHeader, m_program_id); } class NroHeader { public: static constexpr u32 Magic = util::FourCC<'N','R','O','0'>::Code; static constexpr u32 FlagAlignedHeader = 1; private: u32 m_entrypoint_insn; u32 m_mod_offset; u8 m_reserved_08[0x8]; u32 m_magic; u8 m_version; u32 m_size; u32 m_flags; u32 m_text_offset; u32 m_text_size; u32 m_ro_offset; u32 m_ro_size; u32 m_rw_offset; u32 m_rw_size; u32 m_bss_size; u8 m_reserved_3C[0x4]; ModuleId m_module_id; u8 m_reserved_60[0x20]; public: bool IsMagicValid() const { return m_magic == Magic; } u32 GetVersion() const { return m_version; } u32 GetSize() const { return m_size; } u32 GetFlags() const { return m_flags; } bool IsAlignedHeader() const { return m_flags & FlagAlignedHeader; } u32 GetTextOffset() const { return m_text_offset; } u32 GetTextSize() const { return m_text_size; } u32 GetRoOffset() const { return m_ro_offset; } u32 GetRoSize() const { return m_ro_size; } u32 GetRwOffset() const { return m_rw_offset; } u32 GetRwSize() const { return m_rw_size; } u32 GetBssSize() const { return m_bss_size; } const ModuleId *GetModuleId() const { return std::addressof(m_module_id); } }; static_assert(sizeof(NroHeader) == 0x80, "NroHeader definition!"); }
6,086
C++
.h
174
23.563218
116
0.535921
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
7,818
ro_debug_monitor_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ro/impl/ro_debug_monitor_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/ro/ro_types.hpp> #include <stratosphere/ldr/ldr_types.hpp> #include <stratosphere/sf.hpp> #define AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessModuleInfo, (sf::Out<u32> out_count, const sf::OutArray<ldr::ModuleInfo> &out_infos, os::ProcessId process_id), (out_count, out_infos, process_id)) AMS_SF_DEFINE_INTERFACE(ams::ro::impl, IDebugMonitorInterface, AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO, 0xBBA11B0A)
1,310
C++
.h
23
55.043478
200
0.680685
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
7,819
ro_ro_exception_info.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ro/impl/ro_ro_exception_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 <vapours.hpp> namespace ams::ro::impl { struct ExceptionInfo { uintptr_t module_address; size_t module_size; uintptr_t info_offset; size_t info_size; }; bool GetExceptionInfo(ExceptionInfo *out, uintptr_t pc); }
917
C++
.h
26
31.884615
76
0.728298
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
7,820
ro_ro_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ro/impl/ro_ro_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/ro/ro_types.hpp> #include <stratosphere/sf.hpp> #define AMS_RO_I_RO_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, MapManualLoadModuleMemory, (sf::Out<u64> out_load_address, const sf::ClientProcessId &client_pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size), (out_load_address, client_pid, nro_address, nro_size, bss_address, bss_size)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, UnmapManualLoadModuleMemory, (const sf::ClientProcessId &client_pid, u64 nro_address), (client_pid, nro_address)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, RegisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size), (client_pid, nrr_address, nrr_size)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, UnregisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address), (client_pid, nrr_address)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, RegisterProcessHandle, (const sf::ClientProcessId &client_pid, sf::CopyHandle &&process_h), (client_pid, std::move(process_h))) \ AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterProcessModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle &&process_h), (client_pid, nrr_address, nrr_size, std::move(process_h)), hos::Version_7_0_0) AMS_SF_DEFINE_INTERFACE(ams::ro::impl, IRoInterface, AMS_RO_I_RO_INTERFACE_INTERFACE_INFO, 0xA52C55A9)
2,974
C++
.h
27
107.62963
303
0.514946
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
7,821
pgl_event_observer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <stratosphere/os.hpp> #include <stratosphere/pm.hpp> #include <stratosphere/pgl/pgl_types.hpp> #include <stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp> #include <stratosphere/pgl/tipc/pgl_tipc_i_event_observer.hpp> namespace ams::pgl { namespace impl { class EventObserverInterface { NON_COPYABLE(EventObserverInterface); NON_MOVEABLE(EventObserverInterface); public: constexpr EventObserverInterface() = default; virtual ~EventObserverInterface() { /* ... */ } virtual Result GetSystemEvent(os::SystemEventType *out) = 0; virtual Result GetProcessEventInfo(pm::ProcessEventInfo *out) = 0; }; class EventObserverByCmif final : public EventObserverInterface { NON_COPYABLE(EventObserverByCmif); NON_MOVEABLE(EventObserverByCmif); private: ams::sf::SharedPointer<pgl::sf::IEventObserver> m_cmif_interface; public: explicit EventObserverByCmif(ams::sf::SharedPointer<pgl::sf::IEventObserver> intf) : m_cmif_interface(intf) { /* ... */ } public: virtual Result GetSystemEvent(os::SystemEventType *out) override { ams::sf::NativeHandle handle; R_TRY(m_cmif_interface->GetProcessEventHandle(std::addressof(handle))); os::AttachReadableHandleToSystemEvent(out, handle.GetOsHandle(), handle.IsManaged(), os::EventClearMode_AutoClear); handle.Detach(); R_SUCCEED(); } virtual Result GetProcessEventInfo(pm::ProcessEventInfo *out) override { R_RETURN(m_cmif_interface->GetProcessEventInfo(out)); } }; template<typename T> requires tipc::IsIEventObserver<T> class EventObserverByTipc final : public EventObserverInterface { NON_COPYABLE(EventObserverByTipc); NON_MOVEABLE(EventObserverByTipc); private: T m_tipc_interface; public: template<typename... Args> explicit EventObserverByTipc(Args &&... args) : m_tipc_interface(std::forward<Args>(args)...) { /* ... */ } public: virtual Result GetSystemEvent(os::SystemEventType *out) override { os::NativeHandle handle; R_TRY(m_tipc_interface.GetProcessEventHandle(std::addressof(handle))); os::AttachReadableHandleToSystemEvent(out, handle, true, os::EventClearMode_AutoClear); R_SUCCEED(); } virtual Result GetProcessEventInfo(pm::ProcessEventInfo *out) override { R_RETURN(m_tipc_interface.GetProcessEventInfo(ams::tipc::Out<pm::ProcessEventInfo>(out))); } }; } class EventObserver { NON_COPYABLE(EventObserver); private: struct Deleter { void operator()(impl::EventObserverInterface *); }; public: using UniquePtr = std::unique_ptr<impl::EventObserverInterface, Deleter>; private: UniquePtr m_impl; public: EventObserver() { /* ... */ } explicit EventObserver(UniquePtr impl) : m_impl(std::move(impl)) { /* ... */ } EventObserver(EventObserver &&rhs) { m_impl = std::move(rhs.m_impl); } EventObserver &operator=(EventObserver &&rhs) { EventObserver(std::move(rhs)).Swap(*this); return *this; } void Swap(EventObserver &rhs) { std::swap(m_impl, rhs.m_impl); } public: Result GetSystemEvent(os::SystemEventType *out) { R_RETURN(m_impl->GetSystemEvent(out)); } Result GetProcessEventInfo(pm::ProcessEventInfo *out) { R_RETURN(m_impl->GetProcessEventInfo(out)); } }; }
4,761
C++
.h
104
34.144231
137
0.601466
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
7,822
pgl_shell_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/pgl_shell_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 <vapours.hpp> #include <stratosphere/pgl/pgl_types.hpp> #include <stratosphere/pgl/pgl_event_observer.hpp> namespace ams::pgl { Result Initialize(); void Finalize(); Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 process_flags, u8 pgl_flags); Result TerminateProcess(os::ProcessId process_id); Result LaunchProgramFromHost(os::ProcessId *out, const char *content_path, u32 process_flags); Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path); Result GetApplicationProcessId(os::ProcessId *out); Result BoostSystemMemoryResourceLimit(u64 size); Result IsProcessTracked(bool *out, os::ProcessId process_id); Result EnableApplicationCrashReport(bool enabled); Result IsApplicationCrashReportEnabled(bool *out); Result EnableApplicationAllThreadDumpOnCrash(bool enabled); Result TriggerApplicationSnapShotDumper(const char *arg, SnapShotDumpType dump_type); Result GetEventObserver(pgl::EventObserver *out); }
1,688
C++
.h
35
45.057143
111
0.775349
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
7,823
pgl_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/pgl_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 <vapours.hpp> #include <stratosphere/os.hpp> #include <stratosphere/pm.hpp> #include <stratosphere/ncm.hpp> namespace ams::pgl { enum LaunchFlags : u8 { LaunchFlags_None = 0, LaunchFlags_EnableDetailedCrashReport = (1 << 0), LaunchFlags_EnableCrashReportScreenShotForProduction = (1 << 1), LaunchFlags_EnableCrashReportScreenShotForDevelop = (1 << 2), }; enum class SnapShotDumpType : u32 { None = 0, Auto = 1, Full = 2, }; /* TODO: Is this really nn::ncm::Content<Something>Info? */ struct ContentMetaInfo { u64 id; u32 version; ncm::ContentType content_type; u8 id_offset; u8 reserved_0E[2]; static constexpr ContentMetaInfo Make(u64 id, u32 version, ncm::ContentType content_type, u8 id_offset) { return { .id = id, .version = version, .content_type = content_type, .id_offset = id_offset, }; } }; static_assert(sizeof(ContentMetaInfo) == 0x10 && util::is_pod<ContentMetaInfo>::value); }
1,859
C++
.h
50
31.12
113
0.631521
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
7,824
pgl_sf_i_shell_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_shell_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/os.hpp> #include <stratosphere/pm.hpp> #include <stratosphere/pgl/pgl_types.hpp> #include <stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp> #define AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (ams::sf::Out<os::ProcessId> out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags), (out, loc, pm_flags, pgl_flags)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, LaunchProgramFromHost, (ams::sf::Out<os::ProcessId> out, const ams::sf::InBuffer &content_path, u32 pm_flags), (out, content_path, pm_flags)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, GetHostContentMetaInfo, (ams::sf::Out<pgl::ContentMetaInfo> out, const ams::sf::InBuffer &content_path), (out, content_path)) \ AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (ams::sf::Out<os::ProcessId> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 6, Result, BoostSystemMemoryResourceLimit, (u64 size), (size)) \ AMS_SF_METHOD_INFO(C, H, 7, Result, IsProcessTracked, (ams::sf::Out<bool> out, os::ProcessId process_id), (out, process_id)) \ AMS_SF_METHOD_INFO(C, H, 8, Result, EnableApplicationCrashReport, (bool enabled), (enabled)) \ AMS_SF_METHOD_INFO(C, H, 9, Result, IsApplicationCrashReportEnabled, (ams::sf::Out<bool> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 10, Result, EnableApplicationAllThreadDumpOnCrash, (bool enabled), (enabled)) \ AMS_SF_METHOD_INFO(C, H, 12, Result, TriggerApplicationSnapShotDumper, (pgl::SnapShotDumpType dump_type, const ams::sf::InBuffer &arg), (dump_type, arg)) \ AMS_SF_METHOD_INFO(C, H, 20, Result, GetShellEventObserver, (ams::sf::Out<ams::sf::SharedPointer<pgl::sf::IEventObserver>> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 21, Result, Command21NotImplemented, (ams::sf::Out<u64> out, u32 in, const ams::sf::InBuffer &buf1, const ams::sf::InBuffer &buf2), (out, in, buf1, buf2), hos::Version_11_0_0) AMS_SF_DEFINE_INTERFACE(ams::pgl::sf, IShellInterface, AMS_PGL_I_SHELL_INTERFACE_INTERFACE_INFO, 0x00000000);
4,193
C++
.h
36
113.555556
231
0.479056
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
7,825
pgl_sf_i_event_observer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/os.hpp> #include <stratosphere/pm.hpp> #include <stratosphere/pgl/pgl_types.hpp> #define AMS_PGL_SF_I_EVENT_OBSERVER_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessEventHandle, (ams::sf::OutCopyHandle out), (out)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetProcessEventInfo, (ams::sf::Out<pm::ProcessEventInfo> out), (out)) AMS_SF_DEFINE_INTERFACE(ams::pgl::sf, IEventObserver, AMS_PGL_SF_I_EVENT_OBSERVER_INTERFACE_INFO, 0x00000000);
1,230
C++
.h
24
49.166667
113
0.707987
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
7,826
pgl_tipc_i_shell_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/tipc/pgl_tipc_i_shell_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/os.hpp> #include <stratosphere/pm.hpp> #include <stratosphere/tipc.hpp> #include <stratosphere/pgl/pgl_types.hpp> #include <stratosphere/pgl/tipc/pgl_tipc_i_event_observer.hpp> #define AMS_PGL_TIPC_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \ AMS_TIPC_METHOD_INFO(C, H, 0, Result, LaunchProgram, (ams::tipc::Out<os::ProcessId> out, const ncm::ProgramLocation loc, u32 pm_flags, u8 pgl_flags), (out, loc, pm_flags, pgl_flags)) \ AMS_TIPC_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \ AMS_TIPC_METHOD_INFO(C, H, 2, Result, LaunchProgramFromHost, (ams::tipc::Out<os::ProcessId> out, const ams::tipc::InBuffer content_path, u32 pm_flags), (out, content_path, pm_flags)) \ AMS_TIPC_METHOD_INFO(C, H, 4, Result, GetHostContentMetaInfo, (ams::tipc::Out<pgl::ContentMetaInfo> out, const ams::tipc::InBuffer content_path), (out, content_path)) \ AMS_TIPC_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (ams::tipc::Out<os::ProcessId> out), (out)) \ AMS_TIPC_METHOD_INFO(C, H, 6, Result, BoostSystemMemoryResourceLimit, (u64 size), (size)) \ AMS_TIPC_METHOD_INFO(C, H, 7, Result, IsProcessTracked, (ams::tipc::Out<bool> out, os::ProcessId process_id), (out, process_id)) \ AMS_TIPC_METHOD_INFO(C, H, 8, Result, EnableApplicationCrashReport, (bool enabled), (enabled)) \ AMS_TIPC_METHOD_INFO(C, H, 9, Result, IsApplicationCrashReportEnabled, (ams::tipc::Out<bool> out), (out)) \ AMS_TIPC_METHOD_INFO(C, H, 10, Result, EnableApplicationAllThreadDumpOnCrash, (bool enabled), (enabled)) \ AMS_TIPC_METHOD_INFO(C, H, 20, Result, GetShellEventObserver, (ams::tipc::OutMoveHandle out), (out)) AMS_TIPC_DEFINE_INTERFACE(ams::pgl::tipc, IShellInterface, AMS_PGL_TIPC_I_SHELL_INTERFACE_INTERFACE_INFO);
3,521
C++
.h
35
97.857143
213
0.511341
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
7,827
pgl_tipc_i_event_observer.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/tipc/pgl_tipc_i_event_observer.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/os.hpp> #include <stratosphere/pm.hpp> #include <stratosphere/tipc.hpp> #include <stratosphere/pgl/pgl_types.hpp> #define AMS_PGL_TIPC_I_EVENT_OBSERVER_INTERFACE_INFO(C, H) \ AMS_TIPC_METHOD_INFO(C, H, 0, Result, GetProcessEventHandle, (ams::tipc::OutCopyHandle out), (out)) \ AMS_TIPC_METHOD_INFO(C, H, 1, Result, GetProcessEventInfo, (ams::tipc::Out<pm::ProcessEventInfo> out), (out)) AMS_TIPC_DEFINE_INTERFACE(ams::pgl::tipc, IEventObserver, AMS_PGL_TIPC_I_EVENT_OBSERVER_INTERFACE_INFO);
1,269
C++
.h
25
48.72
117
0.712097
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
7,828
pgl_srv_shell_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/srv/pgl_srv_shell_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/pgl/pgl_types.hpp> #include <stratosphere/pgl/sf/pgl_sf_i_shell_interface.hpp> #include <stratosphere/pgl/tipc/pgl_tipc_i_shell_interface.hpp> namespace ams::pgl::srv { class ShellInterfaceCommon { NON_COPYABLE(ShellInterfaceCommon); NON_MOVEABLE(ShellInterfaceCommon); public: constexpr ShellInterfaceCommon() = default; public: Result LaunchProgramImpl(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags); Result TerminateProcessImpl(os::ProcessId process_id); Result LaunchProgramFromHostImpl(os::ProcessId *out, const void *content_path, size_t content_path_size, u32 pm_flags); Result GetHostContentMetaInfoImpl(pgl::ContentMetaInfo *out, const void *content_path, size_t content_path_size); Result GetApplicationProcessIdImpl(os::ProcessId *out); Result BoostSystemMemoryResourceLimitImpl(u64 size); Result IsProcessTrackedImpl(bool *out, os::ProcessId process_id); Result EnableApplicationCrashReportImpl(bool enabled); Result IsApplicationCrashReportEnabledImpl(bool *out); Result EnableApplicationAllThreadDumpOnCrashImpl(bool enabled); Result TriggerApplicationSnapShotDumperImpl(SnapShotDumpType dump_type, const void *arg, size_t arg_size); }; class ShellInterfaceCmif : public ShellInterfaceCommon { NON_COPYABLE(ShellInterfaceCmif); NON_MOVEABLE(ShellInterfaceCmif); private: using Allocator = ams::sf::ExpHeapAllocator; using ObjectFactory = ams::sf::ObjectFactory<ams::sf::ExpHeapAllocator::Policy>; private: Allocator *m_allocator; public: constexpr ShellInterfaceCmif(Allocator *a) : ShellInterfaceCommon(), m_allocator(a) { /* ... */ } public: /* Interface commands. */ Result LaunchProgram(ams::sf::Out<os::ProcessId> out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags); Result TerminateProcess(os::ProcessId process_id); Result LaunchProgramFromHost(ams::sf::Out<os::ProcessId> out, const ams::sf::InBuffer &content_path, u32 pm_flags); Result GetHostContentMetaInfo(ams::sf::Out<pgl::ContentMetaInfo> out, const ams::sf::InBuffer &content_path); Result GetApplicationProcessId(ams::sf::Out<os::ProcessId> out); Result BoostSystemMemoryResourceLimit(u64 size); Result IsProcessTracked(ams::sf::Out<bool> out, os::ProcessId process_id); Result EnableApplicationCrashReport(bool enabled); Result IsApplicationCrashReportEnabled(ams::sf::Out<bool> out); Result EnableApplicationAllThreadDumpOnCrash(bool enabled); Result TriggerApplicationSnapShotDumper(SnapShotDumpType dump_type, const ams::sf::InBuffer &arg); Result GetShellEventObserver(ams::sf::Out<ams::sf::SharedPointer<pgl::sf::IEventObserver>> out); Result Command21NotImplemented(ams::sf::Out<u64> out, u32 in, const ams::sf::InBuffer &buf1, const ams::sf::InBuffer &buf2); }; static_assert(pgl::sf::IsIShellInterface<ShellInterfaceCmif>); class ShellInterfaceTipc : public ShellInterfaceCommon { NON_COPYABLE(ShellInterfaceTipc); NON_MOVEABLE(ShellInterfaceTipc); public: constexpr ShellInterfaceTipc() : ShellInterfaceCommon() { /* ... */ } public: /* Interface commands. */ Result LaunchProgram(ams::tipc::Out<os::ProcessId> out, const ncm::ProgramLocation loc, u32 pm_flags, u8 pgl_flags); Result TerminateProcess(os::ProcessId process_id); Result LaunchProgramFromHost(ams::tipc::Out<os::ProcessId> out, const ams::tipc::InBuffer content_path, u32 pm_flags); Result GetHostContentMetaInfo(ams::tipc::Out<pgl::ContentMetaInfo> out, const ams::tipc::InBuffer content_path); Result GetApplicationProcessId(ams::tipc::Out<os::ProcessId> out); Result BoostSystemMemoryResourceLimit(u64 size); Result IsProcessTracked(ams::tipc::Out<bool> out, os::ProcessId process_id); Result EnableApplicationCrashReport(bool enabled); Result IsApplicationCrashReportEnabled(ams::tipc::Out<bool> out); Result EnableApplicationAllThreadDumpOnCrash(bool enabled); Result GetShellEventObserver(ams::tipc::OutMoveHandle out); }; static_assert(pgl::tipc::IsIShellInterface<ShellInterfaceTipc>); }
5,263
C++
.h
87
51.678161
136
0.703868
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
7,829
pgl_srv_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pgl/srv/pgl_srv_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 <vapours.hpp> #include <stratosphere/pgl/pgl_types.hpp> #include <stratosphere/pgl/srv/pgl_srv_shell_interface.hpp> namespace ams::pgl::srv { void InitializeHeap(); void *Allocate(size_t size); void Deallocate(void *p, size_t size); void StartServer(); }
932
C++
.h
25
34.92
76
0.749723
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
7,830
usb_limits.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/usb_limits.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 <vapours.hpp> #include <stratosphere/dd/dd_device_address_space_common.hpp> namespace ams::usb { constexpr inline int HwLimitDmaBufferAlignmentSize = dd::DeviceAddressSpaceMemoryRegionAlignment; constexpr inline int HwLimitDataCacheLineSize = 0x40; constexpr inline int HwLimitMaxPortCount = 0x4; constexpr inline int UsbLimitMaxEndpointsCount = 0x20; constexpr inline int UsbLimitMaxEndpointPairCount = 0x10; constexpr inline int DsLimitMaxConfigurationsPerDeviceCount = 1; constexpr inline int DsLimitMaxInterfacesPerConfigurationCount = 4; constexpr inline int DsLimitMaxNameSize = 0x40; constexpr inline int DsLimitRingSize = 8; }
1,403
C++
.h
29
45.482759
101
0.747261
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
7,831
usb_device_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/usb_device_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 <vapours.hpp> #include <stratosphere/usb/usb_limits.hpp> #include <stratosphere/usb/usb_types.hpp> namespace ams::usb { constexpr inline u8 InterfaceNumberAuto = DsLimitMaxInterfacesPerConfigurationCount; constexpr inline u8 EndpointAddressAutoIn = UsbEndpointAddressMask_DirDevicetoHost; constexpr inline u8 EndpointAddressAutoOut = UsbEndpointAddressMask_DirHostToDevice; enum UrbStatus { UrbStatus_Invalid = 0, UrbStatus_Pending = 1, UrbStatus_Running = 2, UrbStatus_Finished = 3, UrbStatus_Cancelled = 4, UrbStatus_Failed = 5, }; struct UrbReport { struct Report { u32 id; u32 requested_size; u32 transferred_size; UrbStatus status; } reports[DsLimitRingSize]; u32 count; }; enum DsString { DsString_Max = 0x20, }; struct DsVidPidBcd { uint16_t idVendor; uint16_t idProduct; uint16_t bcdDevice; char manufacturer[DsString_Max]; char product[DsString_Max]; char serial_number[DsString_Max]; }; }
1,798
C++
.h
52
28.923077
91
0.691024
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
7,832
usb_device.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/usb_device.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 <vapours.hpp> #include <stratosphere/os/os_system_event.hpp> #include <stratosphere/sf/sf_lmem_utility.hpp> #include <stratosphere/usb/usb_limits.hpp> #include <stratosphere/usb/usb_device_types.hpp> #include <stratosphere/usb/ds/usb_i_ds_service.hpp> namespace ams::usb { class DsInterface; class DsEndpoint; class DsClient { friend class DsInterface; friend class DsEndpoint; private: /* NOTE: Nintendo uses a UnitHeap here on newer firmware versions. */ /* For now, we'll use an ExpHeap and do it the old way. */ sf::ExpHeapAllocator m_allocator{}; u8 m_heap_buffer[32_KB]; lmem::HeapHandle m_heap_handle{}; sf::SharedPointer<ds::IDsRootSession> m_root_session{}; sf::SharedPointer<ds::IDsService> m_ds_service{}; bool m_is_initialized{false}; std::atomic<int> m_reference_count{0}; os::SystemEventType m_state_change_event{}; DsInterface *m_interfaces[DsLimitMaxInterfacesPerConfigurationCount]{}; bool m_is_enabled{false}; public: DsClient() = default; ~DsClient() { /* ... */ } public: Result Initialize(ComplexId complex_id); Result Finalize(); bool IsInitialized(); Result EnableDevice(); Result DisableDevice(); os::SystemEventType *GetStateChangeEvent(); Result GetState(UsbState *out); Result ClearDeviceData(); Result AddUsbStringDescriptor(u8 *out_index, UsbStringDescriptor *desc); Result DeleteUsbStringDescriptor(u8 index); Result SetUsbDeviceDescriptor(UsbDeviceDescriptor *desc, UsbDeviceSpeed speed); Result SetBinaryObjectStore(u8 *data, int size); private: Result AddInterface(DsInterface *intf, sf::SharedPointer<ds::IDsInterface> *out_srv, uint8_t bInterfaceNumber); Result DeleteInterface(uint8_t bInterfaceNumber); }; class DsInterface { friend class DsEndpoint; private: DsClient *m_client; sf::SharedPointer<ds::IDsInterface> m_interface; bool m_is_initialized; std::atomic<int> m_reference_count; os::SystemEventType m_setup_event; os::SystemEventType m_ctrl_in_completion_event; os::SystemEventType m_ctrl_out_completion_event; UrbReport m_report; u8 m_interface_num; DsEndpoint *m_endpoints[UsbLimitMaxEndpointsCount]; public: DsInterface() : m_client(nullptr), m_is_initialized(false), m_reference_count(0) { /* ... */ } ~DsInterface() { /* ... */ } public: Result Initialize(DsClient *client, u8 bInterfaceNumber); Result Finalize(); Result AppendConfigurationData(UsbDeviceSpeed speed, void *data, u32 size); bool IsInitialized(); os::SystemEventType *GetSetupEvent(); Result GetSetupPacket(UsbCtrlRequest *out); Result Enable(); Result Disable(); Result CtrlRead(u32 *out_transferred, void *dst, u32 size); Result CtrlWrite(u32 *out_transferred, void *dst, u32 size); Result CtrlDone(); Result CtrlStall(); private: Result AddEndpoint(DsEndpoint *ep, u8 bEndpointAddress, sf::SharedPointer<ds::IDsEndpoint> *out); Result DeleteEndpoint(u8 bEndpointAddress); Result CtrlIn(u32 *out_transferred, void *dst, u32 size); Result CtrlOut(u32 *out_transferred, void *dst, u32 size); }; class DsEndpoint { private: bool m_is_initialized; bool m_is_new_format; std::atomic<int> m_reference_count; DsInterface *m_interface; sf::SharedPointer<ds::IDsEndpoint> m_endpoint; u8 m_address; os::SystemEventType m_completion_event; os::SystemEventType m_unknown_event; public: DsEndpoint() : m_is_initialized(false), m_is_new_format(false), m_reference_count(0) { /* ... */ } public: Result Initialize(DsInterface *interface, u8 bEndpointAddress); Result Finalize(); bool IsInitialized(); Result PostBuffer(u32 *out_transferred, void *buf, u32 size); Result PostBufferAsync(u32 *out_urb_id, void *buf, u32 size); os::SystemEventType *GetCompletionEvent(); Result GetUrbReport(UrbReport *out); Result Cancel(); Result SetZeroLengthTransfer(bool zlt); }; }
5,385
C++
.h
120
34.95
123
0.632824
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
7,833
usb_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/usb_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 <vapours.hpp> #include <stratosphere/usb/usb_limits.hpp> namespace ams::usb { constexpr ALWAYS_INLINE bool IsDmaAligned(u64 address) { return util::IsAligned(address, static_cast<u64>(HwLimitDmaBufferAlignmentSize)); } enum ComplexId { ComplexId_Tegra21x = 2, }; enum UsbDescriptorType { UsbDescriptorType_Device = 1, UsbDescriptorType_Config = 2, UsbDescriptorType_String = 3, UsbDescriptorType_Interface = 4, UsbDescriptorType_Endpoint = 5, UsbDescriptorType_DeviceQualifier = 6, UsbDescriptorType_OtherSpeedConfig = 7, UsbDescriptorType_InterfacePower = 8, UsbDescriptorType_Otg = 9, UsbDescriptorType_Debug = 10, UsbDescriptorType_InterfaceAssociation = 11, UsbDescriptorType_Bos = 15, UsbDescriptorType_DeviceCapability = 16, UsbDescriptorType_Hid = 33, UsbDescriptorType_Report = 34, UsbDescriptorType_Physical = 35, UsbDescriptorType_Hub = 41, UsbDescriptorType_EndpointCompanion = 48, UsbDescriptorType_IsocEndpointCompanion = 49, }; struct UsbDescriptorHeader { uint8_t bLength; uint8_t bDescriptorType; } PACKED; struct UsbInterfaceDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; uint8_t bNumEndpoints; uint8_t bInterfaceClass; uint8_t bInterfaceSubClass; uint8_t bInterfaceProtocol; uint8_t iInterface; } PACKED; struct UsbEndpointDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bEndpointAddress; uint8_t bmAttributes; uint16_t wMaxPacketSize; uint8_t bInterval; } PACKED; struct UsbDeviceDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint16_t idVendor; uint16_t idProduct; uint16_t bcdDevice; uint8_t iManufacturer; uint8_t iProduct; uint8_t iSerialNumber; uint8_t bNumConfigurations; } PACKED; struct UsbConfigDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t wTotalLength; uint8_t bNumInterfaces; uint8_t bConfigurationValue; uint8_t iConfiguration; uint8_t bmAttributes; uint8_t bMaxPower; } PACKED; struct UsbEndpointCompanionDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bMaxBurst; uint8_t bmAttributes; uint16_t wBytesPerInterval; } PACKED; struct UsbStringDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t wData[DsLimitMaxNameSize]; } PACKED; struct UsbCtrlRequest { uint8_t bmRequestType; uint8_t bRequest; uint16_t wValue; uint16_t wIndex; uint16_t wLength; } PACKED; enum UsbState { UsbState_Detached = 0, UsbState_Attached = 1, UsbState_Powered = 2, UsbState_Default = 3, UsbState_Address = 4, UsbState_Configured = 5, UsbState_Suspended = 6, }; enum UsbDescriptorSize { UsbDescriptorSize_Interface = sizeof(UsbInterfaceDescriptor), UsbDescriptorSize_Endpoint = sizeof(UsbEndpointDescriptor), UsbDescriptorSize_Device = sizeof(UsbDeviceDescriptor), UsbDescriptorSize_Config = sizeof(UsbConfigDescriptor), UsbDescriptorSize_EndpointCompanion = sizeof(UsbEndpointCompanionDescriptor), }; enum UsbDeviceSpeed { UsbDeviceSpeed_Invalid = 0, UsbDeviceSpeed_Low = 1, UsbDeviceSpeed_Full = 2, UsbDeviceSpeed_High = 3, UsbDeviceSpeed_Super = 4, UsbDeviceSpeed_SuperPlus = 5, }; enum UsbEndpointAddressMask { UsbEndpointAddressMask_EndpointNumber = (0xF << 0), UsbEndpointAddressMask_Dir = (0x1 << 7), UsbEndpointAddressMask_DirHostToDevice = (0x0 << 7), UsbEndpointAddressMask_DirDevicetoHost = (0x1 << 7), }; enum UsbEndpointAttributeMask { UsbEndpointAttributeMask_XferType = (0x3 << 0), UsbEndpointAttributeMask_XferTypeControl = (0x0 << 0), UsbEndpointAttributeMask_XferTypeIsoc = (0x1 << 0), UsbEndpointAttributeMask_XferTypeBulk = (0x2 << 0), UsbEndpointAttributeMask_XferTypeInt = (0x3 << 0), }; enum UsbEndpointDirection { UsbEndpointDirection_Invalid = 0, UsbEndpointDirection_ToDevice = 1, UsbEndpointDirection_ToHost = 2, UsbEndpointDirection_Control = 3, }; constexpr inline u8 UsbGetEndpointNumber(const UsbEndpointDescriptor *desc) { return desc->bEndpointAddress & UsbEndpointAddressMask_EndpointNumber; } constexpr inline bool UsbEndpointIsHostToDevice(const UsbEndpointDescriptor *desc) { return (desc->bEndpointAddress & UsbEndpointAddressMask_Dir) == UsbEndpointAddressMask_DirHostToDevice; } constexpr inline bool UsbEndpointIsDeviceToHost(const UsbEndpointDescriptor *desc) { return (desc->bEndpointAddress & UsbEndpointAddressMask_Dir) == UsbEndpointAddressMask_DirDevicetoHost; } constexpr inline u8 UsbGetEndpointAddress(u8 number, UsbEndpointDirection dir) { u8 val = static_cast<u8>(number & UsbEndpointAddressMask_EndpointNumber); if (dir == UsbEndpointDirection_ToHost) { val |= UsbEndpointAddressMask_DirDevicetoHost; } else { val |= UsbEndpointAddressMask_DirHostToDevice; } return val; } constexpr inline UsbEndpointDirection GetUsbEndpointDirection(const UsbEndpointDescriptor *desc) { if (UsbEndpointIsDeviceToHost(desc)) { return UsbEndpointDirection_ToHost; } else { return UsbEndpointDirection_ToDevice; } } constexpr inline bool UsbEndpointIsValid(const UsbEndpointDescriptor *desc) { return desc != nullptr && desc->bLength >= UsbDescriptorSize_Endpoint && desc->bEndpointAddress != 0; } constexpr inline void UsbMarkEndpointInvalid(UsbEndpointDescriptor *desc) { desc->bLength = 0; desc->bEndpointAddress = 0; } }
7,502
C++
.h
190
32.005263
111
0.645968
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
7,834
usb_i_ds_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/usb/usb_limits.hpp> #include <stratosphere/usb/usb_types.hpp> #include <stratosphere/usb/usb_device_types.hpp> #include <stratosphere/usb/ds/usb_i_ds_endpoint.hpp> #define AMS_USB_I_DS_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, RegisterEndpoint, (u8 endpoint_address, sf::Out<sf::SharedPointer<usb::ds::IDsEndpoint>> out), (endpoint_address, out)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetSetupEvent, (sf::OutCopyHandle out), (out)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, GetSetupPacket, (const sf::OutBuffer &out), (out)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, CtrlInAsync, (sf::Out<u32> out_urb_id, u64 address, u32 size), (out_urb_id, address, size)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, CtrlOutAsync, (sf::Out<u32> out_urb_id, u64 address, u32 size), (out_urb_id, address, size)) \ AMS_SF_METHOD_INFO(C, H, 5, Result, GetCtrlInCompletionEvent, (sf::OutCopyHandle out), (out)) \ AMS_SF_METHOD_INFO(C, H, 6, Result, GetCtrlInUrbReport, (sf::Out<usb::UrbReport> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 7, Result, GetCtrlOutCompletionEvent, (sf::OutCopyHandle out), (out)) \ AMS_SF_METHOD_INFO(C, H, 8, Result, GetCtrlOutUrbReport, (sf::Out<usb::UrbReport> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 9, Result, CtrlStall, (), ()) \ AMS_SF_METHOD_INFO(C, H, 10, Result, AppendConfigurationData, (u8 bInterfaceNumber, usb::UsbDeviceSpeed device_speed, const sf::InBuffer &data), (bInterfaceNumber, device_speed, data)) \ AMS_SF_METHOD_INFO(C, H, 65000, Result, Enable, (), ()) \ AMS_SF_METHOD_INFO(C, H, 65001, Result, Disable, (), ()) /* TODO: Deprecated interface? */ AMS_SF_DEFINE_INTERFACE(ams::usb::ds, IDsInterface, AMS_USB_I_DS_INTERFACE_INTERFACE_INFO, 0x5632AFB2)
3,705
C++
.h
37
97.243243
195
0.46643
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
7,835
usb_i_ds_service.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_service.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/usb/usb_limits.hpp> #include <stratosphere/usb/usb_types.hpp> #include <stratosphere/usb/usb_device_types.hpp> #include <stratosphere/usb/ds/usb_i_ds_interface.hpp> #define AMS_USB_I_DS_SERVICE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, Bind, (usb::ComplexId complex_id, sf::CopyHandle &&process_h), (complex_id, std::move(process_h))) \ AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterInterface, (sf::Out<sf::SharedPointer<usb::ds::IDsInterface>> out, u8 bInterfaceNumber), (out, bInterfaceNumber)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, GetStateChangeEvent, (sf::OutCopyHandle out), (out)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, GetState, (sf::Out<usb::UsbState> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, ClearDeviceData, (), ()) \ AMS_SF_METHOD_INFO(C, H, 5, Result, AddUsbStringDescriptor, (sf::Out<u8> out, const sf::InBuffer &desc), (out, desc)) \ AMS_SF_METHOD_INFO(C, H, 6, Result, DeleteUsbStringDescriptor, (u8 index), (index)) \ AMS_SF_METHOD_INFO(C, H, 7, Result, SetUsbDeviceDescriptor, (const sf::InBuffer &desc, usb::UsbDeviceSpeed speed), (desc, speed)) \ AMS_SF_METHOD_INFO(C, H, 8, Result, SetBinaryObjectStore, (const sf::InBuffer &bos), (bos)) \ AMS_SF_METHOD_INFO(C, H, 9, Result, Enable, (), ()) \ AMS_SF_METHOD_INFO(C, H, 10, Result, Disable, (), ()) /* TODO: Deprecated interface? */ AMS_SF_DEFINE_INTERFACE(ams::usb::ds, IDsService, AMS_USB_I_DS_SERVICE_INTERFACE_INFO, 0x306DB3C1) #define AMS_USB_I_DS_ROOT_SESSION_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, GetService, (sf::Out<sf::SharedPointer<usb::ds::IDsService>> out), (out)) AMS_SF_DEFINE_INTERFACE(ams::usb::ds, IDsRootSession, AMS_USB_I_DS_ROOT_SESSION_INTERFACE_INFO, 0x2EC38748)
3,451
C++
.h
38
88.026316
183
0.503669
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
7,836
usb_i_ds_endpoint.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_endpoint.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/usb/usb_limits.hpp> #include <stratosphere/usb/usb_types.hpp> #include <stratosphere/usb/usb_device_types.hpp> #define AMS_USB_I_DS_ENDPOINT_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, PostBufferAsync, (sf::Out<u32> out_urb_id, u64 address, u32 size), (out_urb_id, address, size)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, Cancel, (), ()) \ AMS_SF_METHOD_INFO(C, H, 2, Result, GetCompletionEvent, (sf::OutCopyHandle out), (out)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, GetUrbReport, (sf::Out<usb::UrbReport> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, Stall, (), ()) \ AMS_SF_METHOD_INFO(C, H, 5, Result, SetZlt, (bool zlt), (zlt)) /* TODO: Deprecated interface? */ AMS_SF_DEFINE_INTERFACE(ams::usb::ds, IDsEndpoint, AMS_USB_I_DS_ENDPOINT_INTERFACE_INFO, 0x107E43A4)
1,935
C++
.h
29
64.275862
144
0.554154
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
7,837
err_error_context.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/err/err_error_context.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 <vapours.hpp> #include <stratosphere/sf/sf_buffer_tags.hpp> namespace ams::err { enum class ErrorContextType : u8 { None = 0, Http = 1, FileSystem = 2, WebMediaPlayer = 3, LocalContentShare = 4, }; struct PaddingErrorContext { u8 padding[0x200 - 8]; }; struct ErrorContext : public sf::LargeData, public sf::PrefersMapAliasTransferMode { ErrorContextType type; u8 reserved[7]; union { PaddingErrorContext padding; }; }; static_assert(sizeof(ErrorContext) == 0x200); static_assert(util::is_pod<ErrorContext>::value); struct ContextDescriptor { int value; constexpr ALWAYS_INLINE bool operator==(const ContextDescriptor &rhs) const { return this->value == rhs.value; } constexpr ALWAYS_INLINE bool operator!=(const ContextDescriptor &rhs) const { return this->value != rhs.value; } constexpr ALWAYS_INLINE bool operator< (const ContextDescriptor &rhs) const { return this->value < rhs.value; } constexpr ALWAYS_INLINE bool operator<=(const ContextDescriptor &rhs) const { return this->value <= rhs.value; } constexpr ALWAYS_INLINE bool operator> (const ContextDescriptor &rhs) const { return this->value > rhs.value; } constexpr ALWAYS_INLINE bool operator>=(const ContextDescriptor &rhs) const { return this->value >= rhs.value; } }; constexpr inline const ContextDescriptor InvalidContextDescriptor{ -1 }; namespace impl { constexpr inline const ContextDescriptor ContextDescriptorMin{ 0x001 }; constexpr inline const ContextDescriptor ContextDescriptorMax{ 0x1FF }; } constexpr Result MakeResultWithContextDescriptor(Result result, ContextDescriptor descriptor) { /* Check pre-conditions. */ AMS_ASSERT(R_FAILED(result)); AMS_ASSERT(descriptor != InvalidContextDescriptor); AMS_ASSERT(impl::ContextDescriptorMin <= descriptor && descriptor <= impl::ContextDescriptorMax); return result::impl::ResultInternalAccessor::MergeReserved(result, descriptor.value | 0x200); } constexpr ContextDescriptor GetContextDescriptorFromResult(Result result) { /* Check pre-conditions. */ AMS_ASSERT(R_FAILED(result)); /* Get reserved bits. */ const auto reserved = result::impl::ResultInternalAccessor::GetReserved(result); if ((reserved & 0x200) != 0x200) { return InvalidContextDescriptor; } /* Check the descriptor value. */ const ContextDescriptor descriptor{static_cast<decltype(ContextDescriptor{}.value)>(reserved & ~0x200)}; if (!(impl::ContextDescriptorMin <= descriptor && descriptor <= impl::ContextDescriptorMax)) { return InvalidContextDescriptor; } return descriptor; } }
3,568
C++
.h
75
41.026667
120
0.691799
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
7,838
err_system_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/err/err_system_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 <vapours.hpp> #include <stratosphere/err/err_types.hpp> namespace ams::err { ErrorCode ConvertResultToErrorCode(const Result &result); void GetErrorCodeString(char *dst, size_t dst_size, ErrorCode error_code); }
880
C++
.h
22
37.863636
78
0.763743
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
7,839
err_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/err/err_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 <vapours.hpp> namespace ams::err { using ErrorCodeCategory = u32; using ErrorCodeNumber = u32; struct ErrorCode { static constexpr auto StringLengthMax = 15; ErrorCodeCategory category; ErrorCodeNumber number; constexpr ALWAYS_INLINE bool IsValid() const { return this->category > 0; } }; constexpr inline ErrorCode InvalidErrorCode = { .category = 0, .number = 0, }; }
1,110
C++
.h
31
31.806452
83
0.716418
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
7,840
ldr_pm_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ldr/ldr_pm_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/ldr/ldr_types.hpp> namespace ams::ldr::pm { /* Process Manager API. */ Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle reslimit); Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc); Result PinProgram(PinId *out, const ncm::ProgramLocation &loc); Result UnpinProgram(PinId pin_id); Result SetEnabledProgramVerification(bool enabled); Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id); /* Atmosphere extension API. */ Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc); Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status); }
1,438
C++
.h
29
46.551724
120
0.760684
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
7,841
ldr_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ldr/ldr_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 <vapours.hpp> #include <stratosphere/ncm/ncm_ids.hpp> #include <stratosphere/ncm/ncm_program_location.hpp> #include <stratosphere/sf/sf_buffer_tags.hpp> #include <stratosphere/ncm/ncm_content_meta_platform.hpp> namespace ams::ldr { /* General types. */ struct ProgramInfo : public sf::LargeData { u8 main_thread_priority; u8 default_cpu_id; u16 flags; u32 main_thread_stack_size; ncm::ProgramId program_id; u32 acid_sac_size; u32 aci_sac_size; u32 acid_fac_size; u32 aci_fah_size; u8 unused_20[0x10]; u8 ac_buffer[0x3E0]; }; static_assert(util::is_pod<ProgramInfo>::value && sizeof(ProgramInfo) == 0x410, "ProgramInfo definition!"); enum ProgramInfoFlag { ProgramInfoFlag_SystemModule = (0 << 0), ProgramInfoFlag_Application = (1 << 0), ProgramInfoFlag_Applet = (2 << 0), ProgramInfoFlag_InvalidType = (3 << 0), ProgramInfoFlag_ApplicationTypeMask = (3 << 0), ProgramInfoFlag_AllowDebug = (1 << 2), }; enum CreateProcessFlag { CreateProcessFlag_EnableDebug = (1 << 0), CreateProcessFlag_DisableAslr = (1 << 1), }; struct ProgramArguments { u32 allocated_size; u32 arguments_size; u8 reserved[0x18]; u8 arguments[]; }; static_assert(sizeof(ProgramArguments) == 0x20, "ProgramArguments definition!"); struct PinId { u64 value; }; inline bool operator==(const PinId &lhs, const PinId &rhs) { return lhs.value == rhs.value; } inline bool operator!=(const PinId &lhs, const PinId &rhs) { return lhs.value != rhs.value; } static_assert(sizeof(PinId) == sizeof(u64) && util::is_pod<PinId>::value, "PinId definition!"); struct ModuleInfo { u8 module_id[0x20]; u64 address; u64 size; }; static_assert(sizeof(ModuleInfo) == 0x30); /* NSO types. */ struct NsoHeader { static constexpr u32 Magic = util::FourCC<'N','S','O','0'>::Code; enum Segment : size_t { Segment_Text = 0, Segment_Ro = 1, Segment_Rw = 2, Segment_Count, }; enum Flag : u32 { Flag_CompressedText = (1 << 0), Flag_CompressedRo = (1 << 1), Flag_CompressedRw = (1 << 2), Flag_CheckHashText = (1 << 3), Flag_CheckHashRo = (1 << 4), Flag_CheckHashRw = (1 << 5), }; struct SegmentInfo { u32 file_offset; u32 dst_offset; u32 size; u32 reserved; }; u32 magic; u32 version; u32 reserved_08; u32 flags; union { struct { u32 text_file_offset; u32 text_dst_offset; u32 text_size; u32 unk_file_offset; u32 ro_file_offset; u32 ro_dst_offset; u32 ro_size; u32 unk_size; u32 rw_file_offset; u32 rw_dst_offset; u32 rw_size; u32 bss_size; }; SegmentInfo segments[Segment_Count]; }; u8 module_id[sizeof(ModuleInfo::module_id)]; union { u32 compressed_sizes[Segment_Count]; struct { u32 text_compressed_size; u32 ro_compressed_size; u32 rw_compressed_size; }; }; u8 reserved_6C[0x34]; union { u8 segment_hashes[Segment_Count][crypto::Sha256Generator::HashSize]; struct { u8 text_hash[crypto::Sha256Generator::HashSize]; u8 ro_hash[crypto::Sha256Generator::HashSize]; u8 rw_hash[crypto::Sha256Generator::HashSize]; }; }; }; static_assert(sizeof(NsoHeader) == 0x100 && util::is_pod<NsoHeader>::value, "NsoHeader definition!"); /* NPDM types. */ struct Aci { static constexpr u32 Magic = util::FourCC<'A','C','I','0'>::Code; u32 magic; u8 reserved_04[0xC]; ncm::ProgramId program_id; u8 reserved_18[0x8]; u32 fah_offset; u32 fah_size; u32 sac_offset; u32 sac_size; u32 kac_offset; u32 kac_size; u8 reserved_38[0x8]; }; static_assert(sizeof(Aci) == 0x40 && util::is_pod<Aci>::value, "Aci definition!"); struct Acid { static constexpr u32 Magic = util::FourCC<'A','C','I','D'>::Code; enum AcidFlag { AcidFlag_Production = (1 << 0), AcidFlag_UnqualifiedApproval = (1 << 1), AcidFlag_DeprecatedUseSecureMemory = (1 << 2), AcidFlag_PoolPartitionShift = 2, AcidFlag_PoolPartitionMask = (0xF << AcidFlag_PoolPartitionShift), }; enum PoolPartition { PoolPartition_Application = 0, PoolPartition_Applet = 1, PoolPartition_System = 2, PoolPartition_SystemNonSecure = 3, }; #if defined(ATMOSPHERE_OS_HORIZON) static_assert(PoolPartition_Application == (svc::CreateProcessFlag_PoolPartitionApplication >> svc::CreateProcessFlag_PoolPartitionShift)); static_assert(PoolPartition_Applet == (svc::CreateProcessFlag_PoolPartitionApplet >> svc::CreateProcessFlag_PoolPartitionShift)); static_assert(PoolPartition_System == (svc::CreateProcessFlag_PoolPartitionSystem >> svc::CreateProcessFlag_PoolPartitionShift)); static_assert(PoolPartition_SystemNonSecure == (svc::CreateProcessFlag_PoolPartitionSystemNonSecure >> svc::CreateProcessFlag_PoolPartitionShift)); #endif u8 signature[0x100]; u8 modulus[0x100]; u32 magic; u32 size; u8 version; u8 unknown_209; u8 reserved_20A[2]; u32 flags; ncm::ProgramId program_id_min; ncm::ProgramId program_id_max; u32 fac_offset; u32 fac_size; u32 sac_offset; u32 sac_size; u32 kac_offset; u32 kac_size; u8 reserved_238[0x8]; }; static_assert(sizeof(Acid) == 0x240 && util::is_pod<Acid>::value, "Acid definition!"); struct Npdm { static constexpr u32 Magic = util::FourCC<'M','E','T','A'>::Code; enum MetaFlag { MetaFlag_Is64Bit = (1 << 0), MetaFlag_AddressSpaceTypeShift = 1, MetaFlag_AddressSpaceTypeMask = (7 << MetaFlag_AddressSpaceTypeShift), MetaFlag_OptimizeMemoryAllocation = (1 << 4), MetaFlag_DisableDeviceAddressSpaceMerge = (1 << 5), MetaFlag_EnableAliasRegionExtraSize = (1 << 6), MetaFlag_PreventCodeReads = (1 << 7), }; enum AddressSpaceType { AddressSpaceType_32Bit = 0, AddressSpaceType_64BitDeprecated = 1, AddressSpaceType_32BitWithoutAlias = 2, AddressSpaceType_64Bit = 3, }; #if defined(ATMOSPHERE_OS_HORIZON) static_assert(AddressSpaceType_32Bit == (svc::CreateProcessFlag_AddressSpace32Bit >> svc::CreateProcessFlag_AddressSpaceShift)); static_assert(AddressSpaceType_64BitDeprecated == (svc::CreateProcessFlag_AddressSpace64BitDeprecated >> svc::CreateProcessFlag_AddressSpaceShift)); static_assert(AddressSpaceType_32BitWithoutAlias == (svc::CreateProcessFlag_AddressSpace32BitWithoutAlias >> svc::CreateProcessFlag_AddressSpaceShift)); static_assert(AddressSpaceType_64Bit == (svc::CreateProcessFlag_AddressSpace64Bit >> svc::CreateProcessFlag_AddressSpaceShift)); #endif u32 magic; u32 signature_key_generation; u8 reserved_08[4]; u8 flags; u8 reserved_0D; u8 main_thread_priority; u8 default_cpu_id; u8 reserved_10[4]; u32 system_resource_size; u32 version; u32 main_thread_stack_size; char program_name[0x10]; char product_code[0x10]; u8 reserved_40[0x30]; u32 aci_offset; u32 aci_size; u32 acid_offset; u32 acid_size; }; static_assert(sizeof(Npdm) == 0x80 && util::is_pod<Npdm>::value, "Npdm definition!"); }
9,260
C++
.h
236
29.940678
165
0.582963
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
7,842
ldr_shell_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ldr/ldr_shell_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 <vapours.hpp> #include <stratosphere/ncm/ncm_ids.hpp> #include <stratosphere/ldr/ldr_types.hpp> namespace ams::ldr { /* Shell API. */ Result InitializeForShell(); Result FinalizeForShell(); Result SetProgramArgument(ncm::ProgramId program_id, const void *arg, size_t size); Result FlushArguments(); }
983
C++
.h
26
35.307692
87
0.75105
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
7,843
ldr_shell_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_shell_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/ldr/ldr_types.hpp> #include <stratosphere/sf.hpp> #define AMS_LDR_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgumentDeprecated, (ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size), (program_id, args, args_size), hos::Version_Min, hos::Version_10_2_0) \ AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgument, (ncm::ProgramId program_id, const sf::InPointerBuffer &args), (program_id, args), hos::Version_11_0_0 ) \ AMS_SF_METHOD_INFO(C, H, 1, Result, FlushArguments, (), ()) \ AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereRegisterExternalCode, (sf::OutMoveHandle out, ncm::ProgramId program_id), (out, program_id)) \ AMS_SF_METHOD_INFO(C, H, 65001, void, AtmosphereUnregisterExternalCode, (ncm::ProgramId program_id), (program_id)) AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IShellInterface, AMS_LDR_I_SHELL_INTERFACE_INTERFACE_INFO, 0x3EE5B554)
2,177
C++
.h
26
81.307692
229
0.5554
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
7,844
ldr_process_manager_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/ldr/ldr_types.hpp> #include <stratosphere/sf.hpp> #define AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, ldr::PinId id, u32 flags, sf::CopyHandle &&reslimit_h), (proc_h, id, flags, std::move(reslimit_h))) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetProgramInfo, (sf::Out<ldr::ProgramInfo> out_program_info, const ncm::ProgramLocation &loc), (out_program_info, loc)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out<ldr::PinId> out_id, const ncm::ProgramLocation &loc), (out_id, loc)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (ldr::PinId id), (id)) \ AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabledProgramVerification, (bool enabled), (enabled), hos::Version_10_0_0) \ AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedBootProgram, (sf::Out<bool> out, ncm::ProgramId program_id), (out, program_id)) \ AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetProgramInfo, (sf::Out<ldr::ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc), (out_program_info, out_status, loc)) \ AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmospherePinProgram, (sf::Out<ldr::PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status), (out_id, loc, override_status)) AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IProcessManagerInterface, AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO, 0x01518B8E)
3,171
C++
.h
29
106.655172
257
0.506212
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
7,845
ldr_debug_monitor_interface.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_debug_monitor_interface.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/ldr/ldr_types.hpp> #include <stratosphere/sf.hpp> #define AMS_LDR_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgumentDeprecated, (ncm::ProgramId program_id, const sf::InPointerBuffer &args, u32 args_size), (program_id, args, args_size), hos::Version_Min, hos::Version_10_2_0) \ AMS_SF_METHOD_INFO(C, H, 0, Result, SetProgramArgument, (ncm::ProgramId program_id, const sf::InPointerBuffer &args), (program_id, args), hos::Version_11_0_0 ) \ AMS_SF_METHOD_INFO(C, H, 1, Result, FlushArguments, (), ()) \ AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessModuleInfo, (sf::Out<u32> count, const sf::OutPointerArray<ldr::ModuleInfo> &out, os::ProcessId process_id), (count, out, process_id)) \ AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedBootProgram, (sf::Out<bool> out, ncm::ProgramId program_id), (out, program_id)) AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IDebugMonitorInterface, AMS_LDR_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO, 0xEE195D22)
2,317
C++
.h
26
86.692308
249
0.547203
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
7,846
settings_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/settings_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 <vapours.hpp> namespace ams::settings { constexpr size_t SettingsNameLengthMax = 0x40; constexpr size_t SettingsItemKeyLengthMax = 0x40; struct SettingsName : public sf::LargeData { char value[util::AlignUp(SettingsNameLengthMax + 1, alignof(u64))]; }; static_assert(util::is_pod<SettingsName>::value && sizeof(SettingsName) > SettingsNameLengthMax); struct SettingsItemKey : public sf::LargeData { char value[util::AlignUp(SettingsItemKeyLengthMax + 1, alignof(u64))]; }; static_assert(util::is_pod<SettingsItemKey>::value && sizeof(SettingsItemKey) > SettingsItemKeyLengthMax); enum Language { Language_Japanese, Language_AmericanEnglish, Language_French, Language_German, Language_Italian, Language_Spanish, Language_Chinese, Language_Korean, Language_Dutch, Language_Portuguese, Language_Russian, Language_Taiwanese, Language_BritishEnglish, Language_CanadianFrench, Language_LatinAmericanSpanish, /* 4.0.0+ */ Language_SimplifiedChinese, Language_TraditionalChinese, /* 10.1.0+ */ Language_PortugueseBr, Language_Count, }; struct LanguageCode { static constexpr size_t MaxLength = 8; char name[MaxLength]; static constexpr LanguageCode Encode(util::string_view name) { LanguageCode out{}; for (size_t i = 0; i < MaxLength && i < name.size(); i++) { out.name[i] = name[i]; } return out; } template<Language Lang> static constexpr inline LanguageCode EncodeLanguage() { if constexpr (false) { /* ... */ } #define AMS_MATCH_LANGUAGE(lang, enc) else if constexpr (Lang == Language_##lang) { return LanguageCode::Encode(enc); } AMS_MATCH_LANGUAGE(Japanese, "ja") AMS_MATCH_LANGUAGE(AmericanEnglish, "en-US") AMS_MATCH_LANGUAGE(French, "fr") AMS_MATCH_LANGUAGE(German, "de") AMS_MATCH_LANGUAGE(Italian, "it") AMS_MATCH_LANGUAGE(Spanish, "es") AMS_MATCH_LANGUAGE(Chinese, "zh-CN") AMS_MATCH_LANGUAGE(Korean, "ko") AMS_MATCH_LANGUAGE(Dutch, "nl") AMS_MATCH_LANGUAGE(Portuguese, "pt") AMS_MATCH_LANGUAGE(Russian, "ru") AMS_MATCH_LANGUAGE(Taiwanese, "zh-TW") AMS_MATCH_LANGUAGE(BritishEnglish, "en-GB") AMS_MATCH_LANGUAGE(CanadianFrench, "fr-CA") AMS_MATCH_LANGUAGE(LatinAmericanSpanish, "es-419") /* 4.0.0+ */ AMS_MATCH_LANGUAGE(SimplifiedChinese, "zh-Hans") AMS_MATCH_LANGUAGE(TraditionalChinese, "zh-Hant") /* 10.1.0+ */ AMS_MATCH_LANGUAGE(PortugueseBr, "pt-BR") #undef AMS_MATCH_LANGUAGE else { static_assert(Lang != Language_Japanese); } } static constexpr inline LanguageCode Encode(const Language language) { constexpr LanguageCode EncodedLanguages[Language_Count] = { EncodeLanguage<Language_Japanese>(), EncodeLanguage<Language_AmericanEnglish>(), EncodeLanguage<Language_French>(), EncodeLanguage<Language_German>(), EncodeLanguage<Language_Italian>(), EncodeLanguage<Language_Spanish>(), EncodeLanguage<Language_Chinese>(), EncodeLanguage<Language_Korean>(), EncodeLanguage<Language_Dutch>(), EncodeLanguage<Language_Portuguese>(), EncodeLanguage<Language_Russian>(), EncodeLanguage<Language_Taiwanese>(), EncodeLanguage<Language_BritishEnglish>(), EncodeLanguage<Language_CanadianFrench>(), EncodeLanguage<Language_LatinAmericanSpanish>(), /* 4.0.0+ */ EncodeLanguage<Language_SimplifiedChinese>(), EncodeLanguage<Language_TraditionalChinese>(), /* 10.1.0+ */ EncodeLanguage<Language_PortugueseBr>(), }; return EncodedLanguages[language]; } }; constexpr inline bool operator==(const LanguageCode &lhs, const LanguageCode &rhs) { return util::Strncmp<char>(lhs.name, rhs.name, sizeof(lhs)) == 0; } constexpr inline bool operator!=(const LanguageCode &lhs, const LanguageCode &rhs) { return !(lhs == rhs); } constexpr inline bool operator==(const LanguageCode &lhs, const Language &rhs) { return lhs == LanguageCode::Encode(rhs); } constexpr inline bool operator!=(const LanguageCode &lhs, const Language &rhs) { return !(lhs == rhs); } constexpr inline bool operator==(const Language &lhs, const LanguageCode &rhs) { return rhs == lhs; } constexpr inline bool operator!=(const Language &lhs, const LanguageCode &rhs) { return !(lhs == rhs); } namespace impl { template<size_t ...Is> constexpr inline bool IsValidLanguageCode(const LanguageCode &lc, std::index_sequence<Is...>) { return ((lc == LanguageCode::Encode(static_cast<Language>(Is))) || ...); } } constexpr inline bool IsValidLanguageCodeDeprecated(const LanguageCode &lc) { return impl::IsValidLanguageCode(lc, std::make_index_sequence<Language_Count - 3>{}); } constexpr inline bool IsValidLanguageCodeDeprecated2(const LanguageCode &lc) { return impl::IsValidLanguageCode(lc, std::make_index_sequence<Language_Count - 1>{}); } constexpr inline bool IsValidLanguageCode(const LanguageCode &lc) { return impl::IsValidLanguageCode(lc, std::make_index_sequence<Language_Count>{}); } static_assert(util::is_pod<LanguageCode>::value); static_assert(sizeof(LanguageCode) == sizeof(u64)); /* Not an official type, but convenient. */ enum RegionCode : s32 { RegionCode_Japan, RegionCode_America, RegionCode_Europe, RegionCode_Australia, RegionCode_China, RegionCode_Korea, RegionCode_Taiwan, RegionCode_Count, }; constexpr inline bool IsValidRegionCode(const RegionCode rc) { return 0 <= rc && rc < RegionCode_Count; } /* This needs to be defined separately from libnx's so that it can inherit from sf::LargeData. */ struct FirmwareVersion : public sf::LargeData { u8 major; u8 minor; u8 micro; u8 padding1; u8 revision_major; u8 revision_minor; u8 padding2; u8 padding3; char platform[0x20]; char version_hash[0x40]; char display_version[0x18]; char display_title[0x80]; constexpr inline u32 GetVersion() const { return (static_cast<u32>(major) << 16) | (static_cast<u32>(minor) << 8) | (static_cast<u32>(micro) << 0); } }; static_assert(util::is_pod<FirmwareVersion>::value); static_assert(sizeof(FirmwareVersion) == 0x100); #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(FirmwareVersion) == sizeof(::SetSysFirmwareVersion)); #endif constexpr inline bool operator==(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetVersion() == rhs.GetVersion(); } constexpr inline bool operator!=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return !(lhs == rhs); } constexpr inline bool operator<(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetVersion() < rhs.GetVersion(); } constexpr inline bool operator>=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return !(lhs < rhs); } constexpr inline bool operator<=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetVersion() <= rhs.GetVersion(); } constexpr inline bool operator>(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return !(lhs <= rhs); } struct BluetoothDevicesSettings : public sf::LargeData { u8 address[0x6]; char name[0x20]; u8 class_of_device[0x3]; u8 link_key[0x10]; u8 link_key_present; u16 version; u32 trusted_services; u16 vid; u16 pid; u8 sub_class; u8 attribute_mask; u16 descriptor_length; u8 descriptor[0x80]; u8 key_type; u8 device_type; u16 brr_size; u8 brr[0x9]; u8 reserved0; char name2[0xF9]; u8 reserved1[0x31]; }; #if defined(ATMOSPHERE_OS_HORIZON) static_assert(sizeof(BluetoothDevicesSettings) == sizeof(::SetSysBluetoothDevicesSettings)); #endif }
9,751
C++
.h
230
33.613043
131
0.620133
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
7,847
settings_fwdbg_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/settings_fwdbg_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 <vapours.hpp> #include <stratosphere/sf/sf_buffer_tags.hpp> namespace ams::settings::fwdbg { }
755
C++
.h
20
35.9
76
0.760929
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
7,848
settings_fwdbg_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/settings_fwdbg_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 <vapours.hpp> #include <stratosphere/settings/settings_fwdbg_types.hpp> namespace ams::settings::fwdbg { bool IsDebugModeEnabled(); size_t GetSettingsItemValueSize(const char *name, const char *key); size_t GetSettingsItemValue(void *dst, size_t dst_size, const char *name, const char *key); }
968
C++
.h
23
39.73913
95
0.759574
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
7,849
settings_firmware_version.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/system/settings_firmware_version.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 <vapours.hpp> #include <stratosphere/settings/settings_types.hpp> namespace ams::settings::system { struct alignas(4) FirmwareVersion { u8 major; u8 minor; u8 micro; u8 padding1; u8 revision_major; u8 revision_minor; u8 padding2; u8 padding3; char platform[0x20]; char revision[0x40]; char display_version[0x18]; char display_name[0x80]; constexpr int GetComparableVersion() const { return (static_cast<int>(major) << 16) | (static_cast<int>(minor) << 8) | (static_cast<int>(micro) << 0); } constexpr friend bool operator==(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetComparableVersion() == rhs.GetComparableVersion(); } constexpr friend bool operator!=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetComparableVersion() != rhs.GetComparableVersion(); } constexpr friend bool operator<=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetComparableVersion() <= rhs.GetComparableVersion(); } constexpr friend bool operator>=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetComparableVersion() >= rhs.GetComparableVersion(); } constexpr friend bool operator<(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetComparableVersion() < rhs.GetComparableVersion(); } constexpr friend bool operator>(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { return lhs.GetComparableVersion() > rhs.GetComparableVersion(); } }; void GetFirmwareVersion(FirmwareVersion *out); }
2,460
C++
.h
56
37.035714
117
0.685201
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
7,850
settings_product_model.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/system/settings_product_model.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 <vapours.hpp> #include <stratosphere/settings/settings_types.hpp> namespace ams::settings::system { enum ProductModel { ProductModel_Invalid = 0, ProductModel_Nx = 1, }; ProductModel GetProductModel(); }
899
C++
.h
25
33.08
76
0.739931
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
7,851
settings_platform_region.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/system/settings_platform_region.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 <vapours.hpp> #include <stratosphere/settings/settings_types.hpp> namespace ams::settings::system { enum PlatformRegion { PlatformRegion_Invalid = 0, PlatformRegion_Global = 1, PlatformRegion_China = 2, }; PlatformRegion GetPlatformRegion(); }
945
C++
.h
26
33.230769
76
0.7407
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
7,852
settings_serial_number.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/system/settings_serial_number.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 <vapours.hpp> #include <stratosphere/settings/settings_types.hpp> namespace ams::settings::system { struct SerialNumber { char str[0x18]; }; void GetSerialNumber(SerialNumber *out); }
866
C++
.h
24
33.458333
76
0.750299
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
7,853
settings_error_report.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/system/settings_error_report.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 <vapours.hpp> #include <stratosphere/settings/settings_types.hpp> namespace ams::settings::system { enum ErrorReportSharePermission { ErrorReportSharePermission_NotConfirmed = 0, ErrorReportSharePermission_Granted = 1, ErrorReportSharePermission_Denied = 2, }; ErrorReportSharePermission GetErrorReportSharePermission(); }
1,032
C++
.h
26
36.576923
76
0.755245
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
7,854
settings_region.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/system/settings_region.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 <vapours.hpp> #include <stratosphere/settings/settings_types.hpp> namespace ams::settings::system { enum RegionCode { RegionCode_Japan = 0, RegionCode_Usa = 1, RegionCode_Europe = 2, RegionCode_Australia = 3, RegionCode_HongKongTaiwanKorea = 4, RegionCode_China = 5, }; void GetRegionCode(RegionCode *out); }
1,098
C++
.h
29
34.137931
76
0.678571
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
7,855
settings_configuration_id.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/factory/settings_configuration_id.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 <vapours.hpp> namespace ams::settings::factory { struct ConfigurationId1 { char str[30]; }; static_assert(sizeof(ConfigurationId1) == 30); static_assert(util::is_pod<ConfigurationId1>::value); void GetConfigurationId1(ConfigurationId1 *out); }
933
C++
.h
25
34.48
76
0.745575
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
7,856
settings_device_certificate.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/factory/settings_device_certificate.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 <vapours.hpp> namespace ams::settings::factory { struct EccP256DeviceCertificate { u8 data[0x180]; }; static_assert(sizeof(EccP256DeviceCertificate) == 0x180); static_assert(util::is_pod<EccP256DeviceCertificate>::value); struct EccB233DeviceCertificate { u8 data[0x180]; }; static_assert(sizeof(EccB233DeviceCertificate) == 0x180); static_assert(util::is_pod<EccB233DeviceCertificate>::value); struct Rsa2048DeviceCertificate { u8 data[0x240]; }; static_assert(sizeof(Rsa2048DeviceCertificate) == 0x240); static_assert(util::is_pod<Rsa2048DeviceCertificate>::value); }
1,304
C++
.h
34
34.676471
76
0.740711
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
7,857
settings_serial_number.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings/factory/settings_serial_number.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 <vapours.hpp> namespace ams::settings::factory { struct SerialNumber { char str[0x18]; }; static_assert(sizeof(SerialNumber) == 0x18); static_assert(util::is_pod<SerialNumber>::value); Result GetSerialNumber(SerialNumber *out); }
919
C++
.h
25
33.92
76
0.741573
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
7,858
hid_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/hid/hid_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 namespace ams::hid { /* Key API. */ Result GetKeysHeld(u64 *out); }
728
C++
.h
20
34.1
76
0.742898
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
7,859
fat_file_system.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fat/fat_file_system.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 <vapours.hpp> namespace ams::fat { constexpr inline size_t FatErrorNameMaxLength = 0x10; struct FatError { int error; int extra_error; int drive_id; char name[FatErrorNameMaxLength]; u8 reserved[4]; }; static_assert(sizeof(FatError) == 0x20); static_assert(util::is_pod<FatError>::value); struct FatReportInfo1 { u16 open_file_peak_count; u16 open_directory_peak_count; }; static_assert(sizeof(FatReportInfo1) == 4); static_assert(util::is_pod<FatReportInfo1>::value); struct FatReportInfo2 { u16 open_unique_file_entry_peak_count; u16 open_unique_directory_entry_peak_count; }; static_assert(sizeof(FatReportInfo2) == 4); static_assert(util::is_pod<FatReportInfo2>::value); struct FatSafeInfo { u32 result; u32 error_number; u32 safe_error_number; }; static_assert(sizeof(FatSafeInfo) == 12); static_assert(util::is_pod<FatSafeInfo>::value); }
1,673
C++
.h
48
30
76
0.697775
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
7,860
htcs_socket.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs/htcs_socket.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 <vapours.hpp> #include <stratosphere/htcs/htcs_types.hpp> namespace ams::htcs { const HtcsPeerName GetPeerNameAny(); const HtcsPeerName GetDefaultHostName(); s32 GetLastError(); s32 Socket(); s32 Close(s32 desc); s32 Connect(s32 desc, const SockAddrHtcs *address); s32 Bind(s32 desc, const SockAddrHtcs *address); s32 Listen(s32 desc, s32 backlog_count); s32 Accept(s32 desc, SockAddrHtcs *address); s32 Shutdown(s32 desc, s32 how); s32 Fcntl(s32 desc, s32 command, s32 value); s32 Select(s32 count, FdSet *read, FdSet *write, FdSet *exception, TimeVal *timeout); ssize_t Recv(s32 desc, void *buffer, size_t buffer_size, s32 flags); ssize_t Send(s32 desc, const void *buffer, size_t buffer_size, s32 flags); void FdSetZero(FdSet *set); void FdSetSet(s32 fd, FdSet *set); void FdSetClr(s32 fd, FdSet *set); bool FdSetIsSet(s32 fd, const FdSet *set); }
1,588
C++
.h
38
38.315789
89
0.73022
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
7,861
htcs_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs/htcs_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 <vapours.hpp> #include <stratosphere/htcs/htcs_types.hpp> namespace ams::htcs { bool IsInitialized(); size_t GetWorkingMemorySize(int max_socket_count); void Initialize(AllocateFunction allocate, DeallocateFunction deallocate, int num_sessions = SessionCountMax); void Initialize(void *buffer, size_t buffer_size); void InitializeForDisableDisconnectionEmulation(AllocateFunction allocate, DeallocateFunction deallocate, int num_sessions = SessionCountMax); void InitializeForDisableDisconnectionEmulation(void *buffer, size_t buffer_size); void InitializeForSystem(void *buffer, size_t buffer_size, int num_sessions); void Finalize(); }
1,335
C++
.h
28
44.75
146
0.779061
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
7,862
htcs_types.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs/htcs_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 <vapours.hpp> namespace ams::htcs { using ssize_t = intptr_t; using AddressFamilyType = u16; constexpr inline int PeerNameBufferLength = 32; constexpr inline int PortNameBufferLength = 32; constexpr inline int SessionCountMax = 0x10; constexpr inline int SocketCountMax = 40; constexpr inline int FdSetSize = SocketCountMax; struct HtcsPeerName { char name[PeerNameBufferLength]; }; struct HtcsPortName { char name[PortNameBufferLength]; }; struct SockAddrHtcs { AddressFamilyType family; HtcsPeerName peer_name; HtcsPortName port_name; }; struct TimeVal { s64 tv_sec; s64 tv_usec; }; struct FdSet { int fds[FdSetSize]; }; enum SocketError { HTCS_ENONE = 0, HTCS_EACCES = 2, HTCS_EADDRINUSE = 3, HTCS_EADDRNOTAVAIL = 4, HTCS_EAGAIN = 6, HTCS_EALREADY = 7, HTCS_EBADF = 8, HTCS_EBUSY = 10, HTCS_ECONNABORTED = 13, HTCS_ECONNREFUSED = 14, HTCS_ECONNRESET = 15, HTCS_EDESTADDRREQ = 17, HTCS_EFAULT = 21, HTCS_EINPROGRESS = 26, HTCS_EINTR = 27, HTCS_EINVAL = 28, HTCS_EIO = 29, HTCS_EISCONN = 30, HTCS_EMFILE = 33, HTCS_EMSGSIZE = 35, HTCS_ENETDOWN = 38, HTCS_ENETRESET = 39, HTCS_ENOBUFS = 42, HTCS_ENOMEM = 49, HTCS_ENOTCONN = 56, HTCS_ETIMEDOUT = 76, HTCS_EUNKNOWN = 79, HTCS_EWOULDBLOCK = HTCS_EAGAIN, }; enum MessageFlag { HTCS_MSG_PEEK = 1, HTCS_MSG_WAITALL = 2, }; enum ShutdownType { HTCS_SHUT_RD = 0, HTCS_SHUT_WR = 1, HTCS_SHUT_RDWR = 2, }; enum FcntlOperation { HTCS_F_GETFL = 3, HTCS_F_SETFL = 4, }; enum FcntlFlag { HTCS_O_NONBLOCK = 4, }; enum AddressFamily { HTCS_AF_HTCS = 0, }; }
2,825
C++
.h
93
23.913978
76
0.578482
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
7,863
htcs_channel_ids.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs/impl/htcs_channel_ids.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 <vapours.hpp> #include <stratosphere/htclow/htclow_channel_types.hpp> namespace ams::htcs::impl { constexpr inline htclow::ChannelId HtcsClientChannelId = 0; }
824
C++
.h
21
37.238095
76
0.765
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
7,864
htcs_manager_holder.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs/impl/htcs_manager_holder.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 <vapours.hpp> #include <stratosphere/htcs/htcs_types.hpp> namespace ams::htcs::impl { class HtcsManager; namespace HtcsManagerHolder { void AddReference(); void Release(); HtcsManager *GetHtcsManager(); } }
907
C++
.h
26
31.692308
76
0.737986
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
7,865
htcs_hipc_server.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs/server/htcs_hipc_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 <vapours.hpp> namespace ams::htcs::server { void Initialize(); void RegisterHipcServer(); void LoopHipcServer(); }
788
C++
.h
22
33.454545
76
0.750656
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
7,866
svc_stratosphere_shims.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.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/>. */ #if defined(ATMOSPHERE_BOARD_NINTENDO_NX) namespace ams::svc { #if defined(ATMOSPHERE_ARCH_ARM64) namespace aarch64::lp64 { ALWAYS_INLINE Result SetHeapSize(::ams::svc::Address *out_address, ::ams::svc::Size size) { R_RETURN(::svcSetHeapSize(reinterpret_cast<void **>(out_address), size)); } ALWAYS_INLINE Result SetHeapSize(uintptr_t *out_address, ::ams::svc::Size size) { static_assert(sizeof(::ams::svc::Address) == sizeof(uintptr_t)); R_RETURN(::svcSetHeapSize(reinterpret_cast<void **>(out_address), size)); } ALWAYS_INLINE Result SetMemoryPermission(::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission perm) { R_RETURN(::svcSetMemoryPermission(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size, static_cast<u32>(perm))); } ALWAYS_INLINE Result SetMemoryAttribute(::ams::svc::Address address, ::ams::svc::Size size, uint32_t mask, uint32_t attr) { R_RETURN(::svcSetMemoryAttribute(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size, mask, attr)); } ALWAYS_INLINE Result MapMemory(::ams::svc::Address dst_address, ::ams::svc::Address src_address, ::ams::svc::Size size) { R_RETURN(::svcMapMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(dst_address)), reinterpret_cast<void *>(static_cast<uintptr_t>(src_address)), size)); } ALWAYS_INLINE Result UnmapMemory(::ams::svc::Address dst_address, ::ams::svc::Address src_address, ::ams::svc::Size size) { R_RETURN(::svcUnmapMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(dst_address)), reinterpret_cast<void *>(static_cast<uintptr_t>(src_address)), size)); } ALWAYS_INLINE Result QueryMemory(::ams::svc::UserPointer< ::ams::svc::lp64::MemoryInfo *> out_memory_info, ::ams::svc::PageInfo *out_page_info, ::ams::svc::Address address) { R_RETURN(::svcQueryMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast<u32 *>(out_page_info), address)); } ALWAYS_INLINE void ExitProcess() { return ::svcExitProcess(); } ALWAYS_INLINE Result CreateThread(::ams::svc::Handle *out_handle, ::ams::svc::ThreadFunc func, ::ams::svc::Address arg, ::ams::svc::Address stack_bottom, int32_t priority, int32_t core_id) { R_RETURN(::svcCreateThread(out_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(func)), reinterpret_cast<void *>(static_cast<uintptr_t>(arg)), reinterpret_cast<void *>(static_cast<uintptr_t>(stack_bottom)), priority, core_id)); } ALWAYS_INLINE Result StartThread(::ams::svc::Handle thread_handle) { R_RETURN(::svcStartThread(thread_handle)); } ALWAYS_INLINE void ExitThread() { return ::svcExitThread(); } ALWAYS_INLINE void SleepThread(int64_t ns) { return ::svcSleepThread(ns); } ALWAYS_INLINE Result GetThreadPriority(int32_t *out_priority, ::ams::svc::Handle thread_handle) { R_RETURN(::svcGetThreadPriority(out_priority, thread_handle)); } ALWAYS_INLINE Result SetThreadPriority(::ams::svc::Handle thread_handle, int32_t priority) { R_RETURN(::svcSetThreadPriority(thread_handle, priority)); } ALWAYS_INLINE Result GetThreadCoreMask(int32_t *out_core_id, uint64_t *out_affinity_mask, ::ams::svc::Handle thread_handle) { R_RETURN(::svcGetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle)); } ALWAYS_INLINE Result SetThreadCoreMask(::ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) { R_RETURN(::svcSetThreadCoreMask(thread_handle, core_id, affinity_mask)); } ALWAYS_INLINE int32_t GetCurrentProcessorNumber() { return ::svcGetCurrentProcessorNumber(); } ALWAYS_INLINE Result SignalEvent(::ams::svc::Handle event_handle) { R_RETURN(::svcSignalEvent(event_handle)); } ALWAYS_INLINE Result ClearEvent(::ams::svc::Handle event_handle) { R_RETURN(::svcClearEvent(event_handle)); } ALWAYS_INLINE Result MapSharedMemory(::ams::svc::Handle shmem_handle, ::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission map_perm) { R_RETURN(::svcMapSharedMemory(shmem_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size, static_cast<u32>(map_perm))); } ALWAYS_INLINE Result UnmapSharedMemory(::ams::svc::Handle shmem_handle, ::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcUnmapSharedMemory(shmem_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result CreateTransferMemory(::ams::svc::Handle *out_handle, ::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission map_perm) { R_RETURN(::svcCreateTransferMemory(out_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size, static_cast<u32>(map_perm))); } ALWAYS_INLINE Result CloseHandle(::ams::svc::Handle handle) { R_RETURN(::svcCloseHandle(handle)); } ALWAYS_INLINE Result ResetSignal(::ams::svc::Handle handle) { R_RETURN(::svcResetSignal(handle)); } ALWAYS_INLINE Result WaitSynchronization(int32_t *out_index, ::ams::svc::UserPointer<const ::ams::svc::Handle *> handles, int32_t num_handles, int64_t timeout_ns) { R_RETURN(::svcWaitSynchronization(out_index, handles.GetPointerUnsafe(), num_handles, timeout_ns)); } ALWAYS_INLINE Result CancelSynchronization(::ams::svc::Handle handle) { R_RETURN(::svcCancelSynchronization(handle)); } ALWAYS_INLINE Result ArbitrateLock(::ams::svc::Handle thread_handle, ::ams::svc::Address address, uint32_t tag) { R_RETURN(::svcArbitrateLock(thread_handle, reinterpret_cast<u32 *>(static_cast<uintptr_t>(address)), tag)); } ALWAYS_INLINE Result ArbitrateUnlock(::ams::svc::Address address) { R_RETURN(::svcArbitrateUnlock(reinterpret_cast<u32 *>(static_cast<uintptr_t>(address)))); } ALWAYS_INLINE Result WaitProcessWideKeyAtomic(::ams::svc::Address address, ::ams::svc::Address cv_key, uint32_t tag, int64_t timeout_ns) { R_RETURN(::svcWaitProcessWideKeyAtomic(reinterpret_cast<u32 *>(static_cast<uintptr_t>(address)), reinterpret_cast<u32 *>(static_cast<uintptr_t>(cv_key)), tag, timeout_ns)); } ALWAYS_INLINE void SignalProcessWideKey(::ams::svc::Address cv_key, int32_t count) { return ::svcSignalProcessWideKey(reinterpret_cast<u32 *>(static_cast<uintptr_t>(cv_key)), count); } ALWAYS_INLINE int64_t GetSystemTick() { return ::svcGetSystemTick(); } ALWAYS_INLINE Result ConnectToNamedPort(::ams::svc::Handle *out_handle, ::ams::svc::UserPointer<const char *> name) { R_RETURN(::svcConnectToNamedPort(out_handle, name.GetPointerUnsafe())); } ALWAYS_INLINE Result SendSyncRequestLight(::ams::svc::Handle session_handle) { R_RETURN(::svcSendSyncRequestLight(session_handle)); } ALWAYS_INLINE Result SendSyncRequest(::ams::svc::Handle session_handle) { R_RETURN(::svcSendSyncRequest(session_handle)); } ALWAYS_INLINE Result SendSyncRequestWithUserBuffer(::ams::svc::Address message_buffer, ::ams::svc::Size message_buffer_size, ::ams::svc::Handle session_handle) { R_RETURN(::svcSendSyncRequestWithUserBuffer(reinterpret_cast<void *>(static_cast<uintptr_t>(message_buffer)), message_buffer_size, session_handle)); } ALWAYS_INLINE Result SendAsyncRequestWithUserBuffer(::ams::svc::Handle *out_event_handle, ::ams::svc::Address message_buffer, ::ams::svc::Size message_buffer_size, ::ams::svc::Handle session_handle) { R_RETURN(::svcSendAsyncRequestWithUserBuffer(out_event_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(message_buffer)), message_buffer_size, session_handle)); } ALWAYS_INLINE Result GetProcessId(uint64_t *out_process_id, ::ams::svc::Handle process_handle) { R_RETURN(::svcGetProcessId(out_process_id, process_handle)); } ALWAYS_INLINE Result GetThreadId(uint64_t *out_thread_id, ::ams::svc::Handle thread_handle) { R_RETURN(::svcGetThreadId(out_thread_id, thread_handle)); } ALWAYS_INLINE void Break(::ams::svc::BreakReason break_reason, ::ams::svc::Address arg, ::ams::svc::Size size) { ::svcBreak(break_reason, arg, size); } ALWAYS_INLINE Result OutputDebugString(::ams::svc::UserPointer<const char *> debug_str, ::ams::svc::Size len) { R_RETURN(::svcOutputDebugString(debug_str.GetPointerUnsafe(), len)); } ALWAYS_INLINE void ReturnFromException(::ams::Result result) { return ::svcReturnFromException(result.GetValue()); } ALWAYS_INLINE Result GetInfo(uint64_t *out, ::ams::svc::InfoType info_type, ::ams::svc::Handle handle, uint64_t info_subtype) { R_RETURN(::svcGetInfo(out, static_cast<u32>(info_type), handle, info_subtype)); } ALWAYS_INLINE void FlushEntireDataCache() { return ::svcFlushEntireDataCache(); } ALWAYS_INLINE Result FlushDataCache(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcFlushDataCache(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result MapPhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcMapPhysicalMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result UnmapPhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcUnmapPhysicalMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result GetDebugFutureThreadInfo(::ams::svc::lp64::LastThreadContext *out_context, uint64_t *thread_id, ::ams::svc::Handle debug_handle, int64_t ns) { R_RETURN(::svcGetDebugFutureThreadInfo(reinterpret_cast<::LastThreadContext *>(out_context), thread_id, debug_handle, ns)); } ALWAYS_INLINE Result GetLastThreadInfo(::ams::svc::lp64::LastThreadContext *out_context, ::ams::svc::Address *out_tls_address, uint32_t *out_flags) { R_RETURN(::svcGetLastThreadInfo(reinterpret_cast<::LastThreadContext *>(out_context), reinterpret_cast<u64 *>(out_tls_address), out_flags)); } ALWAYS_INLINE Result GetResourceLimitLimitValue(int64_t *out_limit_value, ::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which) { R_RETURN(::svcGetResourceLimitLimitValue(out_limit_value, resource_limit_handle, static_cast<::LimitableResource>(which))); } ALWAYS_INLINE Result GetResourceLimitCurrentValue(int64_t *out_current_value, ::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which) { R_RETURN(::svcGetResourceLimitCurrentValue(out_current_value, resource_limit_handle, static_cast<::LimitableResource>(which))); } ALWAYS_INLINE Result SetThreadActivity(::ams::svc::Handle thread_handle, ::ams::svc::ThreadActivity thread_activity) { R_RETURN(::svcSetThreadActivity(thread_handle, static_cast<::ThreadActivity>(thread_activity))); } ALWAYS_INLINE Result GetThreadContext3(::ams::svc::UserPointer< ::ams::svc::ThreadContext *> out_context, ::ams::svc::Handle thread_handle) { R_RETURN(::svcGetThreadContext3(reinterpret_cast<::ThreadContext *>(out_context.GetPointerUnsafe()), thread_handle)); } ALWAYS_INLINE Result WaitForAddress(::ams::svc::Address address, ::ams::svc::ArbitrationType arb_type, int64_t value, int64_t timeout_ns) { R_RETURN(::svcWaitForAddress(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), arb_type, value, timeout_ns)); } ALWAYS_INLINE Result SignalToAddress(::ams::svc::Address address, ::ams::svc::SignalType signal_type, int32_t value, int32_t count) { R_RETURN(::svcSignalToAddress(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), signal_type, value, count)); } ALWAYS_INLINE void SynchronizePreemptionState() { return ::svcSynchronizePreemptionState(); } ALWAYS_INLINE Result GetResourceLimitPeakValue(int64_t *out_peak_value, ::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which) { R_RETURN(::svcGetResourceLimitPeakValue(out_peak_value, resource_limit_handle, static_cast<::LimitableResource>(which))); } ALWAYS_INLINE void KernelDebug(::ams::svc::KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2) { return ::svcKernelDebug(kern_debug_type, arg0, arg1, arg2); } ALWAYS_INLINE void ChangeKernelTraceState(::ams::svc::KernelTraceState kern_trace_state) { return ::svcChangeKernelTraceState(kern_trace_state); } ALWAYS_INLINE Result CreateSession(::ams::svc::Handle *out_server_session_handle, ::ams::svc::Handle *out_client_session_handle, bool is_light, ::ams::svc::Address name) { R_RETURN(::svcCreateSession(out_server_session_handle, out_client_session_handle, is_light, name)); } ALWAYS_INLINE Result AcceptSession(::ams::svc::Handle *out_handle, ::ams::svc::Handle port) { R_RETURN(::svcAcceptSession(out_handle, port)); } ALWAYS_INLINE Result ReplyAndReceiveLight(::ams::svc::Handle handle) { R_RETURN(::svcReplyAndReceiveLight(handle)); } ALWAYS_INLINE Result ReplyAndReceive(int32_t *out_index, ::ams::svc::UserPointer<const ::ams::svc::Handle *> handles, int32_t num_handles, ::ams::svc::Handle reply_target, int64_t timeout_ns) { R_RETURN(::svcReplyAndReceive(out_index, handles.GetPointerUnsafe(), num_handles, reply_target, timeout_ns)); } ALWAYS_INLINE Result ReplyAndReceiveWithUserBuffer(int32_t *out_index, ::ams::svc::Address message_buffer, ::ams::svc::Size message_buffer_size, ::ams::svc::UserPointer<const ::ams::svc::Handle *> handles, int32_t num_handles, ::ams::svc::Handle reply_target, int64_t timeout_ns) { R_RETURN(::svcReplyAndReceiveWithUserBuffer(out_index, reinterpret_cast<void *>(static_cast<uintptr_t>(message_buffer)), message_buffer_size, handles.GetPointerUnsafe(), num_handles, reply_target, timeout_ns)); } ALWAYS_INLINE Result CreateEvent(::ams::svc::Handle *out_write_handle, ::ams::svc::Handle *out_read_handle) { R_RETURN(::svcCreateEvent(out_write_handle, out_read_handle)); } ALWAYS_INLINE Result MapPhysicalMemoryUnsafe(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcMapPhysicalMemoryUnsafe(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result UnmapPhysicalMemoryUnsafe(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcUnmapPhysicalMemoryUnsafe(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result SetUnsafeLimit(::ams::svc::Size limit) { R_RETURN(::svcSetUnsafeLimit(limit)); } ALWAYS_INLINE Result CreateCodeMemory(::ams::svc::Handle *out_handle, ::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcCreateCodeMemory(out_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result ControlCodeMemory(::ams::svc::Handle code_memory_handle, ::ams::svc::CodeMemoryOperation operation, uint64_t address, uint64_t size, ::ams::svc::MemoryPermission perm) { R_RETURN(::svcControlCodeMemory(code_memory_handle, static_cast<::CodeMapOperation>(operation), reinterpret_cast<void *>(address), size, static_cast<u32>(perm))); } ALWAYS_INLINE void SleepSystem() { return ::svcSleepSystem(); } ALWAYS_INLINE Result ReadWriteRegister(uint32_t *out_value, ::ams::svc::PhysicalAddress address, uint32_t mask, uint32_t value) { R_RETURN(::svcReadWriteRegister(out_value, address, mask, value)); } ALWAYS_INLINE Result SetProcessActivity(::ams::svc::Handle process_handle, ::ams::svc::ProcessActivity process_activity) { R_RETURN(::svcSetProcessActivity(process_handle, static_cast<::ProcessActivity>(process_activity))); } ALWAYS_INLINE Result CreateSharedMemory(::ams::svc::Handle *out_handle, ::ams::svc::Size size, ::ams::svc::MemoryPermission owner_perm, ::ams::svc::MemoryPermission remote_perm) { R_RETURN(::svcCreateSharedMemory(out_handle, size, static_cast<u32>(owner_perm), static_cast<u32>(remote_perm))); } ALWAYS_INLINE Result MapTransferMemory(::ams::svc::Handle trmem_handle, ::ams::svc::Address address, ::ams::svc::Size size, ::ams::svc::MemoryPermission owner_perm) { R_RETURN(::svcMapTransferMemory(trmem_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size, static_cast<u32>(owner_perm))); } ALWAYS_INLINE Result UnmapTransferMemory(::ams::svc::Handle trmem_handle, ::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcUnmapTransferMemory(trmem_handle, reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result CreateInterruptEvent(::ams::svc::Handle *out_read_handle, int32_t interrupt_id, ::ams::svc::InterruptType interrupt_type) { R_RETURN(::svcCreateInterruptEvent(out_read_handle, interrupt_id, static_cast<u32>(interrupt_type))); } ALWAYS_INLINE Result QueryPhysicalAddress(::ams::svc::lp64::PhysicalMemoryInfo *out_info, ::ams::svc::Address address) { R_RETURN(::svcQueryPhysicalAddress(reinterpret_cast<::PhysicalMemoryInfo *>(out_info), address)); } ALWAYS_INLINE Result QueryMemoryMapping(::ams::svc::Address *out_address, ::ams::svc::Size *out_size, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { R_RETURN(::svcQueryMemoryMapping(reinterpret_cast<u64 *>(out_address), reinterpret_cast<u64 *>(out_size), physical_address, size)); } ALWAYS_INLINE Result LegacyQueryIoMapping(::ams::svc::Address *out_address, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { R_RETURN(::svcLegacyQueryIoMapping(reinterpret_cast<u64 *>(out_address), physical_address, size)); } ALWAYS_INLINE Result CreateDeviceAddressSpace(::ams::svc::Handle *out_handle, uint64_t das_address, uint64_t das_size) { R_RETURN(::svcCreateDeviceAddressSpace(out_handle, das_address, das_size)); } ALWAYS_INLINE Result AttachDeviceAddressSpace(::ams::svc::DeviceName device_name, ::ams::svc::Handle das_handle) { R_RETURN(::svcAttachDeviceAddressSpace(static_cast<u64>(device_name), das_handle)); } ALWAYS_INLINE Result DetachDeviceAddressSpace(::ams::svc::DeviceName device_name, ::ams::svc::Handle das_handle) { R_RETURN(::svcDetachDeviceAddressSpace(static_cast<u64>(device_name), das_handle)); } ALWAYS_INLINE Result MapDeviceAddressSpaceByForce(::ams::svc::Handle das_handle, ::ams::svc::Handle process_handle, uint64_t process_address, ::ams::svc::Size size, uint64_t device_address, u32 option) { R_RETURN(::svcMapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, option)); } ALWAYS_INLINE Result MapDeviceAddressSpaceAligned(::ams::svc::Handle das_handle, ::ams::svc::Handle process_handle, uint64_t process_address, ::ams::svc::Size size, uint64_t device_address, u32 option) { R_RETURN(::svcMapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, option)); } ALWAYS_INLINE Result UnmapDeviceAddressSpace(::ams::svc::Handle das_handle, ::ams::svc::Handle process_handle, uint64_t process_address, ::ams::svc::Size size, uint64_t device_address) { R_RETURN(::svcUnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address)); } ALWAYS_INLINE Result InvalidateProcessDataCache(::ams::svc::Handle process_handle, uint64_t address, uint64_t size) { R_RETURN(::svcInvalidateProcessDataCache(process_handle, address, size)); } ALWAYS_INLINE Result StoreProcessDataCache(::ams::svc::Handle process_handle, uint64_t address, uint64_t size) { R_RETURN(::svcStoreProcessDataCache(process_handle, address, size)); } ALWAYS_INLINE Result FlushProcessDataCache(::ams::svc::Handle process_handle, uint64_t address, uint64_t size) { R_RETURN(::svcFlushProcessDataCache(process_handle, address, size)); } ALWAYS_INLINE Result DebugActiveProcess(::ams::svc::Handle *out_handle, uint64_t process_id) { R_RETURN(::svcDebugActiveProcess(out_handle, process_id)); } ALWAYS_INLINE Result BreakDebugProcess(::ams::svc::Handle debug_handle) { R_RETURN(::svcBreakDebugProcess(debug_handle)); } ALWAYS_INLINE Result TerminateDebugProcess(::ams::svc::Handle debug_handle) { R_RETURN(::svcTerminateDebugProcess(debug_handle)); } ALWAYS_INLINE Result GetDebugEvent(::ams::svc::UserPointer< ::ams::svc::lp64::DebugEventInfo *> out_info, ::ams::svc::Handle debug_handle) { R_RETURN(::svcGetDebugEvent(out_info.GetPointerUnsafe(), debug_handle)); } ALWAYS_INLINE Result ContinueDebugEvent(::ams::svc::Handle debug_handle, uint32_t flags, ::ams::svc::UserPointer<const uint64_t *> thread_ids, int32_t num_thread_ids) { R_RETURN(::svcContinueDebugEvent(debug_handle, flags, const_cast<u64 *>(thread_ids.GetPointerUnsafe()), num_thread_ids)); } ALWAYS_INLINE Result LegacyContinueDebugEvent(::ams::svc::Handle debug_handle, uint32_t flags, uint64_t thread_id) { R_RETURN(::svcLegacyContinueDebugEvent(debug_handle, flags, thread_id)); } ALWAYS_INLINE Result GetProcessList(int32_t *out_num_processes, ::ams::svc::UserPointer<uint64_t *> out_process_ids, int32_t max_out_count) { R_RETURN(::svcGetProcessList(out_num_processes, out_process_ids.GetPointerUnsafe(), max_out_count)); } ALWAYS_INLINE Result GetThreadList(int32_t *out_num_threads, ::ams::svc::UserPointer<uint64_t *> out_thread_ids, int32_t max_out_count, ::ams::svc::Handle debug_handle) { R_RETURN(::svcGetThreadList(out_num_threads, out_thread_ids.GetPointerUnsafe(), max_out_count, debug_handle)); } ALWAYS_INLINE Result GetDebugThreadContext(::ams::svc::UserPointer< ::ams::svc::ThreadContext *> out_context, ::ams::svc::Handle debug_handle, uint64_t thread_id, uint32_t context_flags) { R_RETURN(::svcGetDebugThreadContext(reinterpret_cast<::ThreadContext *>(out_context.GetPointerUnsafe()), debug_handle, thread_id, context_flags)); } ALWAYS_INLINE Result SetDebugThreadContext(::ams::svc::Handle debug_handle, uint64_t thread_id, ::ams::svc::UserPointer<const ::ams::svc::ThreadContext *> context, uint32_t context_flags) { R_RETURN(::svcSetDebugThreadContext(debug_handle, thread_id, reinterpret_cast<const ::ThreadContext *>(context.GetPointerUnsafe()), context_flags)); } ALWAYS_INLINE Result QueryDebugProcessMemory(::ams::svc::UserPointer< ::ams::svc::lp64::MemoryInfo *> out_memory_info, ::ams::svc::PageInfo *out_page_info, ::ams::svc::Handle process_handle, ::ams::svc::Address address) { R_RETURN(::svcQueryDebugProcessMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast<u32 *>(out_page_info), process_handle, address)); } ALWAYS_INLINE Result ReadDebugProcessMemory(::ams::svc::Address buffer, ::ams::svc::Handle debug_handle, ::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcReadDebugProcessMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(buffer)), debug_handle, address, size)); } ALWAYS_INLINE Result WriteDebugProcessMemory(::ams::svc::Handle debug_handle, ::ams::svc::Address buffer, ::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcWriteDebugProcessMemory(debug_handle, reinterpret_cast<const void *>(static_cast<uintptr_t>(buffer)), address, size)); } ALWAYS_INLINE Result SetHardwareBreakPoint(::ams::svc::HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value) { R_RETURN(::svcSetHardwareBreakPoint(static_cast<u32>(name), flags, value)); } ALWAYS_INLINE Result GetDebugThreadParam(uint64_t *out_64, uint32_t *out_32, ::ams::svc::Handle debug_handle, uint64_t thread_id, ::ams::svc::DebugThreadParam param) { R_RETURN(::svcGetDebugThreadParam(out_64, out_32, debug_handle, thread_id, static_cast<::DebugThreadParam>(param))); } ALWAYS_INLINE Result GetSystemInfo(uint64_t *out, ::ams::svc::SystemInfoType info_type, ::ams::svc::Handle handle, uint64_t info_subtype) { R_RETURN(::svcGetSystemInfo(out, static_cast<u64>(info_type), handle, info_subtype)); } ALWAYS_INLINE Result CreatePort(::ams::svc::Handle *out_server_handle, ::ams::svc::Handle *out_client_handle, int32_t max_sessions, bool is_light, ::ams::svc::Address name) { R_RETURN(::svcCreatePort(out_server_handle, out_client_handle, max_sessions, is_light, reinterpret_cast<const char *>(static_cast<uintptr_t>(name)))); } ALWAYS_INLINE Result ManageNamedPort(::ams::svc::Handle *out_server_handle, ::ams::svc::UserPointer<const char *> name, int32_t max_sessions) { R_RETURN(::svcManageNamedPort(out_server_handle, name.GetPointerUnsafe(), max_sessions)); } ALWAYS_INLINE Result ConnectToPort(::ams::svc::Handle *out_handle, ::ams::svc::Handle port) { R_RETURN(::svcConnectToPort(out_handle, port)); } ALWAYS_INLINE Result SetProcessMemoryPermission(::ams::svc::Handle process_handle, uint64_t address, uint64_t size, ::ams::svc::MemoryPermission perm) { R_RETURN(::svcSetProcessMemoryPermission(process_handle, address, size, static_cast<u32>(perm))); } ALWAYS_INLINE Result MapProcessMemory(::ams::svc::Address dst_address, ::ams::svc::Handle process_handle, uint64_t src_address, ::ams::svc::Size size) { R_RETURN(::svcMapProcessMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(dst_address)), process_handle, src_address, size)); } ALWAYS_INLINE Result UnmapProcessMemory(::ams::svc::Address dst_address, ::ams::svc::Handle process_handle, uint64_t src_address, ::ams::svc::Size size) { R_RETURN(::svcUnmapProcessMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(dst_address)), process_handle, src_address, size)); } ALWAYS_INLINE Result QueryProcessMemory(::ams::svc::UserPointer< ::ams::svc::lp64::MemoryInfo *> out_memory_info, ::ams::svc::PageInfo *out_page_info, ::ams::svc::Handle process_handle, uint64_t address) { R_RETURN(::svcQueryProcessMemory(reinterpret_cast<::MemoryInfo *>(out_memory_info.GetPointerUnsafe()), reinterpret_cast<u32 *>(out_page_info), process_handle, address)); } ALWAYS_INLINE Result MapProcessCodeMemory(::ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { R_RETURN(::svcMapProcessCodeMemory(process_handle, dst_address, src_address, size)); } ALWAYS_INLINE Result UnmapProcessCodeMemory(::ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { R_RETURN(::svcUnmapProcessCodeMemory(process_handle, dst_address, src_address, size)); } ALWAYS_INLINE Result CreateProcess(::ams::svc::Handle *out_handle, ::ams::svc::UserPointer<const ::ams::svc::lp64::CreateProcessParameter *> parameters, ::ams::svc::UserPointer<const uint32_t *> caps, int32_t num_caps) { R_RETURN(::svcCreateProcess(out_handle, parameters.GetPointerUnsafe(), caps.GetPointerUnsafe(), num_caps)); } ALWAYS_INLINE Result StartProcess(::ams::svc::Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size) { R_RETURN(::svcStartProcess(process_handle, priority, core_id, main_thread_stack_size)); } ALWAYS_INLINE Result TerminateProcess(::ams::svc::Handle process_handle) { R_RETURN(::svcTerminateProcess(process_handle)); } ALWAYS_INLINE Result GetProcessInfo(int64_t *out_info, ::ams::svc::Handle process_handle, ::ams::svc::ProcessInfoType info_type) { R_RETURN(::svcGetProcessInfo(out_info, process_handle, static_cast<::ProcessInfoType>(info_type))); } ALWAYS_INLINE Result CreateResourceLimit(::ams::svc::Handle *out_handle) { R_RETURN(::svcCreateResourceLimit(out_handle)); } ALWAYS_INLINE Result SetResourceLimitLimitValue(::ams::svc::Handle resource_limit_handle, ::ams::svc::LimitableResource which, int64_t limit_value) { R_RETURN(::svcSetResourceLimitLimitValue(resource_limit_handle, static_cast<::LimitableResource>(which), limit_value)); } ALWAYS_INLINE void CallSecureMonitor(::ams::svc::lp64::SecureMonitorArguments *args) { ::svcCallSecureMonitor(reinterpret_cast<::SecmonArgs *>(args)); } ALWAYS_INLINE Result MapInsecurePhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcMapInsecurePhysicalMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } ALWAYS_INLINE Result UnmapInsecurePhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { R_RETURN(::svcUnmapInsecurePhysicalMemory(reinterpret_cast<void *>(static_cast<uintptr_t>(address)), size)); } } #endif ALWAYS_INLINE bool IsKernelMesosphere() { uint64_t dummy; return R_SUCCEEDED(::ams::svc::GetInfo(std::addressof(dummy), ::ams::svc::InfoType_MesosphereMeta, ::ams::svc::InvalidHandle, ::ams::svc::MesosphereMetaInfo_KernelVersion)); } ALWAYS_INLINE bool IsKTraceEnabled() { uint64_t value = 0; return R_SUCCEEDED(::ams::svc::GetInfo(std::addressof(value), ::ams::svc::InfoType_MesosphereMeta, ::ams::svc::InvalidHandle, ::ams::svc::MesosphereMetaInfo_IsKTraceEnabled)) && value != 0; } } #endif
34,844
C++
.h
398
69.871859
297
0.621361
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
7,867
i2c_register_accessor.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/i2c/i2c_register_accessor.hpp
/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vapours.hpp> #include <stratosphere/i2c/i2c_types.hpp> #include <stratosphere/i2c/i2c_command_list_formatter.hpp> #include <stratosphere/i2c/i2c_bus_api.hpp> namespace ams::i2c { template<typename RegType> requires std::unsigned_integral<RegType> Result ReadSingleRegister(const I2cSession &session, u8 address, RegType *out) { /* Check pre-conditions. */ AMS_ABORT_UNLESS(out != nullptr); constexpr i2c::TransactionOption StartOption = i2c::TransactionOption_StartCondition; constexpr i2c::TransactionOption StopOption = static_cast<i2c::TransactionOption>(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition); u8 cmd_list[CommandListLengthMax]; i2c::CommandListFormatter formatter(cmd_list, sizeof(cmd_list)); R_TRY(formatter.EnqueueSendCommand(StartOption, std::addressof(address), sizeof(address))); R_TRY(formatter.EnqueueReceiveCommand(StopOption, sizeof(*out))); R_TRY(i2c::ExecuteCommandList(out, sizeof(*out), session, cmd_list, formatter.GetCurrentLength())); R_SUCCEED(); } template<typename RegType> requires std::unsigned_integral<RegType> Result WriteSingleRegister(const I2cSession &session, u8 address, RegType value) { /* Prepare buffer. */ u8 buf[sizeof(address) + sizeof(value)]; std::memcpy(buf + 0, std::addressof(address), sizeof(address)); std::memcpy(buf + sizeof(address), std::addressof(value), sizeof(value)); constexpr i2c::TransactionOption StopOption = static_cast<i2c::TransactionOption>(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition); R_TRY(i2c::Send(session, buf, sizeof(buf), StopOption)); R_SUCCEED(); } }
2,428
C++
.h
45
48.844444
169
0.73398
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
7,868
i2c_api.hpp
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/i2c/i2c_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 <vapours.hpp> #include <stratosphere/i2c/i2c_types.hpp> #include <stratosphere/i2c/sf/i2c_sf_i_manager.hpp> namespace ams::i2c { void InitializeWith(ams::sf::SharedPointer<i2c::sf::IManager> sp, ams::sf::SharedPointer<i2c::sf::IManager> sp_pcv); void InitializeEmpty(); void Finalize(); }
962
C++
.h
24
37.833333
120
0.751606
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