id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,634
|
powctl_session_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/powctl_session_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/powctl/powctl_types.hpp>
namespace ams::powctl {
namespace impl {
class SessionImpl : public ::ams::ddsf::ISession {
NON_COPYABLE(SessionImpl);
NON_MOVEABLE(SessionImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::SessionImpl, ::ams::ddsf::ISession);
public:
SessionImpl() : ISession() { /* ... */ }
~SessionImpl() { ddsf::CloseSession(this); }
};
}
struct Session {
bool has_session;
util::TypedStorage<impl::SessionImpl> impl_storage;
struct ConstantInitializeTag{};
constexpr Session(ConstantInitializeTag) : has_session(false), impl_storage() { /* ... */ }
Session() : has_session(false) { /* ... */ }
};
Result OpenSession(Session *out, DeviceCode device_code, ddsf::AccessMode access_mode);
void CloseSession(Session &session);
}
| 1,602
|
C++
|
.h
| 39
| 35.333333
| 99
| 0.673325
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,635
|
powctl_battery_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/powctl_battery_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/powctl/powctl_types.hpp>
#include <stratosphere/powctl/powctl_session_api.hpp>
namespace ams::powctl {
/* Battery API. */
Result GetBatteryChargePercentage(float *out_percent, Session &session);
Result GetBatteryVoltageFuelGaugePercentage(float *out_percent, Session &session);
Result GetBatteryFullCapacity(int *out_mah, Session &session);
Result GetBatteryRemainingCapacity(int *out_mah, Session &session);
Result SetBatteryChargePercentageMinimumAlertThreshold(Session &session, float percentage);
Result SetBatteryChargePercentageMaximumAlertThreshold(Session &session, float percentage);
Result SetBatteryVoltageFuelGaugePercentageMinimumAlertThreshold(Session &session, float percentage);
Result SetBatteryVoltageFuelGaugePercentageMaximumAlertThreshold(Session &session, float percentage);
Result SetBatteryFullChargeThreshold(Session &session, float percentage);
Result GetBatteryAverageCurrent(int *out_ma, Session &session);
Result GetBatteryCurrent(int *out_ma, Session &session);
Result GetBatteryInternalState(void *dst, size_t *out_size, Session &session, size_t dst_size);
Result SetBatteryInternalState(Session &session, const void *src, size_t src_size);
Result GetBatteryNeedToRestoreParameters(bool *out, Session &session);
Result SetBatteryNeedToRestoreParameters(Session &session, bool en);
Result IsBatteryI2cShutdownEnabled(bool *out, Session &session);
Result SetBatteryI2cShutdownEnabled(Session &session, bool en);
Result IsBatteryPresent(bool *out, Session &session);
Result GetBatteryCycles(int *out, Session &session);
Result SetBatteryCycles(Session &session, int cycles);
Result GetBatteryAge(float *out_percent, Session &session);
Result GetBatteryTemperature(float *out_c, Session &session);
Result GetBatteryMaximumTemperature(float *out_c, Session &session);
Result SetBatteryTemperatureMinimumAlertThreshold(Session &session, float c);
Result SetBatteryTemperatureMaximumAlertThreshold(Session &session, float c);
Result GetBatteryVCell(int *out_mv, Session &session);
Result GetBatteryAverageVCell(int *out_mv, Session &session);
Result GetBatteryAverageVCellTime(TimeSpan *out, Session &session);
Result GetBatteryOpenCircuitVoltage(int *out_mv, Session &session);
Result SetBatteryVoltageMinimumAlertThreshold(Session &session, int mv);
Result SetBatteryVoltageMaximumAlertThreshold(Session &session, int mv);
}
| 3,194
|
C++
|
.h
| 53
| 56.188679
| 105
| 0.79359
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,636
|
powctl_battery_charge_percentage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/impl/powctl_battery_charge_percentage.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/powctl/powctl_types.hpp>
namespace ams::powctl::impl {
constexpr inline const double MinRawDefaultPercentage = 3.0;
constexpr inline const double MaxRawDefaultPercentage = 99.0;
constexpr inline const double MinRawThresholdPercentage = 11.0;
constexpr inline const int MinDisplayPercentage = 1;
constexpr inline const int MaxDisplayPercentage = 100;
constexpr inline void CalculateMarginatedRawPercentage(double *out_marginated_min, double *out_marginated_max, double min, double max) {
/* Ensure minimum is in correct range. */
min = std::max(std::min(min, MinRawThresholdPercentage), MinRawDefaultPercentage);
/* Calculate the marginated values. */
constexpr const double MinMarginPercentage = 0.93359375;
constexpr const double MaxMarginPercentage = -0.83593750;
const auto margin_factor = (max - min) / (MaxRawDefaultPercentage - MinRawDefaultPercentage);
*out_marginated_min = min + MinMarginPercentage * margin_factor;
*out_marginated_max = max + MaxMarginPercentage * margin_factor;
}
constexpr inline int GetDisplayPercentage(double raw_percentage, double min, double max) {
/* Calculate the display percentage. */
constexpr const double BaseDisplayPercentage = 2.0;
const auto display_percentage = BaseDisplayPercentage + ((static_cast<double>(MaxDisplayPercentage - BaseDisplayPercentage) * (raw_percentage - min)) / (max - min));
/* Clamp the display percentage within bounds. */
return std::max(std::min(static_cast<int>(display_percentage), MaxDisplayPercentage), MinDisplayPercentage);
}
constexpr inline int ConvertBatteryChargePercentage(double raw_percentage, double min, double max) {
/* Marginate the min/max. */
double marginated_min = 0.0, marginated_max = 0.0;
CalculateMarginatedRawPercentage(std::addressof(marginated_min), std::addressof(marginated_max), min, max);
/* Convert to display percentage. */
return GetDisplayPercentage(raw_percentage, marginated_min, marginated_max);
}
constexpr inline int ConvertBatteryChargePercentage(double raw_percentage) {
return ConvertBatteryChargePercentage(raw_percentage, MinRawDefaultPercentage, MaxRawDefaultPercentage);
}
}
| 3,004
|
C++
|
.h
| 52
| 52.326923
| 173
| 0.744131
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,637
|
powctl_driver_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/driver/powctl_driver_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/powctl/powctl_types.hpp>
namespace ams::powctl {
void Initialize(bool enable_interrupt_handlers);
void Finalize();
}
| 822
|
C++
|
.h
| 22
| 35.227273
| 76
| 0.760351
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,638
|
powctl_charger_parameters.generic.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charger_parameters.generic.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/powctl/powctl_types.hpp>
namespace ams::powctl::driver::impl {
struct ChargeParametersRule {
/* ... */
};
struct UnknownParameterX {
/* ... */
};
struct ChargeParameters {
/* ... */
};
}
| 934
|
C++
|
.h
| 29
| 28.896552
| 76
| 0.704444
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,639
|
powctl_charge_arbiter.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charge_arbiter.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/powctl/powctl_types.hpp>
#include <stratosphere/powctl/driver/impl/powctl_select_charger_parameters.hpp>
namespace ams::powctl::driver::impl {
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
class ChargeArbiter {
private:
const ChargeParametersRule *m_rules;
size_t m_num_rules;
int m_charge_voltage_limit;
BatteryTemperatureLevel m_temperature_level;
int m_avg_v_cell;
float m_voltage_fuel_gauge_percentage;
bool m_has_battery_done_current;
int m_battery_done_current;
PowerState m_power_state;
const ChargeParametersRule *m_selected_rule;
bool m_check_battery_done_current;
private:
static constexpr bool IsInRange(int value, int min, int max) {
if (!(min <= value)) {
return false;
}
if (max == std::numeric_limits<int>::max()) {
return value <= max;
} else {
return value < max;
}
}
static constexpr bool IsInRangeFloat(float value, float min, float max) {
if (!(min <= value)) {
return false;
}
if (max == std::numeric_limits<float>::max()) {
return value <= max;
} else {
return value < max;
}
}
bool IsAcceptablePowerState(const PowerState *acceptable, size_t num_acceptable) const {
for (size_t i = 0; i < num_acceptable; ++i) {
if (m_power_state == acceptable[i]) {
return true;
}
}
return false;
}
public:
ChargeArbiter(const ChargeParametersRule *r, size_t nr, int cvl)
: m_rules(r), m_num_rules(nr), m_charge_voltage_limit(cvl), m_temperature_level(BatteryTemperatureLevel::Medium),
m_avg_v_cell(4080), m_voltage_fuel_gauge_percentage(25.0), m_has_battery_done_current(false), m_battery_done_current(0),
m_power_state(PowerState::FullAwake), m_selected_rule(nullptr), m_check_battery_done_current(false)
{
this->UpdateSelectedRule();
}
void SetBatteryTemperatureLevel(BatteryTemperatureLevel btl) {
m_temperature_level = btl;
this->UpdateSelectedRule();
}
void SetBatteryAverageVCell(int avg) {
m_avg_v_cell = avg;
this->UpdateSelectedRule();
}
void SetBatteryVoltageFuelGaugePercentage(float pct) {
m_voltage_fuel_gauge_percentage = pct;
this->UpdateSelectedRule();
}
void SetBatteryDoneCurrent(int current) {
m_battery_done_current = current;
m_has_battery_done_current = true;
this->UpdateSelectedRule();
}
void SetPowerState(PowerState ps) {
m_power_state = ps;
this->UpdateSelectedRule();
}
int GetChargeVoltageLimit() const {
return m_charge_voltage_limit;
}
bool IsBatteryDoneCurrentAcceptable(int current) const {
const auto *rule = this->GetSelectedRule();
AMS_ASSERT(rule != nullptr);
return IsInRange(current, rule->min_battery_done_current, rule->max_battery_done_current);
}
const ChargeParametersRule *GetSelectedRule() const {
return m_selected_rule;
}
void UpdateSelectedRule() {
/* Try to find an entry that fits our current requirements. */
const ChargeParametersRule *best_rule = nullptr;
for (size_t i = 0; i < m_num_rules; ++i) {
/* Get the current rule. */
const ChargeParametersRule &cur_rule = m_rules[i];
/* Check the temperature level. */
if (m_temperature_level != cur_rule.temperature_level) {
continue;
}
/* Check that average voltage is in range. */
if (!IsInRange(m_avg_v_cell, cur_rule.min_avg_v_cell, cur_rule.max_avg_v_cell)) {
continue;
}
/* Check that voltage fuel gauge percentage is in range. */
if (!IsInRangeFloat(m_voltage_fuel_gauge_percentage, cur_rule.min_voltage_fuel_gauge_percentage, cur_rule.max_voltage_fuel_gauge_percentage)) {
continue;
}
/* Check if our power state is acceptable. */
if (!this->IsAcceptablePowerState(cur_rule.acceptable_power_states, cur_rule.num_acceptable_power_states)) {
continue;
}
/* The limit is probably acceptable. */
if (m_selected_rule != std::addressof(cur_rule)) {
/* We're selecting a new rule. Check if our need to deal with battery current is acceptable. */
if (cur_rule.check_battery_current && m_check_battery_done_current) {
continue;
}
/* Determine whether we should check battery done current. */
bool check_battery_done_current;
if (m_selected_rule != nullptr && m_selected_rule->check_battery_current) {
if (m_selected_rule->temperature_level == m_temperature_level &&
IsInRange(m_avg_v_cell, m_selected_rule->min_avg_v_cell, m_selected_rule->max_avg_v_cell) &&
IsInRangeFloat(m_voltage_fuel_gauge_percentage, m_selected_rule->min_voltage_fuel_gauge_percentage, m_selected_rule->max_voltage_fuel_gauge_percentage))
{
check_battery_done_current = m_has_battery_done_current && !IsInRange(m_battery_done_current, m_selected_rule->min_battery_done_current, m_selected_rule->max_battery_done_current);
} else {
check_battery_done_current = true;
}
} else {
check_battery_done_current = false;
}
/* Set whether we need to check the battery done current. */
m_has_battery_done_current = false;
m_check_battery_done_current |= check_battery_done_current;
} else {
/* We're selecting the currently selected rule. Make sure the battery done current is acceptable if we have one. */
if (m_has_battery_done_current && !IsInRange(m_battery_done_current, cur_rule.min_battery_done_current, cur_rule.max_battery_done_current)) {
continue;
}
}
/* Select the current rule. */
best_rule = std::addressof(cur_rule);
break;
}
/* Update our selected rule. */
m_selected_rule = best_rule;
}
};
#endif
}
| 8,289
|
C++
|
.h
| 164
| 34.152439
| 212
| 0.530559
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,640
|
powctl_select_charger_parameters.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_select_charger_parameters.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/powctl/powctl_types.hpp>
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
#include <stratosphere/powctl/driver/impl/powctl_charger_parameters.board.nintendo_nx.hpp>
#else
#include <stratosphere/powctl/driver/impl/powctl_charger_parameters.generic.hpp>
#endif
| 954
|
C++
|
.h
| 23
| 39.521739
| 94
| 0.77551
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,641
|
powctl_charger_parameters.board.nintendo_nx.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charger_parameters.board.nintendo_nx.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/powctl/powctl_types.hpp>
namespace ams::powctl::driver::impl {
struct ChargeParametersRule {
BatteryTemperatureLevel temperature_level;
int min_avg_v_cell;
int max_avg_v_cell;
int min_battery_done_current;
int max_battery_done_current;
float min_unknown_14;
float max_unknown_18;
float min_voltage_fuel_gauge_percentage;
float max_voltage_fuel_gauge_percentage;
const PowerState *acceptable_power_states;
size_t num_acceptable_power_states;
bool check_battery_current;
bool reinitialize_charger;
int charge_voltage_limit;
int fast_charge_current_limit;
int battery_compensation;
int voltage_clamp;
};
struct UnknownParameterX {
int _00;
int _04;
double _08;
double _10;
};
struct ChargeParameters {
int temp_min;
int temp_low;
int temp_high;
int temp_max;
int low_voltage_fast_charge_current_limit;
int default_charge_voltage_limit;
const UnknownParameterX *unknown_x_table;
size_t x_table_size;
double _28;
double _30;
const ChargeParametersRule *rules;
size_t num_rules;
};
const ChargeParameters &GetChargeParameters();
}
| 2,017
|
C++
|
.h
| 60
| 27.416667
| 76
| 0.678626
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,642
|
mem_standard_allocator.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mem/mem_standard_allocator.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/os.hpp>
#include <stratosphere/mem/impl/mem_impl_declarations.hpp>
namespace ams::mem {
class StandardAllocator {
NON_COPYABLE(StandardAllocator);
NON_MOVEABLE(StandardAllocator);
public:
using WalkCallback = int (*)(void *ptr, size_t size, void *user_data);
struct AllocatorHash {
size_t allocated_count;
size_t allocated_size;
size_t hash;
};
private:
bool m_initialized;
bool m_enable_thread_cache;
uintptr_t m_unused;
os::TlsSlot m_tls_slot;
impl::InternalCentralHeapStorage m_central_heap_storage;
public:
StandardAllocator();
StandardAllocator(void *mem, size_t size);
StandardAllocator(void *mem, size_t size, bool enable_cache);
~StandardAllocator() {
if (m_initialized) {
this->Finalize();
}
}
void Initialize(void *mem, size_t size);
void Initialize(void *mem, size_t size, bool enable_cache);
void Finalize();
void *Allocate(size_t size);
void *Allocate(size_t size, size_t alignment);
void Free(void *ptr);
void *Reallocate(void *ptr, size_t new_size);
size_t Shrink(void *ptr, size_t new_size);
void ClearThreadCache() const;
void CleanUpManagementArea() const;
size_t GetSizeOf(const void *ptr) const;
size_t GetTotalFreeSize() const;
size_t GetAllocatableSize() const;
void WalkAllocatedBlocks(WalkCallback callback, void *user_data) const;
void Dump() const;
AllocatorHash Hash() const;
};
}
| 2,486
|
C++
|
.h
| 62
| 30.693548
| 83
| 0.618317
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,643
|
mem_impl_common.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mem/impl/mem_impl_common.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <errno.h>
namespace ams::mem::impl {
constexpr inline size_t MaxSize = static_cast<size_t>(std::numeric_limits<s64>::max());
using errno_t = int;
enum DumpMode {
DumpMode_Basic = (0 << 0),
DumpMode_Spans = (1 << 0),
DumpMode_Pointers = (1 << 1),
DumpMode_Pages = (1 << 2),
DumpMode_All = (DumpMode_Pages | DumpMode_Pointers | DumpMode_Spans | DumpMode_Basic),
};
enum AllocQuery {
AllocQuery_Dump = 0,
AllocQuery_PageSize = 1,
AllocQuery_AllocatedSize = 2,
AllocQuery_FreeSize = 3,
AllocQuery_SystemSize = 4,
AllocQuery_MaxAllocatableSize = 5,
AllocQuery_IsClean = 6,
AllocQuery_HeapHash = 7,
AllocQuery_UnifyFreeList = 8,
AllocQuery_SetColor = 9,
AllocQuery_GetColor = 10,
AllocQuery_SetName = 11,
AllocQuery_GetName = 12,
/* AllocQuery_Thirteen = 13, */
AllocQuery_CheckCache = 14,
AllocQuery_ClearCache = 15,
AllocQuery_FinalizeCache = 16,
AllocQuery_FreeSizeMapped = 17,
AllocQuery_MaxAllocatableSizeMapped = 18,
AllocQuery_DumpJson = 19,
};
enum HeapOption {
HeapOption_UseEnvironment = (1 << 0),
HeapOption_DisableCache = (1 << 2),
};
struct HeapHash {
size_t alloc_count;
size_t alloc_size;
size_t hash;
};
static_assert(util::is_pod<HeapHash>::value);
}
| 2,435
|
C++
|
.h
| 61
| 33.885246
| 99
| 0.569556
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,644
|
mem_impl_heap.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mem/impl/mem_impl_heap.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/mem/impl/mem_impl_common.hpp>
#include <stratosphere/mem/impl/heap/mem_impl_heap_cached_heap.hpp>
#include <stratosphere/mem/impl/heap/mem_impl_heap_central_heap.hpp>
| 840
|
C++
|
.h
| 19
| 42.368421
| 76
| 0.769231
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,645
|
mem_impl_declarations.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mem/impl/mem_impl_declarations.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
namespace ams::mem::impl {
namespace heap {
class CentralHeap;
}
using InternalCentralHeapStorage = ::ams::util::TypedStorage<::ams::mem::impl::heap::CentralHeap, sizeof(void *) * 6, alignof(void *)>;
}
| 877
|
C++
|
.h
| 22
| 37.045455
| 139
| 0.734982
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,646
|
mem_impl_heap_cached_heap.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_cached_heap.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/mem/impl/mem_impl_common.hpp>
namespace ams::mem::impl::heap {
class TlsHeapCache;
class CachedHeap final {
NON_COPYABLE(CachedHeap);
private:
TlsHeapCache *m_tls_heap_cache;
public:
constexpr CachedHeap() : m_tls_heap_cache() { /* ... */ }
~CachedHeap() { this->Finalize(); }
ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : m_tls_heap_cache(rhs.m_tls_heap_cache) {
rhs.m_tls_heap_cache = nullptr;
}
ALWAYS_INLINE CachedHeap &operator=(CachedHeap &&rhs) {
this->Reset();
m_tls_heap_cache = rhs.m_tls_heap_cache;
rhs.m_tls_heap_cache = nullptr;
return *this;
}
void *Allocate(size_t n);
void *Allocate(size_t n, size_t align);
size_t GetAllocationSize(const void *ptr);
errno_t Free(void *p);
errno_t FreeWithSize(void *p, size_t size);
errno_t Reallocate(void *ptr, size_t size, void **p);
errno_t Shrink(void *ptr, size_t size);
void ReleaseAllCache();
void Finalize();
bool CheckCache();
errno_t QueryV(int query, std::va_list vl);
errno_t Query(int query, ...);
void Reset() { this->Finalize(); }
void Reset(TlsHeapCache *thc);
TlsHeapCache *Release();
constexpr explicit ALWAYS_INLINE operator bool() const { return m_tls_heap_cache != nullptr; }
};
}
| 2,251
|
C++
|
.h
| 54
| 33
| 106
| 0.610146
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,647
|
mem_impl_heap_central_heap.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_central_heap.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/mem/impl/mem_impl_common.hpp>
#include <stratosphere/mem/impl/mem_impl_declarations.hpp>
namespace ams::mem::impl::heap {
class CachedHeap;
class TlsHeapCentral;
using HeapWalkCallback = int (*)(void *ptr, size_t size, void *user_data);
class CentralHeap final {
NON_COPYABLE(CentralHeap);
NON_MOVEABLE(CentralHeap);
public:
static constexpr size_t PageSize = 4_KB;
static constexpr size_t MinimumAlignment = alignof(u64);
using DestructorHandler = void (*)(void *start, void *end);
private:
TlsHeapCentral *m_tls_heap_central;
bool m_use_virtual_memory;
u32 m_option;
u8 *m_start;
u8 *m_end;
public:
constexpr CentralHeap() : m_tls_heap_central(), m_use_virtual_memory(), m_option(), m_start(), m_end() { /* ... */ }
~CentralHeap() { this->Finalize(); }
errno_t Initialize(void *start, size_t size, u32 option);
void Finalize();
ALWAYS_INLINE void *Allocate(size_t n) { return this->Allocate(n, MinimumAlignment); }
void *Allocate(size_t n, size_t align);
size_t GetAllocationSize(const void *ptr);
errno_t Free(void *p);
errno_t FreeWithSize(void *p, size_t size);
errno_t Reallocate(void *ptr, size_t size, void **p);
errno_t Shrink(void *ptr, size_t size);
bool MakeCache(CachedHeap *cached_heap);
errno_t WalkAllocatedPointers(HeapWalkCallback callback, void *user_data);
errno_t QueryV(int query, std::va_list vl);
errno_t Query(int query, ...);
};
static_assert(sizeof(CentralHeap) <= sizeof(::ams::mem::impl::InternalCentralHeapStorage));
static_assert(alignof(CentralHeap) <= alignof(void *));
}
| 2,556
|
C++
|
.h
| 56
| 38.089286
| 128
| 0.648735
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,648
|
pwm_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/pwm_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#include <stratosphere/pwm/sf/pwm_sf_i_manager.hpp>
namespace ams::pwm {
void InitializeWith(ams::sf::SharedPointer<pwm::sf::IManager> sp);
void Finalize();
}
| 883
|
C++
|
.h
| 23
| 36.304348
| 76
| 0.754959
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,649
|
pwm_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/pwm_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::pwm {
/* ... */
}
| 711
|
C++
|
.h
| 20
| 33.5
| 76
| 0.742733
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,650
|
pwm_channel_name.generic.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/pwm_channel_name.generic.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm {
enum ChannelName {
ChannelName_Invalid = 0,
};
constexpr inline DeviceCode ConvertToDeviceCode(ChannelName cn) {
switch (cn) {
AMS_UNREACHABLE_DEFAULT_CASE();
}
return InvalidDeviceCode;
}
constexpr inline ChannelName ConvertToChannelName(DeviceCode dc) {
switch (dc.GetInternalValue()) {
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ChannelName_Invalid;
}
}
| 1,203
|
C++
|
.h
| 35
| 29.857143
| 76
| 0.706793
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,651
|
pwm_select_channel_name.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/pwm_select_channel_name.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
#include <stratosphere/pwm/pwm_channel_name.board.nintendo_nx.hpp>
#else
#include <stratosphere/pwm/pwm_channel_name.generic.hpp>
#endif
| 901
|
C++
|
.h
| 23
| 37.173913
| 76
| 0.766249
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,652
|
pwm_channel_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/pwm_channel_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm {
struct ChannelSession {
void *_session;
};
Result OpenSession(ChannelSession *out, DeviceCode device_code);
void CloseSession(ChannelSession &session);
void SetPeriod(ChannelSession &session, TimeSpan period);
TimeSpan GetPeriod(ChannelSession &session);
void SetDuty(ChannelSession &session, int duty);
int GetDuty(ChannelSession &session);
void SetEnabled(ChannelSession &session, bool en);
bool GetEnabled(ChannelSession &session);
void SetScale(ChannelSession &session, double scale);
double GetScale(ChannelSession &session);
}
| 1,338
|
C++
|
.h
| 33
| 37.181818
| 76
| 0.753277
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,653
|
pwm_channel_name.board.nintendo_nx.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/pwm_channel_name.board.nintendo_nx.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm {
enum ChannelName {
ChannelName_Invalid = 0,
ChannelName_CpuFan = 1,
ChannelName_LcdBacklight = 2,
ChannelName_BlinkLed = 3,
};
constexpr inline const DeviceCode DeviceCode_CpuFan = 0x3D000001;
constexpr inline const DeviceCode DeviceCode_LcdBacklight = 0x3400003D;
constexpr inline const DeviceCode DeviceCode_BlinkLed = 0x35000065;
constexpr inline DeviceCode ConvertToDeviceCode(ChannelName cn) {
switch (cn) {
case ChannelName_CpuFan: return DeviceCode_CpuFan;
case ChannelName_LcdBacklight: return DeviceCode_LcdBacklight;
case ChannelName_BlinkLed: return DeviceCode_BlinkLed;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
constexpr inline ChannelName ConvertToChannelName(DeviceCode dc) {
switch (dc.GetInternalValue()) {
case DeviceCode_CpuFan .GetInternalValue(): return ChannelName_CpuFan;
case DeviceCode_LcdBacklight.GetInternalValue(): return ChannelName_LcdBacklight;
case DeviceCode_BlinkLed .GetInternalValue(): return ChannelName_BlinkLed;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}
| 1,963
|
C++
|
.h
| 45
| 37.822222
| 93
| 0.70659
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,654
|
pwm_sf_i_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/sf/pwm_sf_i_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/ddsf/ddsf_types.hpp>
#include <stratosphere/pwm/pwm_select_channel_name.hpp>
#include <stratosphere/pwm/sf/pwm_sf_i_channel_session.hpp>
#define AMS_PWM_I_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, int channel), (out, channel) ) \
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name), (out, channel_name) ) \
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSession2, (ams::sf::Out<ams::sf::SharedPointer<pwm::sf::IChannelSession>> out, DeviceCode device_code), (out, device_code), hos::Version_6_0_0)
AMS_SF_DEFINE_INTERFACE(ams::pwm::sf, IManager, AMS_PWM_I_MANAGER_INTERFACE_INFO, 0xBC382479)
| 1,810
|
C++
|
.h
| 25
| 70.24
| 220
| 0.614478
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,655
|
pwm_sf_i_channel_session.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/sf/pwm_sf_i_channel_session.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#define AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetPeriod, (TimeSpanType period), (period)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetPeriod, (ams::sf::Out<TimeSpanType> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetDuty, (int duty), (duty), hos::Version_Min, hos::Version_13_2_1) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out), (out), hos::Version_Min, hos::Version_13_2_1) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabled, (bool enabled), (enabled)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetEnabled, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SetScale, (double scale), (scale), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetScale, (ams::sf::Out<double> out), (out), hos::Version_6_0_0)
AMS_SF_DEFINE_INTERFACE(ams::pwm::sf, IChannelSession, AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO, 0xAC0A18F9)
| 2,071
|
C++
|
.h
| 28
| 71.214286
| 140
| 0.562745
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,656
|
pwm_i_pwm_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_i_pwm_driver.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#include <stratosphere/pwm/driver/pwm_i_pwm_device.hpp>
#include <stratosphere/ddsf.hpp>
namespace ams::pwm::driver {
class IPwmDriver : public ::ams::ddsf::IDriver {
NON_COPYABLE(IPwmDriver);
NON_MOVEABLE(IPwmDriver);
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::IPwmDriver, ::ams::ddsf::IDriver);
public:
IPwmDriver() : IDriver() { /* ... */ }
virtual ~IPwmDriver() { /* ... */ }
virtual void InitializeDriver() = 0;
virtual void FinalizeDriver() = 0;
virtual Result InitializeDevice(IPwmDevice *device) = 0;
virtual void FinalizeDevice(IPwmDevice *device) = 0;
virtual Result SetPeriod(IPwmDevice *device, TimeSpan period) = 0;
virtual Result GetPeriod(TimeSpan *out, IPwmDevice *device) = 0;
/* TODO: Nintendo removed these in 14.0.0. Should we? */
virtual Result SetDuty(IPwmDevice *device, int duty) = 0;
virtual Result GetDuty(int *out, IPwmDevice *device) = 0;
virtual Result SetScale(IPwmDevice *device, double scale) = 0;
virtual Result GetScale(double *out, IPwmDevice *device) = 0;
virtual Result SetEnabled(IPwmDevice *device, bool en) = 0;
virtual Result GetEnabled(bool *out, IPwmDevice *device) = 0;
virtual Result Suspend() = 0;
virtual void Resume() = 0;
};
}
| 2,155
|
C++
|
.h
| 45
| 40.933333
| 85
| 0.662857
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,657
|
pwm_i_pwm_device.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_i_pwm_device.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#include <stratosphere/ddsf.hpp>
namespace ams::pwm::driver {
class IPwmDevice : public ::ams::ddsf::IDevice {
NON_COPYABLE(IPwmDevice);
NON_MOVEABLE(IPwmDevice);
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::IPwmDevice, ::ams::ddsf::IDevice);
private:
int m_channel_index;
public:
IPwmDevice(int id) : IDevice(false), m_channel_index(id) { /* ... */ }
virtual ~IPwmDevice() { /* ... */ }
constexpr int GetChannelIndex() const { return m_channel_index; }
};
}
| 1,270
|
C++
|
.h
| 32
| 35.125
| 85
| 0.688006
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,658
|
pwm_channel_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_channel_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm::driver {
namespace impl {
constexpr inline size_t ChannelSessionSize = 0x60;
constexpr inline size_t ChannelSessionAlign = 8;
struct alignas(ChannelSessionAlign) ChannelSessionImplPadded;
}
struct ChannelSession {
util::TypedStorage<impl::ChannelSessionImplPadded, impl::ChannelSessionSize, impl::ChannelSessionAlign> _impl;
};
Result OpenSession(ChannelSession *out, DeviceCode device_code);
void CloseSession(ChannelSession &session);
void SetPeriod(ChannelSession &session, TimeSpan period);
TimeSpan GetPeriod(ChannelSession &session);
void SetDuty(ChannelSession &session, int duty);
int GetDuty(ChannelSession &session);
void SetEnabled(ChannelSession &session, bool en);
bool GetEnabled(ChannelSession &session);
void SetScale(ChannelSession &session, double scale);
double GetScale(ChannelSession &session);
}
| 1,659
|
C++
|
.h
| 38
| 39.657895
| 118
| 0.755749
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,659
|
pwm_driver_service_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_driver_service_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#include <stratosphere/pwm/driver/pwm_i_pwm_device.hpp>
#include <stratosphere/pwm/driver/pwm_i_pwm_driver.hpp>
namespace ams::pwm::driver {
void RegisterDriver(IPwmDriver *driver);
void UnregisterDriver(IPwmDriver *driver);
Result RegisterDeviceCode(DeviceCode device_code, IPwmDevice *device);
bool UnregisterDeviceCode(DeviceCode device_code);
}
| 1,082
|
C++
|
.h
| 26
| 39.307692
| 76
| 0.771863
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,660
|
pwm_driver_client_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_driver_client_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm::driver {
void Initialize();
void Finalize();
}
| 791
|
C++
|
.h
| 22
| 33.818182
| 76
| 0.751958
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,661
|
pwm_select_driver_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_select_driver_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#include <stratosphere/pwm/driver/pwm_i_pwm_driver.hpp>
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
#include <stratosphere/pwm/driver/board/nintendo/nx/pwm_driver_api.hpp>
namespace ams::pwm::driver::board {
using namespace ams::pwm::driver::board::nintendo::nx;
}
#else
// TODO: #error "Unknown board for ams::pwm::driver::"
#endif
| 1,077
|
C++
|
.h
| 27
| 37.148148
| 76
| 0.746398
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,662
|
pwm_driver_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/driver/board/nintendo/nx/pwm_driver_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
namespace ams::pwm::driver::board::nintendo::nx {
void Initialize();
}
| 791
|
C++
|
.h
| 21
| 35.666667
| 76
| 0.754889
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,663
|
pwm_server_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pwm/server/pwm_server_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp>
#include <stratosphere/pwm/sf/pwm_sf_i_manager.hpp>
namespace ams::pwm::server {
ams::sf::SharedPointer<pwm::sf::IManager> GetServiceObject();
}
| 865
|
C++
|
.h
| 22
| 37.363636
| 76
| 0.758333
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,664
|
sm_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/ncm/ncm_ids.hpp>
#include <stratosphere/cfg/cfg_types.hpp>
namespace ams::sm {
struct ServiceName {
static constexpr size_t MaxLength = 8;
char name[MaxLength];
static constexpr ServiceName Encode(const char *name, size_t name_size) {
ServiceName out{};
for (size_t i = 0; i < MaxLength; i++) {
if (i < name_size) {
out.name[i] = name[i];
} else {
out.name[i] = 0;
}
}
return out;
}
static constexpr ServiceName Encode(util::string_view name) {
return Encode(name.data(), name.size());
}
};
static constexpr inline ServiceName InvalidServiceName = ServiceName::Encode("");
static_assert(alignof(ServiceName) == 1, "ServiceName definition!");
inline bool operator==(const ServiceName &lhs, const ServiceName &rhs) {
return std::memcmp(std::addressof(lhs), std::addressof(rhs), sizeof(ServiceName)) == 0;
}
inline bool operator!=(const ServiceName &lhs, const ServiceName &rhs) {
return !(lhs == rhs);
}
/* For Mitm extensions. */
struct MitmProcessInfo {
os::ProcessId process_id;
ncm::ProgramId program_id;
cfg::OverrideStatus override_status;
};
static_assert(std::is_trivial<MitmProcessInfo>::value && sizeof(MitmProcessInfo) == 0x20, "MitmProcessInfo definition!");
}
| 2,163
|
C++
|
.h
| 54
| 33.277778
| 125
| 0.651551
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,665
|
sm_manager_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm/sm_manager_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/os.hpp>
#include <stratosphere/ncm/ncm_ids.hpp>
#include <stratosphere/cfg/cfg_types.hpp>
#include <stratosphere/sm/sm_types.hpp>
namespace ams::sm::manager {
/* Manager API. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size);
Result UnregisterProcess(os::ProcessId process_id);
/* Atmosphere extensions. */
Result EndInitialDefers();
Result HasMitm(bool *out, ServiceName name);
}
| 1,208
|
C++
|
.h
| 28
| 40.607143
| 178
| 0.75234
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,666
|
sm_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm/sm_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/sm/sm_types.hpp>
namespace ams::sm {
/* Initialization. */
Result Initialize();
Result Finalize();
/* Ordinary SM API. */
Result GetServiceHandle(os::NativeHandle *out, ServiceName name);
Result RegisterService(os::NativeHandle *out, ServiceName name, size_t max_sessions, bool is_light);
Result UnregisterService(ServiceName name);
/* Atmosphere extensions. */
Result HasService(bool *out, ServiceName name);
Result WaitService(ServiceName name);
}
| 1,168
|
C++
|
.h
| 29
| 37.172414
| 104
| 0.7447
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,667
|
sm_mitm_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm/sm_mitm_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/sm/sm_types.hpp>
#include <stratosphere/sf/sf_mitm_config.hpp>
#if AMS_SF_MITM_SUPPORTED
namespace ams::sm::mitm {
/* Mitm API. */
Result InstallMitm(os::NativeHandle *out_port, os::NativeHandle *out_query, ServiceName name);
Result UninstallMitm(ServiceName name);
Result DeclareFutureMitm(ServiceName name);
Result ClearFutureMitm(ServiceName name);
Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name);
Result HasMitm(bool *out, ServiceName name);
Result WaitMitm(ServiceName name);
}
#endif
| 1,242
|
C++
|
.h
| 30
| 38.733333
| 98
| 0.762417
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,668
|
sm_manager_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm/impl/sm_manager_interface.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/sm/sm_types.hpp>
#include <stratosphere/tipc.hpp>
#define AMS_SM_I_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \
AMS_TIPC_METHOD_INFO(C, H, 0, Result, RegisterProcess, (os::ProcessId process_id, const tipc::InBuffer acid_sac, const tipc::InBuffer aci_sac), (process_id, acid_sac, aci_sac)) \
AMS_TIPC_METHOD_INFO(C, H, 1, Result, UnregisterProcess, (os::ProcessId process_id), (process_id)) \
AMS_TIPC_METHOD_INFO(C, H, 65000, void, AtmosphereEndInitDefers, (), ()) \
AMS_TIPC_METHOD_INFO(C, H, 65001, void, AtmosphereHasMitm, (tipc::Out<bool> out, sm::ServiceName service), (out, service)) \
AMS_TIPC_METHOD_INFO(C, H, 65002, Result, AtmosphereRegisterProcess, (os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const tipc::InBuffer acid_sac, const tipc::InBuffer aci_sac), (process_id, program_id, override_status, acid_sac, aci_sac))
AMS_TIPC_DEFINE_INTERFACE(ams::sm::impl, IManagerInterface, AMS_SM_I_MANAGER_INTERFACE_INTERFACE_INFO)
| 2,586
|
C++
|
.h
| 26
| 97.038462
| 289
| 0.484943
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,669
|
sm_user_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm/impl/sm_user_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/sm/sm_types.hpp>
#include <stratosphere/tipc.hpp>
#define AMS_SM_I_USER_INTERFACE_INTERFACE_INFO(C, H) \
AMS_TIPC_METHOD_INFO(C, H, 0, Result, RegisterClient, (const tipc::ClientProcessId client_process_id), (client_process_id)) \
AMS_TIPC_METHOD_INFO(C, H, 1, Result, GetServiceHandle, (tipc::OutMoveHandle out_h, sm::ServiceName service), (out_h, service)) \
AMS_TIPC_METHOD_INFO(C, H, 2, Result, RegisterService, (tipc::OutMoveHandle out_h, sm::ServiceName service, u32 max_sessions, bool is_light), (out_h, service, max_sessions, is_light)) \
AMS_TIPC_METHOD_INFO(C, H, 3, Result, UnregisterService, (sm::ServiceName service), (service)) \
AMS_TIPC_METHOD_INFO(C, H, 4, Result, DetachClient, (const tipc::ClientProcessId client_process_id), (client_process_id)) \
AMS_TIPC_METHOD_INFO(C, H, 65000, Result, AtmosphereInstallMitm, (tipc::OutMoveHandle srv_h, tipc::OutMoveHandle qry_h, sm::ServiceName service), (srv_h, qry_h, service)) \
AMS_TIPC_METHOD_INFO(C, H, 65001, Result, AtmosphereUninstallMitm, (sm::ServiceName service), (service)) \
AMS_TIPC_METHOD_INFO(C, H, 65003, Result, AtmosphereAcknowledgeMitmSession, (tipc::Out<sm::MitmProcessInfo> client_info, tipc::OutMoveHandle fwd_h, sm::ServiceName service), (client_info, fwd_h, service)) \
AMS_TIPC_METHOD_INFO(C, H, 65004, Result, AtmosphereHasMitm, (tipc::Out<bool> out, sm::ServiceName service), (out, service)) \
AMS_TIPC_METHOD_INFO(C, H, 65005, Result, AtmosphereWaitMitm, (sm::ServiceName service), (service)) \
AMS_TIPC_METHOD_INFO(C, H, 65006, Result, AtmosphereDeclareFutureMitm, (sm::ServiceName service), (service)) \
AMS_TIPC_METHOD_INFO(C, H, 65007, Result, AtmosphereClearFutureMitm, (sm::ServiceName service), (service)) \
AMS_TIPC_METHOD_INFO(C, H, 65100, Result, AtmosphereHasService, (tipc::Out<bool> out, sm::ServiceName service), (out, service)) \
AMS_TIPC_METHOD_INFO(C, H, 65101, Result, AtmosphereWaitService, (sm::ServiceName service), (service))
AMS_TIPC_DEFINE_INTERFACE(ams::sm::impl, IUserInterface, AMS_SM_I_USER_INTERFACE_INTERFACE_INFO)
| 4,141
|
C++
|
.h
| 35
| 115.228571
| 221
| 0.493785
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,670
|
fatal_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fatal/fatal_types.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/ncm/ncm_ids.hpp>
#include <stratosphere/sf/sf_buffer_tags.hpp>
namespace ams::fatal {
enum FatalPolicy : u32 {
FatalPolicy_ErrorReportAndErrorScreen = 0,
FatalPolicy_ErrorReport = 1,
FatalPolicy_ErrorScreen = 2
};
#if defined(ATMOSPHERE_ARCH_ARM64)
namespace aarch64 {
enum RegisterName {
RegisterName_X0 = 0,
RegisterName_X1 = 1,
RegisterName_X2 = 2,
RegisterName_X3 = 3,
RegisterName_X4 = 4,
RegisterName_X5 = 5,
RegisterName_X6 = 6,
RegisterName_X7 = 7,
RegisterName_X8 = 8,
RegisterName_X9 = 9,
RegisterName_X10 = 10,
RegisterName_X11 = 11,
RegisterName_X12 = 12,
RegisterName_X13 = 13,
RegisterName_X14 = 14,
RegisterName_X15 = 15,
RegisterName_X16 = 16,
RegisterName_X17 = 17,
RegisterName_X18 = 18,
RegisterName_X19 = 19,
RegisterName_X20 = 20,
RegisterName_X21 = 21,
RegisterName_X22 = 22,
RegisterName_X23 = 23,
RegisterName_X24 = 24,
RegisterName_X25 = 25,
RegisterName_X26 = 26,
RegisterName_X27 = 27,
RegisterName_X28 = 28,
RegisterName_FP = 29,
RegisterName_LR = 30,
RegisterName_SP = 31,
RegisterName_PC = 32,
RegisterName_GeneralPurposeCount,
RegisterName_PState = 33,
RegisterName_Afsr0 = 34,
RegisterName_Afsr1 = 35,
RegisterName_Esr = 36,
RegisterName_Far = 37,
RegisterName_Count,
};
struct CpuContext {
using RegisterType = u64;
static constexpr size_t MaxStackTraceDepth = 0x20;
static constexpr const char *RegisterNameStrings[RegisterName_Count] = {
"X0",
"X1",
"X2",
"X3",
"X4",
"X5",
"X6",
"X7",
"X8",
"X9",
"X10",
"X11",
"X12",
"X13",
"X14",
"X15",
"X16",
"X17",
"X18",
"X19",
"X20",
"X21",
"X22",
"X23",
"X24",
"X25",
"X26",
"X27",
"X28",
"FP",
"LR",
"SP",
"PC",
"PState",
"Afsr0",
"Afsr1",
"Esr",
"Far",
};
/* Registers, exception context. N left names for these fields in fatal .rodata. */
union {
struct {
union {
RegisterType x[RegisterName_GeneralPurposeCount];
struct {
RegisterType _x[RegisterName_FP];
RegisterType fp;
RegisterType lr;
RegisterType sp;
RegisterType pc;
};
};
RegisterType pstate;
RegisterType afsr0;
RegisterType afsr1;
RegisterType esr;
RegisterType far;
};
RegisterType registers[RegisterName_Count];
};
/* Misc. */
RegisterType stack_trace[MaxStackTraceDepth];
RegisterType base_address;
RegisterType register_set_flags;
u32 stack_trace_size;
void ClearState() {
std::memset(this, 0, sizeof(*this));
}
void SetProgramIdForAtmosphere(ncm::ProgramId program_id) {
/* Right now, we mux program ID in through afsr when creport. */
/* TODO: Better way to do this? */
this->afsr0 = static_cast<RegisterType>(program_id.value);
}
ncm::ProgramId GetProgramIdForAtmosphere() const {
return ncm::ProgramId{this->afsr0};
}
void SetRegisterValue(RegisterName name, RegisterType value) {
this->registers[name] = value;
this->register_set_flags |= (RegisterType(1) << name);
}
bool HasRegisterValue(RegisterName name) const {
return this->register_set_flags & (RegisterType(1) << name);
}
void SetBaseAddress(RegisterType base_addr) {
this->base_address = base_addr;
}
};
}
#endif
#if defined(ATMOSPHERE_ARCH_ARM64) || defined(ATMOSPHERE_ARCH_ARM)
namespace aarch32 {
enum RegisterName {
RegisterName_R0 = 0,
RegisterName_R1 = 1,
RegisterName_R2 = 2,
RegisterName_R3 = 3,
RegisterName_R4 = 4,
RegisterName_R5 = 5,
RegisterName_R6 = 6,
RegisterName_R7 = 7,
RegisterName_R8 = 8,
RegisterName_R9 = 9,
RegisterName_R10 = 10,
RegisterName_FP = 11,
RegisterName_IP = 12,
RegisterName_LR = 13,
RegisterName_SP = 14,
RegisterName_PC = 15,
RegisterName_GeneralPurposeCount,
RegisterName_PState = 16,
RegisterName_Afsr0 = 17,
RegisterName_Afsr1 = 18,
RegisterName_Esr = 29,
RegisterName_Far = 20,
RegisterName_Count,
};
struct CpuContext {
using RegisterType = u32;
static constexpr size_t MaxStackTraceDepth = 0x20;
static constexpr const char *RegisterNameStrings[RegisterName_Count] = {
"R0",
"R1",
"R2",
"R3",
"R4",
"R5",
"R6",
"R7",
"R8",
"R9",
"R10",
"FP",
"IP",
"LR",
"SP",
"PC",
"PState",
"Afsr0",
"Afsr1",
"Esr",
"Far",
};
/* Registers, exception context. N left names for these fields in fatal .rodata. */
union {
struct {
union {
RegisterType r[RegisterName_GeneralPurposeCount];
struct {
RegisterType _x[RegisterName_FP];
RegisterType fp;
RegisterType ip;
RegisterType lr;
RegisterType sp;
RegisterType pc;
};
};
RegisterType pstate;
RegisterType afsr0;
RegisterType afsr1;
RegisterType esr;
RegisterType far;
};
RegisterType registers[RegisterName_Count];
};
/* Misc. Yes, stack_trace_size is really laid out differently than aarch64... */
RegisterType stack_trace[MaxStackTraceDepth];
u32 stack_trace_size;
RegisterType base_address;
RegisterType register_set_flags;
void ClearState() {
std::memset(this, 0, sizeof(*this));
}
void SetProgramIdForAtmosphere(ncm::ProgramId program_id) {
/* Right now, we mux program ID in through afsr when creport. */
/* TODO: Better way to do this? */
this->afsr0 = static_cast<RegisterType>(static_cast<u64>(program_id.value) >> 0);
this->afsr1 = static_cast<RegisterType>(static_cast<u64>(program_id.value) >> 32);
}
ncm::ProgramId GetProgramIdForAtmosphere() const {
return ncm::ProgramId{(static_cast<u64>(this->afsr1) << 32ul) | (static_cast<u64>(this->afsr0) << 0ul)};
}
void SetRegisterValue(RegisterName name, RegisterType value) {
this->registers[name] = value;
this->register_set_flags |= (RegisterType(1) << name);
}
bool HasRegisterValue(RegisterName name) const {
return this->register_set_flags & (RegisterType(1) << name);
}
void SetBaseAddress(RegisterType base_addr) {
this->base_address = base_addr;
}
};
}
#endif
#if defined(ATMOSPHERE_ARCH_X64)
namespace x64 {
enum RegisterName {
/* TODO */
RegisterName_Count,
};
struct CpuContext {
using RegisterType = u64;
static constexpr size_t MaxStackTraceDepth = 0x20;
static constexpr const char *RegisterNameStrings[RegisterName_Count] = {
/* TODO */
};
/* Registers, exception context. N left names for these fields in fatal .rodata. */
union {
// struct {
// /* TODO */
// };
RegisterType registers[RegisterName_Count];
};
/* Misc. */
RegisterType stack_trace[MaxStackTraceDepth];
RegisterType base_address;
RegisterType register_set_flags;
u32 stack_trace_size;
void ClearState() {
std::memset(this, 0, sizeof(*this));
}
void SetProgramIdForAtmosphere(ncm::ProgramId program_id) {
AMS_UNUSED(program_id);
AMS_ABORT("TODO");
}
ncm::ProgramId GetProgramIdForAtmosphere() const {
AMS_ABORT("TODO");
}
void SetRegisterValue(RegisterName name, RegisterType value) {
this->registers[name] = value;
this->register_set_flags |= (RegisterType(1) << name);
}
bool HasRegisterValue(RegisterName name) const {
return this->register_set_flags & (RegisterType(1) << name);
}
void SetBaseAddress(RegisterType base_addr) {
this->base_address = base_addr;
}
};
}
#endif
#if defined(ATMOSPHERE_ARCH_X64) || defined(ATMOSPHERE_ARCH_X86)
namespace x86 {
enum RegisterName {
/* TODO */
RegisterName_Count,
};
struct CpuContext {
using RegisterType = u32;
static constexpr size_t MaxStackTraceDepth = 0x20;
static constexpr const char *RegisterNameStrings[RegisterName_Count] = {
/* TODO */
};
/* Registers, exception context. N left names for these fields in fatal .rodata. */
union {
// struct {
// /* TODO */
// };
RegisterType registers[RegisterName_Count];
};
/* Misc. Yes, stack_trace_size is really laid out differently than aarch64... */
RegisterType stack_trace[MaxStackTraceDepth];
u32 stack_trace_size;
RegisterType base_address;
RegisterType register_set_flags;
void ClearState() {
std::memset(this, 0, sizeof(*this));
}
void SetProgramIdForAtmosphere(ncm::ProgramId program_id) {
AMS_UNUSED(program_id);
AMS_ABORT("TODO");
}
ncm::ProgramId GetProgramIdForAtmosphere() const {
AMS_ABORT("TODO");
}
void SetRegisterValue(RegisterName name, RegisterType value) {
this->registers[name] = value;
this->register_set_flags |= (RegisterType(1) << name);
}
bool HasRegisterValue(RegisterName name) const {
return this->register_set_flags & (RegisterType(1) << name);
}
void SetBaseAddress(RegisterType base_addr) {
this->base_address = base_addr;
}
};
}
#endif
struct CpuContext : sf::LargeData, sf::PrefersMapAliasTransferMode {
enum Architecture {
#if defined(ATMOSPHERE_ARCH_ARM64)
Architecture_Aarch64,
#endif
#if defined(ATMOSPHERE_ARCH_ARM64) || defined(ATMOSPHERE_ARCH_ARM)
Architecture_Aarch32,
#endif
#if defined(ATMOSPHERE_X64)
Architecture_X64,
#endif
#if defined(ATMOSPHERE_X64) || defined(ATMOSPHERE_ARCH_X86)
Architecture_X86,
#endif
};
union {
#if defined(ATMOSPHERE_ARCH_ARM64)
aarch64::CpuContext aarch64_ctx;
#endif
#if defined(ATMOSPHERE_ARCH_ARM64) || defined(ATMOSPHERE_ARCH_ARM)
aarch32::CpuContext aarch32_ctx;
#endif
#if defined(ATMOSPHERE_X64)
aarch64::CpuContext x64_ctx;
#endif
#if defined(ATMOSPHERE_X64) || defined(ATMOSPHERE_ARCH_X86)
aarch64::CpuContext x86_ctx;
#endif
u8 raw_storage[0x248];
};
Architecture architecture;
u32 type;
void ClearState() {
std::memset(this, 0, sizeof(*this));
}
};
#if defined(ATMOSPHERE_ARCH_ARM64)
static_assert(util::is_pod<aarch64::CpuContext>::value && sizeof(aarch64::CpuContext) == 0x248, "aarch64::CpuContext definition!");
#endif
#if defined(ATMOSPHERE_ARCH_ARM64) || defined(ATMOSPHERE_ARCH_ARM)
static_assert(util::is_pod<aarch32::CpuContext>::value && sizeof(aarch32::CpuContext) == 0xE0, "aarch32::CpuContext definition!");
#endif
static_assert(util::is_pod<CpuContext>::value && sizeof(CpuContext) == 0x250, "CpuContext definition!");
namespace srv {
struct ThrowContext {
Result result;
FatalPolicy policy;
ncm::ProgramId program_id;
ncm::ProgramId throw_program_id;
char proc_name[0xD];
bool is_creport;
CpuContext cpu_ctx;
bool generate_error_report;
os::Event *erpt_event;
os::Event *battery_event;
size_t stack_dump_size;
u64 stack_dump_base;
u8 stack_dump[0x100];
u64 tls_address;
u8 tls_dump[0x100];
ThrowContext(os::Event *erpt, os::Event *bat)
: result(ResultSuccess()), policy(), program_id(), throw_program_id(), proc_name(), is_creport(), cpu_ctx(), generate_error_report(),
erpt_event(erpt), battery_event(bat),
stack_dump_size(), stack_dump_base(), stack_dump(), tls_address(), tls_dump()
{
/* ... */
}
};
}
}
| 16,353
|
C++
|
.h
| 431
| 24.232019
| 149
| 0.492744
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,671
|
fatal_i_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_service.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/sf.hpp>
#define AMS_FATAL_I_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ThrowFatal, (Result error, const sf::ClientProcessId &client_pid), (error, client_pid)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ThrowFatalWithPolicy, (Result error, const sf::ClientProcessId &client_pid, fatal::FatalPolicy policy), (error, client_pid, policy)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ThrowFatalWithCpuContext, (Result error, const sf::ClientProcessId &client_pid, fatal::FatalPolicy policy, const fatal::CpuContext &cpu_ctx), (error, client_pid, policy, cpu_ctx))
AMS_SF_DEFINE_INTERFACE(ams::fatal::impl, IService, AMS_FATAL_I_SERVICE_INTERFACE_INFO, 0x91328766)
| 1,737
|
C++
|
.h
| 24
| 70.166667
| 221
| 0.616959
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,672
|
fatal_i_private_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_private_service.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/sf.hpp>
#define AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetFatalEvent, (sf::OutCopyHandle out_h), (out_h)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetFatalContext, (sf::Out<Result> out_error, sf::Out<ncm::ProgramId> out_program_id, sf::Out<fatal::FatalPolicy> out_policy, sf::Out<fatal::CpuContext> out_ctx), (out_error, out_program_id, out_policy, out_ctx))
AMS_SF_DEFINE_INTERFACE(ams::fatal::impl, IPrivateService, AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO, 0x6C3C9791)
| 1,629
|
C++
|
.h
| 23
| 68.73913
| 254
| 0.582034
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,673
|
cfg_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/cfg/cfg_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.hpp>
#include <stratosphere/ncm/ncm_ids.hpp>
namespace ams::cfg {
namespace impl {
enum OverrideStatusFlag : u64 {
OverrideStatusFlag_Hbl = (1u << 0),
OverrideStatusFlag_ProgramSpecific = (1u << 1),
OverrideStatusFlag_CheatEnabled = (1u << 2),
OverrideStatusFlag_AddressSpaceShift = 3,
OverrideStatusFlag_AddressSpaceMask = ((1u << 2) - 1) << OverrideStatusFlag_AddressSpaceShift,
#if defined(ATMOSPHERE_OS_HORIZON)
OverrideStatusFlag_AddressSpace32Bit = (svc::CreateProcessFlag_AddressSpace32Bit >> svc::CreateProcessFlag_AddressSpaceShift) << OverrideStatusFlag_AddressSpaceShift,
OverrideStatusFlag_AddressSpace64BitDeprecated = (svc::CreateProcessFlag_AddressSpace64BitDeprecated >> svc::CreateProcessFlag_AddressSpaceShift) << OverrideStatusFlag_AddressSpaceShift,
OverrideStatusFlag_AddressSpace32BitWithoutAlias = (svc::CreateProcessFlag_AddressSpace32BitWithoutAlias >> svc::CreateProcessFlag_AddressSpaceShift) << OverrideStatusFlag_AddressSpaceShift,
OverrideStatusFlag_AddressSpace64Bit = (svc::CreateProcessFlag_AddressSpace64Bit >> svc::CreateProcessFlag_AddressSpaceShift) << OverrideStatusFlag_AddressSpaceShift,
#endif
};
}
struct OverrideStatus {
u64 keys_held;
u64 flags;
constexpr inline u64 GetKeysHeld() const { return this->keys_held; }
#define DEFINE_FLAG_ACCESSORS(flag) \
constexpr inline bool Is##flag() const { return this->flags & impl::OverrideStatusFlag_##flag; } \
constexpr inline void Set##flag() { this->flags |= impl::OverrideStatusFlag_##flag; } \
constexpr inline void Clear##flag() { this->flags &= ~u64(impl::OverrideStatusFlag_##flag); }
DEFINE_FLAG_ACCESSORS(Hbl)
DEFINE_FLAG_ACCESSORS(ProgramSpecific)
DEFINE_FLAG_ACCESSORS(CheatEnabled)
#undef DEFINE_FLAG_ACCESSORS
constexpr inline u64 GetOverrideAddressSpaceFlags() const { return this->flags & impl::OverrideStatusFlag_AddressSpaceMask; }
constexpr inline bool HasOverrideAddressSpace() const { return this->IsHbl() && this->GetOverrideAddressSpaceFlags() != 0; }
};
static_assert(sizeof(OverrideStatus) == 0x10, "sizeof(OverrideStatus)");
static_assert(util::is_pod<OverrideStatus>::value, "util::is_pod<OverrideStatus>::value");
constexpr inline bool operator==(const OverrideStatus &lhs, const OverrideStatus &rhs) {
if (std::is_constant_evaluated()) {
return lhs.keys_held == rhs.keys_held && lhs.flags == rhs.flags;
} else {
return std::memcmp(std::addressof(lhs), std::addressof(rhs), sizeof(lhs)) == 0;
}
}
constexpr inline bool operator!=(const OverrideStatus &lhs, const OverrideStatus &rhs) {
return !(lhs == rhs);
}
}
| 3,638
|
C++
|
.h
| 62
| 51.564516
| 202
| 0.69542
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,674
|
cfg_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/cfg/cfg_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/cfg/cfg_types.hpp>
#include <stratosphere/cfg/cfg_locale_types.hpp>
#include <stratosphere/sm/sm_types.hpp>
namespace ams::cfg {
/* SD card configuration. */
bool IsSdCardRequiredServicesReady();
void WaitSdCardRequiredServicesReady();
bool IsSdCardInitialized();
void WaitSdCardInitialized();
/* Override key utilities. */
OverrideStatus CaptureOverrideStatus(ncm::ProgramId program_id);
/* Locale utilities. */
OverrideLocale GetOverrideLocale(ncm::ProgramId program_id);
/* Flag utilities. */
bool HasFlag(const sm::MitmProcessInfo &process_info, const char *flag);
bool HasContentSpecificFlag(ncm::ProgramId program_id, const char *flag);
bool HasGlobalFlag(const char *flag);
Result DeleteGlobalFlag(const char *flag);
/* HBL Configuration utilities. */
bool HasHblFlag(const char *flag);
const char *GetHblPath();
}
| 1,568
|
C++
|
.h
| 38
| 37.921053
| 77
| 0.749179
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,675
|
cfg_locale_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/cfg/cfg_locale_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/cfg/cfg_types.hpp>
#include <stratosphere/settings/settings_types.hpp>
namespace ams::cfg {
struct OverrideLocale {
settings::LanguageCode language_code;
settings::RegionCode region_code;
};
}
| 891
|
C++
|
.h
| 24
| 34.416667
| 76
| 0.752315
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,676
|
updater_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/updater/updater_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/updater/updater_types.hpp>
#include <stratosphere/spl/spl_types.hpp>
namespace ams::updater {
/* Public API. */
BootImageUpdateType GetBootImageUpdateType(int boot_image_update_type);
BootImageUpdateType GetBootImageUpdateType(spl::HardwareType hw_type);
Result GetBootImagePackageId(ncm::SystemDataId *out_data_id, BootModeType mode, void *work_buffer, size_t work_buffer_size);
Result MarkVerifyingRequired(BootModeType mode, void *work_buffer, size_t work_buffer_size);
Result MarkVerified(BootModeType mode, void *work_buffer, size_t work_buffer_size);
Result UpdateBootImagesFromPackage(ncm::SystemDataId boot_image_package_id, BootModeType mode, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type);
Result VerifyBootImagesAndRepairIfNeeded(bool *out_repaired_normal, bool *out_repaired_safe, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type);
}
| 1,636
|
C++
|
.h
| 28
| 55.5
| 187
| 0.7825
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,677
|
updater_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/updater/updater_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::updater {
/* Types. */
enum class BootImageUpdateType {
Erista,
Mariko,
};
enum class BootModeType {
Normal,
Safe,
};
struct VerificationState {
bool needs_verify_normal;
bool needs_verify_safe;
};
/* Convenience size definitions. */
constexpr size_t BctSize = 0x4000;
constexpr size_t EksSize = 0x4000;
constexpr size_t EksEntrySize = 0x200;
constexpr size_t EksBlobSize = 0xB0;
}
| 1,170
|
C++
|
.h
| 37
| 27.486486
| 76
| 0.704525
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,678
|
vi_layer_stack.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/vi/vi_layer_stack.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::vi {
enum LayerStack {
LayerStack_Default = 0,
LayerStack_Lcd = 1,
LayerStack_Screenshot = 2,
LayerStack_Recording = 3,
LayerStack_LastFrame = 4,
LayerStack_Arbitrary = 5,
LayerStack_ApplicationForDebug = 6,
LayerStack_Null = 10,
};
}
| 1,086
|
C++
|
.h
| 29
| 33.344828
| 76
| 0.648623
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,679
|
wec_wake_event.board.nintendo_nx.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/wec/wec_wake_event.board.nintendo_nx.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::wec {
enum WakeEvent {
WakeEvent_PexWakeN = 0x00,
WakeEvent_GpioPortA6 = 0x01,
WakeEvent_QspiCsN = 0x02,
WakeEvent_Spi2Mosi = 0x03,
WakeEvent_ExtconDetS = 0x04,
WakeEvent_McuIrq = 0x05,
WakeEvent_Uart2Cts = 0x06,
WakeEvent_Uart3Cts = 0x07,
WakeEvent_WifiWakeAp = 0x08,
WakeEvent_AoTag2Pmc = 0x09,
WakeEvent_ExtconDetU = 0x0A,
WakeEvent_NfcInt = 0x0B,
WakeEvent_Gen1I2cSda = 0x0C,
WakeEvent_Gen2I2cSda = 0x0D,
WakeEvent_CradleIrq = 0x0E,
WakeEvent_GpioPortK6 = 0x0F,
WakeEvent_RtcIrq = 0x10,
WakeEvent_Sdmmc1Dat1 = 0x11,
WakeEvent_Sdmmc2Dat1 = 0x12,
WakeEvent_HdmiCec = 0x13,
WakeEvent_Gen3I2cSda = 0x14,
WakeEvent_GpioPortL1 = 0x15,
WakeEvent_Clk_32kOut = 0x16,
WakeEvent_PwrI2cSda = 0x17,
WakeEvent_ButtonPowerOn = 0x18,
WakeEvent_ButtonVolUp = 0x19,
WakeEvent_ButtonVolDown = 0x1A,
WakeEvent_ButtonSlideSw = 0x1B,
WakeEvent_ButtonHome = 0x1C,
/* ... */
WakeEvent_AlsProxInt = 0x20,
WakeEvent_TempAlert = 0x21,
WakeEvent_Bq24190Irq = 0x22,
WakeEvent_SdCd = 0x23,
WakeEvent_GpioPortZ2 = 0x24,
/* ... */
WakeEvent_Utmip0 = 0x27,
WakeEvent_Utmip1 = 0x28,
WakeEvent_Utmip2 = 0x29,
WakeEvent_Utmip3 = 0x2A,
WakeEvent_Uhsic = 0x2B,
WakeEvent_Wake2PmcXusbSystem = 0x2C,
WakeEvent_Sdmmc3Dat1 = 0x2D,
WakeEvent_Sdmmc4Dat1 = 0x2E,
WakeEvent_CamI2cScl = 0x2F,
WakeEvent_CamI2cSda = 0x30,
WakeEvent_GpioPortZ5 = 0x31,
WakeEvent_DpHpd0 = 0x32,
WakeEvent_PwrIntN = 0x33,
WakeEvent_BtWakeAp = 0x34,
WakeEvent_HdmiIntDpHpd = 0x35,
WakeEvent_UsbVbusEn0 = 0x36,
WakeEvent_UsbVbusEn1 = 0x37,
WakeEvent_LcdRst = 0x38,
WakeEvent_LcdGpio1 = 0x39,
WakeEvent_LcdGpio2 = 0x3A,
WakeEvent_Uart4Cts = 0x3B,
WakeEvent_ModemWakeAp = 0x3D,
WakeEvent_TouchInt = 0x3E,
WakeEvent_MotionInt = 0x3F,
WakeEvent_Count = 0x40,
};
constexpr inline WakeEvent WakeEvent_None = static_cast<WakeEvent>(-1);
}
| 3,494
|
C++
|
.h
| 83
| 34.843373
| 76
| 0.549618
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,680
|
wec_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/wec/wec_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/wec/wec_types.hpp>
namespace ams::wec {
void Initialize();
void ClearWakeEvents();
void WecRestoreForExitSuspend();
void SetWakeEventLevel(wec::WakeEvent event, wec::WakeEventLevel level);
void SetWakeEventEnabled(wec::WakeEvent event, bool en);
}
| 967
|
C++
|
.h
| 25
| 36.12
| 76
| 0.758805
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,681
|
wec_wake_event.generic.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/wec/wec_wake_event.generic.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::wec {
enum WakeEvent {
WakeEvent_Debug = 0,
WakeEvent_Count = 1,
};
constexpr inline WakeEvent WakeEvent_None = static_cast<WakeEvent>(-1);
}
| 861
|
C++
|
.h
| 24
| 32.916667
| 76
| 0.734375
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,682
|
wec_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/wec/wec_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>
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
#include <stratosphere/wec/wec_wake_event.board.nintendo_nx.hpp>
#else
#include <stratosphere/wec/wec_wake_event.generic.hpp>
#endif
namespace ams::wec {
enum WakeEventLevel {
WakeEventLevel_Low = 0,
WakeEventLevel_High = 1,
WakeEventLevel_Auto = 2,
};
}
| 1,013
|
C++
|
.h
| 29
| 31.931034
| 76
| 0.738776
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,683
|
sprofile_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sprofile/sprofile_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::sprofile {
struct Identifier {
u8 data[7];
friend bool operator==(const Identifier &lhs, const Identifier &rhs) {
return std::memcmp(lhs.data, rhs.data, sizeof(lhs.data)) == 0;
}
friend bool operator!=(const Identifier &lhs, const Identifier &rhs) {
return !(lhs == rhs);
}
};
static_assert(sizeof(Identifier) == 7);
static_assert(util::is_pod<Identifier>::value);
}
| 1,138
|
C++
|
.h
| 30
| 33.633333
| 78
| 0.695376
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,684
|
sprofile_srv_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sprofile/srv/sprofile_srv_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::sprofile::srv {
void Initialize();
void StartIpcServer();
}
| 756
|
C++
|
.h
| 21
| 33.857143
| 76
| 0.751705
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,685
|
scs_server_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/scs/scs_server_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/sf.hpp>
namespace ams::scs {
enum Port {
Port_HtcTenv,
Port_Count,
};
constexpr inline int SessionCount[Port_Count] = {
6,
};
constexpr inline auto MaxSessions = [] {
auto total = 0;
for (const auto sessions : SessionCount) {
total += sessions;
}
return total;
}();
struct ServerOptions {
static constexpr size_t PointerBufferSize = 0;
static constexpr size_t MaxDomains = 6;
static constexpr size_t MaxDomainObjects = 16;
static constexpr bool CanDeferInvokeRequest = false;
static constexpr bool CanManageMitmServers = false;
};
class ServerManager final : public sf::hipc::ServerManager<Port_Count, ServerOptions, MaxSessions> {
/* ... */
};
ServerManager *GetServerManager();
void StartServer();
}
| 1,569
|
C++
|
.h
| 46
| 29.065217
| 104
| 0.685809
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,686
|
scs_tenv.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/scs/scs_tenv.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::scs {
void InitializeTenvServiceManager();
}
| 738
|
C++
|
.h
| 20
| 34.85
| 76
| 0.759441
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,687
|
scs_shell.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/scs/scs_shell.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/os.hpp>
#include <stratosphere/ncm/ncm_ids.hpp>
namespace ams::scs {
using ProcessEventHandler = void(*)(u64 id, s32 socket, os::ProcessId process_id);
void InitializeShell();
void RegisterCommonProcessEventHandler(ProcessEventHandler on_start, ProcessEventHandler on_exit, ProcessEventHandler on_jit_debug);
Result RegisterSocket(s32 socket, u64 id);
void UnregisterSocket(s32 socket);
Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, const void *args, size_t args_size, u32 process_flags);
inline Result LaunchProgram(os::ProcessId *out, ncm::ProgramId program_id, const void *args, size_t args_size, u32 process_flags) {
R_RETURN(LaunchProgram(out, ncm::ProgramLocation::Make(program_id, ncm::StorageId::BuiltInSystem), args, args_size, process_flags));
}
Result SubscribeProcessEvent(s32 socket, bool is_register, u64 id);
}
| 1,601
|
C++
|
.h
| 31
| 48.483871
| 140
| 0.759769
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,688
|
scs_shell_server.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/scs/scs_shell_server.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/os.hpp>
#include <stratosphere/htcs.hpp>
#include <stratosphere/scs/scs_command_processor.hpp>
namespace ams::scs {
class ShellServer {
private:
htcs::HtcsPortName m_port_name;
os::ThreadType m_thread;
u8 m_buffer[64_KB];
CommandProcessor *m_command_processor;
private:
static void ThreadEntry(void *arg) { reinterpret_cast<ShellServer *>(arg)->DoShellServer(); }
void DoShellServer();
public:
constexpr ShellServer() = default;
public:
void Initialize(const char *port_name, void *stack, size_t stack_size, CommandProcessor *command_processor);
void Start();
};
}
| 1,411
|
C++
|
.h
| 37
| 32.648649
| 120
| 0.690511
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,689
|
scs_command_processor.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/scs/scs_command_processor.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::scs {
struct alignas(alignof(u32)) CommandHeader {
u64 id __attribute__((packed));
u32 command;
u32 body_size;
};
static_assert(sizeof(CommandHeader) == 0x10);
static_assert(alignof(CommandHeader) == alignof(u32));
struct alignas(alignof(u32)) ResponseHeader {
u64 id __attribute__((packed));
u32 response;
u32 body_size;
};
static_assert(sizeof(ResponseHeader) == 0x10);
static_assert(alignof(ResponseHeader) == alignof(u32));
class CommandProcessor {
protected:
enum Command {
Command_None = 0,
Command_LaunchProgramFromHost = 1,
Command_TerminateProcesses = 2,
Command_GetFirmwareVersion = 3,
Command_Reboot = 4,
Command_SetSafeMode = 5,
Command_RegisterTenvDefinitionFilePath = 6,
Command_TerminateApplication = 7,
Command_Shutdown = 8,
Command_SubscribeProcessEvent = 9,
Command_GetTitleName = 10,
Command_ControlVirtualTemperature = 11,
Command_LaunchInstalledApplication = 12,
Command_LaunchGameCardApplication = 13,
Command_LaunchInstalledSystemProcess = 14,
Command_TakeScreenShot = 15,
Command_TakeForegroundScreenShot = 16,
Command_SimulateGameCardDetection = 17,
Command_SimulateSdCardDetection = 18,
Command_DumpRunningApplication = 19,
};
enum Response {
Response_None = 0,
Response_Success = 1,
Response_Error = 2,
Response_ProgramExited = 3,
Response_FirmwareVersion = 4,
Response_JitDebug = 5,
Response_ProgramLaunched = 6,
Response_TitleName = 7,
Response_ScreenShot = 8,
};
public:
constexpr CommandProcessor() = default;
void Initialize();
public:
virtual bool ProcessCommand(const CommandHeader &header, const u8 *body, s32 socket);
protected:
static std::scoped_lock<os::SdkMutex> MakeSendGuardBlock();
static void Send(s32 socket, const void *data, size_t size);
static void SendSuccess(s32 socket, const CommandHeader &header);
static void SendErrorResult(s32 socket, const CommandHeader &header, Result result);
private:
static void SendErrorResult(s32 socket, u64 id, Result result);
static void SendExited(s32 socket, u64 id, u64 process_id);
static void SendJitDebug(s32 socket, u64 id);
static void SendLaunched(s32 socket, u64 id, u64 process_id);
static void OnProcessStart(u64 id, s32 socket, os::ProcessId process_id);
static void OnProcessExit(u64 id, s32 socket, os::ProcessId process_id);
static void OnProcessJitDebug(u64 id, s32 socket, os::ProcessId process_id);
};
}
| 4,088
|
C++
|
.h
| 87
| 36.436782
| 97
| 0.578657
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,690
|
pinmux_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pinmux/pinmux_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pinmux {
/* ... */
}
| 714
|
C++
|
.h
| 20
| 33.65
| 76
| 0.743849
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,691
|
pinmux_driver_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/pinmux/driver/pinmux_driver_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::pinmux::driver {
void Initialize();
void Finalize();
void SetInitialConfig();
void SetInitialDrivePadConfig();
}
| 819
|
C++
|
.h
| 23
| 33.130435
| 76
| 0.75
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,692
|
ams_exosphere_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ams/ams_exosphere_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/ams/ams_types.hpp>
namespace ams::exosphere {
ApiInfo GetApiInfo();
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
void ForceRebootToRcm();
void ForceRebootToIramPayload();
void ForceRebootToFatalError();
void ForceRebootByPmic();
void ForceShutdown();
bool IsRcmBugPatched();
bool ShouldBlankProdInfo();
bool ShouldAllowWritesToProdInfo();
u64 GetDeviceId();
void CopyToIram(uintptr_t iram_dst, const void *dram_src, size_t size);
void CopyFromIram(void *dram_dst, uintptr_t iram_src, size_t size);
#endif
}
namespace ams {
/* Version checking utility. */
inline void CheckApiVersion() {
const u32 runtime_version = exosphere::GetApiInfo().GetVersion();
const u32 build_version = exosphere::GetVersion(ATMOSPHERE_RELEASE_VERSION);
if (runtime_version < build_version) {
R_ABORT_UNLESS(exosphere::ResultVersionMismatch());
}
}
}
| 1,622
|
C++
|
.h
| 43
| 33.488372
| 86
| 0.726054
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,693
|
ams_environment.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ams/ams_environment.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/ams/ams_types.hpp>
namespace ams {
/* Will be called by libstratosphere on crash. */
#if defined(ATMOSPHERE_OS_HORIZON)
void CrashHandler(ThreadExceptionDump *ctx);
#endif
/* API for boot sysmodule. */
void InitializeForBoot();
void SetInitialRebootPayload(const void *src, size_t src_size);
void *Malloc(size_t size);
void Free(void *ptr);
void *MallocForRapidJson(size_t size);
void *ReallocForRapidJson(void *ptr, size_t size);
void FreeForRapidJson(void *ptr);
}
| 1,193
|
C++
|
.h
| 31
| 35.258065
| 76
| 0.738528
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,694
|
ams_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ams/ams_types.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/sf/sf_buffer_tags.hpp>
#include <stratosphere/hos.hpp>
namespace ams::exosphere {
using TargetFirmware = ams::TargetFirmware;
constexpr ALWAYS_INLINE u32 GetVersion(u32 major, u32 minor, u32 micro) {
return (major << 16) | (minor << 8) | (micro);
}
struct ApiInfo {
using TargetFirmwareVersion = util::BitPack64::Field<0, 32, TargetFirmware>;
using MasterKeyRevision = util::BitPack64::Field<TargetFirmwareVersion::Next, 8, u32>;
using MicroVersion = util::BitPack64::Field<MasterKeyRevision::Next, 8, u32>;
using MinorVersion = util::BitPack64::Field<MicroVersion::Next, 8, u32>;
using MajorVersion = util::BitPack64::Field<MinorVersion::Next, 8, u32>;
util::BitPack64 value;
constexpr ALWAYS_INLINE u32 GetVersion() const {
return ::ams::exosphere::GetVersion(this->GetMajorVersion(), this->GetMinorVersion(), this->GetMicroVersion());
}
constexpr ALWAYS_INLINE u32 GetMajorVersion() const {
return this->value.Get<MajorVersion>();
}
constexpr ALWAYS_INLINE u32 GetMinorVersion() const {
return this->value.Get<MinorVersion>();
}
constexpr ALWAYS_INLINE u32 GetMicroVersion() const {
return this->value.Get<MicroVersion>();
}
constexpr ALWAYS_INLINE TargetFirmware GetTargetFirmware() const {
return this->value.Get<TargetFirmwareVersion>();
}
constexpr ALWAYS_INLINE u32 GetMasterKeyRevision() const {
return this->value.Get<MasterKeyRevision>();
}
};
}
namespace ams {
struct FatalErrorContext : ::ams::impl::FatalErrorContext, sf::LargeData, sf::PrefersMapAliasTransferMode {};
static_assert(sizeof(FatalErrorContext) == sizeof(::ams::impl::FatalErrorContext));
#ifdef ATMOSPHERE_GIT_BRANCH
NX_CONSTEXPR const char *GetGitBranch() {
return ATMOSPHERE_GIT_BRANCH;
}
#endif
#ifdef ATMOSPHERE_GIT_REVISION
NX_CONSTEXPR const char *GetGitRevision() {
return ATMOSPHERE_GIT_REVISION;
}
#endif
}
| 2,875
|
C++
|
.h
| 65
| 38.353846
| 123
| 0.678968
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,695
|
ams_emummc_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ams/ams_emummc_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/ams/ams_types.hpp>
namespace ams::emummc {
/* Get whether emummc is active. */
bool IsActive();
/* Get the active emummc id. */
u32 GetActiveId();
/* Get Nintendo redirection path. */
const char *GetNintendoDirPath();
/* Get Emummc folderpath, NULL if not file-based. */
const char *GetFilePath();
}
| 1,010
|
C++
|
.h
| 27
| 34.444444
| 76
| 0.727459
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,696
|
ams_system_thread_definitions.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::impl {
struct SystemThreadDefinition {
s32 priority;
const char *name;
};
#define AMS_DEFINE_SYSTEM_THREAD(__AMS_THREAD_PRIORITY__, __AMS_MODULE__, __AMS_THREAD_NAME__) \
constexpr inline const ::ams::impl::SystemThreadDefinition SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__ = { __AMS_THREAD_PRIORITY__, "ams." # __AMS_MODULE__ "." #__AMS_THREAD_NAME__ }
/* sm. */
AMS_DEFINE_SYSTEM_THREAD(-1, sm, Main);
AMS_DEFINE_SYSTEM_THREAD(-1, sm, DispatcherThread);
/* spl. */
AMS_DEFINE_SYSTEM_THREAD(-1, spl, Main);
/* Loader. */
AMS_DEFINE_SYSTEM_THREAD(21, ldr, Main);
/* Process Manager. */
AMS_DEFINE_SYSTEM_THREAD(21, pm, Main);
AMS_DEFINE_SYSTEM_THREAD(21, pm, ProcessTrack);
/* NCM. */
AMS_DEFINE_SYSTEM_THREAD(21, ncm, MainWaitThreads);
AMS_DEFINE_SYSTEM_THREAD(21, ncm, ContentManagerServerIpcSession);
AMS_DEFINE_SYSTEM_THREAD(21, ncm, LocationResolverServerIpcSession);
/* FS. */
AMS_DEFINE_SYSTEM_THREAD(11, sdmmc, DeviceDetector);
AMS_DEFINE_SYSTEM_THREAD(16, fs, WorkerThreadPool);
AMS_DEFINE_SYSTEM_THREAD(17, fs, Main);
AMS_DEFINE_SYSTEM_THREAD(17, fs, WorkerRealTimeAccess);
AMS_DEFINE_SYSTEM_THREAD(18, fs, WorkerNormalPriorityAccess);
AMS_DEFINE_SYSTEM_THREAD(19, fs, WorkerLowPriorityAccess);
AMS_DEFINE_SYSTEM_THREAD(30, fs, WorkerBackgroundAccess);
AMS_DEFINE_SYSTEM_THREAD(30, fs, PatrolReader);
/* Boot. */
AMS_DEFINE_SYSTEM_THREAD(-1, boot, Main);
/* Mitm. */
AMS_DEFINE_SYSTEM_THREAD(-7, mitm, InitializeThread);
AMS_DEFINE_SYSTEM_THREAD(-1, mitm_sf, QueryServerProcessThread);
AMS_DEFINE_SYSTEM_THREAD(16, mitm_fs, RomFileSystemInitializeThread);
AMS_DEFINE_SYSTEM_THREAD(16, mitm_fs, RomFileSystemFinalizeThread);
AMS_DEFINE_SYSTEM_THREAD(21, mitm, DebugThrowThread);
AMS_DEFINE_SYSTEM_THREAD(21, mitm_sysupdater, IpcServer);
AMS_DEFINE_SYSTEM_THREAD(21, mitm_sysupdater, AsyncPrepareSdCardUpdateTask);
/* boot2. */
AMS_DEFINE_SYSTEM_THREAD(20, boot2, Main);
/* LogManager. */
AMS_DEFINE_SYSTEM_THREAD(10, LogManager, MainThread);
AMS_DEFINE_SYSTEM_THREAD(10, lm, IpcServer);
AMS_DEFINE_SYSTEM_THREAD(10, lm, Flush);
AMS_DEFINE_SYSTEM_THREAD(10, lm, HtcsConnection);
/* dmnt. */
AMS_DEFINE_SYSTEM_THREAD(-3, dmnt, MultiCoreEventManager);
AMS_DEFINE_SYSTEM_THREAD(-1, dmnt, CheatDebugEvents);
AMS_DEFINE_SYSTEM_THREAD(-1, dmnt, MultiCoreBP);
AMS_DEFINE_SYSTEM_THREAD(11, dmnt, Main);
AMS_DEFINE_SYSTEM_THREAD(11, dmnt, Ipc);
AMS_DEFINE_SYSTEM_THREAD(11, dmnt, CheatDetect);
AMS_DEFINE_SYSTEM_THREAD(20, dmnt, CheatVirtualMachine);
/* fatal */
AMS_DEFINE_SYSTEM_THREAD(-13, fatal, Main);
AMS_DEFINE_SYSTEM_THREAD(-13, fatalsrv, FatalTaskThread);
AMS_DEFINE_SYSTEM_THREAD( 9, fatalsrv, IpcDispatcher);
/* creport. */
AMS_DEFINE_SYSTEM_THREAD(16, creport, Main);
/* ro. */
AMS_DEFINE_SYSTEM_THREAD(16, ro, Main);
/* gpio. */
AMS_DEFINE_SYSTEM_THREAD(-12, gpio, InterruptHandler);
/* bpc. */
AMS_DEFINE_SYSTEM_THREAD(4, bpc, IpcServer);
/* powctl. */
AMS_DEFINE_SYSTEM_THREAD(9, powctl, InterruptHandler);
/* hid. */
AMS_DEFINE_SYSTEM_THREAD(-10, hid, IpcServer);
/* ns.*/
AMS_DEFINE_SYSTEM_THREAD(21, ns, ApplicationManagerIpcSession);
AMS_DEFINE_SYSTEM_THREAD(21, nssrv, AsyncPrepareCardUpdateTask);
/* settings. */
AMS_DEFINE_SYSTEM_THREAD(21, settings, Main);
AMS_DEFINE_SYSTEM_THREAD(21, settings, IpcServer);
AMS_DEFINE_SYSTEM_THREAD(21, settings, LazyWriter);
/* erpt. */
AMS_DEFINE_SYSTEM_THREAD(21, erpt, Main);
AMS_DEFINE_SYSTEM_THREAD(21, erpt, IpcServer);
/* socket. */
AMS_DEFINE_SYSTEM_THREAD(29, socket, ResolverIpcServer);
/* jpegdec. */
AMS_DEFINE_SYSTEM_THREAD(21, jpegdec, Main);
/* pgl. */
AMS_DEFINE_SYSTEM_THREAD(21, pgl, Main);
AMS_DEFINE_SYSTEM_THREAD(21, pgl, ProcessControlTask);
/* htc. */
AMS_DEFINE_SYSTEM_THREAD(10, htc, Main);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcIpc);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcsIpc);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcsMonitor);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcfsIpc);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcfsMonitor);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowDiscovery);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowTcpServer);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowUsbIndication);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowListen);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowObserver);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowSend);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtclowReceive);
AMS_DEFINE_SYSTEM_THREAD(10, htc, Htcmisc);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcmiscReceive);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcmiscSend);
AMS_DEFINE_SYSTEM_THREAD(10, htc, HtcObserver);
AMS_DEFINE_SYSTEM_THREAD(10, tma, BridgePcieDriver);
/* cs/scs. */
AMS_DEFINE_SYSTEM_THREAD(20, cs, Main);
AMS_DEFINE_SYSTEM_THREAD(20, cs, HidctlService);
AMS_DEFINE_SYSTEM_THREAD(20, cs, HidctlLegacyServer);
AMS_DEFINE_SYSTEM_THREAD(20, cs, AudioServer);
AMS_DEFINE_SYSTEM_THREAD(10, cs, GrcVideoSender);
AMS_DEFINE_SYSTEM_THREAD(10, cs, GrcVideoReader);
AMS_DEFINE_SYSTEM_THREAD(10, cs, GrcAudioSender);
AMS_DEFINE_SYSTEM_THREAD(10, cs, GrcAudioReader);
AMS_DEFINE_SYSTEM_THREAD(21, scs, ShellServer);
AMS_DEFINE_SYSTEM_THREAD(21, scs, ShellEventHandler);
/* DevServer/TioServer. */
AMS_DEFINE_SYSTEM_THREAD(21, TioServer, Main);
AMS_DEFINE_SYSTEM_THREAD(21, TioServer, FileServerHtcsServer);
AMS_DEFINE_SYSTEM_THREAD(21, TioServer, SdCardObserver);
/* ServiceProfile */
AMS_DEFINE_SYSTEM_THREAD(-1, sprofile, IpcServer);
#undef AMS_DEFINE_SYSTEM_THREAD
}
#define AMS_GET_SYSTEM_THREAD_PRIORITY(__AMS_MODULE__, __AMS_THREAD_NAME__) ( ::ams::impl::SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__ ).priority
#define AMS_GET_SYSTEM_THREAD_NAME(__AMS_MODULE__, __AMS_THREAD_NAME__) ( ::ams::impl::SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__ ).name
| 6,957
|
C++
|
.h
| 145
| 43.117241
| 210
| 0.694863
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,697
|
dd_device_address_space_common.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_device_address_space_common.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/dd/dd_types.hpp>
namespace ams::dd {
#if defined(ATMOSPHERE_OS_HORIZON)
using DeviceName = ::ams::svc::DeviceName;
using enum ::ams::svc::DeviceName;
#else
enum DeviceName { };
#endif
constexpr inline u64 DeviceAddressSpaceMemoryRegionAlignment = 4_KB;
}
| 981
|
C++
|
.h
| 27
| 33.62963
| 76
| 0.745263
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,698
|
dd_device_address_space_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_device_address_space_types.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/dd/dd_types.hpp>
namespace ams::dd {
using DeviceVirtualAddress = u64;
using DeviceAddressSpaceHandle = os::NativeHandle;
struct DeviceAddressSpaceType {
enum State {
State_NotInitialized = 0,
State_Initialized = 1,
};
DeviceAddressSpaceHandle device_handle;
u8 state;
bool is_handle_managed;
};
static_assert(std::is_trivial<DeviceAddressSpaceType>::value);
}
| 1,157
|
C++
|
.h
| 32
| 31.9375
| 76
| 0.713393
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,699
|
dd_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_types.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/os.hpp>
namespace ams::dd {
using ProcessHandle = os::NativeHandle;
using MemoryPermission = os::MemoryPermission;
using enum os::MemoryPermission;
}
| 860
|
C++
|
.h
| 23
| 35.086957
| 76
| 0.758703
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,700
|
dd_process_handle.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_process_handle.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/dd/dd_types.hpp>
namespace ams::dd {
ProcessHandle GetCurrentProcessHandle();
}
| 781
|
C++
|
.h
| 21
| 35.190476
| 76
| 0.762219
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,701
|
dd_device_address_space.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_device_address_space.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/dd/dd_device_address_space_common.hpp>
#include <stratosphere/dd/dd_device_address_space_types.hpp>
#include <stratosphere/dd/dd_device_address_space_api.hpp>
| 854
|
C++
|
.h
| 20
| 40.95
| 76
| 0.770708
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,702
|
dd_device_address_space_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_device_address_space_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/dd/dd_types.hpp>
#include <stratosphere/dd/dd_device_address_space_common.hpp>
#include <stratosphere/dd/dd_device_address_space_types.hpp>
namespace ams::dd {
Result CreateDeviceAddressSpace(DeviceAddressSpaceType *das, u64 address, u64 size);
Result CreateDeviceAddressSpace(DeviceAddressSpaceType *das, u64 size);
void DestroyDeviceAddressSpace(DeviceAddressSpaceType *das);
void AttachDeviceAddressSpaceHandle(DeviceAddressSpaceType *das, DeviceAddressSpaceHandle handle, bool managed);
DeviceAddressSpaceHandle GetDeviceAddressSpaceHandle(DeviceAddressSpaceType *das);
Result MapDeviceAddressSpaceAligned(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address, MemoryPermission device_perm);
Result MapDeviceAddressSpaceNotAligned(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address, MemoryPermission device_perm);
void UnmapDeviceAddressSpace(DeviceAddressSpaceType *das, ProcessHandle process_handle, u64 process_address, size_t size, DeviceVirtualAddress device_address);
Result AttachDeviceAddressSpace(DeviceAddressSpaceType *das, DeviceName device_name);
void DetachDeviceAddressSpace(DeviceAddressSpaceType *das, DeviceName device_name);
}
| 2,044
|
C++
|
.h
| 32
| 60.96875
| 203
| 0.813965
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,703
|
dd_io_mappings.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd/dd_io_mappings.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::dd {
/* Convenience Helper. */
inline uintptr_t GetIoMapping(dd::PhysicalAddress phys_addr, size_t size) {
const uintptr_t io_mapping = dd::QueryIoMapping(phys_addr, size);
AMS_ABORT_UNLESS(io_mapping);
return io_mapping;
}
}
| 952
|
C++
|
.h
| 25
| 34.92
| 79
| 0.731311
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,704
|
tipc_allocators.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_allocators.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_service_object_base.hpp>
namespace ams::tipc {
template<typename T>
concept IsServiceObjectAllocator = requires (T &t) {
{ t.Allocate() } -> std::convertible_to<ServiceObjectBase *>;
};
template<typename T, size_t N> requires IsServiceObject<T>
class SingletonAllocator final {
static_assert(N >= 1);
private:
T m_singleton;
public:
constexpr ALWAYS_INLINE SingletonAllocator() : m_singleton() { /* ... */ }
ALWAYS_INLINE ServiceObjectBase *Allocate() { return std::addressof(m_singleton); }
};
template<typename T, size_t N> requires IsServiceObject<T>
class SlabAllocator final : public ServiceObjectDeleter {
private:
struct Entry {
bool used;
util::TypedStorage<T> storage;
};
private:
Entry m_entries[N];
os::SdkMutex m_mutex;
public:
constexpr ALWAYS_INLINE SlabAllocator() : m_entries(), m_mutex() { /* ... */ }
T *Allocate() {
std::scoped_lock lk(m_mutex);
for (size_t i = 0; i < N; ++i) {
if (!m_entries[i].used) {
m_entries[i].used = true;
return util::ConstructAt(m_entries[i].storage);
}
}
return nullptr;
}
void Deallocate(ServiceObjectBase *object) {
std::scoped_lock lk(m_mutex);
for (size_t i = 0; i < N; ++i) {
if (m_entries[i].used && GetPointer(m_entries[i].storage) == object) {
util::DestroyAt(m_entries[i].storage);
m_entries[i].used = false;
return;
}
}
AMS_ABORT("Failed to deallocate entry in SlabAllocator<T, N>");
}
public:
virtual void DeleteServiceObject(ServiceObjectBase *object) override {
return this->Deallocate(object);
}
};
static_assert(IsServiceObjectAllocator<SlabAllocator<ServiceObjectBase, 1>>);
static_assert(IsServiceObjectDeleter<SlabAllocator<ServiceObjectBase, 1>>);
}
| 3,030
|
C++
|
.h
| 74
| 30.77027
| 95
| 0.587156
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,705
|
tipc_handles.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_handles.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_out.hpp>
#include <stratosphere/tipc/tipc_pointer_and_size.hpp>
namespace ams::tipc {
/* TODO: How do InHandles work in tipc? No examples to work off of. */
class CopyHandle {
private:
CopyHandle();
};
class MoveHandle {
private:
MoveHandle();
};
template<>
class Out<CopyHandle> {
private:
tipc::NativeHandle * const m_ptr;
public:
ALWAYS_INLINE Out(tipc::NativeHandle *p) : m_ptr(p) { /* ... */ }
ALWAYS_INLINE void SetValue(tipc::NativeHandle v) const {
*m_ptr = v;
}
ALWAYS_INLINE const tipc::NativeHandle &GetValue() const {
return *m_ptr;
}
ALWAYS_INLINE tipc::NativeHandle *GetPointer() const {
return m_ptr;
}
/* Convenience operators. */
ALWAYS_INLINE tipc::NativeHandle &operator*() const {
return *m_ptr;
}
ALWAYS_INLINE tipc::NativeHandle *operator->() const {
return m_ptr;
}
};
template<>
class Out<MoveHandle> {
private:
tipc::NativeHandle * const m_ptr;
public:
ALWAYS_INLINE Out(tipc::NativeHandle *p) : m_ptr(p) { /* ... */ }
ALWAYS_INLINE void SetValue(tipc::NativeHandle v) const {
*m_ptr = v;
}
ALWAYS_INLINE const tipc::NativeHandle &GetValue() const {
return *m_ptr;
}
ALWAYS_INLINE tipc::NativeHandle *GetPointer() const {
return m_ptr;
}
/* Convenience operators. */
ALWAYS_INLINE tipc::NativeHandle &operator*() const {
return *m_ptr;
}
ALWAYS_INLINE tipc::NativeHandle *operator->() const {
return m_ptr;
}
};
using OutMoveHandle = tipc::Out<tipc::MoveHandle>;
using OutCopyHandle = tipc::Out<tipc::CopyHandle>;
}
| 2,780
|
C++
|
.h
| 78
| 26.602564
| 77
| 0.582868
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,706
|
tipc_buffers.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_buffers.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_out.hpp>
#include <stratosphere/tipc/tipc_pointer_and_size.hpp>
namespace ams::tipc {
namespace impl {
/* Buffer utilities. */
struct BufferBaseTag{};
}
namespace impl {
class BufferBase : public BufferBaseTag {
public:
static constexpr u32 AdditionalAttributes = 0;
private:
const tipc::PointerAndSize m_pas;
protected:
constexpr ALWAYS_INLINE uintptr_t GetAddressImpl() const {
return m_pas.GetAddress();
}
template<typename Entry>
constexpr ALWAYS_INLINE size_t GetSizeImpl() const {
return m_pas.GetSize() / sizeof(Entry);
}
public:
constexpr ALWAYS_INLINE BufferBase() : m_pas() { /* ... */ }
constexpr ALWAYS_INLINE BufferBase(const tipc::PointerAndSize &pas) : m_pas(pas) { /* ... */ }
constexpr ALWAYS_INLINE BufferBase(uintptr_t ptr, size_t sz) : m_pas(ptr, sz) { /* ... */ }
};
class InBufferBase : public BufferBase {
public:
using BaseType = BufferBase;
static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes |
SfBufferAttr_In;
public:
constexpr ALWAYS_INLINE InBufferBase() : BaseType() { /* ... */ }
constexpr ALWAYS_INLINE InBufferBase(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ }
constexpr ALWAYS_INLINE InBufferBase(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
ALWAYS_INLINE InBufferBase(const void *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE InBufferBase(const u8 *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
};
class OutBufferBase : public BufferBase {
public:
using BaseType = BufferBase;
static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes |
SfBufferAttr_Out;
public:
constexpr ALWAYS_INLINE OutBufferBase() : BaseType() { /* ... */ }
constexpr ALWAYS_INLINE OutBufferBase(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ }
constexpr ALWAYS_INLINE OutBufferBase(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
ALWAYS_INLINE OutBufferBase(void *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE OutBufferBase(u8 *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
};
template<u32 ExtraAttributes = 0>
class InBufferImpl : public InBufferBase {
public:
using BaseType = InBufferBase;
static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes |
ExtraAttributes;
public:
constexpr ALWAYS_INLINE InBufferImpl() : BaseType() { /* ... */ }
constexpr ALWAYS_INLINE InBufferImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ }
constexpr ALWAYS_INLINE InBufferImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
ALWAYS_INLINE InBufferImpl(const void *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE InBufferImpl(const u8 *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE const u8 *GetPointer() const {
return reinterpret_cast<const u8 *>(this->GetAddressImpl());
}
constexpr ALWAYS_INLINE size_t GetSize() const {
return this->GetSizeImpl<u8>();
}
};
template<u32 ExtraAttributes = 0>
class OutBufferImpl : public OutBufferBase {
public:
using BaseType = OutBufferBase;
static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes |
ExtraAttributes;
public:
constexpr ALWAYS_INLINE OutBufferImpl() : BaseType() { /* ... */ }
constexpr ALWAYS_INLINE OutBufferImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ }
constexpr ALWAYS_INLINE OutBufferImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
ALWAYS_INLINE OutBufferImpl(void *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE OutBufferImpl(u8 *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE u8 *GetPointer() const {
return reinterpret_cast<u8 *>(this->GetAddressImpl());
}
constexpr ALWAYS_INLINE size_t GetSize() const {
return this->GetSizeImpl<u8>();
}
};
template<typename T>
struct InArrayImpl : public InBufferBase {
public:
using BaseType = InBufferBase;
static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes;
public:
constexpr ALWAYS_INLINE InArrayImpl() : BaseType() { /* ... */ }
constexpr ALWAYS_INLINE InArrayImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ }
constexpr ALWAYS_INLINE InArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
ALWAYS_INLINE InArrayImpl(const T *ptr, size_t num_elements) : BaseType(reinterpret_cast<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
ALWAYS_INLINE const T *GetPointer() const {
return reinterpret_cast<const T *>(this->GetAddressImpl());
}
constexpr ALWAYS_INLINE size_t GetSize() const {
return this->GetSizeImpl<T>();
}
ALWAYS_INLINE const T &operator[](size_t i) const {
return this->GetPointer()[i];
}
constexpr explicit ALWAYS_INLINE operator Span<const T>() const {
return {this->GetPointer(), this->GetSize()};
}
constexpr ALWAYS_INLINE Span<const T> ToSpan() const {
return {this->GetPointer(), this->GetSize()};
}
};
template<typename T>
struct OutArrayImpl : public OutBufferBase {
public:
using BaseType = OutBufferBase;
static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes;
public:
constexpr ALWAYS_INLINE OutArrayImpl() : BaseType() { /* ... */ }
constexpr ALWAYS_INLINE OutArrayImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ }
constexpr ALWAYS_INLINE OutArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
ALWAYS_INLINE OutArrayImpl(T *ptr, size_t num_elements) : BaseType(reinterpret_cast<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
ALWAYS_INLINE T *GetPointer() const {
return reinterpret_cast<T *>(this->GetAddressImpl());
}
constexpr ALWAYS_INLINE size_t GetSize() const {
return this->GetSizeImpl<T>();
}
ALWAYS_INLINE T &operator[](size_t i) const {
return this->GetPointer()[i];
}
constexpr explicit ALWAYS_INLINE operator Span<T>() const {
return {this->GetPointer(), this->GetSize()};
}
constexpr ALWAYS_INLINE Span<T> ToSpan() const {
return {this->GetPointer(), this->GetSize()};
}
};
}
/* Buffer Types. */
using InBuffer = typename impl::InBufferImpl<>;
// using InNonSecureBuffer = typename impl::InBufferImpl<SfBufferAttr_HipcMapTransferAllowsNonSecure>;
// using InNonDeviceBuffer = typename impl::InBufferImpl<SfBufferAttr_HipcMapTransferAllowsNonDevice>;
using OutBuffer = typename impl::OutBufferImpl<>;
//using OutNonSecureBuffer = typename impl::OutBufferImpl<SfBufferAttr_HipcMapTransferAllowsNonSecure>;
//using OutNonDeviceBuffer = typename impl::OutBufferImpl<SfBufferAttr_HipcMapTransferAllowsNonDevice>;
template<typename T>
using InArray = typename impl::InArrayImpl<T>;
template<typename T>
using OutArray = typename impl::OutArrayImpl<T>;
/* Attribute serialization structs. */
template<typename T>
concept IsBuffer = std::derived_from<T, impl::BufferBaseTag>;
template<typename T> requires IsBuffer<T>
constexpr inline u32 BufferAttributes = SfBufferAttr_HipcMapAlias | T::AdditionalAttributes;
}
| 10,075
|
C++
|
.h
| 175
| 43.451429
| 161
| 0.57324
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,707
|
tipc_deferral_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_deferral_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
#include <stratosphere/tipc/tipc_object_holder.hpp>
#include <stratosphere/tipc/tipc_service_object_base.hpp>
namespace ams::tipc {
template<typename T>
concept IsResumeKey = util::is_pod<T>::value && (0 < sizeof(T) && sizeof(T) <= sizeof(uintptr_t));
template<IsResumeKey ResumeKey>
static constexpr ALWAYS_INLINE uintptr_t ConvertToInternalResumeKey(ResumeKey key) {
if constexpr (std::same_as<ResumeKey, uintptr_t>) {
return key;
} else if constexpr (sizeof(key) == sizeof(uintptr_t)) {
return std::bit_cast<uintptr_t>(key);
} else {
uintptr_t converted = 0;
std::memcpy(std::addressof(converted), std::addressof(key), sizeof(key));
return converted;
}
}
class DeferralManagerBase;
namespace impl {
class DeferrableBaseTag{};
}
class DeferrableBaseImpl : public impl::DeferrableBaseTag {
private:
DeferralManagerBase *m_deferral_manager;
ObjectHolder m_object_holder;
uintptr_t m_resume_key;
const u32 m_message_buffer_size;
u8 m_message_buffer_base[0];
public:
ALWAYS_INLINE DeferrableBaseImpl(u32 mb_size) : m_deferral_manager(nullptr), m_object_holder(), m_resume_key(), m_message_buffer_size(mb_size) { /* ... */ }
~DeferrableBaseImpl();
ALWAYS_INLINE void SetDeferralManager(DeferralManagerBase *manager, tipc::NativeHandle reply_target, ServiceObjectBase *object) {
m_deferral_manager = manager;
m_object_holder.InitializeForDeferralManager(reply_target, object);
}
ALWAYS_INLINE bool TestResume(uintptr_t key) const {
return m_resume_key == key;
}
template<IsResumeKey ResumeKey>
ALWAYS_INLINE void RegisterRetry(ResumeKey key) {
m_resume_key = ConvertToInternalResumeKey(key);
std::memcpy(m_message_buffer_base, tipc::GetMessageBuffer(), m_message_buffer_size);
}
template<IsResumeKey ResumeKey, typename F>
ALWAYS_INLINE Result RegisterRetryIfDeferred(ResumeKey key, F f) {
ON_RESULT_INCLUDED(tipc::ResultRequestDeferred) { this->RegisterRetry(key); };
R_RETURN(f());
}
template<typename PortManager>
ALWAYS_INLINE void TriggerResume(PortManager *port_manager) {
/* Clear resume key. */
m_resume_key = 0;
/* Restore message buffer. */
std::memcpy(tipc::GetMessageBuffer(), m_message_buffer_base, m_message_buffer_size);
/* Process the request. */
return port_manager->ProcessDeferredRequest(m_object_holder);
}
protected:
static consteval size_t GetMessageBufferOffsetBase();
};
static_assert(std::is_standard_layout<DeferrableBaseImpl>::value);
#define TIPC_REGISTER_RETRY_ON_RESULT_REQUEST_DEFERRED(KEY) ON_RESULT_INCLUDED(tipc::ResultRequestDeferred) { this->RegisterRetry(KEY); }
template<size_t _MessageBufferRequiredSize>
class DeferrableBaseImplWithBuffer : public DeferrableBaseImpl {
private:
static constexpr size_t MessageBufferRequiredSize = _MessageBufferRequiredSize;
private:
u8 m_message_buffer[MessageBufferRequiredSize];
public:
DeferrableBaseImplWithBuffer();
private:
static consteval size_t GetMessageBufferOffset();
};
consteval size_t DeferrableBaseImpl::GetMessageBufferOffsetBase() {
return AMS_OFFSETOF(DeferrableBaseImpl, m_message_buffer_base);
}
template<size_t _MessageBufferRequiredSize>
consteval size_t DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>::GetMessageBufferOffset() {
return AMS_OFFSETOF(DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>, m_message_buffer);
}
template<size_t _MessageBufferRequiredSize>
ALWAYS_INLINE DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>::DeferrableBaseImplWithBuffer() : DeferrableBaseImpl(MessageBufferRequiredSize) {
static_assert(GetMessageBufferOffsetBase() == GetMessageBufferOffset());
static_assert(sizeof(DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>) >= sizeof(DeferrableBaseImpl) + MessageBufferRequiredSize);
}
template<typename Interface, size_t MaximumDefaultRequestSize = 0>
class DeferrableBase : public DeferrableBaseImplWithBuffer<std::max(Interface::MaximumRequestSize, MaximumDefaultRequestSize)> {
private:
using BaseImpl = DeferrableBaseImplWithBuffer<std::max(Interface::MaximumRequestSize, MaximumDefaultRequestSize)>;
public:
using BaseImpl::BaseImpl;
};
template<class T>
concept IsDeferrable = std::derived_from<T, impl::DeferrableBaseTag>;
class DeferralManagerBase {
NON_COPYABLE(DeferralManagerBase);
NON_MOVEABLE(DeferralManagerBase);
private:
size_t m_object_count;
DeferrableBaseImpl *m_objects_base[0];
public:
ALWAYS_INLINE DeferralManagerBase() : m_object_count(0) { /* ... */ }
void AddObject(DeferrableBaseImpl &object, tipc::NativeHandle reply_target, ServiceObjectBase *service_object) {
/* Set ourselves as the manager for the object. */
object.SetDeferralManager(this, reply_target, service_object);
/* Add the object to our entries. */
m_objects_base[m_object_count++] = std::addressof(object);
}
void RemoveObject(DeferrableBaseImpl *object) {
/* If the object is present, remove it. */
for (size_t i = 0; i < m_object_count; ++i) {
if (m_objects_base[i] == object) {
std::swap(m_objects_base[i], m_objects_base[--m_object_count]);
break;
}
}
}
ALWAYS_INLINE bool TestResume(uintptr_t resume_key) const {
/* Try to resume all entries. */
for (size_t i = 0; i < m_object_count; ++i) {
if (m_objects_base[i]->TestResume(resume_key)) {
return true;
}
}
return false;
}
template<typename PortManager>
ALWAYS_INLINE void TriggerResume(PortManager *port_manager, uintptr_t resume_key) const {
/* Try to resume all entries. */
for (size_t i = 0; i < m_object_count; ++i) {
if (m_objects_base[i]->TestResume(resume_key)) {
m_objects_base[i]->TriggerResume(port_manager);
}
}
}
protected:
static consteval size_t GetObjectPointersOffsetBase();
};
static_assert(std::is_standard_layout<DeferralManagerBase>::value);
inline DeferrableBaseImpl::~DeferrableBaseImpl() {
AMS_ASSUME(m_deferral_manager != nullptr);
m_deferral_manager->RemoveObject(this);
}
template<size_t N> requires (N > 0)
class DeferralManager final : public DeferralManagerBase {
private:
DeferrableBaseImpl *m_objects[N];
public:
DeferralManager();
private:
static consteval size_t GetObjectPointersOffset();
};
consteval size_t DeferralManagerBase::GetObjectPointersOffsetBase() {
return AMS_OFFSETOF(DeferralManagerBase, m_objects_base);
}
template<size_t N> requires (N > 0)
consteval size_t DeferralManager<N>::GetObjectPointersOffset() {
return AMS_OFFSETOF(DeferralManager<N>, m_objects);
}
template<size_t N> requires (N > 0)
inline DeferralManager<N>::DeferralManager() : DeferralManagerBase() {
static_assert(GetObjectPointersOffset() == GetObjectPointersOffsetBase());
static_assert(sizeof(DeferralManager<N>) == sizeof(DeferralManagerBase) + N * sizeof(DeferrableBaseImpl *));
}
}
| 8,932
|
C++
|
.h
| 183
| 38.47541
| 168
| 0.645161
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,708
|
tipc_common.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_common.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/ams.hpp>
#include <stratosphere/os.hpp>
#include <stratosphere/sm/sm_types.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
| 826
|
C++
|
.h
| 21
| 37.666667
| 76
| 0.767702
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,709
|
tipc_server_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_service_object.hpp>
#include <stratosphere/tipc/tipc_object_manager.hpp>
#include <stratosphere/tipc/tipc_deferral_manager.hpp>
namespace ams::tipc {
template<size_t NumSessions, typename Interface, typename Impl, template<typename, size_t> typename _Allocator>
struct PortMeta {
static constexpr inline size_t MaxSessions = NumSessions;
static constexpr bool CanDeferInvokeRequest = IsDeferrable<Impl>;
using ServiceObject = tipc::ServiceObject<Interface, Impl>;
using Allocator = _Allocator<ServiceObject, NumSessions>;
};
struct DummyDeferralManagerBase{};
template<size_t N>
struct DummyDeferralManager : public DummyDeferralManagerBase {};
namespace impl {
template<size_t ThreadStackSize, bool IsDeferralSupported, size_t NumPorts, typename... PortInfos>
class ServerManagerImpl {
private:
static_assert(NumPorts == sizeof...(PortInfos));
static constexpr inline size_t MaxSessions = (PortInfos::MaxSessions + ...);
/* Verify that we have at least one port. */
static_assert(NumPorts > 0);
/* Verify that it's possible to service this many sessions, with our port manager count. */
static_assert(MaxSessions <= NumPorts * MaximumSessionsPerPort);
static_assert(util::IsAligned(ThreadStackSize, os::ThreadStackAlignment));
alignas(os::ThreadStackAlignment) static constinit inline u8 s_port_stacks[ThreadStackSize * (NumPorts - 1)];
template<size_t Ix> AMS_CONCEPTS_REQUIRES_IF_SUPPORTED(Ix < NumPorts)
static constexpr inline size_t SessionsPerPortManager = (Ix == NumPorts - 1) ? ((MaxSessions / NumPorts) + MaxSessions % NumPorts)
: ((MaxSessions / NumPorts));
template<size_t Ix> AMS_CONCEPTS_REQUIRES_IF_SUPPORTED(Ix < NumPorts)
using PortInfo = typename std::tuple_element<Ix, std::tuple<PortInfos...>>::type;
static_assert(IsDeferralSupported == (PortInfos::CanDeferInvokeRequest || ...));
template<size_t Sessions>
using DeferralManagerImplType = typename std::conditional<IsDeferralSupported, DeferralManager<Sessions>, DummyDeferralManager<Sessions>>::type;
using DeferralManagerBaseType = typename std::conditional<IsDeferralSupported, DeferralManagerBase, DummyDeferralManagerBase>::type;
template<size_t Ix> AMS_CONCEPTS_REQUIRES_IF_SUPPORTED(Ix < NumPorts)
static constexpr inline bool IsPortDeferrable = PortInfo<Ix>::CanDeferInvokeRequest;
public:
class PortManagerBase {
public:
enum MessageType : u8 {
MessageType_AddSession = 0,
MessageType_TriggerResume = 1,
};
protected:
s32 m_id;
std::atomic<s32> m_num_sessions;
s32 m_port_number;
os::MultiWaitType m_multi_wait;
os::MessageQueueType m_message_queue;
os::MultiWaitHolderType m_message_queue_holder;
uintptr_t m_message_queue_storage[MaxSessions];
ServerManagerImpl *m_server_manager;
ObjectManagerBase *m_object_manager;
DeferralManagerBaseType *m_deferral_manager;
public:
PortManagerBase() : m_id(), m_num_sessions(), m_port_number(), m_multi_wait(), m_message_queue(), m_message_queue_holder(), m_message_queue_storage(), m_server_manager(), m_object_manager(), m_deferral_manager() {
/* Setup our message queue. */
os::InitializeMessageQueue(std::addressof(m_message_queue), m_message_queue_storage, util::size(m_message_queue_storage));
os::InitializeMultiWaitHolder(std::addressof(m_message_queue_holder), std::addressof(m_message_queue), os::MessageQueueWaitType::ForNotEmpty);
}
constexpr s32 GetPortIndex() const {
return m_port_number;
}
s32 GetSessionCount() const {
return m_num_sessions;
}
void InitializeBase(s32 id, ServerManagerImpl *sm, DeferralManagerBaseType *dm, ObjectManagerBase *om) {
/* Set our id. */
m_id = id;
/* Set our server manager. */
m_server_manager = sm;
/* Reset our session count. */
m_num_sessions = 0;
/* Initialize our multi wait. */
os::InitializeMultiWait(std::addressof(m_multi_wait));
os::LinkMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_message_queue_holder));
/* Initialize our object manager. */
m_object_manager = om;
/* Initialize our deferral manager. */
m_deferral_manager = dm;
}
void RegisterPort(s32 index, tipc::NativeHandle port_handle) {
/* Set our port number. */
m_port_number = index;
/* Create an object holder for the port. */
tipc::ObjectHolder object;
/* Setup the object. */
object.InitializeAsPort(port_handle);
/* Register the object. */
m_object_manager->AddObject(object);
}
tipc::NativeHandle ProcessRequest(ObjectHolder &object) {
/* Acquire exclusive server manager access. */
std::scoped_lock lk(m_server_manager->GetMutex());
/* Process the request. */
const Result result = m_object_manager->ProcessRequest(object);
if (R_SUCCEEDED(result)) {
/* We should reply only if the request isn't deferred. */
return !IsRequestDeferred() ? object.GetHandle() : tipc::InvalidNativeHandle;
} else {
/* Processing failed, so note the session as closed (or close it). */
this->CloseSessionIfNecessary(object, !tipc::ResultSessionClosed::Includes(result));
/* We shouldn't reply on failure. */
return tipc::InvalidNativeHandle;
}
}
template<bool Enable = IsDeferralSupported, typename = typename std::enable_if<Enable>::type>
void ProcessDeferredRequest(ObjectHolder &object) {
static_assert(Enable == IsDeferralSupported);
if (const auto reply_target = this->ProcessRequest(object); reply_target != tipc::InvalidNativeHandle) {
m_object_manager->Reply(reply_target);
}
}
bool ReplyAndReceive(os::MultiWaitHolderType **out_holder, ObjectHolder *out_object, tipc::NativeHandle reply_target) {
/* If we don't have a reply target, clear our message buffer. */
if (reply_target == tipc::InvalidNativeHandle) {
tipc::MessageBuffer(tipc::GetMessageBuffer()).SetNull();
}
/* Try to reply/receive. */
const Result result = m_object_manager->ReplyAndReceive(out_holder, out_object, reply_target, std::addressof(m_multi_wait));
/* Acquire exclusive access to the server manager. */
std::scoped_lock lk(m_server_manager->GetMutex());
/* Handle the result. */
R_TRY_CATCH(result) {
R_CATCH(os::ResultSessionClosedForReceive, os::ResultReceiveListBroken) {
/* Close the object. */
this->CloseSession(*out_object);
/* We don't have anything to process. */
return false;
}
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
return true;
}
void AddSession(tipc::NativeHandle session_handle, tipc::ServiceObjectBase *service_object) {
/* Create an object holder for the session. */
tipc::ObjectHolder object;
/* Setup the object. */
object.InitializeAsSession(session_handle, true, service_object);
/* Register the object. */
m_object_manager->AddObject(object);
}
void ProcessMessages() {
/* While we have messages in our queue, receive and handle them. */
uintptr_t message_type, message_data;
while (os::TryReceiveMessageQueue(std::addressof(message_type), std::addressof(m_message_queue))) {
/* Receive the message's data. */
os::ReceiveMessageQueue(std::addressof(message_data), std::addressof(m_message_queue));
/* Handle the specific message. */
switch (static_cast<MessageType>(static_cast<typename std::underlying_type<MessageType>::type>(message_type))) {
case MessageType_AddSession:
{
/* Get the handle from where it's packed into the message type. */
const tipc::NativeHandle session_handle = tipc::DecodeNativeHandleForMessageQueue(message_type >> BITSIZEOF(u32));
/* Allocate a service object for the port. */
auto *service_object = m_server_manager->AllocateObject(static_cast<size_t>(message_data), session_handle, *m_deferral_manager);
/* Add the newly-created service object. */
this->AddSession(session_handle, service_object);
}
break;
case MessageType_TriggerResume:
if constexpr (IsDeferralSupported) {
/* Perform the resume. */
this->OnTriggerResume(message_data);
}
break;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}
void CloseSession(ObjectHolder &object) {
/* Get the object's handle. */
const auto handle = object.GetHandle();
/* Close the object with our manager. */
m_object_manager->CloseObject(handle);
/* Close the handle itself. */
R_ABORT_UNLESS(tipc::impl::CloseHandle(handle));
/* Decrement our session count. */
--m_num_sessions;
}
void CloseSessionIfNecessary(ObjectHolder &object, bool necessary) {
if (necessary) {
/* Get the object's handle. */
const auto handle = object.GetHandle();
/* Close the object with our manager. */
m_object_manager->CloseObject(handle);
/* Close the handle itself. */
R_ABORT_UNLESS(tipc::impl::CloseHandle(handle));
}
/* Decrement our session count. */
--m_num_sessions;
}
bool TestResume(uintptr_t key) {
if constexpr (IsDeferralSupported) {
/* Acquire exclusive server manager access. */
std::scoped_lock lk(m_server_manager->GetMutex());
/* Check to see if the key corresponds to some deferred message. */
return m_deferral_manager->TestResume(key);
} else {
return false;
}
}
void TriggerResume(uintptr_t key) {
/* Acquire exclusive server manager access. */
std::scoped_lock lk(m_server_manager->GetMutex());
/* Send the key as a message. */
os::SendMessageQueue(std::addressof(m_message_queue), static_cast<uintptr_t>(MessageType_TriggerResume));
os::SendMessageQueue(std::addressof(m_message_queue), key);
}
void TriggerAddSession(tipc::NativeHandle session_handle, size_t port_index) {
/* Increment our session count. */
++m_num_sessions;
/* Send information about the session as a message. */
os::SendMessageQueue(std::addressof(m_message_queue), static_cast<uintptr_t>(MessageType_AddSession) | (static_cast<u64>(tipc::EncodeNativeHandleForMessageQueue(session_handle)) << BITSIZEOF(u32)));
os::SendMessageQueue(std::addressof(m_message_queue), static_cast<uintptr_t>(port_index));
}
private:
void OnTriggerResume(uintptr_t key) {
/* Acquire exclusive server manager access. */
std::scoped_lock lk(m_server_manager->GetMutex());
/* Trigger the resume. */
m_deferral_manager->TriggerResume(this, key);
}
public:
static bool IsRequestDeferred() {
if constexpr (IsDeferralSupported) {
/* Get the message buffer. */
const tipc::MessageBuffer message_buffer(tipc::GetMessageBuffer());
/* Parse the hipc headers. */
const tipc::MessageBuffer::MessageHeader message_header(message_buffer);
const tipc::MessageBuffer::SpecialHeader special_header(message_buffer, message_header);
/* Determine raw data index. */
const auto raw_data_offset = message_buffer.GetRawDataIndex(message_header, special_header);
/* Result is the first raw data word. */
const Result method_result = message_buffer.GetRaw<u32>(raw_data_offset);
/* Check that the result is the special deferral result. */
return tipc::ResultRequestDeferred::Includes(method_result);
} else {
/* If deferral isn't supported, requests are never deferred. */
return false;
}
}
};
template<typename PortInfo, size_t PortSessions>
class PortManagerImpl final : public PortManagerBase {
private:
DeferralManagerImplType<PortSessions> m_deferral_manager_impl;
tipc::ObjectManager<1 + PortSessions> m_object_manager_impl;
public:
PortManagerImpl() : PortManagerBase(), m_deferral_manager_impl(), m_object_manager_impl() {
/* ... */
}
void Initialize(s32 id, ServerManagerImpl *sm) {
/* Initialize our base. */
this->InitializeBase(id, sm, std::addressof(m_deferral_manager_impl), std::addressof(m_object_manager_impl));
/* Initialize our object manager. */
m_object_manager_impl.Initialize(std::addressof(this->m_multi_wait));
}
};
template<size_t Ix>
using PortManager = PortManagerImpl<PortInfo<Ix>, SessionsPerPortManager<Ix>>;
using PortManagerTuple = decltype([]<size_t... Ix>(std::index_sequence<Ix...>) {
return std::tuple<PortManager<Ix>...>{};
}(std::make_index_sequence<NumPorts>()));
using PortAllocatorTuple = std::tuple<typename PortInfos::Allocator...>;
private:
os::SdkRecursiveMutex m_mutex;
PortManagerTuple m_port_managers;
PortAllocatorTuple m_port_allocators;
os::ThreadType m_port_threads[NumPorts - 1];
private:
template<size_t Ix>
ALWAYS_INLINE auto &GetPortManager() {
return std::get<Ix>(m_port_managers);
}
template<size_t Ix>
ALWAYS_INLINE const auto &GetPortManager() const {
return std::get<Ix>(m_port_managers);
}
template<size_t Ix>
void LoopAutoForPort() {
R_ABORT_UNLESS(this->LoopProcess(this->GetPortManager<Ix>()));
}
template<size_t Ix>
static void LoopAutoForPortThreadFunction(void *_this) {
static_cast<ServerManagerImpl *>(_this)->LoopAutoForPort<Ix>();
}
template<size_t Ix>
void InitializePortThread(s32 priority, const char *name) {
/* Create the thread. */
R_ABORT_UNLESS(os::CreateThread(m_port_threads + Ix, &LoopAutoForPortThreadFunction<Ix>, this, s_port_stacks + Ix, ThreadStackSize, priority));
/* Set the thread name pointer. */
if (name != nullptr) {
os::SetThreadNamePointer(m_port_threads + Ix, name);
}
/* Start the thread. */
os::StartThread(m_port_threads + Ix);
}
public:
ServerManagerImpl() : m_mutex(), m_port_managers(), m_port_allocators() { /* ... */ }
os::SdkRecursiveMutex &GetMutex() { return m_mutex; }
void Initialize() {
/* Initialize our port managers. */
[this]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
(this->GetPortManager<Ix>().Initialize(static_cast<s32>(Ix), this), ...);
}(std::make_index_sequence<NumPorts>());
}
template<size_t Ix>
void RegisterPort(tipc::NativeHandle port_handle) {
this->GetPortManager<Ix>().RegisterPort(static_cast<s32>(Ix), port_handle);
}
template<size_t Ix>
void RegisterPort(sm::ServiceName service_name, size_t max_sessions) {
/* Register service. */
tipc::NativeHandle port_handle;
R_ABORT_UNLESS(sm::RegisterService(std::addressof(port_handle), service_name, max_sessions, false));
/* Register the port handle. */
this->RegisterPort<Ix>(port_handle);
}
void LoopAuto() {
/* If we have additional threads, create and start them. */
if constexpr (NumPorts > 1) {
const auto thread_priority = os::GetThreadPriority(os::GetCurrentThread());
[thread_priority, this]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
/* Create all threads. */
(this->InitializePortThread<Ix>(thread_priority, nullptr), ...);
}(std::make_index_sequence<NumPorts - 1>());
}
/* Process for the last port. */
this->LoopAutoForPort<NumPorts - 1>();
}
void LoopAuto(int priority, const char *name) {
/* If we have additional threads, create and start them. */
if constexpr (NumPorts > 1) {
[priority, name, this]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
/* Create all threads. */
(this->InitializePortThread<Ix>(priority, name), ...);
}(std::make_index_sequence<NumPorts - 1>());
}
/* Check current thread. */
{
AMS_ASSERT(priority == os::GetThreadPriority(os::GetCurrentThread()));
/* N does not do: os::SetThreadNamePointer(os::GetCurrentThread(), name); */
}
/* Process for the last port. */
this->LoopAutoForPort<NumPorts - 1>();
}
tipc::ServiceObjectBase *AllocateObject(size_t port_index, tipc::NativeHandle handle, DeferralManagerBaseType &deferral_manager) {
/* Check that the port index is valid. */
AMS_ABORT_UNLESS(port_index < NumPorts);
/* Try to allocate from each port, in turn. */
tipc::ServiceObjectBase *allocated = nullptr;
[this, port_index, handle, &deferral_manager, &allocated]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
(this->TryAllocateObject<Ix>(port_index, handle, deferral_manager, allocated), ...);
}(std::make_index_sequence<NumPorts>());
/* Return the allocated object. */
AMS_ABORT_UNLESS(allocated != nullptr);
return allocated;
}
template<IsResumeKey ResumeKey>
void TriggerResume(const ResumeKey &resume_key) {
/* Acquire exclusive access to ourselves. */
std::scoped_lock lk(m_mutex);
/* Convert to internal resume key. */
const auto internal_resume_key = ConvertToInternalResumeKey(resume_key);
/* Check/trigger resume on each of our ports. */
[this, internal_resume_key]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
(this->TriggerResumeImpl<Ix>(internal_resume_key), ...);
}(std::make_index_sequence<NumPorts>());
}
Result AddSession(tipc::NativeHandle *out, tipc::ServiceObjectBase *object) {
/* Acquire exclusive access to ourselves. */
std::scoped_lock lk(m_mutex);
/* Create a handle for the session. */
tipc::NativeHandle session_handle;
R_TRY(tipc::impl::CreateSession(std::addressof(session_handle), static_cast<tipc::NativeHandle *>(out), false, 0));
/* Select the best port manager. */
PortManagerBase *best_manager = nullptr;
s32 best_sessions = -1;
[this, &best_manager, &best_sessions]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
(this->TrySelectBetterPort<Ix>(best_manager, best_sessions), ...);
}(std::make_index_sequence<NumPorts>());
/* Add the session to the least burdened manager. */
best_manager->AddSession(session_handle, object);
R_SUCCEED();
}
private:
template<size_t Ix> requires (Ix < NumPorts)
void TryAllocateObject(size_t port_index, tipc::NativeHandle handle, DeferralManagerBaseType &deferral_manager, tipc::ServiceObjectBase *&allocated) {
/* Check that the port index matches. */
if (port_index == Ix) {
/* Check that we haven't already allocated. */
AMS_ABORT_UNLESS(allocated == nullptr);
/* Get the allocator. */
auto &allocator = std::get<Ix>(m_port_allocators);
/* Allocate the object. */
auto * const new_object = allocator.Allocate();
AMS_ABORT_UNLESS(new_object != nullptr);
/* If we should, set the object's deleter. */
if constexpr (IsServiceObjectDeleter<typename std::tuple_element<Ix, PortAllocatorTuple>::type>) {
new_object->SetDeleter(std::addressof(allocator));
}
/* If we should, set the object's deferral manager. */
if constexpr (IsPortDeferrable<Ix>) {
deferral_manager.AddObject(new_object->GetImpl(), handle, new_object);
}
/* Set the allocated object. */
allocated = new_object;
}
}
Result LoopProcess(PortManagerBase &port_manager) {
/* Process requests forever. */
tipc::NativeHandle reply_target = tipc::InvalidNativeHandle;
while (true) {
/* Reply to our pending request, and wait to receive a new one. */
os::MultiWaitHolderType *signaled_holder = nullptr;
tipc::ObjectHolder signaled_object{};
while (!port_manager.ReplyAndReceive(std::addressof(signaled_holder), std::addressof(signaled_object), reply_target)) {
reply_target = tipc::InvalidNativeHandle;
signaled_object = {};
}
if (signaled_holder == nullptr) {
/* A session was signaled, accessible via signaled_object. */
switch (signaled_object.GetType()) {
case ObjectHolder::ObjectType_Port:
{
/* Try to accept a new session */
tipc::NativeHandle session_handle;
if (R_SUCCEEDED(tipc::impl::AcceptSession(std::addressof(session_handle), signaled_object.GetHandle()))) {
this->TriggerAddSession(session_handle, static_cast<size_t>(port_manager.GetPortIndex()));
}
/* We have nothing to reply to. */
reply_target = tipc::InvalidNativeHandle;
}
break;
case ObjectHolder::ObjectType_Session:
{
/* Process the request */
reply_target = port_manager.ProcessRequest(signaled_object);
}
break;
AMS_UNREACHABLE_DEFAULT_CASE();
}
} else {
/* Our message queue was signaled. */
port_manager.ProcessMessages();
/* We have nothing to reply to. */
reply_target = tipc::InvalidNativeHandle;
}
}
}
void TriggerAddSession(tipc::NativeHandle session_handle, size_t port_index) {
/* Acquire exclusive access to ourselves. */
std::scoped_lock lk(m_mutex);
/* Select the best port manager. */
PortManagerBase *best_manager = nullptr;
s32 best_sessions = -1;
[this, &best_manager, &best_sessions]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
(this->TrySelectBetterPort<Ix>(best_manager, best_sessions), ...);
}(std::make_index_sequence<NumPorts>());
/* Trigger the session add on the least-burdened manager. */
best_manager->TriggerAddSession(session_handle, port_index);
}
template<size_t Ix> requires (Ix < NumPorts)
void TrySelectBetterPort(PortManagerBase *&best_manager, s32 &best_sessions) {
auto &cur_manager = this->GetPortManager<Ix>();
const auto cur_sessions = cur_manager.GetSessionCount();
/* NOTE: It's unknown how nintendo handles the case where the last manager has more sessions (to cover the remainder). */
/* Our algorithm diverges from theirs (it does not do std::min bounds capping), to accommodate remainder ports. */
/* If we learn how they handle this edge case, we can change our ways to match theirs. */
if constexpr (Ix == 0) {
best_manager = std::addressof(cur_manager);
best_sessions = cur_sessions;
} else {
static_assert(SessionsPerPortManager<Ix - 1> == SessionsPerPortManager<0>);
static_assert(SessionsPerPortManager<Ix - 1> <= SessionsPerPortManager<Ix>);
if (cur_sessions < best_sessions || best_sessions >= static_cast<s32>(SessionsPerPortManager<Ix - 1>)) {
best_manager = std::addressof(cur_manager);
best_sessions = cur_sessions;
}
}
}
template<size_t Ix>
void TriggerResumeImpl(uintptr_t resume_key) {
/* Get the port manager. */
auto &port_manager = this->GetPortManager<Ix>();
/* If we should, trigger a resume. */
if (port_manager.TestResume(resume_key)) {
port_manager.TriggerResume(resume_key);
}
}
};
template<size_t ThreadStackSize, typename PortInfo>
class ServerManagerImpl<ThreadStackSize, false, 1, PortInfo> {
private:
static constexpr inline size_t NumPorts = 1;
static constexpr inline size_t MaxSessions = PortInfo::MaxSessions;
/* Verify that it's possible to service this many sessions, with our port manager count. */
static_assert(MaxSessions <= MaximumSessionsPerPort);
public:
class PortManagerBase {
protected:
os::MultiWaitType m_multi_wait;
ObjectManagerBase *m_object_manager;
public:
constexpr PortManagerBase() : m_multi_wait(), m_object_manager() { /* ... */ }
void InitializeBase(ObjectManagerBase *om) {
/* Initialize our multi wait. */
os::InitializeMultiWait(std::addressof(m_multi_wait));
/* Initialize our object manager. */
m_object_manager = om;
}
void RegisterPort(tipc::NativeHandle port_handle) {
/* Create an object holder for the port. */
tipc::ObjectHolder object;
/* Setup the object. */
object.InitializeAsPort(port_handle);
/* Register the object. */
m_object_manager->AddObject(object);
}
tipc::NativeHandle ProcessRequest(ObjectHolder &object) {
/* Process the request. */
const Result result = m_object_manager->ProcessRequest(object);
if (R_SUCCEEDED(result)) {
/* We should reply only if the request isn't deferred. */
return object.GetHandle();
} else {
/* Processing failed, so close the session if we need to. */
if (!tipc::ResultSessionClosed::Includes(result)) {
this->CloseSession(object);
}
/* We shouldn't reply on failure. */
return tipc::InvalidNativeHandle;
}
}
bool ReplyAndReceive(ObjectHolder *out_object, tipc::NativeHandle reply_target) {
/* If we don't have a reply target, clear our message buffer. */
if (reply_target == tipc::InvalidNativeHandle) {
tipc::MessageBuffer(tipc::GetMessageBuffer()).SetNull();
}
/* Try to reply/receive. */
const Result result = [&]() ALWAYS_INLINE_LAMBDA -> Result {
os::MultiWaitHolderType *signaled_holder = nullptr;
ON_SCOPE_EXIT { AMS_ABORT_UNLESS(signaled_holder == nullptr); };
return m_object_manager->ReplyAndReceive(std::addressof(signaled_holder), out_object, reply_target, std::addressof(m_multi_wait));
}();
/* Handle the result. */
if (R_FAILED(result)) {
/* Close the object. */
this->CloseSession(*out_object);
/* We don't have anything to process. */
return false;
}
return true;
}
void AddSession(tipc::NativeHandle session_handle, tipc::ServiceObjectBase *service_object) {
/* Create an object holder for the session. */
tipc::ObjectHolder object;
/* Setup the object. */
object.InitializeAsSession(session_handle, true, service_object);
/* Register the object. */
m_object_manager->AddObject(object);
}
void CloseSession(ObjectHolder &object) {
/* Get the object's handle. */
const auto handle = object.GetHandle();
/* Close the object with our manager. */
m_object_manager->CloseObject(handle);
/* Close the handle itself. */
R_ABORT_UNLESS(tipc::impl::CloseHandle(handle));
}
};
class PortManagerImpl final : public PortManagerBase {
private:
tipc::ObjectManager<1 + MaxSessions> m_object_manager_impl;
public:
constexpr PortManagerImpl() : PortManagerBase(), m_object_manager_impl() {
/* ... */
}
void Initialize() {
/* Initialize our base. */
this->InitializeBase(std::addressof(m_object_manager_impl));
/* Initialize our object manager. */
m_object_manager_impl.Initialize(std::addressof(this->m_multi_wait));
}
};
using PortManager = PortManagerImpl;
private:
PortManager m_port_manager;
typename PortInfo::Allocator m_port_allocator;
public:
constexpr ServerManagerImpl() : m_port_manager(), m_port_allocator() { /* ... */ }
void Initialize() {
/* Initialize our port manager. */
m_port_manager.Initialize();
}
void RegisterPort(tipc::NativeHandle port_handle) {
m_port_manager.RegisterPort(port_handle);
}
void RegisterPort(sm::ServiceName service_name, size_t max_sessions) {
/* Register service. */
tipc::NativeHandle port_handle;
R_ABORT_UNLESS(sm::RegisterService(std::addressof(port_handle), service_name, max_sessions, false));
/* Register the port handle. */
this->RegisterPort(port_handle);
}
void LoopAuto() {
/* Process for the only port. */
this->LoopProcess(m_port_manager);
}
tipc::ServiceObjectBase *AllocateObject() {
/* Allocate the object. */
auto * const new_object = m_port_allocator.Allocate();
AMS_ABORT_UNLESS(new_object != nullptr);
/* If we should, set the object's deleter. */
if constexpr (IsServiceObjectDeleter<typename PortInfo::Allocator>) {
new_object->SetDeleter(std::addressof(m_port_allocator));
}
return new_object;
}
Result AddSession(tipc::NativeHandle *out, tipc::ServiceObjectBase *object) {
/* Create a handle for the session. */
tipc::NativeHandle session_handle;
R_TRY(tipc::impl::CreateSession(std::addressof(session_handle), static_cast<tipc::NativeHandle *>(out), false, 0));
/* Add the session to our manager. */
m_port_manager.AddSession(session_handle, object);
R_SUCCEED();
}
private:
void LoopProcess(PortManagerBase &port_manager) {
/* Process requests forever. */
tipc::NativeHandle reply_target = tipc::InvalidNativeHandle;
while (true) {
/* Reply to our pending request, and wait to receive a new one. */
tipc::ObjectHolder signaled_object{};
while (!port_manager.ReplyAndReceive(std::addressof(signaled_object), reply_target)) {
reply_target = tipc::InvalidNativeHandle;
}
/* A session was signaled, accessible via signaled_object. */
switch (signaled_object.GetType()) {
case ObjectHolder::ObjectType_Port:
{
/* Try to accept a new session */
tipc::NativeHandle session_handle;
if (R_SUCCEEDED(tipc::impl::AcceptSession(std::addressof(session_handle), signaled_object.GetHandle()))) {
port_manager.AddSession(session_handle, this->AllocateObject());
}
/* We have nothing to reply to. */
reply_target = tipc::InvalidNativeHandle;
}
break;
case ObjectHolder::ObjectType_Session:
{
/* Process the request */
reply_target = port_manager.ProcessRequest(signaled_object);
}
break;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}
};
}
template<size_t ThreadStackSize, typename... PortInfos>
using ServerManagerImpl = impl::ServerManagerImpl<ThreadStackSize, (PortInfos::CanDeferInvokeRequest || ...), sizeof...(PortInfos), PortInfos...>;
template<typename... PortInfos>
using ServerManager = ServerManagerImpl<os::MemoryPageSize, PortInfos...>;
template<size_t ThreadStackSize, typename... PortInfos>
using ServerManagerWithThreadStack = ServerManagerImpl<ThreadStackSize, PortInfos...>;
}
| 43,765
|
C++
|
.h
| 688
| 39.238372
| 237
| 0.480368
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,710
|
tipc_object_holder.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_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/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_service_object_base.hpp>
namespace ams::tipc {
class ObjectHolder {
public:
enum ObjectType : u8 {
ObjectType_Invalid = 0,
ObjectType_Port = 1,
ObjectType_Session = 2,
ObjectType_Deferral = ObjectType_Invalid,
};
private:
tipc::NativeHandle m_handle;
ObjectType m_type;
bool m_managed;
tipc::ServiceObjectBase *m_object;
private:
void InitializeImpl(ObjectType type, tipc::NativeHandle handle, bool managed, tipc::ServiceObjectBase *object) {
/* Validate that the object isn't already constructed. */
AMS_ASSERT(m_type == ObjectType_Invalid);
/* Set all fields. */
m_handle = handle;
m_type = type;
m_managed = managed;
m_object = object;
}
public:
constexpr inline ObjectHolder() : m_handle(tipc::InvalidNativeHandle), m_type(ObjectType_Invalid), m_managed(false), m_object(nullptr) { /* ... */ }
void InitializeAsPort(tipc::NativeHandle handle) {
/* NOTE: Nintendo sets ports as managed, but this will cause a nullptr-deref if one is ever closed. */
/* This is theoretically a non-issue, as ports can't be closed, but we will set ours as unmanaged, */
/* just in case. */
this->InitializeImpl(ObjectType_Port, handle, false, nullptr);
}
void InitializeAsSession(tipc::NativeHandle handle, bool managed, tipc::ServiceObjectBase *object) {
this->InitializeImpl(ObjectType_Session, handle, managed, object);
}
void InitializeForDeferralManager(tipc::NativeHandle handle, tipc::ServiceObjectBase *object) {
this->InitializeImpl(ObjectType_Deferral, handle, false, object);
}
void Destroy() {
/* Validate that the object is constructed. */
AMS_ASSERT(m_type != ObjectType_Invalid);
/* If we're managed, destroy the associated object. */
if (m_managed) {
if (auto * const deleter = m_object->GetDeleter(); deleter != nullptr) {
deleter->DeleteServiceObject(m_object);
}
}
/* Reset all fields. */
m_handle = tipc::InvalidNativeHandle;
m_type = ObjectType_Invalid;
m_managed = false;
m_object = nullptr;
}
constexpr tipc::NativeHandle GetHandle() const {
return m_handle;
}
constexpr ObjectType GetType() const {
return m_type;
}
constexpr tipc::ServiceObjectBase *GetObject() const {
return m_object;
}
};
}
| 3,740
|
C++
|
.h
| 83
| 33.349398
| 160
| 0.583745
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,711
|
tipc_pointer_and_size.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_pointer_and_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/tipc/tipc_pointer_and_size.hpp>
namespace ams::tipc {
class PointerAndSize {
private:
uintptr_t m_pointer;
size_t m_size;
public:
constexpr PointerAndSize() : m_pointer(0), m_size(0) { /* ... */ }
constexpr PointerAndSize(uintptr_t ptr, size_t sz) : m_pointer(ptr), m_size(sz) { /* ... */ }
PointerAndSize(void *ptr, size_t sz) : PointerAndSize(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
ALWAYS_INLINE void *GetPointer() const {
return reinterpret_cast<void *>(m_pointer);
}
constexpr ALWAYS_INLINE uintptr_t GetAddress() const {
return m_pointer;
}
constexpr ALWAYS_INLINE size_t GetSize() const {
return m_size;
}
};
}
| 1,511
|
C++
|
.h
| 37
| 33.783784
| 117
| 0.636921
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,712
|
tipc_message_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_message_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::tipc {
namespace impl {
template<typename HandleType>
class DummyMessageBuffer {
public:
class MessageHeader {
public:
MessageHeader() { AMS_ABORT("TODO"); }
MessageHeader(const DummyMessageBuffer &) { AMS_ABORT("TODO"); }
u16 GetTag() const { AMS_ABORT("TODO"); }
};
class SpecialHeader {
public:
SpecialHeader() { AMS_ABORT("TODO"); }
SpecialHeader(const DummyMessageBuffer &, const MessageHeader &) { AMS_ABORT("TODO"); }
bool GetHasProcessId() const { AMS_ABORT("TODO"); }
s32 GetCopyHandleCount() const { AMS_ABORT("TODO"); }
};
public:
DummyMessageBuffer(u32 *) { AMS_ABORT("TODO"); }
DummyMessageBuffer(u32 *, size_t) { AMS_ABORT("TODO"); }
void SetNull() const { AMS_ABORT("TODO"); }
HandleType GetHandle(s32) const { AMS_ABORT("TODO"); }
template<typename T>
const T &GetRaw(s32) const { AMS_ABORT("TODO"); }
static s32 GetSpecialDataIndex(const MessageHeader &, const SpecialHeader &) { AMS_ABORT("TODO"); }
static s32 GetRawDataIndex(const MessageHeader &, const SpecialHeader &) { AMS_ABORT("TODO"); }
};
}
#if defined(ATMOSPHERE_OS_HORIZON)
constexpr inline auto MaximumSessionsPerPort = svc::ArgumentHandleCountMax;
using NativeHandle = svc::Handle;
constexpr inline NativeHandle InvalidNativeHandle = svc::InvalidHandle;
using MessageBuffer = ::ams::svc::ipc::MessageBuffer;
ALWAYS_INLINE u32 *GetMessageBuffer() { return svc::ipc::GetMessageBuffer(); }
constexpr ALWAYS_INLINE u32 EncodeNativeHandleForMessageQueue(NativeHandle h) { return static_cast<u32>(h); }
constexpr ALWAYS_INLINE NativeHandle DecodeNativeHandleForMessageQueue(u32 v) { return static_cast<NativeHandle>(v); }
#elif defined(ATMOSPHERE_OS_WINDOWS)
/* TODO */
constexpr inline auto MaximumSessionsPerPort = 0x40;
using NativeHandle = void *;
constexpr inline NativeHandle InvalidNativeHandle = nullptr;
using MessageBuffer = ::ams::tipc::impl::DummyMessageBuffer<NativeHandle>;
ALWAYS_INLINE u32 *GetMessageBuffer() { AMS_ABORT("TODO"); }
ALWAYS_INLINE u32 EncodeNativeHandleForMessageQueue(NativeHandle) { AMS_ABORT("TODO"); }
ALWAYS_INLINE NativeHandle DecodeNativeHandleForMessageQueue(u32) { AMS_ABORT("TODO"); }
#elif defined(ATMOSPHERE_OS_LINUX)
/* TODO */
constexpr inline auto MaximumSessionsPerPort = 0x40;
using NativeHandle = s32;
constexpr inline NativeHandle InvalidNativeHandle = -1;
using MessageBuffer = ::ams::tipc::impl::DummyMessageBuffer<NativeHandle>;
ALWAYS_INLINE u32 *GetMessageBuffer() { AMS_ABORT("TODO"); }
ALWAYS_INLINE u32 EncodeNativeHandleForMessageQueue(NativeHandle) { AMS_ABORT("TODO"); }
ALWAYS_INLINE NativeHandle DecodeNativeHandleForMessageQueue(u32) { AMS_ABORT("TODO"); }
#elif defined(ATMOSPHERE_OS_MACOS)
/* TODO */
constexpr inline auto MaximumSessionsPerPort = 0x40;
using NativeHandle = s32;
constexpr inline NativeHandle InvalidNativeHandle = -1;
using MessageBuffer = ::ams::tipc::impl::DummyMessageBuffer<NativeHandle>;
ALWAYS_INLINE u32 *GetMessageBuffer() { AMS_ABORT("TODO"); }
ALWAYS_INLINE u32 EncodeNativeHandleForMessageQueue(NativeHandle) { AMS_ABORT("TODO"); }
ALWAYS_INLINE NativeHandle DecodeNativeHandleForMessageQueue(u32) { AMS_ABORT("TODO"); }
#else
#error "Unknown OS for tipc platform types."
#endif
namespace impl {
}
}
| 4,643
|
C++
|
.h
| 87
| 43.183908
| 126
| 0.65072
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,713
|
tipc_object_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/impl/tipc_impl_message_api.hpp>
#include <stratosphere/tipc/tipc_service_object.hpp>
#include <stratosphere/tipc/tipc_object_holder.hpp>
namespace ams::tipc {
/* TODO: Put this in a better header. */
constexpr inline u16 MethodId_Invalid = 0x0;
constexpr inline u16 MethodId_CloseSession = 0xF;
class ObjectManagerBase {
protected:
struct Entry {
util::TypedStorage<ObjectHolder> object;
os::MultiWaitHolderType multi_wait_holder;
};
private:
os::SdkMutex m_mutex{};
Entry *m_entries_start{};
Entry *m_entries_end{};
os::MultiWaitType *m_multi_wait{};
private:
Entry *FindEntry(tipc::NativeHandle handle) {
for (Entry *cur = m_entries_start; cur != m_entries_end; ++cur) {
if (GetReference(cur->object).GetHandle() == handle) {
return cur;
}
}
return nullptr;
}
Entry *FindEntry(os::MultiWaitHolderType *holder) {
for (Entry *cur = m_entries_start; cur != m_entries_end; ++cur) {
if (std::addressof(cur->multi_wait_holder) == holder) {
return cur;
}
}
return nullptr;
}
public:
constexpr ObjectManagerBase() = default;
void InitializeImpl(os::MultiWaitType *multi_wait, Entry *entries, size_t max_objects) {
/* Set our multi wait. */
m_multi_wait = multi_wait;
/* Setup entry pointers. */
m_entries_start = entries;
m_entries_end = entries + max_objects;
/* Construct all entries. */
for (size_t i = 0; i < max_objects; ++i) {
util::ConstructAt(m_entries_start[i].object);
}
}
void AddObject(ObjectHolder &object) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Find an empty entry. */
auto *entry = this->FindEntry(tipc::InvalidNativeHandle);
AMS_ABORT_UNLESS(entry != nullptr);
/* Set the entry's object. */
GetReference(entry->object) = object;
/* Setup the entry's holder. */
os::InitializeMultiWaitHolder(std::addressof(entry->multi_wait_holder), object.GetHandle());
os::LinkMultiWaitHolder(m_multi_wait, std::addressof(entry->multi_wait_holder));
}
void CloseObject(tipc::NativeHandle handle) {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
/* Find the matching entry. */
auto *entry = this->FindEntry(handle);
AMS_ABORT_UNLESS(entry != nullptr);
/* Finalize the entry's holder. */
os::UnlinkMultiWaitHolder(std::addressof(entry->multi_wait_holder));
os::FinalizeMultiWaitHolder(std::addressof(entry->multi_wait_holder));
/* Destroy the object. */
GetReference(entry->object).Destroy();
}
Result ReplyAndReceive(os::MultiWaitHolderType **out_holder, ObjectHolder *out_object, tipc::NativeHandle reply_target, os::MultiWaitType *multi_wait) {
/* Declare signaled holder for processing ahead of time. */
os::MultiWaitHolderType *signaled_holder;
/* Reply and receive until we get a newly signaled target. */
Result result = os::SdkReplyAndReceive(out_holder, reply_target, multi_wait);
for (signaled_holder = *out_holder; signaled_holder == nullptr; signaled_holder = *out_holder) {
result = os::SdkReplyAndReceive(out_holder, tipc::InvalidNativeHandle, multi_wait);
}
/* Find the entry matching the signaled holder. */
if (auto *entry = this->FindEntry(signaled_holder); entry != nullptr) {
/* Get the output object. */
*out_object = GetReference(entry->object);
*out_holder = nullptr;
R_RETURN(result);
} else {
R_SUCCEED();
}
}
void Reply(tipc::NativeHandle reply_target) {
return tipc::impl::Reply(reply_target);
}
Result ProcessRequest(ObjectHolder &object) {
/* Get the message buffer. */
const MessageBuffer message_buffer(tipc::GetMessageBuffer());
/* Get the method id. */
const auto method_id = MessageBuffer::MessageHeader(message_buffer).GetTag();
/* Process for the method id. */
{
/* Ensure that if we fail, we clean up any handles that get sent our way. */
ON_RESULT_FAILURE {
const MessageBuffer::MessageHeader message_header(message_buffer);
const MessageBuffer::SpecialHeader special_header(message_buffer, message_header);
/* Determine the offset to the start of handles. */
auto offset = message_buffer.GetSpecialDataIndex(message_header, special_header);
if (special_header.GetHasProcessId()) {
offset += sizeof(u64) / sizeof(u32);
}
/* Close all copy handles. */
for (auto i = 0; i < special_header.GetCopyHandleCount(); ++i) {
tipc::impl::CloseHandle(message_buffer.GetHandle(offset));
offset += sizeof(typename std::remove_reference<decltype(message_buffer.GetHandle(offset))>::type) / sizeof(u32);
}
};
/* Check that the method id is valid. */
R_UNLESS(method_id != MethodId_Invalid, tipc::ResultInvalidMethod());
/* Process the request. */
if (method_id != MethodId_CloseSession) {
/* Process the generic method for the object. */
R_TRY(object.GetObject()->ProcessRequest());
} else {
/* Validate that the close request is of valid format. */
using CloseSessionCommandMeta = impl::CommandMetaInfo<MethodId_CloseSession, std::tuple<>>;
using CloseSessionProcessor = impl::CommandProcessor<CloseSessionCommandMeta>;
R_TRY(CloseSessionProcessor::ValidateCommandFormat(message_buffer));
}
}
/* If we were asked to close the object, do so. */
if (method_id == MethodId_CloseSession) {
/* Get the object handle. */
const auto handle = object.GetHandle();
/* Close the object itself. */
this->CloseObject(handle);
/* Close the object's handle. */
/* NOTE: Nintendo does not check that this succeeds. */
R_ABORT_UNLESS(tipc::impl::CloseHandle(handle));
/* Return an error to signify we closed the object. */
R_THROW(tipc::ResultSessionClosed());
}
/* We successfully processed, so we don't need to clean up handles. */
R_SUCCEED();
}
};
template<size_t MaxObjects>
class ObjectManager : public ObjectManagerBase {
private:
Entry m_entries_storage[MaxObjects]{};
public:
constexpr ObjectManager() = default;
void Initialize(os::MultiWaitType *multi_wait) {
this->InitializeImpl(multi_wait, m_entries_storage, MaxObjects);
}
};
}
| 8,892
|
C++
|
.h
| 173
| 36.023121
| 164
| 0.543884
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,714
|
tipc_out.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_out.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_pointer_and_size.hpp>
namespace ams::tipc {
namespace impl {
struct OutBaseTag{};
}
template<typename>
struct IsOutForceEnabled : public std::false_type{};
template<>
struct IsOutForceEnabled<::ams::Result> : public std::true_type{};
template<typename T>
concept OutEnabled = (std::is_trivial<T>::value || IsOutForceEnabled<T>::value) && !std::is_pointer<T>::value;
template<typename T>
class Out : public impl::OutBaseTag {
static_assert(OutEnabled<T>);
public:
static constexpr size_t TypeSize = sizeof(T);
private:
T *m_ptr;
public:
constexpr Out(uintptr_t p) : m_ptr(reinterpret_cast<T *>(p)) { /* ... */ }
constexpr Out(T *p) : m_ptr(p) { /* ... */ }
constexpr Out(const tipc::PointerAndSize &pas) : m_ptr(reinterpret_cast<T *>(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ }
ALWAYS_INLINE void SetValue(const T& value) const {
*m_ptr = value;
}
ALWAYS_INLINE const T &GetValue() const {
return *m_ptr;
}
ALWAYS_INLINE T *GetPointer() const {
return m_ptr;
}
/* Convenience operators. */
ALWAYS_INLINE T &operator*() const {
return *m_ptr;
}
ALWAYS_INLINE T *operator->() const {
return m_ptr;
}
};
template<typename T>
class Out<T *> {
static_assert(!std::is_same<T, T>::value, "Invalid tipc::Out<T> (Raw Pointer)");
};
}
| 2,392
|
C++
|
.h
| 61
| 31.57377
| 183
| 0.610967
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,715
|
tipc_service_object.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_service_object.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/tipc/tipc_service_object_base.hpp>
#include <stratosphere/tipc/impl/tipc_impl_template_base.hpp>
namespace ams::tipc {
namespace impl {
template<typename Impl>
class EmplacedImplHolderBaseGetter {
public:
using Type = Impl;
};
template<typename Impl>
class EmplacedImplHolder {
template<typename, typename, typename, typename, typename>
friend class impl::ImplTemplateBaseT;
private:
using Impl2 = typename EmplacedImplHolderBaseGetter<Impl>::Type;
static_assert(!std::is_abstract<Impl2>::value);
private:
Impl2 m_impl;
private:
template<typename... Args>
constexpr explicit EmplacedImplHolder(Args &&... args) : m_impl(std::forward<Args>(args)...) { /* ... */ }
public:
static constexpr Impl *GetImplPointer(EmplacedImplHolder *holder) {
return std::addressof(holder->m_impl);
}
};
}
template<typename Interface, typename Impl>
class ServiceObject final : public impl::ImplTemplateBase<Interface, Interface, impl::EmplacedImplHolder<Impl>, impl::EmplacedImplHolder<Impl>> {
private:
using ImplBase = impl::ImplTemplateBase<Interface, Interface, impl::EmplacedImplHolder<Impl>, impl::EmplacedImplHolder<Impl>>;
public:
using ImplBase::ImplBase;
constexpr Impl &GetImpl() { return *impl::EmplacedImplHolder<Impl>::GetImplPointer(this); }
};
}
| 2,297
|
C++
|
.h
| 53
| 35.264151
| 149
| 0.661298
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,716
|
tipc_service_object_base.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/tipc_service_object_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 <vapours.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
namespace ams::tipc {
class ServiceObjectBase;
class ServiceObjectDeleter {
public:
virtual void DeleteServiceObject(ServiceObjectBase *object) = 0;
};
template<typename T>
concept IsServiceObjectDeleter = std::derived_from<T, ServiceObjectDeleter>;
class ServiceObjectBase {
private:
ServiceObjectDeleter *m_deleter;
public:
constexpr ALWAYS_INLINE ServiceObjectBase() : m_deleter(nullptr) { /* ... */ }
ALWAYS_INLINE void SetDeleter(ServiceObjectDeleter *deleter) {
m_deleter = deleter;
}
ALWAYS_INLINE ServiceObjectDeleter *GetDeleter() const {
return m_deleter;
}
virtual ~ServiceObjectBase() { /* ... */ }
virtual Result ProcessRequest() = 0;
};
template<typename T>
concept IsServiceObject = std::derived_from<T, ServiceObjectBase>;
}
| 1,675
|
C++
|
.h
| 43
| 32.72093
| 90
| 0.684762
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,717
|
tipc_impl_template_base.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_template_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 <vapours.hpp>
namespace ams::tipc::impl {
template<typename Interface, typename Base, typename ImplHolder, typename ImplGetter, typename Root>
class ImplTemplateBaseT;
template<typename Interface, typename Base, typename ImplHolder, typename ImplGetter>
class ImplTemplateBase : public ImplTemplateBaseT<Interface, Base, ImplHolder, ImplGetter, Interface> {
private:
using BaseImpl = ImplTemplateBaseT<Interface, Base, ImplHolder, ImplGetter, Interface>;
public:
using BaseImpl::BaseImpl;
};
}
| 1,215
|
C++
|
.h
| 28
| 39.607143
| 107
| 0.750634
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,718
|
tipc_impl_message_api.os.horizon.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.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>
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
namespace ams::tipc::impl {
inline void Reply(tipc::NativeHandle reply_target) {
/* Perform the reply. */
s32 dummy;
R_TRY_CATCH(svc::ReplyAndReceive(std::addressof(dummy), nullptr, 0, reply_target, 0)) {
R_CATCH(svc::ResultTimedOut) {
/* Timing out is acceptable. */
}
R_CATCH(svc::ResultSessionClosed) {
/* It's okay if we couldn't reply to a closed session. */
}
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
}
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
R_RETURN(svc::CloseHandle(handle));
}
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
R_RETURN(svc::CreateSession(out_server_session_handle, out_client_session_handle, is_light, name));
}
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
R_RETURN(svc::AcceptSession(out_handle, port));
}
}
| 1,857
|
C++
|
.h
| 42
| 38.738095
| 165
| 0.695965
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,719
|
tipc_autogen_interface_macros.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/tipc/tipc_message_types.hpp>
#include <stratosphere/tipc/tipc_service_object_base.hpp>
#include <stratosphere/tipc/impl/tipc_impl_command_serialization.hpp>
namespace ams::tipc::impl {
template<typename T>
concept HasDefaultServiceCommandProcessor = requires (T &t, const MessageBuffer &message_buffer) {
{ t.ProcessDefaultServiceCommand(message_buffer) } -> std::same_as<Result>;
};
struct SyncFunctionTraits {
public:
template<typename R, typename C, typename... A>
static std::tuple<A...> GetArgsImpl(R(C::*)(A...));
};
template<auto F>
using SyncFunctionArgsType = decltype(SyncFunctionTraits::GetArgsImpl(F));
#define AMS_TIPC_IMPL_DEFINE_SYNC_METHOD_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
struct NAME##ArgumentsFunctionHolder { RETURN f ARGS; };
#define AMS_TIPC_IMPL_EXTRACT_SYNC_METHOD_ARGUMENTS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
using NAME##ArgumentsType = ::ams::tipc::impl::SyncFunctionArgsType<&NAME##ArgumentsFunctionHolder::f>;
#define AMS_TIPC_IMPL_GET_MAXIMUM_REQUEST_SIZE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
, ::ams::tipc::impl::CommandMetaInfo<CMD_ID + 0x10, NAME##ArgumentsType>::InMessageTotalSize
#define AMS_TIPC_IMPL_GET_MAXIMUM_RESPONSE_SIZE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
, ::ams::tipc::impl::CommandMetaInfo<CMD_ID + 0x10, NAME##ArgumentsType>::OutMessageTotalSize
#define AMS_TIPC_IMPL_DEFINE_INTERFACE(BASECLASS, CLASSNAME, CMD_MACRO) \
class CLASSNAME : public BASECLASS { \
private: \
CMD_MACRO(CLASSNAME, AMS_TIPC_IMPL_DEFINE_SYNC_METHOD_HOLDER) \
public: \
CMD_MACRO(CLASSNAME, AMS_TIPC_IMPL_EXTRACT_SYNC_METHOD_ARGUMENTS) \
public: \
static constexpr size_t MaximumRequestSize = std::max<size_t>({ \
0 \
CMD_MACRO(CLASSNAME, AMS_TIPC_IMPL_GET_MAXIMUM_REQUEST_SIZE) \
}); \
\
static constexpr size_t MaximumResponseSize = std::max<size_t>({ \
0 \
CMD_MACRO(CLASSNAME, AMS_TIPC_IMPL_GET_MAXIMUM_RESPONSE_SIZE) \
}); \
};
#define AMS_TIPC_IMPL_DEFINE_CONCEPT_HELPERS(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
template<typename T, typename... Args> \
concept Is##CLASSNAME##__##NAME##Impl = requires (T &t, Args &&... args) { \
{ t.NAME(std::forward<Args>(args)...) } -> std::same_as<RETURN>; \
}; \
\
template<typename T, typename A> \
struct Is##CLASSNAME##__##NAME##Holder : std::false_type{}; \
\
template<typename T, typename... Args> requires std::same_as<std::tuple<Args...>, CLASSNAME::NAME##ArgumentsType> \
struct Is##CLASSNAME##__##NAME##Holder<T, std::tuple<Args...>> : std::bool_constant<Is##CLASSNAME##__##NAME##Impl<T, Args...>>{}; \
\
template<typename T> \
static constexpr inline bool Is##CLASSNAME##__##NAME = Is##CLASSNAME##__##NAME##Holder<T, CLASSNAME::NAME##ArgumentsType>::value;
#define AMS_TIPC_IMPL_CHECK_CONCEPT_HELPER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
Is##CLASSNAME##__##NAME<T> &&
#define AMS_TIPC_IMPL_DEFINE_CONCEPT(CLASSNAME, CMD_MACRO) \
CMD_MACRO(CLASSNAME, AMS_TIPC_IMPL_DEFINE_CONCEPT_HELPERS) \
\
template<typename T> \
concept Is##CLASSNAME = CMD_MACRO(CLASSNAME, AMS_TIPC_IMPL_CHECK_CONCEPT_HELPER) true;
#define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
else if (constexpr u16 TipcCommandId = CMD_ID + 0x10; tag == TipcCommandId) { \
R_RETURN((this->ProcessMethodById<TipcCommandId, ImplType>(impl, message_buffer, fw_ver))); \
}
#define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
if constexpr (constexpr u16 TipcCommandId = CMD_ID + 0x10; CommandId == TipcCommandId) { \
constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \
constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \
if ((MinValid || VERSION_MIN <= fw_ver) && (MaxValid || fw_ver <= VERSION_MAX)) { \
R_RETURN((::ams::tipc::impl::InvokeServiceCommandImpl<TipcCommandId, &ImplType::NAME, ImplType>(impl, message_buffer))); \
} \
}
#define AMS_TIPC_IMPL_IS_FIRMWARE_VERSION_ALWAYS_VALID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
{ \
constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \
constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \
if (!MinValid || !MaxValid) { \
return false; \
} \
}
#define AMS_TIPC_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \
namespace NAMESPACE { \
\
AMS_TIPC_IMPL_DEFINE_INTERFACE(BASE, INTERFACE, CMD_MACRO) \
AMS_TIPC_IMPL_DEFINE_CONCEPT(INTERFACE, CMD_MACRO) \
\
} \
\
namespace ams::tipc::impl { \
\
template<typename Base, typename ImplHolder, typename ImplGetter, typename Root> \
class ImplTemplateBaseT<::NAMESPACE::INTERFACE, Base, ImplHolder, ImplGetter, Root> : public Base, public ImplHolder { \
public: \
template<typename... Args> \
constexpr explicit ImplTemplateBaseT(Args &&...args) : ImplHolder(std::forward<Args>(args)...) { /* ... */ } \
private: \
template<typename ImplType> \
ALWAYS_INLINE Result ProcessDefaultMethod(ImplType *impl, const MessageBuffer &message_buffer) const { \
/* Handle a default command. */ \
if constexpr (HasDefaultServiceCommandProcessor<ImplType>) { \
R_RETURN(impl->ProcessDefaultServiceCommand(message_buffer)); \
} else { \
R_THROW(tipc::ResultInvalidMethod()); \
} \
} \
\
template<u16 CommandId, typename ImplType> \
ALWAYS_INLINE Result ProcessMethodById(ImplType *impl, const MessageBuffer &message_buffer, hos::Version fw_ver) const { \
CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID) \
\
R_RETURN(this->ProcessDefaultMethod<ImplType>(impl, message_buffer)); \
} \
\
static consteval bool IsFirmwareVersionAlwaysValid() { \
CMD_MACRO(ImplType, AMS_TIPC_IMPL_IS_FIRMWARE_VERSION_ALWAYS_VALID); \
return true; \
} \
public: \
virtual Result ProcessRequest() override { \
/* Get the implementation object. */ \
auto * const impl = ImplGetter::GetImplPointer(static_cast<ImplHolder *>(this)); \
\
/* Get the implementation type. */ \
using ImplType = typename std::remove_reference<decltype(*impl)>::type; \
static_assert(::NAMESPACE::Is##INTERFACE<ImplType>); \
\
/* Get accessor to the message buffer. */ \
const MessageBuffer message_buffer(tipc::GetMessageBuffer()); \
\
/* Get decision variables. */ \
const auto tag = MessageBuffer::MessageHeader(message_buffer).GetTag(); \
const auto fw_ver = IsFirmwareVersionAlwaysValid() ? hos::Version_Current : hos::GetVersion(); \
\
/* Process against the command ids. */ \
if (false) { } \
CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST) \
else { \
R_RETURN(this->ProcessDefaultMethod<ImplType>(impl, message_buffer)); \
} \
} \
}; \
\
}
#define AMS_TIPC_DEFINE_INTERFACE(NAMESPACE, INTERFACE, CMD_MACRO) \
AMS_TIPC_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, ::ams::tipc::ServiceObjectBase, CMD_MACRO)
#define AMS_TIPC_METHOD_INFO_7(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, ARGNAMES) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, hos::Version_Min, hos::Version_Max)
#define AMS_TIPC_METHOD_INFO_8(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, hos::Version_Max)
#define AMS_TIPC_METHOD_INFO_9(CLASSNAME, HANDLER, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
HANDLER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX)
#define AMS_TIPC_METHOD_INFO_X(_, _0, _1, _2, _3, _4, _5, _6, _7, _8, FUNC, ...) FUNC
#define AMS_TIPC_METHOD_INFO(...) \
AMS_TIPC_METHOD_INFO_X(, ## __VA_ARGS__, AMS_TIPC_METHOD_INFO_9(__VA_ARGS__), AMS_TIPC_METHOD_INFO_8(__VA_ARGS__), AMS_TIPC_METHOD_INFO_7(__VA_ARGS__))
}
| 19,178
|
C++
|
.h
| 173
| 85.416185
| 159
| 0.323393
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,720
|
tipc_impl_command_serialization.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_command_serialization.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_out.hpp>
#include <stratosphere/tipc/tipc_buffers.hpp>
#include <stratosphere/tipc/tipc_handles.hpp>
namespace ams::tipc {
struct ClientProcessId {
os::ProcessId value;
};
static_assert(std::is_trivial<ClientProcessId>::value && sizeof(ClientProcessId) == sizeof(os::ProcessId), "ClientProcessId");
}
#if defined(ATMOSPHERE_OS_HORIZON)
namespace ams::tipc::impl {
/* Machinery for filtering type lists. */
template<class, class>
struct TupleCat;
template<class... First, class... Second>
struct TupleCat<std::tuple<First...>, std::tuple<Second...>> {
using type = std::tuple<First..., Second...>;
};
template<template <typename> typename Cond>
struct TupleFilter {
private:
template<typename, typename>
struct ImplType;
template<typename Res>
struct ImplType<Res, std::tuple<>> {
using type = Res;
};
template<typename Res, typename T, typename... Ts>
struct ImplType<Res, std::tuple<T, Ts...>> {
using type = typename std::conditional<Cond<T>::value,
typename ImplType<typename TupleCat<Res, std::tuple<T>>::type, std::tuple<Ts...>>::type,
typename ImplType<Res, std::tuple<Ts...>>::type
>::type;
};
public:
template<typename T>
using FilteredType = typename ImplType<std::tuple<>, T>::type;
};
enum class ArgumentType {
InData,
OutData,
Buffer,
InHandle,
OutHandle,
ProcessId,
};
template<typename T>
constexpr inline ArgumentType GetArgumentType = [] {
if constexpr (tipc::IsBuffer<T>) {
return ArgumentType::Buffer;
} else if constexpr (std::same_as<T, tipc::CopyHandle> || std::same_as<T, tipc::MoveHandle>) {
return ArgumentType::InHandle;
} else if constexpr (std::same_as<T, tipc::OutCopyHandle> || std::same_as<T, tipc::OutMoveHandle>) {
return ArgumentType::OutHandle;
} else if constexpr (std::is_base_of<tipc::impl::OutBaseTag, T>::value) {
return ArgumentType::OutData;
} else if constexpr (std::same_as<T, tipc::ClientProcessId>) {
return ArgumentType::ProcessId;
} else if constexpr (std::is_trivial<T>::value && !std::is_pointer<T>::value) {
return ArgumentType::InData;
} else if constexpr (std::is_same<T, ::ams::Result>::value) {
return ArgumentType::InData;
} else {
static_assert(!std::is_same<T, T>::value, "Invalid ArgumentType<T>");
}
}();
template<typename T, ArgumentType ArgT>
struct ArgumentTypeFilter : public std::bool_constant<GetArgumentType<T> == ArgT>{};
template<typename T, typename U>
struct TypeEqualityFilter : public std::bool_constant<std::is_same<T, U>::value>{};
/* Argument type filters. */
template<typename T>
using InDataFilter = ArgumentTypeFilter<T, ArgumentType::InData>;
template<typename T>
using OutDataFilter = ArgumentTypeFilter<T, ArgumentType::OutData>;
template<typename T>
using BufferFilter = ArgumentTypeFilter<T, ArgumentType::Buffer>;
template<typename T>
using InHandleFilter = ArgumentTypeFilter<T, ArgumentType::InHandle>;
template<typename T>
using OutHandleFilter = ArgumentTypeFilter<T, ArgumentType::OutHandle>;
template<typename T>
using ProcessIdFilter = ArgumentTypeFilter<T, ArgumentType::ProcessId>;
/* Handle kind filters. */
template<typename T>
using InMoveHandleFilter = TypeEqualityFilter<T, tipc::MoveHandle>;
template<typename T>
using InCopyHandleFilter = TypeEqualityFilter<T, tipc::CopyHandle>;
template<typename T>
using OutMoveHandleFilter = TypeEqualityFilter<T, tipc::OutMoveHandle>;
template<typename T>
using OutCopyHandleFilter = TypeEqualityFilter<T, tipc::OutCopyHandle>;
template<typename>
struct BufferAttributeArrayGetter;
template<typename ...Ts>
struct BufferAttributeArrayGetter<std::tuple<Ts...>> {
static constexpr std::array<u32, sizeof...(Ts)> value = { BufferAttributes<Ts>..., };
};
template<>
struct BufferAttributeArrayGetter<std::tuple<>> {
static constexpr std::array<u32, 0> value{};
};
template<auto Predicate>
struct BufferAttributeCounter {
template<size_t Size>
static constexpr size_t GetCount(const std::array<u32, Size> &attributes_array) {
size_t count = 0;
for (size_t i = 0; i < Size; i++) {
if (Predicate(attributes_array[i])) {
count++;
}
}
return count;
}
};
static constexpr size_t InBufferPredicate(const u32 attribute) {
return (attribute & SfBufferAttr_In) && !(attribute & SfBufferAttr_Out);
}
static constexpr size_t OutBufferPredicate(const u32 attribute) {
return !(attribute & SfBufferAttr_In) && (attribute & SfBufferAttr_Out);
}
template<typename>
struct RawDataOffsetCalculator;
template<typename... Ts>
struct RawDataOffsetCalculator<std::tuple<Ts...>> {
private:
template<typename T>
struct LayoutHelper {
static_assert(GetArgumentType<T> == ArgumentType::InData, "LayoutHelper InData");
static constexpr size_t Alignment = alignof(T);
static constexpr size_t Size = sizeof(T);
};
template<typename T>
struct LayoutHelper<Out<T>> {
static_assert(GetArgumentType<T> == ArgumentType::InData, "LayoutHelper OutData");
static constexpr size_t Alignment = alignof(T);
static constexpr size_t Size = sizeof(T);
};
public:
static constexpr std::array<size_t, sizeof...(Ts)+1> Offsets = [] {
std::array<size_t, sizeof...(Ts)+1> offsets{};
offsets[0] = 0;
if constexpr (sizeof...(Ts) > 0) {
/* Get size, alignment for each type. */
const std::array<size_t, sizeof...(Ts)> sizes = { LayoutHelper<Ts>::Size... };
const std::array<size_t, sizeof...(Ts)> aligns = { LayoutHelper<Ts>::Alignment... };
/* We want to sort...by alignment. */
std::array<size_t, sizeof...(Ts)> map = {};
for (size_t i = 0; i < sizeof...(Ts); i++) { map[i] = i; }
/* TODO: Is sorting done on parameters? */
/* Sort?(map, aligns); */
/* Iterate over sorted sizes. */
size_t cur_offset = 0;
for (size_t i : map) {
cur_offset = util::AlignUp(cur_offset, aligns[i]);
offsets[i] = cur_offset;
cur_offset += sizes[i];
}
offsets[sizeof...(Ts)] = cur_offset;
}
return offsets;
}();
};
struct ArgumentSerializationInfo {
/* Type used to select from below fields. */
ArgumentType arg_type;
/* Raw data indexing. */
size_t in_raw_data_index;
size_t out_raw_data_index;
/* Buffer indexing. */
size_t buffer_index;
bool is_send_buffer;
size_t send_map_alias_index;
size_t recv_map_alias_index;
/* Handle indexing. */
size_t in_move_handle_index;
size_t in_copy_handle_index;
size_t out_move_handle_index;
size_t out_copy_handle_index;
};
template<u16 _CommandId, typename ArgumentsTuple>
struct CommandMetaInfo;
template<u16 _CommandId, typename... Arguments>
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
public:
static constexpr u16 CommandId = _CommandId;
using ArgsType = std::tuple<typename std::decay<Arguments>::type...>;
using InDatas = TupleFilter<InDataFilter>::FilteredType<ArgsType>;
using OutDatas = TupleFilter<OutDataFilter>::FilteredType<ArgsType>;
using Buffers = TupleFilter<BufferFilter>::FilteredType<ArgsType>;
using InHandles = TupleFilter<InHandleFilter>::FilteredType<ArgsType>;
using OutHandles = TupleFilter<OutHandleFilter>::FilteredType<ArgsType>;
using ProcessIds = TupleFilter<ProcessIdFilter>::FilteredType<ArgsType>;
static constexpr size_t NumInDatas = std::tuple_size<InDatas>::value;
static constexpr size_t NumOutDatas = std::tuple_size<OutDatas>::value;
static constexpr size_t NumBuffers = std::tuple_size<Buffers>::value;
static constexpr size_t NumInHandles = std::tuple_size<InHandles>::value;
static constexpr size_t NumOutHandles = std::tuple_size<OutHandles>::value;
static constexpr size_t NumProcessIds = std::tuple_size<ProcessIds>::value;
static constexpr bool HasProcessId = NumProcessIds >= 1;
static_assert(NumBuffers <= 8, "Methods must take in <= 8 Buffers");
static_assert(NumInHandles <= 8, "Methods must take in <= 8 Handles");
static_assert(NumOutHandles <= 8, "Methods must output <= 8 Handles");
static_assert(NumInHandles == 0, "In Handles not yet implemented!");
/* Buffer marshalling. */
static constexpr std::array<u32, NumBuffers> BufferAttributes = BufferAttributeArrayGetter<Buffers>::value;
static constexpr size_t NumInBuffers = BufferAttributeCounter<InBufferPredicate>::GetCount(BufferAttributes);
static constexpr size_t NumOutBuffers = BufferAttributeCounter<OutBufferPredicate>::GetCount(BufferAttributes);
/* In/Out data marshalling. */
static constexpr std::array<size_t, NumInDatas+1> InDataOffsets = RawDataOffsetCalculator<InDatas>::Offsets;
static constexpr size_t InDataSize = util::AlignUp(InDataOffsets[NumInDatas], alignof(u32));
static constexpr std::array<size_t, NumOutDatas+1> OutDataOffsets = RawDataOffsetCalculator<OutDatas>::Offsets;
static constexpr size_t OutDataSize = util::AlignUp(OutDataOffsets[NumOutDatas], alignof(u32));
/* Useful because reasons. */
static constexpr size_t OutDataAlign = []() -> size_t {
if constexpr (std::tuple_size<OutDatas>::value) {
return alignof(typename std::tuple_element<0, OutDatas>::type);
}
return 0;
}();
/* Handle marshalling. */
static constexpr size_t NumInMoveHandles = std::tuple_size<TupleFilter<InMoveHandleFilter>::FilteredType<InHandles>>::value;
static constexpr size_t NumInCopyHandles = std::tuple_size<TupleFilter<InCopyHandleFilter>::FilteredType<InHandles>>::value;
static constexpr size_t NumOutMoveHandles = std::tuple_size<TupleFilter<OutMoveHandleFilter>::FilteredType<OutHandles>>::value;
static constexpr size_t NumOutCopyHandles = std::tuple_size<TupleFilter<OutCopyHandleFilter>::FilteredType<OutHandles>>::value;
static_assert(NumInMoveHandles + NumInCopyHandles == NumInHandles, "NumInMoveHandles + NumInCopyHandles == NumInHandles");
static_assert(NumOutMoveHandles + NumOutCopyHandles == NumOutHandles, "NumOutMoveHandles + NumOutCopyHandles == NumOutHandles");
/* tipc-specific accessors. */
static constexpr bool HasInSpecialHeader = HasProcessId || NumInHandles > 0;
static constexpr MessageBuffer::MessageHeader InMessageHeader{CommandId, HasInSpecialHeader, 0, NumInBuffers, NumOutBuffers, 0, InDataSize / sizeof(u32), 0};
static constexpr MessageBuffer::SpecialHeader InSpecialHeader{HasProcessId, NumInCopyHandles, NumInMoveHandles, HasInSpecialHeader};
static constexpr auto InMessageProcessIdIndex = MessageBuffer::GetSpecialDataIndex(InMessageHeader, InSpecialHeader);
static constexpr auto InMessageHandleIndex = MessageBuffer::GetSpecialDataIndex(InMessageHeader, InSpecialHeader) + (HasProcessId ? sizeof(u64) / sizeof(u32) : 0);
static constexpr auto InMessageBufferIndex = MessageBuffer::GetMapAliasDescriptorIndex(InMessageHeader, InSpecialHeader);
static constexpr auto InMessageRawDataIndex = MessageBuffer::GetRawDataIndex(InMessageHeader, InSpecialHeader);
static constexpr bool HasOutSpecialHeader = NumOutHandles > 0;
static constexpr MessageBuffer::MessageHeader OutMessageHeader{CommandId, HasOutSpecialHeader, 0, 0, 0, 0, (OutDataSize / sizeof(u32)) + 1, 0};
static constexpr MessageBuffer::SpecialHeader OutSpecialHeader{false, NumOutCopyHandles, NumOutMoveHandles, HasOutSpecialHeader};
static constexpr auto OutMessageHandleIndex = MessageBuffer::GetSpecialDataIndex(OutMessageHeader, OutSpecialHeader);
static constexpr auto OutMessageResultIndex = MessageBuffer::GetRawDataIndex(OutMessageHeader, OutSpecialHeader);
static constexpr auto OutMessageRawDataIndex = OutMessageResultIndex + 1;
static constexpr size_t InMessageTotalSize = (InMessageRawDataIndex * sizeof(u32)) + InDataSize;
static constexpr size_t OutMessageTotalSize = (OutMessageRawDataIndex * sizeof(u32)) + OutDataSize;
/* Construction of argument serialization structs. */
private:
template<typename>
struct ArgumentSerializationInfoConstructor;
template<typename ...Ts>
struct ArgumentSerializationInfoConstructor<std::tuple<Ts...>> {
template<typename T>
static constexpr ArgumentSerializationInfo ProcessUpdate(ArgumentSerializationInfo ¤t_info) {
/* Save a copy of the current state to return. */
ArgumentSerializationInfo returned_info = current_info;
constexpr auto arg_type = GetArgumentType<T>;
returned_info.arg_type = arg_type;
if constexpr (arg_type == ArgumentType::InData) {
/* New rawdata, so increment index. */
current_info.in_raw_data_index++;
} else if constexpr (arg_type == ArgumentType::OutData) {
/* New rawdata, so increment index. */
current_info.out_raw_data_index++;
} else if constexpr (arg_type == ArgumentType::InHandle) {
/* New InHandle, increment the appropriate index. */
if constexpr (std::same_as<T, tipc::MoveHandle>) {
current_info.in_move_handle_index++;
} else if constexpr (std::same_as<T, tipc::CopyHandle>) {
current_info.in_copy_handle_index++;
} else {
static_assert(!std::is_same<T, T>::value, "Invalid InHandle kind");
}
} else if constexpr (arg_type == ArgumentType::OutHandle) {
/* New OutHandle, increment the appropriate index. */
if constexpr (std::same_as<T, tipc::OutMoveHandle>) {
current_info.out_move_handle_index++;
} else if constexpr (std::same_as<T, tipc::OutCopyHandle>) {
current_info.out_copy_handle_index++;
} else {
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
}
} else if constexpr (arg_type == ArgumentType::Buffer) {
/* New Buffer, increment the appropriate index. */
const auto attributes = BufferAttributes[current_info.buffer_index++];
if (attributes & SfBufferAttr_In) {
returned_info.is_send_buffer = true;
current_info.send_map_alias_index++;
} else if (attributes & SfBufferAttr_Out) {
returned_info.is_send_buffer = false;
current_info.recv_map_alias_index++;
}
} else if constexpr (arg_type == ArgumentType::ProcessId) {
/* Nothing needs to be done to track process ids. */
} else {
static_assert(!std::is_same<T, T>::value, "Invalid ArgumentType<T>");
}
return returned_info;
}
static constexpr std::array<ArgumentSerializationInfo, sizeof...(Ts)> ArgumentSerializationInfos = [] {
ArgumentSerializationInfo current_info = {};
return std::array<ArgumentSerializationInfo, sizeof...(Ts)>{ ProcessUpdate<Ts>(current_info)... };
}();
};
public:
static constexpr std::array<ArgumentSerializationInfo, std::tuple_size<ArgsType>::value> ArgumentSerializationInfos = ArgumentSerializationInfoConstructor<ArgsType>::ArgumentSerializationInfos;
};
template<size_t _Size, size_t _Align, size_t OutIndex>
class OutRawHolder {
public:
static constexpr size_t Size = _Size;
static constexpr size_t Align = _Align ? _Align : alignof(u8);
private:
alignas(Align) u8 data[Size];
public:
constexpr ALWAYS_INLINE OutRawHolder() : data() { /* ... */ }
template<size_t Offset, size_t TypeSize>
constexpr ALWAYS_INLINE uintptr_t GetAddress() const {
static_assert(Offset <= Size, "Offset <= Size");
static_assert(TypeSize <= Size, "TypeSize <= Size");
static_assert(Offset + TypeSize <= Size, "Offset + TypeSize <= Size");
return reinterpret_cast<uintptr_t>(data + Offset);
}
constexpr ALWAYS_INLINE void CopyTo(const MessageBuffer &buffer) const {
if constexpr (Size > 0) {
buffer.SetRawArray(OutIndex, data, Size);
}
}
};
template<size_t _NumMove, size_t _NumCopy, size_t OutIndex>
class OutHandleHolder {
public:
static constexpr size_t NumMove = _NumMove;
static constexpr size_t NumCopy = _NumCopy;
private:
tipc::NativeHandle move_handles[NumMove];
tipc::NativeHandle copy_handles[NumCopy];
public:
ALWAYS_INLINE OutHandleHolder() { /* ... */ }
template<size_t Index>
constexpr ALWAYS_INLINE tipc::NativeHandle *GetMoveHandlePointer() {
static_assert(Index < NumMove, "Index < NumMove");
return move_handles + Index;
}
template<size_t Index>
constexpr ALWAYS_INLINE tipc::NativeHandle *GetCopyHandlePointer() {
static_assert(Index < NumCopy, "Index < NumCopy");
return copy_handles + Index;
}
ALWAYS_INLINE void CopyTo(const MessageBuffer &buffer) const {
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { buffer.SetHandle(OutIndex + n, copy_handles[n]); } } while (0)
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(0);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(1);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(2);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(3);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(4);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(5);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(6);
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(7);
#undef _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { buffer.SetHandle(OutIndex + NumCopy + n, move_handles[n]); } } while (0)
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(0);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(1);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(2);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(3);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(4);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(5);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(6);
_TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(7);
#undef _TIPC_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE
}
};
template<size_t... Ix>
struct PrintIndex;
template<typename CommandMeta>
class CommandProcessor {
public:
/* Useful defines. */
using ArgsType = typename CommandMeta::ArgsType;
using OutRawHolderType = OutRawHolder<CommandMeta::OutDataSize, CommandMeta::OutDataAlign, CommandMeta::OutMessageRawDataIndex>;
using OutHandleHolderType = OutHandleHolder<CommandMeta::NumOutMoveHandles, CommandMeta::NumOutCopyHandles, CommandMeta::OutMessageHandleIndex>;
private:
static constexpr u64 GetMessageHeaderForCheck(const MessageBuffer::MessageHeader &header) {
using Value = util::BitPack32::Field<0, BITSIZEOF(util::BitPack32)>;
const util::BitPack32 *data = header.GetData();
const u32 lower = data[0].Get<Value>();
const u32 upper = data[1].Get<Value>();
return static_cast<u64>(lower) | (static_cast<u64>(upper) << BITSIZEOF(u32));
}
static constexpr u32 GetSpecialHeaderForCheck(const MessageBuffer::SpecialHeader &header) {
using Value = util::BitPack32::Field<0, BITSIZEOF(util::BitPack32)>;
return header.GetHeader()->Get<Value>();
}
/* Argument deserialization. */
template<size_t Index, typename T = typename std::tuple_element<Index, ArgsType>::type>
static ALWAYS_INLINE typename std::tuple_element<Index, ArgsType>::type DeserializeArgumentImpl(const MessageBuffer &message_buffer, const OutRawHolderType &out_raw_holder, OutHandleHolderType &out_handles_holder) {
constexpr auto Info = CommandMeta::ArgumentSerializationInfos[Index];
if constexpr (Info.arg_type == ArgumentType::InData) {
/* New in rawdata. */
constexpr size_t Offset = CommandMeta::InDataOffsets[Info.in_raw_data_index];
constexpr size_t RawIndex = Offset / sizeof(u32);
static_assert(Offset == RawIndex * sizeof(u32)); /* TODO: Do unaligned data exist? */
if constexpr (!std::same_as<T, bool>) {
return message_buffer.GetRaw<T>(CommandMeta::InMessageRawDataIndex + RawIndex);
} else {
return message_buffer.GetRaw<u8>(CommandMeta::InMessageRawDataIndex + RawIndex) & 1;
}
} else if constexpr (Info.arg_type == ArgumentType::OutData) {
/* New out rawdata. */
constexpr size_t Offset = CommandMeta::OutDataOffsets[Info.out_raw_data_index];
return T(out_raw_holder.template GetAddress<Offset, T::TypeSize>());
} else if constexpr (Info.arg_type == ArgumentType::InHandle) {
/* New InHandle. */
if constexpr (std::same_as<T, tipc::MoveHandle>) {
constexpr auto HandleIndex = CommandMeta::InMessageHandleIndex + CommandMeta::NumInCopyHandles + Info.in_move_handle_index;
return T(message_buffer.GetHandle(HandleIndex));
} else if constexpr (std::same_as<T, tipc::CopyHandle>) {
constexpr auto HandleIndex = CommandMeta::InMessageHandleIndex + Info.in_copy_handle_index;
return T(message_buffer.GetHandle(HandleIndex));
} else {
static_assert(!std::is_same<T, T>::value, "Invalid InHandle kind");
}
} else if constexpr (Info.arg_type == ArgumentType::OutHandle) {
/* New OutHandle. */
if constexpr (std::same_as<T, tipc::OutMoveHandle>) {
tipc::NativeHandle * const ptr = out_handles_holder.template GetMoveHandlePointer<Info.out_move_handle_index>();
*ptr = tipc::InvalidNativeHandle;
return T(ptr);
} else if constexpr (std::same_as<T, tipc::OutCopyHandle>) {
tipc::NativeHandle * const ptr = out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>();
*ptr = tipc::InvalidNativeHandle;
return T(ptr);
} else {
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
}
} else if constexpr (Info.arg_type == ArgumentType::Buffer) {
/* NOTE: There are currently no tipc commands which use buffers-with-attributes */
/* If these are added (e.g., NonSecure buffers), implement checking here? */
constexpr size_t MapAliasDescriptorSize = MessageBuffer::MapAliasDescriptor::GetDataSize();
if constexpr (Info.is_send_buffer) {
/* Input send buffer. */
constexpr auto BufferIndex = CommandMeta::InMessageBufferIndex + (Info.send_map_alias_index * MapAliasDescriptorSize / sizeof(util::BitPack32));
const MessageBuffer::MapAliasDescriptor descriptor(message_buffer, BufferIndex);
return T(descriptor.GetAddress(), descriptor.GetSize());
} else {
/* Input receive buffer. */
constexpr auto BufferIndex = CommandMeta::InMessageBufferIndex + ((CommandMeta::NumInBuffers + Info.recv_map_alias_index) * MapAliasDescriptorSize / sizeof(util::BitPack32));
const MessageBuffer::MapAliasDescriptor descriptor(message_buffer, BufferIndex);
return T(descriptor.GetAddress(), descriptor.GetSize());
}
} else if constexpr (Info.arg_type == ArgumentType::ProcessId) {
return T{ os::ProcessId{ message_buffer.GetProcessId(CommandMeta::InMessageProcessIdIndex) } };
} else {
static_assert(!std::is_same<T, T>::value, "Invalid ArgumentType<T>");
}
}
public:
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &message_buffer) {
/* Validate the message header. */
constexpr auto ExpectedMessageHeader = GetMessageHeaderForCheck(CommandMeta::InMessageHeader);
R_UNLESS(message_buffer.Get64(0) == ExpectedMessageHeader, tipc::ResultInvalidMessageFormat());
/* Validate the special header. */
if constexpr (CommandMeta::HasInSpecialHeader) {
constexpr auto ExpectedSpecialHeader = GetSpecialHeaderForCheck(CommandMeta::InSpecialHeader);
constexpr auto SpecialHeaderIndex = MessageBuffer::MessageHeader::GetDataSize() / sizeof(util::BitPack32);
R_UNLESS(message_buffer.Get32(SpecialHeaderIndex) == ExpectedSpecialHeader, tipc::ResultInvalidMessageFormat());
}
R_SUCCEED();
}
template<size_t Ix>
static ALWAYS_INLINE auto DeserializeArgument(const MessageBuffer &message_buffer, const OutRawHolderType &out_raw_holder, OutHandleHolderType &out_handles_holder) {
return DeserializeArgumentImpl<Ix>(message_buffer, out_raw_holder, out_handles_holder);
}
static ALWAYS_INLINE void SerializeResults(const MessageBuffer &message_buffer, const Result &result, const OutRawHolderType &out_raw_holder, const OutHandleHolderType &out_handles_holder) {
/* Set output headers. */
message_buffer.Set(CommandMeta::OutMessageHeader);
if constexpr (CommandMeta::HasOutSpecialHeader) {
message_buffer.Set(CommandMeta::OutSpecialHeader);
}
/* Set output handles. */
out_handles_holder.CopyTo(message_buffer);
/* Set output result. */
message_buffer.Set(CommandMeta::OutMessageResultIndex, result.GetValue());
/* Set output data. */
out_raw_holder.CopyTo(message_buffer);
}
};
struct FunctionTraits {
public:
template<typename R, typename C, typename... A>
static std::tuple<A...> GetArgumentsImpl(R(C::*)(A...));
template<typename R, typename C, typename... A>
static R GetReturnImpl(R(C::*)(A...));
};
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
constexpr ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
using Return = decltype(FunctionTraits::GetReturnImpl(ServiceCommandImpl));
using TrueArgumentsTuple = decltype(FunctionTraits::GetArgumentsImpl(ServiceCommandImpl));
using CommandMeta = CommandMetaInfo<_CommmandId, TrueArgumentsTuple>;
using Processor = CommandProcessor<CommandMeta>;
/* TODO: ValidateClassType is valid? */
constexpr bool ReturnsResult = std::is_same<Return, Result>::value;
constexpr bool ReturnsVoid = std::is_same<Return, void>::value;
static_assert(ReturnsResult || ReturnsVoid, "Service Commands must return Result or void.");
/* Validate that the command is valid. */
R_TRY(Processor::ValidateCommandFormat(message_buffer));
/* Deserialize arguments. */
typename Processor::OutRawHolderType out_raw_holder;
typename Processor::OutHandleHolderType out_handles_holder;
const Result command_result = [&]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
if constexpr (ReturnsResult) {
R_RETURN((object->*ServiceCommandImpl)(Processor::template DeserializeArgument<Ix>(message_buffer, out_raw_holder, out_handles_holder)...));
} else {
(object->*ServiceCommandImpl)(Processor::template DeserializeArgument<Ix>(message_buffer, out_raw_holder, out_handles_holder)...);
R_SUCCEED();
}
}(std::make_index_sequence<std::tuple_size<typename CommandMeta::ArgsType>::value>());
/* Serialize output. */
Processor::SerializeResults(message_buffer, command_result, out_raw_holder, out_handles_holder);
R_SUCCEED();
}
}
#elif defined(ATMOSPHERE_OS_WINDOWS)
namespace ams::tipc::impl {
template<u16 _CommandId, typename ArgumentsTuple>
struct CommandMetaInfo;
template<u16 _CommandId, typename... Arguments>
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
public:
static constexpr size_t InMessageTotalSize = 0x40; /* TODO */
static constexpr size_t OutMessageTotalSize = 0x40; /* TODO */
};
template<typename CommandMeta>
class CommandProcessor {
public:
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &) {
AMS_ABORT("TODO");
}
};
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
/* TODO: Is some kind of emulated serialization interesting/desirable? */
/* TIPC is generally a huge TODO. */
AMS_UNUSED(object, message_buffer);
AMS_ABORT("TIPC serialization not currently supported on Windows.");
}
}
#elif defined(ATMOSPHERE_OS_LINUX)
namespace ams::tipc::impl {
template<u16 _CommandId, typename ArgumentsTuple>
struct CommandMetaInfo;
template<u16 _CommandId, typename... Arguments>
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
public:
static constexpr size_t InMessageTotalSize = 0x40; /* TODO */
static constexpr size_t OutMessageTotalSize = 0x40; /* TODO */
};
template<typename CommandMeta>
class CommandProcessor {
public:
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &) {
AMS_ABORT("TODO");
}
};
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
/* TODO: Is some kind of emulated serialization interesting/desirable? */
/* TIPC is generally a huge TODO. */
AMS_UNUSED(object, message_buffer);
AMS_ABORT("TIPC serialization not currently supported on Linux.");
}
}
#elif defined(ATMOSPHERE_OS_MACOS)
namespace ams::tipc::impl {
template<u16 _CommandId, typename ArgumentsTuple>
struct CommandMetaInfo;
template<u16 _CommandId, typename... Arguments>
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
public:
static constexpr size_t InMessageTotalSize = 0x40; /* TODO */
static constexpr size_t OutMessageTotalSize = 0x40; /* TODO */
};
template<typename CommandMeta>
class CommandProcessor {
public:
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &) {
AMS_ABORT("TODO");
}
};
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
/* TODO: Is some kind of emulated serialization interesting/desirable? */
/* TIPC is generally a huge TODO. */
AMS_UNUSED(object, message_buffer);
AMS_ABORT("TIPC serialization not currently supported on macOS.");
}
}
#else
#error "Unknown OS for tipc Command serialization."
#endif
| 35,767
|
C++
|
.h
| 615
| 45.034146
| 227
| 0.615804
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,721
|
tipc_impl_message_api.os.linux.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.os.linux.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
namespace ams::tipc::impl {
inline void Reply(tipc::NativeHandle reply_target) {
AMS_UNUSED(reply_target);
AMS_ABORT("TODO: tipc Linux Reply");
}
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
AMS_UNUSED(handle);
AMS_ABORT("TODO: tipc Linux CloseHandle");
}
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
AMS_UNUSED(out_server_session_handle, out_client_session_handle, is_light, name);
AMS_ABORT("TODO: tipc Linux CreateSession");
}
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
AMS_UNUSED(out_handle, port);
AMS_ABORT("TODO: tipc Linux AcceptSession");
}
}
| 1,607
|
C++
|
.h
| 37
| 39.297297
| 165
| 0.7289
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,722
|
tipc_impl_message_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#if defined(ATMOSPHERE_OS_HORIZON)
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.horizon.hpp>
#elif defined(ATMOSPHERE_OS_WINDOWS)
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.windows.hpp>
#elif defined(ATMOSPHERE_OS_LINUX)
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.linux.hpp>
#elif defined(ATMOSPHERE_OS_MACOS)
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.macos.hpp>
#else
#error "Unknown OS for tipc message impl"
#endif
| 1,169
|
C++
|
.h
| 28
| 39.5
| 76
| 0.767544
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,723
|
tipc_impl_message_api.os.macos.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.os.macos.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
namespace ams::tipc::impl {
inline void Reply(tipc::NativeHandle reply_target) {
AMS_UNUSED(reply_target);
AMS_ABORT("TODO: tipc macOS Reply");
}
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
AMS_UNUSED(handle);
AMS_ABORT("TODO: tipc macOS CloseHandle");
}
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
AMS_UNUSED(out_server_session_handle, out_client_session_handle, is_light, name);
AMS_ABORT("TODO: tipc macOS CreateSession");
}
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
AMS_UNUSED(out_handle, port);
AMS_ABORT("TODO: tipc macOS AcceptSession");
}
}
| 1,607
|
C++
|
.h
| 37
| 39.297297
| 165
| 0.7289
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,724
|
tipc_impl_message_api.os.windows.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_impl_message_api.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>
#include <stratosphere/tipc/tipc_common.hpp>
#include <stratosphere/tipc/tipc_message_types.hpp>
namespace ams::tipc::impl {
inline void Reply(tipc::NativeHandle reply_target) {
AMS_UNUSED(reply_target);
AMS_ABORT("TODO: tipc Windows Reply");
}
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
AMS_UNUSED(handle);
AMS_ABORT("TODO: tipc Windows CloseHandle");
}
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
AMS_UNUSED(out_server_session_handle, out_client_session_handle, is_light, name);
AMS_ABORT("TODO: tipc Windows CreateSession");
}
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
AMS_UNUSED(out_handle, port);
AMS_ABORT("TODO: tipc Windows AcceptSession");
}
}
| 1,615
|
C++
|
.h
| 37
| 39.513514
| 165
| 0.73028
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,725
|
capsrv_screen_shot_control_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/capsrv/capsrv_screen_shot_control_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/vi/vi_layer_stack.hpp>
namespace ams::capsrv {
constexpr inline s32 DefaultCaptureTimeoutMilliSeconds = 100;
Result InitializeScreenShotControl();
void FinalizeScreenShotControl();
Result OpenRawScreenShotReadStreamForDevelop(size_t *out_data_size, s32 *out_width, s32 *out_height, vi::LayerStack layer_stack, TimeSpan timeout);
Result ReadRawScreenShotReadStreamForDevelop(size_t *out_read_size, void *dst, size_t dst_size, std::ptrdiff_t offset);
void CloseRawScreenShotReadStreamForDevelop();
Result CaptureJpegScreenshot(u64 *out_size, void *dst, size_t dst_size, vi::LayerStack layer_stack, TimeSpan timeout);
}
| 1,348
|
C++
|
.h
| 27
| 47.111111
| 151
| 0.772451
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,726
|
capsrv_screen_shot_decode_option.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/capsrv/capsrv_screen_shot_decode_option.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have 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::capsrv {
enum ScreenShotDecoderFlag : u64 {
ScreenShotDecoderFlag_None = (0 << 0),
ScreenShotDecoderFlag_EnableFancyUpsampling = (1 << 0),
ScreenShotDecoderFlag_EnableBlockSmoothing = (1 << 1),
};
using ScreenShotJpegDecoderFlagType = typename std::underlying_type<ScreenShotDecoderFlag>::type;
struct ScreenShotDecodeOption {
ScreenShotJpegDecoderFlagType flags;
u8 reserved[0x20 - sizeof(ScreenShotJpegDecoderFlagType)];
static constexpr ScreenShotDecodeOption GetDefaultOption() {
return ScreenShotDecodeOption{};
}
constexpr bool HasJpegDecoderFlag(ScreenShotJpegDecoderFlagType flag) const {
return (this->flags & flag) != 0;
}
};
static_assert(sizeof(ScreenShotDecodeOption) == 0x20);
static_assert(util::is_pod<ScreenShotDecodeOption>::value);
#if defined(ATMOSPHERE_OS_HORIZON)
static_assert(sizeof(ScreenShotDecodeOption) == sizeof(::CapsScreenShotDecodeOption));
#endif
}
| 1,731
|
C++
|
.h
| 40
| 38.3
| 101
| 0.724138
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,727
|
capsrv_server_config.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/capsrv/server/capsrv_server_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::capsrv::server {
constexpr inline int ScreenShotWidth = 1280;
constexpr inline int ScreenShotHeight = 720;
constexpr inline int MovieWidth = 1280;
constexpr inline int MovieHeight = 720;
constexpr inline size_t SoftwareJpegDecoderWorkMemorySize = 16_KB;
}
| 970
|
C++
|
.h
| 24
| 37.75
| 76
| 0.760638
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,728
|
capsrv_server_decoder_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/capsrv/server/capsrv_server_decoder_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::capsrv::server {
Result InitializeForDecoderServer();
void FinalizeForDecoderServer();
void DecoderControlServerThreadFunction(void *);
}
| 841
|
C++
|
.h
| 22
| 35.818182
| 76
| 0.764128
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,729
|
lm_log_getter.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lm/lm_log_getter.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::lm {
void StartLogging();
void StopLogging();
void GetLog(char *dst, size_t size, s64 *out_write_size, u32 *out_drop_count);
}
| 829
|
C++
|
.h
| 22
| 35.318182
| 82
| 0.743462
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,730
|
lm_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lm/lm_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::lm {
enum LogDestination {
LogDestination_TargetManager = (1 << 0),
LogDestination_Uart = (1 << 1),
LogDestination_UartIfSleep = (1 << 2),
LogDestination_All = 0xFFFF,
};
}
| 924
|
C++
|
.h
| 25
| 33.64
| 76
| 0.700559
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,731
|
lm_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lm/lm_api.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::lm {
void Initialize();
void Finalize();
void SetDestination(u32 destination);
}
| 783
|
C++
|
.h
| 22
| 33.227273
| 76
| 0.75033
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,732
|
lmem_common.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lmem/lmem_common.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/lmem/impl/lmem_impl_common.hpp>
namespace ams::lmem {
enum CreateOption {
CreateOption_None = (0),
CreateOption_ZeroClear = (1 << 0),
CreateOption_DebugFill = (1 << 1),
CreateOption_ThreadSafe = (1 << 2),
};
enum FillType {
FillType_Unallocated,
FillType_Allocated,
FillType_Freed,
FillType_Count,
};
namespace impl {
struct HeapHead;
}
using HeapHandle = impl::HeapHead *;
using HeapCommonHead = impl::HeapHead;
struct MemoryRange {
uintptr_t address;
size_t size;
};
constexpr inline s32 DefaultAlignment = 0x8;
/* Common API. */
u32 GetDebugFillValue(FillType fill_type);
void SetDebugFillValue(FillType fill_type, u32 value);
size_t GetTotalSize(HeapHandle handle);
void *GetStartAddress(HeapHandle handle);
bool ContainsAddress(HeapHandle handle, const void *address);
}
| 1,649
|
C++
|
.h
| 48
| 29.520833
| 76
| 0.696282
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,733
|
lmem_exp_heap.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/lmem/lmem_exp_heap.hpp
|
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/lmem/lmem_common.hpp>
namespace ams::lmem {
enum AllocationMode {
AllocationMode_FirstFit,
AllocationMode_BestFit,
};
enum AllocationDirection {
AllocationDirection_Front,
AllocationDirection_Back,
};
using HeapVisitor = void (*)(void *block, HeapHandle handle, uintptr_t user_data);
HeapHandle CreateExpHeap(void *address, size_t size, u32 option);
void DestroyExpHeap(HeapHandle handle);
MemoryRange AdjustExpHeap(HeapHandle handle);
void *AllocateFromExpHeap(HeapHandle handle, size_t size);
void *AllocateFromExpHeap(HeapHandle handle, size_t size, s32 alignment);
void FreeToExpHeap(HeapHandle handle, void *block);
size_t ResizeExpHeapMemoryBlock(HeapHandle handle, void *block, size_t size);
size_t GetExpHeapTotalFreeSize(HeapHandle handle);
size_t GetExpHeapAllocatableSize(HeapHandle handle, s32 alignment);
AllocationMode GetExpHeapAllocationMode(HeapHandle handle);
AllocationMode SetExpHeapAllocationMode(HeapHandle handle, AllocationMode new_mode);
bool GetExpHeapUseMarginsOfAlignment(HeapHandle handle);
bool SetExpHeapUseMarginsOfAlignment(HeapHandle handle, bool use_margins);
u16 GetExpHeapGroupId(HeapHandle handle);
u16 SetExpHeapGroupId(HeapHandle handle, u16 group_id);
size_t GetExpHeapMemoryBlockSize(const void *memory_block);
u16 GetExpHeapMemoryBlockGroupId(const void *memory_block);
AllocationDirection GetExpHeapMemoryBlockAllocationDirection(const void *memory_block);
void VisitExpHeapAllocatedBlocks(HeapHandle handle, HeapVisitor visitor, uintptr_t user_data);
}
| 2,346
|
C++
|
.h
| 48
| 44.604167
| 98
| 0.774858
|
Atmosphere-NX/Atmosphere
| 14,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.