namespace sts -> namespace ams

namespace sts::ams -> ams::exosphere, ams::.

This is to facilitate future use of ams:: namespace code in
mesosphere, as we'll want to include ams::util, ams::result, ams::svc...
This commit is contained in:
Michael Scire
2019-10-24 02:30:10 -07:00
committed by SciresM
parent 4059dc6187
commit 8cb77ac136
397 changed files with 968 additions and 926 deletions

View File

@@ -18,7 +18,7 @@
#include "boot_calibration.hpp"
#include "boot_i2c_utils.hpp"
namespace sts::boot {
namespace ams::boot {
/* Include configuration into anonymous namespace. */
namespace {

View File

@@ -20,7 +20,7 @@
#include "i2c/driver/i2c_api.hpp"
namespace sts::boot {
namespace ams::boot {
class BatteryDriver {
private:

View File

@@ -17,7 +17,7 @@
#include "boot_battery_icons.hpp"
#include "boot_display.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Battery Display utilities. */
void ShowLowBatteryIcon();

View File

@@ -20,7 +20,7 @@
#include "boot_pmic_driver.hpp"
#include "boot_rtc_driver.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@@ -104,7 +104,7 @@ namespace sts::boot {
}
u32 GetBootReason() {
STS_ASSERT(g_detected_boot_reason);
AMS_ASSERT(g_detected_boot_reason);
return g_boot_reason;
}

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Boot Reason utilities. */
void DetectBootReason();

View File

@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace sts::boot::bq24193 {
namespace ams::boot::bq24193 {
constexpr u8 InputSourceControl = 0x00;
constexpr u8 PowerOnConfiguration = 0x01;
@@ -38,8 +38,8 @@ namespace sts::boot::bq24193 {
constexpr u32 ChargeVoltageLimitMax = 4208;
inline u8 EncodeChargeVoltageLimit(u32 voltage) {
STS_ASSERT(voltage >= ChargeVoltageLimitMin);
STS_ASSERT(voltage <= ChargeVoltageLimitMax);
AMS_ASSERT(voltage >= ChargeVoltageLimitMin);
AMS_ASSERT(voltage <= ChargeVoltageLimitMax);
voltage -= ChargeVoltageLimitMin;
voltage >>= 4;
@@ -54,8 +54,8 @@ namespace sts::boot::bq24193 {
constexpr u32 FastChargeCurrentLimitMax = 4544;
inline u8 EncodeFastChargeCurrentLimit(u32 current) {
STS_ASSERT(current >= FastChargeCurrentLimitMin);
STS_ASSERT(current <= FastChargeCurrentLimitMax);
AMS_ASSERT(current >= FastChargeCurrentLimitMin);
AMS_ASSERT(current <= FastChargeCurrentLimitMax);
current -= FastChargeCurrentLimitMin;
current >>= 6;
@@ -81,8 +81,8 @@ namespace sts::boot::bq24193 {
constexpr u32 PreChargeCurrentLimitMax = 2048;
inline u8 EncodePreChargeCurrentLimit(u32 current) {
STS_ASSERT(current >= PreChargeCurrentLimitMin);
STS_ASSERT(current <= PreChargeCurrentLimitMax);
AMS_ASSERT(current >= PreChargeCurrentLimitMin);
AMS_ASSERT(current <= PreChargeCurrentLimitMax);
current -= PreChargeCurrentLimitMin;
current >>= 7;
@@ -97,8 +97,8 @@ namespace sts::boot::bq24193 {
constexpr u32 TerminationCurrentLimitMax = 2048;
inline u8 EncodeTerminationCurrentLimit(u32 current) {
STS_ASSERT(current >= TerminationCurrentLimitMin);
STS_ASSERT(current <= TerminationCurrentLimitMax);
AMS_ASSERT(current >= TerminationCurrentLimitMin);
AMS_ASSERT(current <= TerminationCurrentLimitMax);
current -= TerminationCurrentLimitMin;
current >>= 7;
@@ -113,8 +113,8 @@ namespace sts::boot::bq24193 {
constexpr u32 MinimumSystemVoltageLimitMax = 3700;
inline u8 EncodeMinimumSystemVoltageLimit(u32 voltage) {
STS_ASSERT(voltage >= MinimumSystemVoltageLimitMin);
STS_ASSERT(voltage <= MinimumSystemVoltageLimitMax);
AMS_ASSERT(voltage >= MinimumSystemVoltageLimitMin);
AMS_ASSERT(voltage <= MinimumSystemVoltageLimitMax);
voltage -= MinimumSystemVoltageLimitMin;
voltage /= 100;

View File

@@ -16,7 +16,7 @@
#include "boot_calibration.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@@ -36,7 +36,7 @@ namespace sts::boot {
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
};
STS_ASSERT(data != nullptr);
AMS_ASSERT(data != nullptr);
u16 crc16 = 0x55AA;
const u8 *data_u8 = reinterpret_cast<const u8 *>(data);

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Calibration utilities. */
u32 GetBatteryVersion();

View File

@@ -17,7 +17,7 @@
#include "boot_change_voltage.hpp"
#include "boot_pmc_wrapper.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void ChangeGpioVoltageTo1_8v();;

View File

@@ -19,7 +19,7 @@
#include "boot_charger_driver.hpp"
namespace sts::boot {
namespace ams::boot {
Result ChargerDriver::Read(u8 addr, u8 *out) {
return ReadI2cRegister(this->i2c_session, reinterpret_cast<u8 *>(out), sizeof(*out), &addr, sizeof(addr));

View File

@@ -23,7 +23,7 @@
#include "gpio/gpio_utils.hpp"
namespace sts::boot {
namespace ams::boot {
class ChargerDriver {
private:

View File

@@ -23,7 +23,7 @@
#include "boot_pmic_driver.hpp"
#include "boot_power_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@@ -100,7 +100,7 @@ namespace sts::boot {
return &BatteryChargeParameters1;
case 2:
return &BatteryChargeParameters2;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -280,7 +280,7 @@ namespace sts::boot {
case CheckBatteryResult::Reboot:
RebootSystem();
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void CheckBatteryCharge();

View File

@@ -18,7 +18,7 @@
#include "boot_check_clock.hpp"
#include "boot_power_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void CheckClock();

View File

@@ -18,7 +18,7 @@
#include "boot_pmc_wrapper.hpp"
#include "boot_registers_pmc.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void SetInitialClockConfiguration();

View File

@@ -28,7 +28,7 @@
#include "boot_registers_pinmux.hpp"
#include "boot_registers_pmc.hpp"
namespace sts::boot {
namespace ams::boot {
/* Display configuration included into anonymous namespace. */
namespace {
@@ -110,7 +110,7 @@ namespace sts::boot {
case DsiSleepOrRegisterWriteKind_Sleep:
svcSleepThread(1'000'000ul * u64(reg_writes[i].offset));
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Splash Screen/Display utilities. */
void InitializeDisplay();

View File

@@ -20,7 +20,7 @@
#include "gpio/gpio_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void SetFanEnabled();

View File

@@ -16,7 +16,7 @@
#include "boot_i2c_utils.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@@ -43,8 +43,8 @@ namespace sts::boot {
}
Result ReadI2cRegister(i2c::driver::Session &session, u8 *dst, size_t dst_size, const u8 *cmd, size_t cmd_size) {
STS_ASSERT(dst != nullptr && dst_size > 0);
STS_ASSERT(cmd != nullptr && cmd_size > 0);
AMS_ASSERT(dst != nullptr && dst_size > 0);
AMS_ASSERT(cmd != nullptr && cmd_size > 0);
u8 cmd_list[i2c::CommandListFormatter::MaxCommandListSize];
@@ -56,8 +56,8 @@ namespace sts::boot {
}
Result WriteI2cRegister(i2c::driver::Session &session, const u8 *src, size_t src_size, const u8 *cmd, size_t cmd_size) {
STS_ASSERT(src != nullptr && src_size > 0);
STS_ASSERT(cmd != nullptr && cmd_size > 0);
AMS_ASSERT(src != nullptr && src_size > 0);
AMS_ASSERT(cmd != nullptr && cmd_size > 0);
u8 cmd_list[0x20];

View File

@@ -20,7 +20,7 @@
#include "i2c/driver/i2c_api.hpp"
namespace sts::boot {
namespace ams::boot {
/* I2C Utilities. */
Result ReadI2cRegister(i2c::driver::Session &session, u8 *dst, size_t dst_size, const u8 *cmd, size_t cmd_size);

View File

@@ -39,7 +39,7 @@
#include "boot_power_utils.hpp"
using namespace sts;
using namespace ams;
extern "C" {
extern u32 __start__;
@@ -61,24 +61,24 @@ extern "C" {
void __libnx_exception_handler(ThreadExceptionDump *ctx);
}
namespace sts::ams {
namespace ams {
ncm::TitleId StratosphereTitleId = ncm::TitleId::Boot;
ncm::TitleId CurrentTitleId = ncm::TitleId::Boot;
void ExceptionHandler(FatalErrorContext *ctx) {
/* We're boot sysmodule, so manually reboot to fatal error. */
boot::RebootForFatalError(ctx);
}
}
namespace result {
namespace sts::result {
bool CallFatalOnResultAssertion = false;
bool CallFatalOnResultAssertion = false;
}
}
using namespace sts;
using namespace ams;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
ams::CrashHandler(ctx);

View File

@@ -21,9 +21,9 @@
#include "i2c/driver/impl/i2c_pcv.hpp"
#include "i2c/driver/impl/i2c_registers.hpp"
using namespace sts::i2c::driver::impl;
using namespace ams::i2c::driver::impl;
namespace sts::pcv {
namespace ams::pcv {
void Initialize() {
/* Don't do anything. */

View File

@@ -17,7 +17,7 @@
#include <stratosphere/spl/smc/spl_smc.hpp>
#include "boot_pmc_wrapper.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {
@@ -41,12 +41,12 @@ namespace sts::boot {
}
u32 ReadPmcRegister(u32 phys_addr) {
STS_ASSERT(IsValidPmcAddress(phys_addr));
AMS_ASSERT(IsValidPmcAddress(phys_addr));
return ReadWriteRegisterImpl(phys_addr, 0, 0);
}
void WritePmcRegister(u32 phys_addr, u32 value, u32 mask) {
STS_ASSERT(IsValidPmcAddress(phys_addr));
AMS_ASSERT(IsValidPmcAddress(phys_addr));
ReadWriteRegisterImpl(phys_addr, value, mask);
}

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* PMC Access Utilities. */
u32 ReadPmcRegister(u32 phys_addr);

View File

@@ -20,7 +20,7 @@
#include "boot_i2c_utils.hpp"
#include "boot_pmic_driver.hpp"
namespace sts::boot {
namespace ams::boot {
void PmicDriver::ShutdownSystem() {
R_ASSERT(this->ShutdownSystem(false));
@@ -89,7 +89,7 @@ namespace sts::boot {
/* Allow up to 5 seconds for shutdown/reboot to take place. */
svcSleepThread(5'000'000'000ul);
STS_ASSERT(false);
AMS_ASSERT(false);
}
void PmicDriver::FinalizeBattery(BatteryDriver *battery_driver) {

View File

@@ -20,7 +20,7 @@
#include "boot_battery_driver.hpp"
namespace sts::boot {
namespace ams::boot {
/* Driver object. */
class PmicDriver {

View File

@@ -21,7 +21,7 @@
#include "boot_power_utils.hpp"
#include "fusee-primary_bin.h"
namespace sts::boot {
namespace ams::boot {
namespace {
@@ -41,7 +41,7 @@ namespace sts::boot {
/* Overwrite all of IRAM with FFs. */
for (size_t ofs = 0; ofs < IramSize; ofs += sizeof(g_work_page)) {
ams::CopyToIram(IramBase + ofs, g_work_page, sizeof(g_work_page));
exosphere::CopyToIram(IramBase + ofs, g_work_page, sizeof(g_work_page));
}
}
@@ -52,7 +52,7 @@ namespace sts::boot {
/* Copy in payload. */
for (size_t ofs = 0; ofs < fusee_primary_bin_size; ofs += 0x1000) {
std::memcpy(g_work_page, &fusee_primary_bin[ofs], std::min(static_cast<size_t>(fusee_primary_bin_size - ofs), size_t(0x1000)));
ams::CopyToIram(IramPayloadBase + ofs, g_work_page, 0x1000);
exosphere::CopyToIram(IramPayloadBase + ofs, g_work_page, 0x1000);
}
@@ -60,10 +60,10 @@ namespace sts::boot {
if (ctx != nullptr) {
std::memset(g_work_page, 0xCC, sizeof(g_work_page));
std::memcpy(g_work_page, ctx, sizeof(*ctx));
ams::CopyToIram(IramPayloadBase + IramPayloadMaxSize, g_work_page, sizeof(g_work_page));
exosphere::CopyToIram(IramPayloadBase + IramPayloadMaxSize, g_work_page, sizeof(g_work_page));
}
ams::ForceRebootToIramPayload();
exosphere::ForceRebootToIramPayload();
}
}

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
/* Power utilities. */
void RebootSystem();

View File

@@ -20,7 +20,7 @@
#include "boot_power_utils.hpp"
#include "boot_repair_boot_images.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void CheckAndRepairBootImages();

View File

@@ -19,7 +19,7 @@
#include "boot_rtc_driver.hpp"
namespace sts::boot {
namespace ams::boot {
Result RtcDriver::ReadRtcRegister(u8 *out, u8 address) {
const u8 update_addr = 0x04;

View File

@@ -20,7 +20,7 @@
#include "boot_i2c_utils.hpp"
namespace sts::boot {
namespace ams::boot {
class RtcDriver {
private:

View File

@@ -18,7 +18,7 @@
#include "boot_display.hpp"
#include "boot_splash_screen.hpp"
namespace sts::boot {
namespace ams::boot {
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void ShowSplashScreen();

View File

@@ -21,7 +21,7 @@
#include "boot_registers_pmc.hpp"
namespace sts::boot {
namespace ams::boot {
/* Include configuration into anonymous namespace. */
namespace {

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::boot {
namespace ams::boot {
void SetInitialWakePinConfiguration();

View File

@@ -19,7 +19,7 @@
#include "gpio_initial_configuration.hpp"
#include "gpio_utils.hpp"
namespace sts::gpio {
namespace ams::gpio {
namespace {
@@ -70,7 +70,7 @@ namespace sts::gpio {
num_configs = NumInitialConfigsIowa;
break;
/* Unknown hardware type, we can't proceed. */
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
} else {
/* Until 2.0.0, the GPIO map for Icosa was used for all hardware types. */
@@ -79,7 +79,7 @@ namespace sts::gpio {
}
/* Ensure we found an appropriate config. */
STS_ASSERT(configs != nullptr);
AMS_ASSERT(configs != nullptr);
for (size_t i = 0; i < num_configs; i++) {
/* Configure the GPIO. */

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::gpio {
namespace ams::gpio {
void SetInitialConfiguration();

View File

@@ -18,7 +18,7 @@
#include "gpio_utils.hpp"
namespace sts::gpio {
namespace ams::gpio {
namespace {
@@ -33,7 +33,7 @@ namespace sts::gpio {
/* Helpers. */
inline u32 GetPadDescriptor(u32 gpio_pad_name) {
STS_ASSERT(gpio_pad_name < PadNameMax);
AMS_ASSERT(gpio_pad_name < PadNameMax);
return Map[gpio_pad_name];
}

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::gpio {
namespace ams::gpio {
/* GPIO Utilities. */
u32 Configure(u32 gpio_pad_name);

View File

@@ -20,7 +20,7 @@
#include "i2c_api.hpp"
#include "impl/i2c_resource_manager.hpp"
namespace sts::i2c::driver {
namespace ams::i2c::driver {
namespace {
@@ -70,7 +70,7 @@ namespace sts::i2c::driver {
svcSleepThread(us * 1'000ul);
}
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess();
}
@@ -87,7 +87,7 @@ namespace sts::i2c::driver {
}
inline void CheckInitialized() {
STS_ASSERT(GetResourceManager().IsInitialized());
AMS_ASSERT(GetResourceManager().IsInitialized());
}
}
@@ -104,7 +104,7 @@ namespace sts::i2c::driver {
/* Session management. */
void OpenSession(Session *out_session, I2cDevice device) {
CheckInitialized();
STS_ASSERT(impl::IsDeviceSupported(device));
AMS_ASSERT(impl::IsDeviceSupported(device));
const auto bus = impl::GetDeviceBus(device);
const auto slave_address = impl::GetDeviceSlaveAddress(device);
@@ -123,8 +123,8 @@ namespace sts::i2c::driver {
/* Communication. */
Result Send(Session &session, const void *src, size_t size, I2cTransactionOption option) {
CheckInitialized();
STS_ASSERT(src != nullptr);
STS_ASSERT(size > 0);
AMS_ASSERT(src != nullptr);
AMS_ASSERT(size > 0);
std::scoped_lock<os::Mutex &> lk(GetResourceManager().GetTransactionMutex(impl::ConvertFromIndex(session.bus_idx)));
return GetResourceManager().GetSession(session.session_id).DoTransactionWithRetry(nullptr, src, size, option, impl::Command::Send);
@@ -132,8 +132,8 @@ namespace sts::i2c::driver {
Result Receive(Session &session, void *dst, size_t size, I2cTransactionOption option) {
CheckInitialized();
STS_ASSERT(dst != nullptr);
STS_ASSERT(size > 0);
AMS_ASSERT(dst != nullptr);
AMS_ASSERT(size > 0);
std::scoped_lock<os::Mutex &> lk(GetResourceManager().GetTransactionMutex(impl::ConvertFromIndex(session.bus_idx)));
return GetResourceManager().GetSession(session.session_id).DoTransactionWithRetry(dst, nullptr, size, option, impl::Command::Receive);
@@ -141,8 +141,8 @@ namespace sts::i2c::driver {
Result ExecuteCommandList(Session &session, void *dst, size_t size, const void *cmd_list, size_t cmd_list_size) {
CheckInitialized();
STS_ASSERT(dst != nullptr && size > 0);
STS_ASSERT(cmd_list != nullptr && cmd_list_size > 0);
AMS_ASSERT(dst != nullptr && size > 0);
AMS_ASSERT(cmd_list != nullptr && cmd_list_size > 0);
u8 *cur_dst = static_cast<u8 *>(dst);
const u8 *cur_cmd = static_cast<const u8 *>(cmd_list);
@@ -150,7 +150,7 @@ namespace sts::i2c::driver {
while (cur_cmd < cmd_list_end) {
Command cmd = static_cast<Command>((*cur_cmd) & 3);
STS_ASSERT(cmd < Command::Count);
AMS_ASSERT(cmd < Command::Count);
R_TRY(g_cmd_handlers[static_cast<size_t>(cmd)](&cur_cmd, &cur_dst, session));
}

View File

@@ -21,7 +21,7 @@
#include "../i2c_types.hpp"
#include "../i2c_command_list.hpp"
namespace sts::i2c::driver {
namespace ams::i2c::driver {
struct Session {
size_t bus_idx;

View File

@@ -20,7 +20,7 @@
#include "i2c_pcv.hpp"
#include "i2c_bus_accessor.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
void BusAccessor::Open(Bus bus, SpeedMode speed_mode) {
std::scoped_lock lk(this->open_mutex);
@@ -29,7 +29,7 @@ namespace sts::i2c::driver::impl {
/* Ensure we're good if this isn't our first session. */
if (this->open_sessions > 1) {
STS_ASSERT(this->speed_mode == speed_mode);
AMS_ASSERT(this->speed_mode == speed_mode);
return;
}
@@ -244,7 +244,7 @@ namespace sts::i2c::driver::impl {
0x46, 0x74, 0x7C, 0x98, 0x55, 0x5F
};
const auto index = ConvertToIndex(bus);
STS_ASSERT(index < util::size(s_interrupts));
AMS_ASSERT(index < util::size(s_interrupts));
R_ASSERT(this->interrupt_event.Initialize(s_interrupts[index], false));
}
@@ -282,7 +282,7 @@ namespace sts::i2c::driver::impl {
src_div = 0x02;
debounce = 0;
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
if (speed_mode == SpeedMode::HighSpeed) {

View File

@@ -21,7 +21,7 @@
#include "i2c_driver_types.hpp"
#include "i2c_registers.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
class BusAccessor {
private:

View File

@@ -19,7 +19,7 @@
#include "i2c_driver_types.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
namespace {
@@ -88,37 +88,37 @@ namespace sts::i2c::driver::impl {
Bus GetDeviceBus(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].bus;
}
u32 GetDeviceSlaveAddress(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].slave_address;
}
AddressingMode GetDeviceAddressingMode(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].addressing_mode;
}
SpeedMode GetDeviceSpeedMode(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].speed_mode;
}
u32 GetDeviceMaxRetries(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].max_retries;
}
u64 GetDeviceRetryWaitTime(I2cDevice dev) {
const size_t dev_idx = GetDeviceIndex(dev);
STS_ASSERT(dev_idx != DeviceInvalidIndex);
AMS_ASSERT(dev_idx != DeviceInvalidIndex);
return g_device_configs[dev_idx].retry_wait_time;
}

View File

@@ -20,7 +20,7 @@
#include "../../i2c_types.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
enum class Command {
Send = 0,
@@ -43,7 +43,7 @@ namespace sts::i2c::driver::impl {
}
constexpr inline Bus ConvertFromIndex(size_t idx) {
STS_ASSERT(idx < static_cast<size_t>(Bus::Count));
AMS_ASSERT(idx < static_cast<size_t>(Bus::Count));
return static_cast<Bus>(idx);
}
@@ -61,7 +61,7 @@ namespace sts::i2c::driver::impl {
return PcvModule_I2C5;
case Bus::I2C6:
return PcvModule_I2C6;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -79,7 +79,7 @@ namespace sts::i2c::driver::impl {
return Bus::I2C5;
case PcvModule_I2C6:
return Bus::I2C6;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}

View File

@@ -20,7 +20,7 @@
/* This forward declares the functionality from pcv that i2c::driver uses. */
/* This allows for overriding at compile-time (e.g., for boot sysmodule). */
namespace sts::pcv {
namespace ams::pcv {
void Initialize();
void Finalize();

View File

@@ -21,7 +21,7 @@
#include "i2c_driver_types.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
struct Registers {
volatile u32 I2C_I2C_CNFG_0;

View File

@@ -20,7 +20,7 @@
#include "i2c_pcv.hpp"
#include "i2c_resource_manager.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
void ResourceManager::Initialize() {
std::scoped_lock lk(this->initialize_mutex);
@@ -29,7 +29,7 @@ namespace sts::i2c::driver::impl {
void ResourceManager::Finalize() {
std::scoped_lock lk(this->initialize_mutex);
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
this->ref_cnt--;
if (this->ref_cnt > 0) {
return;
@@ -59,11 +59,11 @@ namespace sts::i2c::driver::impl {
/* Get, open session. */
{
std::scoped_lock lk(this->session_open_mutex);
STS_ASSERT(out_session != nullptr);
STS_ASSERT(bus < Bus::Count);
AMS_ASSERT(out_session != nullptr);
AMS_ASSERT(bus < Bus::Count);
session_id = GetFreeSessionId();
STS_ASSERT(session_id != InvalidSessionId);
AMS_ASSERT(session_id != InvalidSessionId);
if ((bus == Bus::I2C2 || bus == Bus::I2C3) && (this->bus_accessors[ConvertToIndex(Bus::I2C2)].GetOpenSessions() == 0 && this->bus_accessors[ConvertToIndex(Bus::I2C3)].GetOpenSessions() == 0)) {
@@ -90,7 +90,7 @@ namespace sts::i2c::driver::impl {
/* Get, open session. */
{
std::scoped_lock lk(this->session_open_mutex);
STS_ASSERT(this->sessions[session.session_id].IsOpen());
AMS_ASSERT(this->sessions[session.session_id].IsOpen());
this->sessions[session.session_id].Close();
@@ -109,7 +109,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::SuspendBuses() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
if (!this->suspended) {
{
@@ -128,7 +128,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::ResumeBuses() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
if (this->suspended) {
if (this->bus_accessors[ConvertToIndex(Bus::I2C2)].GetOpenSessions() > 0 || this->bus_accessors[ConvertToIndex(Bus::I2C3)].GetOpenSessions() > 0) {
@@ -151,7 +151,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::SuspendPowerBus() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
std::scoped_lock lk(this->session_open_mutex);
if (!this->power_bus_suspended) {
@@ -163,7 +163,7 @@ namespace sts::i2c::driver::impl {
}
void ResourceManager::ResumePowerBus() {
STS_ASSERT(this->ref_cnt > 0);
AMS_ASSERT(this->ref_cnt > 0);
std::scoped_lock lk(this->session_open_mutex);
if (this->power_bus_suspended) {

View File

@@ -23,7 +23,7 @@
#include "i2c_bus_accessor.hpp"
#include "i2c_session.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
class ResourceManager {
public:

View File

@@ -19,7 +19,7 @@
#include "i2c_session.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
void Session::Open(Bus bus, u32 slave_address, AddressingMode addr_mode, SpeedMode speed_mode, BusAccessor *bus_accessor, u32 max_retries, u64 retry_wait_time) {
std::scoped_lock lk(this->bus_accessor_mutex);
@@ -74,7 +74,7 @@ namespace sts::i2c::driver::impl {
case Command::Receive:
R_TRY(this->bus_accessor->Receive(reinterpret_cast<u8 *>(dst), num_bytes, option, this->addressing_mode, this->slave_address));
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess();

View File

@@ -21,7 +21,7 @@
#include "i2c_driver_types.hpp"
#include "i2c_bus_accessor.hpp"
namespace sts::i2c::driver::impl {
namespace ams::i2c::driver::impl {
class Session {
private:

View File

@@ -20,7 +20,7 @@
#include "i2c_types.hpp"
#include "i2c_command_list.hpp"
namespace sts::i2c {
namespace ams::i2c {
namespace {

View File

@@ -20,7 +20,7 @@
#include "i2c_types.hpp"
namespace sts::i2c {
namespace ams::i2c {
enum class Command {
Send = 0,
@@ -43,7 +43,7 @@ namespace sts::i2c {
size_t cur_index = 0;
public:
CommandListFormatter(void *cmd_list, size_t cmd_list_size) : cmd_list(static_cast<u8 *>(cmd_list)), cmd_list_size(cmd_list_size) {
STS_ASSERT(cmd_list_size <= MaxCommandListSize);
AMS_ASSERT(cmd_list_size <= MaxCommandListSize);
}
~CommandListFormatter() {
this->cmd_list = nullptr;

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::i2c {
namespace ams::i2c {
enum class AddressingMode {
SevenBit = 0,

View File

@@ -19,7 +19,7 @@
#include "pinmux_initial_configuration.hpp"
#include "pinmux_utils.hpp"
namespace sts::pinmux {
namespace ams::pinmux {
namespace {
@@ -61,11 +61,11 @@ namespace sts::pinmux {
num_configs = NumInitialConfigsIowa;
break;
/* Unknown hardware type, we can't proceed. */
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Ensure we found an appropriate config. */
STS_ASSERT(configs != nullptr);
AMS_ASSERT(configs != nullptr);
for (size_t i = 0; i < num_configs; i++) {
UpdatePad(configs[i].name, configs[i].val, configs[i].mask);

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::pinmux {
namespace ams::pinmux {
void SetInitialConfiguration();

View File

@@ -18,7 +18,7 @@
#include "pinmux_utils.hpp"
namespace sts::pinmux {
namespace ams::pinmux {
namespace {
@@ -33,12 +33,12 @@ namespace sts::pinmux {
/* Helpers. */
inline const Definition *GetDefinition(u32 pinmux_name) {
STS_ASSERT(pinmux_name < PadNameMax);
AMS_ASSERT(pinmux_name < PadNameMax);
return &Map[pinmux_name];
}
inline const DrivePadDefinition *GetDrivePadDefinition(u32 drivepad_name) {
STS_ASSERT(drivepad_name < DrivePadNameMax);
AMS_ASSERT(drivepad_name < DrivePadNameMax);
return &DrivePadMap[drivepad_name];
}
@@ -104,7 +104,7 @@ namespace sts::pinmux {
u32 pinmux_val = reg::Read(pinmux_reg);
/* This PINMUX register is locked */
STS_ASSERT((pinmux_val & 0x80) == 0);
AMS_ASSERT((pinmux_val & 0x80) == 0);
u32 pm_val = (pinmux_config_val & 0x07);

View File

@@ -18,7 +18,7 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::pinmux {
namespace ams::pinmux {
/* Pinmux Utilities. */
u32 UpdatePark(u32 pinmux_name);