Compare commits

...

3 Commits

Author SHA1 Message Date
Michael Scire
7557b7eb92 util: prevent optimizer from removing endian-swapped writes 2022-05-08 15:32:59 -07:00
Michael Scire
187745abd5 ams: address some warnings when building with gcc-12 2022-05-07 17:09:22 -07:00
Michael Scire
4db485083b strat: update for code changes found in boot (closes #1797) 2022-05-05 17:45:55 -07:00
8 changed files with 28 additions and 17 deletions

View File

@@ -843,7 +843,7 @@ namespace ams::ncm {
R_SUCCEED_IF(m_header.has_value());
/* Get our header. */
PatchMetaExtendedDataHeader header;
PatchMetaExtendedDataHeader header{};
R_TRY(this->GetHeader(std::addressof(header)));
/* Set our header. */

View File

@@ -38,6 +38,7 @@ namespace ams::pwm::driver {
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;

View File

@@ -18,14 +18,14 @@
#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) ) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out), (out) ) \
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) \
#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)

View File

@@ -148,6 +148,8 @@ init_libnx_shim.os.horizon.o: CXXFLAGS += -fno-lto
result_get_name.o: CXXFLAGS += -fno-lto
crypto_sha256_generator.o: CXXFLAGS += -fno-lto
spl_secure_monitor_api.os.generic.o: CXXFLAGS += -I$(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/include
fs_id_string_impl.os.generic.o: CXXFLAGS += -I$(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/include

View File

@@ -79,7 +79,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl {
/* Configure initial settings. */
/* NOTE: None of these results are checked. */
this->SetEnabled(device, false);
this->SetDuty(device, 0);
this->SetScale(device, 0.0);
this->SetPeriod(device, DefaultChannelPeriod);
R_SUCCEED();
}
@@ -169,8 +169,16 @@ namespace ams::pwm::driver::board::nintendo::nx::impl {
/* Convert the scale to a duty. */
const int duty = static_cast<int>(((scale * 256.0) / 100.0) + 0.5);
/* Set the duty. */
R_RETURN(this->SetDuty(device, duty));
/* Validate the duty. */
R_UNLESS(0 <= duty && duty <= MaxDuty, pwm::ResultInvalidArgument());
/* Acquire exclusive access to the device registers. */
std::scoped_lock lk(device->SafeCastTo<PwmDeviceImpl>());
/* Update the duty. */
reg::ReadWrite(this->GetRegistersFor(device) + PWM_CONTROLLER_PWM_CSR, PWM_REG_BITS_VALUE(PWM_CSR_PWM, static_cast<u32>(duty)));
R_SUCCEED();
}
Result PwmDriverImpl::GetScale(double *out, IPwmDevice *device) {

View File

@@ -47,9 +47,9 @@ namespace ams::crypto {
};
static constexpr size_t Asn1IdentifierSize = util::size(Asn1Identifier);
private:
Impl m_impl;
Impl m_impl{};
public:
Sha256Generator() { /* ... */ }
Sha256Generator() = default;
void Initialize() {
m_impl.Initialize();

View File

@@ -144,12 +144,12 @@ namespace ams::util {
template<std::integral T>
constexpr ALWAYS_INLINE void StoreBigEndian(T *ptr, T val) {
*ptr = ConvertToBigEndian<T>(val);
*static_cast<volatile T *>(ptr) = ConvertToBigEndian<T>(val);
}
template<std::integral T>
constexpr ALWAYS_INLINE void StoreLittleEndian(T *ptr, T val) {
*ptr = ConvertToLittleEndian<T>(val);
*static_cast<volatile T *>(ptr) = ConvertToLittleEndian<T>(val);
}
}

View File

@@ -18,7 +18,7 @@
namespace ams::crypto {
void GenerateSha256(void *dst, size_t dst_size, const void *src, size_t src_size) {
Sha256Generator gen;
Sha256Generator gen{};
gen.Initialize();
gen.Update(src, src_size);