mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:15:08 +01:00
Fix some minor inaccuracies in SVCs and Services
This commit fixes some minor inaccuracies in SVCs and some Service functions.
This commit is contained in:
parent
36f05ee7e0
commit
b13002f0e1
@ -2,7 +2,7 @@
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,*, android-*, -bugprone-bool-pointer-implicit-conversion, -cert-env33-c, -cert-dcl50-cpp, -cert-dcl59-cpp, -cppcoreguidelines-no-malloc, -cppcoreguidelines-owning-memory, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-type-const-cast,
|
||||
-cppcoreguidelines-pro-type-cstyle-cast, -cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-union-access, -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-special-member-functions, -fuchsia-*, -google-*, google-default-arguments, google-explicit-constructor, google-runtime-member-string-references, google-runtime-operator, -hicpp-braces-around-statements,
|
||||
-hicpp-braces-around-statements, -hicpp-named-parameter, -hicpp-no-array-decay, -hicpp-no-assembler, -hicpp-no-malloc, -hicpp-function-size, -hicpp-special-member-functions, -hicpp-vararg, -llvm-*, -objc-*, -readability-else-after-return, -readability-implicit-bool-conversion, -readability-named-parameter, -readability-simplify-boolean-expr, -readability-braces-around-statements,
|
||||
-readability-identifier-naming, -readability-function-size, -readability-redundant-member-init, -misc-bool-pointer-implicit-conversion, -misc-definitions-in-headers, -misc-unused-alias-decls, -misc-unused-parameters, -misc-unused-using-decls, -modernize-use-using, -modernize-use-default-member-init, -clang-diagnostic-*, -clang-analyzer-*, -hicpp-signed-bitwise'
|
||||
-readability-identifier-naming, -readability-function-size, -readability-redundant-member-init, -misc-bool-pointer-implicit-conversion, -misc-definitions-in-headers, -misc-unused-alias-decls, -misc-unused-parameters, -misc-unused-using-decls, -modernize-use-using, -modernize-use-default-member-init, -clang-diagnostic-*, -clang-analyzer-*, -hicpp-signed-bitwise, -misc-non-private-member-variables-in-classes'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:extractNativeLibs="false"
|
||||
android:extractNativeLibs="true"
|
||||
android:fullBackupContent="@xml/backup_descriptor"
|
||||
android:icon="@drawable/logo_skyline"
|
||||
android:label="@string/app_name"
|
||||
|
@ -163,6 +163,11 @@ namespace skyline::kernel::svc {
|
||||
state.logger->Debug("svcSleepThread: Yielding thread: {}", in);
|
||||
break;
|
||||
default:
|
||||
struct timespec spec = {
|
||||
.tv_sec = static_cast<time_t>(state.ctx->registers.x0 / 1000000000),
|
||||
.tv_nsec = static_cast<long>(state.ctx->registers.x0 % 1000000000)
|
||||
};
|
||||
nanosleep(&spec, nullptr);
|
||||
state.logger->Debug("svcSleepThread: Thread sleeping for {} ns", in);
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ namespace skyline::kernel::type {
|
||||
this->address = fregs.x0;
|
||||
}
|
||||
|
||||
u64 RemapPrivateFunc(u64 address, size_t oldSize, size_t size, u64 flags) {
|
||||
return reinterpret_cast<u64>(mremap(reinterpret_cast<void *>(address), oldSize, size, static_cast<int>(flags)));
|
||||
}
|
||||
|
||||
u64 KPrivateMemory::Resize(size_t newSize, bool canMove) {
|
||||
Registers fregs{};
|
||||
fregs.x0 = address;
|
||||
@ -38,10 +34,6 @@ namespace skyline::kernel::type {
|
||||
return address;
|
||||
}
|
||||
|
||||
u64 UpdatePermissionPrivateFunc(u64 address, size_t size, u64 perms) {
|
||||
return static_cast<u64>(mprotect(reinterpret_cast<void *>(address), size, static_cast<int>(perms)));
|
||||
}
|
||||
|
||||
void KPrivateMemory::UpdatePermission(memory::Permission permission) {
|
||||
Registers fregs{};
|
||||
fregs.x0 = address;
|
||||
@ -73,10 +65,6 @@ namespace skyline::kernel::type {
|
||||
return info;
|
||||
}
|
||||
|
||||
u64 UnmapPrivateFunc(u64 address, size_t size) {
|
||||
return static_cast<u64>(munmap(reinterpret_cast<void *>(address), size));
|
||||
}
|
||||
|
||||
KPrivateMemory::~KPrivateMemory() {
|
||||
try {
|
||||
if (state.process) {
|
||||
|
@ -6,10 +6,6 @@
|
||||
#include <asm/unistd.h>
|
||||
|
||||
namespace skyline::kernel::type {
|
||||
u64 MapSharedFunc(u64 address, size_t size, u64 perms, u64 fd) {
|
||||
return reinterpret_cast<u64>(mmap(reinterpret_cast<void *>(address), size, static_cast<int>(perms), MAP_SHARED | ((address) ? MAP_FIXED : 0), static_cast<int>(fd), 0));
|
||||
}
|
||||
|
||||
KSharedMemory::KSharedMemory(const DeviceState &state, u64 address, size_t size, const memory::Permission permission, memory::Type type) : type(type), KObject(state, KType::KSharedMemory) {
|
||||
fd = ASharedMemory_create("", size);
|
||||
if (fd < 0)
|
||||
@ -35,36 +31,13 @@ namespace skyline::kernel::type {
|
||||
return fregs.x0;
|
||||
}
|
||||
|
||||
u64 UnmapSharedFunc(u64 address, size_t size) {
|
||||
return static_cast<u64>(munmap(reinterpret_cast<void *>(address), size));
|
||||
}
|
||||
|
||||
KSharedMemory::~KSharedMemory() {
|
||||
try {
|
||||
if (guest.valid() && state.process) {
|
||||
Registers fregs{};
|
||||
fregs.x0 = guest.address;
|
||||
fregs.x1 = guest.size;
|
||||
fregs.x8 = __NR_munmap;
|
||||
state.nce->ExecuteFunction(ThreadCall::Syscall, fregs, state.process->pid);
|
||||
}
|
||||
if (kernel.valid())
|
||||
UnmapSharedFunc(kernel.address, kernel.size);
|
||||
} catch (const std::exception &) {
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
u64 RemapSharedFunc(u64 address, size_t oldSize, size_t size) {
|
||||
return reinterpret_cast<u64>(mremap(reinterpret_cast<void *>(address), oldSize, size, 0));
|
||||
}
|
||||
|
||||
void KSharedMemory::Resize(size_t size) {
|
||||
if (guest.valid()) {
|
||||
Registers fregs{};
|
||||
fregs.x0 = guest.address;
|
||||
fregs.x1 = guest.size;
|
||||
fregs.x2 = size;
|
||||
fregs.x8 = __NR_mremap;
|
||||
state.nce->ExecuteFunction(ThreadCall::Syscall, fregs, state.thread->pid);
|
||||
if (fregs.x0 < 0)
|
||||
throw exception("An error occurred while remapping shared region in child process");
|
||||
@ -77,16 +50,13 @@ namespace skyline::kernel::type {
|
||||
}
|
||||
}
|
||||
|
||||
u64 UpdatePermissionSharedFunc(u64 address, size_t size, u64 perms) {
|
||||
return static_cast<u64>(mprotect(reinterpret_cast<void *>(address), size, static_cast<int>(perms)));
|
||||
}
|
||||
|
||||
void KSharedMemory::UpdatePermission(memory::Permission permission, bool host) {
|
||||
if (guest.valid() && !host) {
|
||||
Registers fregs{};
|
||||
fregs.x0 = guest.address;
|
||||
fregs.x1 = guest.size;
|
||||
fregs.x2 = static_cast<u64>(guest.permission.Get());
|
||||
fregs.x8 = __NR_mprotect;
|
||||
state.nce->ExecuteFunction(ThreadCall::Syscall, fregs, state.thread->pid);
|
||||
if (fregs.x0 < 0)
|
||||
throw exception("An error occurred while updating shared region's permissions in child process");
|
||||
@ -113,4 +83,20 @@ namespace skyline::kernel::type {
|
||||
info.deviceRefCount = deviceRefCount;
|
||||
return info;
|
||||
}
|
||||
|
||||
KSharedMemory::~KSharedMemory() {
|
||||
try {
|
||||
if (guest.valid() && state.process) {
|
||||
Registers fregs{};
|
||||
fregs.x0 = guest.address;
|
||||
fregs.x1 = guest.size;
|
||||
fregs.x8 = __NR_munmap;
|
||||
state.nce->ExecuteFunction(ThreadCall::Syscall, fregs, state.process->pid);
|
||||
}
|
||||
if (kernel.valid())
|
||||
munmap(reinterpret_cast<void *>(kernel.address), kernel.size);
|
||||
} catch (const std::exception &) {
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
};
|
||||
|
@ -4,10 +4,6 @@
|
||||
#include <asm/unistd.h>
|
||||
|
||||
namespace skyline::kernel::type {
|
||||
u64 MapTransferFunc(u64 address, size_t size, u64 perms) {
|
||||
return reinterpret_cast<u64>(mmap(reinterpret_cast<void *>(address), size, static_cast<int>(perms), MAP_ANONYMOUS | MAP_PRIVATE | ((address) ? MAP_FIXED : 0), -1, 0));
|
||||
}
|
||||
|
||||
KTransferMemory::KTransferMemory(const DeviceState &state, pid_t pid, u64 address, size_t size, const memory::Permission permission) : owner(pid), cSize(size), permission(permission), KObject(state, KType::KTransferMemory) {
|
||||
if (pid) {
|
||||
Registers fregs{};
|
||||
@ -43,7 +39,7 @@ namespace skyline::kernel::type {
|
||||
throw exception("An error occurred while mapping transfer memory in child process");
|
||||
address = fregs.x0;
|
||||
} else {
|
||||
address = MapTransferFunc(address, size, static_cast<u64>(permission.Get()));
|
||||
address = reinterpret_cast<u64>(mmap(reinterpret_cast<void *>(address), size, permission.Get(), MAP_ANONYMOUS | MAP_PRIVATE | ((address) ? MAP_FIXED : 0), -1, 0));
|
||||
if (reinterpret_cast<void *>(address) == MAP_FAILED)
|
||||
throw exception("An error occurred while mapping transfer memory in kernel");
|
||||
}
|
||||
@ -94,6 +90,7 @@ namespace skyline::kernel::type {
|
||||
Registers fregs{};
|
||||
fregs.x0 = cAddress;
|
||||
fregs.x1 = cSize;
|
||||
fregs.x8 = __NR_munmap;
|
||||
state.nce->ExecuteFunction(ThreadCall::Syscall, fregs, state.process->pid);
|
||||
}
|
||||
} catch (const std::exception &) {
|
||||
|
@ -139,7 +139,8 @@ namespace skyline {
|
||||
if (ctx->sp)
|
||||
regStr += fmt::format("\nStack Pointer: 0x{:X}", ctx->sp);
|
||||
for (u16 index = 0; index < constant::NumRegs - 1; index += 2) {
|
||||
regStr += fmt::format("\nX{}: 0x{:X}, X{}: 0x{:X}", index, ctx->registers.regs[index], index + 1, ctx->registers.regs[index + 1]);
|
||||
auto xStr = index < 10 ? " X" : "X";
|
||||
regStr += fmt::format("\n{}{}: 0x{:<16X} {}{}: 0x{:X}", xStr, index, ctx->registers.regs[index], xStr, index + 1, ctx->registers.regs[index + 1]);
|
||||
}
|
||||
if (numHist) {
|
||||
state.logger->Debug("Process Trace:{}", trace);
|
||||
|
@ -112,7 +112,7 @@ namespace skyline::guest {
|
||||
"MOV LR, SP\n\t"
|
||||
"SVC #0\n\t"
|
||||
"MOV SP, LR\n\t"
|
||||
"LDR LR, [SP], #16":: : "x0", "x1", "x2", "x3", "x4", "x5", "x8");
|
||||
"LDR LR, [SP], #16" :: : "x0", "x1", "x2", "x3", "x4", "x5", "x8");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -120,8 +120,8 @@ namespace skyline::guest {
|
||||
.tv_sec = static_cast<time_t>(ctx->registers.x0 / 1000000000),
|
||||
.tv_nsec = static_cast<long>(ctx->registers.x0 % 1000000000)
|
||||
};
|
||||
volatile register __unused timespec *specPtr asm("x0") = &spec;
|
||||
asm("MOV X1, XZR\n\t"
|
||||
asm("MOV X0, %0\n\t"
|
||||
"MOV X1, XZR\n\t"
|
||||
"MOV X2, XZR\n\t"
|
||||
"MOV X3, XZR\n\t"
|
||||
"MOV X4, XZR\n\t"
|
||||
@ -131,11 +131,11 @@ namespace skyline::guest {
|
||||
"MOV LR, SP\n\t"
|
||||
"SVC #0\n\t"
|
||||
"MOV SP, LR\n\t"
|
||||
"LDR LR, [SP], #16":: : "x0", "x1", "x2", "x3", "x4", "x5", "x8");
|
||||
"LDR LR, [SP], #16" :: "r"(&spec) : "x0", "x1", "x2", "x3", "x4", "x5", "x8");
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (svc == 0x1E) {
|
||||
} else if (svc == 0x1E) { // svcGetSystemTick
|
||||
asm("STP X1, X2, [SP, #-16]!\n\t"
|
||||
"STR Q0, [SP, #-16]!\n\t"
|
||||
"STR Q1, [SP, #-16]!\n\t"
|
||||
@ -153,7 +153,7 @@ namespace skyline::guest {
|
||||
"LDR Q2, [SP], #16\n\t"
|
||||
"LDR Q1, [SP], #16\n\t"
|
||||
"LDR Q0, [SP], #16\n\t"
|
||||
"LDP X1, X2, [SP], #16"::"r"(ctx->registers.x0));
|
||||
"LDP X1, X2, [SP], #16" :: "r"(ctx->registers.x0));
|
||||
return;
|
||||
}
|
||||
while (true) {
|
||||
|
@ -21,7 +21,7 @@ namespace skyline::service::am {
|
||||
|
||||
void ICommonStateGetter::GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
auto handle = state.process->InsertItem(messageEvent);
|
||||
state.logger->Debug("Event Handle: 0x{:X}", handle);
|
||||
state.logger->Debug("Applet Event Handle: 0x{:X}", handle);
|
||||
response.copyHandles.push_back(handle);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace skyline::service::nvnflinger {
|
||||
|
||||
void dispdrv::GetNativeHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
handle_t handle = state.process->InsertItem(state.gpu->bufferEvent);
|
||||
state.logger->Debug("BufferEvent Handle: 0x{:X}", handle);
|
||||
state.logger->Debug("Display Buffer Event Handle: 0x{:X}", handle);
|
||||
response.copyHandles.push_back(handle);
|
||||
response.Push<u32>(constant::status::Success);
|
||||
}
|
||||
|
@ -115,9 +115,7 @@ namespace skyline::service::vi {
|
||||
{0x908, SFUNC(IDisplayService::CreateStrayLayer)}
|
||||
}) {}
|
||||
|
||||
void ISystemDisplayService::SetLayerZ(skyline::kernel::type::KSession &session, skyline::kernel::ipc::IpcRequest &request, skyline::kernel::ipc::IpcResponse &response) {
|
||||
response.Push<u32>(constant::status::Success);
|
||||
}
|
||||
void ISystemDisplayService::SetLayerZ(skyline::kernel::type::KSession &session, skyline::kernel::ipc::IpcRequest &request, skyline::kernel::ipc::IpcResponse &response) {}
|
||||
|
||||
IManagerDisplayService::IManagerDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_IManagerDisplayService, {
|
||||
{0x7DA, SFUNC(IManagerDisplayService::CreateManagedLayer)},
|
||||
@ -144,7 +142,5 @@ namespace skyline::service::vi {
|
||||
response.Push<u32>(constant::status::Success);
|
||||
}
|
||||
|
||||
void IManagerDisplayService::AddToLayerStack(skyline::kernel::type::KSession &session, skyline::kernel::ipc::IpcRequest &request, skyline::kernel::ipc::IpcResponse &response) {
|
||||
response.Push<u32>(constant::status::Success);
|
||||
}
|
||||
void IManagerDisplayService::AddToLayerStack(skyline::kernel::type::KSession &session, skyline::kernel::ipc::IpcRequest &request, skyline::kernel::ipc::IpcResponse &response) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user