Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/libs/prx/libSceAgc/tests/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "prx/libSceAgc/Patch/include/Nop.hpp"
#include "prx/libSceAgc/Misc/include/Suspend.hpp"
#include "prx/libSceAgc/Misc/include/RegisterDefaults.hpp"
#include "prx/libSceAgc/Patch/include/Jump.hpp"
#include "prx/libSceAgc/Misc/include/PacketInfo.hpp"
#include "prx/libSceAgc/Misc/include/Debug.hpp"
#include "prx/libSceAgc/DcbState/include/Workload.hpp"
Expand Down Expand Up @@ -215,6 +216,24 @@ void testTagHeaders() {
}
}

void testJumpTargetPatch() {
const auto target = [](std::uintptr_t address) { return reinterpret_cast<const volatile std::uint32_t*>(address); };
Storage storage;
auto* packet = sceAgcDcbJump(&storage.buffer, 1, 2, reinterpret_cast<const std::uint32_t*>(0x1000ull), 0x40);
check(sceAgcJumpPatchSetTarget_0300(packet, 1, target(0x123456789ab0u), 0x80) == 0, "jump target patch with a cache policy failed");
check(packet[1] == 0x56789ab0u && packet[2] == 0x1234u && packet[3] == 0x1f300080u, "jump target patch did not replace the address, size and cache policy only");
check(sceAgcJumpPatchSetTarget(packet, target(0x2000u), 0x10) == 0, "jump target patch failed");
check(packet[1] == 0x2000u && packet[2] == 0 && packet[3] == 0x1f300010u, "jump target patch without a cache policy changed it");
const auto before = storage.words;
expectFailure([&] { sceAgcJumpPatchSetTarget_0300(packet, 4, target(0x3000u), 1); });
expectFailure([&] { sceAgcJumpPatchSetTarget_0300(packet, 0, target(0x3002u), 1); });
expectFailure([&] { sceAgcJumpPatchSetTarget(packet, target(0x3000u), 0x100000u); });
packet[0] = Agc::Command::Header(0x3fu, 5);
expectFailure([&] { sceAgcJumpPatchSetTarget(packet, target(0x3000u), 1); });
packet[0] = before[0];
check(storage.words == before, "a refused jump target patch modified the packet");
}

void testMarkers() {
Storage dcb;
Storage acb;
Expand Down Expand Up @@ -857,6 +876,7 @@ int main(int argc, char** argv) {
testIndexedIndirectDraws();
testTagHeaders();
testMarkers();
testJumpTargetPatch();
testMarkerSpans();
testWorkloads();
testWorkloadStreams();
Expand Down
Loading