early-access version 4102

This commit is contained in:
pineappleEA 2024-01-31 06:35:48 +01:00
parent f0e57883dd
commit 6a0b9484c1
11 changed files with 72 additions and 70 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 4101. This is the source code for early-access 4102.
## Legal Notice ## Legal Notice

View file

@ -207,7 +207,7 @@ void Error::Execute() {
void Error::DisplayCompleted() { void Error::DisplayCompleted() {
complete = true; complete = true;
PushOutData(std::make_shared<IStorage>(system, std::vector<u8>())); PushOutData(std::make_shared<IStorage>(system, std::vector<u8>(0x1000)));
Exit(); Exit();
} }

View file

@ -127,7 +127,15 @@ TimeManager::TimeManager(Core::System& system)
res = m_set_sys->GetUserSystemClockContext(user_clock_context); res = m_set_sys->GetUserSystemClockContext(user_clock_context);
ASSERT(res == ResultSuccess); ASSERT(res == ResultSuccess);
// TODO the local clock should initialise with this epoch time, and be updated somewhere else on
// first boot to update it, but I haven't been able to find that point (likely via ntc's auto
// correct as it's defaulted to be enabled). So to get a time that isn't stuck in the past for
// first boot, grab the current real seconds.
auto epoch_time{GetEpochTimeFromInitialYear(m_set_sys)}; auto epoch_time{GetEpochTimeFromInitialYear(m_set_sys)};
if (user_clock_context == Service::PSC::Time::SystemClockContext{}) {
m_steady_clock_resource.GetRtcTimeInSeconds(epoch_time);
}
res = m_time_m->SetupStandardLocalSystemClockCore(user_clock_context, epoch_time); res = m_time_m->SetupStandardLocalSystemClockCore(user_clock_context, epoch_time);
ASSERT(res == ResultSuccess); ASSERT(res == ResultSuccess);

View file

@ -197,32 +197,27 @@ Result TimeZoneService::ToCalendarTimeWithMyRule(
Result TimeZoneService::ToPosixTime(Out<u32> out_count, Result TimeZoneService::ToPosixTime(Out<u32> out_count,
OutArray<s64, BufferAttr_HipcPointer> out_times, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, const Service::PSC::Time::CalendarTime& calendar_time,
Service::PSC::Time::CalendarTime& calendar_time, InRule rule) { InRule rule) {
SCOPE_EXIT({ SCOPE_EXIT({
LOG_DEBUG(Service_Time, LOG_DEBUG(Service_Time,
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} " "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}",
"out_times_count={}", calendar_time, *out_count, out_times[0], out_times[1]);
calendar_time, *out_count, out_times[0], out_times[1], *out_times_count);
}); });
R_RETURN( R_RETURN(m_wrapped_service->ToPosixTime(out_count, out_times, calendar_time, rule));
m_wrapped_service->ToPosixTime(out_count, out_times, out_times_count, calendar_time, rule));
} }
Result TimeZoneService::ToPosixTimeWithMyRule(Out<u32> out_count, Result TimeZoneService::ToPosixTimeWithMyRule(
OutArray<s64, BufferAttr_HipcPointer> out_times, Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, const Service::PSC::Time::CalendarTime& calendar_time) {
Service::PSC::Time::CalendarTime& calendar_time) {
SCOPE_EXIT({ SCOPE_EXIT({
LOG_DEBUG(Service_Time, LOG_DEBUG(Service_Time,
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} " "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}",
"out_times_count={}", calendar_time, *out_count, out_times[0], out_times[1]);
calendar_time, *out_count, out_times[0], out_times[1], *out_times_count);
}); });
R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, out_times_count, R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, calendar_time));
calendar_time));
} }
} // namespace Service::Glue::Time } // namespace Service::Glue::Time

View file

