Compare commits

...

5 Commits

Author SHA1 Message Date
Marco Rodolfi 710380a325
Merge 8bd63d2922 into 55bbb28a80 2025-01-17 10:40:54 +01:00
Marco Rodolfi 55bbb28a80 [threading] Linux fixes on setting an incorrect priority
This call was failing since SCHED_FIFO doesn't support negative priorities, but only positive ones, see third paragraph of scheduling policies: https://man7.org/linux/man-pages/man7/sched.7.html.

Additionally Linux do provice up to 99 levels, but I've limited myself to the required UNIX standard of 32, and split the priority levels evenly from that.

I've also added a couple of rows to debug additional issues in the future like this.
2025-01-17 09:56:43 +01:00
The-Little-Wolf 4d7b30e844 [Xam/XamUser] - Stub XamUserGetOnlineLanguageFromXUID
- Stubs XamUserGetOnlineLanguageFromXUID and have it return cvars::user_language
- Leave notes for future implementation once we have proper profile support
2025-01-17 08:32:46 +01:00
Adrian ae23222ba8 [Emulator] Validate module is an executable before launching 2025-01-17 08:04:49 +01:00
Marco Rodolfi 8bd63d2922 [linux_platform] Force Clang to preallocate a vector to the required size
It seems that by default vectors are left empty, even if requested with a specific size. Coerce Clang to allocate it by requesting a resize to the desired capacity.
2025-01-16 15:01:22 +01:00
5 changed files with 49 additions and 3 deletions

View File

@ -402,6 +402,7 @@ class Timer : public WaitHandle {
virtual bool Cancel() = 0;
};
#if XE_PLATFORM_WINDOWS
struct ThreadPriority {
static const int32_t kLowest = -2;
static const int32_t kBelowNormal = -1;
@ -409,6 +410,15 @@ struct ThreadPriority {
static const int32_t kAboveNormal = 1;
static const int32_t kHighest = 2;
};
#else
struct ThreadPriority {
static const int32_t kLowest = 1;
static const int32_t kBelowNormal = 8;
static const int32_t kNormal = 16;
static const int32_t kAboveNormal = 24;
static const int32_t kHighest = 32;
};
#endif
// Models a Win32-like thread object.
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx

View File

@ -27,6 +27,8 @@
#include <ctime>
#include <memory>
#include "logging.h"
#if XE_PLATFORM_ANDROID
#include <dlfcn.h>
@ -660,8 +662,18 @@ class PosixCondition<Thread> : public PosixConditionBase {
WaitStarted();
sched_param param{};
param.sched_priority = new_priority;
if (pthread_setschedparam(thread_, SCHED_FIFO, &param) != 0)
assert_always();
int res = pthread_setschedparam(thread_, SCHED_FIFO, &param);
if (res != 0) {
switch (res) {
case EPERM:
XELOGW("Permission denied while setting priority");
break;
case EINVAL:
assert_always();
default:
XELOGW("Unknown error while setting priority");
}
}
}
void QueueUserCallback(std::function<void()> callback) {

View File

@ -1372,6 +1372,12 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
return X_STATUS_NOT_FOUND;
}
if (!module->is_executable()) {
kernel_state_->UnloadUserModule(module, false);
XELOGE("Failed to load user module {}", path);
return X_STATUS_NOT_SUPPORTED;
}
X_RESULT result = kernel_state_->ApplyTitleUpdate(module);
if (XFAILED(result)) {
XELOGE("Failed to apply title update! Cannot run module {}", path);

View File

@ -37,7 +37,13 @@ XamModule::XamModule(Emulator* emulator, KernelState* kernel_state)
std::vector<xe::cpu::Export*> xam_exports(4096);
xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export_entry) {
assert_true(export_entry->ordinal < xam_exports.size());
//FIXME(RodoMa92): I have no clue why, but with Clang asking for a size
//will NOT allocate it by default (fe: size will still be 0). Resizing will
//force it to comply though.
if (xam_exports.size() < export_entry->ordinal) {
xam_exports.resize(4096);
assert_true(export_entry->ordinal < xam_exports.size());
}
xam_exports[export_entry->ordinal] = export_entry;
return export_entry;
}

View File

@ -799,6 +799,18 @@ dword_result_t XamUserGetUserFlagsFromXUID_entry(qword_t xuid) {
}
DECLARE_XAM_EXPORT1(XamUserGetUserFlagsFromXUID, kUserProfiles, kImplemented);
dword_result_t XamUserGetOnlineLanguageFromXUID_entry(qword_t xuid) {
/* Notes:
- Calls XamUserGetUserFlagsFromXUID and returns (ulonglong)(cached_flag <<
0x20) >> 0x39 & 0x1f;
- XamUserGetMembershipTierFromXUID and XamUserGetOnlineCountryFromXUID also
call it
- Removed in metro
*/
return cvars::user_language;
}
DECLARE_XAM_EXPORT1(XamUserGetOnlineLanguageFromXUID, kUserProfiles, kStub);
constexpr uint8_t kStatsMaxAmount = 64;
struct X_STATS_DETAILS {