mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 13:35:30 +03:00
Address CR Comments + Fix Clock Rescaling
This commit is contained in:
parent
a3dd759a1c
commit
fbf9f06244
@ -92,9 +92,9 @@ namespace skyline {
|
|||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
/**
|
/**
|
||||||
* @brief A way to implicitly cast all pointers to u64s, this is used for {fmt} as we use 0x{:X} to print pointers
|
* @brief A way to implicitly cast all pointers to uintptr_t, this is used for {fmt} as we use 0x{:X} to print pointers
|
||||||
* @note There's the exception of signed char pointers as they represent C Strings
|
* @note There's the exception of signed char pointers as they represent C Strings
|
||||||
* @note This does not cover std::shared_ptr or std::unique_ptr and those will have to be explicitly casted to u64 or passed through fmt::ptr
|
* @note This does not cover std::shared_ptr or std::unique_ptr and those will have to be explicitly casted to uintptr_t or passed through fmt::ptr
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr auto FmtCast(T object) {
|
constexpr auto FmtCast(T object) {
|
||||||
@ -102,7 +102,7 @@ namespace skyline {
|
|||||||
if constexpr (std::is_same<char, typename std::remove_cv<typename std::remove_pointer<T>::type>::type>::value)
|
if constexpr (std::is_same<char, typename std::remove_cv<typename std::remove_pointer<T>::type>::type>::value)
|
||||||
return reinterpret_cast<typename std::common_type<char *, T>::type>(object);
|
return reinterpret_cast<typename std::common_type<char *, T>::type>(object);
|
||||||
else
|
else
|
||||||
return reinterpret_cast<const u64>(object);
|
return reinterpret_cast<const uintptr_t>(object);
|
||||||
else
|
else
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ namespace skyline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
size_t PointerValue(T *item) {
|
uintptr_t PointerValue(T *item) {
|
||||||
return reinterpret_cast<uintptr_t>(item);
|
return reinterpret_cast<uintptr_t>(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ namespace skyline {
|
|||||||
template<size_t Size>
|
template<size_t Size>
|
||||||
constexpr std::array<u8, Size> HexStringToArray(std::string_view string) {
|
constexpr std::array<u8, Size> HexStringToArray(std::string_view string) {
|
||||||
if (string.size() != Size * 2)
|
if (string.size() != Size * 2)
|
||||||
throw exception("Invalid size");
|
throw exception("String size: {} (Expected {})", string.size(), Size);
|
||||||
std::array<u8, Size> result;
|
std::array<u8, Size> result;
|
||||||
for (size_t i{}; i < Size; i++) {
|
for (size_t i{}; i < Size; i++) {
|
||||||
size_t index{i * 2};
|
size_t index{i * 2};
|
||||||
@ -255,9 +255,11 @@ namespace skyline {
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
constexpr Type HexStringToInt(std::string_view string) {
|
constexpr Type HexStringToInt(std::string_view string) {
|
||||||
|
if (string.size() > sizeof(Type) * 2)
|
||||||
|
throw exception("String size larger than type: {} (sizeof(Type): {})", string.size(), sizeof(Type));
|
||||||
Type result{};
|
Type result{};
|
||||||
size_t offset{(sizeof(Type) * 8) - 4};
|
size_t offset{(sizeof(Type) * 8) - 4};
|
||||||
for (size_t index{}; index < std::min(sizeof(Type) * 2, string.size()); index++, offset -= 4) {
|
for (size_t index{}; index < string.size(); index++, offset -= 4) {
|
||||||
char digit{string[index]};
|
char digit{string[index]};
|
||||||
if (digit >= '0' && digit <= '9')
|
if (digit >= '0' && digit <= '9')
|
||||||
result |= static_cast<Type>(digit - '0') << offset;
|
result |= static_cast<Type>(digit - '0') << offset;
|
||||||
|
@ -23,6 +23,16 @@ namespace skyline {
|
|||||||
public:
|
public:
|
||||||
inline CircularQueue(size_t size) : vector((size + 1) * sizeof(Type)) {}
|
inline CircularQueue(size_t size) : vector((size + 1) * sizeof(Type)) {}
|
||||||
|
|
||||||
|
inline CircularQueue(const CircularQueue &) = delete;
|
||||||
|
|
||||||
|
inline CircularQueue &operator=(const CircularQueue &) = delete;
|
||||||
|
|
||||||
|
inline CircularQueue(CircularQueue &&other) : vector(std::move(other.vector)), consumptionMutex(std::move(other.consumptionMutex)), consumeCondition(std::move(other.consumeCondition)), productionMutex(std::move(other.productionMutex)), produceCondition(std::move(other.produceCondition)) {
|
||||||
|
this->start = other.start;
|
||||||
|
this->end = other.end;
|
||||||
|
other.start = other.end = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
inline ~CircularQueue() {
|
inline ~CircularQueue() {
|
||||||
while (start != end) {
|
while (start != end) {
|
||||||
auto next{start + 1};
|
auto next{start + 1};
|
||||||
@ -68,7 +78,7 @@ namespace skyline {
|
|||||||
|
|
||||||
inline void Append(span <Type> buffer) {
|
inline void Append(span <Type> buffer) {
|
||||||
std::unique_lock lock(productionMutex);
|
std::unique_lock lock(productionMutex);
|
||||||
for (auto &item : buffer) {
|
for (const auto &item : buffer) {
|
||||||
auto next{end + 1};
|
auto next{end + 1};
|
||||||
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
|
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
|
||||||
if (next == start) {
|
if (next == start) {
|
||||||
@ -88,7 +98,7 @@ namespace skyline {
|
|||||||
template<typename TransformedType, typename Transformation>
|
template<typename TransformedType, typename Transformation>
|
||||||
inline void AppendTranform(span <TransformedType> buffer, Transformation transformation) {
|
inline void AppendTranform(span <TransformedType> buffer, Transformation transformation) {
|
||||||
std::unique_lock lock(productionMutex);
|
std::unique_lock lock(productionMutex);
|
||||||
for (auto &item : buffer) {
|
for (const auto &item : buffer) {
|
||||||
auto next{end + 1};
|
auto next{end + 1};
|
||||||
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
|
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
|
||||||
if (next == start) {
|
if (next == start) {
|
||||||
|
@ -48,7 +48,7 @@ namespace skyline::signal {
|
|||||||
signalException.signal = signal;
|
signalException.signal = signal;
|
||||||
signalException.pc = context->uc_mcontext.pc;
|
signalException.pc = context->uc_mcontext.pc;
|
||||||
if (signal == SIGSEGV)
|
if (signal == SIGSEGV)
|
||||||
signalException.faultAddress = info->si_addr;
|
signalException.fault = info->si_addr;
|
||||||
SignalExceptionPtr = std::make_exception_ptr(signalException);
|
SignalExceptionPtr = std::make_exception_ptr(signalException);
|
||||||
context->uc_mcontext.pc = reinterpret_cast<u64>(&ExceptionThrow);
|
context->uc_mcontext.pc = reinterpret_cast<u64>(&ExceptionThrow);
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ namespace skyline::signal {
|
|||||||
public:
|
public:
|
||||||
int signal{};
|
int signal{};
|
||||||
u64 pc{};
|
u64 pc{};
|
||||||
void *faultAddress{};
|
void *fault{};
|
||||||
|
|
||||||
inline std::string what() const {
|
inline std::string what() const {
|
||||||
if (!faultAddress)
|
if (!fault)
|
||||||
return fmt::format("Signal: {} (PC: 0x{:X})", strsignal(signal), pc);
|
return fmt::format("Signal: {} (PC: 0x{:X})", strsignal(signal), pc);
|
||||||
else
|
else
|
||||||
return fmt::format("Signal: {} @ 0x{:X} (PC: 0x{:X})", strsignal(signal), reinterpret_cast<u64>(faultAddress), pc);
|
return fmt::format("Signal: {} @ 0x{:X} (PC: 0x{:X})", strsignal(signal), reinterpret_cast<uintptr_t>(fault), pc);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +99,6 @@ namespace skyline {
|
|||||||
*/
|
*/
|
||||||
bool Unmap(u64 virtAddr, u64 size);
|
bool Unmap(u64 virtAddr, u64 size);
|
||||||
|
|
||||||
|
|
||||||
void Read(u8 *destination, u64 virtAddr, u64 size) const;
|
void Read(u8 *destination, u64 virtAddr, u64 size) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,7 @@ namespace skyline::kernel {
|
|||||||
// Search for a suitable carveout in host AS to fit the guest AS inside of
|
// Search for a suitable carveout in host AS to fit the guest AS inside of
|
||||||
std::ifstream mapsFile("/proc/self/maps");
|
std::ifstream mapsFile("/proc/self/maps");
|
||||||
std::string maps((std::istreambuf_iterator<char>(mapsFile)), std::istreambuf_iterator<char>());
|
std::string maps((std::istreambuf_iterator<char>(mapsFile)), std::istreambuf_iterator<char>());
|
||||||
size_t line{}, start{1ULL << 35}, alignedStart{1ULL << 35}; // 1 << 35 is where QC KGSL (Kernel Graphic Support Layer) maps down from, we skip over this or KGSL goes OOM
|
size_t line{}, start{1ULL << 35}, alignedStart{1ULL << 35}; // Qualcomm KGSL (Kernel Graphic Support Layer/Kernel GPU driver) maps below 35-bits, reserving it causes KGSL to go OOM
|
||||||
do {
|
do {
|
||||||
auto end{util::HexStringToInt<u64>(std::string_view(maps.data() + line, sizeof(u64) * 2))};
|
auto end{util::HexStringToInt<u64>(std::string_view(maps.data() + line, sizeof(u64) * 2))};
|
||||||
if (end < start)
|
if (end < start)
|
||||||
|
@ -186,12 +186,6 @@ namespace skyline {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace loader {
|
|
||||||
class NroLoader;
|
|
||||||
class NsoLoader;
|
|
||||||
class NcaLoader;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
struct ChunkDescriptor {
|
struct ChunkDescriptor {
|
||||||
u8 *ptr;
|
u8 *ptr;
|
||||||
|
@ -113,7 +113,7 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.process->NewHandle<type::KPrivateMemory>(destination, size, chunk->permission, memory::states::Stack);
|
state.process->NewHandle<type::KPrivateMemory>(destination, size, chunk->permission, memory::states::Stack);
|
||||||
memcpy(destination, source, size);
|
std::memcpy(destination, source, size);
|
||||||
|
|
||||||
auto object{state.process->GetMemoryObject(source)};
|
auto object{state.process->GetMemoryObject(source)};
|
||||||
if (!object)
|
if (!object)
|
||||||
@ -281,12 +281,11 @@ namespace skyline::kernel::svc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SleepThread(const DeviceState &state) {
|
void SleepThread(const DeviceState &state) {
|
||||||
u64 in{state.ctx->gpr.x0};
|
i64 in{static_cast<i64>(state.ctx->gpr.x0)};
|
||||||
|
|
||||||
switch (in) {
|
switch (in) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case -1:
|
||||||
case 2:
|
case -2:
|
||||||
state.logger->Debug("svcSleepThread: Yielding thread: {}", in);
|
state.logger->Debug("svcSleepThread: Yielding thread: {}", in);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -553,7 +552,7 @@ namespace skyline::kernel::svc {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint index{};
|
u32 index{};
|
||||||
for (const auto &object : objectTable) {
|
for (const auto &object : objectTable) {
|
||||||
if (object->signalled) {
|
if (object->signalled) {
|
||||||
state.logger->Debug("svcWaitSynchronization: Signalled handle: 0x{:X}", waitHandles[index]);
|
state.logger->Debug("svcWaitSynchronization: Signalled handle: 0x{:X}", waitHandles[index]);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
#include <vfs/npdm.h>
|
||||||
#include "nso.h"
|
#include "nso.h"
|
||||||
#include "nca.h"
|
#include "nca.h"
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ namespace skyline::loader {
|
|||||||
if (nsoFile == nullptr)
|
if (nsoFile == nullptr)
|
||||||
throw exception("Cannot load an ExeFS that doesn't contain rtld");
|
throw exception("Cannot load an ExeFS that doesn't contain rtld");
|
||||||
|
|
||||||
state.process->memory.InitializeVmm(memory::AddressSpaceType::AddressSpace39Bit);
|
state.process->memory.InitializeVmm(process->npdm.meta.flags.type);
|
||||||
|
|
||||||
auto loadInfo{NsoLoader::LoadNso(nsoFile, process, state)};
|
auto loadInfo{NsoLoader::LoadNso(nsoFile, process, state)};
|
||||||
u64 offset{loadInfo.size};
|
u64 offset{loadInfo.size};
|
||||||
|
@ -270,7 +270,7 @@ namespace skyline::nce {
|
|||||||
*instruction = instr::B((end - patch) + offset, true).raw;
|
*instruction = instr::B((end - patch) + offset, true).raw;
|
||||||
|
|
||||||
/* Rescale host clock */
|
/* Rescale host clock */
|
||||||
std::memcpy(patch, reinterpret_cast<void *>(&guest::RescaleClock), guest::RescaleClockSize);
|
std::memcpy(patch, reinterpret_cast<void *>(&guest::RescaleClock), guest::RescaleClockSize * sizeof(u32));
|
||||||
patch += guest::RescaleClockSize;
|
patch += guest::RescaleClockSize;
|
||||||
|
|
||||||
/* Load result from stack into destination register */
|
/* Load result from stack into destination register */
|
||||||
|
@ -38,4 +38,5 @@ namespace skyline::vfs {
|
|||||||
OsFileSystemDirectory(const std::string &path, ListMode listMode);
|
OsFileSystemDirectory(const std::string &path, ListMode listMode);
|
||||||
|
|
||||||
std::vector<Entry> Read();
|
std::vector<Entry> Read();
|
||||||
};}
|
};
|
||||||
|
}
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp">
|
android:paddingVertical="8dp"
|
||||||
|
android:paddingHorizontal="16dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_title"
|
android:id="@+id/text_title"
|
||||||
|
Loading…
Reference in New Issue
Block a user