@ -68,12 +68,10 @@ public:
Out<Service::PSC::Time::CalendarTime> out_calendar_time, Out<Service::PSC::Time::CalendarTime> out_calendar_time,
Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time); Out<Service::PSC::Time::CalendarAdditionalInfo> out_additional_info, s64 time);
Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times, Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, Service::PSC::Time::CalendarTime& calendar_time, const Service::PSC::Time::CalendarTime& calendar_time, InRule rule);
InRule rule);
Result ToPosixTimeWithMyRule(Out<u32> out_count, Result ToPosixTimeWithMyRule(Out<u32> out_count,
OutArray<s64, BufferAttr_HipcPointer> out_times, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, const Service::PSC::Time::CalendarTime& calendar_time);
Service::PSC::Time::CalendarTime& calendar_time);
private: private:
Core::System& m_system; Core::System& m_system;

View file

@ -189,7 +189,7 @@ struct fmt::formatter<Service::PSC::Time::SteadyClockTimePoint> : fmt::formatter
template <typename FormatContext> template <typename FormatContext>
auto format(const Service::PSC::Time::SteadyClockTimePoint& time_point, auto format(const Service::PSC::Time::SteadyClockTimePoint& time_point,
FormatContext& ctx) const { FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "time_point={}", time_point.time_point); return fmt::format_to(ctx.out(), "[time_point={}]", time_point.time_point);
} }
}; };
@ -197,7 +197,7 @@ template <>
struct fmt::formatter<Service::PSC::Time::SystemClockContext> : fmt::formatter<fmt::string_view> { struct fmt::formatter<Service::PSC::Time::SystemClockContext> : fmt::formatter<fmt::string_view> {
template <typename FormatContext> template <typename FormatContext>
auto format(const Service::PSC::Time::SystemClockContext& context, FormatContext& ctx) const { auto format(const Service::PSC::Time::SystemClockContext& context, FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "offset={} steady_time_point={}", context.offset, return fmt::format_to(ctx.out(), "[offset={} steady_time_point={}]", context.offset,
context.steady_time_point.time_point); context.steady_time_point.time_point);
} }
}; };
@ -206,8 +206,9 @@ template <>
struct fmt::formatter<Service::PSC::Time::CalendarTime> : fmt::formatter<fmt::string_view> { struct fmt::formatter<Service::PSC::Time::CalendarTime> : fmt::formatter<fmt::string_view> {
template <typename FormatContext> template <typename FormatContext>
auto format(const Service::PSC::Time::CalendarTime& calendar, FormatContext& ctx) const { auto format(const Service::PSC::Time::CalendarTime& calendar, FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "{}/{}/{} {}:{}:{}", calendar.day, calendar.month, return fmt::format_to(ctx.out(), "[{:02}/{:02}/{:04} {:02}:{:02}:{:02}]", calendar.day,
calendar.year, calendar.hour, calendar.minute, calendar.second); calendar.month, calendar.year, calendar.hour, calendar.minute,
calendar.second);
} }
}; };
@ -217,7 +218,7 @@ struct fmt::formatter<Service::PSC::Time::CalendarAdditionalInfo>
template <typename FormatContext> template <typename FormatContext>
auto format(const Service::PSC::Time::CalendarAdditionalInfo& additional, auto format(const Service::PSC::Time::CalendarAdditionalInfo& additional,
FormatContext& ctx) const { FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "weekday={} yearday={} name={} is_dst={} ut_offset={}", return fmt::format_to(ctx.out(), "[weekday={} yearday={} name={} is_dst={} ut_offset={}]",
additional.day_of_week, additional.day_of_year, additional.day_of_week, additional.day_of_year,
additional.name.data(), additional.is_dst, additional.ut_offset); additional.name.data(), additional.is_dst, additional.ut_offset);
} }
@ -245,10 +246,11 @@ struct fmt::formatter<Service::PSC::Time::ClockSnapshot> : fmt::formatter<fmt::s
auto format(const Service::PSC::Time::ClockSnapshot& snapshot, FormatContext& ctx) const { auto format(const Service::PSC::Time::ClockSnapshot& snapshot, FormatContext& ctx) const {
return fmt::format_to( return fmt::format_to(
ctx.out(), ctx.out(),
"user_context={} network_context={} user_time={} network_time={} user_calendar_time={} " "[user_context={} network_context={} user_time={} network_time={} "
"user_calendar_time={} "
"network_calendar_time={} user_calendar_additional_time={} " "network_calendar_time={} user_calendar_additional_time={} "
"network_calendar_additional_time={} steady_clock_time_point={} location={} " "network_calendar_additional_time={} steady_clock_time_point={} location={} "
"is_automatic_correction_enabled={} type={}", "is_automatic_correction_enabled={} type={}]",
snapshot.user_context, snapshot.network_context, snapshot.user_time, snapshot.user_context, snapshot.network_context, snapshot.user_time,
snapshot.network_time, snapshot.user_calendar_time, snapshot.network_calendar_time, snapshot.network_time, snapshot.user_calendar_time, snapshot.network_calendar_time,
snapshot.user_calendar_additional_time, snapshot.network_calendar_additional_time, snapshot.user_calendar_additional_time, snapshot.network_calendar_additional_time,
@ -264,7 +266,7 @@ struct fmt::formatter<Service::PSC::Time::ContinuousAdjustmentTimePoint>
auto format(const Service::PSC::Time::ContinuousAdjustmentTimePoint& time_point, auto format(const Service::PSC::Time::ContinuousAdjustmentTimePoint& time_point,
FormatContext& ctx) const { FormatContext& ctx) const {
return fmt::format_to(ctx.out(), return fmt::format_to(ctx.out(),
"rtc_offset={} diff_scale={} shift_amount={} lower={} upper={}", "[rtc_offset={} diff_scale={} shift_amount={} lower={} upper={}]",
time_point.rtc_offset, time_point.diff_scale, time_point.shift_amount, time_point.rtc_offset, time_point.diff_scale, time_point.shift_amount,
time_point.lower, time_point.upper); time_point.lower, time_point.upper);
} }

View file

@ -140,11 +140,11 @@ Result TimeZone::ParseBinaryInto(Tz::Rule& out_rule, std::span<const u8> binary)
R_RETURN(ParseBinaryImpl(out_rule, binary)); R_RETURN(ParseBinaryImpl(out_rule, binary));
} }
Result TimeZone::ToPosixTime(u32& out_count, std::span<s64> out_times, u32 out_times_count, Result TimeZone::ToPosixTime(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
CalendarTime& calendar, const Tz::Rule& rule) { const CalendarTime& calendar, const Tz::Rule& rule) {
std::scoped_lock l{m_mutex}; std::scoped_lock l{m_mutex};
auto res = ToPosixTimeImpl(out_count, out_times, out_times_count, calendar, rule, -1); auto res = ToPosixTimeImpl(out_count, out_times, out_times_max_count, calendar, rule, -1);
if (res != ResultSuccess) { if (res != ResultSuccess) {
if (res == ResultTimeZoneNotFound) { if (res == ResultTimeZoneNotFound) {
@ -158,10 +158,10 @@ Result TimeZone::ToPosixTime(u32& out_count, std::span<s64> out_times, u32 out_t
} }
Result TimeZone::ToPosixTimeWithMyRule(u32& out_count, std::span<s64> out_times, Result TimeZone::ToPosixTimeWithMyRule(u32& out_count, std::span<s64> out_times,
u32 out_times_count, CalendarTime& calendar) { size_t out_times_max_count, const CalendarTime& calendar) {
std::scoped_lock l{m_mutex}; std::scoped_lock l{m_mutex};
auto res = ToPosixTimeImpl(out_count, out_times, out_times_count, calendar, m_my_rule, -1); auto res = ToPosixTimeImpl(out_count, out_times, out_times_max_count, calendar, m_my_rule, -1);
if (res != ResultSuccess) { if (res != ResultSuccess) {
if (res == ResultTimeZoneNotFound) { if (res == ResultTimeZoneNotFound) {
@ -212,20 +212,23 @@ Result TimeZone::ToCalendarTimeImpl(CalendarTime& out_calendar_time,
R_SUCCEED(); R_SUCCEED();
} }
Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times, u32 out_times_count, Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times,
CalendarTime& calendar, const Tz::Rule& rule, s32 is_dst) { size_t out_times_max_count, const CalendarTime& calendar,
const Tz::Rule& rule, s32 is_dst) {
R_TRY(ValidateRule(rule)); R_TRY(ValidateRule(rule));
calendar.month -= 1; CalendarTime local_calendar{calendar};
calendar.year -= 1900;
local_calendar.month -= 1;
local_calendar.year -= 1900;
Tz::CalendarTimeInternal internal{ Tz::CalendarTimeInternal internal{
.tm_sec = calendar.second, .tm_sec = local_calendar.second,
.tm_min = calendar.minute, .tm_min = local_calendar.minute,
.tm_hour = calendar.hour, .tm_hour = local_calendar.hour,
.tm_mday = calendar.day, .tm_mday = local_calendar.day,
.tm_mon = calendar.month, .tm_mon = local_calendar.month,
.tm_year = calendar.year, .tm_year = local_calendar.year,
.tm_wday = 0, .tm_wday = 0,
.tm_yday = 0, .tm_yday = 0,
.tm_isdst = is_dst, .tm_isdst = is_dst,
@ -243,9 +246,9 @@ Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times, u32 o
R_RETURN(ResultTimeZoneNotFound); R_RETURN(ResultTimeZoneNotFound);
} }
if (internal.tm_sec != calendar.second || internal.tm_min != calendar.minute || if (internal.tm_sec != local_calendar.second || internal.tm_min != local_calendar.minute ||
internal.tm_hour != calendar.hour || internal.tm_mday != calendar.day || internal.tm_hour != local_calendar.hour || internal.tm_mday != local_calendar.day ||
internal.tm_mon != calendar.month || internal.tm_year != calendar.year) { internal.tm_mon != local_calendar.month || internal.tm_year != local_calendar.year) {
R_RETURN(ResultTimeZoneNotFound); R_RETURN(ResultTimeZoneNotFound);
} }
@ -254,7 +257,7 @@ Result TimeZone::ToPosixTimeImpl(u32& out_count, std::span<s64> out_times, u32 o
} }
out_times[0] = time; out_times[0] = time;
if (out_times_count < 2) { if (out_times_max_count < 2) {
out_count = 1; out_count = 1;
R_SUCCEED(); R_SUCCEED();
} }

View file

@ -38,18 +38,18 @@ public:
CalendarAdditionalInfo& calendar_additional, s64 time); CalendarAdditionalInfo& calendar_additional, s64 time);
Result ParseBinary(LocationName& name, std::span<const u8> binary); Result ParseBinary(LocationName& name, std::span<const u8> binary);
Result ParseBinaryInto(Tz::Rule& out_rule, std::span<const u8> binary); Result ParseBinaryInto(Tz::Rule& out_rule, std::span<const u8> binary);
Result ToPosixTime(u32& out_count, std::span<s64> out_times, u32 out_times_count, Result ToPosixTime(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
CalendarTime& calendar, const Tz::Rule& rule); const CalendarTime& calendar, const Tz::Rule& rule);
Result ToPosixTimeWithMyRule(u32& out_count, std::span<s64> out_times, u32 out_times_count, Result ToPosixTimeWithMyRule(u32& out_count, std::span<s64> out_times,
CalendarTime& calendar); size_t out_times_max_count, const CalendarTime& calendar);
private: private:
Result ParseBinaryImpl(Tz::Rule& out_rule, std::span<const u8> binary); Result ParseBinaryImpl(Tz::Rule& out_rule, std::span<const u8> binary);
Result ToCalendarTimeImpl(CalendarTime& out_calendar_time, Result ToCalendarTimeImpl(CalendarTime& out_calendar_time,
CalendarAdditionalInfo& out_additional_info, s64 time, CalendarAdditionalInfo& out_additional_info, s64 time,
const Tz::Rule& rule); const Tz::Rule& rule);
Result ToPosixTimeImpl(u32& out_count, std::span<s64> out_times, u32 out_times_count, Result ToPosixTimeImpl(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
CalendarTime& calendar, const Tz::Rule& rule, s32 is_dst); const CalendarTime& calendar, const Tz::Rule& rule, s32 is_dst);
bool m_initialized{}; bool m_initialized{};
std::recursive_mutex m_mutex; std::recursive_mutex m_mutex;

View file

@ -138,32 +138,28 @@ Result TimeZoneService::ToCalendarTimeWithMyRule(Out<CalendarTime> out_calendar_
Result TimeZoneService::ToPosixTime(Out<u32> out_count, Result TimeZoneService::ToPosixTime(Out<u32> out_count,
OutArray<s64, BufferAttr_HipcPointer> out_times, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, CalendarTime& calendar_time, const CalendarTime& calendar_time, InRule rule) {
InRule rule) {
SCOPE_EXIT({ SCOPE_EXIT({
LOG_DEBUG(Service_Time, LOG_DEBUG(Service_Time,
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} " "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} ",
"out_times_count={}", calendar_time, *out_count, out_times[0], out_times[1]);
calendar_time, *out_count, out_times[0], out_times[1], *out_times_count);
}); });
R_RETURN( R_RETURN(
m_time_zone.ToPosixTime(*out_count, out_times, *out_times_count, calendar_time, *rule)); m_time_zone.ToPosixTime(*out_count, out_times, out_times.size(), calendar_time, *rule));
} }
Result TimeZoneService::ToPosixTimeWithMyRule(Out<u32> out_count, Result TimeZoneService::ToPosixTimeWithMyRule(Out<u32> out_count,
OutArray<s64, BufferAttr_HipcPointer> out_times, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, const CalendarTime& calendar_time) {
CalendarTime& calendar_time) {
SCOPE_EXIT({ SCOPE_EXIT({
LOG_DEBUG(Service_Time, LOG_DEBUG(Service_Time,
"called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} " "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} ",
"out_times_count={}", calendar_time, *out_count, out_times[0], out_times[1]);
calendar_time, *out_count, out_times[0], out_times[1], *out_times_count);
}); });
R_RETURN( R_RETURN(
m_time_zone.ToPosixTimeWithMyRule(*out_count, out_times, *out_times_count, calendar_time)); m_time_zone.ToPosixTimeWithMyRule(*out_count, out_times, out_times.size(), calendar_time));
} }
} // namespace Service::PSC::Time } // namespace Service::PSC::Time

View file

@ -50,10 +50,10 @@ public:
Result ToCalendarTimeWithMyRule(Out<CalendarTime> out_calendar_time, Result ToCalendarTimeWithMyRule(Out<CalendarTime> out_calendar_time,
Out<CalendarAdditionalInfo> out_additional_info, s64 time); Out<CalendarAdditionalInfo> out_additional_info, s64 time);
Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times, Result ToPosixTime(Out<u32> out_count, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, CalendarTime& calendar_time, InRule rule); const CalendarTime& calendar_time, InRule rule);
Result ToPosixTimeWithMyRule(Out<u32> out_count, Result ToPosixTimeWithMyRule(Out<u32> out_count,
OutArray<s64, BufferAttr_HipcPointer> out_times, OutArray<s64, BufferAttr_HipcPointer> out_times,
Out<u32> out_times_count, CalendarTime& calendar_time); const CalendarTime& calendar_time);
private: private:
Core::System& m_system; Core::System& m_system;

View file

@ -25,7 +25,7 @@
namespace Service::Set { namespace Service::Set {
namespace { namespace {
constexpr u32 SETTINGS_VERSION{2u}; constexpr u32 SETTINGS_VERSION{3u};
constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't'); constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't');
struct SettingsHeader { struct SettingsHeader {
u64 magic; u64 magic;