From 5018b69fbacf12832f17a6c498c7a3dd9ef778ba Mon Sep 17 00:00:00 2001 From: Chad Date: Sun, 4 Oct 2026 18:25:24 -0500 Subject: [PATCH 1/2] fix(libs): take the AMPR wait and counter signatures from ampr_emu sceAmprCommandBufferWaitOnAddress took (address, reference, mask, compare) and WaitOnCounter (counter, reference, compare), and both read the compare value as WAIT_REG_MEM (0 always, 1 <, 2 <=, 3 ==, ...). ampr_emu, which replaces libSceAmpr for retail titles on the console, has (address, reference, compare, flush) and (counter, reference, compare, flush) with the SCE compare values (0 ==, 1 > unsigned, 2 < unsigned, 3 !=), so waits were decoded as other comparisons and could block forever or pass early. WriteAddressFromCounterPairOnCompletion takes one counter index, not two, and WriteKernelEventQueueOnCompletion an int id and no user data. Counter indices above 127, compare values above 3, flush values above 1 and misaligned wait addresses return EINVAL, as in ampr_emu. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceAmpr/Export.cpp | 34 +++++++++++---- core/libs/prx/libkernel/Apr/src/Apr.cpp | 15 +++---- core/libs/tests/GuestAmpr.cpp | 56 +++++++++++++++++++++++++ docs/dev/TechnicalDebt.md | 2 +- 4 files changed, 90 insertions(+), 17 deletions(-) diff --git a/core/libs/prx/libSceAmpr/Export.cpp b/core/libs/prx/libSceAmpr/Export.cpp index 0e05885d2..07a8db5e6 100644 --- a/core/libs/prx/libSceAmpr/Export.cpp +++ b/core/libs/prx/libSceAmpr/Export.cpp @@ -4,6 +4,7 @@ #include "prx/libc/include/General.hpp" #include "prx/libkernel/Apr/include/AprCommandBuffer.hpp" #include +#include static constexpr int SCE_AMPR_ERROR_BUFFER_FULL = 0x8002001C; static constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016; @@ -23,6 +24,14 @@ static int AppendCommand(Apr::CommandBufferObject* buffer, Apr::Opcode opcode, T return Append(buffer, &command, sizeof(command)); } +static bool ValidCounter(std::uint32_t counter) { + return counter < 128u; +} + +static bool ValidWait(std::uint32_t compare, std::uint32_t flush) { + return compare < 4u && flush < 2u; +} + static std::uint64_t MarkerBytes(const char* text) { return sizeof(Apr::MarkerCommand) + ((std::strlen(text) + 8) & ~std::uint64_t{7}); } @@ -53,32 +62,39 @@ int APS5_VABI sceAmprCommandBufferWriteAddressOnCompletion(Apr::CommandBufferObj return AppendCommand(buffer, Apr::Opcode::WriteAddress, Apr::WriteAddressCommand{{}, reinterpret_cast(address), value, 0, 0}); } -int APS5_VABI sceAmprCommandBufferWriteCounterOnCompletion(Apr::CommandBufferObject* buffer, std::uint32_t counter, std::uint32_t value) { +int APS5_VABI sceAmprCommandBufferWriteCounterOnCompletion(Apr::CommandBufferObject* buffer, std::uint8_t counter, std::uint32_t value) { + if (!ValidCounter(counter)) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WriteCounter, Apr::WriteCounterCommand{{}, counter, value}); } -int APS5_VABI sceAmprCommandBufferWaitOnAddress(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t compare) { - return AppendCommand(buffer, Apr::Opcode::WaitOnAddress, Apr::WaitCommand{{}, reinterpret_cast(address), reference, mask, 0, compare}); +int APS5_VABI sceAmprCommandBufferWaitOnAddress(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint64_t reference, std::uint8_t compare, std::uint8_t flush) { + if ((reinterpret_cast(address) & 7u) != 0u || !ValidWait(compare, flush)) return SCE_KERNEL_ERROR_EINVAL; + return AppendCommand(buffer, Apr::Opcode::WaitOnAddress, Apr::WaitCommand{{}, reinterpret_cast(address), reference, ~0ull, 0, compare}); } -int APS5_VABI sceAmprCommandBufferWaitOnCounter(Apr::CommandBufferObject* buffer, std::uint32_t counter, std::uint32_t reference, std::uint32_t compare) { +int APS5_VABI sceAmprCommandBufferWaitOnCounter(Apr::CommandBufferObject* buffer, std::uint8_t counter, std::uint32_t reference, std::uint8_t compare, std::uint8_t flush) { + if (!ValidCounter(counter) || !ValidWait(compare, flush)) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WaitOnCounter, Apr::WaitCommand{{}, 0, reference, ~0ull, counter, compare}); } -int APS5_VABI sceAmprCommandBufferWriteKernelEventQueueOnCompletion(Apr::CommandBufferObject* buffer, std::uint64_t equeue, std::uint64_t ident, std::uint64_t data, std::uint64_t userData) { - return AppendCommand(buffer, Apr::Opcode::WriteKernelEventQueue, Apr::WriteKernelEventQueueCommand{{}, equeue, ident, data, userData}); +int APS5_VABI sceAmprCommandBufferWriteKernelEventQueueOnCompletion(Apr::CommandBufferObject* buffer, std::uint64_t equeue, std::int32_t ident, std::uint64_t data) { + if (!equeue) return SCE_KERNEL_ERROR_EINVAL; + return AppendCommand(buffer, Apr::Opcode::WriteKernelEventQueue, Apr::WriteKernelEventQueueCommand{{}, equeue, static_cast(ident), data, 0}); } int APS5_VABI sceAmprCommandBufferWriteAddressFromTimeCounterOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address) { return AppendCommand(buffer, Apr::Opcode::WriteAddressFromTimeCounter, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), 0, 0}); } -int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint32_t counter) { +int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint8_t counter) { + if (!ValidCounter(counter)) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WriteAddressFromCounter, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), counter, 0}); } -int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint32_t counter0, std::uint32_t counter1) { - return AppendCommand(buffer, Apr::Opcode::WriteAddressFromCounterPair, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), counter0, counter1}); +int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint8_t counter) { + if (!ValidCounter(counter)) return SCE_KERNEL_ERROR_EINVAL; + if (!ValidCounter(counter + 1u)) throw std::runtime_error("sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion: the pair of counter 127 is not known"); + return AppendCommand(buffer, Apr::Opcode::WriteAddressFromCounterPair, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), counter, counter + 1u}); } std::uint64_t APS5_VABI sceAmprMeasureCommandSizeWriteAddressOnCompletion() { return sizeof(Apr::WriteAddressCommand); } diff --git a/core/libs/prx/libkernel/Apr/src/Apr.cpp b/core/libs/prx/libkernel/Apr/src/Apr.cpp index 7f0ebd31f..9152f9419 100644 --- a/core/libs/prx/libkernel/Apr/src/Apr.cpp +++ b/core/libs/prx/libkernel/Apr/src/Apr.cpp @@ -166,14 +166,15 @@ std::uint32_t _counter(std::uint32_t index) { } bool _waitSatisfied(std::uint32_t compare, std::uint64_t value, std::uint64_t reference) { + constexpr std::uint64_t sign = std::uint64_t{1} << 63u; switch (compare) { - case 0: return true; - case 1: return value < reference; - case 2: return value <= reference; - case 3: return value == reference; - case 4: return value != reference; - case 5: return value >= reference; - case 6: return value > reference; + case 0: return value == reference; + case 1: return value > reference; + case 2: return value < reference; + case 3: return value != reference; + case 4: return value - reference < sign; + case 5: return (value ^ sign) > (reference ^ sign); + case 6: return (value ^ sign) < (reference ^ sign); default: throw std::runtime_error("APR: wait compare function " + std::to_string(compare) + " not implemented"); } } diff --git a/core/libs/tests/GuestAmpr.cpp b/core/libs/tests/GuestAmpr.cpp index 6a563e9a9..572e74b77 100644 --- a/core/libs/tests/GuestAmpr.cpp +++ b/core/libs/tests/GuestAmpr.cpp @@ -1,9 +1,11 @@ #include "prx/libc/include/general/VabiMacros.hpp" #include "prx/libkernel/Apr/include/AprCommandBuffer.hpp" #include +#include #include #include #include +#include #include extern "C" { @@ -24,6 +26,12 @@ std::uint64_t APS5_VABI sceAmprMeasureCommandSizePopMarker(); std::uint64_t APS5_VABI sceAmprMeasureCommandSizeSetMarker(const char*); std::uint64_t APS5_VABI sceAmprMeasureCommandSizeSetMarkerWithColor(const char*, std::uint32_t); int APS5_VABI sceKernelAprSubmitCommandBuffer(const Apr::CommandBufferObject*, std::uint32_t); +int APS5_VABI sceAmprCommandBufferWaitOnAddress(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint64_t, std::uint8_t, std::uint8_t); +int APS5_VABI sceAmprCommandBufferWaitOnCounter(Apr::CommandBufferObject*, std::uint8_t, std::uint32_t, std::uint8_t, std::uint8_t); +int APS5_VABI sceAmprCommandBufferWriteCounterOnCompletion(Apr::CommandBufferObject*, std::uint8_t, std::uint32_t); +int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterOnCompletion(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint8_t); +int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint8_t); +int APS5_VABI sceAmprCommandBufferWriteKernelEventQueueOnCompletion(Apr::CommandBufferObject*, std::uint64_t, std::int32_t, std::uint64_t); } static void Require(bool value) { if (!value) std::abort(); } @@ -153,6 +161,51 @@ void TestSubmission() { Require(first == 0x1111 && second == 0x2222); } +void TestWaits() { + Recorder recorder; + alignas(8) std::uint64_t value = 5; + alignas(8) std::uint64_t done = 0; + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, &value, 5, 0, 0) == 0); + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, &value, 3, 1, 0) == 0); + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, &value, 9, 2, 1) == 0); + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, &value, 4, 3, 0) == 0); + Require(sceAmprCommandBufferWriteAddressOnCompletion(&recorder.buffer, &done, 1) == 0); + auto submitted = std::async(std::launch::async, [&]() { return sceKernelAprSubmitCommandBuffer(&recorder.buffer, 0); }); + Require(submitted.wait_for(std::chrono::seconds(10)) == std::future_status::ready); + Require(submitted.get() == 0 && done == 1); +} + +void TestCounters() { + Recorder recorder; + alignas(8) std::uint64_t single = 0; + alignas(8) std::uint64_t pair = 0; + Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 5, 7) == 0); + Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 6, 9) == 0); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 5, 7, 0, 0) == 0); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 6, 8, 1, 1) == 0); + Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, &single, 5) == 0); + Require(sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(&recorder.buffer, &pair, 5) == 0); + Require(sceKernelAprSubmitCommandBuffer(&recorder.buffer, 0) == 0); + Require(single == 7 && pair == (7ull | (9ull << 32u))); +} + +void TestRejectedWaitsAndCounters() { + Recorder recorder; + alignas(8) std::uint64_t words[2] = {}; + auto* misaligned = reinterpret_cast(reinterpret_cast(words) + 4); + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, &words[0], 0, 4, 0) == invalidArgument); + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, &words[0], 0, 0, 2) == invalidArgument); + Require(sceAmprCommandBufferWaitOnAddress(&recorder.buffer, misaligned, 0, 0, 0) == invalidArgument); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 128, 0, 0, 0) == invalidArgument); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 0, 0, 4, 0) == invalidArgument); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 0, 0, 0, 2) == invalidArgument); + Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 128, 0) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, &words[0], 128) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(&recorder.buffer, &words[0], 128) == invalidArgument); + Require(sceAmprCommandBufferWriteKernelEventQueueOnCompletion(&recorder.buffer, 0, 1, 0) == invalidArgument); + Require(recorder.Offset() == 0 && recorder.Commands() == 0); +} + } int main() { @@ -164,5 +217,8 @@ int main() { TestRejectedArguments(); TestFullBuffer(); TestSubmission(); + TestWaits(); + TestCounters(); + TestRejectedWaitsAndCounters(); return 0; } diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 9fe00e510..9132746fc 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -24,7 +24,7 @@ Throughout the project, every function at every stage either **does exactly what ### Unknown function info - [sceVideoOutOpen](../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - the open param's first word is unknown (PPSA21564 passes 16; it is not the byte size, since the affinity mask is at offset 16); only 16 is accepted. Whether the param continues past offset 24 is also unknown -- [AMPR WaitOnAddress / WaitOnCounter](../../core/libs/prx/libkernel/Apr/src/Apr.cpp) (libSceAmpr) - compare encoding assumed to be the WAIT_REG_MEM one (0 always, 1 <, 2 <=, 3 ==, 4 !=, 5 >=, 6 >) +- [AMPR WriteAddressFromCounterPairOnCompletion](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - the pair of counter n is assumed to be counters n (low 32 bits) and n + 1 (high 32 bits); counter 127 throws. Wait compare values, wait flush and counter index ranges follow the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation; the flush is accepted and has no effect, as commands run in order - [AMPR markers](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - signatures taken from the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation, not confirmed on a title: `sceAmprCommandBufferSetMarkerWithColor` takes the color by pointer, the push and measure variants by value. Colors are not recorded - [sceAgcSetSubmitMode](../../core/libs/prx/libSceAgc/Misc/src/Suspend.cpp) (libSceAgc) - mode values unknown; only 0 is accepted - [zARR5aCmkoY](../../core/libs/prx/libSceAgc/DcbFlow/src/Control.cpp) (libSceAgc) - unknown name, signature From a583dc7116e6a4992db788f984f07ec2b5e1892e Mon Sep 17 00:00:00 2001 From: Chad Date: Sun, 4 Oct 2026 18:27:00 -0500 Subject: [PATCH 2/2] fix(libs): reject odd AMPR counter pairs and invalid write addresses As in ampr_emu, a counter pair starts at an even counter, and the write commands take a non-null, 8-byte aligned address; others return EINVAL. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceAmpr/Export.cpp | 13 ++++++++----- core/libs/tests/GuestAmpr.cpp | 18 ++++++++++++------ docs/dev/TechnicalDebt.md | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/core/libs/prx/libSceAmpr/Export.cpp b/core/libs/prx/libSceAmpr/Export.cpp index 07a8db5e6..51d8032fd 100644 --- a/core/libs/prx/libSceAmpr/Export.cpp +++ b/core/libs/prx/libSceAmpr/Export.cpp @@ -4,7 +4,6 @@ #include "prx/libc/include/General.hpp" #include "prx/libkernel/Apr/include/AprCommandBuffer.hpp" #include -#include static constexpr int SCE_AMPR_ERROR_BUFFER_FULL = 0x8002001C; static constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016; @@ -28,6 +27,10 @@ static bool ValidCounter(std::uint32_t counter) { return counter < 128u; } +static bool ValidWriteAddress(volatile std::uint64_t* address) { + return address && (reinterpret_cast(address) & 7u) == 0u; +} + static bool ValidWait(std::uint32_t compare, std::uint32_t flush) { return compare < 4u && flush < 2u; } @@ -58,7 +61,7 @@ static int AppendMarker(Apr::CommandBufferObject* buffer, Apr::Opcode opcode, co extern "C" { int APS5_VABI sceAmprCommandBufferWriteAddressOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint64_t value) { - if (!address) return static_cast(0x80020016); + if (!ValidWriteAddress(address)) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WriteAddress, Apr::WriteAddressCommand{{}, reinterpret_cast(address), value, 0, 0}); } @@ -83,17 +86,17 @@ int APS5_VABI sceAmprCommandBufferWriteKernelEventQueueOnCompletion(Apr::Command } int APS5_VABI sceAmprCommandBufferWriteAddressFromTimeCounterOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address) { + if (!ValidWriteAddress(address)) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WriteAddressFromTimeCounter, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), 0, 0}); } int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint8_t counter) { - if (!ValidCounter(counter)) return SCE_KERNEL_ERROR_EINVAL; + if (!ValidWriteAddress(address) || !ValidCounter(counter)) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WriteAddressFromCounter, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), counter, 0}); } int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(Apr::CommandBufferObject* buffer, volatile std::uint64_t* address, std::uint8_t counter) { - if (!ValidCounter(counter)) return SCE_KERNEL_ERROR_EINVAL; - if (!ValidCounter(counter + 1u)) throw std::runtime_error("sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion: the pair of counter 127 is not known"); + if (!ValidWriteAddress(address) || (counter & 0x81u) != 0u) return SCE_KERNEL_ERROR_EINVAL; return AppendCommand(buffer, Apr::Opcode::WriteAddressFromCounterPair, Apr::WriteAddressFromCounterCommand{{}, reinterpret_cast(address), counter, counter + 1u}); } diff --git a/core/libs/tests/GuestAmpr.cpp b/core/libs/tests/GuestAmpr.cpp index 572e74b77..74dad2ece 100644 --- a/core/libs/tests/GuestAmpr.cpp +++ b/core/libs/tests/GuestAmpr.cpp @@ -29,6 +29,7 @@ int APS5_VABI sceKernelAprSubmitCommandBuffer(const Apr::CommandBufferObject*, s int APS5_VABI sceAmprCommandBufferWaitOnAddress(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint64_t, std::uint8_t, std::uint8_t); int APS5_VABI sceAmprCommandBufferWaitOnCounter(Apr::CommandBufferObject*, std::uint8_t, std::uint32_t, std::uint8_t, std::uint8_t); int APS5_VABI sceAmprCommandBufferWriteCounterOnCompletion(Apr::CommandBufferObject*, std::uint8_t, std::uint32_t); +int APS5_VABI sceAmprCommandBufferWriteAddressFromTimeCounterOnCompletion(Apr::CommandBufferObject*, volatile std::uint64_t*); int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterOnCompletion(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint8_t); int APS5_VABI sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(Apr::CommandBufferObject*, volatile std::uint64_t*, std::uint8_t); int APS5_VABI sceAmprCommandBufferWriteKernelEventQueueOnCompletion(Apr::CommandBufferObject*, std::uint64_t, std::int32_t, std::uint64_t); @@ -179,12 +180,12 @@ void TestCounters() { Recorder recorder; alignas(8) std::uint64_t single = 0; alignas(8) std::uint64_t pair = 0; - Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 5, 7) == 0); - Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 6, 9) == 0); - Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 5, 7, 0, 0) == 0); - Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 6, 8, 1, 1) == 0); - Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, &single, 5) == 0); - Require(sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(&recorder.buffer, &pair, 5) == 0); + Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 6, 7) == 0); + Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 7, 9) == 0); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 6, 7, 0, 0) == 0); + Require(sceAmprCommandBufferWaitOnCounter(&recorder.buffer, 7, 8, 1, 1) == 0); + Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, &single, 6) == 0); + Require(sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(&recorder.buffer, &pair, 6) == 0); Require(sceKernelAprSubmitCommandBuffer(&recorder.buffer, 0) == 0); Require(single == 7 && pair == (7ull | (9ull << 32u))); } @@ -202,6 +203,11 @@ void TestRejectedWaitsAndCounters() { Require(sceAmprCommandBufferWriteCounterOnCompletion(&recorder.buffer, 128, 0) == invalidArgument); Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, &words[0], 128) == invalidArgument); Require(sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(&recorder.buffer, &words[0], 128) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressFromCounterPairOnCompletion(&recorder.buffer, &words[0], 7) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, nullptr, 0) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressFromCounterOnCompletion(&recorder.buffer, misaligned, 0) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressFromTimeCounterOnCompletion(&recorder.buffer, nullptr) == invalidArgument); + Require(sceAmprCommandBufferWriteAddressOnCompletion(&recorder.buffer, misaligned, 0) == invalidArgument); Require(sceAmprCommandBufferWriteKernelEventQueueOnCompletion(&recorder.buffer, 0, 1, 0) == invalidArgument); Require(recorder.Offset() == 0 && recorder.Commands() == 0); } diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 9132746fc..ff3427580 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -24,7 +24,7 @@ Throughout the project, every function at every stage either **does exactly what ### Unknown function info - [sceVideoOutOpen](../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - the open param's first word is unknown (PPSA21564 passes 16; it is not the byte size, since the affinity mask is at offset 16); only 16 is accepted. Whether the param continues past offset 24 is also unknown -- [AMPR WriteAddressFromCounterPairOnCompletion](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - the pair of counter n is assumed to be counters n (low 32 bits) and n + 1 (high 32 bits); counter 127 throws. Wait compare values, wait flush and counter index ranges follow the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation; the flush is accepted and has no effect, as commands run in order +- [AMPR WriteAddressFromCounterPairOnCompletion](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - the pair of an even counter n is assumed to give counter n in the low 32 bits and n + 1 in the high 32 bits. Wait compare values, wait flush and counter index ranges follow the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation; the flush is accepted and has no effect, as commands run in order - [AMPR markers](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - signatures taken from the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation, not confirmed on a title: `sceAmprCommandBufferSetMarkerWithColor` takes the color by pointer, the push and measure variants by value. Colors are not recorded - [sceAgcSetSubmitMode](../../core/libs/prx/libSceAgc/Misc/src/Suspend.cpp) (libSceAgc) - mode values unknown; only 0 is accepted - [zARR5aCmkoY](../../core/libs/prx/libSceAgc/DcbFlow/src/Control.cpp) (libSceAgc) - unknown name, signature