mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 10:01:50 +01:00
Address CR Comments + Fix Clock Rescaling
This commit is contained in:
parent
a3dd759a1c
commit
fbf9f06244
@ -31,6 +31,6 @@ namespace skyline::audio {
|
||||
/**
|
||||
* @brief Decodes a buffer of ADPCM data into I16 PCM
|
||||
*/
|
||||
std::vector<i16> Decode(span<u8> adpcmData);
|
||||
std::vector<i16> Decode(span <u8> adpcmData);
|
||||
};
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ namespace skyline::audio {
|
||||
* @param ratio The conversion ratio needed
|
||||
* @param channelCount The amount of channels the buffer contains
|
||||
*/
|
||||
std::vector<i16> ResampleBuffer(span<i16> inputBuffer, double ratio, u8 channelCount);
|
||||
std::vector<i16> ResampleBuffer(span <i16> inputBuffer, double ratio, u8 channelCount);
|
||||
};
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ namespace fmt {
|
||||
/**
|
||||
* @brief A std::bitset formatter for {fmt}
|
||||
*/
|
||||
template <size_t N>
|
||||
struct formatter<std::bitset<N>>: formatter<std::string> {
|
||||
template <typename FormatContext>
|
||||
template<size_t N>
|
||||
struct formatter<std::bitset<N>> : formatter<std::string> {
|
||||
template<typename FormatContext>
|
||||
constexpr auto format(const std::bitset<N> &s, FormatContext &ctx) {
|
||||
return formatter<std::string>::format(s.to_string(), ctx);
|
||||
}
|
||||
@ -92,9 +92,9 @@ namespace skyline {
|
||||
|
||||
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 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>
|
||||
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)
|
||||
return reinterpret_cast<typename std::common_type<char *, T>::type>(object);
|
||||
else
|
||||
return reinterpret_cast<const u64>(object);
|
||||
return reinterpret_cast<const uintptr_t>(object);
|
||||
else
|
||||
return object;
|
||||
}
|
||||
@ -153,7 +153,7 @@ namespace skyline {
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t PointerValue(T *item) {
|
||||
uintptr_t PointerValue(T *item) {
|
||||
return reinterpret_cast<uintptr_t>(item);
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ namespace skyline {
|
||||
template<size_t Size>
|
||||
constexpr std::array<u8, Size> HexStringToArray(std::string_view string) {
|
||||
if (string.size() != Size * 2)
|
||||
throw exception("Invalid size");
|
||||
throw exception("String size: {} (Expected {})", string.size(), Size);
|
||||
std::array<u8, Size> result;
|
||||
for (size_t i{}; i < Size; i++) {
|
||||
size_t index{i * 2};
|
||||
@ -255,9 +255,11 @@ namespace skyline {
|
||||
|
||||
template<class Type>
|
||||
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{};
|
||||
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]};
|
||||
if (digit >= '0' && digit <= '9')
|
||||
result |= static_cast<Type>(digit - '0') << offset;
|
||||
|
@ -28,7 +28,7 @@ namespace skyline {
|
||||
* @param copyOffset The offset into the buffer after which to use memcpy rather than copyFunction, -1 will use it for the entire buffer
|
||||
* @return The amount of data written into the input buffer in units of Type
|
||||
*/
|
||||
inline size_t Read(span<Type> buffer, void copyFunction(Type *, Type *) = {}, ssize_t copyOffset = -1) {
|
||||
inline size_t Read(span <Type> buffer, void copyFunction(Type *, Type *) = {}, ssize_t copyOffset = -1) {
|
||||
std::lock_guard guard(mtx);
|
||||
|
||||
if (empty)
|
||||
@ -91,7 +91,7 @@ namespace skyline {
|
||||
/**
|
||||
* @brief Appends data from the specified buffer into this buffer
|
||||
*/
|
||||
inline void Append(span<Type> buffer) {
|
||||
inline void Append(span <Type> buffer) {
|
||||
std::lock_guard guard(mtx);
|
||||
|
||||
Type *pointer{buffer.data()};
|
||||
|
@ -23,6 +23,16 @@ namespace skyline {
|
||||
public:
|
||||
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() {
|
||||
while (start != end) {
|
||||
auto next{start + 1};
|
||||
@ -66,9 +76,9 @@ namespace skyline {
|
||||
produceCondition.notify_one();
|
||||
}
|
||||
|
||||
inline void Append(span<Type> buffer) {
|
||||
inline void Append(span <Type> buffer) {
|
||||
std::unique_lock lock(productionMutex);
|
||||
for (auto &item : buffer) {
|
||||
for (const auto &item : buffer) {
|
||||
auto next{end + 1};
|
||||
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
|
||||
if (next == start) {
|
||||
@ -86,9 +96,9 @@ namespace skyline {
|
||||
* @param tranformation A function that takes in an item of TransformedType as input and returns an item of Type
|
||||
*/
|
||||
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);
|
||||
for (auto &item : buffer) {
|
||||
for (const auto &item : buffer) {
|
||||
auto next{end + 1};
|
||||
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
|
||||
if (next == start) {
|
||||
|
@ -48,7 +48,7 @@ namespace skyline::signal {
|
||||
signalException.signal = signal;
|
||||
signalException.pc = context->uc_mcontext.pc;
|
||||
if (signal == SIGSEGV)
|
||||
signalException.faultAddress = info->si_addr;
|
||||
signalException.fault = info->si_addr;
|
||||
SignalExceptionPtr = std::make_exception_ptr(signalException);
|
||||
context->uc_mcontext.pc = reinterpret_cast<u64>(&ExceptionThrow);
|
||||
|
||||
|
@ -15,13 +15,13 @@ namespace skyline::signal {
|
||||
public:
|
||||
int signal{};
|
||||
u64 pc{};
|
||||
void *faultAddress{};
|
||||
void *fault{};
|
||||
|
||||
inline std::string what() const {
|
||||
if (!faultAddress)
|
||||
if (!fault)
|
||||
return fmt::format("Signal: {} (PC: 0x{:X})", strsignal(signal), pc);
|
||||
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,14 +99,13 @@ namespace skyline {
|
||||
*/
|
||||
bool Unmap(u64 virtAddr, u64 size);
|
||||
|
||||
|
||||
void Read(u8 *destination, u64 virtAddr, u64 size) const;
|
||||
|
||||
/**
|
||||
* @brief Reads in a span from a region of the virtual address space
|
||||
*/
|
||||
template<typename T>
|
||||
void Read(span<T> destination, u64 virtAddr) const {
|
||||
void Read(span <T> destination, u64 virtAddr) const {
|
||||
Read(reinterpret_cast<u8 *>(destination.data()), virtAddr, destination.size_bytes());
|
||||
}
|
||||
|
||||
@ -127,7 +126,7 @@ namespace skyline {
|
||||
* @brief Writes out a span to a region of the virtual address space
|
||||
*/
|
||||
template<typename T>
|
||||
void Write(span<T> source, u64 virtAddr) const {
|
||||
void Write(span <T> source, u64 virtAddr) const {
|
||||
Write(reinterpret_cast<u8 *>(source.data()), virtAddr, source.size_bytes());
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace skyline::kernel {
|
||||
// Search for a suitable carveout in host AS to fit the guest AS inside of
|
||||
std::ifstream mapsFile("/proc/self/maps");
|
||||
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 {
|
||||
auto end{util::HexStringToInt<u64>(std::string_view(maps.data() + line, sizeof(u64) * 2))};
|
||||
if (end < start)
|
||||
|
@ -186,12 +186,6 @@ namespace skyline {
|
||||
};
|
||||
}
|
||||
|
||||
namespace loader {
|
||||
class NroLoader;
|
||||
class NsoLoader;
|
||||
class NcaLoader;
|
||||
}
|
||||
|
||||
namespace kernel {
|
||||
struct ChunkDescriptor {
|
||||
u8 *ptr;
|
||||
|
@ -113,7 +113,7 @@ namespace skyline::kernel::svc {
|
||||
}
|
||||
|
||||
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)};
|
||||
if (!object)
|
||||
@ -281,12 +281,11 @@ namespace skyline::kernel::svc {
|
||||
}
|
||||
|
||||
void SleepThread(const DeviceState &state) {
|
||||
u64 in{state.ctx->gpr.x0};
|
||||
|
||||
i64 in{static_cast<i64>(state.ctx->gpr.x0)};
|
||||
switch (in) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case -1:
|
||||
case -2:
|
||||
state.logger->Debug("svcSleepThread: Yielding thread: {}", in);
|
||||
break;
|
||||
default:
|
||||
@ -553,7 +552,7 @@ namespace skyline::kernel::svc {
|
||||
break;
|
||||
}
|
||||
|
||||
uint index{};
|
||||
u32 index{};
|
||||
for (const auto &object : objectTable) {
|
||||
if (object->signalled) {
|
||||
state.logger->Debug("svcWaitSynchronization: Signalled handle: 0x{:X}", waitHandles[index]);
|
||||
|
@ -183,7 +183,7 @@ namespace skyline {
|
||||
throw exception("GetHandle was called with a deleted handle: 0x{:X}", handle);
|
||||
else
|
||||
throw exception("Tried to get kernel object (0x{:X}) with different type: {} when object is {}", handle, objectType, item->objectType);
|
||||
} catch (const std::out_of_range&) {
|
||||
} catch (const std::out_of_range &) {
|
||||
throw std::out_of_range(fmt::format("GetHandle was called with an invalid handle: 0x{:X}", handle));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||
|
||||
#include <kernel/types/KProcess.h>
|
||||
#include <vfs/npdm.h>
|
||||
#include "nso.h"
|
||||
#include "nca.h"
|
||||
|
||||
@ -19,7 +20,7 @@ namespace skyline::loader {
|
||||
if (nsoFile == nullptr)
|
||||
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)};
|
||||
u64 offset{loadInfo.size};
|
||||
|
@ -270,7 +270,7 @@ namespace skyline::nce {
|
||||
*instruction = instr::B((end - patch) + offset, true).raw;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Load result from stack into destination register */
|
||||
|
@ -39,7 +39,7 @@ namespace skyline {
|
||||
/**
|
||||
* @brief Writes a vector of 128-bit user IDs to an output buffer
|
||||
*/
|
||||
Result WriteUserList(span<u8> buffer, std::vector<UserId> userIds);
|
||||
Result WriteUserList(span <u8> buffer, std::vector<UserId> userIds);
|
||||
|
||||
public:
|
||||
IAccountServiceForApplication(const DeviceState &state, ServiceManager &manager);
|
||||
|
@ -27,43 +27,43 @@ namespace skyline::service::nvdrv::device {
|
||||
* @brief Binds a channel to the address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_BIND_CHANNEL
|
||||
*/
|
||||
NvStatus BindChannel(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus BindChannel(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
/**
|
||||
* @brief Reserves a region in the GPU address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_ALLOC_SPACE
|
||||
*/
|
||||
NvStatus AllocSpace(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus AllocSpace(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
/**
|
||||
* @brief Unmaps a region in the GPU address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_UNMAP_BUFFER
|
||||
*/
|
||||
NvStatus UnmapBuffer(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus UnmapBuffer(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
/**
|
||||
* @brief Maps a region in the GPU address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_MODIFY
|
||||
*/
|
||||
NvStatus Modify(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus Modify(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
/**
|
||||
* @brief Returns the application's GPU address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_GET_VA_REGIONS
|
||||
*/
|
||||
NvStatus GetVaRegions(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus GetVaRegions(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
/**
|
||||
* @brief Initializes the application's GPU address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_ALLOC_AS_EX
|
||||
*/
|
||||
NvStatus AllocAsEx(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus AllocAsEx(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
/**
|
||||
* @brief Remaps a region of the GPU address space
|
||||
* @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_REMAP
|
||||
*/
|
||||
NvStatus Remap(IoctlType type, span<u8> buffer, span<u8> inlineBuffer);
|
||||
NvStatus Remap(IoctlType type, span <u8> buffer, span <u8> inlineBuffer);
|
||||
|
||||
NVDEVICE_DECL(
|
||||
NVFUNC(0x4101, NvHostAsGpu, BindChannel),
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -42,13 +42,13 @@ namespace skyline::vfs {
|
||||
* @param offset The offset to start reading from
|
||||
* @return The amount of bytes read
|
||||
*/
|
||||
virtual size_t Read(span<u8> output, size_t offset = 0) = 0;
|
||||
virtual size_t Read(span <u8> output, size_t offset = 0) = 0;
|
||||
|
||||
/**
|
||||
* @brief Implicit casting for reading into spans of different types
|
||||
*/
|
||||
template<class T, typename std::enable_if<!std::is_same_v<T, u8>, bool>::type = true>
|
||||
inline size_t Read(span<T> output, size_t offset = 0) {
|
||||
inline size_t Read(span <T> output, size_t offset = 0) {
|
||||
return Read(output.template cast<u8>(), offset);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ namespace skyline::vfs {
|
||||
* @param offset The offset where the input buffer should be written
|
||||
* @return The amount of bytes written
|
||||
*/
|
||||
virtual size_t Write(span<u8> input, size_t offset = 0) {
|
||||
virtual size_t Write(span <u8> input, size_t offset = 0) {
|
||||
throw exception("This backing does not support being written to");
|
||||
}
|
||||
|
||||
|
@ -38,4 +38,5 @@ namespace skyline::vfs {
|
||||
OsFileSystemDirectory(const std::string &path, ListMode listMode);
|
||||
|
||||
std::vector<Entry> Read();
|
||||
};}
|
||||
};
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace skyline::vfs {
|
||||
*/
|
||||
RegionBacking(const std::shared_ptr<vfs::Backing> &backing, size_t offset, size_t size, Mode mode = {true, false, false}) : Backing(mode, size), backing(backing), baseOffset(offset) {};
|
||||
|
||||
size_t Read(span<u8> output, size_t offset = 0) {
|
||||
size_t Read(span <u8> output, size_t offset = 0) {
|
||||
if (!mode.read)
|
||||
throw exception("Attempting to read a backing that is not readable");
|
||||
if (size - offset < output.size())
|
||||
|
@ -8,7 +8,8 @@
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
android:paddingVertical="8dp"
|
||||
android:paddingHorizontal="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_title"
|
||||
|
Loading…
Reference in New Issue
Block a user