id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8,169
|
ncm_content_meta.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/ncm/ncm_content_meta_id.hpp>
#include <stratosphere/ncm/ncm_content_meta_key.hpp>
#include <stratosphere/ncm/ncm_content_meta_platform.hpp>
#include <stratosphere/ncm/ncm_content_info.hpp>
#include <stratosphere/ncm/ncm_content_info_data.hpp>
#include <stratosphere/ncm/ncm_firmware_variation.hpp>
#include <stratosphere/ncm/ncm_storage_id.hpp>
namespace ams::ncm {
enum ContentMetaAttribute : u8 {
ContentMetaAttribute_None = (0 << 0),
ContentMetaAttribute_IncludesExFatDriver = (1 << 0),
ContentMetaAttribute_Rebootless = (1 << 1),
ContentMetaAttribute_Compacted = (1 << 2),
};
struct ContentMetaInfo {
u64 id;
u32 version;
ContentMetaType type;
u8 attributes;
u8 padding[2];
static constexpr ContentMetaInfo Make(u64 id, u32 version, ContentMetaType type, u8 attributes) {
return {
.id = id,
.version = version,
.type = type,
.attributes = attributes,
};
}
constexpr ContentMetaKey ToKey() const {
return ContentMetaKey::Make(this->id, this->version, this->type);
}
};
static_assert(sizeof(ContentMetaInfo) == 0x10);
struct ContentMetaHeader {
u16 extended_header_size;
u16 content_count;
u16 content_meta_count;
u8 attributes;
ContentMetaPlatform platform;
};
static_assert(sizeof(ContentMetaHeader) == 0x8);
struct PackagedContentMetaHeader {
u64 id;
u32 version;
ContentMetaType type;
ContentMetaPlatform platform;
u16 extended_header_size;
u16 content_count;
u16 content_meta_count;
u8 attributes;
u8 storage_id;
ContentInstallType install_type;
bool committed;
u32 required_download_system_version;
u8 reserved_1C[4];
};
static_assert(sizeof(PackagedContentMetaHeader) == 0x20);
static_assert(AMS_OFFSETOF(PackagedContentMetaHeader, reserved_1C) == 0x1C);
using InstallContentMetaHeader = PackagedContentMetaHeader;
struct ApplicationMetaExtendedHeader {
PatchId patch_id;
u32 required_system_version;
u32 required_application_version;
};
struct PatchMetaExtendedHeader {
ApplicationId application_id;
u32 required_system_version;
u32 extended_data_size;
u8 reserved[0x8];
};
struct AddOnContentMetaExtendedHeader {
ApplicationId application_id;
u32 required_application_version;
u8 content_accessibilities;
u8 padding[3];
DataPatchId data_patch_id;
};
struct LegacyAddOnContentMetaExtendedHeader {
ApplicationId application_id;
u32 required_application_version;
u32 padding;
};
struct DeltaMetaExtendedHeader {
ApplicationId application_id;
u32 extended_data_size;
u32 padding;
};
struct SystemUpdateMetaExtendedHeader {
u32 extended_data_size;
};
template<typename ContentMetaHeaderType, typename ContentInfoType>
class ContentMetaAccessor {
public:
using HeaderType = ContentMetaHeaderType;
using InfoType = ContentInfoType;
private:
void *m_data;
const size_t m_size;
bool m_is_header_valid;
private:
static size_t GetExtendedHeaderSize(ContentMetaType type) {
switch (type) {
case ContentMetaType::Application: return sizeof(ApplicationMetaExtendedHeader);
case ContentMetaType::Patch: return sizeof(PatchMetaExtendedHeader);
case ContentMetaType::AddOnContent: return sizeof(AddOnContentMetaExtendedHeader);
case ContentMetaType::Delta: return sizeof(DeltaMetaExtendedHeader);
default: return 0;
}
}
protected:
constexpr ContentMetaAccessor(const void *d, size_t sz) : m_data(const_cast<void *>(d)), m_size(sz), m_is_header_valid(true) { /* ... */ }
constexpr ContentMetaAccessor(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ }
template<class NewHeaderType, class NewInfoType>
static constexpr size_t CalculateSizeImpl(size_t ext_header_size, size_t content_count, size_t content_meta_count, size_t extended_data_size, bool has_digest) {
return sizeof(NewHeaderType) + ext_header_size + content_count * sizeof(NewInfoType) + content_meta_count * sizeof(ContentMetaInfo) + extended_data_size + (has_digest ? sizeof(Digest) : 0);
}
static constexpr size_t CalculateSize(ContentMetaType type, size_t content_count, size_t content_meta_count, size_t extended_data_size, bool has_digest = false) {
return CalculateSizeImpl<ContentMetaHeaderType, ContentInfoType>(GetExtendedHeaderSize(type), content_count, content_meta_count, extended_data_size, has_digest);
}
uintptr_t GetExtendedHeaderAddress() const {
return reinterpret_cast<uintptr_t>(m_data) + sizeof(HeaderType);
}
uintptr_t GetContentInfoStartAddress() const {
return this->GetExtendedHeaderAddress() + this->GetExtendedHeaderSize();
}
uintptr_t GetContentInfoAddress(size_t i) const {
return this->GetContentInfoStartAddress() + i * sizeof(InfoType);
}
uintptr_t GetContentMetaInfoStartAddress() const {
return this->GetContentInfoAddress(this->GetContentCount());
}
uintptr_t GetContentMetaInfoAddress(size_t i) const {
return this->GetContentMetaInfoStartAddress() + i * sizeof(ContentMetaInfo);
}
uintptr_t GetExtendedDataAddress() const {
return this->GetContentMetaInfoAddress(this->GetContentMetaCount());
}
uintptr_t GetDigestAddress() const {
return this->GetExtendedDataAddress() + this->GetExtendedDataSize();
}
InfoType *GetWritableContentInfo(size_t i) const {
AMS_ABORT_UNLESS(i < this->GetContentCount());
return reinterpret_cast<InfoType *>(this->GetContentInfoAddress(i));
}
InfoType *GetWritableContentInfo(ContentType type) const {
InfoType *found = nullptr;
for (size_t i = 0; i < this->GetContentCount(); i++) {
/* We want to find the info with the lowest id offset and the correct type. */
InfoType *info = this->GetWritableContentInfo(i);
if (info->GetType() == type && (found == nullptr || info->GetIdOffset() < found->GetIdOffset())) {
found = info;
}
}
return found;
}
InfoType *GetWritableContentInfo(ContentType type, u8 id_ofs) const {
for (size_t i = 0; i < this->GetContentCount(); i++) {
/* We want to find the info with the correct id offset and the correct type. */
if (InfoType *info = this->GetWritableContentInfo(i); info->GetType() == type && info->GetIdOffset() == id_ofs) {
return info;
}
}
return nullptr;
}
s64 CalculateContentRequiredSize() const {
s64 required_size = 0;
for (size_t i = 0; i < this->GetContentCount(); i++) {
required_size += CalculateRequiredSize(this->GetContentInfo(i)->info.GetSize());
}
return required_size;
}
void SetStorageId(StorageId storage_id) {
this->GetWritableHeader()->storage_id = static_cast<u8>(storage_id);
}
public:
const void *GetData() const {
return m_data;
}
size_t GetSize() const {
return m_size;
}
HeaderType *GetWritableHeader() const {
AMS_ABORT_UNLESS(m_is_header_valid);
return reinterpret_cast<HeaderType *>(m_data);
}
const HeaderType *GetHeader() const {
AMS_ABORT_UNLESS(m_is_header_valid);
return static_cast<const HeaderType *>(m_data);
}
ContentMetaKey GetKey() const {
auto header = this->GetHeader();
return ContentMetaKey::Make(header->id, header->version, header->type, header->install_type);
}
size_t GetExtendedHeaderSize() const {
return this->GetHeader()->extended_header_size;
}
template<typename ExtendedHeaderType>
const ExtendedHeaderType *GetExtendedHeader() const {
return reinterpret_cast<const ExtendedHeaderType *>(this->GetExtendedHeaderAddress());
}
size_t GetContentCount() const {
return this->GetHeader()->content_count;
}
const InfoType *GetContentInfo(size_t i) const {
AMS_ABORT_UNLESS(i < this->GetContentCount());
return this->GetWritableContentInfo(i);
}
const InfoType *GetContentInfo(ContentType type) const {
return this->GetWritableContentInfo(type);
}
const InfoType *GetContentInfo(ContentType type, u8 id_ofs) const {
return this->GetWritableContentInfo(type, id_ofs);
}
size_t GetContentMetaCount() const {
return this->GetHeader()->content_meta_count;
}
const ContentMetaInfo *GetContentMetaInfo(size_t i) const {
AMS_ABORT_UNLESS(i < this->GetContentMetaCount());
return reinterpret_cast<const ContentMetaInfo *>(this->GetContentMetaInfoAddress(i));
}
size_t GetExtendedDataSize() const {
switch (this->GetHeader()->type) {
case ContentMetaType::Patch: return this->GetExtendedHeader<PatchMetaExtendedHeader>()->extended_data_size;
case ContentMetaType::Delta: return this->GetExtendedHeader<DeltaMetaExtendedHeader>()->extended_data_size;
case ContentMetaType::SystemUpdate: return this->GetExtendedHeaderSize() == 0 ? 0 : this->GetExtendedHeader<SystemUpdateMetaExtendedHeader>()->extended_data_size;
default: return 0;
}
}
const void *GetExtendedData() const {
return reinterpret_cast<const void *>(this->GetExtendedDataAddress());
}
const Digest *GetDigest() const {
return reinterpret_cast<Digest *>(this->GetDigestAddress());
}
bool HasContent(const ContentId &id) const {
for (size_t i = 0; i < this->GetContentCount(); i++) {
if (id == this->GetContentInfo(i)->GetId()) {
return true;
}
}
return false;
}
StorageId GetStorageId() const {
return static_cast<StorageId>(this->GetHeader()->storage_id);
}
util::optional<ApplicationId> GetApplicationId(const ContentMetaKey &key) const {
switch (key.type) {
case ContentMetaType::Application: return ApplicationId{ key.id };
case ContentMetaType::Patch: return this->GetExtendedHeader<PatchMetaExtendedHeader>()->application_id;
case ContentMetaType::AddOnContent: return this->GetExtendedHeader<AddOnContentMetaExtendedHeader>()->application_id;
case ContentMetaType::Delta: return this->GetExtendedHeader<DeltaMetaExtendedHeader>()->application_id;
default: return util::nullopt;
}
}
util::optional<ApplicationId> GetApplicationId() const {
return this->GetApplicationId(this->GetKey());
}
};
class ContentMetaReader : public ContentMetaAccessor<ContentMetaHeader, ContentInfo> {
public:
constexpr ContentMetaReader(const void *data, size_t size) : ContentMetaAccessor(data, size) { /* ... */ }
using ContentMetaAccessor::CalculateSize;
};
class PackagedContentMetaReader : public ContentMetaAccessor<PackagedContentMetaHeader, PackagedContentInfo> {
public:
constexpr PackagedContentMetaReader(const void *data, size_t size) : ContentMetaAccessor(data, size) { /* ... */ }
size_t CalculateConvertInstallContentMetaSize() const;
void ConvertToInstallContentMeta(void *dst, size_t size, const InstallContentInfo &meta);
size_t CalculateConvertContentMetaSize() const;
void ConvertToContentMeta(void *dst, size_t size, const ContentInfo &meta);
size_t CalculateConvertFragmentOnlyInstallContentMetaSize(s32 fragment_count) const {
return CalculateSizeImpl<InstallContentMetaHeader, InstallContentInfo>(this->GetExtendedHeaderSize(), fragment_count + 1, 0, 0, false);
}
Result CalculateConvertFragmentOnlyInstallContentMetaSize(size_t *out_size, u32 source_version) const;
Result ConvertToFragmentOnlyInstallContentMeta(void *dst, size_t size, const InstallContentInfo &content_info, u32 source_version);
size_t CountDeltaFragments() const;
static constexpr size_t CalculateSize(ContentMetaType type, size_t content_count, size_t content_meta_count, size_t extended_data_size) {
return ContentMetaAccessor::CalculateSize(type, content_count, content_meta_count, extended_data_size, true);
}
size_t GetExtendedDataOffset() const {
return this->GetExtendedDataAddress() - reinterpret_cast<uintptr_t>(this->GetData());
}
};
class InstallContentMetaReader : public ContentMetaAccessor<InstallContentMetaHeader, InstallContentInfo> {
public:
constexpr InstallContentMetaReader(const void *data, size_t size) : ContentMetaAccessor(data, size) { /* ... */ }
using ContentMetaAccessor::CalculateSize;
using ContentMetaAccessor::CalculateContentRequiredSize;
using ContentMetaAccessor::GetStorageId;
size_t CalculateConvertSize() const;
void ConvertToContentMeta(void *dst, size_t size) const;
};
class InstallContentMetaWriter : public ContentMetaAccessor<InstallContentMetaHeader, InstallContentInfo> {
public:
InstallContentMetaWriter(const void *data, size_t size) : ContentMetaAccessor(data, size) { /* ... */ }
using ContentMetaAccessor::CalculateSize;
using ContentMetaAccessor::CalculateContentRequiredSize;
using ContentMetaAccessor::GetWritableContentInfo;
using ContentMetaAccessor::SetStorageId;
};
class PatchMetaExtendedDataAccessor;
struct PatchDeltaHeader;
class AutoBuffer;
class MetaConverter {
public:
static Result CountContentExceptForMeta(s32 *out, PatchMetaExtendedDataAccessor *accessor, const PatchDeltaHeader &header, s32 delta_index);
static Result FindDeltaIndex(s32 *out, PatchMetaExtendedDataAccessor *accessor, u32 source_version, u32 destination_version);
static Result GetFragmentOnlyInstallContentMeta(AutoBuffer *out, const InstallContentInfo &content_info, const PackagedContentMetaReader &reader, PatchMetaExtendedDataAccessor *accessor, u32 source_version);
};
}
| 16,838
|
C++
|
.h
| 326
| 39.59816
| 219
| 0.623091
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,170
|
ncm_system_content_meta_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_content_meta_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 <stratosphere/ncm/ncm_data_id.hpp>
#include <stratosphere/ncm/ncm_program_id.hpp>
namespace ams::ncm {
struct SystemProgramId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
static const SystemProgramId Start;
static const SystemProgramId Fs;
static const SystemProgramId Loader;
static const SystemProgramId Ncm;
static const SystemProgramId Pm;
static const SystemProgramId Sm;
static const SystemProgramId Boot;
static const SystemProgramId Usb;
static const SystemProgramId Tma;
static const SystemProgramId Boot2;
static const SystemProgramId Settings;
static const SystemProgramId Bus;
static const SystemProgramId Bluetooth;
static const SystemProgramId Bcat;
static const SystemProgramId Dmnt;
static const SystemProgramId Friends;
static const SystemProgramId Nifm;
static const SystemProgramId Ptm;
static const SystemProgramId Shell;
static const SystemProgramId BsdSockets;
static const SystemProgramId Hid;
static const SystemProgramId Audio;
static const SystemProgramId LogManager;
static const SystemProgramId Wlan;
static const SystemProgramId Cs;
static const SystemProgramId Ldn;
static const SystemProgramId NvServices;
static const SystemProgramId Pcv;
static const SystemProgramId Ppc;
static const SystemProgramId NvnFlinger;
static const SystemProgramId Pcie;
static const SystemProgramId Account;
static const SystemProgramId Ns;
static const SystemProgramId Nfc;
static const SystemProgramId Psc;
static const SystemProgramId CapSrv;
static const SystemProgramId Am;
static const SystemProgramId Ssl;
static const SystemProgramId Nim;
static const SystemProgramId Cec;
static const SystemProgramId Tspm;
static const SystemProgramId Spl;
static const SystemProgramId Lbl;
static const SystemProgramId Btm;
static const SystemProgramId Erpt;
static const SystemProgramId Time;
static const SystemProgramId Vi;
static const SystemProgramId Pctl;
static const SystemProgramId Npns;
static const SystemProgramId Eupld;
static const SystemProgramId Arp;
static const SystemProgramId Glue;
static const SystemProgramId Eclct;
static const SystemProgramId Es;
static const SystemProgramId Fatal;
static const SystemProgramId Grc;
static const SystemProgramId Creport;
static const SystemProgramId Ro;
static const SystemProgramId Profiler;
static const SystemProgramId Sdb;
static const SystemProgramId Migration;
static const SystemProgramId Jit;
static const SystemProgramId JpegDec;
static const SystemProgramId SafeMode;
static const SystemProgramId Olsc;
static const SystemProgramId Dt;
static const SystemProgramId Nd;
static const SystemProgramId Ngct;
static const SystemProgramId Pgl;
static const SystemProgramId Omm;
static const SystemProgramId Eth;
static const SystemProgramId Ngc;
static const SystemProgramId End;
static const SystemProgramId Manu;
static const SystemProgramId Htc;
static const SystemProgramId DmntGen2;
static const SystemProgramId DevServer;
};
struct AtmosphereProgramId {
u64 value;
constexpr operator SystemProgramId() const {
return { this->value };
}
constexpr operator ProgramId() const {
return static_cast<SystemProgramId>(*this);
}
static const AtmosphereProgramId Mitm;
static const AtmosphereProgramId AtmosphereLogManager;
};
inline constexpr const AtmosphereProgramId AtmosphereProgramId::Mitm = { 0x010041544D530000ul };
inline constexpr const AtmosphereProgramId AtmosphereProgramId::AtmosphereLogManager = { 0x0100000000000420ul };
inline constexpr bool IsAtmosphereProgramId(const ProgramId &program_id) {
return program_id == AtmosphereProgramId::Mitm || program_id == AtmosphereProgramId::AtmosphereLogManager;
}
inline constexpr bool IsSystemProgramId(const AtmosphereProgramId &) {
return true;
}
inline constexpr const SystemProgramId SystemProgramId::Start = { 0x0100000000000000ul };
inline constexpr const SystemProgramId SystemProgramId::Fs = { 0x0100000000000000ul };
inline constexpr const SystemProgramId SystemProgramId::Loader = { 0x0100000000000001ul };
inline constexpr const SystemProgramId SystemProgramId::Ncm = { 0x0100000000000002ul };
inline constexpr const SystemProgramId SystemProgramId::Pm = { 0x0100000000000003ul };
inline constexpr const SystemProgramId SystemProgramId::Sm = { 0x0100000000000004ul };
inline constexpr const SystemProgramId SystemProgramId::Boot = { 0x0100000000000005ul };
inline constexpr const SystemProgramId SystemProgramId::Usb = { 0x0100000000000006ul };
inline constexpr const SystemProgramId SystemProgramId::Tma = { 0x0100000000000007ul };
inline constexpr const SystemProgramId SystemProgramId::Boot2 = { 0x0100000000000008ul };
inline constexpr const SystemProgramId SystemProgramId::Settings = { 0x0100000000000009ul };
inline constexpr const SystemProgramId SystemProgramId::Bus = { 0x010000000000000Aul };
inline constexpr const SystemProgramId SystemProgramId::Bluetooth = { 0x010000000000000Bul };
inline constexpr const SystemProgramId SystemProgramId::Bcat = { 0x010000000000000Cul };
inline constexpr const SystemProgramId SystemProgramId::Dmnt = { 0x010000000000000Dul };
inline constexpr const SystemProgramId SystemProgramId::Friends = { 0x010000000000000Eul };
inline constexpr const SystemProgramId SystemProgramId::Nifm = { 0x010000000000000Ful };
inline constexpr const SystemProgramId SystemProgramId::Ptm = { 0x0100000000000010ul };
inline constexpr const SystemProgramId SystemProgramId::Shell = { 0x0100000000000011ul };
inline constexpr const SystemProgramId SystemProgramId::BsdSockets = { 0x0100000000000012ul };
inline constexpr const SystemProgramId SystemProgramId::Hid = { 0x0100000000000013ul };
inline constexpr const SystemProgramId SystemProgramId::Audio = { 0x0100000000000014ul };
inline constexpr const SystemProgramId SystemProgramId::LogManager = { 0x0100000000000015ul };
inline constexpr const SystemProgramId SystemProgramId::Wlan = { 0x0100000000000016ul };
inline constexpr const SystemProgramId SystemProgramId::Cs = { 0x0100000000000017ul };
inline constexpr const SystemProgramId SystemProgramId::Ldn = { 0x0100000000000018ul };
inline constexpr const SystemProgramId SystemProgramId::NvServices = { 0x0100000000000019ul };
inline constexpr const SystemProgramId SystemProgramId::Pcv = { 0x010000000000001Aul };
inline constexpr const SystemProgramId SystemProgramId::Ppc = { 0x010000000000001Bul };
inline constexpr const SystemProgramId SystemProgramId::NvnFlinger = { 0x010000000000001Cul };
inline constexpr const SystemProgramId SystemProgramId::Pcie = { 0x010000000000001Dul };
inline constexpr const SystemProgramId SystemProgramId::Account = { 0x010000000000001Eul };
inline constexpr const SystemProgramId SystemProgramId::Ns = { 0x010000000000001Ful };
inline constexpr const SystemProgramId SystemProgramId::Nfc = { 0x0100000000000020ul };
inline constexpr const SystemProgramId SystemProgramId::Psc = { 0x0100000000000021ul };
inline constexpr const SystemProgramId SystemProgramId::CapSrv = { 0x0100000000000022ul };
inline constexpr const SystemProgramId SystemProgramId::Am = { 0x0100000000000023ul };
inline constexpr const SystemProgramId SystemProgramId::Ssl = { 0x0100000000000024ul };
inline constexpr const SystemProgramId SystemProgramId::Nim = { 0x0100000000000025ul };
inline constexpr const SystemProgramId SystemProgramId::Cec = { 0x0100000000000026ul };
inline constexpr const SystemProgramId SystemProgramId::Tspm = { 0x0100000000000027ul };
inline constexpr const SystemProgramId SystemProgramId::Spl = { 0x0100000000000028ul };
inline constexpr const SystemProgramId SystemProgramId::Lbl = { 0x0100000000000029ul };
inline constexpr const SystemProgramId SystemProgramId::Btm = { 0x010000000000002Aul };
inline constexpr const SystemProgramId SystemProgramId::Erpt = { 0x010000000000002Bul };
inline constexpr const SystemProgramId SystemProgramId::Time = { 0x010000000000002Cul };
inline constexpr const SystemProgramId SystemProgramId::Vi = { 0x010000000000002Dul };
inline constexpr const SystemProgramId SystemProgramId::Pctl = { 0x010000000000002Eul };
inline constexpr const SystemProgramId SystemProgramId::Npns = { 0x010000000000002Ful };
inline constexpr const SystemProgramId SystemProgramId::Eupld = { 0x0100000000000030ul };
inline constexpr const SystemProgramId SystemProgramId::Arp = { 0x0100000000000031ul };
inline constexpr const SystemProgramId SystemProgramId::Glue = { 0x0100000000000031ul };
inline constexpr const SystemProgramId SystemProgramId::Eclct = { 0x0100000000000032ul };
inline constexpr const SystemProgramId SystemProgramId::Es = { 0x0100000000000033ul };
inline constexpr const SystemProgramId SystemProgramId::Fatal = { 0x0100000000000034ul };
inline constexpr const SystemProgramId SystemProgramId::Grc = { 0x0100000000000035ul };
inline constexpr const SystemProgramId SystemProgramId::Creport = { 0x0100000000000036ul };
inline constexpr const SystemProgramId SystemProgramId::Ro = { 0x0100000000000037ul };
inline constexpr const SystemProgramId SystemProgramId::Profiler = { 0x0100000000000038ul };
inline constexpr const SystemProgramId SystemProgramId::Sdb = { 0x0100000000000039ul };
inline constexpr const SystemProgramId SystemProgramId::Migration = { 0x010000000000003Aul };
inline constexpr const SystemProgramId SystemProgramId::Jit = { 0x010000000000003Bul };
inline constexpr const SystemProgramId SystemProgramId::JpegDec = { 0x010000000000003Cul };
inline constexpr const SystemProgramId SystemProgramId::SafeMode = { 0x010000000000003Dul };
inline constexpr const SystemProgramId SystemProgramId::Olsc = { 0x010000000000003Eul };
inline constexpr const SystemProgramId SystemProgramId::Dt = { 0x010000000000003Ful };
inline constexpr const SystemProgramId SystemProgramId::Nd = { 0x0100000000000040ul };
inline constexpr const SystemProgramId SystemProgramId::Ngct = { 0x0100000000000041ul };
inline constexpr const SystemProgramId SystemProgramId::Pgl = { 0x0100000000000042ul };
inline constexpr const SystemProgramId SystemProgramId::Omm = { 0x0100000000000045ul };
inline constexpr const SystemProgramId SystemProgramId::Eth = { 0x0100000000000046ul };
inline constexpr const SystemProgramId SystemProgramId::Ngc = { 0x0100000000000050ul };
inline constexpr const SystemProgramId SystemProgramId::End = { 0x01000000000007FFul };
inline constexpr const SystemProgramId SystemProgramId::Manu = { 0x010000000000B14Aul };
inline constexpr const SystemProgramId SystemProgramId::Htc = { 0x010000000000B240ul };
inline constexpr const SystemProgramId SystemProgramId::DmntGen2 = { 0x010000000000D609ul };
inline constexpr const SystemProgramId SystemProgramId::DevServer = { 0x010000000000D623ul };
inline constexpr bool IsSystemProgramId(const ProgramId &program_id) {
return (SystemProgramId::Start <= program_id && program_id <= SystemProgramId::End) || IsAtmosphereProgramId(program_id);
}
inline constexpr bool IsSystemProgramId(const SystemProgramId &) {
return true;
}
struct SystemDataId {
u64 value;
constexpr operator DataId() const {
return { this->value };
}
constexpr inline bool operator==(const SystemDataId &) const = default;
constexpr inline bool operator!=(const SystemDataId &) const = default;
static const SystemDataId Start;
static const SystemDataId CertStore;
static const SystemDataId ErrorMessage;
static const SystemDataId MiiModel;
static const SystemDataId BrowserDll;
static const SystemDataId Help;
static const SystemDataId SharedFont;
static const SystemDataId NgWord;
static const SystemDataId SsidList;
static const SystemDataId Dictionary;
static const SystemDataId SystemVersion;
static const SystemDataId AvatarImage;
static const SystemDataId LocalNews;
static const SystemDataId Eula;
static const SystemDataId UrlBlackList;
static const SystemDataId TimeZoneBinar;
static const SystemDataId CertStoreCruiser;
static const SystemDataId FontNintendoExtension;
static const SystemDataId FontStandard;
static const SystemDataId FontKorean;
static const SystemDataId FontChineseTraditional;
static const SystemDataId FontChineseSimple;
static const SystemDataId FontBfcpx;
static const SystemDataId SystemUpdate;
static const SystemDataId FirmwareDebugSettings;
static const SystemDataId BootImagePackage;
static const SystemDataId BootImagePackageSafe;
static const SystemDataId BootImagePackageExFat;
static const SystemDataId BootImagePackageExFatSafe;
static const SystemDataId FatalMessage;
static const SystemDataId ControllerIcon;
static const SystemDataId PlatformConfigIcosa;
static const SystemDataId PlatformConfigCopper;
static const SystemDataId PlatformConfigHoag;
static const SystemDataId ControllerFirmware;
static const SystemDataId NgWord2;
static const SystemDataId PlatformConfigIcosaMariko;
static const SystemDataId ApplicationBlackList;
static const SystemDataId RebootlessSystemUpdateVersion;
static const SystemDataId ContentActionTable;
static const SystemDataId PlatformConfigCalcio;
static const SystemDataId PlatformConfigAula;
static const SystemDataId End;
};
inline constexpr const SystemDataId SystemDataId::Start = { 0x0100000000000800ul };
inline constexpr const SystemDataId SystemDataId::CertStore = { 0x0100000000000800ul };
inline constexpr const SystemDataId SystemDataId::ErrorMessage = { 0x0100000000000801ul };
inline constexpr const SystemDataId SystemDataId::MiiModel = { 0x0100000000000802ul };
inline constexpr const SystemDataId SystemDataId::BrowserDll = { 0x0100000000000803ul };
inline constexpr const SystemDataId SystemDataId::Help = { 0x0100000000000804ul };
inline constexpr const SystemDataId SystemDataId::SharedFont = { 0x0100000000000805ul };
inline constexpr const SystemDataId SystemDataId::NgWord = { 0x0100000000000806ul };
inline constexpr const SystemDataId SystemDataId::SsidList = { 0x0100000000000807ul };
inline constexpr const SystemDataId SystemDataId::Dictionary = { 0x0100000000000808ul };
inline constexpr const SystemDataId SystemDataId::SystemVersion = { 0x0100000000000809ul };
inline constexpr const SystemDataId SystemDataId::AvatarImage = { 0x010000000000080Aul };
inline constexpr const SystemDataId SystemDataId::LocalNews = { 0x010000000000080Bul };
inline constexpr const SystemDataId SystemDataId::Eula = { 0x010000000000080Cul };
inline constexpr const SystemDataId SystemDataId::UrlBlackList = { 0x010000000000080Dul };
inline constexpr const SystemDataId SystemDataId::TimeZoneBinar = { 0x010000000000080Eul };
inline constexpr const SystemDataId SystemDataId::CertStoreCruiser = { 0x010000000000080Ful };
inline constexpr const SystemDataId SystemDataId::FontNintendoExtension = { 0x0100000000000810ul };
inline constexpr const SystemDataId SystemDataId::FontStandard = { 0x0100000000000811ul };
inline constexpr const SystemDataId SystemDataId::FontKorean = { 0x0100000000000812ul };
inline constexpr const SystemDataId SystemDataId::FontChineseTraditional = { 0x0100000000000813ul };
inline constexpr const SystemDataId SystemDataId::FontChineseSimple = { 0x0100000000000814ul };
inline constexpr const SystemDataId SystemDataId::FontBfcpx = { 0x0100000000000815ul };
inline constexpr const SystemDataId SystemDataId::SystemUpdate = { 0x0100000000000816ul };
inline constexpr const SystemDataId SystemDataId::FirmwareDebugSettings = { 0x0100000000000818ul };
inline constexpr const SystemDataId SystemDataId::BootImagePackage = { 0x0100000000000819ul };
inline constexpr const SystemDataId SystemDataId::BootImagePackageSafe = { 0x010000000000081Aul };
inline constexpr const SystemDataId SystemDataId::BootImagePackageExFat = { 0x010000000000081Bul };
inline constexpr const SystemDataId SystemDataId::BootImagePackageExFatSafe = { 0x010000000000081Cul };
inline constexpr const SystemDataId SystemDataId::FatalMessage = { 0x010000000000081Dul };
inline constexpr const SystemDataId SystemDataId::ControllerIcon = { 0x010000000000081Eul };
inline constexpr const SystemDataId SystemDataId::PlatformConfigIcosa = { 0x010000000000081Ful };
inline constexpr const SystemDataId SystemDataId::PlatformConfigCopper = { 0x0100000000000820ul };
inline constexpr const SystemDataId SystemDataId::PlatformConfigHoag = { 0x0100000000000821ul };
inline constexpr const SystemDataId SystemDataId::ControllerFirmware = { 0x0100000000000822ul };
inline constexpr const SystemDataId SystemDataId::NgWord2 = { 0x0100000000000823ul };
inline constexpr const SystemDataId SystemDataId::PlatformConfigIcosaMariko = { 0x0100000000000824ul };
inline constexpr const SystemDataId SystemDataId::ApplicationBlackList = { 0x0100000000000825ul };
inline constexpr const SystemDataId SystemDataId::RebootlessSystemUpdateVersion = { 0x0100000000000826ul };
inline constexpr const SystemDataId SystemDataId::ContentActionTable = { 0x0100000000000827ul };
inline constexpr const SystemDataId SystemDataId::PlatformConfigCalcio = { 0x0100000000000829ul };
inline constexpr const SystemDataId SystemDataId::PlatformConfigAula = { 0x0100000000000831ul };
inline constexpr const SystemDataId SystemDataId::End = { 0x0100000000000FFFul };
inline constexpr bool IsSystemDataId(const DataId &data_id) {
return SystemDataId::Start <= data_id && data_id <= SystemDataId::End;
}
inline constexpr bool IsSystemDataId(const SystemDataId &) {
return true;
}
struct SystemUpdateId {
u64 value;
constexpr operator DataId() const {
return { this->value };
}
constexpr inline bool operator==(const SystemUpdateId &) const = default;
constexpr inline bool operator!=(const SystemUpdateId &) const = default;
};
struct SystemAppletId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
constexpr inline bool operator==(const SystemAppletId &) const = default;
constexpr inline bool operator!=(const SystemAppletId &) const = default;
static const SystemAppletId Start;
static const SystemAppletId Qlaunch;
static const SystemAppletId Auth;
static const SystemAppletId Cabinet;
static const SystemAppletId Controller;
static const SystemAppletId DataErase;
static const SystemAppletId Error;
static const SystemAppletId NetConnect;
static const SystemAppletId PlayerSelect;
static const SystemAppletId Swkbd;
static const SystemAppletId MiiEdit;
static const SystemAppletId Web;
static const SystemAppletId Shop;
static const SystemAppletId OverlayDisp;
static const SystemAppletId PhotoViewer;
static const SystemAppletId Set;
static const SystemAppletId OfflineWeb;
static const SystemAppletId LoginShare;
static const SystemAppletId WifiWebAuth;
static const SystemAppletId Starter;
static const SystemAppletId MyPage;
static const SystemAppletId PlayReport;
static const SystemAppletId MaintenanceMenu;
static const SystemAppletId Gift;
static const SystemAppletId DummyShop;
static const SystemAppletId UserMigration;
static const SystemAppletId Encounter;
static const SystemAppletId Story;
static const SystemAppletId End;
};
inline constexpr const SystemAppletId SystemAppletId::Start = { 0x0100000000001000ul };
inline constexpr const SystemAppletId SystemAppletId::Qlaunch = { 0x0100000000001000ul };
inline constexpr const SystemAppletId SystemAppletId::Auth = { 0x0100000000001001ul };
inline constexpr const SystemAppletId SystemAppletId::Cabinet = { 0x0100000000001002ul };
inline constexpr const SystemAppletId SystemAppletId::Controller = { 0x0100000000001003ul };
inline constexpr const SystemAppletId SystemAppletId::DataErase = { 0x0100000000001004ul };
inline constexpr const SystemAppletId SystemAppletId::Error = { 0x0100000000001005ul };
inline constexpr const SystemAppletId SystemAppletId::NetConnect = { 0x0100000000001006ul };
inline constexpr const SystemAppletId SystemAppletId::PlayerSelect = { 0x0100000000001007ul };
inline constexpr const SystemAppletId SystemAppletId::Swkbd = { 0x0100000000001008ul };
inline constexpr const SystemAppletId SystemAppletId::MiiEdit = { 0x0100000000001009ul };
inline constexpr const SystemAppletId SystemAppletId::Web = { 0x010000000000100Aul };
inline constexpr const SystemAppletId SystemAppletId::Shop = { 0x010000000000100Bul };
inline constexpr const SystemAppletId SystemAppletId::OverlayDisp = { 0x010000000000100Cul };
inline constexpr const SystemAppletId SystemAppletId::PhotoViewer = { 0x010000000000100Dul };
inline constexpr const SystemAppletId SystemAppletId::Set = { 0x010000000000100Eul };
inline constexpr const SystemAppletId SystemAppletId::OfflineWeb = { 0x010000000000100Ful };
inline constexpr const SystemAppletId SystemAppletId::LoginShare = { 0x0100000000001010ul };
inline constexpr const SystemAppletId SystemAppletId::WifiWebAuth = { 0x0100000000001011ul };
inline constexpr const SystemAppletId SystemAppletId::Starter = { 0x0100000000001012ul };
inline constexpr const SystemAppletId SystemAppletId::MyPage = { 0x0100000000001013ul };
inline constexpr const SystemAppletId SystemAppletId::PlayReport = { 0x0100000000001014ul };
inline constexpr const SystemAppletId SystemAppletId::MaintenanceMenu = { 0x0100000000001015ul };
inline constexpr const SystemAppletId SystemAppletId::Gift = { 0x010000000000101Aul };
inline constexpr const SystemAppletId SystemAppletId::DummyShop = { 0x010000000000101Bul };
inline constexpr const SystemAppletId SystemAppletId::UserMigration = { 0x010000000000101Cul };
inline constexpr const SystemAppletId SystemAppletId::Encounter = { 0x010000000000101Dul };
inline constexpr const SystemAppletId SystemAppletId::Story = { 0x0100000000001020ul };
inline constexpr const SystemAppletId SystemAppletId::End = { 0x0100000000001FFFul };
inline constexpr bool IsSystemAppletId(const ProgramId &program_id) {
return SystemAppletId::Start <= program_id && program_id <= SystemAppletId::End;
}
inline constexpr bool IsSystemAppletId(const SystemAppletId &) {
return true;
}
struct SystemDebugAppletId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
constexpr inline bool operator==(const SystemDebugAppletId &) const = default;
constexpr inline bool operator!=(const SystemDebugAppletId &) const = default;
static const SystemDebugAppletId Start;
static const SystemDebugAppletId SnapShotDumper;
static const SystemDebugAppletId End;
};
inline constexpr const SystemDebugAppletId SystemDebugAppletId::Start = { 0x0100000000002000ul };
inline constexpr const SystemDebugAppletId SystemDebugAppletId::SnapShotDumper = { 0x0100000000002071ul };
inline constexpr const SystemDebugAppletId SystemDebugAppletId::End = { 0x0100000000002FFFul };
inline constexpr bool IsSystemDebugAppletId(const ProgramId &program_id) {
return SystemDebugAppletId::Start <= program_id && program_id <= SystemDebugAppletId::End;
}
inline constexpr bool IsSystemDebugAppletId(const SystemDebugAppletId &) {
return true;
}
struct LibraryAppletId {
u64 value;
constexpr operator SystemAppletId() const {
return { this->value };
}
constexpr operator ProgramId() const {
return static_cast<SystemAppletId>(*this);
}
constexpr inline bool operator==(const LibraryAppletId &) const = default;
constexpr inline bool operator!=(const LibraryAppletId &) const = default;
static const LibraryAppletId Auth;
static const LibraryAppletId Controller;
static const LibraryAppletId Error;
static const LibraryAppletId PlayerSelect;
static const LibraryAppletId Swkbd;
static const LibraryAppletId Web;
static const LibraryAppletId Shop;
static const LibraryAppletId PhotoViewer;
static const LibraryAppletId OfflineWeb;
static const LibraryAppletId LoginShare;
static const LibraryAppletId WifiWebAuth;
static const LibraryAppletId MyPage;
};
inline constexpr const LibraryAppletId LibraryAppletId::Auth = { SystemAppletId::Auth.value };
inline constexpr const LibraryAppletId LibraryAppletId::Controller = { SystemAppletId::Controller.value };
inline constexpr const LibraryAppletId LibraryAppletId::Error = { SystemAppletId::Error.value };
inline constexpr const LibraryAppletId LibraryAppletId::PlayerSelect = { SystemAppletId::PlayerSelect.value };
inline constexpr const LibraryAppletId LibraryAppletId::Swkbd = { SystemAppletId::Swkbd.value };
inline constexpr const LibraryAppletId LibraryAppletId::Web = { SystemAppletId::Web.value };
inline constexpr const LibraryAppletId LibraryAppletId::Shop = { SystemAppletId::Shop.value };
inline constexpr const LibraryAppletId LibraryAppletId::PhotoViewer = { SystemAppletId::PhotoViewer.value };
inline constexpr const LibraryAppletId LibraryAppletId::OfflineWeb = { SystemAppletId::OfflineWeb.value };
inline constexpr const LibraryAppletId LibraryAppletId::LoginShare = { SystemAppletId::LoginShare.value };
inline constexpr const LibraryAppletId LibraryAppletId::WifiWebAuth = { SystemAppletId::WifiWebAuth.value };
inline constexpr const LibraryAppletId LibraryAppletId::MyPage = { SystemAppletId::MyPage.value };
inline constexpr bool IsLibraryAppletId(const ProgramId &id) {
return id == LibraryAppletId::Auth ||
id == LibraryAppletId::Controller ||
id == LibraryAppletId::Error ||
id == LibraryAppletId::PlayerSelect ||
id == LibraryAppletId::Swkbd ||
id == LibraryAppletId::Web ||
id == LibraryAppletId::Shop ||
id == LibraryAppletId::PhotoViewer ||
id == LibraryAppletId::OfflineWeb ||
id == LibraryAppletId::LoginShare ||
id == LibraryAppletId::WifiWebAuth ||
id == LibraryAppletId::MyPage;
}
inline constexpr bool IsLibraryAppletId(const LibraryAppletId &) {
return true;
}
struct WebAppletId {
u64 value;
constexpr operator LibraryAppletId() const {
return { this->value };
}
constexpr operator SystemAppletId() const {
return static_cast<LibraryAppletId>(*this);
}
constexpr operator ProgramId() const {
return static_cast<SystemAppletId>(*this);
}
constexpr inline bool operator==(const WebAppletId &) const = default;
constexpr inline bool operator!=(const WebAppletId &) const = default;
static const WebAppletId Web;
static const WebAppletId Shop;
static const WebAppletId OfflineWeb;
static const WebAppletId LoginShare;
static const WebAppletId WifiWebAuth;
};
inline constexpr const WebAppletId WebAppletId::Web = { LibraryAppletId::Web.value };
inline constexpr const WebAppletId WebAppletId::Shop = { LibraryAppletId::Shop.value };
inline constexpr const WebAppletId WebAppletId::OfflineWeb = { LibraryAppletId::OfflineWeb.value };
inline constexpr const WebAppletId WebAppletId::LoginShare = { LibraryAppletId::LoginShare.value };
inline constexpr const WebAppletId WebAppletId::WifiWebAuth = { LibraryAppletId::WifiWebAuth.value };
inline constexpr bool IsWebAppletId(const ProgramId &id) {
return id == WebAppletId::Web ||
id == WebAppletId::Shop ||
id == WebAppletId::OfflineWeb ||
id == WebAppletId::LoginShare ||
id == WebAppletId::WifiWebAuth;
}
inline constexpr bool IsWebAppletId(const WebAppletId &) {
return true;
}
struct SystemApplicationId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
constexpr inline bool operator==(const SystemApplicationId &) const = default;
constexpr inline bool operator!=(const SystemApplicationId &) const = default;
};
}
| 32,244
|
C++
|
.h
| 499
| 57.160321
| 129
| 0.717386
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,171
|
ncm_content_meta_platform.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_platform.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::ncm {
enum class ContentMetaPlatform : u8 {
Nx = 0x0,
};
}
| 764
|
C++
|
.h
| 22
| 32.227273
| 76
| 0.738836
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,172
|
ncm_placeholder_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_placeholder_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::ncm {
struct PlaceHolderId {
util::Uuid uuid;
bool operator==(const PlaceHolderId &other) const {
return this->uuid == other.uuid;
}
bool operator!=(const PlaceHolderId &other) const {
return this->uuid != other.uuid;
}
bool operator==(const util::Uuid &other) const {
return this->uuid == other;
}
bool operator!=(const util::Uuid &other) const {
return this->uuid != other;
}
};
static_assert(alignof(PlaceHolderId) == 1);
constexpr inline PlaceHolderId InvalidPlaceHolderId = { util::InvalidUuid };
}
| 1,335
|
C++
|
.h
| 36
| 31.666667
| 80
| 0.675969
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,173
|
ncm_package_install_task_base.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/kvdb/kvdb_bounded_string.hpp>
#include <stratosphere/ncm/ncm_install_task_base.hpp>
namespace ams::ncm {
class PackageInstallTaskBase : public InstallTaskBase {
private:
using PackagePath = kvdb::BoundedString<256>;
private:
PackagePath m_package_root;
void *m_buffer{};
size_t m_buffer_size{};
public:
PackageInstallTaskBase() : m_package_root() { /* ... */ }
Result Initialize(const char *package_root_path, void *buffer, size_t buffer_size, StorageId storage_id, InstallTaskDataBase *data, u32 config);
protected:
const char *GetPackageRootPath() {
return m_package_root.Get();
}
private:
virtual Result OnWritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) override;
virtual Result InstallTicket(const fs::RightsId &rights_id, ContentMetaType meta_type) override;
void CreateContentMetaPath(PackagePath *out_path, ContentId content_id);
void CreateContentPath(PackagePath *out_path, ContentId content_id);
void CreateTicketPath(PackagePath *out_path, fs::RightsId id);
void CreateCertificatePath(PackagePath *out_path, fs::RightsId id);
};
}
| 1,980
|
C++
|
.h
| 42
| 40.166667
| 156
| 0.693223
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,174
|
ncm_rights_id_cache.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/os.hpp>
#include <stratosphere/ncm/ncm_rights_id.hpp>
#include <stratosphere/ncm/ncm_content_id.hpp>
namespace ams::ncm {
class RightsIdCache {
NON_COPYABLE(RightsIdCache);
NON_MOVEABLE(RightsIdCache);
private:
static constexpr size_t MaxEntries = 0x80;
private:
struct Entry {
public:
util::Uuid uuid;
ncm::RightsId rights_id;
u64 last_accessed;
};
private:
Entry m_entries[MaxEntries];
u64 m_counter;
os::SdkMutex m_mutex;
public:
RightsIdCache() : m_entries(), m_counter(2), m_mutex() {
this->Invalidate();
}
void Invalidate() {
m_counter = 2;
for (size_t i = 0; i < MaxEntries; i++) {
m_entries[i].last_accessed = 1;
}
}
void Store(ContentId content_id, ncm::RightsId rights_id) {
std::scoped_lock lk(m_mutex);
Entry *eviction_candidate = std::addressof(m_entries[0]);
/* Find a suitable existing entry to store our new one at. */
for (size_t i = 1; i < MaxEntries; i++) {
Entry *entry = std::addressof(m_entries[i]);
/* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */
if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) {
eviction_candidate = entry;
}
}
/* Update the cache. */
eviction_candidate->uuid = content_id.uuid;
eviction_candidate->rights_id = rights_id;
eviction_candidate->last_accessed = m_counter++;
}
bool Find(ncm::RightsId *out_rights_id, ContentId content_id) {
std::scoped_lock lk(m_mutex);
/* Attempt to locate the content id in the cache. */
for (size_t i = 0; i < MaxEntries; i++) {
Entry *entry = std::addressof(m_entries[i]);
if (entry->last_accessed != 1 && content_id == entry->uuid) {
entry->last_accessed = m_counter;
m_counter++;
*out_rights_id = entry->rights_id;
return true;
}
}
return false;
}
};
}
| 3,361
|
C++
|
.h
| 78
| 30.628205
| 160
| 0.542953
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,175
|
ncm_path_string.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_path_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 <stratosphere/fs/fs_directory.hpp>
#include <stratosphere/kvdb/kvdb_bounded_string.hpp>
namespace ams::ncm {
using PathString = kvdb::BoundedString<fs::EntryNameLengthMax>;
}
| 839
|
C++
|
.h
| 21
| 37.952381
| 76
| 0.765644
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,176
|
ncm_content_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/ncm/ncm_i_content_storage.hpp>
namespace ams::ncm {
class ContentStorage {
NON_COPYABLE(ContentStorage);
private:
sf::SharedPointer<IContentStorage> m_interface;
public:
ContentStorage() : m_interface(nullptr) { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : m_interface(intf) { /* ... */ }
ContentStorage(ContentStorage &&rhs) {
m_interface = std::move(rhs.m_interface);
}
ContentStorage &operator=(ContentStorage &&rhs) {
ContentStorage(std::move(rhs)).swap(*this);
return *this;
}
void swap(ContentStorage &rhs) {
std::swap(m_interface, rhs.m_interface);
}
public:
PlaceHolderId GeneratePlaceHolderId() {
AMS_ASSERT(m_interface != nullptr);
PlaceHolderId id;
R_ABORT_UNLESS(m_interface->GeneratePlaceHolderId(std::addressof(id)));
return id;
}
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->CreatePlaceHolder(placeholder_id, content_id, size));
}
Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->DeletePlaceHolder(placeholder_id));
}
Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->HasPlaceHolder(out, placeholder_id));
}
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size)));
}
Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Register(placeholder_id, content_id));
}
Result Delete(ContentId content_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Delete(content_id));
}
Result Has(bool *out, ContentId content_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Has(out, content_id));
}
void GetPath(Path *out, ContentId content_id) {
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->GetPath(out, content_id));
}
void GetPlaceHolderPath(Path *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->GetPlaceHolderPath(out, placeholder_id));
}
Result CleanupAllPlaceHolder() {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->CleanupAllPlaceHolder());
}
Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size)));
}
Result GetContentCount(s32 *out_count) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetContentCount(out_count));
}
Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset));
}
Result GetSize(s64 *out_size, ContentId content_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetSizeFromContentId(out_size, content_id));
}
Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id));
}
Result DisableForcibly() {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->DisableForcibly());
}
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id));
}
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->SetPlaceHolderSize(placeholder_id, size));
}
Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset));
}
Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) {
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_16_0_0) {
R_RETURN(m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id, attr));
} else if (vers >= hos::Version_3_0_0) {
R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdDeprecated2(out_rights_id, placeholder_id));
} else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {};
R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id));
}
}
Result GetRightsId(ncm::RightsId *out_rights_id, ContentId content_id, fs::ContentAttributes attr) {
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_16_0_0) {
R_RETURN(m_interface->GetRightsIdFromContentId(out_rights_id, content_id, attr));
} else if (vers >= hos::Version_3_0_0) {
R_RETURN(m_interface->GetRightsIdFromContentIdDeprecated2(out_rights_id, content_id));
} else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {};
R_RETURN(m_interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id));
}
}
Result WriteContentForDebug(ContentId content_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size)));
}
Result GetFreeSpaceSize(s64 *out_size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetFreeSpaceSize(out_size));
}
Result GetTotalSpaceSize(s64 *out_size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetTotalSpaceSize(out_size));
}
Result FlushPlaceHolder() {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->FlushPlaceHolder());
}
Result RepairInvalidFileAttribute() {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->RepairInvalidFileAttribute());
}
Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) {
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_16_0_0) {
R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id, attr));
} else {
R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdWithCacheDeprecated(out_rights_id, cache_content_id, placeholder_id));
}
}
Result GetProgramId(ncm::ProgramId *out, ContentId content_id, fs::ContentAttributes attr) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetProgramId(out, content_id, attr));
}
};
}
| 9,715
|
C++
|
.h
| 179
| 40.223464
| 174
| 0.589177
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,177
|
ncm_content_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_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::ncm {
struct ContentId {
util::Uuid uuid;
bool operator==(const ContentId &other) const {
return this->uuid == other.uuid;
}
bool operator!=(const ContentId &other) const {
return this->uuid != other.uuid;
}
bool operator==(const util::Uuid &other) const {
return this->uuid == other;
}
bool operator!=(const util::Uuid &other) const {
return this->uuid != other;
}
};
static_assert(alignof(ContentId) == 1);
constexpr inline ContentId InvalidContentId = { util::InvalidUuid };
}
| 1,311
|
C++
|
.h
| 36
| 31
| 76
| 0.669826
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,178
|
ncm_package_system_update_task.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/ncm/ncm_package_install_task_base.hpp>
namespace ams::ncm {
class PackageSystemUpdateTask : public PackageInstallTaskBase {
private:
using PackagePath = kvdb::BoundedString<0x100>;
private:
PackagePath m_context_path{};
FileInstallTaskData m_data{};
ContentMetaDatabase m_package_db{};
bool m_gamecard_content_meta_database_active{};
public:
~PackageSystemUpdateTask();
void Inactivate();
Result Initialize(const char *package_root, const char *context_path, void *buffer, size_t buffer_size, bool requires_exfat_driver, FirmwareVariationId firmware_variation_id);
util::optional<ContentMetaKey> GetSystemUpdateMetaKey();
protected:
virtual Result PrepareInstallContentMetaData() override;
virtual Result GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) override;
InstallTaskDataBase &GetInstallData() { return m_data; } /* Atmosphere extension. */
private:
virtual Result PrepareDependency() override;
Result GetContentInfoOfContentMeta(ContentInfo *out, const ContentMetaKey &key);
};
}
| 1,914
|
C++
|
.h
| 40
| 40.975
| 187
| 0.71054
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,179
|
ncm_i_content_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/sf.hpp>
#include <stratosphere/ncm/ncm_content_id.hpp>
#include <stratosphere/ncm/ncm_placeholder_id.hpp>
#include <stratosphere/ncm/ncm_path.hpp>
#include <stratosphere/ncm/ncm_rights_id.hpp>
#define AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GeneratePlaceHolderId, (sf::Out<ncm::PlaceHolderId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder_AtmosphereAlignmentFix, (ncm::ContentId content_id, ncm::PlaceHolderId placeholder_id, s64 size), (content_id, placeholder_id, size), hos::Version_Min, hos::Version_15_0_1) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id, s64 size), (placeholder_id, content_id, size), hos::Version_16_0_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, DeletePlaceHolder, (ncm::PlaceHolderId placeholder_id), (placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HasPlaceHolder, (sf::Out<bool> out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, WritePlaceHolder, (ncm::PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data), (placeholder_id, offset, data)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, Register_AtmosphereAlignmentFix, (ncm::ContentId content_id, ncm::PlaceHolderId placeholder_id), (content_id, placeholder_id), hos::Version_Min, hos::Version_15_0_1) \
AMS_SF_METHOD_INFO(C, H, 5, Result, Register, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id), (placeholder_id, content_id), hos::Version_16_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, Delete, (ncm::ContentId content_id), (content_id)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, Has, (sf::Out<bool> out, ncm::ContentId content_id), (out, content_id)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetPath, (sf::Out<ncm::Path> out, ncm::ContentId content_id), (out, content_id)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetPlaceHolderPath, (sf::Out<ncm::Path> out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, CleanupAllPlaceHolder, (), ()) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ListPlaceHolder, (sf::Out<s32> out_count, const sf::OutArray<ncm::PlaceHolderId> &out_buf), (out_count, out_buf)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetContentCount, (sf::Out<s32> out_count), (out_count)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, ListContentId, (sf::Out<s32> out_count, const sf::OutArray<ncm::ContentId> &out_buf, s32 start_offset), (out_count, out_buf, start_offset)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetSizeFromContentId, (sf::Out<s64> out_size, ncm::ContentId content_id), (out_size, content_id)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, DisableForcibly, (), ()) \
AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder_AtmosphereAlignmentFix, (ncm::ContentId old_content_id, ncm::ContentId new_content_id, ncm::PlaceHolderId placeholder_id), (old_content_id, new_content_id, placeholder_id), hos::Version_2_0_0, hos::Version_15_0_1) \
AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId old_content_id, ncm::ContentId new_content_id), (placeholder_id, old_content_id, new_content_id), hos::Version_16_0_0) \
AMS_SF_METHOD_INFO(C, H, 17, Result, SetPlaceHolderSize, (ncm::PlaceHolderId placeholder_id, s64 size), (placeholder_id, size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, ReadContentIdFile, (const sf::OutBuffer &buf, ncm::ContentId content_id, s64 offset), (buf, content_id, offset), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated, (sf::Out<ams::fs::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated2, (sf::Out<ncm::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_3_0_0, hos::Version_15_0_1) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderId, (sf::Out<ncm::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id, fs::ContentAttributes attr), (out_rights_id, placeholder_id, attr), hos::Version_16_0_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated, (sf::Out<ams::fs::RightsId> out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated2, (sf::Out<ncm::RightsId> out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_3_0_0, hos::Version_15_0_1) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentId, (sf::Out<ncm::RightsId> out_rights_id, ncm::ContentId content_id, fs::ContentAttributes attr), (out_rights_id, content_id, attr), hos::Version_16_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, WriteContentForDebug, (ncm::ContentId content_id, s64 offset, const sf::InBuffer &data), (content_id, offset, data), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 22, Result, GetFreeSpaceSize, (sf::Out<s64> out_size), (out_size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 23, Result, GetTotalSpaceSize, (sf::Out<s64> out_size), (out_size), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 24, Result, FlushPlaceHolder, (), (), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 25, Result, GetSizeFromPlaceHolderId, (sf::Out<s64> out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 26, Result, RepairInvalidFileAttribute, (), (), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCacheDeprecated, (sf::Out<ncm::RightsId> out_rights_id, ncm::ContentId cache_content_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, cache_content_id, placeholder_id), hos::Version_8_0_0, hos::Version_15_0_1) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCache, (sf::Out<ncm::RightsId> out_rights_id, ncm::PlaceHolderId placeholder_id, ncm::ContentId cache_content_id, fs::ContentAttributes attr), (out_rights_id, placeholder_id, cache_content_id, attr), hos::Version_16_0_0) \
AMS_SF_METHOD_INFO(C, H, 28, Result, RegisterPath, (const ncm::ContentId &content_id, const ncm::Path &path), (content_id, path), hos::Version_13_0_0) \
AMS_SF_METHOD_INFO(C, H, 29, Result, ClearRegisteredPath, (), (), hos::Version_13_0_0) \
AMS_SF_METHOD_INFO(C, H, 30, Result, GetProgramId, (sf::Out<ncm::ProgramId> out, ncm::ContentId content_id, fs::ContentAttributes attr), (out, content_id, attr), hos::Version_17_0_0)
AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentStorage, AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO, 0xFEAE3DD1)
| 14,068
|
C++
|
.h
| 62
| 223.129032
| 327
| 0.383248
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,180
|
ncm_submission_package_install_task.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_submission_package_install_task.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/common/fs_file_storage.hpp>
#include <stratosphere/ncm/ncm_package_install_task.hpp>
namespace ams::ncm {
class SubmissionPackageInstallTask : public PackageInstallTask {
private:
class Impl;
private:
std::unique_ptr<Impl> m_impl;
public:
SubmissionPackageInstallTask();
virtual ~SubmissionPackageInstallTask() override;
Result Initialize(fs::FileHandle handle, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket = false);
};
}
| 1,222
|
C++
|
.h
| 30
| 36.066667
| 137
| 0.723064
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,181
|
ncm_content_meta_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_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 <stratosphere/ncm/ncm_data_id.hpp>
#include <stratosphere/ncm/ncm_program_id.hpp>
namespace ams::ncm {
struct ApplicationId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
constexpr inline bool operator==(const ApplicationId &) const = default;
constexpr inline bool operator!=(const ApplicationId &) const = default;
static const ApplicationId Start;
static const ApplicationId End;
};
constexpr inline const ApplicationId InvalidApplicationId = {};
inline constexpr const ApplicationId ApplicationId::Start = { 0x0100000000010000ul };
inline constexpr const ApplicationId ApplicationId::End = { 0x01FFFFFFFFFFFFFFul };
inline constexpr bool IsApplicationId(const ProgramId &program_id) {
return ApplicationId::Start <= program_id && program_id <= ApplicationId::End;
}
inline constexpr bool IsApplicationId(const ApplicationId &) {
return true;
}
struct ApplicationGroupId {
u64 value;
};
struct PatchId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
constexpr inline bool operator==(const PatchId &) const = default;
constexpr inline bool operator!=(const PatchId &) const = default;
};
struct PatchGroupId {
u64 value;
};
struct AddOnContentId {
u64 value;
constexpr operator DataId() const {
return { this->value };
}
constexpr inline bool operator==(const AddOnContentId &) const = default;
constexpr inline bool operator!=(const AddOnContentId &) const = default;
};
struct DeltaId {
u64 value;
constexpr operator ProgramId() const {
return { this->value };
}
constexpr inline bool operator==(const DeltaId &) const = default;
constexpr inline bool operator!=(const DeltaId &) const = default;
};
struct DataPatchId {
u64 value;
constexpr operator DataId() const {
return { this->value };
}
constexpr inline bool operator==(const DataPatchId &) const = default;
constexpr inline bool operator!=(const DataPatchId &) const = default;
};
}
| 2,985
|
C++
|
.h
| 77
| 32.181818
| 91
| 0.67233
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,182
|
ncm_install_task_occupied_size.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_occupied_size.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/ncm/ncm_content_meta_key.hpp>
namespace ams::ncm {
struct InstallTaskOccupiedSize {
ContentMetaKey key;
s64 size;
StorageId storage_id;
u8 reserved[7];
};
static_assert(sizeof(InstallTaskOccupiedSize) == 0x20);
}
| 931
|
C++
|
.h
| 26
| 32.461538
| 76
| 0.735033
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,183
|
ncm_integrated_content_meta_database_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_integrated_content_meta_database_impl.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include <stratosphere/ncm/ncm_i_content_meta_database.hpp>
#include <stratosphere/ncm/ncm_integrated_list.hpp>
namespace ams::ncm {
class IntegratedContentMetaDatabaseImpl {
NON_COPYABLE(IntegratedContentMetaDatabaseImpl);
NON_MOVEABLE(IntegratedContentMetaDatabaseImpl);
private:
using ListType = ncm::IntegratedList<ncm::IContentMetaDatabase, 2>;
using DataType = ListType::ListData;
private:
os::SdkRecursiveMutex m_mutex;
ListType m_list;
bool m_disabled;
public:
IntegratedContentMetaDatabaseImpl() : m_mutex(), m_list(), m_disabled(false) { /* ... */ }
void Add(sf::SharedPointer<ncm::IContentMetaDatabase> p, u8 id) {
DataType data = {std::move(p), id};
m_list.Add(data);
}
private:
/* Helpers. */
Result EnsureEnabled() const {
R_UNLESS(!m_disabled, ncm::ResultInvalidContentMetaDatabase());
R_SUCCEED();
}
public:
/* Actual commands. */
Result Set(const ContentMetaKey &key, const sf::InBuffer &value);
Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value);
Result Remove(const ContentMetaKey &key);
Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type);
Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset);
Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type);
Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id);
Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type);
Result Has(sf::Out<bool> out, const ContentMetaKey &key);
Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys);
Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key);
Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key);
Result GetPatchContentMetaId(sf::Out<u64> out_patch_id, const ContentMetaKey &key);
Result DisableForcibly();
Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids);
Result Commit();
Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id);
Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset);
Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key);
Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key);
Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset);
Result GetCount(sf::Out<u32> out_count);
Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key);
Result GetContentAccessibilities(sf::Out<u8> out_accessibilities, const ContentMetaKey &key);
Result GetContentInfoByType(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type);
Result GetContentInfoByTypeAndIdOffset(sf::Out<ContentInfo> out_content_info, const ContentMetaKey &key, ContentType type, u8 id_offset);
Result GetPlatform(sf::Out<ncm::ContentMetaPlatform> out, const ContentMetaKey &key);
};
static_assert(ncm::IsIContentMetaDatabase<IntegratedContentMetaDatabaseImpl>);
}
| 4,770
|
C++
|
.h
| 74
| 55.108108
| 244
| 0.692882
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,184
|
ncm_integrated_content_storage_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_integrated_content_storage_impl.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include <stratosphere/ncm/ncm_i_content_storage.hpp>
#include <stratosphere/ncm/ncm_integrated_list.hpp>
namespace ams::ncm {
class IntegratedContentStorageImpl {
NON_COPYABLE(IntegratedContentStorageImpl);
NON_MOVEABLE(IntegratedContentStorageImpl);
private:
using ListType = ncm::IntegratedList<ncm::IContentStorage, 2>;
using DataType = ListType::ListData;
private:
os::SdkRecursiveMutex m_mutex;
ListType m_list;
bool m_disabled;
public:
IntegratedContentStorageImpl() : m_mutex(), m_list(), m_disabled(false) { /* ... */ }
void Add(sf::SharedPointer<ncm::IContentStorage> p, u8 id) {
DataType data = {std::move(p), id};
m_list.Add(data);
}
private:
/* Helpers. */
Result EnsureEnabled() const {
R_UNLESS(!m_disabled, ncm::ResultInvalidContentStorage());
R_SUCCEED();
}
public:
/* Actual commands. */
Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out);
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size);
Result DeletePlaceHolder(PlaceHolderId placeholder_id);
Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id);
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data);
Result Register(PlaceHolderId placeholder_id, ContentId content_id);
Result Delete(ContentId content_id);
Result Has(sf::Out<bool> out, ContentId content_id);
Result GetPath(sf::Out<Path> out, ContentId content_id);
Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id);
Result CleanupAllPlaceHolder();
Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf);
Result GetContentCount(sf::Out<s32> out_count);
Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 start_offset);
Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id);
Result DisableForcibly();
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id);
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size);
Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset);
Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id);
Result GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id);
Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr);
Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id);
Result GetRightsIdFromContentIdDeprecated2(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id);
Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id, fs::ContentAttributes attr);
Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data);
Result GetFreeSpaceSize(sf::Out<s64> out_size);
Result GetTotalSpaceSize(sf::Out<s64> out_size);
Result FlushPlaceHolder();
Result GetSizeFromPlaceHolderId(sf::Out<s64> out, PlaceHolderId placeholder_id);
Result RepairInvalidFileAttribute();
Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr);
Result RegisterPath(const ContentId &content_id, const Path &path);
Result ClearRegisteredPath();
Result GetProgramId(sf::Out<ncm::ProgramId> out, ContentId content_id, fs::ContentAttributes attr);
/* 16.0.0 Alignment change hacks. */
Result CreatePlaceHolder_AtmosphereAlignmentFix(ContentId content_id, PlaceHolderId placeholder_id, s64 size) { R_RETURN(this->CreatePlaceHolder(placeholder_id, content_id, size)); }
Result Register_AtmosphereAlignmentFix(ContentId content_id, PlaceHolderId placeholder_id) { R_RETURN(this->Register(placeholder_id, content_id)); }
Result RevertToPlaceHolder_AtmosphereAlignmentFix(ncm::ContentId old_content_id, ncm::ContentId new_content_id, ncm::PlaceHolderId placeholder_id) { R_RETURN(this->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id)); }
Result GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out<ncm::RightsId> out_rights_id, ContentId cache_content_id, PlaceHolderId placeholder_id) { R_RETURN(this->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id, fs::ContentAttributes_None)); }
};
static_assert(ncm::IsIContentStorage<IntegratedContentStorageImpl>);
}
| 5,906
|
C++
|
.h
| 87
| 57.977011
| 298
| 0.702614
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,185
|
ncm_content_info.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/fs/fs_content_attributes.hpp>
#include <stratosphere/ncm/ncm_content_id.hpp>
#include <stratosphere/ncm/ncm_content_type.hpp>
namespace ams::ncm {
struct ContentInfo {
static constexpr fs::ContentAttributes DefaultContentAttributes = fs::ContentAttributes_None;
ContentId content_id;
u32 size_low;
u8 size_high;
u8 content_attributes;
ContentType content_type;
u8 id_offset;
constexpr const ContentId &GetId() const {
return this->content_id;
}
constexpr u64 GetSize() const {
return (static_cast<u64>(this->size_high) << 32) | static_cast<u64>(this->size_low);
}
constexpr fs::ContentAttributes GetContentAttributes() const {
return static_cast<fs::ContentAttributes>(this->content_attributes & 0xF);
}
constexpr ContentType GetType() const {
return this->content_type;
}
constexpr u8 GetIdOffset() const {
return this->id_offset;
}
static constexpr ContentInfo Make(ContentId id, u64 size, fs::ContentAttributes attr, ContentType type, u8 id_ofs = 0) {
const u32 size_low = size & 0xFFFFFFFFu;
const u8 size_high = static_cast<u8>(size >> 32);
return {
.content_id = id,
.size_low = size_low,
.size_high = size_high,
.content_attributes = attr,
.content_type = type,
.id_offset = id_ofs,
};
}
};
static_assert(sizeof(util::is_pod<ContentInfo>::value));
static_assert(sizeof(ContentInfo) == 0x18);
}
| 2,398
|
C++
|
.h
| 59
| 32.915254
| 128
| 0.632302
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,186
|
ncm_install_task_base.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/ncm/ncm_install_task_data.hpp>
#include <stratosphere/ncm/ncm_install_task_occupied_size.hpp>
namespace ams::ncm {
enum class ListContentMetaKeyFilter : u8 {
All = 0,
Committed = 1,
NotCommitted = 2,
};
enum InstallConfig {
InstallConfig_None = (0 << 0),
InstallConfig_SystemUpdate = (1 << 2),
InstallConfig_RequiresExFatDriver = (1 << 3),
InstallConfig_IgnoreTicket = (1 << 4),
};
struct InstallThroughput {
s64 installed;
TimeSpan elapsed_time;
};
struct InstallContentMetaInfo {
ContentId content_id;
s64 content_size;
ContentMetaKey key;
bool verify_digest;
bool has_key;
Digest digest;
static constexpr InstallContentMetaInfo MakeVerifiable(const ContentId &cid, s64 sz, const ContentMetaKey &ky, const Digest &d) {
return {
.content_id = cid,
.content_size = sz,
.key = ky,
.verify_digest = true,
.has_key = true,
.digest = d,
};
}
static constexpr InstallContentMetaInfo MakeUnverifiable(const ContentId &cid, s64 sz, const ContentMetaKey &ky) {
return {
.content_id = cid,
.content_size = sz,
.key = ky,
.verify_digest = false,
.has_key = true,
};
}
static constexpr InstallContentMetaInfo MakeUnverifiable(const ContentId &cid, s64 sz) {
return {
.content_id = cid,
.content_size = sz,
.verify_digest = false,
.has_key = false,
};
}
};
static_assert(sizeof(InstallContentMetaInfo) == 0x50);
class InstallTaskBase {
NON_COPYABLE(InstallTaskBase);
NON_MOVEABLE(InstallTaskBase);
private:
crypto::Sha256Generator m_sha256_generator{};
StorageId m_install_storage{};
InstallTaskDataBase *m_data{};
InstallProgress m_progress{};
os::SdkMutex m_progress_mutex{};
u32 m_config{};
os::SdkMutex m_cancel_mutex{};
bool m_cancel_requested{};
InstallThroughput m_throughput{};
TimeSpan m_throughput_start_time{};
os::SdkMutex m_throughput_mutex{};
FirmwareVariationId m_firmware_variation_id{};
private:
ALWAYS_INLINE Result SetLastResultOnFailure(Result result) {
if (R_FAILED(result)) {
this->SetLastResult(result);
}
R_RETURN(result);
}
public:
InstallTaskBase() : m_data(), m_progress(), m_progress_mutex(), m_cancel_mutex(), m_cancel_requested(), m_throughput_mutex() { /* ... */ }
virtual ~InstallTaskBase() { /* ... */ };
public:
virtual void Cancel();
virtual void ResetCancel();
Result Prepare();
Result GetPreparedPlaceHolderPath(Path *out_path, u64 id, ContentMetaType meta_type, ContentType type);
Result CalculateRequiredSize(s64 *out_size);
Result Cleanup();
Result ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset, ListContentMetaKeyFilter filter);
Result ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset) { R_RETURN(this->ListContentMetaKey(out_keys_written, out_keys, out_keys_count, offset, ListContentMetaKeyFilter::All)); }
Result ListApplicationContentMetaKey(s32 *out_keys_written, ApplicationContentMetaKey *out_keys, s32 out_keys_count, s32 offset);
Result Execute();
Result PrepareAndExecute();
Result Commit(const StorageContentMetaKey *keys, s32 num_keys);
Result Commit() { R_RETURN(this->Commit(nullptr, 0)); }
virtual InstallProgress GetProgress();
void ResetLastResult();
Result IncludesExFatDriver(bool *out);
InstallThroughput GetThroughput();
Result CalculateContentsSize(s64 *out_size, const ContentMetaKey &key, StorageId storage_id);
Result ListOccupiedSize(s32 *out_written, InstallTaskOccupiedSize *out_list, s32 out_list_size, s32 offset);
Result FindMaxRequiredApplicationVersion(u32 *out);
Result FindMaxRequiredSystemVersion(u32 *out);
protected:
Result Initialize(StorageId install_storage, InstallTaskDataBase *data, u32 config);
Result PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional<ContentMetaKey> key, util::optional<u32> source_version);
Result PrepareContentMeta(ContentId content_id, s64 size, ContentMetaType meta_type, AutoBuffer *buffer);
Result WritePlaceHolderBuffer(InstallContentInfo *content_info, const void *data, size_t data_size);
void PrepareAgain();
Result CountInstallContentMetaData(s32 *out_count);
Result GetInstallContentMetaData(InstallContentMeta *out_content_meta, s32 index);
Result DeleteInstallContentMetaData(const ContentMetaKey *keys, s32 num_keys);
virtual Result GetInstallContentMetaInfo(InstallContentMetaInfo *out_info, const ContentMetaKey &key) = 0;
virtual Result PrepareDependency();
Result PrepareSystemUpdateDependency();
virtual Result PrepareContentMetaIfLatest(const ContentMetaKey &key); /* NOTE: This is not virtual in Nintendo's code. We do so to facilitate downgrades. */
u32 GetConfig() const { return m_config; }
Result WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional<bool> is_temporary);
StorageId GetInstallStorage() const { return m_install_storage; }
virtual Result OnPrepareComplete() { R_SUCCEED(); }
Result GetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo *out);
Result CanContinue();
private:
bool IsCancelRequested();
Result PrepareImpl();
Result ExecuteImpl();
Result CommitImpl(const StorageContentMetaKey *keys, s32 num_keys);
Result CleanupOne(const InstallContentMeta &content_meta);
Result VerifyAllNotCommitted(const StorageContentMetaKey *keys, s32 num_keys);
virtual Result PrepareInstallContentMetaData() = 0;
virtual Result GetLatestVersion(util::optional<u32> *out_version, u64 id) { AMS_UNUSED(out_version, id); R_THROW(ncm::ResultContentMetaNotFound()); }
virtual Result OnExecuteComplete() { R_SUCCEED(); }
Result WritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info);
virtual Result OnWritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) = 0;
bool IsNecessaryInstallTicket(const fs::RightsId &rights_id);
virtual Result InstallTicket(const fs::RightsId &rights_id, ContentMetaType meta_type) = 0;
Result IsNewerThanInstalled(bool *out, const ContentMetaKey &key);
Result PreparePlaceHolder();
void SetProgressState(InstallProgressState state);
void IncrementProgress(s64 size);
void SetTotalSize(s64 size);
void SetLastResult(Result last_result);
void CleanupProgress();
void ResetThroughputMeasurement();
void StartThroughputMeasurement();
void UpdateThroughputMeasurement(s64 throughput);
Result GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional<u32> source_version);
InstallContentInfo MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, util::optional<bool> is_temporary);
Result ReadContentMetaInfoList(s32 *out_count, std::unique_ptr<ContentMetaInfo[]> *out_meta_infos, const ContentMetaKey &key, fs::ContentAttributes attr);
Result ListRightsIdsByInstallContentMeta(s32 *out_count, Span<RightsId> out_span, const InstallContentMeta &content_meta, s32 offset);
public:
virtual Result CheckInstallable() { R_SUCCEED(); }
void SetFirmwareVariationId(FirmwareVariationId id) { m_firmware_variation_id = id; }
Result ListRightsIds(s32 *out_count, Span<RightsId> out_span, const ContentMetaKey &key, s32 offset);
};
}
| 9,565
|
C++
|
.h
| 171
| 44.818713
| 248
| 0.651143
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,187
|
ncm_i_content_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/ncm/ncm_i_content_storage.hpp>
#include <stratosphere/ncm/ncm_i_content_meta_database.hpp>
#include <stratosphere/ncm/ncm_memory_report.hpp>
#include <stratosphere/fs/fs_content_storage_id.hpp>
#define AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, CreateContentStorage, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CreateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, VerifyContentStorage, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, VerifyContentMetaDatabase, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, OpenContentStorage, (sf::Out<sf::SharedPointer<ncm::IContentStorage>> out, ncm::StorageId storage_id), (out, storage_id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, OpenContentMetaDatabase, (sf::Out<sf::SharedPointer<ncm::IContentMetaDatabase>> out, ncm::StorageId storage_id), (out, storage_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, CloseContentStorageForcibly, (ncm::StorageId storage_id), (storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, CloseContentMetaDatabaseForcibly, (ncm::StorageId storage_id), (storage_id), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, CleanupContentMetaDatabase, (ncm::StorageId storage_id), (storage_id)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, ActivateContentStorage, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, InactivateContentStorage, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, ActivateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 12, Result, InactivateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 13, Result, InvalidateRightsIdCache, (), (), hos::Version_9_0_0) \
AMS_SF_METHOD_INFO(C, H, 14, Result, GetMemoryReport, (sf::Out<ncm::MemoryReport> out), (out), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 15, Result, ActivateFsContentStorage, (fs::ContentStorageId fs_storage_id), (fs_storage_id)) /* Technically min 16.0.0, but used. */
AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentManager, AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO, 0xFDB4FFE1);
| 4,777
|
C++
|
.h
| 38
| 122.605263
| 223
| 0.475829
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,188
|
ncm_i_content_meta_database.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/sf.hpp>
#include <stratosphere/ncm/ncm_content_meta.hpp>
#define AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Set, (const ncm::ContentMetaKey &key, const sf::InBuffer &value), (key, value)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Get, (sf::Out<u64> out_size, const ncm::ContentMetaKey &key, const sf::OutBuffer &out_value), (out_size, key, out_value)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Remove, (const ncm::ContentMetaKey &key), (key)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetContentIdByType, (sf::Out<ncm::ContentId> out_content_id, const ncm::ContentMetaKey &key, ncm::ContentType type), (out_content_id, key, type)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, ListContentInfo, (sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ContentInfo> &out_info, const ncm::ContentMetaKey &key, s32 offset), (out_entries_written, out_info, key, offset)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, List, (sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ContentMetaKey> &out_info, ncm::ContentMetaType meta_type, ncm::ApplicationId application_id, u64 min, u64 max, ncm::ContentInstallType install_type), (out_entries_total, out_entries_written, out_info, meta_type, application_id, min, max, install_type)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetLatestContentMetaKey, (sf::Out<ncm::ContentMetaKey> out_key, u64 id), (out_key, id)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, ListApplication, (sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ApplicationContentMetaKey> &out_keys, ncm::ContentMetaType meta_type), (out_entries_total, out_entries_written, out_keys, meta_type)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Has, (sf::Out<bool> out, const ncm::ContentMetaKey &key), (out, key)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, HasAll, (sf::Out<bool> out, const sf::InArray<ncm::ContentMetaKey> &keys), (out, keys)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetSize, (sf::Out<u64> out_size, const ncm::ContentMetaKey &key), (out_size, key)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetRequiredSystemVersion, (sf::Out<u32> out_version, const ncm::ContentMetaKey &key), (out_version, key)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetPatchContentMetaId, (sf::Out<u64> out_patch_id, const ncm::ContentMetaKey &key), (out_patch_id, key)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, DisableForcibly, (), ()) \
AMS_SF_METHOD_INFO(C, H, 14, Result, LookupOrphanContent, (const sf::OutArray<bool> &out_orphaned, const sf::InArray<ncm::ContentId> &content_ids), (out_orphaned, content_ids)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, Commit, (), ()) \
AMS_SF_METHOD_INFO(C, H, 16, Result, HasContent, (sf::Out<bool> out, const ncm::ContentMetaKey &key, const ncm::ContentId &content_id), (out, key, content_id)) \
AMS_SF_METHOD_INFO(C, H, 17, Result, ListContentMetaInfo, (sf::Out<s32> out_entries_written, const sf::OutArray<ncm::ContentMetaInfo> &out_meta_info, const ncm::ContentMetaKey &key, s32 offset), (out_entries_written, out_meta_info, key, offset)) \
AMS_SF_METHOD_INFO(C, H, 18, Result, GetAttributes, (sf::Out<u8> out_attributes, const ncm::ContentMetaKey &key), (out_attributes, key)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, GetRequiredApplicationVersion, (sf::Out<u32> out_version, const ncm::ContentMetaKey &key), (out_version, key), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, GetContentIdByTypeAndIdOffset, (sf::Out<ncm::ContentId> out_content_id, const ncm::ContentMetaKey &key, ncm::ContentType type, u8 id_offset), (out_content_id, key, type, id_offset), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, GetCount, (sf::Out<u32> out_count), (out_count), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 22, Result, GetOwnerApplicationId, (sf::Out<ncm::ApplicationId> out_id, const ncm::ContentMetaKey &key), (out_id, key), hos::Version_10_0_0) \
AMS_SF_METHOD_INFO(C, H, 23, Result, GetContentAccessibilities, (sf::Out<u8> out_accessibilities, const ncm::ContentMetaKey &key), (out_accessibilities, key), hos::Version_15_0_0) \
AMS_SF_METHOD_INFO(C, H, 24, Result, GetContentInfoByType, (sf::Out<ncm::ContentInfo> out_content_info, const ncm::ContentMetaKey &key, ncm::ContentType type), (out_content_info, key, type), hos::Version_15_0_0) \
AMS_SF_METHOD_INFO(C, H, 25, Result, GetContentInfoByTypeAndIdOffset, (sf::Out<ncm::ContentInfo> out_content_info, const ncm::ContentMetaKey &key, ncm::ContentType type, u8 id_offset), (out_content_info, key, type, id_offset), hos::Version_15_0_0) \
AMS_SF_METHOD_INFO(C, H, 26, Result, GetPlatform, (sf::Out<ncm::ContentMetaPlatform> out, const ncm::ContentMetaKey &key), (out, key), hos::Version_17_0_0)
AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentMetaDatabase, AMS_NCM_I_CONTENT_META_DATABASE_INTERFACE_INFO, 0x58021FEC)
| 13,221
|
C++
|
.h
| 47
| 277.638298
| 441
| 0.298914
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,189
|
ncm_make_path.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_make_path.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/ncm/ncm_content_id.hpp>
#include <stratosphere/ncm/ncm_placeholder_id.hpp>
#include <stratosphere/ncm/ncm_path_string.hpp>
namespace ams::ncm {
using MakeContentPathFunction = void (*)(PathString *out, ContentId content_id, const char *root_path);
using MakePlaceHolderPathFunction = void (*)(PathString *out, PlaceHolderId placeholder_id,const char *root_path);
void MakeFlatContentFilePath(PathString *out, ContentId content_id, const char *root_path);
void MakeSha256HierarchicalContentFilePath_ForFat4KCluster(PathString *out, ContentId content_id, const char *root_path);
void MakeSha256HierarchicalContentFilePath_ForFat16KCluster(PathString *out, ContentId content_id, const char *root_path);
void MakeSha256HierarchicalContentFilePath_ForFat32KCluster(PathString *out, ContentId content_id, const char *root_path);
size_t GetHierarchicalContentDirectoryDepth(MakeContentPathFunction func);
void MakeFlatPlaceHolderFilePath(PathString *out, PlaceHolderId placeholder_id, const char *root_path);
void MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster(PathString *out, PlaceHolderId placeholder_id, const char *root_pathroot);
size_t GetHierarchicalPlaceHolderDirectoryDepth(MakePlaceHolderPathFunction func);
}
| 1,954
|
C++
|
.h
| 31
| 60.064516
| 142
| 0.794885
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,190
|
ncm_content_meta_type.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_type.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::ncm {
enum class ContentMetaType : u8 {
Unknown = 0x0,
SystemProgram = 0x1,
SystemData = 0x2,
SystemUpdate = 0x3,
BootImagePackage = 0x4,
BootImagePackageSafe = 0x5,
Application = 0x80,
Patch = 0x81,
AddOnContent = 0x82,
Delta = 0x83,
DataPatch = 0x84,
};
const char *GetContentMetaTypeString(ContentMetaType type);
}
| 1,241
|
C++
|
.h
| 33
| 33.030303
| 76
| 0.620432
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,191
|
ncm_ids.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_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 <stratosphere/ncm/ncm_data_id.hpp>
#include <stratosphere/ncm/ncm_program_id.hpp>
#include <stratosphere/ncm/ncm_content_meta_id.hpp>
#include <stratosphere/ncm/ncm_system_content_meta_id.hpp>
| 850
|
C++
|
.h
| 20
| 40.8
| 76
| 0.768675
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,192
|
ncm_content_meta_database.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/ncm/ncm_i_content_meta_database.hpp>
namespace ams::ncm {
class ContentMetaDatabase {
NON_COPYABLE(ContentMetaDatabase);
public:
struct ListCount {
s32 written;
s32 total;
};
private:
sf::SharedPointer<IContentMetaDatabase> m_interface;
public:
ContentMetaDatabase() : m_interface(nullptr) { /* ... */ }
explicit ContentMetaDatabase(sf::SharedPointer<IContentMetaDatabase> intf) : m_interface(intf) { /* ... */ }
ContentMetaDatabase(ContentMetaDatabase &&rhs) {
m_interface = std::move(rhs.m_interface);
}
ContentMetaDatabase &operator=(ContentMetaDatabase &&rhs) {
ContentMetaDatabase(std::move(rhs)).swap(*this);
return *this;
}
void swap(ContentMetaDatabase &rhs) {
std::swap(m_interface, rhs.m_interface);
}
public:
Result Set(const ContentMetaKey &key, const void *buf, size_t size) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Set(key, sf::InBuffer(buf, size)));
}
Result Get(size_t *out_size, void *dst, size_t dst_size, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
u64 size;
R_TRY(m_interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size)));
*out_size = size;
R_SUCCEED();
}
#define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \
Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \
R_RETURN(m_interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind)); \
} \
\
Result Get##Kind(ContentInfo *out, IdType##Id id, u32 version) { \
R_RETURN(m_interface->GetContentInfoByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind)); \
} \
\
Result GetLatest##Kind(ContentId *out, IdType##Id id) { \
ContentMetaKey latest_key; \
R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \
R_RETURN(m_interface->GetContentIdByType(out, latest_key, ContentType::Kind)); \
} \
\
Result GetLatest##Kind(ContentInfo *out, IdType##Id id) { \
ContentMetaKey latest_key; \
R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \
R_RETURN(m_interface->GetContentInfoByType(out, latest_key, ContentType::Kind)); \
}
AMS_NCM_DEFINE_GETTERS(Program, Program)
AMS_NCM_DEFINE_GETTERS(Data, Data)
AMS_NCM_DEFINE_GETTERS(Control, Application)
AMS_NCM_DEFINE_GETTERS(HtmlDocument, Application)
AMS_NCM_DEFINE_GETTERS(LegalInformation, Application)
#undef AMS_NCM_DEFINE_GETTERS
Result Remove(const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Remove(key));
}
Result Remove(SystemProgramId id, u32 version) {
R_RETURN(this->Remove(ContentMetaKey::Make(id, version)));
}
Result Remove(SystemDataId id, u32 version) {
R_RETURN(this->Remove(ContentMetaKey::Make(id, version)));
}
Result Remove(ApplicationId id, u32 version) {
R_RETURN(this->Remove(ContentMetaKey::Make(id, version)));
}
Result GetContentIdByType(ContentId *out_content_id, const ContentMetaKey &key, ContentType type) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetContentIdByType(out_content_id, key, type));
}
Result GetContentIdByTypeAndIdOffset(ContentId *out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset));
}
ListCount ListApplication(ApplicationContentMetaKey *dst, size_t dst_size) {
ListCount lc = {};
R_ABORT_UNLESS(m_interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ApplicationContentMetaKey>(dst, dst_size), ContentMetaType::Unknown));
return lc;
}
ListCount ListContentMeta(ContentMetaKey *dst, size_t dst_size, ContentMetaType type = ContentMetaType::Unknown, ApplicationId app_id = InvalidApplicationId, u64 min = std::numeric_limits<u64>::min(), u64 max = std::numeric_limits<u64>::max(), ContentInstallType install_type = ContentInstallType::Full) {
ListCount lc = {};
R_ABORT_UNLESS(m_interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ContentMetaKey>(dst, dst_size), type, app_id, min, max, install_type));
return lc;
}
Result GetLatest(ContentMetaKey *out_key, u64 id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetLatestContentMetaKey(out_key, id));
}
Result ListContentInfo(s32 *out_count, ContentInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->ListContentInfo(out_count, sf::OutArray<ContentInfo>(dst, dst_size), key, offset));
}
Result ListContentMetaInfo(s32 *out_count, ContentMetaInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->ListContentMetaInfo(out_count, sf::OutArray<ContentMetaInfo>(dst, dst_size), key, offset));
}
Result Has(bool *out, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Has(out, key));
}
Result HasAll(bool *out, const ContentMetaKey *keys, size_t num_keys) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->HasAll(out, sf::InArray<ContentMetaKey>(keys, num_keys)));
}
Result HasContent(bool *out, const ContentMetaKey &key, const ContentId &content_id) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->HasContent(out, key, content_id));
}
Result GetSize(size_t *out_size, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
u64 size;
R_TRY(m_interface->GetSize(std::addressof(size), key));
*out_size = size;
R_SUCCEED();
}
Result GetRequiredSystemVersion(u32 *out_version, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetRequiredSystemVersion(out_version, key));
}
Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
static_assert(sizeof(*out_patch_id) == sizeof(u64));
R_RETURN(m_interface->GetPatchContentMetaId(reinterpret_cast<u64 *>(out_patch_id), key));
}
Result GetDataPatchId(DataPatchId *out_patch_id, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
static_assert(sizeof(*out_patch_id) == sizeof(u64));
R_RETURN(m_interface->GetPatchContentMetaId(reinterpret_cast<u64 *>(out_patch_id), key));
}
Result DisableForcibly() {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->DisableForcibly());
}
Result LookupOrphanContent(bool *out_orphaned, ContentId *content_list, size_t count) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->LookupOrphanContent(sf::OutArray<bool>(out_orphaned, count), sf::InArray<ContentId>(content_list, count)));
}
Result Commit() {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->Commit());
}
Result GetAttributes(u8 *out_attributes, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetAttributes(out_attributes, key));
}
Result GetRequiredApplicationVersion(u32 *out_version, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetRequiredApplicationVersion(out_version, key));
}
Result GetContentAccessibilities(u8 *out_accessibilities, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetContentAccessibilities(out_accessibilities, key));
}
Result GetContentInfoByType(ContentInfo *out_content_info, const ContentMetaKey &key, ContentType type) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetContentInfoByType(out_content_info, key, type));
}
Result GetContentInfoByTypeAndIdOffset(ContentInfo *out_content_info, const ContentMetaKey &key, ContentType type, u8 id_offset) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetContentInfoByTypeAndIdOffset(out_content_info, key, type, id_offset));
}
Result GetPlatform(ContentMetaPlatform *out, const ContentMetaKey &key) {
AMS_ASSERT(m_interface != nullptr);
R_RETURN(m_interface->GetPlatform(out, key));
}
};
}
| 12,313
|
C++
|
.h
| 192
| 48.630208
| 317
| 0.528886
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,193
|
ncm_content_manager_config.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_config.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::ncm {
struct ContentManagerConfig {
bool build_system_database;
bool import_database_from_system_on_sd;
bool enable_integrated_system_content;
bool HasAnyConfig() const {
return this->ShouldBuildDatabase() || this->import_database_from_system_on_sd || this->enable_integrated_system_content;
}
bool ShouldBuildDatabase() const {
return hos::GetVersion() < hos::Version_4_0_0 || this->build_system_database;
}
bool ShouldImportDatabaseFromSignedSystemPartitionOnSd() const {
return this->import_database_from_system_on_sd;
}
bool IsIntegratedSystemContentEnabled() const {
return this->enable_integrated_system_content;
}
};
}
| 1,463
|
C++
|
.h
| 36
| 35.055556
| 132
| 0.703521
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,194
|
ncm_max_count.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_max_count.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::ncm {
constexpr inline s32 SystemMaxContentMetaCount = 0x800;
constexpr inline s32 GameCardMaxContentMetaCount = 0x800;
constexpr inline s32 HostMaxContentMetaCount = 0x800;
constexpr inline s32 UserMaxContentMetaCount = 0x2000;
constexpr inline s32 SdCardMaxContentMetaCount = 0x2000;
}
| 1,009
|
C++
|
.h
| 24
| 39.5
| 76
| 0.764766
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,195
|
ncm_rights_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_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/fs/fs_rights_id.hpp>
namespace ams::ncm {
struct RightsId {
fs::RightsId id;
u8 key_generation;
u8 reserved[7];
};
static_assert(sizeof(RightsId) == 0x18);
static_assert(util::is_pod<RightsId>::value);
inline bool operator==(const RightsId &lhs, const RightsId &rhs) {
return std::tie(lhs.id, lhs.key_generation) == std::tie(rhs.id, rhs.key_generation);
}
inline bool operator!=(const RightsId &lhs, const RightsId &rhs) {
return !(lhs == rhs);
}
inline bool operator<(const RightsId &lhs, const RightsId &rhs) {
return std::tie(lhs.id, lhs.key_generation) < std::tie(rhs.id, rhs.key_generation);
}
}
| 1,388
|
C++
|
.h
| 36
| 34.583333
| 92
| 0.700074
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,196
|
ncm_system_update_task_apply_info.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_update_task_apply_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::ncm {
enum class SystemUpdateTaskApplyInfo : u8 {
Unknown = 0,
RequireReboot = 1,
RequireNoReboot = 2,
};
}
| 848
|
C++
|
.h
| 24
| 32.291667
| 76
| 0.712546
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,197
|
ncm_content_manager_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/os.hpp>
#include <stratosphere/fs/fs_mount.hpp>
#include <stratosphere/fs/fs_bis.hpp>
#include <stratosphere/fs/fs_content_storage.hpp>
#include <stratosphere/fs/fs_system_save_data.hpp>
#include <stratosphere/ncm/ncm_i_content_manager.hpp>
#include <stratosphere/ncm/ncm_content_manager_config.hpp>
#include <stratosphere/ncm/ncm_content_meta_database.hpp>
#include <stratosphere/ncm/ncm_bounded_map.hpp>
#include <stratosphere/ncm/ncm_rights_id_cache.hpp>
#include <stratosphere/ncm/ncm_content_management_utils.hpp>
#include <stratosphere/ncm/ncm_content_meta_utils.hpp>
#include <stratosphere/ncm/ncm_registered_host_content.hpp>
#include <stratosphere/ncm/ncm_integrated_content_meta_database_impl.hpp>
#include <stratosphere/ncm/ncm_integrated_content_storage_impl.hpp>
#include <stratosphere/kvdb/kvdb_memory_key_value_store.hpp>
namespace ams::ncm {
class ContentMetaMemoryResource : public MemoryResource {
private:
mem::StandardAllocator m_allocator;
size_t m_peak_total_alloc_size;
size_t m_peak_alloc_size;
public:
explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : m_allocator(heap, heap_size), m_peak_total_alloc_size(0), m_peak_alloc_size(0) { /* ... */ }
mem::StandardAllocator *GetAllocator() { return std::addressof(m_allocator); }
size_t GetPeakTotalAllocationSize() const { return m_peak_total_alloc_size; }
size_t GetPeakAllocationSize() const { return m_peak_alloc_size; }
private:
virtual void *AllocateImpl(size_t size, size_t alignment) override {
void *mem = m_allocator.Allocate(size, alignment);
m_peak_total_alloc_size = std::max(m_allocator.Hash().allocated_size, m_peak_total_alloc_size);
m_peak_alloc_size = std::max(size, m_peak_alloc_size);
return mem;
}
virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override {
AMS_UNUSED(size, alignment);
return m_allocator.Free(buffer);
}
virtual bool IsEqualImpl(const MemoryResource &resource) const override {
return this == std::addressof(resource);
}
};
struct SystemSaveDataInfo {
u64 id;
u64 size;
u64 journal_size;
u32 flags;
fs::SaveDataSpaceId space_id;
};
static_assert(util::is_pod<SystemSaveDataInfo>::value);
struct IntegratedContentStorageImpl;
class ContentManagerImpl {
private:
constexpr static size_t MaxContentStorageRoots = 8;
constexpr static size_t MaxIntegratedContentStorageRoots = 8;
constexpr static size_t MaxContentMetaDatabaseRoots = 8;
constexpr static size_t MaxIntegratedContentMetaDatabaseRoots = 8;
constexpr static size_t MaxConfigs = 8;
constexpr static size_t MaxIntegratedConfigs = 8;
private:
struct ContentStorageConfig {
fs::ContentStorageId content_storage_id;
bool skip_verify_and_create;
bool skip_activate;
};
struct IntegratedContentStorageConfig {
ncm::StorageId storage_id;
fs::ContentStorageId content_storage_ids[MaxContentStorageRoots];
int num_content_storage_ids;
bool is_integrated;
};
private:
struct ContentStorageRoot {
NON_COPYABLE(ContentStorageRoot);
NON_MOVEABLE(ContentStorageRoot);
char mount_name[fs::MountNameLengthMax + 1];
char path[128];
StorageId storage_id;
util::optional<ContentStorageConfig> config;
sf::SharedPointer<IContentStorage> content_storage;
ContentStorageRoot() : mount_name(), path(), storage_id(), config(util::nullopt), content_storage() { /* ... */ }
};
struct IntegratedContentStorageRoot {
NON_COPYABLE(IntegratedContentStorageRoot);
NON_MOVEABLE(IntegratedContentStorageRoot);
const IntegratedContentStorageConfig *m_config;
ContentStorageRoot *m_roots;
int m_num_roots;
sf::EmplacedRef<IContentStorage, IntegratedContentStorageImpl> m_integrated_content_storage;
IntegratedContentStorageRoot() : m_config(), m_roots(), m_num_roots(), m_integrated_content_storage() { /* ... */ }
Result Create();
Result Verify();
Result Open(sf::Out<sf::SharedPointer<IContentStorage>> out, RightsIdCache &rights_id_cache, RegisteredHostContent ®istered_host_content);
Result Activate(RightsIdCache &rights_id_cache, RegisteredHostContent ®istered_host_content);
Result Inactivate(RegisteredHostContent ®istered_host_content);
Result Activate(ContentStorageRoot &root, RightsIdCache &rights_id_cache, RegisteredHostContent ®istered_host_content);
Result Activate(RightsIdCache &rights_id_cache, RegisteredHostContent ®istered_host_content, fs::ContentStorageId content_storage_id);
ContentStorageRoot *GetRoot(fs::ContentStorageId storage_id) {
for (auto i = 0; i < m_num_roots; ++i) {
if (auto &root = m_roots[i]; root.config.has_value() && root.config->content_storage_id == storage_id) {
return std::addressof(root);
}
}
return nullptr;
}
};
struct ContentMetaDatabaseRoot {
NON_COPYABLE(ContentMetaDatabaseRoot);
NON_MOVEABLE(ContentMetaDatabaseRoot);
char mount_name[fs::MountNameLengthMax + 1];
char path[128];
StorageId storage_id;
util::optional<ContentStorageConfig> storage_config;
util::optional<SystemSaveDataInfo> save_data_info;
util::optional<kvdb::MemoryKeyValueStore<ContentMetaKey>> kvs;
sf::SharedPointer<IContentMetaDatabase> content_meta_database;
ContentMetaMemoryResource *memory_resource;
u32 max_content_metas;
ContentMetaDatabaseRoot() : mount_name(), path(), storage_id(), storage_config(util::nullopt), save_data_info(util::nullopt), kvs(util::nullopt), content_meta_database(), memory_resource(), max_content_metas() { /* ... */ }
};
struct IntegratedContentMetaDatabaseRoot {
NON_COPYABLE(IntegratedContentMetaDatabaseRoot);
NON_MOVEABLE(IntegratedContentMetaDatabaseRoot);
const IntegratedContentStorageConfig *m_config;
ContentMetaDatabaseRoot *m_roots;
int m_num_roots;
sf::EmplacedRef<IContentMetaDatabase, IntegratedContentMetaDatabaseImpl> m_integrated_content_meta_database;
IntegratedContentMetaDatabaseRoot() : m_config(), m_roots(), m_num_roots(), m_integrated_content_meta_database() { /* ... */ }
Result Create();
Result Verify();
Result Open(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out);
Result Cleanup();
Result Activate();
Result Inactivate();
Result Activate(ContentMetaDatabaseRoot &root);
Result Activate(fs::ContentStorageId content_storage_id);
ContentMetaDatabaseRoot *GetRoot(fs::ContentStorageId storage_id) {
for (auto i = 0; i < m_num_roots; ++i) {
if (auto &root = m_roots[i]; root.storage_config.has_value() && root.storage_config->content_storage_id == storage_id) {
return std::addressof(root);
}
}
return nullptr;
}
};
private:
os::SdkRecursiveMutex m_mutex{};
bool m_initialized{false};
IntegratedContentStorageRoot m_integrated_content_storage_roots[MaxIntegratedContentStorageRoots]{};
ContentStorageRoot m_content_storage_roots[MaxContentStorageRoots]{};
IntegratedContentMetaDatabaseRoot m_integrated_content_meta_database_roots[MaxIntegratedContentMetaDatabaseRoots]{};
ContentMetaDatabaseRoot m_content_meta_database_roots[MaxContentMetaDatabaseRoots]{};
IntegratedContentStorageConfig m_integrated_configs[MaxIntegratedConfigs]{};
ContentStorageConfig m_configs[MaxConfigs]{};
u32 m_num_integrated_content_storage_entries{0};
u32 m_num_content_storage_entries{0};
u32 m_num_integrated_content_meta_entries{0};
u32 m_num_content_meta_entries{0};
u32 m_num_integrated_configs{0};
u32 m_num_configs{0};
RightsIdCache m_rights_id_cache{};
RegisteredHostContent m_registered_host_content{};
public:
ContentManagerImpl() = default;
~ContentManagerImpl();
public:
Result Initialize(const ContentManagerConfig &config);
private:
Result Initialize(const ContentManagerConfig &manager_config, const IntegratedContentStorageConfig *integrated_configs, size_t num_integrated_configs, const ContentStorageConfig *configs, size_t num_configs, const ncm::StorageId *activated_storages, size_t num_activated_storages);
Result InitializeStorageBuiltInSystem(const ContentManagerConfig &manager_config);
Result InitializeStorage(ncm::StorageId storage_id);
const ContentStorageConfig &GetContentStorageConfig(fs::ContentStorageId content_storage_id) {
for (size_t i = 0; i < m_num_configs; ++i) {
if (m_configs[i].content_storage_id == content_storage_id) {
return m_configs[i];
}
}
/* NOTE: Nintendo accesses out of bounds memory here. Should we explicitly abort? This is guaranteed by data to never happen. */
AMS_ASSUME(false);
}
private:
/* Helpers. */
Result GetIntegratedContentStorageConfig(IntegratedContentStorageConfig **out, fs::ContentStorageId content_storage_id);
Result GetIntegratedContentStorageRoot(IntegratedContentStorageRoot **out, StorageId id);
Result GetIntegratedContentMetaDatabaseRoot(IntegratedContentMetaDatabaseRoot **out, StorageId id);
Result InitializeContentStorageRoot(ContentStorageRoot *out, StorageId storage_id, util::optional<ContentStorageConfig> config);
Result InitializeContentMetaDatabaseRoot(ContentMetaDatabaseRoot *out, StorageId storage_id, util::optional<ContentStorageConfig> storage_config);
Result InitializeIntegratedContentStorageRoot(IntegratedContentStorageRoot *out, const IntegratedContentStorageConfig *config, size_t root_idx, size_t root_count);
Result InitializeIntegratedContentMetaDatabaseRoot(IntegratedContentMetaDatabaseRoot *out, const IntegratedContentStorageConfig *config, size_t root_idx, size_t root_count);
Result BuildContentMetaDatabase(StorageId storage_id);
Result BuildContentMetaDatabaseImpl(StorageId storage_id);
Result ImportContentMetaDatabase(StorageId storage_id, bool from_signed_partition);
Result ImportContentMetaDatabaseImpl(ContentMetaDatabaseRoot *root, const char *import_mount_name);
private:
/* Helpers for unofficial functionality. */
bool IsNeedRebuildSystemContentMetaDatabase();
public:
/* Actual commands. */
Result CreateContentStorage(StorageId storage_id);
Result CreateContentMetaDatabase(StorageId storage_id);
Result VerifyContentStorage(StorageId storage_id);
Result VerifyContentMetaDatabase(StorageId storage_id);
Result OpenContentStorage(sf::Out<sf::SharedPointer<IContentStorage>> out, StorageId storage_id);
Result OpenContentMetaDatabase(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out, StorageId storage_id);
Result CloseContentStorageForcibly(StorageId storage_id);
Result CloseContentMetaDatabaseForcibly(StorageId storage_id);
Result CleanupContentMetaDatabase(StorageId storage_id);
Result ActivateContentStorage(StorageId storage_id);
Result InactivateContentStorage(StorageId storage_id);
Result ActivateContentMetaDatabase(StorageId storage_id);
Result InactivateContentMetaDatabase(StorageId storage_id);
Result InvalidateRightsIdCache();
Result GetMemoryReport(sf::Out<MemoryReport> out);
Result ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id);
};
static_assert(IsIContentManager<ContentManagerImpl>);
}
| 13,985
|
C++
|
.h
| 233
| 47.287554
| 293
| 0.654783
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,198
|
ncm_registered_host_content.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_registered_host_content.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/ncm/ncm_content_id.hpp>
#include <stratosphere/ncm/ncm_path.hpp>
namespace ams::ncm {
class RegisteredHostContent {
NON_COPYABLE(RegisteredHostContent);
NON_MOVEABLE(RegisteredHostContent);
private:
class RegisteredPath;
private:
using RegisteredPathList = ams::util::IntrusiveListBaseTraits<RegisteredPath>::ListType;
private:
os::SdkMutex m_mutex;
RegisteredPathList m_path_list;
public:
RegisteredHostContent() : m_mutex(), m_path_list() { /* ... */ }
~RegisteredHostContent();
Result RegisterPath(const ncm::ContentId &content_id, const ncm::Path &path);
Result GetPath(Path *out, const ncm::ContentId &content_id);
void ClearPaths();
};
}
| 1,514
|
C++
|
.h
| 38
| 34.052632
| 100
| 0.691576
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,199
|
ncm_content_meta_extended_data.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/ncm/ncm_content_info.hpp>
#include <stratosphere/ncm/ncm_content_meta_id.hpp>
#include <stratosphere/ncm/ncm_content_meta.hpp>
#include <stratosphere/ncm/ncm_firmware_variation.hpp>
#include <stratosphere/ncm/ncm_mapped_memory.hpp>
namespace ams::ncm {
enum class UpdateType : u8 {
ApplyAsDelta = 0,
Overwrite = 1,
Create = 2,
};
struct FragmentIndicator {
u16 content_info_index;
u16 fragment_index;
};
struct FragmentSet {
ContentId source_content_id;
ContentId destination_content_id;
u32 source_size_low;
u16 source_size_high;
u16 destination_size_high;
u32 destination_size_low;
u16 fragment_count;
ContentType target_content_type;
UpdateType update_type;
u8 reserved[4];
constexpr s64 GetSourceSize() const {
return (static_cast<s64>(this->source_size_high) << 32) + this->source_size_low;
}
constexpr s64 GetDestinationSize() const {
return (static_cast<s64>(this->destination_size_high) << 32) + this->destination_size_low;
}
constexpr void SetSourceSize(s64 size) {
this->source_size_low = size & 0xFFFFFFFFll;
this->source_size_high = static_cast<u16>(size >> 32);
}
constexpr void SetDestinationSize(s64 size) {
this->destination_size_low = size & 0xFFFFFFFFll;
this->destination_size_high = static_cast<u16>(size >> 32);
}
};
struct SystemUpdateMetaExtendedDataHeader {
u32 version;
u32 firmware_variation_count;
};
struct DeltaMetaExtendedDataHeader {
PatchId source_id;
PatchId destination_id;
u32 source_version;
u32 destination_version;
u16 fragment_set_count;
u8 reserved[6];
};
struct PatchMetaExtendedDataHeader {
u32 history_count;
u32 delta_history_count;
u32 delta_count;
u32 fragment_set_count;
u32 history_content_total_count;
u32 delta_content_total_count;
u8 reserved[4];
};
struct PatchHistoryHeader {
ContentMetaKey key;
Digest digest;
u16 content_count;
u8 reserved[2];
};
struct PatchDeltaHistory {
PatchId source_id;
PatchId destination_id;
u32 source_version;
u32 destination_version;
u64 download_size;
u8 reserved[4];
};
struct PatchDeltaHeader {
DeltaMetaExtendedDataHeader delta;
u16 content_count;
u8 reserved[4];
};
template<typename MemberTypePointer, typename DataTypePointer>
class PatchMetaExtendedDataReaderWriterBase {
private:
MemberTypePointer m_data;
const size_t m_size;
public:
PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : m_data(d), m_size(sz) { /* ... */ }
protected:
s32 CountFragmentSet(s32 delta_index) const {
auto delta_header = this->GetPatchDeltaHeader(0);
s32 count = 0;
for (s32 i = 0; i < delta_index; i++) {
count += delta_header[i].delta.fragment_set_count;
}
return count;
}
s32 CountHistoryContent(s32 history_index) const {
auto history_header = this->GetPatchHistoryHeader(0);
s32 count = 0;
for (s32 i = 0; i < history_index; i++) {
count += history_header[i].content_count;
}
return count;
}
s32 CountDeltaContent(s32 delta_index) const {
auto delta_header = this->GetPatchDeltaHeader(0);
s32 count = 0;
for (s32 i = 0; i < delta_index; i++) {
count += delta_header[i].content_count;
}
return count;
}
s32 CountFragment(s32 index) const {
auto fragment_set = this->GetFragmentSet(0, 0);
s32 count = 0;
for (s32 i = 0; i < index; i++) {
count += fragment_set[i].fragment_count;
}
return count;
}
DataTypePointer GetHeaderAddress() const {
return reinterpret_cast<DataTypePointer>(m_data);
}
DataTypePointer GetPatchHistoryHeaderAddress(s32 index) const {
auto header = this->GetHeader();
AMS_ABORT_UNLESS(static_cast<u16>(index) < header->history_count);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * index;
}
DataTypePointer GetPatchDeltaHistoryAddress(s32 index) const {
auto header = this->GetHeader();
AMS_ABORT_UNLESS(static_cast<u16>(index) < header->delta_history_count);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * header->history_count
+ sizeof(PatchDeltaHistory) * index;
}
DataTypePointer GetPatchDeltaHeaderAddress(s32 index) const {
auto header = this->GetHeader();
AMS_ABORT_UNLESS(static_cast<u16>(index) < header->delta_count);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * header->history_count
+ sizeof(PatchDeltaHistory) * header->delta_history_count
+ sizeof(PatchDeltaHeader) * index;
}
DataTypePointer GetFragmentSetAddress(s32 delta_index, s32 fragment_set_index) const {
auto header = this->GetHeader();
AMS_ABORT_UNLESS(static_cast<u16>(delta_index) < header->delta_count);
auto delta_header = this->GetPatchDeltaHeader(delta_index);
AMS_ABORT_UNLESS(static_cast<u16>(fragment_set_index) < delta_header->delta.fragment_set_count);
auto previous_fragment_set_count = this->CountFragmentSet(delta_index);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * header->history_count
+ sizeof(PatchDeltaHistory) * header->delta_history_count
+ sizeof(PatchDeltaHeader) * header->delta_count
+ sizeof(FragmentSet) * (previous_fragment_set_count + fragment_set_index);
}
DataTypePointer GetPatchHistoryContentInfoAddress(s32 history_index, s32 content_index) const {
auto header = this->GetHeader();
auto history_header = this->GetPatchHistoryHeader(history_index);
AMS_ABORT_UNLESS(static_cast<u16>(content_index) < history_header->content_count);
auto prev_history_count = this->CountHistoryContent(history_index);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * header->history_count
+ sizeof(PatchDeltaHistory) * header->delta_history_count
+ sizeof(PatchDeltaHeader) * header->delta_count
+ sizeof(FragmentSet) * header->fragment_set_count
+ sizeof(ContentInfo) * (prev_history_count + content_index);
}
DataTypePointer GetPatchDeltaPackagedContentInfoAddress(s32 delta_index, s32 content_index) const {
auto header = this->GetHeader();
auto delta_header = this->GetPatchDeltaHeader(delta_index);
AMS_ABORT_UNLESS(static_cast<u16>(content_index) < delta_header->content_count);
auto content_count = this->CountDeltaContent(delta_index);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * header->history_count
+ sizeof(PatchDeltaHistory) * header->delta_history_count
+ sizeof(PatchDeltaHeader) * header->delta_count
+ sizeof(FragmentSet) * header->fragment_set_count
+ sizeof(ContentInfo) * header->history_content_total_count
+ sizeof(PackagedContentInfo) * (content_count + content_index);
}
DataTypePointer GetFragmentIndicatorAddress(s32 delta_index, s32 fragment_set_index, s32 index) const {
auto header = this->GetHeader();
auto fragment_set = this->GetFragmentSet(delta_index, fragment_set_index);
AMS_ABORT_UNLESS(static_cast<u16>(index) < fragment_set->fragment_count);
auto fragment_set_count = this->CountFragmentSet(delta_index);
auto fragment_count = this->CountFragment(fragment_set_count + fragment_set_index);
return this->GetHeaderAddress()
+ sizeof(PatchMetaExtendedDataHeader)
+ sizeof(PatchHistoryHeader) * header->history_count
+ sizeof(PatchDeltaHistory) * header->delta_history_count
+ sizeof(PatchDeltaHeader) * header->delta_count
+ sizeof(FragmentSet) * header->fragment_set_count
+ sizeof(ContentInfo) * header->history_content_total_count
+ sizeof(PackagedContentInfo) * header->delta_content_total_count
+ sizeof(FragmentIndicator) * (fragment_count + index);
}
public:
const PatchMetaExtendedDataHeader *GetHeader() const {
return reinterpret_cast<const PatchMetaExtendedDataHeader *>(this->GetHeaderAddress());
}
const PatchHistoryHeader *GetPatchHistoryHeader(s32 index) const {
return reinterpret_cast<const PatchHistoryHeader *>(this->GetPatchHistoryHeaderAddress(index));
}
const PatchDeltaHistory *GetPatchDeltaHistory(s32 index) const {
return reinterpret_cast<const PatchDeltaHistory *>(this->GetPatchDeltaHistoryAddress(index));
}
const ContentInfo *GetPatchHistoryContentInfo(s32 history_index, s32 content_index) const {
return reinterpret_cast<const ContentInfo *>(this->GetPatchHistoryContentInfoAddress(history_index, content_index));
}
const PatchDeltaHeader *GetPatchDeltaHeader(s32 index) const {
return reinterpret_cast<const PatchDeltaHeader *>(this->GetPatchDeltaHeaderAddress(index));
}
const PackagedContentInfo *GetPatchDeltaPackagedContentInfo(s32 delta_index, s32 content_index) const {
return reinterpret_cast<const PackagedContentInfo *>(this->GetPatchDeltaPackagedContentInfoAddress(delta_index, content_index));
}
const FragmentSet *GetFragmentSet(s32 delta_index, s32 fragment_set_index) const {
return reinterpret_cast<const FragmentSet *>(this->GetFragmentSetIndex(delta_index, fragment_set_index));
}
const FragmentIndicator *GetFragmentIndicator(s32 delta_index, s32 fragment_set_index, s32 index) const {
return reinterpret_cast<const FragmentIndicator *>(this->GetFragmentIndicatorAddress(delta_index, fragment_set_index, index));
}
const FragmentIndicator *FindFragmentIndicator(s32 delta_index, s32 fragment_set_index, s32 fragment_index) const {
auto fragment_set = this->GetFragmentSet(delta_index, fragment_set_index);
auto fragment = this->GetFragmentIndicator(delta_index, fragment_set_index, 0);
for (s32 i = 0; i < fragment_set->fragment_count; i++) {
if (fragment[i].fragment_index == fragment_index) {
return std::addressof(fragment[i]);
}
}
return nullptr;
}
};
class PatchMetaExtendedDataReader : public PatchMetaExtendedDataReaderWriterBase<const void *, const u8 *> {
public:
PatchMetaExtendedDataReader(const void *data, size_t size) : PatchMetaExtendedDataReaderWriterBase(data, size) { /* ... */ }
};
class SystemUpdateMetaExtendedDataReaderWriterBase {
private:
void *m_data;
const size_t m_size;
bool m_is_header_valid;
protected:
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : m_data(const_cast<void *>(d)), m_size(sz), m_is_header_valid(true) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ }
uintptr_t GetHeaderAddress() const {
return reinterpret_cast<uintptr_t>(m_data);
}
uintptr_t GetFirmwareVariationIdStartAddress() const {
return this->GetHeaderAddress() + sizeof(SystemUpdateMetaExtendedDataHeader);
}
uintptr_t GetFirmwareVariationIdAddress(size_t i) const {
return this->GetFirmwareVariationIdStartAddress() + i * sizeof(FirmwareVariationId);
}
uintptr_t GetFirmwareVariationInfoStartAddress() const {
return this->GetFirmwareVariationIdAddress(this->GetFirmwareVariationCount());
}
uintptr_t GetFirmwareVariationInfoAddress(size_t i) const {
return this->GetFirmwareVariationInfoStartAddress() + i * sizeof(FirmwareVariationInfo);
}
uintptr_t GetContentMetaInfoStartAddress() const {
return this->GetFirmwareVariationInfoAddress(this->GetFirmwareVariationCount());
}
uintptr_t GetContentMetaInfoAddress(size_t i) const {
return this->GetContentMetaInfoStartAddress() + i * sizeof(ContentMetaInfo);
}
public:
const SystemUpdateMetaExtendedDataHeader *GetHeader() const {
AMS_ABORT_UNLESS(m_is_header_valid);
return reinterpret_cast<const SystemUpdateMetaExtendedDataHeader *>(this->GetHeaderAddress());
}
size_t GetFirmwareVariationCount() const {
return this->GetHeader()->firmware_variation_count;
}
const FirmwareVariationId *GetFirmwareVariationId(size_t i) const {
AMS_ABORT_UNLESS(i < this->GetFirmwareVariationCount());
return reinterpret_cast<FirmwareVariationId *>(this->GetFirmwareVariationIdAddress(i));
}
const FirmwareVariationInfo *GetFirmwareVariationInfo(size_t i) const {
AMS_ABORT_UNLESS(i < this->GetFirmwareVariationCount());
return reinterpret_cast<FirmwareVariationInfo *>(this->GetFirmwareVariationInfoAddress(i));
}
void GetContentMetaInfoList(Span<const ContentMetaInfo> *out_list, size_t i) const {
size_t preceding_content_meta_count = 0;
/* Count the number of preceding content metas. */
for (size_t j = 0; j < i; j++) {
preceding_content_meta_count += this->GetFirmwareVariationInfo(j)->content_meta_count;
}
/* Output the list. */
*out_list = Span<const ContentMetaInfo>(reinterpret_cast<const ContentMetaInfo *>(this->GetContentMetaInfoAddress(preceding_content_meta_count)), this->GetFirmwareVariationInfo(i)->content_meta_count);
}
};
class SystemUpdateMetaExtendedDataReader : public SystemUpdateMetaExtendedDataReaderWriterBase {
public:
constexpr SystemUpdateMetaExtendedDataReader(const void *data, size_t size) : SystemUpdateMetaExtendedDataReaderWriterBase(data, size) { /* ... */ }
};
template<typename T>
class ReadableStructPin;
class AccessorBase {
public:
template<typename T>
class PinBase {
private:
AccessorBase *m_accessor;
u64 m_pin_id;
T *m_data;
size_t m_size;
public:
PinBase() : m_accessor(nullptr), m_data(nullptr), m_size(0) {
/* ... */
}
PinBase(const PinBase &) = delete;
PinBase &operator=(const PinBase &) = delete;
PinBase(PinBase &&rhs) : m_accessor(rhs.m_accessor), m_pin_id(rhs.m_pin_id), m_data(rhs.m_data), m_size(rhs.m_size) {
rhs.m_accessor = nullptr;
}
PinBase &operator=(PinBase &&rhs) {
m_accessor = rhs.m_accessor;
m_pin_id = rhs.m_pin_id;
m_data = rhs.m_data;
m_size = rhs.m_size;
rhs.m_accessor = nullptr;
return *this;
}
virtual ~PinBase() {
this->Reset();
}
public:
void Reset() {
if (m_accessor != nullptr) {
m_accessor->ReleasePin(m_pin_id);
m_accessor = nullptr;
}
}
void Reset(AccessorBase *accessor, u64 pin_id, void *data, size_t size) {
AMS_ASSERT(data != nullptr || size == 0);
this->Reset();
m_accessor = accessor;
m_pin_id = pin_id;
m_data = reinterpret_cast<T *>(data);
m_size = size;
}
T *GetData() const {
return m_data;
}
size_t GetDataSize() const {
return m_size;
}
};
private:
IMapper *m_mapper;
public:
AccessorBase(IMapper *mapper) : m_mapper(mapper) {
/* ... */
}
template<typename T>
Result AcquireReadableStructPin(ReadableStructPin<T> *out, size_t offset) {
/* Acquire mapped memory for the pin. */
MappedMemory memory = {};
R_TRY(m_mapper->GetMappedMemory(std::addressof(memory), offset, sizeof(T)));
/* Mark the memory as in use. */
R_RETURN(m_mapper->MarkUsing(memory.id));
/* Setup the pin. */
out->Reset(this, memory.id, memory.GetBuffer(offset, sizeof(T)), sizeof(T));
R_SUCCEED();
}
Result ReleasePin(u64 id) {
R_RETURN(m_mapper->UnmarkUsing(id));
}
template<typename T>
Result ReadStruct(T *out, size_t offset) {
/* Acquire mapped memory for the pin. */
MappedMemory memory = {};
R_TRY(m_mapper->GetMappedMemory(std::addressof(memory), offset, sizeof(T)));
/* Mark the memory as in use. */
R_RETURN(m_mapper->MarkUsing(memory.id));
ON_SCOPE_EXIT { this->ReleasePin(memory.id); };
/* Copy out the struct. */
*out = *reinterpret_cast<const T *>(memory.GetBuffer(offset, sizeof(T)));
R_SUCCEED();
}
};
template<typename T>
class ReadableStructPin final : public AccessorBase::PinBase<const u8> {
public:
using PinBase::PinBase;
using PinBase::operator=;
const T *Get() const {
return reinterpret_cast<const T *>(this->GetData());
}
size_t GetSize() const {
return this->GetDataSize();
}
const T &operator*() const { return *this->Get(); }
const T *operator->() const { return this->Get(); }
};
class PatchMetaExtendedDataAccessor : public AccessorBase {
private:
struct CachedCount {
s32 index;
s32 count;
};
private:
util::optional<CachedCount> m_cached_history_content_count = util::nullopt;
util::optional<CachedCount> m_cached_delta_content_count = util::nullopt;
util::optional<CachedCount> m_cached_fragment_set_count = util::nullopt;
util::optional<CachedCount> m_cached_fragment_indicator_count = util::nullopt;
util::optional<PatchMetaExtendedDataHeader> m_header = util::nullopt;
public:
using AccessorBase::AccessorBase;
public:
Result GetHeader(ReadableStructPin<PatchMetaExtendedDataHeader> *out) { R_RETURN(this->AcquireReadableStructPin(out, 0)); }
Result GetHeader(PatchMetaExtendedDataHeader *out) { R_RETURN(this->template ReadStruct<PatchMetaExtendedDataHeader>(out, 0)); }
Result GetHistoryHeader(ReadableStructPin<PatchHistoryHeader> *out, s32 index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= index && static_cast<u32>(index) < m_header->history_count, ncm::ResultInvalidOffset());
/* Get the header. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * index;
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetPatchDeltaHistory(ReadableStructPin<PatchDeltaHistory> *out, s32 index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= index && static_cast<u32>(index) < m_header->delta_history_count, ncm::ResultInvalidOffset());
/* Get the history. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * index;
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetPatchDeltaHeader(ReadableStructPin<PatchDeltaHeader> *out, s32 index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= index && static_cast<u32>(index) < m_header->delta_count, ncm::ResultInvalidOffset());
/* Get the header. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * index;
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetFragmentSet(ReadableStructPin<FragmentSet> *out, s32 delta_index, s32 fragment_set_index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= delta_index && static_cast<u32>(delta_index) < m_header->delta_count, ncm::ResultInvalidOffset());
/* Get the previous fragment set count. */
s32 previous_fragment_set_count = 0;
R_TRY(this->CountFragmentSet(std::addressof(previous_fragment_set_count), delta_index));
/* Get the set. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * m_header->delta_count + sizeof(FragmentSet) * (previous_fragment_set_count + fragment_set_index);
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetFragmentSetDirectly(ReadableStructPin<FragmentSet> *out, s32 fragment_set_direct_index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= fragment_set_direct_index && static_cast<u32>(fragment_set_direct_index) < m_header->fragment_set_count, ncm::ResultInvalidOffset());
/* Get the set. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * m_header->delta_count + sizeof(FragmentSet) * (fragment_set_direct_index);
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetPatchHistoryContentInfo(ReadableStructPin<ContentInfo> *out, s32 history_index, s32 content_index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= history_index && static_cast<u32>(history_index) < m_header->history_count, ncm::ResultInvalidOffset());
/* Determine the true history content index. */
s32 prev_history_count = 0;
R_TRY(this->CountHistoryContentInfo(std::addressof(prev_history_count), history_index));
/* Adjust and check the content index. */
content_index += prev_history_count;
R_UNLESS(0 <= content_index && static_cast<u32>(content_index) < m_header->history_content_total_count, ncm::ResultInvalidOffset());
/* Get the info. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * m_header->delta_count + sizeof(FragmentSet) * m_header->fragment_set_count + sizeof(ContentInfo) * content_index;
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetPatchDeltaContentInfo(ReadableStructPin<PackagedContentInfo> *out, s32 delta_index, s32 content_index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= delta_index && static_cast<u32>(delta_index) < m_header->delta_count, ncm::ResultInvalidOffset());
/* Determine the true delta content index. */
s32 prev_delta_count = 0;
R_TRY(this->CountDeltaContentInfo(std::addressof(prev_delta_count), delta_index));
/* Adjust and check the content index. */
content_index += prev_delta_count;
R_UNLESS(0 <= content_index && static_cast<u32>(content_index) < m_header->delta_content_total_count, ncm::ResultInvalidOffset());
/* Get the info. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * m_header->delta_count + sizeof(FragmentSet) * m_header->fragment_set_count + sizeof(ContentInfo) * m_header->history_content_total_count + sizeof(PackagedContentInfo) * content_index;
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result GetFragmentIndicator(ReadableStructPin<FragmentIndicator> *out, s32 delta_index, s32 fragment_set_index, s32 index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= delta_index && static_cast<u32>(delta_index) < m_header->delta_count, ncm::ResultInvalidOffset());
/* Get the previous fragment set count. */
s32 previous_fragment_set_count = 0;
R_TRY(this->CountFragmentSet(std::addressof(previous_fragment_set_count), delta_index));
/* Get the previous fragment indicator count. */
s32 previous_fragment_count = 0;
R_TRY(this->CountFragmentIndicator(std::addressof(previous_fragment_count), previous_fragment_count + fragment_set_index));
/* Get the info. */
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * m_header->delta_count + sizeof(FragmentSet) * m_header->fragment_set_count + sizeof(ContentInfo) * m_header->history_content_total_count + sizeof(PackagedContentInfo) * m_header->delta_content_total_count + sizeof(FragmentIndicator) * (previous_fragment_count + index);
R_RETURN(this->AcquireReadableStructPin(out, offset));
}
Result FindFragmentIndicator(ReadableStructPin<FragmentIndicator> *out, s32 delta_index, s32 fragment_set_index, s32 fragment_index) {
/* Ensure we have our header. */
R_TRY(this->EnsureHeader());
/* Check that the index is valid. */
R_UNLESS(0 <= delta_index && static_cast<u32>(delta_index) < m_header->delta_count, ncm::ResultInvalidOffset());
/* Get the fragment count. */
s32 fragment_count = 0;
{
ReadableStructPin<FragmentSet> set;
R_TRY(this->GetFragmentSet(std::addressof(set), delta_index, fragment_set_index));
fragment_count = set->fragment_count;
}
/* Get the previous fragment set count. */
s32 previous_fragment_set_count = 0;
R_TRY(this->CountFragmentSet(std::addressof(previous_fragment_set_count), delta_index));
/* Get the previous fragment indicator count. */
s32 previous_fragment_count = 0;
R_TRY(this->CountFragmentIndicator(std::addressof(previous_fragment_count), previous_fragment_count + fragment_set_index));
/* Look for a correct indicator. */
for (auto i = 0; i < fragment_count; ++i) {
/* Get the current info. */
ReadableStructPin<FragmentIndicator> indicator;
const size_t offset = sizeof(PatchHistoryHeader) + sizeof(PatchHistoryHeader) * m_header->history_count + sizeof(PatchDeltaHistory) * m_header->delta_history_count + sizeof(PatchDeltaHeader) * m_header->delta_count + sizeof(FragmentSet) * m_header->fragment_set_count + sizeof(ContentInfo) * m_header->history_content_total_count + sizeof(PackagedContentInfo) * m_header->delta_content_total_count + sizeof(FragmentIndicator) * (previous_fragment_count + i);
R_TRY(this->AcquireReadableStructPin(std::addressof(indicator), offset));
/* If it matches, return it. */
if (indicator->fragment_index == fragment_index) {
*out = std::move(indicator);
R_SUCCEED();
}
}
/* We didn't find an indicator. */
R_THROW(ncm::ResultFragmentIndicatorNotFound());
}
Result GetHistoryHeader(PatchHistoryHeader *out, s32 index) {
/* Get the pin. */
ReadableStructPin<PatchHistoryHeader> pin;
R_TRY(this->GetHistoryHeader(std::addressof(pin), index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result GetPatchDeltaHistory(PatchDeltaHistory *out, s32 index) {
/* Get the pin. */
ReadableStructPin<PatchDeltaHistory> pin;
R_TRY(this->GetPatchDeltaHistory(std::addressof(pin), index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result GetPatchDeltaHeader(PatchDeltaHeader *out, s32 index) {
/* Get the pin. */
ReadableStructPin<PatchDeltaHeader> pin;
R_TRY(this->GetPatchDeltaHeader(std::addressof(pin), index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result GetFragmentSet(FragmentSet *out, s32 delta_index, s32 fragment_set_index) {
/* Get the pin. */
ReadableStructPin<FragmentSet> pin;
R_TRY(this->GetFragmentSet(std::addressof(pin), delta_index, fragment_set_index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result GetPatchHistoryContentInfo(ContentInfo *out, s32 history_index, s32 content_index) {
/* Get the header. */
ReadableStructPin<ContentInfo> pin;
R_TRY(this->GetPatchHistoryContentInfo(std::addressof(pin), history_index, content_index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result GetPatchDeltaContentInfo(PackagedContentInfo *out, s32 delta_index, s32 content_index) {
/* Get the header. */
ReadableStructPin<PackagedContentInfo> pin;
R_TRY(this->GetPatchDeltaContentInfo(std::addressof(pin), delta_index, content_index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result GetFragmentIndicator(FragmentIndicator *out, s32 delta_index, s32 fragment_set_index, s32 index) {
/* Get the header. */
ReadableStructPin<FragmentIndicator> pin;
R_TRY(this->GetFragmentIndicator(std::addressof(pin), delta_index, fragment_set_index, index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result FindFragmentIndicator(FragmentIndicator *out, s32 delta_index, s32 fragment_set_index, s32 fragment_index) {
/* Get the header. */
ReadableStructPin<FragmentIndicator> pin;
R_TRY(this->FindFragmentIndicator(std::addressof(pin), delta_index, fragment_set_index, fragment_index));
/* Copy it out. */
*out = *pin;
R_SUCCEED();
}
Result CountHistoryContentInfo(s32 *out, s32 index) {
R_RETURN(this->CountImpl(out, index, m_cached_history_content_count, [&](s32 *out, s32 i) -> Result {
/* Get the history header. */
ReadableStructPin<ncm::PatchHistoryHeader> header;
R_TRY(this->GetHistoryHeader(std::addressof(header), i));
/* Set the content count. */
*out = header->content_count;
R_SUCCEED();
}));
}
Result CountDeltaContentInfo(s32 *out, s32 index) {
R_RETURN(this->CountImpl(out, index, m_cached_delta_content_count, [&](s32 *out, s32 i) -> Result {
/* Get the history header. */
ReadableStructPin<ncm::PatchDeltaHeader> header;
R_TRY(this->GetPatchDeltaHeader(std::addressof(header), i));
/* Set the content count. */
*out = header->content_count;
R_SUCCEED();
}));
}
Result CountFragmentSet(s32 *out, s32 index) {
R_RETURN(this->CountImpl(out, index, m_cached_fragment_set_count, [&](s32 *out, s32 i) -> Result {
/* Get the history header. */
ReadableStructPin<ncm::PatchDeltaHeader> header;
R_TRY(this->GetPatchDeltaHeader(std::addressof(header), i));
/* Set the fragment set count. */
*out = header->delta.fragment_set_count;
R_SUCCEED();
}));
}
Result CountFragmentIndicator(s32 *out, s32 index) {
R_RETURN(this->CountImpl(out, index, m_cached_fragment_indicator_count, [&](s32 *out, s32 i) -> Result {
/* Get the history header. */
ReadableStructPin<ncm::FragmentSet> set;
R_TRY(this->GetFragmentSetDirectly(std::addressof(set), i));
/* Set the indicator count. */
*out = set->fragment_count;
R_SUCCEED();
}));
}
private:
Result CountImpl(s32 *out, s32 index, util::optional<CachedCount> &cache, auto get_count_impl) const {
/* Ensure the value is cached. */
if (!(cache.has_value() && cache->index == index)) {
/* Determine the count. */
CachedCount calc = { .index = index, .count = 0 };
for (auto i = 0; i < index; ++i) {
s32 cur_count = 0;
R_TRY(get_count_impl(std::addressof(cur_count), i));
calc.count += cur_count;
}
/* Cache the count. */
cache = calc;
}
/* Set the output count. */
*out = cache->count;
R_SUCCEED();
}
private:
Result EnsureHeader() {
/* If we have our header, we're good. */
R_SUCCEED_IF(m_header.has_value());
/* Get our header. */
PatchMetaExtendedDataHeader header{};
R_TRY(this->GetHeader(std::addressof(header)));
/* Set our header. */
m_header.emplace(header);
R_SUCCEED();
}
};
}
| 39,554
|
C++
|
.h
| 697
| 41.299857
| 478
| 0.571491
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,200
|
ncm_content_info_utils.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info_utils.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/ncm/ncm_content_meta_key.hpp>
namespace ams::ncm {
constexpr inline s64 MaxClusterSize = 256_KB;
s64 CalculateRequiredSize(s64 file_size, s64 cluster_size = MaxClusterSize);
s64 CalculateRequiredSizeForExtension(s64 file_size, s64 cluster_size = MaxClusterSize);
class ContentMetaDatabase;
Result EstimateRequiredSize(s64 *out_size, const ContentMetaKey &key, ContentMetaDatabase *db);
}
| 1,108
|
C++
|
.h
| 25
| 41.72
| 99
| 0.771588
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,201
|
ncm_program_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_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::ncm {
struct ProgramId {
u64 value;
#if defined(ATMOSPHERE_OS_HORIZON)
inline explicit operator svc::ProgramId() const {
static_assert(sizeof(value) == sizeof(svc::ProgramId));
return { this->value };
}
#endif
constexpr inline auto operator<=>(const ProgramId &) const = default;
};
inline constexpr const ProgramId InvalidProgramId = {};
}
| 1,117
|
C++
|
.h
| 30
| 32.766667
| 77
| 0.703053
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,202
|
ncm_content_type.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_type.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::ncm {
enum class ContentType : u8 {
Meta = 0,
Program = 1,
Data = 2,
Control = 3,
HtmlDocument = 4,
LegalInformation = 5,
DeltaFragment = 6,
};
}
| 969
|
C++
|
.h
| 28
| 30.714286
| 76
| 0.642857
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,203
|
gc.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gc/gc.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/gc/impl/gc_types.hpp>
namespace ams::gc {
struct GameCardIdSet {
gc::impl::CardId1 id1;
gc::impl::CardId2 id2;
gc::impl::CardId3 id3;
};
static_assert(util::is_pod<GameCardIdSet>::value);
static_assert(sizeof(GameCardIdSet) == 0xC);
}
| 972
|
C++
|
.h
| 27
| 32.888889
| 76
| 0.727176
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,204
|
gc_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gc/impl/gc_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::gc::impl {
struct CardInitialDataPayload {
u8 package_id[8];
u8 reserved_8[8];
u8 auth_data[0x10];
u8 auth_mac[0x10];
u8 auth_nonce[0xC];
};
static_assert(util::is_pod<CardInitialDataPayload>::value);
static_assert(sizeof(CardInitialDataPayload) == 0x3C);
struct CardInitialData {
CardInitialDataPayload payload;
u8 padding[0x200 - sizeof(CardInitialDataPayload)];
};
static_assert(util::is_pod<CardInitialData>::value);
static_assert(sizeof(CardInitialData) == 0x200);
enum FwVersion : u8 {
FwVersion_ForDev = 0,
FwVersion_1_0_0 = 1,
FwVersion_4_0_0 = 2,
FwVersion_9_0_0 = 3,
FwVersion_11_0_0 = 4,
FwVersion_12_0_0 = 5,
};
enum KekIndex : u8 {
KekIndex_Version0 = 0,
KekIndex_VersionForDev = 1,
};
struct CardHeaderKeyIndex {
using KekIndex = util::BitPack8::Field<0, 4, gc::impl::KekIndex>;
using TitleKeyDecIndex = util::BitPack8::Field<KekIndex::Next, 4, u8>;
static_assert(TitleKeyDecIndex::Next == BITSIZEOF(u8));
};
struct CardHeaderEncryptedData {
u32 fw_version[2];
u32 acc_ctrl_1;
u32 wait_1_time_read;
u32 wait_2_time_read;
u32 wait_1_time_write;
u32 wait_2_time_write;
u32 fw_mode;
u32 cup_version;
u8 compatibility_type;
u8 reserved_25;
u8 reserved_26;
u8 reserved_27;
u8 upp_hash[8];
u64 cup_id;
u8 reserved_38[0x38];
};
static_assert(util::is_pod<CardHeaderEncryptedData>::value);
static_assert(sizeof(CardHeaderEncryptedData) == 0x70);
enum MakerCodeForCardId1 : u8 {
MakerCodeForCardId1_MegaChips = 0xC2,
MakerCodeForCardId1_Lapis = 0xAE,
};
enum MemoryCapacity : u8 {
MemoryCapacity_1GB = 0xFA,
MemoryCapacity_2GB = 0xF8,
MemoryCapacity_4GB = 0xF0,
MemoryCapacity_8GB = 0xE0,
MemoryCapacity_16GB = 0xE1,
MemoryCapacity_32GB = 0xE2,
};
enum MemoryType : u8 {
MemoryType_T1RomFast = 0x01,
MemoryType_T2RomFast = 0x02,
MemoryType_T1NandFast = 0x09,
MemoryType_T2NandFast = 0x0A,
MemoryType_T1RomLate = 0x21,
MemoryType_T2RomLate = 0x22,
MemoryType_T1NandLate = 0x29,
MemoryType_T2NandLate = 0x2A,
};
enum CardSecurityNumber : u8 {
CardSecurityNumber_0 = 0x00,
CardSecurityNumber_1 = 0x01,
CardSecurityNumber_2 = 0x02,
CardSecurityNumber_3 = 0x03,
CardSecurityNumber_4 = 0x04,
};
enum CardType : u8 {
CardType_Rom = 0x00,
CardType_Writable_Dev_T1 = 0x01,
CardType_Writable_Prod_T1 = 0x02,
CardType_Writable_Dev_T2 = 0x03,
CardType_Writable_Prod_T2 = 0x04,
};
enum AccessControl1ClockRate : u32 {
AccessControl1ClockRate_25MHz = 0x00A10011,
AccessControl1ClockRate_50MHz = 0x00A10010,
};
enum SelSec : u8 {
SelSec_T1 = 1,
SelSec_T2 = 2,
};
struct CardId1 {
MakerCodeForCardId1 maker_code;
MemoryCapacity memory_capacity;
u8 reserved;
MemoryType memory_type;
};
struct CardId2 {
CardSecurityNumber card_security_number;
CardType card_type;
u8 reserved[2];
};
struct CardId3 {
u8 reserved[4];
};
struct CardHeader {
static constexpr u32 Magic = util::FourCC<'H','E','A','D'>::Code;
u32 magic;
u32 rom_area_start_page;
u32 backup_area_start_page;
util::BitPack8 key_index;
u8 rom_size;
u8 version;
u8 flags;
u8 package_id[8];
u32 valid_data_end_page;
u8 reserved_11C[4];
u8 iv[crypto::Aes128CbcDecryptor::IvSize];
u64 partition_fs_header_address;
u64 partition_fs_header_size;
u8 partition_fs_header_hash[crypto::Sha256Generator::HashSize];
u8 initial_data_hash[crypto::Sha256Generator::HashSize];
u32 sel_sec;
u32 sel_t1_key;
u32 sel_key;
u32 lim_area_page;
union {
u8 raw_encrypted_data[sizeof(CardHeaderEncryptedData)];
CardHeaderEncryptedData encrypted_data;
};
};
static_assert(util::is_pod<CardHeader>::value);
static_assert(sizeof(CardHeader) == 0x100);
struct CardHeaderWithSignature {
u8 signature[crypto::Rsa2048Pkcs1Sha256Verifier::SignatureSize];
CardHeader data;
};
static_assert(util::is_pod<CardHeaderWithSignature>::value);
static_assert(sizeof(CardHeaderWithSignature) == 0x200);
static constexpr size_t CardDeviceIdLength = 0x10;
struct T1CardCertificate {
static constexpr u32 Magic = util::FourCC<'C','E','R','T'>::Code;
u8 signature[crypto::Rsa2048Pkcs1Sha256Verifier::SignatureSize];
u32 magic;
u32 version;
u8 kek_index;
u8 flags[7];
u8 t1_card_device_id[CardDeviceIdLength];
u8 iv[crypto::Aes128CtrEncryptor::IvSize];
u8 hw_key[crypto::Aes128CtrEncryptor::KeySize];
u8 reserved[0xC0];
u8 padding[0x200];
};
static_assert(util::is_pod<T1CardCertificate>::value);
static_assert(sizeof(T1CardCertificate) == 0x400);
struct Ca10Certificate {
u8 signature[crypto::Rsa2048Pkcs1Sha256Verifier::SignatureSize];
u8 unk_100[0x30];
u8 modulus[crypto::Rsa2048Pkcs1Sha256Verifier::ModulusSize];
u8 unk_230[0x1D0];
};
static_assert(util::is_pod<Ca10Certificate>::value);
static_assert(sizeof(Ca10Certificate) == 0x400);
}
| 6,423
|
C++
|
.h
| 186
| 27.268817
| 81
| 0.639936
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,205
|
gc_embedded_data_holder.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gc/impl/gc_embedded_data_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/gc/impl/gc_gc_crypto.hpp>
namespace ams::gc::impl {
class EmbeddedDataHolder {
NON_COPYABLE(EmbeddedDataHolder);
NON_MOVEABLE(EmbeddedDataHolder);
friend class GcCrypto;
private:
struct ConcatenatedGcLibraryEmbeddedKeys {
u8 enc_hmac_key_for_cv[GcCrypto::GcHmacKeyLength];
u8 enc_hmac_key_for_key_and_iv[GcCrypto::GcHmacKeyLength];
u8 enc_cv_constant_value[GcCrypto::GcCvConstLength];
u8 enc_rsa_oaep_label_hash[GcCrypto::GcSha256HashLength];
};
static_assert(util::is_pod<ConcatenatedGcLibraryEmbeddedKeys>::value);
static_assert(sizeof(ConcatenatedGcLibraryEmbeddedKeys) == 0x70);
private:
static bool s_is_dev;
static const void *s_ca_public_exponent;
static const void *s_ca1_modulus;
static const void *s_ca9_modulus;
static const void *s_ca10_modulus;
static const void *s_ca10_certificate_modulus;
static const void *s_card_header_key;
private:
static constinit inline u8 s_titlekey_keks[GcCrypto::GcTitleKeyKekIndexMax][GcCrypto::GcAesKeyLength] = {};
public:
static Result SetLibraryEmbeddedKeys(bool is_dev = GcCrypto::CheckDevelopmentSpl());
static void SetLibraryTitleKeyKek(size_t kek_index, const void *kek, size_t kek_size) {
AMS_ASSERT(kek_index < GcCrypto::GcTitleKeyKekIndexMax);
AMS_ASSERT(kek_size == GcCrypto::GcAesKeyLength);
AMS_UNUSED(kek_size);
std::memcpy(s_titlekey_keks[kek_index], kek, sizeof(s_titlekey_keks[kek_index]));
}
private:
static Result DecryptoEmbeddedKeys(ConcatenatedGcLibraryEmbeddedKeys *out, size_t out_size, bool is_dev = GcCrypto::CheckDevelopmentSpl());
};
}
| 2,599
|
C++
|
.h
| 54
| 39.518519
| 151
| 0.673228
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,206
|
gc_gc_crypto.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gc/impl/gc_gc_crypto.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/gc/impl/gc_types.hpp>
namespace ams::gc::impl {
class GcCrypto {
NON_COPYABLE(GcCrypto);
NON_MOVEABLE(GcCrypto);
public:
static constexpr size_t GcRsaKeyLength = crypto::Rsa2048PssSha256Verifier::ModulusSize;
static constexpr size_t GcRsaPublicExponentLength = 3;
static constexpr size_t GcAesKeyLength = crypto::AesEncryptor128::KeySize;
static constexpr size_t GcAesCbcIvLength = crypto::Aes128CbcEncryptor::IvSize;
static constexpr size_t GcHmacKeyLength = 0x20;
static constexpr size_t GcCvConstLength = 0x10;
static constexpr size_t GcTitleKeyKekIndexMax = 0x10;
static constexpr size_t GcSha256HashLength = crypto::Sha256Generator::HashSize;
public:
static bool CheckDevelopmentSpl();
static Result DecryptAesKeySpl(void *dst, size_t dst_size, const void *src, size_t src_size, s32 generation, u32 option);
static Result VerifyCardHeader(const void *header_buffer, size_t header_size, const void *modulus, size_t modulus_size);
static Result EncryptCardHeader(void *header, size_t header_size);
static Result DecryptCardHeader(void *header, size_t header_size);
static Result VerifyT1CardCertificate(const void *cert_buffer, size_t cert_size);
static Result VerifyCa10Certificate(const void *cert_buffer, size_t cert_size);
static Result DecryptCardInitialData(void *dst, size_t dst_size, const void *initial_data, size_t data_size, size_t kek_index);
};
}
| 2,359
|
C++
|
.h
| 42
| 49.119048
| 139
| 0.696405
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,207
|
rocrt.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/rocrt/rocrt.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::rocrt {
constexpr inline const u32 ModuleHeaderVersion = util::FourCC<'M','O','D','0'>::Code;
struct ModuleHeader {
u32 signature;
u32 dynamic_offset;
u32 bss_start_offset;
u32 bss_end_offset;
u32 exception_info_start_offset;
u32 exception_info_end_offset;
u32 module_offset;
};
struct ModuleHeaderLocation {
u32 pad;
u32 header_offset;
};
constexpr inline u32 CheckModuleHeaderSignature(const ModuleHeader *header) {
if (header->signature == ModuleHeaderVersion) {
return header->signature;
} else {
return 0;
}
}
inline ModuleHeader *GetModuleHeader(const ModuleHeaderLocation *loc) {
return reinterpret_cast<ModuleHeader *>(reinterpret_cast<uintptr_t>(loc) + loc->header_offset);
}
inline uintptr_t GetDynamicOffset(const ModuleHeader *header, const ModuleHeaderLocation *loc) {
return reinterpret_cast<uintptr_t>(loc) + loc->header_offset + header->dynamic_offset;
}
inline uintptr_t GetBssStartAddress(const ModuleHeader *header, const ModuleHeaderLocation *loc) {
return reinterpret_cast<uintptr_t>(loc) + loc->header_offset + header->bss_start_offset;
}
inline uintptr_t GetBssEndAddress(const ModuleHeader *header, const ModuleHeaderLocation *loc) {
return reinterpret_cast<uintptr_t>(loc) + loc->header_offset + header->bss_end_offset;
}
inline uintptr_t GetModuleOffset(const ModuleHeader *header, const ModuleHeaderLocation *loc) {
return reinterpret_cast<uintptr_t>(loc) + loc->header_offset + header->module_offset;
}
}
| 2,360
|
C++
|
.h
| 55
| 37.272727
| 103
| 0.708115
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,208
|
diag_log_observer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_log_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/diag/diag_log_types.hpp>
namespace ams::diag {
using LogObserver = void (*)(const LogMetaData &meta, const LogBody &body, void *arg);
struct LogObserverHolder {
LogObserver log_observer;
LogObserverHolder *next;
bool is_registered;
void *arg;
};
constexpr inline void InitializeLogObserverHolder(LogObserverHolder *holder, LogObserver observer, void *arg) {
holder->log_observer = observer;
holder->next = nullptr;
holder->is_registered = false;
holder->arg = arg;
}
void RegisterLogObserver(LogObserverHolder *holder);
void UnregisterLogObserver(LogObserverHolder *holder);
}
| 1,389
|
C++
|
.h
| 35
| 35.485714
| 115
| 0.718101
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,209
|
diag_abort_observer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_abort_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/diag/diag_log_types.hpp>
namespace ams::diag {
using AbortObserver = void (*)(const AbortInfo &);
struct AbortObserverHolder {
AbortObserver observer;
AbortObserverHolder *next;
bool is_registered;
};
void InitializeAbortObserverHolder(AbortObserverHolder *holder, AbortObserver observer);
void RegisterAbortObserver(AbortObserverHolder *holder);
void UnregisterAbortObserver(AbortObserverHolder *holder);
void EnableDefaultAbortObserver(bool en);
struct SdkAbortInfo {
AbortInfo abort_info;
Result result;
const ::ams::os::UserExceptionInfo *exc_info;
};
using SdkAbortObserver = void (*)(const SdkAbortInfo &);
struct SdkAbortObserverHolder {
SdkAbortObserver observer;
SdkAbortObserverHolder *next;
bool is_registered;
};
void InitializeSdkAbortObserverHolder(SdkAbortObserverHolder *holder, SdkAbortObserver observer);
void RegisterSdkAbortObserver(SdkAbortObserverHolder *holder);
void UnregisterSdkAbortObserver(SdkAbortObserverHolder *holder);
}
| 1,790
|
C++
|
.h
| 44
| 36.113636
| 101
| 0.75389
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,210
|
diag_sdk_log.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_sdk_log.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/diag/impl/diag_impl_structured_log.hpp>
#if defined(AMS_IMPL_ENABLE_SDK_LOG)
#define AMS_SDK_LOG(...) AMS_IMPL_STRUCTURED_LOG_IMPL("$", ::ams::diag::LogSeverity_Info, 0, __VA_ARGS__)
#define AMS_SDK_VLOG(_FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL("$", ::ams::diag::LogSeverity_Info, 0, _FMT_, _VL_)
#define AMS_SDK_PUT(_MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL("$", ::ams::diag::LogSeverity_Info, 0, _MSG_, _ML_)
#else
#define AMS_SDK_LOG(...) do { /* ... */ } while (false)
#define AMS_SDK_VLOG(_FMT_, _VL_) do { /* ... */ } while (false)
#define AMS_SDK_PUT(_MSG_, _ML_) do { /* ... */ } while (false)
#endif
| 1,329
|
C++
|
.h
| 27
| 47.555556
| 115
| 0.68567
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,211
|
diag_log_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_log_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::diag {
enum LogSeverity {
LogSeverity_Trace = 0,
LogSeverity_Info = 1,
LogSeverity_Warn = 2,
LogSeverity_Error = 3,
LogSeverity_Fatal = 4,
};
struct SourceInfo {
int line_number;
const char *file_name;
const char *function_name;
};
struct LogMetaData {
SourceInfo source_info;
const char *module_name;
LogSeverity severity;
int verbosity;
bool use_default_locale_charset;
void *additional_data;
size_t additional_data_size;
};
struct LogBody {
const char *message;
size_t message_size;
bool is_head;
bool is_tail;
};
struct LogMessage {
const char *fmt;
std::va_list *vl;
};
}
| 1,480
|
C++
|
.h
| 50
| 24.02
| 76
| 0.657765
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,212
|
diag_symbol.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_symbol.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::diag {
uintptr_t GetSymbolName(char *dst, size_t dst_size, uintptr_t address);
size_t GetSymbolSize(uintptr_t address);
}
| 818
|
C++
|
.h
| 21
| 36.809524
| 76
| 0.754717
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,213
|
diag_backtrace.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_backtrace.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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>
#if defined(ATMOSPHERE_OS_HORIZON)
#include <stratosphere/diag/impl/diag_backtrace_impl.os.horizon.hpp>
#elif defined(ATMOSPHERE_OS_WINDOWS)
#include <stratosphere/diag/impl/diag_backtrace_impl.os.windows.hpp>
#elif defined(ATMOSPHERE_OS_LINUX)
#include <stratosphere/diag/impl/diag_backtrace_impl.os.linux.hpp>
#elif defined(ATMOSPHERE_OS_MACOS)
#include <stratosphere/diag/impl/diag_backtrace_impl.os.macos.hpp>
#else
#error "Unknown OS for diag::Backtrace"
#endif
namespace ams::diag {
size_t GetBacktrace(uintptr_t *out, size_t out_size);
#if defined(ATMOSPHERE_OS_HORIZON)
size_t GetBacktace(uintptr_t *out, size_t out_size, uintptr_t fp, uintptr_t sp, uintptr_t pc);
#endif
class Backtrace {
private:
impl::Backtrace m_impl;
public:
NOINLINE Backtrace() {
m_impl.Initialize();
m_impl.Step();
}
#if defined(ATMOSPHERE_OS_HORIZON)
Backtrace(uintptr_t fp, uintptr_t sp, uintptr_t pc) {
m_impl.Initialize(fp, sp, pc);
}
#endif
bool Step() { return m_impl.Step(); }
uintptr_t GetStackPointer() const { return m_impl.GetStackPointer(); }
uintptr_t GetReturnAddress() const { return m_impl.GetReturnAddress(); }
};
}
| 2,025
|
C++
|
.h
| 51
| 33.784314
| 98
| 0.681425
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,214
|
diag_assertion_failure_handler.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_assertion_failure_handler.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/diag/diag_log_types.hpp>
namespace ams::diag {
enum AssertionFailureOperation {
AssertionFailureOperation_Abort,
AssertionFailureOperation_Continue,
};
using AssertionFailureHandler = AssertionFailureOperation (*)(const AssertionInfo &info);
void SetAssertionFailureHandler(AssertionFailureHandler handler);
}
| 1,041
|
C++
|
.h
| 26
| 37.076923
| 93
| 0.769307
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,215
|
diag_log.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/diag_log.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/diag/impl/diag_impl_structured_log.hpp>
#if defined(AMS_IMPL_ENABLE_LOG)
#define AMS_LOG(...) AMS_IMPL_STRUCTURED_LOG_IMPL("", ::ams::diag::LogSeverity_Info, 0, __VA_ARGS__)
#define AMS_VLOG(_FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL("", ::ams::diag::LogSeverity_Info, 0, _FMT_, _VL_)
#define AMS_PUT(_MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL("", ::ams::diag::LogSeverity_Info, 0, _MSG_, _ML_)
#define AMS_STRUCTURED_LOG(_MOD_, _SEV_, _VER_, ...) AMS_IMPL_STRUCTURED_LOG_IMPL(_MOD_, _SEV_, _VER_, __VA_ARGS__)
#define AMS_STRUCTURED_VLOG(_MOD_, _SEV_, _VER_, _FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL(_MOD_, _SEV_, _VER_, _FMT_, _VL_)
#define AMS_STRUCTURED_PUT(_MOD_, _SEV_, _VER_, _MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL(_MOD_, _SEV_, _VER_, _MSG_, _ML_)
#else
#define AMS_LOG(...) do { /* ... */ } while (false)
#define AMS_VLOG(_FMT_, _VL_) do { /* ... */ } while (false)
#define AMS_PUT(_MSG_, _ML_) do { /* ... */ } while (false)
#define AMS_STRUCTURED_LOG(_MOD_, _SEV_, _VER_, ...) do { /* ... */ } while (false)
#define AMS_STRUCTURED_VLOG(_MOD_, _SEV_, _VER_, _FMT_, _VL_) do { /* ... */ } while (false)
#define AMS_STRUCTURED_PUT(_MOD_, _SEV_, _VER_, _MSG_, _ML_) do { /* ... */ } while (false)
#endif
| 1,955
|
C++
|
.h
| 33
| 57.636364
| 125
| 0.641441
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,216
|
diag_backtrace_impl.os.windows.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_backtrace_impl.os.windows.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::diag::impl {
class Backtrace {
private:
static constexpr size_t BacktraceEntryCountMax = 0x80;
private:
void *m_backtrace_addresses[BacktraceEntryCountMax];
size_t m_index = 0;
size_t m_size = 0;
public:
Backtrace() = default;
void Initialize();
bool Step();
uintptr_t GetStackPointer() const;
uintptr_t GetReturnAddress() const;
};
}
| 1,166
|
C++
|
.h
| 33
| 29.515152
| 76
| 0.672872
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,217
|
diag_backtrace_impl.os.horizon.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_backtrace_impl.os.horizon.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::diag::impl {
class Backtrace {
private:
static constexpr size_t MemoryInfoBufferSize = 5;
public:
struct StackInfo {
uintptr_t stack_top;
uintptr_t stack_bottom;
};
private:
s64 m_memory_info_buffer[MemoryInfoBufferSize]{};
StackInfo *m_current_stack_info = nullptr;
StackInfo m_exception_stack_info{};
StackInfo m_normal_stack_info{};
uintptr_t m_fp = 0;
uintptr_t m_prev_fp = 0;
uintptr_t m_lr = 0;
public:
Backtrace() = default;
void Initialize();
void Initialize(uintptr_t fp, uintptr_t sp, uintptr_t pc);
bool Step();
uintptr_t GetStackPointer() const;
uintptr_t GetReturnAddress() const;
private:
void SetStackInfo(uintptr_t fp, uintptr_t sp);
};
}
| 1,630
|
C++
|
.h
| 45
| 28.488889
| 76
| 0.629747
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,218
|
diag_impl_log.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_impl_log.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/diag/diag_log_types.hpp>
namespace ams::diag::impl {
void LogImpl(const LogMetaData &meta, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void VLogImpl(const LogMetaData &meta, const char *fmt, std::va_list vl);
void PutImpl(const LogMetaData &meta, const char *msg, size_t msg_size);
}
| 1,010
|
C++
|
.h
| 23
| 41.652174
| 102
| 0.74187
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,219
|
diag_impl_structured_log.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_impl_structured_log.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/diag/impl/diag_impl_build_config.hpp>
#include <stratosphere/diag/impl/diag_impl_log.hpp>
#if defined(AMS_IMPL_ENABLE_LOG) || defined(AMS_IMPL_ENABLE_SDK_LOG)
#define AMS_IMPL_LOG_META_DATA(_MOD_, _SEV_, _VER_) \
(::ams::diag::LogMetaData { \
{ __LINE__, __FILE__, AMS_CURRENT_FUNCTION_NAME }, \
_MOD_, \
_SEV_, \
_VER_, \
false, \
nullptr, \
0, \
})
#define AMS_IMPL_STRUCTURED_LOG_IMPL(_MOD_, _SEV_, _VER_, ...) ::ams::diag::impl::LogImpl(AMS_IMPL_LOG_META_DATA(_MOD_, _SEV_, _VER_), __VA_ARGS__)
#define AMS_IMPL_STRUCTURED_VLOG_IMPL(_MOD_, _SEV_, _VER_, _FMT_, _VL_) ::ams::diag::impl::VLogImpl(AMS_IMPL_LOG_META_DATA(_MOD_, _SEV_, _VER_), _FMT_, _VL_)
#define AMS_IMPL_STRUCTURED_PUT_IMPL(_MOD_, _SEV_, _VER_, _MSG_, _ML_) ::ams::diag::impl::PutImpl(AMS_IMPL_LOG_META_DATA(_MOD_, _SEV_, _VER_), _MSG_, _ML_)
#else
#define AMS_IMPL_STRUCTURED_LOG_IMPL(_MOD_, _SEV_, _VER_, ...) do { /* ... */ } while (false)
#define AMS_IMPL_STRUCTURED_VLOG_IMPL(_MOD_, _SEV_, _VER_, _FMT_, _VL_) do { /* ... */ } while (false)
#define AMS_IMPL_STRUCTURED_PUT_IMPL(_MOD_, _SEV_, _VER_, _MSG_, _ML_) do { /* ... */ } while (false)
#endif
| 2,199
|
C++
|
.h
| 38
| 54.657895
| 157
| 0.553596
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,220
|
diag_impl_build_config.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_impl_build_config.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#if defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING)
#define AMS_IMPL_ENABLE_SDK_LOG
#else
//#define AMS_IMPL_ENABLE_SDK_LOG
#endif
#if defined(AMS_ENABLE_LOG)
#define AMS_IMPL_ENABLE_LOG
#if defined(AMS_DISABLE_LOG)
#error "Incoherent log configuration"
#endif
#elif defined(AMS_DISABLE_LOG)
#elif defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING)
#define AMS_IMPL_ENABLE_LOG
#else
//#define AMS_IMPL_ENABLE_LOG
#endif
| 1,168
|
C++
|
.h
| 33
| 32.757576
| 76
| 0.747126
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,221
|
diag_utf8_util.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_utf8_util.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::diag::impl {
int GetValidSizeAsUtf8String(const char *str, size_t len);
}
| 767
|
C++
|
.h
| 20
| 36.3
| 76
| 0.75672
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,222
|
diag_impl_structured_sdk_log.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag/impl/diag_impl_structured_sdk_log.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/diag/impl/diag_impl_build_config.hpp>
#include <stratosphere/diag/impl/diag_impl_structured_log.hpp>
#if defined(AMS_IMPL_ENABLE_SDK_LOG)
#define AMS_IMPL_STRUCTURED_SDK_LOG(_MOD_, _SEV_, _VER_, ...) AMS_IMPL_STRUCTURED_LOG_IMPL("$" #_MOD_ , ::ams::diag::LogSeverity_##_SEV_, _VER_, __VA_ARGS__)
#define AMS_IMPL_STRUCTURED_SDK_VLOG(_MOD_, _SEV_, _VER_, _FMT_, _VL_) AMS_IMPL_STRUCTURED_VLOG_IMPL("$" #_MOD_ , ::ams::diag::LogSeverity_##_SEV_, _VER_, _FMT_, _VL_)
#define AMS_IMPL_STRUCTURED_SDK_PUT(_MOD_, _SEV_, _VER_, _MSG_, _ML_) AMS_IMPL_STRUCTURED_PUT_IMPL("$" #_MOD_ , ::ams::diag::LogSeverity_##_SEV_, _VER_, _MSG_, _ML_)
#else
#define AMS_IMPL_STRUCTURED_SDK_LOG(_MOD_, _SEV_, _VER_, ...) do { /* ... */ } while (false)
#define AMS_IMPL_STRUCTURED_SDK_VLOG(_MOD_, _SEV_, _VER_, _FMT_, _VL_) do { /* ... */ } while (false)
#define AMS_IMPL_STRUCTURED_SDK_PUT(_MOD_, _SEV_, _VER_, _MSG_, _ML_) do { /* ... */ } while (false)
#endif
| 1,660
|
C++
|
.h
| 28
| 57.607143
| 167
| 0.66933
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,223
|
pm_shell_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/pm_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 <stratosphere/ldr.hpp>
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/ncm/ncm_program_location.hpp>
namespace ams::pm::shell {
/* Shell API. */
Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags);
Result TerminateProcess(os::ProcessId process_id);
Result GetProcessEventEvent(os::SystemEvent *out);
Result GetProcessEventInfo(ProcessEventInfo *out);
Result GetApplicationProcessIdForShell(os::ProcessId *out);
Result BoostSystemMemoryResourceLimit(u64 size);
Result BoostApplicationThreadResourceLimit();
Result BoostSystemThreadResourceLimit();
}
| 1,302
|
C++
|
.h
| 30
| 40.566667
| 96
| 0.771113
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,224
|
pm_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/pm_types.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/os/os_common_types.hpp>
namespace ams::pm {
enum class BootMode {
Normal = 0,
Maintenance = 1,
SafeMode = 2,
};
enum ResourceLimitGroup {
ResourceLimitGroup_System = 0,
ResourceLimitGroup_Application = 1,
ResourceLimitGroup_Applet = 2,
ResourceLimitGroup_Count,
};
enum LaunchFlags : u32 {
LaunchFlags_None = 0,
LaunchFlags_SignalOnExit = (1 << 0),
LaunchFlags_SignalOnStart = (1 << 1),
LaunchFlags_SignalOnException = (1 << 2),
LaunchFlags_SignalOnDebugEvent = (1 << 3),
LaunchFlags_StartSuspended = (1 << 4),
LaunchFlags_DisableAslr = (1 << 5),
};
enum LaunchFlagsDeprecated : u32 {
LaunchFlagsDeprecated_None = 0,
LaunchFlagsDeprecated_SignalOnExit = (1 << 0),
LaunchFlagsDeprecated_StartSuspended = (1 << 1),
LaunchFlagsDeprecated_SignalOnException = (1 << 2),
LaunchFlagsDeprecated_DisableAslr = (1 << 3),
LaunchFlagsDeprecated_SignalOnDebugEvent = (1 << 4),
LaunchFlagsDeprecated_SignalOnStart = (1 << 5),
};
struct ResourceLimitValue {
u64 physical_memory;
u32 thread_count;
u32 event_count;
u32 transfer_memory_count;
u32 session_count;
};
constexpr inline u32 LaunchFlagsMask = (1 << 6) - 1;
enum class ProcessEvent : u32 {
None = 0,
Exited = 1,
Started = 2,
Exception = 3,
DebugRunning = 4,
DebugBreak = 5,
};
enum class ProcessEventDeprecated : u32 {
None = 0,
Exception = 1,
Exited = 2,
DebugRunning = 3,
DebugBreak = 4,
Started = 5,
};
inline u32 GetProcessEventValue(ProcessEvent event) {
if (hos::GetVersion() >= hos::Version_5_0_0) {
return static_cast<u32>(event);
}
switch (event) {
case ProcessEvent::None:
return static_cast<u32>(ProcessEventDeprecated::None);
case ProcessEvent::Exited:
return static_cast<u32>(ProcessEventDeprecated::Exited);
case ProcessEvent::Started:
return static_cast<u32>(ProcessEventDeprecated::Started);
case ProcessEvent::Exception:
return static_cast<u32>(ProcessEventDeprecated::Exception);
case ProcessEvent::DebugRunning:
return static_cast<u32>(ProcessEventDeprecated::DebugRunning);
case ProcessEvent::DebugBreak:
return static_cast<u32>(ProcessEventDeprecated::DebugBreak);
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
struct ProcessEventInfo {
u32 event;
os::ProcessId process_id;
inline ProcessEvent GetProcessEvent() const {
if (hos::GetVersion() >= hos::Version_5_0_0) {
return static_cast<ProcessEvent>(this->event);
}
switch (static_cast<ProcessEventDeprecated>(event)) {
case ProcessEventDeprecated::None:
return ProcessEvent::None;
case ProcessEventDeprecated::Exited:
return ProcessEvent::Exited;
case ProcessEventDeprecated::Started:
return ProcessEvent::Started;
case ProcessEventDeprecated::Exception:
return ProcessEvent::Exception;
case ProcessEventDeprecated::DebugRunning:
return ProcessEvent::DebugRunning;
case ProcessEventDeprecated::DebugBreak:
return ProcessEvent::DebugBreak;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
};
static_assert(sizeof(ProcessEventInfo) == 0x10 && util::is_pod<ProcessEventInfo>::value, "ProcessEventInfo definition!");
}
| 4,706
|
C++
|
.h
| 117
| 30.982906
| 125
| 0.596284
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,225
|
pm_boot_mode_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/pm_boot_mode_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/pm/pm_types.hpp>
namespace ams::pm::bm {
/* Boot Mode API. */
BootMode GetBootMode();
void SetMaintenanceBoot();
}
| 807
|
C++
|
.h
| 22
| 34.272727
| 76
| 0.741026
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,226
|
pm_info_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/pm_info_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/os.hpp>
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/ncm/ncm_ids.hpp>
#include <stratosphere/ncm/ncm_program_location.hpp>
#include <stratosphere/cfg/cfg_types.hpp>
namespace ams::pm::info {
/* Information API. */
Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id);
Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id);
Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id);
Result GetAppletResourceLimitCurrentValue(pm::ResourceLimitValue *out);
Result GetAppletResourceLimitPeakValue(pm::ResourceLimitValue *out);
Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id);
/* Information convenience API. */
bool HasLaunchedBootProgram(ncm::ProgramId program_id);
Result IsHblProcessId(bool *out, os::ProcessId process_id);
Result IsHblProgramId(bool *out, ncm::ProgramId program_id);
}
| 1,651
|
C++
|
.h
| 34
| 45.588235
| 116
| 0.766791
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,227
|
pm_dmnt_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/pm_dmnt_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.hpp>
#include <stratosphere/pm/pm_types.hpp>
#include <stratosphere/ncm/ncm_program_location.hpp>
namespace ams::pm::dmnt {
/* Debug Monitor API. */
Result StartProcess(os::ProcessId process_id);
Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id);
Result GetProcessId(os::ProcessId *out_process_id, const ncm::ProgramId program_id);
Result GetApplicationProcessId(os::ProcessId *out_process_id);
Result HookToCreateApplicationProcess(os::NativeHandle *out_handle);
Result HookToCreateProcess(os::NativeHandle *out_handle, const ncm::ProgramId program_id);
Result AtmosphereGetProcessInfo(os::NativeHandle *out_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id);
#if defined(ATMOSPHERE_OS_HORIZON)
Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, svc::LimitableResource resource);
#endif
}
| 1,648
|
C++
|
.h
| 32
| 48.5
| 156
| 0.769565
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,228
|
pm_debug_monitor_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/impl/pm_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/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
#define AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetExceptionProcessIdList, (sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids), (out_count, out_process_ids)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, StartProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id), (out_hook, program_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetApplicationProcessId, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook), (out_hook)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, ClearHook, (u32 which), (which), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetProgramId, (sf::Out<ncm::ProgramId> out, os::ProcessId process_id), (out, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id), (out_process_handle, out_loc, out_status, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource), (out_cur_val, out_lim_val, group, resource))
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDebugMonitorInterface, AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO, 0x9391F0EE)
#define AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetModuleIdList, (sf::Out<u32> out_count, const sf::OutBuffer &out_buf, u64 unused), (out_count, out_buf, unused)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetExceptionProcessIdList, (sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids), (out_count, out_process_ids)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, StartProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id), (out_hook, program_id)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook), (out_hook)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetProgramId, (sf::Out<ncm::ProgramId> out, os::ProcessId process_id), (out, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id), (out_process_handle, out_loc, out_status, process_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource), (out_cur_val, out_lim_val, group, resource))
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDeprecatedDebugMonitorInterface, AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO, 0x9391F0EE)
| 7,330
|
C++
|
.h
| 43
| 167.162791
| 298
| 0.40813
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,229
|
pm_boot_mode_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/impl/pm_boot_mode_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/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
#define AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, void, GetBootMode, (sf::Out<u32> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, void, SetMaintenanceBoot, (), ()) \
AMS_SF_METHOD_INFO(C, H, 2, void, GetUnknown, (sf::Out<u32> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, SetUnknown, (u32 val), (val))
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IBootModeInterface, AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO, 0x96D01649)
| 1,304
|
C++
|
.h
| 25
| 49.84
| 115
| 0.677116
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,230
|
pm_shell_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/impl/pm_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/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
#define AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags), (out_process_id, loc, flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id), (program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out<pm::ProcessEventInfo> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, void, NotifyBootFinished, (), ()) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), (boost_size)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, BoostApplicationThreadResourceLimit, (), ()) \
AMS_SF_METHOD_INFO(C, H, 9, void, GetBootFinishedEventHandle, (sf::OutCopyHandle out), (out), hos::Version_8_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, BoostSystemThreadResourceLimit, (), ())
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IShellInterface, AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO, 0x387D60C0)
#define AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out<os::ProcessId> out_process_id, const ncm::ProgramLocation &loc, u32 flags), (out_process_id, loc, flags)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id), (program_id)) \
AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out<pm::ProcessEventInfo> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, CleanupProcess, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, ClearExceptionOccurred, (os::ProcessId process_id), (process_id)) \
AMS_SF_METHOD_INFO(C, H, 7, void, NotifyBootFinished, (), ()) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), (boost_size), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, BoostSystemThreadResourceLimit, (), ())
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDeprecatedShellInterface, AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO, 0x387D60C0)
| 6,410
|
C++
|
.h
| 45
| 139.066667
| 229
| 0.379088
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,231
|
pm_information_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pm/impl/pm_information_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/pm/pm_types.hpp>
#include <stratosphere/sf.hpp>
#define AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetProgramId, (sf::Out<ncm::ProgramId> out, os::ProcessId process_id), (out, process_id)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetAppletResourceLimitCurrentValue, (sf::Out<pm::ResourceLimitValue> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetAppletResourceLimitPeakValue, (sf::Out<pm::ResourceLimitValue> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessId, (sf::Out<os::ProcessId> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereHasLaunchedBootProgram, (sf::Out<bool> out, ncm::ProgramId program_id), (out, program_id)) \
AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmosphereGetProcessInfo, (sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id), (out_loc, out_status, process_id))
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IInformationInterface, AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO, 0xF205AA1F)
| 2,446
|
C++
|
.h
| 27
| 88.074074
| 225
| 0.547599
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,232
|
service_guard.h
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/service_guard.h
|
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <switch/types.h>
#include <switch/result.h>
#include <switch/kernel/mutex.h>
#include <switch/sf/service.h>
#include <switch/services/sm.h>
typedef struct ServiceGuard {
Mutex mutex;
u32 refCount;
} ServiceGuard;
NX_INLINE bool serviceGuardBeginInit(ServiceGuard* g)
{
mutexLock(&g->mutex);
return (g->refCount++) == 0;
}
NX_INLINE Result serviceGuardEndInit(ServiceGuard* g, Result rc, void (*cleanupFunc)(void))
{
if (R_FAILED(rc)) {
cleanupFunc();
--g->refCount;
}
mutexUnlock(&g->mutex);
return rc;
}
NX_INLINE void serviceGuardExit(ServiceGuard* g, void (*cleanupFunc)(void))
{
mutexLock(&g->mutex);
if (g->refCount && (--g->refCount) == 0)
cleanupFunc();
mutexUnlock(&g->mutex);
}
#define NX_GENERATE_SERVICE_GUARD_PARAMS(name, _paramdecl, _parampass) \
\
static ServiceGuard g_##name##Guard; \
NX_INLINE Result _##name##Initialize _paramdecl; \
static void _##name##Cleanup(void); \
\
Result name##Initialize _paramdecl \
{ \
Result rc = 0; \
if (serviceGuardBeginInit(&g_##name##Guard)) \
rc = _##name##Initialize _parampass; \
return serviceGuardEndInit(&g_##name##Guard, rc, _##name##Cleanup); \
} \
\
void name##Exit(void) \
{ \
serviceGuardExit(&g_##name##Guard, _##name##Cleanup); \
}
#define NX_GENERATE_SERVICE_GUARD(name) NX_GENERATE_SERVICE_GUARD_PARAMS(name, (void), ())
#ifdef __cplusplus
}
#endif
| 1,479
|
C++
|
.h
| 56
| 23.607143
| 91
| 0.682461
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,233
|
spl_key_slot_cache.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/spl/impl/spl_key_slot_cache.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::spl::impl {
class AesKeySlotCacheEntry : public util::IntrusiveListBaseNode<AesKeySlotCacheEntry> {
NON_COPYABLE(AesKeySlotCacheEntry);
NON_MOVEABLE(AesKeySlotCacheEntry);
private:
friend class AesKeySlotCache;
public:
static constexpr size_t KeySize = crypto::AesDecryptor128::KeySize;
private:
const s32 m_aes_keyslot_index;
s32 m_virtual_aes_keyslot;
public:
explicit AesKeySlotCacheEntry(s32 idx) : m_aes_keyslot_index(idx), m_virtual_aes_keyslot(-1) { /* ... */ }
bool Contains(s32 virtual_slot) const {
return virtual_slot == m_virtual_aes_keyslot;
}
s32 GetPhysicalAesKeySlotIndex() const { return m_aes_keyslot_index; }
s32 GetVirtualAesKeySlotIndex() const { return m_virtual_aes_keyslot; }
void SetVirtualAesKeySlot(s32 virtual_slot) {
m_virtual_aes_keyslot = virtual_slot;
}
void ClearVirtualAesKeySlot() {
m_virtual_aes_keyslot = -1;
}
};
class AesKeySlotCache {
NON_COPYABLE(AesKeySlotCache);
NON_MOVEABLE(AesKeySlotCache);
private:
using AesKeySlotCacheEntryList = util::IntrusiveListBaseTraits<AesKeySlotCacheEntry>::ListType;
private:
AesKeySlotCacheEntryList m_mru_list;
public:
constexpr AesKeySlotCache() : m_mru_list() { /* ... */ }
s32 Allocate(s32 virtual_slot) {
return this->AllocateFromLru(virtual_slot);
}
bool Find(s32 *out, s32 virtual_slot) {
for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) {
if (it->Contains(virtual_slot)) {
*out = it->GetPhysicalAesKeySlotIndex();
this->UpdateMru(it);
return true;
}
}
return false;
}
bool Release(s32 *out, s32 virtual_slot) {
for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) {
if (it->Contains(virtual_slot)) {
*out = it->GetPhysicalAesKeySlotIndex();
it->ClearVirtualAesKeySlot();
this->UpdateLru(it);
return true;
}
}
return false;
}
bool FindPhysical(s32 physical_slot) {
for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) {
if (it->GetPhysicalAesKeySlotIndex() == physical_slot) {
this->UpdateMru(it);
if (it->GetVirtualAesKeySlotIndex() == physical_slot) {
return true;
} else {
it->SetVirtualAesKeySlot(physical_slot);
return false;
}
}
}
AMS_ABORT();
}
void AddEntry(AesKeySlotCacheEntry *entry) {
m_mru_list.push_front(*entry);
}
private:
s32 AllocateFromLru(s32 virtual_slot) {
AMS_ASSERT(!m_mru_list.empty());
auto it = m_mru_list.rbegin();
it->SetVirtualAesKeySlot(virtual_slot);
auto *entry = std::addressof(*it);
m_mru_list.pop_back();
m_mru_list.push_front(*entry);
return entry->GetPhysicalAesKeySlotIndex();
}
void UpdateMru(AesKeySlotCacheEntryList::iterator it) {
auto *entry = std::addressof(*it);
m_mru_list.erase(it);
m_mru_list.push_front(*entry);
}
void UpdateLru(AesKeySlotCacheEntryList::iterator it) {
auto *entry = std::addressof(*it);
m_mru_list.erase(it);
m_mru_list.push_back(*entry);
}
};
}
| 4,848
|
C++
|
.h
| 114
| 28.947368
| 118
| 0.536518
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,234
|
spl_ctr_drbg.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/spl/impl/spl_ctr_drbg.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::spl::impl {
constexpr inline int BitsPerByte = BITSIZEOF(u8);
/* Nintendo implements CTR_DRBG for their csrng. We will do the same. */
template<typename BlockCipher, size_t KeySize, bool UseDerivation>
class CtrDrbg {
public:
static constexpr int KeyLen = KeySize * BitsPerByte;
static constexpr int OutLen = BlockCipher::BlockSize * BitsPerByte;
static constexpr int SeedLen = KeyLen + OutLen;
static constexpr int MaxNumberOfBitsPerRequest = (1 << 19);
static constexpr int ReseedInterval = 0x7FFFFFF0;
static constexpr size_t OutSize = OutLen / BitsPerByte;
static constexpr size_t SeedSize = SeedLen / BitsPerByte;
static constexpr size_t RequestSizeMax = MaxNumberOfBitsPerRequest / BitsPerByte;
static_assert(SeedSize % OutSize == 0);
private:
class Bcc {
private:
u8 *m_buffer;
const BlockCipher *m_cipher;
size_t m_offset;
public:
Bcc(u8 *buffer, const BlockCipher *cipher) : m_buffer(buffer), m_cipher(cipher), m_offset(0) { /* ... */ }
void Process(const void *data, size_t size) {
const u8 *data_8 = static_cast<const u8 *>(data);
size_t remaining = size;
while (m_offset + remaining >= OutSize) {
const size_t xor_size = OutSize - m_offset;
Xor(m_buffer + m_offset, data_8, xor_size);
m_cipher->EncryptBlock(m_buffer, OutSize, m_buffer, OutSize);
data_8 += xor_size;
remaining -= xor_size;
m_offset = 0;
}
Xor(m_buffer + m_offset, data_8, remaining);
m_offset += remaining;
}
void Flush() {
if (m_offset != 0) {
m_cipher->EncryptBlock(m_buffer, OutSize, m_buffer, OutSize);
m_offset = 0;
}
}
};
private:
BlockCipher m_block_cipher;
u8 m_v[OutSize];
u8 m_key[KeySize];
u8 m_work1[SeedSize];
u8 m_work2[SeedSize];
int m_reseed_counter;
private:
static void Xor(void *dst, const void *src, size_t size) {
const u8 *src_u8 = static_cast<const u8 *>(src);
u8 *dst_u8 = static_cast<u8 *>(dst);
for (size_t i = 0; i < size; i++) {
dst_u8[i] ^= src_u8[i];
}
}
static void Increment(void *v) {
u8 *v_8 = static_cast<u8 *>(v);
for (int i = OutSize - 1; i >= 0; --i) {
if ((++v_8[i]) != 0) {
break;
}
}
}
private:
void DeriveSeed(void *seed, const void *a, size_t a_size, const void *b, size_t b_size, const void *c, size_t c_size) {
/* Determine sizes. */
const u32 in_size = a_size + b_size + c_size;
const u32 out_size = SeedSize;
/* Create header/footer. */
u32 header[2];
util::StoreBigEndian(header + 0, in_size);
util::StoreBigEndian(header + 1, out_size);
const u8 footer = 0x80;
/* Create seed as 000102... */
u8 *seed_8 = static_cast<u8 *>(seed);
for (size_t i = 0; i < KeySize; ++i) {
seed_8[i] = i;
}
/* Initialize block cipher. */
m_block_cipher.Initialize(seed_8, KeySize);
/* Perform derivation. */
for (u32 block = 0; block < SeedSize / OutSize; ++block) {
/* Create the block index value. */
u32 block_value;
util::StoreBigEndian(std::addressof(block_value), block);
/* Get the target block. */
u8 *target = seed_8 + block * OutSize;
std::memset(target, 0, OutSize);
/* Create block processor. */
Bcc bcc(target, std::addressof(m_block_cipher));
/* Process block value. */
bcc.Process(std::addressof(block_value), sizeof(block_value));
bcc.Flush();
/* Process header/data. */
bcc.Process(header, sizeof(header));
bcc.Process(a, a_size);
bcc.Process(b, b_size);
bcc.Process(c, c_size);
bcc.Process(footer, std::addressof(footer));
bcc.Flush();
}
/* Initialize block cipher. */
m_block_cipher.Initialize(seed_8, KeySize);
/* Encrypt seed. */
m_block_cipher.EncryptBlock(seed_8, OutSize, seed_8 + KeySize, OutSize);
for (size_t offset = 0; offset < SeedSize - OutSize; offset += OutSize) {
m_block_cipher.EncryptBlock(seed_8 + offset + OutSize, OutSize, seed_8 + offset, OutSize);
}
}
void UpdateStates(void *key, void *v, const void *provided_data) {
/* Initialize block cipher. */
m_block_cipher.Initialize(key, KeySize);
/* Update work. */
for (size_t offset = 0; offset < SeedSize; offset += OutSize) {
Increment(v);
m_block_cipher.EncryptBlock(std::addressof(m_work2[offset]), OutSize, v, OutSize);
}
/* Xor work with provided data. */
Xor(m_work2, provided_data, SeedSize);
/* Copy to key/v. */
std::memcpy(key, m_work2 + 0, KeySize);
std::memcpy(v, m_work2 + KeySize, OutSize);
}
public:
constexpr CtrDrbg() = default;
void Initialize(const void *entropy, size_t entropy_size, const void *nonce, size_t nonce_size, const void *personalization, size_t personalization_size) {
/* Handle init. */
if constexpr (UseDerivation) {
this->DeriveSeed(m_work1, entropy, entropy_size, nonce, nonce_size, personalization, personalization_size);
} else {
AMS_ASSERT(entropy_size == SeedSize);
AMS_ASSERT(nonce_size == 0);
AMS_ASSERT(personalization_size <= SeedSize);
AMS_UNUSED(entropy_size, nonce, nonce_size);
std::memcpy(m_work1, entropy, SeedSize);
Xor(m_work1, personalization, personalization_size);
}
/* Clear key/v. */
std::memset(m_key, 0, sizeof(m_key));
std::memset(m_v, 0, sizeof(m_v));
/* Set key/v. */
this->UpdateStates(m_key, m_v, m_work1);
/* Set reseed counter. */
m_reseed_counter = 1;
}
void Reseed(const void *entropy, size_t entropy_size, const void *addl, size_t addl_size) {
/* Handle init. */
if constexpr (UseDerivation) {
this->DeriveSeed(m_work1, entropy, entropy_size, addl, addl_size, nullptr, 0);
} else {
AMS_ASSERT(entropy_size == SeedSize);
AMS_ASSERT(addl_size <= SeedSize);
AMS_UNUSED(entropy_size);
std::memcpy(m_work1, entropy, SeedSize);
Xor(m_work1, addl, addl_size);
}
/* Set key/v. */
this->UpdateStates(m_key, m_v, m_work1);
/* Set reseed counter. */
m_reseed_counter = 1;
}
bool Generate(void *out, size_t size, const void *addl, size_t addl_size) {
/* Check that the request is small enough. */
if (size > RequestSizeMax) {
return false;
}
/* Check if we need reseed. */
if (m_reseed_counter > ReseedInterval) {
return false;
}
/* Clear work buffer. */
std::memset(m_work1, 0, sizeof(m_work1));
/* Process additional input, if we have any. */
if (addl_size > 0) {
if constexpr (UseDerivation) {
this->DeriveSeed(m_work1, addl, addl_size, nullptr, 0, nullptr, 0);
} else {
AMS_ASSERT(addl_size <= SeedSize);
std::memcpy(m_work1, addl, addl_size);
}
/* Set key/v. */
this->UpdateStates(m_key, m_v, m_work1);
}
/* Get buffer and aligned size. */
u8 *out_8 = static_cast<u8 *>(out);
const size_t aligned_size = util::AlignDown(size, OutSize);
/* Generate ctr bytes. */
m_block_cipher.Initialize(m_key, KeySize);
for (size_t offset = 0; offset < aligned_size; offset += OutSize) {
Increment(m_v);
m_block_cipher.EncryptBlock(out_8 + offset, OutSize, m_v, OutSize);
}
/* Handle any unaligned data. */
if (size > aligned_size) {
u8 temp[OutSize];
Increment(m_v);
m_block_cipher.EncryptBlock(temp, sizeof(temp), m_v, OutSize);
std::memcpy(out_8 + aligned_size, temp, size - aligned_size);
}
/* Set key/v. */
this->UpdateStates(m_key, m_v, m_work1);
/* Increment reseed counter. */
++m_reseed_counter;
return true;
}
};
}
| 11,157
|
C++
|
.h
| 228
| 32.122807
| 167
| 0.477022
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,235
|
spl_device_address_mapper.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/spl/impl/spl_device_address_mapper.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::spl::impl {
class DeviceAddressMapper {
private:
dd::DeviceAddressSpaceType *m_das;
u64 m_process_address;
size_t m_size;
dd::DeviceVirtualAddress m_device_address;
public:
DeviceAddressMapper(dd::DeviceAddressSpaceType *das, u64 process_address, size_t size, dd::DeviceVirtualAddress device_address, dd::MemoryPermission permission)
: m_das(das), m_process_address(process_address), m_size(size), m_device_address(device_address)
{
#if defined(ATMOSPHERE_OS_HORIZON)
R_ABORT_UNLESS(dd::MapDeviceAddressSpaceAligned(m_das, dd::GetCurrentProcessHandle(), m_process_address, m_size, m_device_address, permission));
#else
AMS_UNUSED(permission);
#endif
}
~DeviceAddressMapper() {
#if defined(ATMOSPHERE_OS_HORIZON)
dd::UnmapDeviceAddressSpace(m_das, dd::GetCurrentProcessHandle(), m_process_address, m_size, m_device_address);
#endif
}
};
}
| 1,809
|
C++
|
.h
| 41
| 35.95122
| 172
| 0.661565
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,236
|
htclow_packet_factory.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_packet_factory.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_packet.hpp"
namespace ams::htclow {
class PacketFactory {
private:
mem::StandardAllocator *m_allocator;
public:
PacketFactory(mem::StandardAllocator *allocator) : m_allocator(allocator) { /* ... */ }
std::unique_ptr<Packet, PacketDeleter> MakeDataPacket(impl::ChannelInternalType channel, s16 version, const void *body, int body_size, u64 share, u32 offset);
std::unique_ptr<Packet, PacketDeleter> MakeMaxDataPacket(impl::ChannelInternalType channel, s16 version, u64 share);
std::unique_ptr<Packet, PacketDeleter> MakeErrorPacket(impl::ChannelInternalType channel);
void Delete(Packet *packet);
private:
std::unique_ptr<Packet, PacketDeleter> MakeSendPacketCommon(impl::ChannelInternalType channel, s16 version, int body_size);
};
}
| 1,549
|
C++
|
.h
| 32
| 43.15625
| 170
| 0.722222
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,237
|
htclow_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "driver/htclow_i_driver.hpp"
namespace ams::htclow {
class HtclowManagerImpl;
class HtclowManager {
private:
mem::StandardAllocator *m_allocator;
HtclowManagerImpl *m_impl;
public:
HtclowManager(mem::StandardAllocator *allocator);
~HtclowManager();
public:
Result OpenDriver(impl::DriverType driver_type);
void CloseDriver();
Result Open(impl::ChannelInternalType channel);
Result Close(impl::ChannelInternalType channel);
void Resume();
void Suspend();
Result ConnectBegin(u32 *out_task_id, impl::ChannelInternalType channel);
Result ConnectEnd(impl::ChannelInternalType channel, u32 task_id);
void Disconnect();
Result FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel);
Result FlushEnd(u32 task_id);
ChannelState GetChannelState(impl::ChannelInternalType channel);
os::EventType *GetChannelStateEvent(impl::ChannelInternalType channel);
impl::DriverType GetDriverType();
os::EventType *GetTaskEvent(u32 task_id);
void NotifyAsleep();
void NotifyAwake();
Result ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size);
Result ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id);
Result SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel);
Result SendEnd(u32 task_id);
Result WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size);
Result WaitReceiveEnd(u32 task_id);
void SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config);
void SetDebugDriver(driver::IDriver *driver);
void SetReceiveBuffer(impl::ChannelInternalType channel, void *buf, size_t buf_size);
void SetSendBuffer(impl::ChannelInternalType channel, void *buf, size_t buf_size);
void SetSendBufferWithData(impl::ChannelInternalType channel, const void *buf, size_t buf_size);
Result Shutdown(impl::ChannelInternalType channel);
};
}
| 3,025
|
C++
|
.h
| 59
| 42.372881
| 129
| 0.683978
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,238
|
htclow_default_channel_config.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_default_channel_config.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_packet.hpp"
namespace ams::htclow {
constexpr inline const ChannelConfig DefaultChannelConfig = {
.flow_control_enabled = true,
.handshake_enabled = true,
.initial_counter_max_data = 0,
.max_packet_size = 0xE000 + sizeof(PacketHeader),
};
}
| 997
|
C++
|
.h
| 26
| 35.153846
| 76
| 0.717975
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,239
|
htclow_worker.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_worker.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "driver/htclow_i_driver.hpp"
#include "ctrl/htclow_ctrl_service.hpp"
#include "mux/htclow_mux.hpp"
namespace ams::htclow {
class Worker {
private:
static_assert(sizeof(ctrl::HtcctrlPacketHeader) <= sizeof(PacketHeader));
static_assert(sizeof(ctrl::HtcctrlPacketBody) <= sizeof(PacketBody));
private:
u32 m_thread_stack_size;
u8 m_send_buffer[sizeof(PacketHeader) + sizeof(PacketBody)];
u8 m_receive_packet_body[sizeof(PacketBody)];
mem::StandardAllocator *m_allocator;
mux::Mux *m_mux;
ctrl::HtcctrlService *m_service;
driver::IDriver *m_driver;
os::ThreadType m_receive_thread;
os::ThreadType m_send_thread;
os::Event m_event;
void *m_receive_thread_stack;
void *m_send_thread_stack;
bool m_cancelled;
private:
static void ReceiveThreadEntry(void *arg) {
static_cast<Worker *>(arg)->ReceiveThread();
}
static void SendThreadEntry(void *arg) {
static_cast<Worker *>(arg)->SendThread();
}
void ReceiveThread();
void SendThread();
public:
Worker(mem::StandardAllocator *allocator, mux::Mux *mux, ctrl::HtcctrlService *ctrl_srv);
void SetDriver(driver::IDriver *driver);
void Start();
void Cancel();
void Wait();
private:
Result ProcessReceive();
Result ProcessSend();
Result ProcessReceive(const ctrl::HtcctrlPacketHeader &header);
Result ProcessReceive(const PacketHeader &header);
};
}
| 2,419
|
C++
|
.h
| 61
| 31.081967
| 101
| 0.633191
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,240
|
htclow_packet.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_packet.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow {
enum PacketType : u16 {
PacketType_Data = 24,
PacketType_MaxData = 25,
PacketType_Error = 26,
};
static constexpr inline u32 HtcGen2Signature = 0xA79F3540;
struct PacketHeader {
u32 signature;
u32 offset;
u32 reserved;
u32 body_size;
s16 version;
PacketType packet_type;
impl::ChannelInternalType channel;
u64 share;
};
static_assert(util::is_pod<PacketHeader>::value);
static_assert(sizeof(PacketHeader) == 0x20);
static constexpr inline size_t PacketBodySizeMax = 0x3E000;
struct PacketBody {
u8 data[PacketBodySizeMax];
};
template<typename HeaderType>
class BasePacket {
private:
mem::StandardAllocator *m_allocator;
u8 *m_header;
int m_packet_size;
public:
BasePacket(mem::StandardAllocator *allocator, int packet_size) : m_allocator(allocator), m_header(nullptr), m_packet_size(packet_size) {
AMS_ASSERT(packet_size >= static_cast<int>(sizeof(HeaderType)));
m_header = static_cast<u8 *>(m_allocator->Allocate(m_packet_size));
}
virtual ~BasePacket() {
if (m_header != nullptr) {
m_allocator->Free(m_header);
}
}
bool IsAllocationSucceeded() const {
return m_header != nullptr;
}
HeaderType *GetHeader() {
return reinterpret_cast<HeaderType *>(m_header);
}
const HeaderType *GetHeader() const {
return reinterpret_cast<const HeaderType *>(m_header);
}
int GetBodySize() const {
return m_packet_size - sizeof(HeaderType);
}
u8 *GetBody() const {
if (this->GetBodySize() > 0) {
return m_header + sizeof(HeaderType);
} else {
return nullptr;
}
}
void CopyBody(const void *src, int src_size) {
AMS_ASSERT(this->GetBodySize() >= 0);
std::memcpy(this->GetBody(), src, src_size);
}
};
class Packet : public BasePacket<PacketHeader>, public util::IntrusiveListBaseNode<Packet> {
public:
using BasePacket<PacketHeader>::BasePacket;
};
struct PacketDeleter {
mem::StandardAllocator *m_allocator;
void operator()(Packet *packet) {
std::destroy_at(packet);
m_allocator->Free(packet);
}
};
}
| 3,353
|
C++
|
.h
| 92
| 26.98913
| 148
| 0.592101
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,241
|
htclow_channel.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_channel.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_manager.hpp"
namespace ams::htclow {
class Channel final {
private:
HtclowManager *m_manager;
ChannelType m_channel;
public:
constexpr Channel(HtclowManager *manager) : m_manager(manager), m_channel() { /* ... */ }
constexpr ~Channel() { m_channel = {}; }
ChannelType *GetBase() { return std::addressof(m_channel); }
public:
Result Open(const Module *module, ChannelId id);
void Close();
ChannelState GetChannelState();
os::EventType *GetChannelStateEvent();
Result Connect();
Result Flush();
void Shutdown();
Result Receive(s64 *out, void *dst, s64 size, ReceiveOption option);
Result Send(s64 *out, const void *src, s64 size);
void SetConfig(const ChannelConfig &config);
void SetReceiveBuffer(void *buf, size_t size);
void SetSendBuffer(void *buf, size_t size);
void SetSendBufferWithData(const void *buf, size_t size);
Result WaitReceive(s64 size);
Result WaitReceive(s64 size, os::EventType *event);
private:
void WaitEvent(os::EventType *event, bool);
Result ReceiveInternal(s64 *out, void *dst, s64 size, ReceiveOption option);
Result WaitReceiveInternal(s64 size, os::EventType *event);
};
}
| 2,118
|
C++
|
.h
| 49
| 35.306122
| 101
| 0.649029
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,242
|
htclow_listener.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_listener.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_worker.hpp"
namespace ams::htclow {
class Listener {
private:
u32 m_thread_stack_size;
mem::StandardAllocator *m_allocator;
mux::Mux *m_mux;
ctrl::HtcctrlService *m_service;
Worker *m_worker;
os::Event m_event;
os::ThreadType m_listen_thread;
void *m_listen_thread_stack;
driver::IDriver *m_driver;
bool m_thread_running;
bool m_cancelled;
private:
static void ListenThreadEntry(void *arg) {
static_cast<Listener *>(arg)->ListenThread();
}
void ListenThread();
public:
Listener(mem::StandardAllocator *allocator, mux::Mux *mux, ctrl::HtcctrlService *ctrl_srv, Worker *worker);
void Start(driver::IDriver *driver);
void Cancel();
void Wait();
};
}
| 1,609
|
C++
|
.h
| 44
| 29.136364
| 119
| 0.638462
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,243
|
htclow_manager_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/htclow_manager_impl.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_packet_factory.hpp"
#include "driver/htclow_driver_manager.hpp"
#include "mux/htclow_mux.hpp"
#include "ctrl/htclow_ctrl_packet_factory.hpp"
#include "ctrl/htclow_ctrl_state_machine.hpp"
#include "ctrl/htclow_ctrl_service.hpp"
#include "htclow_worker.hpp"
#include "htclow_listener.hpp"
namespace ams::htclow {
class HtclowManagerImpl {
private:
PacketFactory m_packet_factory;
driver::DriverManager m_driver_manager;
mux::Mux m_mux;
ctrl::HtcctrlPacketFactory m_ctrl_packet_factory;
ctrl::HtcctrlStateMachine m_ctrl_state_machine;
ctrl::HtcctrlService m_ctrl_service;
Worker m_worker;
Listener m_listener;
bool m_is_driver_open;
public:
HtclowManagerImpl(mem::StandardAllocator *allocator);
~HtclowManagerImpl();
public:
Result OpenDriver(impl::DriverType driver_type);
void CloseDriver();
Result Open(impl::ChannelInternalType channel);
Result Close(impl::ChannelInternalType channel);
void Resume();
void Suspend();
Result ConnectBegin(u32 *out_task_id, impl::ChannelInternalType channel);
Result ConnectEnd(impl::ChannelInternalType channel, u32 task_id);
void Disconnect();
Result FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel);
Result FlushEnd(u32 task_id);
ChannelState GetChannelState(impl::ChannelInternalType channel);
os::EventType *GetChannelStateEvent(impl::ChannelInternalType channel);
impl::DriverType GetDriverType();
os::EventType *GetTaskEvent(u32 task_id);
void NotifyAsleep();
void NotifyAwake();
Result ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size);
Result ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id);
Result SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel);
Result SendEnd(u32 task_id);
Result WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size);
Result WaitReceiveEnd(u32 task_id);
void SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config);
void SetDebugDriver(driver::IDriver *driver);
void SetReceiveBuffer(impl::ChannelInternalType channel, void *buf, size_t buf_size);
void SetSendBuffer(impl::ChannelInternalType channel, void *buf, size_t buf_size);
void SetSendBufferWithData(impl::ChannelInternalType channel, const void *buf, size_t buf_size);
Result Shutdown(impl::ChannelInternalType channel);
};
}
| 3,577
|
C++
|
.h
| 72
| 41.111111
| 129
| 0.685313
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,244
|
htclow_ctrl_settings_holder.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_settings_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 <stratosphere.hpp>
namespace ams::htclow::ctrl {
class SettingsHolder {
private:
char m_hardware_type[0x40]{};
char m_target_name[0x40]{};
char m_serial_number[0x40]{};
char m_firmware_version[0x40]{};
public:
constexpr SettingsHolder() = default;
void LoadSettings();
const char *GetSpec() { return "NX"; }
const char *GetHardwareType() { return m_hardware_type; }
const char *GetTargetName() { return m_target_name; }
const char *GetSerialNumber() { return m_serial_number; }
const char *GetFirmwareVersion() { return m_firmware_version; }
};
}
| 1,365
|
C++
|
.h
| 34
| 34
| 76
| 0.666667
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,245
|
htclow_ctrl_packet.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_packet.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "../htclow_packet.hpp"
namespace ams::htclow::ctrl {
enum HtcctrlPacketType : u16 {
HtcctrlPacketType_ConnectFromHost = 16,
HtcctrlPacketType_ConnectFromTarget = 17,
HtcctrlPacketType_ReadyFromHost = 18,
HtcctrlPacketType_ReadyFromTarget = 19,
HtcctrlPacketType_SuspendFromHost = 20,
HtcctrlPacketType_SuspendFromTarget = 21,
HtcctrlPacketType_ResumeFromHost = 22,
HtcctrlPacketType_ResumeFromTarget = 23,
HtcctrlPacketType_DisconnectFromHost = 24,
HtcctrlPacketType_DisconnectFromTarget = 25,
HtcctrlPacketType_BeaconQuery = 28,
HtcctrlPacketType_BeaconResponse = 29,
HtcctrlPacketType_InformationFromTarget = 33,
};
static constexpr inline u32 HtcctrlSignature = 0x78825637;
struct HtcctrlPacketHeader {
u32 signature;
u32 sequence_id;
u32 reserved;
u32 body_size;
s16 version;
HtcctrlPacketType packet_type;
impl::ChannelInternalType channel;
u64 share;
};
static_assert(util::is_pod<HtcctrlPacketHeader>::value);
static_assert(sizeof(HtcctrlPacketHeader) == 0x20);
static constexpr inline size_t HtcctrlPacketBodySizeMax = 0x1000;
struct HtcctrlPacketBody {
u8 data[HtcctrlPacketBodySizeMax];
};
class HtcctrlPacket : public BasePacket<HtcctrlPacketHeader>, public util::IntrusiveListBaseNode<HtcctrlPacket> {
public:
using BasePacket<HtcctrlPacketHeader>::BasePacket;
};
struct HtcctrlPacketDeleter {
mem::StandardAllocator *m_allocator;
void operator()(HtcctrlPacket *packet) {
std::destroy_at(packet);
m_allocator->Free(packet);
}
};
}
| 2,505
|
C++
|
.h
| 63
| 33.619048
| 117
| 0.693257
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,246
|
htclow_ctrl_state_machine.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_state_machine.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_ctrl_state.hpp"
namespace ams::htclow::ctrl {
class HtcctrlStateMachine {
private:
enum ServiceChannelSupport {
ServiceChannelSupport_Unknown = 0,
ServiceChannelSupport_Suppported = 1,
ServiceChannelSupport_Unsupported = 2,
};
enum ServiceChannelConnect {
ServiceChannelConnect_NotConnecting = 0,
ServiceChannelConnect_Connecting = 1,
ServiceChannelConnect_ConnectingChecked = 2,
};
struct ServiceChannelState {
ServiceChannelSupport support;
ServiceChannelConnect connect;
};
static constexpr int MaxChannelCount = 10;
using MapType = util::FixedMap<impl::ChannelInternalType, ServiceChannelState>;
static constexpr size_t MapRequiredMemorySize = MapType::GetRequiredMemorySize(MaxChannelCount);
private:
u8 m_map_buffer[MapRequiredMemorySize];
MapType m_map;
HtcctrlState m_state;
HtcctrlState m_prev_state;
os::SdkMutex m_mutex;
public:
HtcctrlStateMachine();
HtcctrlState GetHtcctrlState();
Result SetHtcctrlState(bool *out_transitioned, HtcctrlState state);
bool IsConnectedStatusChanged();
bool IsSleepingStatusChanged();
bool IsInformationNeeded();
bool IsDisconnectionNeeded();
bool IsConnected();
bool IsReadied();
bool IsUnconnectable();
bool IsDisconnected();
bool IsSleeping();
bool IsPossibleToSendReady();
bool IsUnsupportedServiceChannelToShutdown(const impl::ChannelInternalType &channel);
bool IsConnectable(const impl::ChannelInternalType &channel);
void SetConnecting(const impl::ChannelInternalType &channel);
void SetNotConnecting(const impl::ChannelInternalType &channel);
void SetConnectingChecked();
void NotifySupportedServiceChannels(const impl::ChannelInternalType *channels, int num_channels);
private:
void SetStateWithoutCheckInternal(HtcctrlState state);
bool AreServiceChannelsConnecting();
void ClearServiceChannelStates();
};
}
| 3,088
|
C++
|
.h
| 70
| 34.1
| 109
| 0.659114
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,247
|
htclow_ctrl_service_channels.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_service_channels.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::ctrl {
constexpr inline const impl::ChannelInternalType ServiceChannels[] = {
{
.channel_id = 0, /* TODO: htcfs::ChannelId? */
.module_id = ModuleId::Htcfs,
},
{
.channel_id = 1, /* TODO: htcmisc::ClientChannelId? */
.module_id = ModuleId::Htcmisc,
},
{
.channel_id = 2, /* TODO: htcmisc::ServerChannelId? */
.module_id = ModuleId::Htcmisc,
},
{
.channel_id = 0, /* TODO: htcs::ChannelId? */
.module_id = ModuleId::Htcs,
},
};
}
| 1,303
|
C++
|
.h
| 37
| 29.216216
| 76
| 0.629454
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,248
|
htclow_ctrl_send_buffer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_send_buffer.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_ctrl_packet.hpp"
namespace ams::htclow::ctrl {
class HtcctrlPacketFactory;
class HtcctrlSendBuffer {
private:
using PacketList = util::IntrusiveListBaseTraits<HtcctrlPacket>::ListType;
private:
HtcctrlPacketFactory *m_packet_factory;
PacketList m_prior_packet_list;
PacketList m_posterior_packet_list;
private:
bool IsPriorPacket(HtcctrlPacketType packet_type) const;
bool IsPosteriorPacket(HtcctrlPacketType packet_type) const;
void CopyPacket(HtcctrlPacketHeader *header, HtcctrlPacketBody *body, int *out_body_size, const HtcctrlPacket &packet);
public:
HtcctrlSendBuffer(HtcctrlPacketFactory *pf) : m_packet_factory(pf), m_prior_packet_list(), m_posterior_packet_list() { /* ... */ }
void AddPacket(std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> ptr);
void RemovePacket(const HtcctrlPacketHeader &header);
bool QueryNextPacket(HtcctrlPacketHeader *header, HtcctrlPacketBody *body, int *out_body_size);
};
}
| 1,793
|
C++
|
.h
| 38
| 41
| 142
| 0.716819
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,249
|
htclow_ctrl_state.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_state.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::ctrl {
enum HtcctrlState : u32 {
HtcctrlState_DriverConnected = 0,
HtcctrlState_SentConnectFromHost = 1,
HtcctrlState_Connected = 2,
HtcctrlState_SentReadyFromHost = 3,
HtcctrlState_Ready = 4,
HtcctrlState_SentSuspendFromTarget = 5,
HtcctrlState_EnterSleep = 6,
HtcctrlState_Sleep = 7,
HtcctrlState_ExitSleep = 8,
HtcctrlState_SentResumeFromTarget = 9,
HtcctrlState_Disconnected = 10,
HtcctrlState_DriverDisconnected = 11,
HtcctrlState_Error = 12,
};
constexpr bool IsStateTransitionAllowed(HtcctrlState from, HtcctrlState to) {
switch (from) {
case HtcctrlState_DriverConnected:
return to == HtcctrlState_SentConnectFromHost ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_SentConnectFromHost:
return to == HtcctrlState_Connected ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_Connected:
return to == HtcctrlState_SentReadyFromHost ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_SentReadyFromHost:
return to == HtcctrlState_Ready ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_Ready:
return to == HtcctrlState_SentSuspendFromTarget ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_SentSuspendFromTarget:
return to == HtcctrlState_EnterSleep ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_EnterSleep:
return to == HtcctrlState_Sleep ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_Sleep:
return to == HtcctrlState_ExitSleep;
case HtcctrlState_ExitSleep:
return to == HtcctrlState_SentResumeFromTarget ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_SentResumeFromTarget:
return to == HtcctrlState_Ready ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_Disconnected:
return to == HtcctrlState_SentConnectFromHost ||
to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
case HtcctrlState_DriverDisconnected:
return to == HtcctrlState_DriverConnected;
case HtcctrlState_Error:
return to == HtcctrlState_Disconnected ||
to == HtcctrlState_DriverDisconnected ||
to == HtcctrlState_Error;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
constexpr bool IsDisconnected(HtcctrlState state) {
switch (state) {
case HtcctrlState_Disconnected:
case HtcctrlState_DriverDisconnected:
return true;
default:
return false;
}
}
constexpr bool IsConnecting(HtcctrlState state) {
switch (state) {
case HtcctrlState_DriverConnected:
case HtcctrlState_SentConnectFromHost:
case HtcctrlState_Disconnected:
return true;
default:
return false;
}
}
constexpr bool IsConnected(HtcctrlState state) {
switch (state) {
case HtcctrlState_Connected:
case HtcctrlState_SentReadyFromHost:
case HtcctrlState_Ready:
case HtcctrlState_SentSuspendFromTarget:
case HtcctrlState_EnterSleep:
case HtcctrlState_Sleep:
case HtcctrlState_ExitSleep:
case HtcctrlState_SentResumeFromTarget:
return true;
default:
return false;
}
}
constexpr bool IsReadied(HtcctrlState state) {
switch (state) {
case HtcctrlState_Ready:
case HtcctrlState_SentSuspendFromTarget:
case HtcctrlState_EnterSleep:
case HtcctrlState_Sleep:
case HtcctrlState_ExitSleep:
case HtcctrlState_SentResumeFromTarget:
return true;
default:
return false;
}
}
constexpr bool IsSleeping(HtcctrlState state) {
switch (state) {
case HtcctrlState_SentSuspendFromTarget:
case HtcctrlState_EnterSleep:
case HtcctrlState_Sleep:
case HtcctrlState_ExitSleep:
case HtcctrlState_SentResumeFromTarget:
return true;
default:
return false;
}
}
}
| 6,667
|
C++
|
.h
| 156
| 29.564103
| 81
| 0.567979
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,250
|
htclow_service_channel_parser.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_service_channel_parser.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::ctrl {
void ParseServiceChannel(s16 *out_version, impl::ChannelInternalType *out_channels, int *out_num_channels, int max_channels, void *str, size_t str_size);
}
| 869
|
C++
|
.h
| 20
| 41.4
| 157
| 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
|
8,251
|
htclow_ctrl_packet_factory.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_packet_factory.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_ctrl_packet.hpp"
namespace ams::htclow::ctrl {
class HtcctrlPacketFactory {
private:
mem::StandardAllocator *m_allocator;
u32 m_sequence_id;
public:
HtcctrlPacketFactory(mem::StandardAllocator *allocator) : m_allocator(allocator) {
/* Get the current time. */
const u64 time = os::GetSystemTick().GetInt64Value();
/* Set a random sequence id. */
{
util::TinyMT rng;
rng.Initialize(reinterpret_cast<const u32 *>(std::addressof(time)), sizeof(time) / sizeof(u32));
m_sequence_id = rng.GenerateRandomU32();
}
}
public:
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeSuspendPacket();
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeResumePacket();
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeReadyPacket(const void *body, int body_size);
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeInformationPacket(const void *body, int body_size);
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeDisconnectPacket();
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeConnectPacket(const void *body, int body_size);
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeBeaconResponsePacket(const void *body, int body_size);
void Delete(HtcctrlPacket *packet);
private:
std::unique_ptr<HtcctrlPacket, HtcctrlPacketDeleter> MakeSendPacketCommon(int body_size);
};
}
| 2,344
|
C++
|
.h
| 47
| 41.297872
| 123
| 0.67656
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,252
|
htclow_json.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_json.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::ctrl {
class JsonHandler : public rapidjson::BaseReaderHandler<rapidjson::UTF8<char>, JsonHandler>{
private:
enum class State {
Begin = 0,
ParseObject = 1,
ParseServiceChannels = 2,
ParseServiceChannelsArray = 3,
ParseProtocolVersion = 4,
End = 5,
};
private:
State m_state;
s16 *m_version;
const char **m_strings;
int *m_num_strings;
int m_max_strings;
public:
JsonHandler(s16 *vers, const char **str, int *ns, int max) : m_state(State::Begin), m_version(vers), m_strings(str), m_num_strings(ns), m_max_strings(max) { /* ... */ }
bool Key(const Ch *str, rapidjson::SizeType len, bool copy);
bool Uint(unsigned);
bool String(const Ch *, rapidjson::SizeType, bool);
bool StartObject();
bool EndObject(rapidjson::SizeType);
bool StartArray();
bool EndArray(rapidjson::SizeType);
};
}
| 1,860
|
C++
|
.h
| 45
| 33.066667
| 180
| 0.598895
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,253
|
htclow_ctrl_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/ctrl/htclow_ctrl_service.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_ctrl_settings_holder.hpp"
#include "htclow_ctrl_send_buffer.hpp"
#include "htclow_ctrl_state.hpp"
namespace ams::htclow {
namespace ctrl {
class HtcctrlPacketFactory;
class HtcctrlStateMachine;
}
namespace mux {
class Mux;
}
}
namespace ams::htclow::ctrl {
class HtcctrlService {
private:
SettingsHolder m_settings_holder;
char m_beacon_response[0x1000];
char m_information_body[0x1000];
HtcctrlPacketFactory *m_packet_factory;
HtcctrlStateMachine *m_state_machine;
mux::Mux *m_mux;
os::Event m_event;
HtcctrlSendBuffer m_send_buffer;
os::SdkMutex m_mutex;
os::SdkConditionVariable m_condvar;
char m_service_channels_packet[0x1000];
s16 m_version;
private:
const char *GetConnectionType(impl::DriverType driver_type) const;
void UpdateBeaconResponse(const char *connection);
void UpdateInformationBody(const char *status);
void SendInformation();
Result ProcessReceiveConnectPacket();
Result ProcessReceiveReadyPacket(const void *body, size_t body_size);
Result ProcessReceiveSuspendPacket();
Result ProcessReceiveResumePacket();
Result ProcessReceiveDisconnectPacket();
Result ProcessReceiveBeaconQueryPacket();
Result ProcessReceiveUnexpectedPacket();
void ProcessSendConnectPacket();
void ProcessSendReadyPacket();
void ProcessSendSuspendPacket();
void ProcessSendResumePacket();
void ProcessSendDisconnectPacket();
void UpdateServiceChannels(const void *body, size_t body_size);
void PrintServiceChannels(char *dst, size_t dst_size);
void TryReadyInternal();
void DisconnectInternal();
Result SetState(HtcctrlState state);
void ReflectState();
public:
HtcctrlService(HtcctrlPacketFactory *pf, HtcctrlStateMachine *sm, mux::Mux *mux);
void SetDriverType(impl::DriverType driver_type);
os::EventType *GetSendPacketEvent() { return m_event.GetBase(); }
Result CheckReceivedHeader(const HtcctrlPacketHeader &header) const;
Result ProcessReceivePacket(const HtcctrlPacketHeader &header, const void *body, size_t body_size);
bool QuerySendPacket(HtcctrlPacketHeader *header, HtcctrlPacketBody *body, int *out_body_size);
void RemovePacket(const HtcctrlPacketHeader &header);
void TryReady();
void Disconnect();
void Resume();
void Suspend();
void NotifyAwake();
void NotifyAsleep();
Result NotifyDriverConnected();
Result NotifyDriverDisconnected();
};
}
| 3,633
|
C++
|
.h
| 85
| 33.494118
| 111
| 0.664016
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,254
|
htclow_driver_memory_management.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_driver_memory_management.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::driver {
constexpr inline size_t UsbDmaBufferSize = 0x80000;
constexpr inline size_t UsbIndicationThreadStackSize = 16_KB;
void *GetUsbReceiveBuffer();
void *GetUsbSendBuffer();
void *GetUsbIndicationThreadStack();
}
| 940
|
C++
|
.h
| 24
| 36.583333
| 76
| 0.760965
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,255
|
htclow_driver_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_i_driver.hpp"
#include "htclow_socket_driver.hpp"
#include "htclow_usb_driver.hpp"
namespace ams::htclow::driver {
class DriverManager {
private:
util::optional<htclow::impl::DriverType> m_driver_type{};
IDriver *m_debug_driver{};
SocketDriver m_socket_driver;
UsbDriver m_usb_driver{};
/* TODO: PlainChannelDriver m_plain_channel_driver; */
os::SdkMutex m_mutex{};
IDriver *m_open_driver{};
public:
DriverManager(mem::StandardAllocator *allocator) : m_socket_driver(allocator) { /* ... */ }
Result OpenDriver(impl::DriverType driver_type);
void CloseDriver();
impl::DriverType GetDriverType();
IDriver *GetCurrentDriver();
void Cancel();
void SetDebugDriver(IDriver *driver);
};
}
| 1,575
|
C++
|
.h
| 40
| 33.025
| 103
| 0.669941
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,256
|
htclow_socket_discovery_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_socket_discovery_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::driver {
class SocketDiscoveryManager {
private:
bool m_driver_closed;
mem::StandardAllocator *m_allocator;
void *m_thread_stack;
os::ThreadType m_discovery_thread;
s32 m_socket;
public:
SocketDiscoveryManager(mem::StandardAllocator *allocator)
: m_driver_closed(false), m_allocator(allocator), m_thread_stack(allocator->Allocate(os::MemoryPageSize, os::ThreadStackAlignment))
{
/* ... */
}
private:
static void ThreadEntry(void *arg) {
static_cast<SocketDiscoveryManager *>(arg)->ThreadFunc();
}
void ThreadFunc();
Result DoDiscovery();
public:
void OnDriverOpen();
void OnDriverClose();
void OnSocketAcceptBegin(u16 port);
void OnSocketAcceptEnd();
};
}
| 1,640
|
C++
|
.h
| 44
| 29.477273
| 147
| 0.642363
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,257
|
htclow_usb_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_usb_driver.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_i_driver.hpp"
#include "htclow_usb_impl.hpp"
namespace ams::htclow::driver {
class UsbDriver final : public IDriver {
private:
bool m_connected;
os::Event m_event;
public:
UsbDriver() : m_connected(false), m_event(os::EventClearMode_ManualClear) { /* ... */ }
public:
static void OnUsbAvailabilityChange(UsbAvailability availability, void *param);
public:
virtual Result Open() override;
virtual void Close() override;
virtual Result Connect(os::EventType *event) override;
virtual void Shutdown() override;
virtual Result Send(const void *src, int src_size) override;
virtual Result Receive(void *dst, int dst_size) override;
virtual void CancelSendReceive() override;
virtual void Suspend() override;
virtual void Resume() override;
};
}
| 1,632
|
C++
|
.h
| 40
| 34.475
| 99
| 0.679673
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,258
|
htclow_usb_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_usb_impl.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::driver {
enum UsbAvailability {
UsbAvailability_Unavailable = 1,
UsbAvailability_Available = 2,
UsbAvailability_Unknown = 3,
};
using UsbAvailabilityChangeCallback = void (*)(UsbAvailability availability, void *param);
void SetUsbAvailabilityChangeCallback(UsbAvailabilityChangeCallback callback, void *param);
void ClearUsbAvailabilityChangeCallback();
Result InitializeUsbInterface();
void FinalizeUsbInterface();
Result SendUsb(int *out_transferred, const void *src, int src_size);
Result ReceiveUsb(int *out_transferred, void *dst, int dst_size);
void CancelUsbSendReceive();
}
| 1,360
|
C++
|
.h
| 32
| 38.78125
| 95
| 0.751327
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,259
|
htclow_socket_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_socket_driver.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_i_driver.hpp"
#include "htclow_socket_discovery_manager.hpp"
namespace ams::htclow::driver {
class SocketDriver final : public IDriver {
private:
mem::StandardAllocator *m_allocator;
SocketDiscoveryManager m_discovery_manager;
socket::SockAddrIn m_server_sockaddr;
socket::SockAddrIn m_saved_server_sockaddr;
socket::SockAddrIn m_saved_client_sockaddr;
os::Event m_event;
Result m_connect_result;
os::SdkMutex m_mutex;
s32 m_server_socket;
s32 m_client_socket;
bool m_server_socket_valid;
bool m_client_socket_valid;
bool m_auto_connect_reserved;
public:
SocketDriver(mem::StandardAllocator *allocator)
: m_allocator(allocator), m_discovery_manager(m_allocator), m_event(os::EventClearMode_ManualClear),
m_connect_result(), m_mutex(), m_server_socket(), m_client_socket(), m_server_socket_valid(false),
m_client_socket_valid(false), m_auto_connect_reserved(false)
{
/* ... */
}
private:
static void ConnectThreadEntry(void *arg) {
auto * const driver = static_cast<SocketDriver *>(arg);
driver->m_connect_result = driver->ConnectThread();
driver->m_event.Signal();
}
Result ConnectThread();
private:
Result CreateServerSocket();
void DestroyServerSocket();
Result SetupClientSocket(s32 desc);
bool IsAutoConnectReserved();
void ReserveAutoConnect();
void DoAutoConnect();
public:
virtual Result Open() override;
virtual void Close() override;
virtual Result Connect(os::EventType *event) override;
virtual void Shutdown() override;
virtual Result Send(const void *src, int src_size) override;
virtual Result Receive(void *dst, int dst_size) override;
virtual void CancelSendReceive() override;
virtual void Suspend() override;
virtual void Resume() override;
};
}
| 2,936
|
C++
|
.h
| 69
| 32.956522
| 116
| 0.63042
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,260
|
htclow_socket_discovery_util.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_socket_discovery_util.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::driver {
constexpr inline u8 TmipcVersion = 5;
struct TmipcHeader {
u32 service_id;
u32 reserved_00;
u16 reserved_01;
u8 reserved_02;
u8 version;
u32 data_len;
u32 reserved[4];
};
static_assert(util::is_pod<TmipcHeader>::value);
static_assert(sizeof(TmipcHeader) == 0x20);
s32 MakeAutoConnectIpv4RequestPacket(char *dst, size_t dst_size, const socket::SockAddrIn &sockaddr);
s32 MakeBeaconResponsePacket(char *dst, size_t dst_size);
}
| 1,225
|
C++
|
.h
| 33
| 33
| 105
| 0.717776
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,261
|
htclow_i_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/driver/htclow_i_driver.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::driver {
class IDriver {
public:
virtual Result Open() = 0;
virtual void Close() = 0;
virtual Result Connect(os::EventType *event) = 0;
virtual void Shutdown() = 0;
virtual Result Send(const void *src, int src_size) = 0;
virtual Result Receive(void *dst, int dst_size) = 0;
virtual void CancelSendReceive() = 0;
virtual void Suspend() = 0;
virtual void Resume() = 0;
};
}
| 1,368
|
C++
|
.h
| 31
| 38.580645
| 76
| 0.583958
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,262
|
htclow_mux_task_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_task_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::mux {
constexpr inline int MaxTaskCount = 0x80;
enum EventTrigger : u8 {
EventTrigger_Disconnect = 1,
EventTrigger_ReceiveData = 2,
EventTrigger_SendComplete = 4,
EventTrigger_SendReady = 5,
EventTrigger_SendBufferEmpty = 10,
EventTrigger_ConnectReady = 11,
};
class TaskManager {
private:
enum TaskType : u8 {
TaskType_Receive = 0,
TaskType_Send = 1,
TaskType_Flush = 6,
TaskType_Connect = 7,
};
struct Task {
impl::ChannelInternalType channel;
os::EventType event;
bool has_event_trigger;
EventTrigger event_trigger;
TaskType type;
size_t size;
};
private:
bool m_valid[MaxTaskCount];
Task m_tasks[MaxTaskCount];
public:
TaskManager() : m_valid() { /* ... */ }
Result AllocateTask(u32 *out_task_id, impl::ChannelInternalType channel);
void FreeTask(u32 task_id);
os::EventType *GetTaskEvent(u32 task_id);
EventTrigger GetTrigger(u32 task_id);
void ConfigureConnectTask(u32 task_id);
void ConfigureFlushTask(u32 task_id);
void ConfigureReceiveTask(u32 task_id, size_t size);
void ConfigureSendTask(u32 task_id);
void NotifyDisconnect(impl::ChannelInternalType channel);
void NotifyReceiveData(impl::ChannelInternalType channel, size_t size);
void NotifySendReady();
void NotifySendBufferEmpty(impl::ChannelInternalType channel);
void NotifyConnectReady();
void CompleteTask(int index, EventTrigger trigger);
};
}
| 2,558
|
C++
|
.h
| 64
| 30.703125
| 85
| 0.621023
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,263
|
htclow_mux_channel_impl_map.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_mux_channel_impl.hpp"
namespace ams::htclow::mux {
class ChannelImplMap {
NON_COPYABLE(ChannelImplMap);
NON_MOVEABLE(ChannelImplMap);
public:
static constexpr int MaxChannelCount = 64;
using MapType = util::FixedMap<impl::ChannelInternalType, int>;
static constexpr size_t MapRequiredMemorySize = MapType::GetRequiredMemorySize(MaxChannelCount);
private:
PacketFactory *m_packet_factory;
ctrl::HtcctrlStateMachine *m_state_machine;
TaskManager *m_task_manager;
os::Event *m_event;
u8 m_map_buffer[MapRequiredMemorySize];
MapType m_map;
util::TypedStorage<ChannelImpl> m_channel_storage[MaxChannelCount];
bool m_storage_valid[MaxChannelCount];
public:
ChannelImplMap(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::Event *ev);
ChannelImpl &GetChannelImpl(int index);
ChannelImpl &GetChannelImpl(impl::ChannelInternalType channel);
bool Exists(impl::ChannelInternalType channel) const {
return m_map.find(channel) != m_map.end();
}
Result AddChannel(impl::ChannelInternalType channel);
Result RemoveChannel(impl::ChannelInternalType channel);
private:
public:
MapType &GetMap() {
return m_map;
}
ChannelImpl &operator[](int index) {
return this->GetChannelImpl(index);
}
};
}
| 2,275
|
C++
|
.h
| 54
| 33.740741
| 109
| 0.662297
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,264
|
htclow_mux_global_send_buffer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_global_send_buffer.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "../htclow_packet.hpp"
namespace ams::htclow {
class PacketFactory;
}
namespace ams::htclow::mux {
class GlobalSendBuffer {
private:
using PacketList = util::IntrusiveListBaseTraits<Packet>::ListType;
private:
PacketFactory *m_packet_factory;
PacketList m_packet_list;
public:
GlobalSendBuffer(PacketFactory *pf) : m_packet_factory(pf), m_packet_list() { /* ... */ }
Packet *GetNextPacket();
Result AddPacket(std::unique_ptr<Packet, PacketDeleter> ptr);
void RemovePacket();
};
}
| 1,293
|
C++
|
.h
| 35
| 31.885714
| 101
| 0.6936
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,265
|
htclow_mux_ring_buffer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_ring_buffer.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::htclow::mux {
class RingBuffer {
private:
void *m_buffer;
void *m_read_only_buffer;
bool m_is_read_only;
size_t m_buffer_size;
size_t m_data_size;
size_t m_offset;
bool m_can_discard;
public:
RingBuffer() : m_buffer(), m_read_only_buffer(), m_is_read_only(true), m_buffer_size(), m_data_size(), m_offset(), m_can_discard(false) { /* ... */ }
void Initialize(void *buffer, size_t buffer_size);
void InitializeForReadOnly(const void *buffer, size_t buffer_size);
void Clear();
size_t GetBufferSize() { return m_buffer_size; }
size_t GetDataSize() { return m_data_size; }
Result Read(void *dst, size_t size);
Result Write(const void *data, size_t size);
Result Copy(void *dst, size_t size);
Result Discard(size_t size);
};
}
| 1,650
|
C++
|
.h
| 40
| 33.975
| 161
| 0.635853
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,266
|
htclow_mux_channel_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_mux_task_manager.hpp"
#include "htclow_mux_send_buffer.hpp"
namespace ams::htclow {
class PacketFactory;
namespace ctrl {
class HtcctrlStateMachine;
}
}
namespace ams::htclow::mux {
class ChannelImpl {
private:
impl::ChannelInternalType m_channel;
PacketFactory *m_packet_factory;
ctrl::HtcctrlStateMachine *m_state_machine;
TaskManager *m_task_manager;
os::Event *m_event;
SendBuffer m_send_buffer;
RingBuffer m_receive_buffer;
s16 m_version;
ChannelConfig m_config;
u64 m_offset;
u64 m_total_send_size;
u64 m_cur_max_data;
u64 m_prev_max_data;
util::optional<u64> m_share;
os::Event m_state_change_event;
ChannelState m_state;
public:
ChannelImpl(impl::ChannelInternalType channel, PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::Event *ev);
void SetVersion(s16 version);
ChannelState GetChannelState() { return m_state; }
os::EventType *GetChannelStateEvent() { return m_state_change_event.GetBase(); }
Result ProcessReceivePacket(const PacketHeader &header, const void *body, size_t body_size);
bool QuerySendPacket(PacketHeader *header, PacketBody *body, int *out_body_size);
void RemovePacket(const PacketHeader &header);
void ShutdownForce();
void UpdateState();
public:
Result DoConnectBegin(u32 *out_task_id);
Result DoConnectEnd();
Result DoFlush(u32 *out_task_id);
Result DoReceiveBegin(u32 *out_task_id, size_t size);
Result DoReceiveEnd(size_t *out, void *dst, size_t dst_size);
Result DoSend(u32 *out_task_id, size_t *out, const void *src, size_t src_size);
Result DoShutdown();
void SetConfig(const ChannelConfig &config);
void SetSendBuffer(void *buf, size_t buf_size, size_t max_packet_size);
void SetReceiveBuffer(void *buf, size_t buf_size);
void SetSendBufferWithData(const void *buf, size_t buf_size, size_t max_packet_size);
private:
void SetState(ChannelState state);
void SetStateWithoutCheck(ChannelState state);
void SignalSendPacketEvent();
Result CheckState(std::initializer_list<ChannelState> states) const;
Result CheckPacketVersion(s16 version) const;
Result ProcessReceiveDataPacket(s16 version, u64 share, u32 offset, const void *body, size_t body_size);
Result ProcessReceiveMaxDataPacket(s16 version, u64 share);
Result ProcessReceiveErrorPacket();
};
}
| 3,518
|
C++
|
.h
| 77
| 36.545455
| 141
| 0.657201
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,267
|
htclow_mux_send_buffer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux_send_buffer.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "../htclow_packet.hpp"
#include "htclow_mux_ring_buffer.hpp"
namespace ams::htclow {
class PacketFactory;
}
namespace ams::htclow::mux {
class SendBuffer {
private:
using PacketList = util::IntrusiveListBaseTraits<Packet>::ListType;
private:
impl::ChannelInternalType m_channel;
PacketFactory *m_packet_factory;
RingBuffer m_ring_buffer;
PacketList m_packet_list;
s16 m_version;
bool m_flow_control_enabled;
size_t m_max_packet_size;
private:
bool IsPriorPacket(PacketType packet_type) const;
void MakeDataPacketHeader(PacketHeader *header, int body_size, s16 version, u64 share, u32 offset) const;
void CopyPacket(PacketHeader *header, PacketBody *body, int *out_body_size, const Packet &packet);
public:
SendBuffer(impl::ChannelInternalType channel, PacketFactory *pf);
~SendBuffer();
void SetVersion(s16 version);
void SetFlowControlEnabled(bool en);
bool QueryNextPacket(PacketHeader *header, PacketBody *body, int *out_body_size, u64 max_data, u64 total_send_size, bool has_share, u64 share);
void AddPacket(std::unique_ptr<Packet, PacketDeleter> ptr);
void RemovePacket(const PacketHeader &header);
size_t AddData(const void *data, size_t size);
void SetBuffer(void *buffer, size_t buffer_size);
void SetReadOnlyBuffer(const void *buffer, size_t buffer_size);
void SetMaxPacketSize(size_t max_packet_size);
bool Empty();
void Clear();
};
}
| 2,378
|
C++
|
.h
| 54
| 36.351852
| 155
| 0.675617
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
8,268
|
htclow_mux.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/source/htclow/mux/htclow_mux.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htclow_mux_task_manager.hpp"
#include "htclow_mux_channel_impl_map.hpp"
#include "htclow_mux_global_send_buffer.hpp"
namespace ams::htclow::mux {
enum class MuxState {
Normal,
Sleep,
};
class Mux {
private:
private:
PacketFactory *m_packet_factory;
ctrl::HtcctrlStateMachine *m_state_machine;
TaskManager m_task_manager;
os::Event m_event;
ChannelImplMap m_channel_impl_map;
GlobalSendBuffer m_global_send_buffer;
os::SdkMutex m_mutex;
MuxState m_state;
s16 m_version;
public:
Mux(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm);
void SetVersion(u16 version);
os::EventType *GetSendPacketEvent() { return m_event.GetBase(); }
Result CheckReceivedHeader(const PacketHeader &header) const;
Result ProcessReceivePacket(const PacketHeader &header, const void *body, size_t body_size);
bool QuerySendPacket(PacketHeader *header, PacketBody *body, int *out_body_size);
void RemovePacket(const PacketHeader &header);
void UpdateChannelState();
void UpdateMuxState();
public:
Result Open(impl::ChannelInternalType channel);
Result Close(impl::ChannelInternalType channel);
Result ConnectBegin(u32 *out_task_id, impl::ChannelInternalType channel);
Result ConnectEnd(impl::ChannelInternalType channel, u32 task_id);
ChannelState GetChannelState(impl::ChannelInternalType channel);
os::EventType *GetChannelStateEvent(impl::ChannelInternalType channel);
Result FlushBegin(u32 *out_task_id, impl::ChannelInternalType channel);
Result FlushEnd(u32 task_id);
os::EventType *GetTaskEvent(u32 task_id);
Result ReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size);
Result ReceiveEnd(size_t *out, void *dst, size_t dst_size, impl::ChannelInternalType channel, u32 task_id);
Result SendBegin(u32 *out_task_id, size_t *out, const void *src, size_t src_size, impl::ChannelInternalType channel);
Result SendEnd(u32 task_id);
Result WaitReceiveBegin(u32 *out_task_id, impl::ChannelInternalType channel, size_t size);
Result WaitReceiveEnd(u32 task_id);
void SetConfig(impl::ChannelInternalType channel, const ChannelConfig &config);
void SetSendBuffer(impl::ChannelInternalType channel, void *buf, size_t buf_size, size_t max_packet_size);
void SetReceiveBuffer(impl::ChannelInternalType channel, void *buf, size_t buf_size);
void SetSendBufferWithData(impl::ChannelInternalType channel, const void *buf, size_t buf_size, size_t max_packet_size);
Result Shutdown(impl::ChannelInternalType channel);
private:
Result CheckChannelExist(impl::ChannelInternalType channel);
Result SendErrorPacket(impl::ChannelInternalType channel);
bool IsSendable(PacketType packet_type) const;
};
}
| 3,856
|
C++
|
.h
| 74
| 43.013514
| 132
| 0.684127
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.