diff --git a/app/src/main/cpp/skyline/kernel/memory.cpp b/app/src/main/cpp/skyline/kernel/memory.cpp index cb4eaafe..88021455 100644 --- a/app/src/main/cpp/skyline/kernel/memory.cpp +++ b/app/src/main/cpp/skyline/kernel/memory.cpp @@ -199,7 +199,7 @@ namespace skyline::kernel { std::shared_lock lock(mutex); size_t size{}; for (const auto &chunk : chunks) - if (chunk.state != memory::states::Unmapped) + if (chunk.state != memory::states::Unmapped && chunk.state != memory::states::Reserved) size += chunk.size; return size; } diff --git a/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp b/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp index e22b7250..09aaccd9 100644 --- a/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp +++ b/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp @@ -20,7 +20,7 @@ namespace skyline::service::am { return result::OutOfBounds; if (size) - span(parent->content).copy_from(request.outputBuf.at(0), size); + span(parent->content).copy_from(request.inputBuf.at(0), size); return {}; } diff --git a/app/src/main/cpp/skyline/services/hid/IHidServer.cpp b/app/src/main/cpp/skyline/services/hid/IHidServer.cpp index 9f194669..372f8ba9 100644 --- a/app/src/main/cpp/skyline/services/hid/IHidServer.cpp +++ b/app/src/main/cpp/skyline/services/hid/IHidServer.cpp @@ -61,7 +61,7 @@ namespace skyline::service::hid { Result IHidServer::AcquireNpadStyleSetUpdateEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto id{request.Pop()}; - request.copyHandles.push_back(state.process->InsertItem(state.input->npad.at(id).updateEvent)); + response.copyHandles.push_back(state.process->InsertItem(state.input->npad.at(id).updateEvent)); return {}; } diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.cpp index 0a31e9ef..54172dd2 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.cpp @@ -79,19 +79,13 @@ namespace skyline::service::nvdrv::device { } &data = buffer.as(); try { - auto driver{nvdrv::driver.lock()}; - auto nvmap{driver->nvMap.lock()}; - auto mapping{nvmap->GetObject(data.nvmapHandle)}; - if (data.flags.remap) { - auto region{regionMap.upper_bound(data.offset)}; - if ((region == regionMap.begin()) || (region == regionMap.end())) { + auto region{regionMap.lower_bound(data.offset)}; + if (region == regionMap.end()) { state.logger->Warn("Cannot remap an unmapped GPU address space region: 0x{:X}", data.offset); return NvStatus::BadParameter; } - region--; // Upper bound gives us the region after the one we want - if (region->second.size < data.mappingSize) { state.logger->Warn("Cannot remap an partially mapped GPU address space region: 0x{:X}", data.offset); return NvStatus::BadParameter; @@ -100,7 +94,7 @@ namespace skyline::service::nvdrv::device { u64 gpuAddress{data.offset + data.bufferOffset}; u8 *cpuPtr{region->second.ptr + data.bufferOffset}; - if (state.gpu->memoryManager.MapFixed(gpuAddress, cpuPtr, data.mappingSize)) { + if (!state.gpu->memoryManager.MapFixed(gpuAddress, cpuPtr, data.mappingSize)) { state.logger->Warn("Failed to remap GPU address space region: 0x{:X}", gpuAddress); return NvStatus::BadParameter; } @@ -108,6 +102,10 @@ namespace skyline::service::nvdrv::device { return NvStatus::Success; } + auto driver{nvdrv::driver.lock()}; + auto nvmap{driver->nvMap.lock()}; + auto mapping{nvmap->GetObject(data.nvmapHandle)}; + u8 *cpuPtr{data.bufferOffset + mapping->ptr}; u64 size{data.mappingSize ? data.mappingSize : mapping->size};