Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22d833d569 | ||
|
|
a80fb38311 | ||
|
|
f74bbbd4bd | ||
|
|
e54a98c845 | ||
|
|
0e0bf5bb56 | ||
|
|
192465422e | ||
|
|
17d81b0ef5 | ||
|
|
486843dd0a | ||
|
|
78a40f39ec | ||
|
|
ea3fcb7745 | ||
|
|
c87e081c8d | ||
|
|
1b3a5f9711 | ||
|
|
d5e0a8e265 | ||
|
|
e758f539af | ||
|
|
eae84e8bff | ||
|
|
11bc5c4e04 | ||
|
|
6ff3d0ae98 | ||
|
|
eeb4497b85 | ||
|
|
3393756ec4 | ||
|
|
ee2a6c7659 | ||
|
|
f67459e46e | ||
|
|
b1df296439 | ||
|
|
9ae78d6e89 | ||
|
|
194a20a333 | ||
|
|
cd23a46923 | ||
|
|
f6ad6b84c1 | ||
|
|
bb109f10c1 | ||
|
|
6d84d33da8 | ||
|
|
9361f192db | ||
|
|
60647811ca | ||
|
|
e94a4be368 | ||
|
|
b97c2cfd2d | ||
|
|
2468eecb26 | ||
|
|
15d8368113 | ||
|
|
98972f7131 | ||
|
|
d67f790c9d | ||
|
|
f5ccaf8aba |
No files matched your search
@@ -0,0 +1,49 @@
|
||||
# .forker.yaml — per-fork configuration for Repo Forker.
|
||||
#
|
||||
# The upstream URL and its token are NOT set here. They are set in the Gitea UI:
|
||||
# Settings -> Actions -> Variables & Secrets
|
||||
# UPSTREAM_URL = https://github.com/owner/repo.git (any provider)
|
||||
# UPSTREAM_TOKEN = <token that can read the upstream>
|
||||
# This keeps secrets out of the repo. Everything below is non-secret.
|
||||
#
|
||||
# All values are optional; sensible defaults apply when a key is absent.
|
||||
|
||||
# (unused — Bearer auth needs no username; retained for compatibility)
|
||||
token_user: oauth2
|
||||
|
||||
# Mirror all tags (true/false). Default: true
|
||||
mirror_tags: true
|
||||
|
||||
# Prune branches that were deleted upstream (true/false). Default: true
|
||||
mirror_prune: true
|
||||
|
||||
# Which upstream branches to mirror. "*" = all (default).
|
||||
# Comma-separated list to restrict, e.g. "main,develop" (stray spaces
|
||||
# tolerated). NOTE: pruning is always checked against the FULL upstream
|
||||
# branch set, so a branch outside this filter but still upstream is never
|
||||
# deleted.
|
||||
mirror_branches: "*"
|
||||
|
||||
# When a new upstream tag is mirrored, automatically build + publish a release
|
||||
# on this Gitea (true/false). Default: true
|
||||
on_new_tag: true
|
||||
|
||||
# Also mirror the upstream's existing releases (metadata + assets) via the
|
||||
# provider API (true/false). Default: false
|
||||
mirror_upstream_releases: true
|
||||
|
||||
# Build commands run inside the tag's working tree to produce release assets.
|
||||
# Multiple commands are ';'-separated. Leave empty to skip the local build and
|
||||
# only mirror upstream release assets.
|
||||
# build_cmd: "make && go build -o dist/app ."
|
||||
build_cmd: ""
|
||||
|
||||
# Optional: point to a custom build script (path relative to the forker branch)
|
||||
# instead of build_cmd. If set, build_cmd is ignored.
|
||||
# build_script: "forker/build-custom.sh"
|
||||
build_script: ""
|
||||
|
||||
# Artifacts to attach to the locally-built release. Space-separated globs,
|
||||
# relative to the tag's working tree.
|
||||
# artifacts: "dist/*"
|
||||
artifacts: ""
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Repo Forker — Release (build + publish)
|
||||
|
||||
# Produces a release on this Gitea fork. Two modes (see .forker.yaml):
|
||||
# BUILD — checkout the tag's working tree, run the configured build command,
|
||||
# publish the release (tag + assets) on this Gitea.
|
||||
# MIRROR — mirror the upstream's existing release (metadata + assets).
|
||||
#
|
||||
# NOTE: this workflow is triggered MANUALLY from the UI (workflow_dispatch).
|
||||
# Automatic releases on new tags are handled INLINE by sync.sh, because a
|
||||
# mirrored tag points at an upstream commit whose tree has no .gitea/workflows,
|
||||
# so a "push: tags" trigger would never find this file. See sync.sh.
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to release'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run release
|
||||
run: |
|
||||
export GITEA_REPO="${GITEA_OWNER_REPO##*/}"
|
||||
bash forker/release.sh "$TAG"
|
||||
env:
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
GITEA_OWNER: ${{ gitea.repository_owner }}
|
||||
GITEA_OWNER_REPO: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
|
||||
UPSTREAM_TOKEN: ${{ secrets.UPSTREAM_TOKEN }}
|
||||
TAG: ${{ inputs.tag }}
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Repo Forker — Runner check
|
||||
|
||||
# Verifies a runner is available for this repo before relying on the cron sync
|
||||
# and local builds. Run it once after forking (or when a sync run is "pending"
|
||||
# for a long time — that usually means no runner is registered for this repo).
|
||||
#
|
||||
# In this Gitea build, runners are repo-scoped: a runner registered on one repo
|
||||
# does NOT serve another. Register a runner for this repo (see README, "Runner").
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Confirm a runner picked this job up
|
||||
run: |
|
||||
echo "A runner is online and serving this job."
|
||||
echo "OS=$RUNNER_OS Arch=$RUNNER_ARCH"
|
||||
|
||||
- name: Which runner(s) serve this repo
|
||||
env:
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
# The repo-level API does NOT list shared runners, so check the
|
||||
# shared (instance) list too and report which serves the repo.
|
||||
# (The Gitea Actions token has admin scope in this setup; with a
|
||||
# plain repo token the admin call 403s and we say so, not hide it.)
|
||||
curl -sS --max-time 20 -H "Authorization: Bearer $GITEA_TOKEN" \
|
||||
"$GITEA_SERVER_URL/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/actions/runners" > /tmp/repo_runners.json
|
||||
curl -sS --max-time 20 -H "Authorization: Bearer $GITEA_TOKEN" \
|
||||
"$GITEA_SERVER_URL/api/v1/admin/actions/runners?limit=50" > /tmp/shared_runners.json
|
||||
python3 -c 'import json; R=json.load(open("/tmp/repo_runners.json")).get("runners",[]); S=[r for r in json.load(open("/tmp/shared_runners.json")).get("runners",[]) if r.get("shared")]; print("Repo-scoped runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in R) or "(none)")); print("Shared runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in S) or "(none)")); print("OK: a runner serves this repo." if (R or S) else "WARNING: no runner (repo-scoped or shared) registered - cron runs will stay queued.")'
|
||||
@@ -0,0 +1,82 @@
|
||||
name: Repo Forker — Sync (mirror upstream)
|
||||
|
||||
# Periodically mirrors the upstream repo (all branches, tags, full history) into
|
||||
# this Gitea fork. This is the "worker" job.
|
||||
#
|
||||
# One-time setup (Gitea UI):
|
||||
# Settings -> Actions -> Variables & Secrets
|
||||
# UPSTREAM_URL = https://github.com/owner/repo.git (any provider)
|
||||
# UPSTREAM_TOKEN = <secret: token that can read the upstream>
|
||||
# GITEA_* values below are injected automatically by Gitea Actions.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# "very periodically" — every 10 minutes. Tune to taste (5-field cron).
|
||||
- cron: '*/10 * * * *'
|
||||
workflow_dispatch: {} # manual trigger from the UI
|
||||
push:
|
||||
branches: [forker] # re-sync when the forker config changes
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
# A cold full-history fetch can exceed the 10-min cron interval (or a
|
||||
# push/dispatch can land mid-run); without this, two overlapping runs
|
||||
# both see the same tag as "missing release" and both build/publish —
|
||||
# duplicate releases + double builds. Serialize per repo (do NOT
|
||||
# cancel-in-progress: an in-flight sync must finish).
|
||||
concurrency:
|
||||
group: sync-${{ gitea.repository }}
|
||||
steps:
|
||||
# A repo without UPSTREAM_URL (e.g. the template itself) is not a mirror:
|
||||
# skip the whole job with a notice instead of failing.
|
||||
- name: Upstream configured?
|
||||
id: check
|
||||
env:
|
||||
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
|
||||
run: |
|
||||
if [ -z "$UPSTREAM_URL" ]; then
|
||||
echo "::notice::UPSTREAM_URL is not set — this repo is not configured as a mirror (e.g. the template). No-op."
|
||||
echo "configured=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "configured=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Checkout
|
||||
if: steps.check.outputs.configured == 'true'
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Restore mirror cache
|
||||
if: steps.check.outputs.configured == 'true'
|
||||
uses: actions/cache@v4
|
||||
continue-on-error: true # no cache service configured? continue cold — still correct
|
||||
with:
|
||||
path: .mirror
|
||||
# Unique per run so saves never conflict; restore-keys pulls the most
|
||||
# recent saved mirror (incremental fetch). No cache → full fetch, still
|
||||
# correct.
|
||||
key: forker-mirror-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
forker-mirror-
|
||||
|
||||
- name: Show config
|
||||
if: steps.check.outputs.configured == 'true'
|
||||
run: |
|
||||
echo "UPSTREAM_URL=${UPSTREAM_URL:?set in Gitea UI (Variables & Secrets)}"
|
||||
echo "Gitea repo: ${{ gitea.repository }}"
|
||||
env:
|
||||
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
|
||||
|
||||
- name: Run sync
|
||||
if: steps.check.outputs.configured == 'true'
|
||||
run: |
|
||||
# gitea.repository is "owner/repo"; extract just the repo name.
|
||||
export GITEA_REPO="${GITEA_OWNER_REPO##*/}"
|
||||
bash forker/sync.sh
|
||||
env:
|
||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||
GITEA_OWNER: ${{ gitea.repository_owner }}
|
||||
GITEA_OWNER_REPO: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
|
||||
UPSTREAM_TOKEN: ${{ secrets.UPSTREAM_TOKEN }}
|
||||
@@ -1,45 +0,0 @@
|
||||
relinker:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'core/relinker/**'
|
||||
|
||||
shader:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'core/shader/**'
|
||||
|
||||
agc:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'core/libs/prx/libSceAgc*/**'
|
||||
|
||||
libc:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'core/libs/prx/libc/**'
|
||||
|
||||
libkernel:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'core/libs/prx/libkernel/**'
|
||||
|
||||
prx:
|
||||
- changed-files:
|
||||
- all-globs-to-any-file:
|
||||
- 'core/libs/prx/**'
|
||||
- '!core/libs/prx/libSceAgc*/**'
|
||||
- '!core/libs/prx/libc/**'
|
||||
- '!core/libs/prx/libkernel/**'
|
||||
|
||||
build:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- '**/CMakeLists.txt'
|
||||
- '**/*.cmake'
|
||||
- '.gitmodules'
|
||||
- '3rdparty/**'
|
||||
|
||||
docs:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- '**/*.md'
|
||||
- 'docs/**'
|
||||
|
||||
ci:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: '.github/**'
|
||||
@@ -1,16 +0,0 @@
|
||||
### What
|
||||
|
||||
### Tested
|
||||
<!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. -->
|
||||
|
||||
### Checklist
|
||||
<!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/docs/CONTRIBUTING.md -->
|
||||
- [ ] Based on current `main`; no other open PR implements the same functions
|
||||
- [ ] One topic per PR; follow-ups go in a new PR
|
||||
- [ ] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/CONVENTIONS.md)
|
||||
- [ ] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/TechnicalDebt.md#silent-stubs)
|
||||
- [ ] No notes, investigation `.md` files or images added to the repository (attach them to this PR)
|
||||
- [ ] New third-party code is a submodule built from source
|
||||
- [ ] Generic behaviour, not specific to one title
|
||||
- [ ] Depends on: <!-- #PR, or none -->
|
||||
- [ ] AI-assisted: <!-- yes / no -->
|
||||
@@ -1,29 +0,0 @@
|
||||
name: Area labels
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 * * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- id: prs
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
{
|
||||
echo 'numbers<<EOF'
|
||||
gh pr list -R "$GITHUB_REPOSITORY" --base "${{ github.event.repository.default_branch }}" -L 200 --json number --jq '.[].number'
|
||||
echo EOF
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
- if: steps.prs.outputs.numbers != ''
|
||||
uses: actions/labeler@v7
|
||||
with:
|
||||
pr-number: ${{ steps.prs.outputs.numbers }}
|
||||
@@ -1,72 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: build-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
CONFIGURE: >-
|
||||
-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
|
||||
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: true
|
||||
- uses: hendrikmuhs/ccache-action@v1.2.24
|
||||
with:
|
||||
key: linux
|
||||
save: ${{ github.event_name == 'push' }}
|
||||
evict-old-files: job
|
||||
- run: cmake -S . -B build $CONFIGURE
|
||||
- run: cmake --build build
|
||||
- run: ctest --test-dir build --output-on-failure --timeout 120
|
||||
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
|
||||
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: true
|
||||
- id: toolchain
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: C:\winlibs
|
||||
key: ${{ env.WINLIBS_ZIP }}
|
||||
- if: steps.toolchain.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
|
||||
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs > /dev/null
|
||||
- run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
|
||||
- uses: hendrikmuhs/ccache-action@v1.2.24
|
||||
with:
|
||||
key: windows
|
||||
save: ${{ github.event_name == 'push' }}
|
||||
evict-old-files: job
|
||||
- shell: cmd
|
||||
run: cmake -S . -B build %CONFIGURE%
|
||||
- shell: cmd
|
||||
run: cmake --build build
|
||||
- shell: cmd
|
||||
run: ctest --test-dir build --output-on-failure --timeout 120
|
||||
@@ -1,21 +0,0 @@
|
||||
name: Conflict label
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 * * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: eps1lon/actions-label-merge-conflict@v3
|
||||
with:
|
||||
dirtyLabel: needs rebase
|
||||
repoToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,42 +0,0 @@
|
||||
name: Progress comment
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Progress report]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: progress-report
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ github.token }}
|
||||
- env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
RUN_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
run: |
|
||||
pr=$(cat pr)
|
||||
[[ $pr =~ ^[0-9]+$ ]] || exit 1
|
||||
[ "$(gh pr view "$pr" --json headRefOid --jq .headRefOid)" = "$RUN_SHA" ] || exit 0
|
||||
marker='<!-- progress-report -->'
|
||||
id=$(gh api "repos/$GH_REPO/issues/$pr/comments" --paginate \
|
||||
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n1)
|
||||
if [ -f report.md ]; then
|
||||
printf '%s\n%s' "$marker" "$(cat report.md)" > body.md
|
||||
if [ -n "$id" ]; then
|
||||
gh api -X PATCH "repos/$GH_REPO/issues/comments/$id" -F body=@body.md > /dev/null
|
||||
else
|
||||
gh pr comment "$pr" --body-file body.md
|
||||
fi
|
||||
elif [ -n "$id" ]; then
|
||||
gh api -X DELETE "repos/$GH_REPO/issues/comments/$id"
|
||||
fi
|
||||
@@ -1,34 +0,0 @@
|
||||
name: Progress report
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
report:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- env:
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
out=$RUNNER_TEMP/out report=$RUNNER_TEMP/report
|
||||
git worktree add --detach "$RUNNER_TEMP/base" HEAD^1
|
||||
python3 tools/progress.py --root "$RUNNER_TEMP/base" "$out/base"
|
||||
python3 tools/progress.py "$out/head"
|
||||
mkdir "$report"
|
||||
echo "$PR" > "$report/pr"
|
||||
body=$(python3 tools/progress.py --compare "$out/base/progress.json" "$out/head/progress.json")
|
||||
if [ -n "$body" ]; then
|
||||
printf '### Progress report (%s → %s)\n\n%s\n' "$(git rev-parse --short HEAD^1)" "${HEAD_SHA::7}" "$body" > "$report/report.md"
|
||||
cat "$report/report.md" >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: progress-report
|
||||
path: ${{ runner.temp }}/report
|
||||
@@ -1,30 +0,0 @@
|
||||
name: Progress
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
progress:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- run: python3 tools/progress.py out
|
||||
- uses: actions/upload-pages-artifact@v5
|
||||
with:
|
||||
path: out
|
||||
- id: deployment
|
||||
uses: actions/deploy-pages@v5
|
||||
@@ -1,126 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
CONFIGURE: >-
|
||||
-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
|
||||
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
|
||||
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and test (${{ matrix.platform }})
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux
|
||||
runner: ubuntu-latest
|
||||
timeout: 30
|
||||
- platform: windows
|
||||
runner: windows-latest
|
||||
timeout: 45
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: ${{ matrix.timeout }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: true
|
||||
- id: toolchain
|
||||
if: matrix.platform == 'windows'
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: C:\winlibs
|
||||
key: ${{ env.WINLIBS_ZIP }}
|
||||
- if: matrix.platform == 'windows' && steps.toolchain.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
|
||||
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs
|
||||
- if: matrix.platform == 'windows'
|
||||
run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
|
||||
- uses: hendrikmuhs/ccache-action@v1.2.24
|
||||
with:
|
||||
key: ${{ matrix.platform }}
|
||||
save: false
|
||||
- name: Configure Linux
|
||||
if: matrix.platform == 'linux'
|
||||
run: cmake -S . -B build $CONFIGURE
|
||||
- name: Configure Windows
|
||||
if: matrix.platform == 'windows'
|
||||
shell: cmd
|
||||
run: cmake -S . -B build %CONFIGURE%
|
||||
- name: Build project and tests (Linux)
|
||||
if: matrix.platform == 'linux'
|
||||
run: cmake --build build
|
||||
- name: Build project and tests (Windows)
|
||||
if: matrix.platform == 'windows'
|
||||
shell: cmd
|
||||
run: cmake --build build
|
||||
- name: Run tests (Linux)
|
||||
if: matrix.platform == 'linux'
|
||||
run: ctest --test-dir build --output-on-failure --timeout 120 --stop-on-failure --no-tests=error
|
||||
- name: Run tests (Windows)
|
||||
if: matrix.platform == 'windows'
|
||||
shell: cmd
|
||||
run: ctest --test-dir build --output-on-failure --timeout 120 --stop-on-failure --no-tests=error
|
||||
- name: Build patched libraries (Linux)
|
||||
if: matrix.platform == 'linux'
|
||||
run: cmake --build build --target libs
|
||||
- name: Build patched libraries (Windows)
|
||||
if: matrix.platform == 'windows'
|
||||
shell: cmd
|
||||
run: cmake --build build --target libs
|
||||
- name: Package release files
|
||||
run: python tools/package_release.py --platform "${{ matrix.platform }}" --build build --output dist --version "$RELEASE_TAG"
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-${{ matrix.platform }}
|
||||
path: dist/*
|
||||
if-no-files-found: error
|
||||
compression-level: 0
|
||||
|
||||
publish:
|
||||
name: Publish release
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
path: dist
|
||||
- name: Check release files and collect documentation
|
||||
shell: bash
|
||||
run: |
|
||||
for file in "prx-windows-$RELEASE_TAG.zip" "prx-windows-$RELEASE_TAG.tar.gz" "prx-linux-$RELEASE_TAG.zip" "prx-linux-$RELEASE_TAG.tar.gz" "relinker-$RELEASE_TAG.exe" "relinker-$RELEASE_TAG"; do
|
||||
test -s "dist/$file"
|
||||
done
|
||||
python tools/package_release.py --docs docs/user --output dist
|
||||
chmod +x "dist/relinker-$RELEASE_TAG"
|
||||
- name: Create draft and upload files
|
||||
run: gh release create "$RELEASE_TAG" dist/* --verify-tag --draft --title "$RELEASE_TAG" --generate-notes
|
||||
- name: Publish complete release
|
||||
run: gh release edit "$RELEASE_TAG" --draft=false
|
||||
+18
-106
@@ -1,111 +1,23 @@
|
||||
*.d
|
||||
# The bare mirror holds upstream objects; never commit it.
|
||||
.mirror/
|
||||
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
*.ilk
|
||||
*.pdb
|
||||
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
_SaveData/
|
||||
_sd/
|
||||
|
||||
build/
|
||||
build_tools/
|
||||
b/
|
||||
Build/
|
||||
build-*/
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
||||
cmake-build-*/
|
||||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
Makefile
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
vcpkg_installed/
|
||||
Testing/
|
||||
tests/sdf/
|
||||
.cache/
|
||||
|
||||
sqlce_wasm.js
|
||||
sqlce_wasm.wasm
|
||||
emsdk/
|
||||
build-wasm/
|
||||
# Local runner config (contains tokens) — but KEEP runner/docker-compose.yml
|
||||
# tracked, otherwise a fresh fork has no documented runner setup at all.
|
||||
# (The runner/_svc_*.go files are untracked Gitea-source scratch snippets.)
|
||||
runner/config/
|
||||
runner/_svc_*.go
|
||||
*.runner.conf
|
||||
|
||||
# OS / editor noise
|
||||
.DS_Store
|
||||
*.swp
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
.venv/
|
||||
venv/
|
||||
env/
|
||||
ENV/
|
||||
|
||||
__pycache__/
|
||||
*.pyo
|
||||
*.pyd
|
||||
*.egg
|
||||
*.egg-info/
|
||||
dist/
|
||||
|
||||
*.dwo
|
||||
|
||||
.pytest_cache/
|
||||
coverage.xml
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
*.tmp
|
||||
*.log
|
||||
*.bak
|
||||
*.swp
|
||||
|
||||
raw/
|
||||
images/
|
||||
sessions/
|
||||
downloads/
|
||||
|
||||
*.tar.gz
|
||||
*.zip
|
||||
*.whl
|
||||
*.env
|
||||
*.sdf
|
||||
|
||||
*.bat
|
||||
*.jpg
|
||||
*.png
|
||||
|
||||
*.json
|
||||
!demo/web/i18n/*.json
|
||||
|
||||
!/assets/*.jpg
|
||||
!/assets/*.png
|
||||
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
cookies.txt
|
||||
|
||||
.env
|
||||
.env.local
|
||||
# stray binaries that are never part of this template
|
||||
*.AppImage
|
||||
*.appimage
|
||||
.superdesign/
|
||||
ui/node_modules/
|
||||
ui/dist/
|
||||
ui/*.log
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
[submodule "3rdparty/SDL2"]
|
||||
path = 3rdparty/SDL2
|
||||
url = https://github.com/libsdl-org/SDL.git
|
||||
[submodule "3rdparty/Vulkan-Headers"]
|
||||
path = 3rdparty/Vulkan-Headers
|
||||
url = https://github.com/KhronosGroup/Vulkan-Headers.git
|
||||
[submodule "3rdparty/SPIRV-Headers"]
|
||||
path = 3rdparty/SPIRV-Headers
|
||||
url = https://github.com/KhronosGroup/SPIRV-Headers.git
|
||||
[submodule "3rdparty/SPIRV-Tools"]
|
||||
path = 3rdparty/SPIRV-Tools
|
||||
url = https://github.com/KhronosGroup/SPIRV-Tools.git
|
||||
[submodule "3rdparty/glslang"]
|
||||
path = 3rdparty/glslang
|
||||
url = https://github.com/KhronosGroup/glslang.git
|
||||
[submodule "3rdparty/VulkanMemoryAllocator"]
|
||||
path = 3rdparty/VulkanMemoryAllocator
|
||||
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
||||
[submodule "3rdparty/LibAtrac9"]
|
||||
path = 3rdparty/LibAtrac9
|
||||
url = https://github.com/shadps4-emu/ext-LibAtrac9.git
|
||||
Vendored
-1
Submodule 3rdparty/LibAtrac9 deleted from ec8899dadf.
Vendored
-1
Submodule 3rdparty/SDL2 deleted from 4b69833bc5.
Vendored
-1
Submodule 3rdparty/SPIRV-Headers deleted from 01e0577914.
Vendored
-1
Submodule 3rdparty/SPIRV-Tools deleted from 7f2d9ee926.
Vendored
-1
Submodule 3rdparty/Vulkan-Headers deleted from 2fa203425e.
Vendored
-1
Submodule 3rdparty/VulkanMemoryAllocator deleted from a1d434708c.
Vendored
-1
Submodule 3rdparty/glslang deleted from ba1640446f.
@@ -0,0 +1,151 @@
|
||||
# AGENTS.md — how to operate Repo Forker
|
||||
|
||||
Instructions for AI agents (and humans) working on or with this repository.
|
||||
|
||||
## What this is
|
||||
|
||||
A **template**. Each fork/generation of it is a *live mirror* of one upstream
|
||||
git repo on this Gitea: all branches, all tags, full history, plus releases
|
||||
produced on the runner. The working tree (the `forker` branch) holds only the
|
||||
machinery — the upstream's content never enters it.
|
||||
|
||||
```
|
||||
This repo (template) → fork/generate per upstream (Lago/<upstream>)
|
||||
├── forker branch ← scripts, config, workflows
|
||||
├── .mirror/ ← bare mirror (gitignored)
|
||||
└── refs ← upstream branches + tags
|
||||
```
|
||||
|
||||
## Golden rules (non-negotiable)
|
||||
|
||||
1. **Never authenticate to upstreams with the operator's personal accounts or
|
||||
stored credentials.** Public upstreams are fetched **anonymously**:
|
||||
`sync.sh`/`release.sh` cut `GIT_CONFIG_GLOBAL`/`GIT_CONFIG_SYSTEM` and the
|
||||
credential helper before any upstream git call, and add a Bearer header
|
||||
**only** when `UPSTREAM_TOKEN` is explicitly set. Do not "simplify" this
|
||||
away — a `credential.helper=store` entry must never be offered to
|
||||
`git fetch`. Do not pass tokens from `~/.git-credentials` into the tool.
|
||||
2. **An empty token must mean "no auth header", not "Bearer <empty>".**
|
||||
GitHub rejects empty Bearer headers (401). All code paths (git
|
||||
`extraHeader`, `provider.sh` curl calls) must branch on token presence.
|
||||
3. **Secrets live in Gitea Actions Variables/Secrets, never in the repo.**
|
||||
`UPSTREAM_URL` (variable) and `UPSTREAM_TOKEN` (secret, optional). The
|
||||
`GITEA_*` values are injected by Gitea Actions automatically.
|
||||
4. **Keep `.forker.yaml` flat** (`key: value`, no nesting) — `config.sh` is a
|
||||
simple grep parser.
|
||||
|
||||
## How it runs
|
||||
|
||||
- **Cron** (`sync.yml`, every 10 min) → `forker/sync.sh`:
|
||||
1. fetch all branches + tags + history into the bare `.mirror/` (incremental
|
||||
when `actions/cache` restores it),
|
||||
2. push refs onto this repo + prune what upstream deleted (fork state is
|
||||
read via the Gitea **API**, not git state — works on cold mirrors),
|
||||
3. for each **tag that has no release yet**, run `forker/release.sh <tag>`
|
||||
inline (a tag-push can't trigger a workflow: the tag points at an upstream
|
||||
commit whose tree has no `.gitea/workflows`). The "missing release" check
|
||||
(not "new tag") makes a failed release retry on the next cron tick.
|
||||
`release.sh` publishes only when there is actual content (build assets or
|
||||
an existing upstream release) and fails loudly on a bad asset
|
||||
download/upload — a partial release never masquerades as success.
|
||||
4. `forker/check-unit.sh` — verifies the **Releases unit** is enabled
|
||||
(self-heals via the units API when the build exposes it; otherwise
|
||||
detects the 404 and prints the one-time UI fix).
|
||||
- `release.sh` = local build (if `build_cmd`/`build_script` set) + optional
|
||||
upstream-release mirror (metadata + assets via `forker/lib/provider.sh`).
|
||||
Idempotent: an existing release is skipped, not duplicated.
|
||||
- `runner-check.yml` — run once per repo to confirm a runner serves it.
|
||||
**Runners are repo-scoped on this Gitea build**: a runner registered on one
|
||||
repo does not serve another. Use a **shared** runner (or PATCH the runner
|
||||
to `"shared":true` — the units/runners APIs are missing here, so UI/DB).
|
||||
|
||||
## Known Gitea-build quirks (verified on git.lago.dev, Gitea 28.1.0)
|
||||
|
||||
- **Forks are created without the Releases unit**
|
||||
(`DefaultForkRepoUnits = [Code, PullRequests]`) → release assets 404 on the
|
||||
web download route (`context.RequireUnitReader`), the source tarball 404s
|
||||
too, while the API by-id works. Fix: enable the Releases unit
|
||||
(Settings → Repository, or DB `INSERT INTO repo_unit (repo_id, type) ... 4` —
|
||||
there is no units API on this build). `check-unit.sh` detects/fixes.
|
||||
**Prefer generating from this template over forking**: generated repos are
|
||||
not forks and get the full unit set (and Gitea only allows 1 fork of a
|
||||
repo per user).
|
||||
- **GitHub asset gotcha**: for a release addressed by *tag*, the asset
|
||||
`download_url` is **null** — the API `url` returns JSON metadata unless
|
||||
`Accept: application/octet-stream` is sent. `provider.sh` instead resolves
|
||||
to the **web download URL** (`github.com/.../releases/download/<tag>/<file>`),
|
||||
which is also unthrottled (the REST asset endpoint is 60 req/h
|
||||
unauthenticated — not enough to mirror ~200 assets).
|
||||
- Runner registration: the `gitea/act_runner` CLI (old and new) fails on this
|
||||
build ("instance address is empty"); runner creation via API is 405.
|
||||
Existing runners can be made shared via `PATCH /api/v1/admin/actions/runners/<id>`.
|
||||
- `actions/cache` timeouts on this build are handled with
|
||||
`continue-on-error: true` (cold fetch is still correct). The artifact cache
|
||||
service itself is NOT configured on this Gitea — every sync is a cold fetch
|
||||
(correct, slower; the cache steps are kept in case a backend is added).
|
||||
- **Per-job DNS flapping:** the ephemeral per-job container intermittently
|
||||
fails to resolve `git.lago.dev` on the fork push (the runner daemon's own
|
||||
network resolves fine). `sync.sh` therefore wraps every fork push in
|
||||
`push_once` — retry with backoff on transient network errors (resolve /
|
||||
connect / timeout), abort immediately on non-network failures.
|
||||
|
||||
## Editing the template vs. a mirror repo
|
||||
|
||||
- **Template** (this repo): edit on `forker` and `git push`. Mirror repos do
|
||||
**not** auto-track the template — sync them manually after a template
|
||||
change:
|
||||
- **Forked repos** (e.g. `Lago/photocraft`): the `forker` branch *is* a
|
||||
descendant of the template's, so a normal merge works:
|
||||
```
|
||||
git remote add template <template-url>
|
||||
git fetch template forker
|
||||
git checkout forker && git merge template/forker
|
||||
git push origin forker
|
||||
```
|
||||
- **Generated repos** (e.g. `Lago/pdfcraft`): the `forker` branch is an
|
||||
**unrelated snapshot** (no common ancestor — `git merge` fails with
|
||||
add/add conflicts). Reset it to the template and re-apply the single
|
||||
per-repo setting, then force-push:
|
||||
```
|
||||
git checkout forker
|
||||
git fetch template forker
|
||||
git reset --hard template/forker
|
||||
# re-apply this repo's .forker.yaml setting(s), e.g.:
|
||||
sed -i 's/^mirror_upstream_releases: false/mirror_upstream_releases: true/' .forker.yaml
|
||||
git commit -am "Adopt template; enable mirror_upstream_releases"
|
||||
git push --force origin forker
|
||||
```
|
||||
This is safe: `forker` holds only the machinery + config (the upstream
|
||||
content lives on the mirrored branches), so the snapshot's extra content
|
||||
is discarded by design.
|
||||
- **Per-repo config**: edit `.forker.yaml` in the UI on the `forker` branch.
|
||||
Pushing to `forker` triggers a re-sync.
|
||||
|
||||
## Local testing (without the runner)
|
||||
|
||||
```
|
||||
export UPSTREAM_URL=... UPSTREAM_TOKEN= # empty for public upstreams
|
||||
export GITEA_TOKEN=... GITEA_SERVER_URL=... GITEA_OWNER=... GITEA_REPO=...
|
||||
bash forker/sync.sh # full mirror (use a scratch repo!)
|
||||
bash forker/release.sh <tag>
|
||||
make check-unit
|
||||
```
|
||||
Test against a **scratch repo** you delete afterwards; never point the scripts
|
||||
at a real mirror while experimenting. `GITEA_TOKEN` from Actions is an API
|
||||
token (Bearer works for API + git); a *password* only works for basic auth —
|
||||
expect the Bearer API calls to fail when testing with a password.
|
||||
|
||||
## File map
|
||||
|
||||
- `forker/sync.sh` — mirror worker (fetch/push/prune + inline releases + unit check)
|
||||
- `forker/release.sh` — local build + upstream-release mirror, idempotent
|
||||
- `forker/check-unit.sh` — Releases unit detection/self-heal (exit 10 = missing)
|
||||
- `forker/lib/config.sh` — flat `.forker.yaml` parser
|
||||
- `forker/lib/provider.sh` — provider-agnostic releases API (github/gitea/codeberg)
|
||||
- `forker/runner-register.sh` — runner registration (see quirks above)
|
||||
- `.gitea/workflows/` — sync.yml (cron), release.yml (manual), runner-check.yml
|
||||
- `runner/docker-compose.yml` — gitea-act-runner in Docker (tracked; the local
|
||||
`runner/config/` token dir is gitignored)
|
||||
- `Makefile` — local targets (sync / release / mirror-releases / runner-check /
|
||||
runner-register / check-unit); `runner-check` queries the Gitea runner APIs
|
||||
- `docs/index.html` — architecture webpage (static)
|
||||
@@ -1,40 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(Relinker CXX)
|
||||
|
||||
option(BUILD_TESTING "Build and register relinker tests" OFF)
|
||||
if(BUILD_TESTING)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
option(ANYPS5_ENABLE_SPIRV_TOOLS "Enable SPIRV-Tools validation and optimization" OFF)
|
||||
option(APS5_ENABLE_TIMING_LOG "Enable frame timing logging" OFF)
|
||||
add_compile_definitions(APS5_ENABLE_TIMING_LOG=$<BOOL:${APS5_ENABLE_TIMING_LOG}>)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")
|
||||
|
||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
set(SDL_TEST OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_VIDEO ON CACHE BOOL "" FORCE)
|
||||
set(SDL_RENDER OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_X11 ON CACHE BOOL "" FORCE)
|
||||
set(SDL_WAYLAND OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_OPENGL OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_OPENGLES OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_VULKAN ON CACHE BOOL "" FORCE)
|
||||
set(SDL_JOYSTICK ON CACHE BOOL "" FORCE)
|
||||
set(SDL_HAPTIC OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_HIDAPI OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_SENSOR OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC_PIC ON CACHE BOOL "" FORCE)
|
||||
set(ANYPS5_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "")
|
||||
add_subdirectory(3rdparty/SDL2)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${ANYPS5_EXE_LINKER_FLAGS}")
|
||||
|
||||
add_subdirectory(core/shader/recompiler)
|
||||
add_subdirectory(core/libs)
|
||||
add_subdirectory(core/relinker)
|
||||
@@ -1,338 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
<https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Moe Ghoul>, 1 April 1989
|
||||
Moe Ghoul, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,43 @@
|
||||
# Repo Forker — convenience targets.
|
||||
# Most work happens in the Gitea Actions workflows; these targets are for local
|
||||
# use (dry-runs, runner setup) and for debugging on the runner.
|
||||
|
||||
CONFIG_FILE ?= .forker.yaml
|
||||
|
||||
.PHONY: help sync release mirror-releases runner-check runner-register check-unit
|
||||
|
||||
help:
|
||||
@echo "Repo Forker targets:"
|
||||
@echo " sync Run a manual sync (needs UPSTREAM_* + GITEA_* env)"
|
||||
@echo " release TAG=x Run a release for tag x"
|
||||
@echo " mirror-releases Mirror upstream releases for a tag (release.sh MIRROR)"
|
||||
@echo " runner-check Run the runner-check workflow logic locally"
|
||||
@echo " runner-register Register a shared gitea-act-runner (see README)"
|
||||
@echo " check-unit Verify the Releases unit is enabled (fork quirk)"
|
||||
|
||||
sync:
|
||||
bash forker/sync.sh
|
||||
|
||||
release:
|
||||
@test -n "$(TAG)" || (echo "make release TAG=<tag>"; exit 1)
|
||||
bash forker/release.sh "$(TAG)"
|
||||
|
||||
mirror-releases:
|
||||
@test -n "$(TAG)" || (echo "make mirror-releases TAG=<tag>"; exit 1)
|
||||
bash forker/release.sh "$(TAG)"
|
||||
|
||||
runner-check:
|
||||
@test -n "$(GITEA_SERVER_URL)" -a -n "$(GITEA_TOKEN)" -a -n "$(GITEA_OWNER)" -a -n "$(GITEA_REPO)" \
|
||||
|| { echo "needs GITEA_SERVER_URL/GITEA_TOKEN/GITEA_OWNER/GITEA_REPO (or run the workflow instead)"; exit 1; }
|
||||
@curl -sS --max-time 20 -H "Authorization: Bearer $(GITEA_TOKEN)" \
|
||||
"$(GITEA_SERVER_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO)/actions/runners" > /tmp/rc_repo.json
|
||||
@curl -sS --max-time 20 -H "Authorization: Bearer $(GITEA_TOKEN)" \
|
||||
"$(GITEA_SERVER_URL)/api/v1/admin/actions/runners?limit=50" > /tmp/rc_shared.json || true
|
||||
@python3 -c 'import json; R=json.load(open("/tmp/rc_repo.json")).get("runners",[]); S=[r for r in json.load(open("/tmp/rc_shared.json")).get("runners",[]) if r.get("shared")]; print("Repo-scoped runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in R) or "(none)")); print("Shared runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in S) or "(none)")); print("OK: a runner serves this repo." if (R or S) else "WARNING: no runner (repo-scoped or shared) registered - cron runs will stay queued.")'
|
||||
@rm -f /tmp/rc_repo.json /tmp/rc_shared.json
|
||||
|
||||
runner-register:
|
||||
bash forker/runner-register.sh
|
||||
|
||||
check-unit:
|
||||
bash forker/check-unit.sh
|
||||
@@ -1,47 +1,221 @@
|
||||
# About
|
||||
# Repo Forker
|
||||
|
||||
Tool for automatic executables porting to Linux and Windows.
|
||||
> 📖 **Documentación y arquitectura interactiva:** [docs/index.html](docs/index.html) — qué es, cómo funciona, cómo crear un fork paso a paso, runner, config y limitaciones.
|
||||
|
||||
Includes a [relinker](core/relinker) that converts executable to the target system's native format and implementations of [system prx libraries](core/libs/prx) suitable for dynamic linking. No emulation or separate runtime process.
|
||||
> 🖥️ **UI de gestión local (mirrors):** [ui/README.md](ui/README.md) — `cd ui && npm install && npm run build && node bin/repo-forker-ui.js` → http://127.0.0.1:8731. Crea/elimina/monitorea mirrors, paridad vs upstream, logs en vivo, cola del runner.
|
||||
|
||||
Turn **any** git repo (GitHub, Gitea, Codeberg, …) into a **live mirror on your
|
||||
Gitea** — all branches, all tags, full commit history — synced very
|
||||
periodically by a Gitea Actions runner (your "gitea worker"), with releases
|
||||
produced **locally on the runner** (and optionally mirrored from the upstream).
|
||||
|
||||
This repo is a **template**. You **fork** it once per upstream; the fork *is*
|
||||
the mirror. The upstream's content never touches the working tree: upstream
|
||||
objects live in a bare mirror (`.mirror/`, gitignored) and are pushed as refs
|
||||
so they show up in the Gitea UI.
|
||||
|
||||
## Status
|
||||
```
|
||||
Fork of this template (Lago/<upstream>)
|
||||
├── working tree (forker branch) ← the machinery: scripts, config, workflows
|
||||
├── .mirror/ ← bare mirror of the upstream (gitignored)
|
||||
└── refs: <upstream branches> + <tags> ← visible in the Gitea UI
|
||||
```
|
||||
|
||||
[](https://boykopovar.github.io/AnyPS5/) [](https://boykopovar.github.io/AnyPS5/)
|
||||
## How it works
|
||||
|
||||
[](https://boykopovar.github.io/AnyPS5/)
|
||||
1. **Sync (the worker).** A cron workflow runs every N minutes. `sync.sh` fetches
|
||||
all branches + tags + full history from the upstream into a true bare mirror
|
||||
(`.mirror/`), then pushes them onto this fork and **prunes** what the upstream
|
||||
deleted. The fork's current state is read via the Gitea API (not git state),
|
||||
so prune + change-detection work even when the workspace is wiped between
|
||||
runs. `actions/cache` restores `.mirror/` when possible → incremental fetches.
|
||||
2. **Release (local build).** When sync detects a **new tag**, it invokes
|
||||
`release.sh` inline: checkout the tag's tree, run your build command **on the
|
||||
runner**, publish the release (tag + assets) on this Gitea. (A tag-push can't
|
||||
trigger a workflow on its own — the tag points at an upstream commit whose
|
||||
tree has no `.gitea/workflows` — so sync does it.) Re-running is idempotent:
|
||||
an existing release is skipped, not duplicated.
|
||||
3. **Release (mirror, optional).** If enabled, the upstream's existing release
|
||||
(metadata + assets) is copied over via the provider API
|
||||
(GitHub / Gitea / Codeberg — auto-detected in `forker/lib/provider.sh`).
|
||||
|
||||
[List of verified games](docs/user/COMPATIBILITY.md)
|
||||
## Quick start (3 steps)
|
||||
|
||||
Dreaming Sarah (2D platformer) runs at a stable 60 fps on a GTX 1050 Ti / i5-7500 3.4GHz.
|
||||
### 1. Fork this template
|
||||
In the Gitea UI: **this repo → Fork** → name it after the upstream
|
||||
(e.g. `Lago/some-upstream`).
|
||||
|
||||
Unsupported or unexpected states strictly throw `std::runtime_error`. `what()` is printed to stderr and the process terminates.
|
||||
### 2. Point it at the upstream (the "remote")
|
||||
In the fork: **Settings → Actions → Variables & Secrets**
|
||||
- **Variable** `UPSTREAM_URL` = `https://github.com/owner/repo.git` (any provider)
|
||||
- **Secret** `UPSTREAM_TOKEN` = *(optional — only for private upstreams.)*
|
||||
Public upstreams are mirrored **anonymously** and the tool never
|
||||
authenticates against them: the global/system git config and the
|
||||
credential helper are cut for all upstream git calls, so a stored
|
||||
`~/.git-credentials` entry is never used. Only set a token when the
|
||||
upstream is private (or you need a higher API rate for mirrored
|
||||
releases).
|
||||
|
||||
The [shader recompiler](core/shader/recompiler/Recompiler.cpp) successfully produces SPIR-V (validated via [Spirv-Tools](3rdparty/SPIRV-Tools) when built with `ANYPS5_ENABLE_SPIRV_TOOLS`).
|
||||
Everything non-secret (which branches, how often, build command, artifacts) lives
|
||||
in **`.forker.yaml`** — edit it in the UI on the `forker` branch.
|
||||
|
||||
[Technical debt of the project](docs/dev/TechnicalDebt.md), [code style conventions](docs/dev/CONVENTIONS.md)
|
||||
> The `GITEA_*` values (server URL, owner, repo, token) are injected
|
||||
> automatically by Gitea Actions — you don't set them. (`GITEA_TOKEN` in the
|
||||
> workflow env block is Gitea's **built-in** Actions secret, not a
|
||||
> user-created secret — don't create one.)
|
||||
|
||||
## Build
|
||||
### 3. Make sure a runner serves this repo
|
||||
In this Gitea build, **runners are repo-scoped**: a runner registered on one
|
||||
repo does **not** serve another. So either:
|
||||
|
||||
The relinker uses only the C++20 standard library and should build with any conforming compiler.
|
||||
- **Shared runner (recommended, one-time):** register a single runner that serves
|
||||
**all** repos. See [Runner](#runner).
|
||||
- **Per-repo runner:** register a runner for this specific repo.
|
||||
|
||||
[libc.prx](core/libs/prx/libc) implementations contain compiler-specific code. Linux builds work with GCC; on Windows, MinGW-w64 GCC 15.2.0 (`winlibs-gcc15`, `x86_64-ucrt-posix-seh`) is currently required.
|
||||
Then trigger **Settings → Actions → "Repo Forker — Runner check"** and confirm it
|
||||
completes. If sync runs stay *pending* for a long time, no runner is serving
|
||||
this repo.
|
||||
|
||||
The project targets maximum compiler portability. Support for additional compilers will be addressed after the first successful game launch.
|
||||
That's it. The cron sync starts pulling the upstream in, and releases are
|
||||
produced locally when tags appear. Note: with the template defaults
|
||||
(`build_cmd` empty, `mirror_upstream_releases: false`) there is nothing to
|
||||
build, so new tags are mirrored as **refs only** — set a `build_cmd` /
|
||||
`build_script` (or `mirror_upstream_releases: true`) for releases to appear.
|
||||
|
||||
## Compatibility
|
||||
## Configuration (`.forker.yaml`)
|
||||
|
||||
See the [game compatibility list](docs/user/COMPATIBILITY.md) for tested games and known issues.
|
||||
| Key | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `token_user` | `oauth2` | *(unused — Bearer auth needs no username; retained for compatibility)* |
|
||||
| `mirror_tags` | `true` | Mirror all tags |
|
||||
| `mirror_prune` | `true` | Prune branches deleted upstream |
|
||||
| `mirror_branches` | `*` | `*` = all, or a comma list (`main,develop`) |
|
||||
| `on_new_tag` | `true` | Build+publish a release when a new tag is mirrored |
|
||||
| `mirror_upstream_releases` | `false` | Also copy the upstream's release (metadata + assets) |
|
||||
| `build_cmd` | — | Build command(s), `;`-separated, run in the tag's tree |
|
||||
| `build_script` | — | Path to a custom build script (overrides `build_cmd`) |
|
||||
| `artifacts` | — | Space-separated globs of files to attach to the release |
|
||||
|
||||
## Input mapping
|
||||
## Manual triggers
|
||||
|
||||
SDL-mapped game controllers are supported, including analog sticks and triggers. Keyboard and mouse controls can be configured with an `anyps5-input.ini` file. See [input mapping](docs/user/INPUT_MAPPING.md) for the supported devices and configuration format.
|
||||
- **Sync now:** Settings → Actions → *Repo Forker — Sync* → Run workflow.
|
||||
- **Release a tag:** Settings → Actions → *Repo Forker — Release* → Run workflow
|
||||
→ enter the tag.
|
||||
- **Check the runner:** Settings → Actions → *Repo Forker — Runner check*.
|
||||
|
||||
## Disclaimer
|
||||
Or from a machine that has the repo + env vars: `make sync`,
|
||||
`make release TAG=v1.2.3`.
|
||||
|
||||
This project is intended for interoperability, research, preservation, and compatibility purposes. It does not include, distribute, or require copyrighted software, firmware, cryptographic keys, or proprietary libraries. Users are responsible for ensuring that any binaries used with this project are obtained and used in accordance with applicable laws and their respective license terms.
|
||||
## Runner
|
||||
|
||||
## License
|
||||
The sync (cron) and the local release build both need a **Gitea Actions runner**
|
||||
serving the repo. In this build, runners are **repo-scoped**, so the clean path
|
||||
is a **shared runner** registered once:
|
||||
|
||||
This project is licensed under the GNU General Public License version 2 only.
|
||||
```bash
|
||||
# install gitea-act-runner (see the Gitea runner docs), then:
|
||||
GITEA_SERVER_URL=https://git.lago.dev \
|
||||
GITEA_TOKEN=<admin-token> \
|
||||
GITEA_OWNER=Lago GITEA_REPO=any \
|
||||
bash forker/runner-register.sh shared
|
||||
|
||||
# then start it (e.g. via docker, see runner/docker-compose.yml)
|
||||
gitea-act-runner run
|
||||
```
|
||||
|
||||
`forker/runner-register.sh` auto-generates a registration token via
|
||||
`POST /api/v1/admin/actions/runners/registration-token` (verified working on this
|
||||
instance) and registers either a **shared** runner or a **per-repo** one.
|
||||
|
||||
> The existing online runner on this instance (id 3, `496cfb9f4583`,
|
||||
> `ubuntu-latest/24.04/22.04`) is registered to `Lago/Tide` only — it will not
|
||||
> serve your forks. Register a shared runner (or one per repo) as above.
|
||||
|
||||
> **This Gitea build quirk (verified):** the `act_runner` CLI fails to
|
||||
> register ("instance address is empty") on both `gitea/act_runner:0.6.1`
|
||||
> and `0.2.13`, and the runner-creation API returns 405. The path that
|
||||
> **does** work: take an existing registered runner and PATCH it to shared:
|
||||
> ```bash
|
||||
> curl -X PATCH "$GITEA_SERVER_URL/api/v1/admin/actions/runners/<id>" \
|
||||
> -H "Authorization: Bearer $GITEA_TOKEN" \
|
||||
> -d '{"name":"gitea-runner-forker","labels":["ubuntu-latest"],"shared":true,"disabled":false}'
|
||||
> ```
|
||||
> then point a `gitea/act_runner:0.6.1` container at its config
|
||||
> (`runner/docker-compose.yml`).
|
||||
|
||||
## Repository layout
|
||||
|
||||
```
|
||||
repo-forker/
|
||||
├── .gitea/workflows/
|
||||
│ ├── sync.yml # cron: mirror upstream (the "worker"); restores .mirror cache
|
||||
│ ├── release.yml # MANUAL only (a tag push can't trigger it); see sync.sh
|
||||
│ └── runner-check.yml # verify a runner serves this repo
|
||||
├── forker/
|
||||
│ ├── sync.sh # true-mirror fetch + push + prune + inline new-tag release + unit check
|
||||
│ ├── release.sh # local build + publish release (± mirror upstream), idempotent
|
||||
│ ├── runner-register.sh # register a shared / per-repo runner
|
||||
│ ├── check-unit.sh # verify/fix the Releases unit (Gitea fork quirk)
|
||||
│ └── lib/
|
||||
│ ├── config.sh # load .forker.yaml
|
||||
│ └── provider.sh # detect provider + releases API (Gitea/GitHub/Codeberg)
|
||||
├── .mirror/ # bare mirror (gitignored, cached by the workflow)
|
||||
├── .forker.yaml # per-fork config (non-secret)
|
||||
├── Makefile
|
||||
├── runner/docker-compose.yml
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## Notes & limitations
|
||||
|
||||
- **Releases are not git objects.** Git only carries the *tag*; release *assets*
|
||||
live on the Gitea. "Local release" = build on the runner + upload via the
|
||||
Gitea API. Mirroring upstream assets works anonymously for public upstreams
|
||||
(a token is only needed for private ones).
|
||||
- **Ephemeral workspace.** The Gitea runner wipes the workspace between runs.
|
||||
`sync.sh` is written to not depend on leftover git state: it re-reads the fork's
|
||||
current refs via the API every run. `actions/cache` on `.mirror/` makes the
|
||||
fetch incremental when it hits; a cold cache just means a full-history fetch
|
||||
(correct, slower).
|
||||
- **Tags point at upstream commits.** That's intentional — it keeps commit
|
||||
hashes identical to the upstream. It also means the workflow can't be
|
||||
triggered *by the tag* (the tag's tree has no workflows), so sync triggers
|
||||
releases inline.
|
||||
- **Provider differences** (releases API, token username) are isolated in
|
||||
`forker/lib/provider.sh`; the rest is provider-agnostic.
|
||||
- **Secrets stay out of the repo.** Upstream URL/token are Gitea Actions
|
||||
Variables/Secrets; the Gitea token is the built-in `GITEA_TOKEN`.
|
||||
- **Runner is the hard dependency.** Without a runner serving the repo, the cron
|
||||
sync and local builds won't run — run the *Runner check* first.
|
||||
- **Gitea forks ship without the Releases unit → asset downloads 404.**
|
||||
Root cause found on this instance (verified in the Gitea source + DB): a fork
|
||||
is created with `DefaultForkRepoUnits = [Code, PullRequests]` — **no
|
||||
Releases unit** — while normal repos get it. So release *assets* uploaded to
|
||||
a fork repo are listed in the API (by-id works) but the web
|
||||
`browser_download_url` returns 404 at the unit-permission check, and the
|
||||
release *source tarball* 404s too.
|
||||
**Detected + fixed:** `sync.sh` runs `check-unit.sh` at the end of every
|
||||
sync — it self-heals via the units API on builds that expose it, and on
|
||||
this build (no units API) it detects the 404 (confirming the API by-id
|
||||
path still works) and prints the exact one-time fix: UI → Settings →
|
||||
Repository → enable the **Releases** unit. `make check-unit` runs it
|
||||
standalone.
|
||||
|
||||
## Security notes
|
||||
|
||||
- **Upstreams are fetched anonymously by default.** `sync.sh` / `release.sh`
|
||||
cut `GIT_CONFIG_GLOBAL`/`GIT_CONFIG_SYSTEM` and the credential helper before
|
||||
any upstream git call, and add a Bearer header **only** when `UPSTREAM_TOKEN`
|
||||
is set. A stored `~/.git-credentials` entry is therefore *never* offered to
|
||||
`git fetch` — a public upstream is a pure anonymous fetch.
|
||||
- **`build_cmd` / `build_script` run with the tokens in the environment.**
|
||||
`release.sh` keeps `GITEA_TOKEN` and `UPSTREAM_TOKEN` set so it can fetch the
|
||||
tag's tree and publish assets. Any repo member can edit `.forker.yaml`, so a
|
||||
malicious `build_cmd` could exfiltrate both tokens. Treat `build_cmd` /
|
||||
`build_script` as **trusted code with credential access** — only put commands
|
||||
you (or the repo owners) trust there.
|
||||
- **Tokens briefly persist in the cached `.mirror/` git config.** The per-URL
|
||||
`http.<url>.extraHeader` Bearer header is written into `.mirror/config`, and
|
||||
`.mirror/` is the `actions/cache` path. The cache is repo-scoped (not
|
||||
committed), but a cache-service reader can read it until the next save
|
||||
overwrites it. The tokens are never written into the repo itself.
|
||||
@@ -0,0 +1,102 @@
|
||||
# TODO — a futuro
|
||||
|
||||
## [UI] Gestión local de mirrors (npx)
|
||||
|
||||
Una web local (arrancable con `npx`) para gestionar todo el ecosistema de
|
||||
Repo Forker desde un solo lugar, sin tocar API/curl/DB.
|
||||
|
||||
### Idea
|
||||
```
|
||||
npx repo-forker-ui # -> http://localhost:8731 (o el puerto libre)
|
||||
```
|
||||
El UI habla con la API de Gitea (con un token que el usuario pega una vez,
|
||||
guardado localmente — nunca en el repo) y ejecuta las mismas operaciones que
|
||||
los scripts, pero de forma guiada.
|
||||
|
||||
### Features (por prioridad)
|
||||
|
||||
**P0 — Gestión de mirrors (el corazón):**
|
||||
- **Crear un mirror**: pega la URL del upstream (GitHub/Gitea/Codeberg/otro)
|
||||
+ nombre → el UI hace lo que se hace hoy por API/curl:
|
||||
1. `POST /repos/{owner}/repo-forker/generate` con `git_content: true`
|
||||
2. crea la variable `UPSTREAM_URL` (`POST .../actions/variables/UPSTREAM_URL`)
|
||||
3. `PATCH` default branch → la del upstream (o `main`)
|
||||
4. activa `mirror_upstream_releases` en la rama `forker` (reset + re-apply,
|
||||
el procedimiento de AGENTS.md para repos generados)
|
||||
5. dispara el primer `sync.yml` (dispatch) y muestra el progreso
|
||||
- **Lista de mirrors**: todos los repos generados desde `repo-forker`
|
||||
(detectables por la rama `forker` + la variable `UPSTREAM_URL`), con:
|
||||
- estado del último `sync.yml` (green/red, timestamp, duración)
|
||||
- branches / tags / releases / assets (vs upstream — paridad)
|
||||
- unidades activas (Code/Issues/PR/Releases/...)
|
||||
- **Stats y gráficas** (por mirror y agregado):
|
||||
- timeline de runs (success/failure/queued) — sparkline de los últimos 7 días
|
||||
- tiempo de sync por run (cold vs incremental — la caché, cuando exista)
|
||||
- assets por release (barras), crecimiento de branches/tags
|
||||
- latencia de mirror: commits upstream sin replicar todavía
|
||||
- **Eliminar un mirror**: delete del repo (con confirmación + advertencia de
|
||||
lo que se pierde; el template queda intacto)
|
||||
- **Re-sincronizar / forzar**: dispatch manual de `sync.yml` / `release.yml` /
|
||||
`runner-check.yml` desde la UI
|
||||
- **Config per-repo**: editar `.forker.yaml` (los campos conocidos:
|
||||
`mirror_branches`, `mirror_tags`, `mirror_prune`, `mirror_upstream_releases`,
|
||||
`build_cmd`, `build_script`, `artifacts`, `on_new_tag`) con validación de
|
||||
esquema plano (el parser es grep — el UI debe mantenerlo plano)
|
||||
- **Variables & secrets**: listar/crear/borrar las Variables de Actions
|
||||
(`UPSTREAM_URL`, `UPSTREAM_TOKEN` opcional) — los secrets solo se crean,
|
||||
no se leen (la API no los devuelve)
|
||||
|
||||
**P1 — Observabilidad:**
|
||||
- **Cola del runner**: runs `queued`/`in_progress` en vivo (polling), con
|
||||
tiempo de espera — el runner es serial (maxParallel=1), así que una vista
|
||||
de "fila" es muy útil
|
||||
- **Logs en vivo** de un run (stream del log del job, con el
|
||||
`::group::`/`::notice::` de Gitea Actions renderizado)
|
||||
- **Diagnóstico de un run fallido**: extraer la línea de error del log y
|
||||
sugerir la causa (DNS flap, cache timeout, token, unidad Releases)
|
||||
- **Unidades**: ver/quitar/habilitar la unidad Releases (con fallback a DB
|
||||
cuando la API no existe — este build)
|
||||
- **Alerta** de mirror "desactualizado" (última sync > N min con runner idle)
|
||||
|
||||
**P2 — Extras:**
|
||||
- **Generar desde otros templates**: que el UI permita usar cualquier repo
|
||||
marcado `template: true` (no solo repo-forker)
|
||||
- **Import de config**: pegar un `.forker.yaml` y aplicarlo
|
||||
- **Export del estado**: snapshot JSON de todos los mirrors (para backups /
|
||||
re-crear después de una catástrofe)
|
||||
- **Comparador de paridad**: side-by-side upstream vs fork (branches/tags/
|
||||
releases) con diff visual (lo que falta se marca)
|
||||
|
||||
### Notas de diseño
|
||||
|
||||
- **Stack sugerido**: Vite + React (o SvelteKit) + Tailwind; el backend
|
||||
"npx" puede ser un thin server Node que solo hace proxy + auth al Gitea
|
||||
(el UI puede ser 100% client-side si el token se guarda en `localStorage`;
|
||||
el proxy solo evita CORS y esconde el token de los logs del navegador).
|
||||
- **Auth**: el usuario pega su token Gitea (o basic) una vez; se guarda en
|
||||
`~/.repo-forker/credentials` (chmod 600) o `localStorage` según el modo.
|
||||
NUNCA se sube al repo.
|
||||
- **Idempotencia**: todas las acciones de creación deben ser idempotentes
|
||||
(re-crear el mirror con el mismo nombre → "ya existe" + enlazar).
|
||||
- **No duplicar lógica**: las operaciones (generate, variable, default branch,
|
||||
forker reset+re-apply, dispatch) ya están probadas en esta sesión — el UI
|
||||
las reproduce tal cual, no inventa variantes.
|
||||
- **Modo offline**: la UI debe funcionar aunque el Gitea esté caído (los
|
||||
últimos datos cacheados + estado "offline").
|
||||
|
||||
### Criterio de "hecho" (P0)
|
||||
|
||||
1. `npx repo-forker-ui` arranca y se conecta a un Gitea (URL + token).
|
||||
2. Desde la UI: crear un mirror de un repo GitHub público → aparece en la
|
||||
lista con su primer sync en verde y paridad correcta.
|
||||
3. Eliminar un mirror desde la UI (con confirmación).
|
||||
4. Ver en la UI: últimos 20 runs de cada mirror, paridad de
|
||||
branches/tags/releases, y el log del último run.
|
||||
5. Re-sincronizar (dispatch) desde la UI.
|
||||
|
||||
### Estado: **A FUTURO — no empezar sin revisar esta spec**
|
||||
|
||||
La infraestructura ya soporta todo lo que el UI necesita (APIs de generate,
|
||||
variables, dispatch, runners, releases; scripts de sync con retry; `check-unit`;
|
||||
cron de limpieza en tizona). Faltan decisiones: stack, nombre del paquete,
|
||||
y si el modo "solo client-side con token en localStorage" es suficiente.
|
||||
@@ -1,496 +0,0 @@
|
||||
if(NOT WIN32)
|
||||
string(REPLACE "-static " "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ")
|
||||
string(STRIP "${CMAKE_EXE_LINKER_FLAGS}" CMAKE_EXE_LINKER_FLAGS)
|
||||
endif()
|
||||
|
||||
add_executable(nid_patcher
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/Sha1.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/NidCompute.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/NidResolver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/ExportExclusions.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/ElfNidPatcher.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/PeNidPatcher.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/BinaryPatcherFactory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/main.cpp
|
||||
)
|
||||
target_include_directories(nid_patcher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/nid/include)
|
||||
target_compile_features(nid_patcher PRIVATE cxx_std_20)
|
||||
|
||||
if(MINGW)
|
||||
target_link_options(nid_patcher PRIVATE -static -static-libgcc -static-libstdc++)
|
||||
add_compile_options(-fno-asynchronous-unwind-tables)
|
||||
endif()
|
||||
|
||||
function(configure_windows_unwind target)
|
||||
if(MINGW)
|
||||
if(NOT EXISTS "${CMAKE_OBJCOPY}")
|
||||
message(FATAL_ERROR "Windows DWARF unwinding requires objcopy")
|
||||
endif()
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram "$<TARGET_FILE:${target}>"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(LIBC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/prx/libc)
|
||||
add_library(libc SHARED EXCLUDE_FROM_ALL)
|
||||
set(LIBS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_subdirectory(${LIBC_DIR} ${CMAKE_CURRENT_BINARY_DIR}/prx/libc)
|
||||
target_include_directories(libc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
configure_windows_unwind(libc)
|
||||
|
||||
set(UNPATCHED_DIR ${CMAKE_CURRENT_BINARY_DIR}/libs/unpatched)
|
||||
set(PATCHED_DIR ${CMAKE_CURRENT_BINARY_DIR}/libs)
|
||||
|
||||
set_target_properties(libc PROPERTIES
|
||||
PREFIX ""
|
||||
SUFFIX .prx
|
||||
RUNTIME_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
|
||||
)
|
||||
|
||||
set(LIBC_UNPATCHED ${UNPATCHED_DIR}/libc.prx)
|
||||
set(LIBC_PATCHED ${PATCHED_DIR}/libc.prx)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${LIBC_PATCHED}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBC_UNPATCHED} ${LIBC_PATCHED}
|
||||
COMMAND $<TARGET_FILE:nid_patcher> libc ${LIBC_PATCHED}
|
||||
DEPENDS nid_patcher libc ${LIBC_UNPATCHED}
|
||||
COMMENT "Patching NIDs for libc"
|
||||
)
|
||||
|
||||
file(GLOB LIBS_DIRS LIST_DIRECTORIES true ${CMAKE_CURRENT_SOURCE_DIR}/prx/*)
|
||||
list(REMOVE_ITEM LIBS_DIRS ${LIBC_DIR})
|
||||
|
||||
set(PATCHED_OUTPUTS ${LIBC_PATCHED})
|
||||
|
||||
foreach(LIB_DIR ${LIBS_DIRS})
|
||||
if(IS_DIRECTORY ${LIB_DIR})
|
||||
get_filename_component(LIB_NAME ${LIB_DIR} NAME)
|
||||
|
||||
if(EXISTS ${LIB_DIR}/CMakeLists.txt)
|
||||
set(LIBS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_subdirectory(${LIB_DIR} ${CMAKE_CURRENT_BINARY_DIR}/prx/${LIB_NAME})
|
||||
else()
|
||||
add_library(${LIB_NAME} SHARED EXCLUDE_FROM_ALL ${LIB_DIR}/Export.cpp)
|
||||
target_include_directories(${LIB_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
configure_windows_unwind(${LIB_NAME})
|
||||
endif()
|
||||
|
||||
if(LIB_NAME STREQUAL "libkernel")
|
||||
target_link_libraries(${LIB_NAME} PRIVATE libc)
|
||||
else()
|
||||
target_link_libraries(${LIB_NAME} PRIVATE libkernel libc)
|
||||
endif()
|
||||
|
||||
set_target_properties(${LIB_NAME} PROPERTIES
|
||||
PREFIX ""
|
||||
SUFFIX .prx
|
||||
RUNTIME_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
|
||||
)
|
||||
|
||||
set(UNPATCHED_FILE ${UNPATCHED_DIR}/${LIB_NAME}.prx)
|
||||
set(PATCHED_FILE ${PATCHED_DIR}/${LIB_NAME}.prx)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PATCHED_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${UNPATCHED_FILE} ${PATCHED_FILE}
|
||||
COMMAND $<TARGET_FILE:nid_patcher> ${LIB_NAME} --preserve-exports "${LIBC_UNPATCHED}" "${PATCHED_FILE}"
|
||||
DEPENDS nid_patcher ${LIB_NAME} ${UNPATCHED_FILE} ${LIBC_UNPATCHED}
|
||||
COMMENT "Patching NIDs for ${LIB_NAME}"
|
||||
)
|
||||
|
||||
list(APPEND PATCHED_OUTPUTS ${PATCHED_FILE})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(LIBCOHTML_PATCHED ${PATCHED_DIR}/libcohtml.prx)
|
||||
set(LIBCOHTML_PROSPERO_PATCHED ${PATCHED_DIR}/libcohtml.Prospero.prx)
|
||||
add_custom_command(
|
||||
OUTPUT ${LIBCOHTML_PROSPERO_PATCHED}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${LIBCOHTML_PATCHED}" "${LIBCOHTML_PROSPERO_PATCHED}"
|
||||
DEPENDS ${LIBCOHTML_PATCHED}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(libcohtml_prospero DEPENDS ${LIBCOHTML_PROSPERO_PATCHED})
|
||||
list(APPEND PATCHED_OUTPUTS ${LIBCOHTML_PROSPERO_PATCHED})
|
||||
|
||||
add_custom_target(libs DEPENDS ${PATCHED_OUTPUTS})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_library(host_thread_local_test_library SHARED tests/HostThreadLocalLibrary.cpp)
|
||||
target_include_directories(host_thread_local_test_library PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(host_thread_local_tests tests/HostThreadLocal.cpp)
|
||||
target_link_libraries(host_thread_local_tests PRIVATE host_thread_local_test_library)
|
||||
if(MINGW)
|
||||
target_compile_options(host_thread_local_test_library PRIVATE -fasynchronous-unwind-tables)
|
||||
target_compile_options(host_thread_local_tests PRIVATE -fasynchronous-unwind-tables)
|
||||
endif()
|
||||
add_test(NAME host_thread_local COMMAND host_thread_local_tests)
|
||||
set_tests_properties(host_thread_local PROPERTIES TIMEOUT 15)
|
||||
add_executable(texture_format_lookup_tests tests/TextureFormatLookup.cpp)
|
||||
target_include_directories(texture_format_lookup_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/3rdparty/Vulkan-Headers/include)
|
||||
target_link_libraries(texture_format_lookup_tests PRIVATE libSceAgcDriver libc)
|
||||
configure_windows_unwind(texture_format_lookup_tests)
|
||||
add_test(NAME texture_format_lookup COMMAND texture_format_lookup_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(texture_format_lookup PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(linear_display_buffer_tests tests/LinearDisplayBuffer.cpp)
|
||||
target_include_directories(linear_display_buffer_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(linear_display_buffer_tests PRIVATE libSceAgcDriver libc)
|
||||
configure_windows_unwind(linear_display_buffer_tests)
|
||||
add_test(NAME linear_display_buffer COMMAND linear_display_buffer_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(linear_display_buffer PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_rendering_wait_tests tests/GuestRenderingWait.cpp)
|
||||
target_include_directories(guest_rendering_wait_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_rendering_wait_tests PRIVATE libSceAgcDriver libc)
|
||||
configure_windows_unwind(guest_rendering_wait_tests)
|
||||
add_test(NAME guest_rendering_wait COMMAND guest_rendering_wait_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_rendering_wait PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_buffer_reuse_tests tests/GuestBufferReuse.cpp)
|
||||
target_include_directories(guest_buffer_reuse_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_buffer_reuse_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_buffer_reuse_tests)
|
||||
add_test(NAME guest_buffer_reuse COMMAND guest_buffer_reuse_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_buffer_reuse PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_indexed_draw_tests tests/GuestIndexedDraw.cpp)
|
||||
add_executable(shader_buffer_address_tests tests/ShaderBufferAddress.cpp)
|
||||
target_link_libraries(shader_buffer_address_tests PRIVATE shader_recompiler_agc_driver libc)
|
||||
configure_windows_unwind(shader_buffer_address_tests)
|
||||
add_test(NAME shader_buffer_address COMMAND shader_buffer_address_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(shader_buffer_address PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
target_include_directories(guest_indexed_draw_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_indexed_draw_tests PRIVATE libSceAgc libSceAgcDriver libc)
|
||||
configure_windows_unwind(guest_indexed_draw_tests)
|
||||
add_test(NAME guest_indexed_draw COMMAND guest_indexed_draw_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_indexed_draw PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_shader_link_tests tests/GuestShaderLink.cpp)
|
||||
target_include_directories(guest_shader_link_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_shader_link_tests PRIVATE libSceAgc libc)
|
||||
configure_windows_unwind(guest_shader_link_tests)
|
||||
add_test(NAME guest_shader_link COMMAND guest_shader_link_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_shader_link PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_system_exit_tests tests/GuestSystemExit.cpp)
|
||||
target_include_directories(guest_system_exit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_system_exit_tests PRIVATE libSceSystemService libc)
|
||||
configure_windows_unwind(guest_system_exit_tests)
|
||||
add_test(NAME guest_system_exit_parameters COMMAND guest_system_exit_tests)
|
||||
add_test(NAME guest_system_exit COMMAND guest_system_exit_tests --exit)
|
||||
add_test(NAME guest_immediate_exit COMMAND guest_system_exit_tests --immediate)
|
||||
set_tests_properties(guest_system_exit PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "Guest shutdown and atexit completed")
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_system_exit guest_system_exit_parameters guest_immediate_exit PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_character_tests tests/GuestCharacter.cpp)
|
||||
target_include_directories(guest_character_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_character_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_character_tests)
|
||||
add_test(NAME guest_character COMMAND guest_character_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_character PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_math_tests tests/GuestMath.cpp)
|
||||
target_include_directories(guest_math_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_math_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_math_tests)
|
||||
add_test(NAME guest_math COMMAND guest_math_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_math PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_working_directory_tests tests/GuestWorkingDirectory.cpp)
|
||||
target_include_directories(guest_working_directory_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_working_directory_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_working_directory_tests)
|
||||
add_test(NAME guest_working_directory COMMAND guest_working_directory_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_working_directory PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_library(guest_module_fixture SHARED tests/GuestModuleFixture.cpp)
|
||||
target_include_directories(guest_module_fixture PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_custom_command(TARGET guest_module_fixture POST_BUILD
|
||||
COMMAND $<TARGET_FILE:nid_patcher> guest_module_fixture $<TARGET_FILE:guest_module_fixture>
|
||||
VERBATIM)
|
||||
add_dependencies(guest_module_fixture nid_patcher)
|
||||
add_executable(guest_dynamic_loader_tests tests/GuestDynamicLoader.cpp)
|
||||
target_include_directories(guest_dynamic_loader_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_dynamic_loader_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_dynamic_loader_tests)
|
||||
add_dependencies(guest_dynamic_loader_tests guest_module_fixture)
|
||||
add_test(NAME guest_dynamic_loader COMMAND guest_dynamic_loader_tests $<TARGET_FILE_NAME:guest_module_fixture>)
|
||||
set_tests_properties(guest_dynamic_loader PROPERTIES
|
||||
WORKING_DIRECTORY "$<TARGET_FILE_DIR:guest_module_fixture>")
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_dynamic_loader PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_filesystem_tests tests/GuestFilesystem.cpp)
|
||||
target_include_directories(guest_filesystem_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_filesystem_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_filesystem_tests)
|
||||
add_test(NAME guest_filesystem COMMAND guest_filesystem_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_filesystem PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_directory_tests tests/GuestDirectory.cpp)
|
||||
target_include_directories(guest_directory_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_directory_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_directory_tests)
|
||||
add_test(NAME guest_directory COMMAND guest_directory_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_directory PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_environment_tests tests/GuestEnvironment.cpp)
|
||||
target_include_directories(guest_environment_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_environment_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_environment_tests)
|
||||
add_test(NAME guest_environment COMMAND guest_environment_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_environment PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_standard_stream_tests tests/GuestStandardStreams.cpp)
|
||||
target_include_directories(guest_standard_stream_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_standard_stream_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_standard_stream_tests)
|
||||
add_test(NAME guest_standard_streams COMMAND guest_standard_stream_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_standard_streams PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_once_tests tests/GuestOnce.cpp)
|
||||
target_include_directories(guest_once_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_once_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_once_tests)
|
||||
add_test(NAME guest_once COMMAND guest_once_tests)
|
||||
set_tests_properties(guest_once PROPERTIES TIMEOUT 20)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_once PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_thread_self_tests tests/GuestThreadSelf.cpp)
|
||||
target_include_directories(guest_thread_self_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_thread_self_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_thread_self_tests)
|
||||
add_test(NAME guest_thread_self COMMAND guest_thread_self_tests)
|
||||
set_tests_properties(guest_thread_self PROPERTIES TIMEOUT 20)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_thread_self PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_cond_timedwait_tests tests/GuestCondTimedwait.cpp)
|
||||
target_include_directories(guest_cond_timedwait_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_cond_timedwait_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_cond_timedwait_tests)
|
||||
add_test(NAME guest_cond_timedwait COMMAND guest_cond_timedwait_tests)
|
||||
set_tests_properties(guest_cond_timedwait PROPERTIES TIMEOUT 20)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_cond_timedwait PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_signal_tests tests/GuestSignals.cpp)
|
||||
target_include_directories(guest_signal_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_signal_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_signal_tests)
|
||||
add_test(NAME guest_signals COMMAND guest_signal_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_signals PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_kernel_error_tests tests/GuestKernelErrors.cpp)
|
||||
target_include_directories(guest_kernel_error_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_kernel_error_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_kernel_error_tests)
|
||||
add_test(NAME guest_kernel_errors COMMAND guest_kernel_error_tests)
|
||||
set_tests_properties(guest_kernel_errors PROPERTIES TIMEOUT 20)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_kernel_errors PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_system_configuration_tests tests/GuestSystemConfiguration.cpp)
|
||||
target_include_directories(guest_system_configuration_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_system_configuration_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_system_configuration_tests)
|
||||
add_test(NAME guest_system_configuration COMMAND guest_system_configuration_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_system_configuration PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_udp_tests tests/GuestUdp.cpp)
|
||||
target_include_directories(guest_udp_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_udp_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_udp_tests)
|
||||
add_test(NAME guest_udp COMMAND guest_udp_tests)
|
||||
set_tests_properties(guest_udp PROPERTIES TIMEOUT 20)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_udp PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_address_tests tests/GuestAddressConversion.cpp)
|
||||
target_include_directories(guest_address_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_address_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_address_tests)
|
||||
add_test(NAME guest_addresses COMMAND guest_address_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_addresses PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
add_executable(guest_error_tests tests/GuestErrors.cpp)
|
||||
target_include_directories(guest_error_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_error_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_error_tests)
|
||||
add_test(NAME guest_errors COMMAND guest_error_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_errors PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_random_tests tests/GuestRandom.cpp)
|
||||
target_include_directories(guest_random_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_random_tests PRIVATE libSceRandom)
|
||||
add_test(NAME guest_random COMMAND guest_random_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_random PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRandom>")
|
||||
endif()
|
||||
add_executable(guest_resolver_tests tests/GuestResolver.cpp)
|
||||
target_include_directories(guest_resolver_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_resolver_tests PRIVATE libScePosixForWebKit)
|
||||
add_test(NAME guest_resolver COMMAND guest_resolver_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_resolver PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libScePosixForWebKit>")
|
||||
endif()
|
||||
add_executable(guest_rtc_tests tests/GuestRtc.cpp)
|
||||
target_include_directories(guest_rtc_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_rtc_tests PRIVATE libSceRtc)
|
||||
add_test(NAME guest_rtc COMMAND guest_rtc_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_rtc PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRtc>")
|
||||
endif()
|
||||
add_executable(guest_json_tests tests/GuestJson.cpp)
|
||||
target_include_directories(guest_json_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_json_tests PRIVATE libSceJson2 libc)
|
||||
add_test(NAME guest_json COMMAND guest_json_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_json PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceJson2>")
|
||||
endif()
|
||||
add_executable(fiber_tests tests/Fiber.cpp)
|
||||
target_include_directories(fiber_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(fiber_tests PRIVATE libSceFiber libc)
|
||||
add_test(NAME fiber COMMAND fiber_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(fiber PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFiber>")
|
||||
endif()
|
||||
add_executable(mspace_tests tests/Mspace.cpp)
|
||||
target_include_directories(mspace_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(mspace_tests PRIVATE libc)
|
||||
configure_windows_unwind(mspace_tests)
|
||||
add_test(NAME mspace COMMAND mspace_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(mspace PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_memory_tests tests/GuestMemory.cpp)
|
||||
target_include_directories(guest_memory_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_memory_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(guest_memory_tests)
|
||||
add_test(NAME guest_memory COMMAND guest_memory_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_memory PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
add_executable(guest_directory_entry_tests tests/GuestDirectoryEntries.cpp)
|
||||
target_include_directories(guest_directory_entry_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_directory_entry_tests PRIVATE libkernel libc)
|
||||
add_test(NAME guest_directory_entries COMMAND guest_directory_entry_tests)
|
||||
endif()
|
||||
add_executable(guest_search_tests tests/GuestSearch.cpp)
|
||||
target_include_directories(guest_search_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_search_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_search_tests)
|
||||
add_test(NAME guest_search COMMAND guest_search_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_search PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
add_executable(guest_string_tests tests/GuestStrings.cpp)
|
||||
target_include_directories(guest_string_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(guest_string_tests PRIVATE libc libScePosixForWebKit)
|
||||
configure_windows_unwind(guest_string_tests)
|
||||
add_test(NAME guest_strings COMMAND guest_string_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_strings PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
if(UNIX)
|
||||
add_executable(exception_runtime_tests tests/ExceptionRuntime.cpp)
|
||||
target_include_directories(exception_runtime_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(exception_runtime_tests PRIVATE libc)
|
||||
add_test(NAME exception_runtime COMMAND exception_runtime_tests)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(application_heap_tests EXCLUDE_FROM_ALL tests/ApplicationHeap.cpp)
|
||||
target_include_directories(application_heap_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(application_heap_tests PRIVATE libc)
|
||||
configure_windows_unwind(application_heap_tests)
|
||||
set_target_properties(application_heap_tests PROPERTIES CXX_EXTENSIONS OFF)
|
||||
if(BUILD_TESTING)
|
||||
set_target_properties(application_heap_tests PROPERTIES EXCLUDE_FROM_ALL FALSE)
|
||||
add_test(NAME application_heap_replacement COMMAND application_heap_tests)
|
||||
add_test(NAME application_heap_invalid_metadata COMMAND application_heap_tests invalid)
|
||||
add_test(NAME application_heap_default COMMAND application_heap_tests default)
|
||||
if(WIN32)
|
||||
set_tests_properties(application_heap_replacement application_heap_invalid_metadata application_heap_default
|
||||
PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(guest_locale_tests EXCLUDE_FROM_ALL tests/GuestLocale.cpp)
|
||||
target_include_directories(guest_locale_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_target_properties(guest_locale_tests PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_link_libraries(guest_locale_tests PRIVATE libc)
|
||||
configure_windows_unwind(guest_locale_tests)
|
||||
|
||||
if(MINGW)
|
||||
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
|
||||
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endforeach()
|
||||
add_executable(windows_exception_tests EXCLUDE_FROM_ALL tests/WindowsExceptions.cpp)
|
||||
set_target_properties(windows_exception_tests PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_link_libraries(windows_exception_tests PRIVATE libc)
|
||||
configure_windows_unwind(windows_exception_tests)
|
||||
endif()
|
||||
@@ -1,91 +0,0 @@
|
||||
#ifndef CORE_LIBS_SCE_SHADERS_HPP
|
||||
#define CORE_LIBS_SCE_SHADERS_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct ShaderSharp {
|
||||
std::uint16_t offset_dw : 15;
|
||||
std::uint16_t size : 1;
|
||||
};
|
||||
|
||||
struct ShaderRegister {
|
||||
std::uint32_t offset;
|
||||
std::uint32_t value;
|
||||
};
|
||||
|
||||
struct ShaderUserData {
|
||||
std::uint16_t* direct_resource_offset;
|
||||
ShaderSharp* sharp_resource_offset[4];
|
||||
std::uint16_t eud_size_dw;
|
||||
std::uint16_t srt_size_dw;
|
||||
std::uint16_t direct_resource_count;
|
||||
std::uint16_t sharp_resource_count[4];
|
||||
};
|
||||
|
||||
struct ShaderRegisterRange {
|
||||
std::uint16_t start;
|
||||
std::uint16_t end;
|
||||
};
|
||||
|
||||
struct ShaderDrawModifier {
|
||||
std::uint32_t enbl_start_vertex_offset : 1;
|
||||
std::uint32_t enbl_start_index_offset : 1;
|
||||
std::uint32_t enbl_start_instance_offset : 1;
|
||||
std::uint32_t enbl_draw_index : 1;
|
||||
std::uint32_t enbl_user_vgprs : 1;
|
||||
std::uint32_t render_target_slice_offset : 3;
|
||||
std::uint32_t fuse_draws : 1;
|
||||
std::uint32_t compiler_flags : 23;
|
||||
std::uint32_t is_default : 1;
|
||||
std::uint32_t reserved : 31;
|
||||
};
|
||||
|
||||
struct ShaderSpecialRegs {
|
||||
ShaderRegister ge_cntl;
|
||||
ShaderRegister vgt_shader_stages_en;
|
||||
std::uint32_t dispatch_modifier;
|
||||
ShaderRegisterRange user_data_range;
|
||||
ShaderDrawModifier draw_modifier;
|
||||
ShaderRegister vgt_gs_out_prim_type;
|
||||
ShaderRegister ge_user_vgpr_en;
|
||||
};
|
||||
|
||||
struct ShaderSemantic {
|
||||
std::uint32_t semantic : 8;
|
||||
std::uint32_t hardware_mapping : 8;
|
||||
std::uint32_t size_in_elements : 4;
|
||||
std::uint32_t is_f16 : 2;
|
||||
std::uint32_t is_flat_shaded : 1;
|
||||
std::uint32_t is_linear : 1;
|
||||
std::uint32_t is_custom : 1;
|
||||
std::uint32_t static_vb_index : 1;
|
||||
std::uint32_t static_attribute : 1;
|
||||
std::uint32_t reserved : 1;
|
||||
std::uint32_t default_value : 2;
|
||||
std::uint32_t default_value_hi : 2;
|
||||
};
|
||||
|
||||
struct Shader {
|
||||
std::uint32_t file_header;
|
||||
std::uint32_t version;
|
||||
ShaderUserData* user_data;
|
||||
const volatile void* code;
|
||||
ShaderRegister* cx_registers;
|
||||
ShaderRegister* sh_registers;
|
||||
ShaderSpecialRegs* specials;
|
||||
ShaderSemantic* input_semantics;
|
||||
ShaderSemantic* output_semantics;
|
||||
std::uint32_t header_size;
|
||||
std::uint32_t shader_size;
|
||||
std::uint32_t embedded_constant_buffer_size_dqw;
|
||||
std::uint32_t target;
|
||||
std::uint32_t num_input_semantics;
|
||||
std::uint16_t scratch_size_dw_per_thread;
|
||||
std::uint16_t num_output_semantics;
|
||||
std::uint16_t special_sizes_bytes;
|
||||
std::uint8_t type;
|
||||
std::uint8_t num_cx_registers;
|
||||
std::uint8_t num_sh_registers;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,15 +0,0 @@
|
||||
#ifndef NID_BINARYPATCHERFACTORY_HPP
|
||||
#define NID_BINARYPATCHERFACTORY_HPP
|
||||
|
||||
#include <nid/IBinaryPatcher.hpp>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::unique_ptr<IBinaryPatcher> MakePatcher(const std::vector<std::uint8_t>& binary);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,103 +0,0 @@
|
||||
#ifndef NID_ELFPATCHER_HPP
|
||||
#define NID_ELFPATCHER_HPP
|
||||
|
||||
#include <nid/IBinaryPatcher.hpp>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
struct Elf64_Ehdr {
|
||||
std::uint8_t e_ident[16];
|
||||
std::uint16_t e_type;
|
||||
std::uint16_t e_machine;
|
||||
std::uint32_t e_version;
|
||||
std::uint64_t e_entry;
|
||||
std::uint64_t e_phoff;
|
||||
std::uint64_t e_shoff;
|
||||
std::uint32_t e_flags;
|
||||
std::uint16_t e_ehsize;
|
||||
std::uint16_t e_phentsize;
|
||||
std::uint16_t e_phnum;
|
||||
std::uint16_t e_shentsize;
|
||||
std::uint16_t e_shnum;
|
||||
std::uint16_t e_shstrndx;
|
||||
};
|
||||
|
||||
struct Elf64_Shdr {
|
||||
std::uint32_t sh_name;
|
||||
std::uint32_t sh_type;
|
||||
std::uint64_t sh_flags;
|
||||
std::uint64_t sh_addr;
|
||||
std::uint64_t sh_offset;
|
||||
std::uint64_t sh_size;
|
||||
std::uint32_t sh_link;
|
||||
std::uint32_t sh_info;
|
||||
std::uint64_t sh_addralign;
|
||||
std::uint64_t sh_entsize;
|
||||
};
|
||||
|
||||
struct Elf64_Sym {
|
||||
std::uint32_t st_name;
|
||||
std::uint8_t st_info;
|
||||
std::uint8_t st_other;
|
||||
std::uint16_t st_shndx;
|
||||
std::uint64_t st_value;
|
||||
std::uint64_t st_size;
|
||||
};
|
||||
|
||||
struct Elf64_Rela {
|
||||
std::uint64_t r_offset;
|
||||
std::uint64_t r_info;
|
||||
std::int64_t r_addend;
|
||||
};
|
||||
|
||||
struct Elf64_Dyn {
|
||||
std::int64_t d_tag;
|
||||
std::uint64_t d_val;
|
||||
};
|
||||
|
||||
struct Elf64_Verneed {
|
||||
std::uint16_t vn_version;
|
||||
std::uint16_t vn_cnt;
|
||||
std::uint32_t vn_file;
|
||||
std::uint32_t vn_aux;
|
||||
std::uint32_t vn_next;
|
||||
};
|
||||
|
||||
struct Elf64_Vernaux {
|
||||
std::uint32_t vna_hash;
|
||||
std::uint16_t vna_flags;
|
||||
std::uint16_t vna_other;
|
||||
std::uint32_t vna_name;
|
||||
std::uint32_t vna_next;
|
||||
};
|
||||
|
||||
struct GnuHashLayout {
|
||||
std::uint32_t NBuckets;
|
||||
std::uint32_t SymOffset;
|
||||
std::uint32_t BloomSize;
|
||||
std::uint32_t BloomShift;
|
||||
std::size_t BloomOffset;
|
||||
std::size_t BucketsOffset;
|
||||
std::size_t ChainOffset;
|
||||
};
|
||||
|
||||
constexpr std::int64_t kDtNeeded = 1;
|
||||
constexpr std::int64_t kDtSoname = 14;
|
||||
constexpr std::int64_t kDtNull = 0;
|
||||
constexpr std::uint32_t kShtDynamic = 6u;
|
||||
constexpr std::uint32_t kShtGnuVerneed = 0x6ffffffeu;
|
||||
constexpr std::uint32_t kShtDynsym = 11u;
|
||||
constexpr std::uint32_t kShtGnuHash = 0x6ffffff6u;
|
||||
constexpr std::uint32_t kShtRela = 4u;
|
||||
constexpr std::uint32_t kShtGnuVersym = 0x6fffffffu;
|
||||
constexpr std::uint8_t kStbLocal = 0u;
|
||||
constexpr std::uint16_t kShnUndef = 0u;
|
||||
|
||||
class ElfNidPatcher final : public IBinaryPatcher {
|
||||
public:
|
||||
void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef NID_EXPORTEXCLUSIONS_HPP
|
||||
#define NID_EXPORTEXCLUSIONS_HPP
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::string NormalizeExportName(const std::string& name);
|
||||
std::unordered_set<std::string> ReadExportExclusions(const std::string& path);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef NID_IBINARYPATCHER_HPP
|
||||
#define NID_IBINARYPATCHER_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
class IBinaryPatcher {
|
||||
public:
|
||||
virtual ~IBinaryPatcher() = default;
|
||||
|
||||
virtual void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef NID_NIDCOMPUTE_HPP
|
||||
#define NID_NIDCOMPUTE_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::string ComputeNid(const std::string& symbolName, const std::string& libraryName);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,87 +0,0 @@
|
||||
#ifndef NID_NIDPATCHERUTILS_HPP
|
||||
#define NID_NIDPATCHERUTILS_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
namespace Internal {
|
||||
|
||||
constexpr char kNidPostfix[] = "_nid_postfix";
|
||||
constexpr std::size_t kNidPostfixLen = sizeof(kNidPostfix) - 1u;
|
||||
constexpr char kNidNoPatch[] = "_nid_no_patch";
|
||||
constexpr std::size_t kNidNoPatchLen = sizeof(kNidNoPatch) - 1u;
|
||||
constexpr char kNidNoPatchCut[] = "_nid_no_patch_cut";
|
||||
constexpr std::size_t kNidNoPatchCutLen = sizeof(kNidNoPatchCut) - 1u;
|
||||
constexpr char kNidDisambigMarker[] = "_nid_disambig";
|
||||
constexpr std::size_t kNidDisambigMarkerLen = sizeof(kNidDisambigMarker) - 1u;
|
||||
constexpr char kSDLPrefix[] = "SDL_";
|
||||
constexpr std::size_t kSDLPrefixLen = sizeof(kSDLPrefix) - 1u;
|
||||
|
||||
|
||||
inline bool IsNidNoPatch(const std::string& name) {
|
||||
return (
|
||||
name.size() >= kNidNoPatchLen &&
|
||||
name.compare(name.size() - kNidNoPatchLen, kNidNoPatchLen, kNidNoPatch) == 0
|
||||
) || name.compare(0, kSDLPrefixLen, kSDLPrefix) == 0;
|
||||
}
|
||||
|
||||
inline bool IsNidNoPatchCut(const std::string& name) {
|
||||
return name.size() >= kNidNoPatchCutLen &&
|
||||
name.compare(name.size() - kNidNoPatchCutLen, kNidNoPatchCutLen, kNidNoPatchCut) == 0;
|
||||
}
|
||||
|
||||
inline std::string StripNidNoPatchCut(const std::string& name) {
|
||||
return name.substr(0u, name.size() - kNidNoPatchCutLen);
|
||||
}
|
||||
|
||||
inline std::string StripNidPostfix(const std::string& name) {
|
||||
std::string result = name;
|
||||
if (result.size() >= kNidPostfixLen &&
|
||||
result.compare(result.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0) {
|
||||
result.resize(result.size() - kNidPostfixLen);
|
||||
}
|
||||
const auto disambigPos = result.rfind(kNidDisambigMarker);
|
||||
if (disambigPos != std::string::npos) {
|
||||
const auto suffixStart = disambigPos + kNidDisambigMarkerLen;
|
||||
const bool allDigits = std::all_of(
|
||||
result.begin() + static_cast<std::ptrdiff_t>(suffixStart), result.end(),
|
||||
[](unsigned char c) { return std::isdigit(c) != 0; }
|
||||
);
|
||||
if (allDigits && suffixStart < result.size())
|
||||
result.resize(disambigPos);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Read(const std::vector<std::uint8_t>& buf, std::size_t offset) {
|
||||
if (offset + sizeof(T) > buf.size()) throw std::runtime_error("read out of bounds");
|
||||
T v;
|
||||
std::memcpy(&v, buf.data() + offset, sizeof(T));
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Write(std::vector<std::uint8_t>& buf, std::size_t offset, const T& v) {
|
||||
if (offset + sizeof(T) > buf.size()) throw std::runtime_error("write out of bounds");
|
||||
std::memcpy(buf.data() + offset, &v, sizeof(T));
|
||||
}
|
||||
|
||||
inline std::string ReadCStr(const std::vector<std::uint8_t>& buf, std::size_t offset) {
|
||||
if (offset >= buf.size()) throw std::runtime_error("cstr offset out of bounds");
|
||||
std::string s;
|
||||
while (offset < buf.size() && buf[offset] != 0u)
|
||||
s.push_back(static_cast<char>(buf[offset++]));
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef NID_NIDRESOLVER_HPP
|
||||
#define NID_NIDRESOLVER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::string ResolveOneName(const std::string& funcName);
|
||||
|
||||
std::unordered_map<std::string, std::string> ResolveNids(const std::vector<std::string>& exportedNames, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
#ifndef CORE_LIBS_NID_PENIDPATCHER_HPP
|
||||
#define CORE_LIBS_NID_PENIDPATCHER_HPP
|
||||
|
||||
#include <nid/IBinaryPatcher.hpp>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
struct PeDataDirectory {
|
||||
std::uint32_t VirtualAddress;
|
||||
std::uint32_t Size;
|
||||
};
|
||||
|
||||
struct PeExportDirectory {
|
||||
std::uint32_t Characteristics;
|
||||
std::uint32_t TimeDateStamp;
|
||||
std::uint16_t MajorVersion;
|
||||
std::uint16_t MinorVersion;
|
||||
std::uint32_t Name;
|
||||
std::uint32_t Base;
|
||||
std::uint32_t NumberOfFunctions;
|
||||
std::uint32_t NumberOfNames;
|
||||
std::uint32_t AddressOfFunctions;
|
||||
std::uint32_t AddressOfNames;
|
||||
std::uint32_t AddressOfNameOrdinals;
|
||||
};
|
||||
|
||||
struct PeSectionHeader {
|
||||
std::uint8_t Name[8];
|
||||
std::uint32_t VirtualSize;
|
||||
std::uint32_t VirtualAddress;
|
||||
std::uint32_t SizeOfRawData;
|
||||
std::uint32_t PointerToRawData;
|
||||
std::uint32_t PointerToRelocations;
|
||||
std::uint32_t PointerToLinenumbers;
|
||||
std::uint16_t NumberOfRelocations;
|
||||
std::uint16_t NumberOfLinenumbers;
|
||||
std::uint32_t Characteristics;
|
||||
};
|
||||
|
||||
class PeNidPatcher final : public IBinaryPatcher {
|
||||
public:
|
||||
void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef NID_SHA1_HPP
|
||||
#define NID_SHA1_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::array<std::uint8_t, 20> Sha1(const std::vector<std::uint8_t>& data);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#include <nid/BinaryPatcherFactory.hpp>
|
||||
#include <nid/ElfPatcher.hpp>
|
||||
#include <nid/PeNidPatcher.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::unique_ptr<IBinaryPatcher> MakePatcher(const std::vector<std::uint8_t>& binary) {
|
||||
if (binary.size() >= 4 && binary[0] == 0x7f && binary[1] == 'E' && binary[2] == 'L' && binary[3] == 'F')
|
||||
return std::make_unique<ElfNidPatcher>();
|
||||
if (binary.size() >= 2 && binary[0] == 'M' && binary[1] == 'Z')
|
||||
return std::make_unique<PeNidPatcher>();
|
||||
throw std::runtime_error("unrecognized binary format");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,497 +0,0 @@
|
||||
#include <nid/ElfPatcher.hpp>
|
||||
#include <nid/NidResolver.hpp>
|
||||
#include <nid/NidPatcherUtils.hpp>
|
||||
#include <nid/NidCompute.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
std::uint32_t GnuHash(const std::string& name) {
|
||||
std::uint32_t h = 5381u;
|
||||
for (const unsigned char c : name)
|
||||
h = h * 33u + c;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
GnuHashLayout ReadGnuHashLayout(const std::vector<std::uint8_t>& elf, std::size_t sectionOffset) {
|
||||
using namespace Internal;
|
||||
GnuHashLayout layout{};
|
||||
layout.NBuckets = Read<std::uint32_t>(elf, sectionOffset + 0u);
|
||||
layout.SymOffset = Read<std::uint32_t>(elf, sectionOffset + 4u);
|
||||
layout.BloomSize = Read<std::uint32_t>(elf, sectionOffset + 8u);
|
||||
layout.BloomShift = Read<std::uint32_t>(elf, sectionOffset + 12u);
|
||||
layout.BloomOffset = sectionOffset + 16u;
|
||||
layout.BucketsOffset = layout.BloomOffset + static_cast<std::size_t>(layout.BloomSize) * 8u;
|
||||
layout.ChainOffset = layout.BucketsOffset + static_cast<std::size_t>(layout.NBuckets) * 4u;
|
||||
return layout;
|
||||
}
|
||||
|
||||
void ReorderDynSymForGnuHash(
|
||||
std::vector<std::uint8_t>& elf,
|
||||
std::size_t dynSymOffset,
|
||||
std::size_t symCount,
|
||||
std::uint32_t symOffset,
|
||||
std::uint32_t bucketCount,
|
||||
std::vector<std::string>& symbolNames,
|
||||
std::vector<std::uint32_t>& oldToNewIndex
|
||||
) {
|
||||
using namespace Internal;
|
||||
|
||||
std::vector<std::uint32_t> movableIndices;
|
||||
for (std::uint32_t i = symOffset; i < symCount; ++i)
|
||||
movableIndices.push_back(i);
|
||||
|
||||
std::stable_sort(
|
||||
movableIndices.begin(), movableIndices.end(),
|
||||
[&](const std::uint32_t lhs, const std::uint32_t rhs) {
|
||||
return GnuHash(symbolNames[lhs]) % bucketCount < GnuHash(symbolNames[rhs]) % bucketCount;
|
||||
}
|
||||
);
|
||||
|
||||
std::vector<Elf64_Sym> reorderedSyms(symCount);
|
||||
std::vector<std::string> reorderedNames(symCount);
|
||||
|
||||
for (std::uint32_t i = 0u; i < symOffset; ++i) {
|
||||
reorderedSyms[i] = Read<Elf64_Sym>(elf, dynSymOffset + i * sizeof(Elf64_Sym));
|
||||
reorderedNames[i] = symbolNames[i];
|
||||
oldToNewIndex[i] = i;
|
||||
}
|
||||
|
||||
for (std::size_t position = 0u; position < movableIndices.size(); ++position) {
|
||||
const std::uint32_t oldIndex = movableIndices[position];
|
||||
const std::uint32_t newIndex = symOffset + static_cast<std::uint32_t>(position);
|
||||
reorderedSyms[newIndex] = Read<Elf64_Sym>(elf, dynSymOffset + oldIndex * sizeof(Elf64_Sym));
|
||||
reorderedNames[newIndex] = symbolNames[oldIndex];
|
||||
oldToNewIndex[oldIndex] = newIndex;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0u; i < symCount; ++i)
|
||||
Write(elf, dynSymOffset + i * sizeof(Elf64_Sym), reorderedSyms[i]);
|
||||
|
||||
symbolNames = std::move(reorderedNames);
|
||||
}
|
||||
|
||||
void FixupRelocationSymbolIndices(
|
||||
std::vector<std::uint8_t>& elf,
|
||||
const Elf64_Ehdr& ehdr,
|
||||
std::uint32_t dynSymSectionIndex,
|
||||
const std::vector<std::uint32_t>& oldToNewIndex
|
||||
) {
|
||||
using namespace Internal;
|
||||
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type != kShtRela) continue;
|
||||
if (shdr.sh_link != dynSymSectionIndex) continue;
|
||||
|
||||
const std::size_t relaOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
const std::size_t relaCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Rela);
|
||||
|
||||
for (std::size_t r = 0u; r < relaCount; ++r) {
|
||||
const std::size_t entryOffset = relaOffset + r * sizeof(Elf64_Rela);
|
||||
const auto rela = Read<Elf64_Rela>(elf, entryOffset);
|
||||
|
||||
const auto oldSymIndex = static_cast<std::uint32_t>(rela.r_info >> 32u);
|
||||
if (oldSymIndex >= oldToNewIndex.size()) continue;
|
||||
|
||||
const std::uint32_t newSymIndex = oldToNewIndex[oldSymIndex];
|
||||
const auto relType = static_cast<std::uint32_t>(rela.r_info & 0xffffffffu);
|
||||
const std::uint64_t newInfo = (static_cast<std::uint64_t>(newSymIndex) << 32u) | relType;
|
||||
|
||||
Write(elf, entryOffset + offsetof(Elf64_Rela, r_info), newInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RebuildGnuHash(
|
||||
std::vector<std::uint8_t>& elf,
|
||||
std::size_t sectionOffset,
|
||||
std::size_t sectionSize,
|
||||
std::size_t symCount,
|
||||
const std::vector<std::string>& symbolNames
|
||||
) {
|
||||
using namespace Internal;
|
||||
|
||||
const GnuHashLayout layout = ReadGnuHashLayout(elf, sectionOffset);
|
||||
|
||||
const std::size_t chainCount = symCount - layout.SymOffset;
|
||||
const std::size_t requiredSize = layout.ChainOffset - sectionOffset + chainCount * 4u;
|
||||
if (requiredSize > sectionSize)
|
||||
throw std::runtime_error("gnu.hash section too small to rebuild in place");
|
||||
|
||||
std::vector<std::uint32_t> hashes(symCount, 0u);
|
||||
for (std::size_t i = layout.SymOffset; i < symCount; ++i)
|
||||
hashes[i] = GnuHash(symbolNames[i]);
|
||||
|
||||
std::vector<std::uint64_t> bloom(layout.BloomSize, 0u);
|
||||
for (std::size_t i = layout.SymOffset; i < symCount; ++i) {
|
||||
const std::uint32_t h = hashes[i];
|
||||
const std::uint32_t wordIndex = (h / 64u) % layout.BloomSize;
|
||||
const std::uint32_t bit1 = h % 64u;
|
||||
const std::uint32_t bit2 = (h >> layout.BloomShift) % 64u;
|
||||
bloom[wordIndex] |= (std::uint64_t{1} << bit1);
|
||||
bloom[wordIndex] |= (std::uint64_t{1} << bit2);
|
||||
}
|
||||
|
||||
std::vector<std::uint32_t> buckets(layout.NBuckets, 0u);
|
||||
std::vector<std::uint32_t> chain(chainCount, 0u);
|
||||
|
||||
for (std::size_t i = layout.SymOffset; i < symCount; ++i) {
|
||||
const std::uint32_t bucketIndex = hashes[i] % layout.NBuckets;
|
||||
if (buckets[bucketIndex] == 0u)
|
||||
buckets[bucketIndex] = static_cast<std::uint32_t>(i);
|
||||
}
|
||||
|
||||
for (std::size_t i = layout.SymOffset; i < symCount; ++i) {
|
||||
const std::uint32_t bucketIndex = hashes[i] % layout.NBuckets;
|
||||
const bool isLastInBucket = (i + 1u == symCount) || (hashes[i + 1u] % layout.NBuckets != bucketIndex);
|
||||
chain[i - layout.SymOffset] = isLastInBucket ? (hashes[i] | 1u) : (hashes[i] & ~std::uint32_t{1});
|
||||
}
|
||||
|
||||
for (std::uint32_t bloomIndex = 0u; bloomIndex < layout.BloomSize; ++bloomIndex)
|
||||
Write(elf, layout.BloomOffset + bloomIndex * 8u, bloom[bloomIndex]);
|
||||
|
||||
for (std::uint32_t bucketIndex = 0u; bucketIndex < layout.NBuckets; ++bucketIndex)
|
||||
Write(elf, layout.BucketsOffset + bucketIndex * 4u, buckets[bucketIndex]);
|
||||
|
||||
for (std::size_t i = 0u; i < chainCount; ++i)
|
||||
Write(elf, layout.ChainOffset + i * 4u, chain[i]);
|
||||
|
||||
if (requiredSize < sectionSize)
|
||||
std::memset(elf.data() + sectionOffset + requiredSize, 0, sectionSize - requiredSize);
|
||||
}
|
||||
|
||||
void RemapDynamicNeededOffsets(
|
||||
std::vector<std::uint8_t>& elf,
|
||||
const Elf64_Ehdr& ehdr,
|
||||
const std::vector<std::pair<std::uint32_t, std::uint32_t>>& oldToNewOffset
|
||||
) {
|
||||
using namespace Internal;
|
||||
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type != kShtDynamic) continue;
|
||||
|
||||
const std::size_t dynOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
const std::size_t dynCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Dyn);
|
||||
|
||||
for (std::size_t d = 0u; d < dynCount; ++d) {
|
||||
const std::size_t entryOffset = dynOffset + d * sizeof(Elf64_Dyn);
|
||||
const auto dyn = Read<Elf64_Dyn>(elf, entryOffset);
|
||||
if (dyn.d_tag != kDtNeeded && dyn.d_tag != kDtSoname) continue;
|
||||
|
||||
const auto oldNameOffset = static_cast<std::uint32_t>(dyn.d_val);
|
||||
const auto mapped = std::find_if(
|
||||
oldToNewOffset.begin(), oldToNewOffset.end(),
|
||||
[&](const auto& entry) { return entry.first == oldNameOffset; }
|
||||
);
|
||||
if (mapped == oldToNewOffset.end()) continue;
|
||||
|
||||
Write(elf, entryOffset + offsetof(Elf64_Dyn, d_val), static_cast<std::uint64_t>(mapped->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemapVerneedOffsets(
|
||||
std::vector<std::uint8_t>& elf,
|
||||
const Elf64_Ehdr& ehdr,
|
||||
const std::vector<std::pair<std::uint32_t, std::uint32_t>>& oldToNewOffset
|
||||
) {
|
||||
using namespace Internal;
|
||||
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type != kShtGnuVerneed) continue;
|
||||
|
||||
const std::size_t verneedOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
std::size_t entryOffset = verneedOffset;
|
||||
|
||||
while (true) {
|
||||
const auto verneed = Read<Elf64_Verneed>(elf, entryOffset);
|
||||
|
||||
const auto mappedFile = std::find_if(
|
||||
oldToNewOffset.begin(), oldToNewOffset.end(),
|
||||
[&](const auto& entry) { return entry.first == verneed.vn_file; }
|
||||
);
|
||||
if (mappedFile != oldToNewOffset.end())
|
||||
Write(elf, entryOffset + offsetof(Elf64_Verneed, vn_file), mappedFile->second);
|
||||
|
||||
std::size_t auxOffset = entryOffset + verneed.vn_aux;
|
||||
for (std::uint16_t a = 0u; a < verneed.vn_cnt; ++a) {
|
||||
const auto vernaux = Read<Elf64_Vernaux>(elf, auxOffset);
|
||||
|
||||
const auto mappedName = std::find_if(
|
||||
oldToNewOffset.begin(), oldToNewOffset.end(),
|
||||
[&](const auto& entry) { return entry.first == vernaux.vna_name; }
|
||||
);
|
||||
if (mappedName != oldToNewOffset.end())
|
||||
Write(elf, auxOffset + offsetof(Elf64_Vernaux, vna_name), mappedName->second);
|
||||
|
||||
if (vernaux.vna_next == 0u) break;
|
||||
auxOffset += vernaux.vna_next;
|
||||
}
|
||||
|
||||
if (verneed.vn_next == 0u) break;
|
||||
entryOffset += verneed.vn_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::uint32_t> CollectDynamicNameOffsets(const std::vector<std::uint8_t>& elf, const Elf64_Ehdr& ehdr) {
|
||||
using namespace Internal;
|
||||
|
||||
std::vector<std::uint32_t> offsets;
|
||||
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type != kShtDynamic) continue;
|
||||
|
||||
const std::size_t dynOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
const std::size_t dynCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Dyn);
|
||||
|
||||
for (std::size_t d = 0u; d < dynCount; ++d) {
|
||||
const auto dyn = Read<Elf64_Dyn>(elf, dynOffset + d * sizeof(Elf64_Dyn));
|
||||
if (dyn.d_tag == kDtNull) break;
|
||||
if (dyn.d_tag != kDtNeeded && dyn.d_tag != kDtSoname) continue;
|
||||
offsets.push_back(static_cast<std::uint32_t>(dyn.d_val));
|
||||
}
|
||||
}
|
||||
|
||||
return offsets;
|
||||
}
|
||||
|
||||
std::vector<std::uint32_t> CollectVerneedNameOffsets(const std::vector<std::uint8_t>& elf, const Elf64_Ehdr& ehdr) {
|
||||
using namespace Internal;
|
||||
|
||||
std::vector<std::uint32_t> offsets;
|
||||
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type != kShtGnuVerneed) continue;
|
||||
|
||||
std::size_t entryOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
|
||||
while (true) {
|
||||
const auto verneed = Read<Elf64_Verneed>(elf, entryOffset);
|
||||
offsets.push_back(verneed.vn_file);
|
||||
|
||||
std::size_t auxOffset = entryOffset + verneed.vn_aux;
|
||||
for (std::uint16_t a = 0u; a < verneed.vn_cnt; ++a) {
|
||||
const auto vernaux = Read<Elf64_Vernaux>(elf, auxOffset);
|
||||
offsets.push_back(vernaux.vna_name);
|
||||
|
||||
if (vernaux.vna_next == 0u) break;
|
||||
auxOffset += vernaux.vna_next;
|
||||
}
|
||||
|
||||
if (verneed.vn_next == 0u) break;
|
||||
entryOffset += verneed.vn_next;
|
||||
}
|
||||
}
|
||||
|
||||
return offsets;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const {
|
||||
using namespace Internal;
|
||||
|
||||
if (elf.size() < sizeof(Elf64_Ehdr)) throw std::runtime_error("file too small");
|
||||
if (elf[4] != 2) throw std::runtime_error("not ELF64");
|
||||
|
||||
const auto ehdr = Read<Elf64_Ehdr>(elf, 0u);
|
||||
|
||||
std::size_t dynSymOffset = 0u, dynSymSize = 0u;
|
||||
std::size_t gnuHashOffset = 0u, gnuHashSize = 0u;
|
||||
std::size_t versymOffset = 0u;
|
||||
std::uint32_t dynSymSectionIndex = 0u;
|
||||
std::uint32_t gnuHashSymOffset = 0u;
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type == kShtDynsym) {
|
||||
dynSymOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
dynSymSize = static_cast<std::size_t>(shdr.sh_size);
|
||||
dynSymSectionIndex = i;
|
||||
}
|
||||
if (shdr.sh_type == kShtGnuHash) {
|
||||
gnuHashOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
gnuHashSize = static_cast<std::size_t>(shdr.sh_size);
|
||||
gnuHashSymOffset = Read<std::uint32_t>(elf, gnuHashOffset + 4u);
|
||||
}
|
||||
if (shdr.sh_type == kShtGnuVersym)
|
||||
versymOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
}
|
||||
|
||||
if (dynSymOffset == 0u) throw std::runtime_error("no .dynsym section");
|
||||
|
||||
const std::size_t symCount = dynSymSize / sizeof(Elf64_Sym);
|
||||
if (symCount == 0u) throw std::runtime_error(".dynsym is empty");
|
||||
|
||||
const std::size_t dynStrSectionLink = [&]() -> std::size_t {
|
||||
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
if (shdr.sh_type == kShtDynsym) return static_cast<std::size_t>(shdr.sh_link);
|
||||
}
|
||||
throw std::runtime_error("cannot find dynsym sh_link");
|
||||
}();
|
||||
|
||||
std::size_t dynStrOffset = 0u, dynStrSize = 0u;
|
||||
{
|
||||
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + dynStrSectionLink * sizeof(Elf64_Shdr);
|
||||
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
|
||||
dynStrOffset = static_cast<std::size_t>(shdr.sh_offset);
|
||||
dynStrSize = static_cast<std::size_t>(shdr.sh_size);
|
||||
}
|
||||
|
||||
if (dynStrOffset == 0u) throw std::runtime_error("no .dynstr section");
|
||||
|
||||
const std::vector<std::uint8_t> origDynStr(
|
||||
elf.begin() + static_cast<std::ptrdiff_t>(dynStrOffset),
|
||||
elf.begin() + static_cast<std::ptrdiff_t>(dynStrOffset + dynStrSize)
|
||||
);
|
||||
|
||||
std::vector<std::string> exportedNames;
|
||||
for (std::size_t i = 1u; i < symCount; ++i) {
|
||||
const std::size_t symOffset = dynSymOffset + i * sizeof(Elf64_Sym);
|
||||
const auto sym = Read<Elf64_Sym>(elf, symOffset);
|
||||
if (sym.st_name == 0u) continue;
|
||||
const std::uint8_t binding = sym.st_info >> 4u;
|
||||
if (binding == kStbLocal || sym.st_shndx == kShnUndef) continue;
|
||||
const std::string symName = ReadCStr(origDynStr, sym.st_name);
|
||||
if (symName.empty()) continue;
|
||||
exportedNames.push_back(symName);
|
||||
}
|
||||
|
||||
const auto nidMap = ResolveNids(exportedNames, libraryName, excludedExports);
|
||||
|
||||
struct SymbolNameUse {
|
||||
std::size_t symIndex;
|
||||
std::uint32_t oldNameOffset;
|
||||
std::string newValue;
|
||||
};
|
||||
|
||||
std::vector<SymbolNameUse> uses;
|
||||
for (std::size_t i = 1u; i < symCount; ++i) {
|
||||
const std::size_t symOffset = dynSymOffset + i * sizeof(Elf64_Sym);
|
||||
const auto sym = Read<Elf64_Sym>(elf, symOffset);
|
||||
if (sym.st_name == 0u) continue;
|
||||
|
||||
const std::uint8_t binding = sym.st_info >> 4u;
|
||||
const bool isPatchable = binding != kStbLocal && sym.st_shndx != kShnUndef;
|
||||
|
||||
const std::string symName = ReadCStr(origDynStr, sym.st_name);
|
||||
if (symName.empty()) continue;
|
||||
|
||||
std::string newValue = symName;
|
||||
if (isPatchable) {
|
||||
const auto it = nidMap.find(symName);
|
||||
if (it != nidMap.end())
|
||||
newValue = it->second;
|
||||
} else if (binding != kStbLocal && sym.st_shndx == kShnUndef) {
|
||||
const bool isUnversioned = versymOffset == 0u ||
|
||||
(Read<std::uint16_t>(elf, versymOffset + i * sizeof(std::uint16_t)) <= 1u);
|
||||
const bool hasNidPostfix = symName.size() >= kNidPostfixLen &&
|
||||
symName.compare(symName.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0;
|
||||
const bool hasScePrefix = symName.size() >= 3u &&
|
||||
std::tolower(static_cast<unsigned char>(symName[0])) == 's' &&
|
||||
std::tolower(static_cast<unsigned char>(symName[1])) == 'c' &&
|
||||
std::tolower(static_cast<unsigned char>(symName[2])) == 'e';
|
||||
if (isUnversioned && (hasNidPostfix || hasScePrefix))
|
||||
newValue = ResolveOneName(symName);
|
||||
}
|
||||
|
||||
uses.push_back(SymbolNameUse{i, sym.st_name, newValue});
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> newDynStr;
|
||||
newDynStr.push_back(0u);
|
||||
|
||||
std::vector<std::pair<std::uint32_t, std::uint32_t>> oldToNewOffset;
|
||||
for (const auto& use : uses) {
|
||||
const auto existing = std::find_if(
|
||||
oldToNewOffset.begin(), oldToNewOffset.end(),
|
||||
[&](const auto& entry) { return entry.first == use.oldNameOffset; }
|
||||
);
|
||||
if (existing != oldToNewOffset.end()) continue;
|
||||
|
||||
const auto newOffset = static_cast<std::uint32_t>(newDynStr.size());
|
||||
newDynStr.insert(newDynStr.end(), use.newValue.begin(), use.newValue.end());
|
||||
newDynStr.push_back(0u);
|
||||
oldToNewOffset.emplace_back(use.oldNameOffset, newOffset);
|
||||
}
|
||||
|
||||
std::vector<std::uint32_t> preservedOffsets = CollectDynamicNameOffsets(elf, ehdr);
|
||||
const std::vector<std::uint32_t> verneedOffsets = CollectVerneedNameOffsets(elf, ehdr);
|
||||
preservedOffsets.insert(preservedOffsets.end(), verneedOffsets.begin(), verneedOffsets.end());
|
||||
|
||||
for (const auto oldOffset : preservedOffsets) {
|
||||
const auto existing = std::find_if(
|
||||
oldToNewOffset.begin(), oldToNewOffset.end(),
|
||||
[&](const auto& entry) { return entry.first == oldOffset; }
|
||||
);
|
||||
if (existing != oldToNewOffset.end()) continue;
|
||||
|
||||
const std::string preservedValue = ReadCStr(origDynStr, oldOffset);
|
||||
|
||||
const auto newOffset = static_cast<std::uint32_t>(newDynStr.size());
|
||||
newDynStr.insert(newDynStr.end(), preservedValue.begin(), preservedValue.end());
|
||||
newDynStr.push_back(0u);
|
||||
oldToNewOffset.emplace_back(oldOffset, newOffset);
|
||||
}
|
||||
|
||||
if (newDynStr.size() > dynStrSize) {
|
||||
throw std::runtime_error(
|
||||
"rebuilt .dynstr (" + std::to_string(newDynStr.size()) + " bytes) exceeds original section size (" +
|
||||
std::to_string(dynStrSize) + " bytes) - relinking with a larger section is required"
|
||||
);
|
||||
}
|
||||
newDynStr.resize(dynStrSize, 0u);
|
||||
|
||||
std::vector<std::string> newSymbolNames(symCount);
|
||||
for (std::size_t i = 1u; i < symCount; ++i) {
|
||||
const std::size_t symOffset = dynSymOffset + i * sizeof(Elf64_Sym);
|
||||
const auto sym = Read<Elf64_Sym>(elf, symOffset);
|
||||
if (sym.st_name == 0u) continue;
|
||||
|
||||
const auto mapped = std::find_if(
|
||||
oldToNewOffset.begin(), oldToNewOffset.end(),
|
||||
[&](const auto& entry) { return entry.first == sym.st_name; }
|
||||
);
|
||||
if (mapped == oldToNewOffset.end()) continue;
|
||||
|
||||
newSymbolNames[i] = ReadCStr(newDynStr, mapped->second);
|
||||
Write(elf, symOffset + offsetof(Elf64_Sym, st_name), mapped->second);
|
||||
}
|
||||
|
||||
std::memcpy(elf.data() + dynStrOffset, newDynStr.data(), newDynStr.size());
|
||||
|
||||
RemapDynamicNeededOffsets(elf, ehdr, oldToNewOffset);
|
||||
RemapVerneedOffsets(elf, ehdr, oldToNewOffset);
|
||||
|
||||
if (gnuHashOffset != 0u) {
|
||||
const auto bucketCount = Read<std::uint32_t>(elf, gnuHashOffset);
|
||||
std::vector<std::uint32_t> oldToNewIndex(symCount);
|
||||
ReorderDynSymForGnuHash(elf, dynSymOffset, symCount, gnuHashSymOffset, bucketCount, newSymbolNames, oldToNewIndex);
|
||||
FixupRelocationSymbolIndices(elf, ehdr, dynSymSectionIndex, oldToNewIndex);
|
||||
RebuildGnuHash(elf, gnuHashOffset, gnuHashSize, symCount, newSymbolNames);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
#include <nid/ExportExclusions.hpp>
|
||||
#include <nid/ElfPatcher.hpp>
|
||||
#include <nid/PeNidPatcher.hpp>
|
||||
#include <nid/NidPatcherUtils.hpp>
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
namespace {
|
||||
|
||||
void RequireRange(const std::vector<std::uint8_t>& binary, std::uint64_t offset, std::uint64_t size) {
|
||||
if (offset > binary.size() || size > binary.size() - offset) throw std::runtime_error("export reference range out of bounds");
|
||||
}
|
||||
|
||||
template<typename TValue>
|
||||
TValue ReadValue(const std::vector<std::uint8_t>& binary, std::uint64_t offset) {
|
||||
RequireRange(binary, offset, sizeof(TValue));
|
||||
TValue value;
|
||||
std::memcpy(&value, binary.data() + offset, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string ReadName(const std::vector<std::uint8_t>& binary, std::uint64_t offset, std::uint64_t size) {
|
||||
RequireRange(binary, offset, size);
|
||||
if (size == 0) throw std::runtime_error("empty export reference name range");
|
||||
const auto start = reinterpret_cast<const char*>(binary.data() + offset);
|
||||
const auto end = static_cast<const char*>(std::memchr(start, 0, size));
|
||||
if (!end || end == start) throw std::runtime_error("invalid export reference name");
|
||||
return {start, end};
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> ReadPeExports(const std::vector<std::uint8_t>& binary) {
|
||||
const std::uint64_t header = ReadValue<std::uint32_t>(binary, 0x3c);
|
||||
if (ReadValue<std::uint32_t>(binary, header) != 0x4550) throw std::runtime_error("invalid reference PE signature");
|
||||
const auto sectionCount = ReadValue<std::uint16_t>(binary, header + 6);
|
||||
const auto optionalSize = ReadValue<std::uint16_t>(binary, header + 20);
|
||||
const auto optional = header + 24;
|
||||
RequireRange(binary, optional, optionalSize);
|
||||
const auto magic = ReadValue<std::uint16_t>(binary, optional);
|
||||
if (magic != 0x20b && magic != 0x10b) throw std::runtime_error("unsupported reference PE optional header");
|
||||
const std::uint64_t directoryOffset = magic == 0x20b ? 112 : 96;
|
||||
if (optionalSize < directoryOffset + sizeof(PeDataDirectory)) throw std::runtime_error("missing reference PE export directory");
|
||||
if (ReadValue<std::uint32_t>(binary, optional + directoryOffset - 4) == 0) throw std::runtime_error("missing reference PE data directories");
|
||||
const auto directory = ReadValue<PeDataDirectory>(binary, optional + directoryOffset);
|
||||
if (!directory.VirtualAddress || directory.Size < sizeof(PeExportDirectory)) throw std::runtime_error("missing reference PE exports");
|
||||
const auto sections = optional + optionalSize;
|
||||
RequireRange(binary, sections, std::uint64_t{sectionCount} * sizeof(PeSectionHeader));
|
||||
const auto mapRva = [&](std::uint32_t rva, std::uint64_t size) -> std::uint64_t {
|
||||
for (std::uint16_t index = 0; index < sectionCount; ++index) {
|
||||
const auto section = ReadValue<PeSectionHeader>(binary, sections + std::uint64_t{index} * sizeof(PeSectionHeader));
|
||||
if (rva < section.VirtualAddress) continue;
|
||||
const std::uint64_t relative = rva - section.VirtualAddress;
|
||||
if (relative >= section.SizeOfRawData || size > section.SizeOfRawData - relative) continue;
|
||||
const auto offset = std::uint64_t{section.PointerToRawData} + relative;
|
||||
RequireRange(binary, offset, size);
|
||||
return offset;
|
||||
}
|
||||
throw std::runtime_error("unmapped reference PE export RVA");
|
||||
};
|
||||
const auto table = ReadValue<PeExportDirectory>(binary, mapRva(directory.VirtualAddress, sizeof(PeExportDirectory)));
|
||||
if (!table.NumberOfNames) throw std::runtime_error("reference PE has no named exports");
|
||||
const auto names = mapRva(table.AddressOfNames, std::uint64_t{table.NumberOfNames} * 4);
|
||||
std::unordered_set<std::string> result;
|
||||
for (std::uint32_t index = 0; index < table.NumberOfNames; ++index) {
|
||||
const auto rva = ReadValue<std::uint32_t>(binary, names + std::uint64_t{index} * 4);
|
||||
const auto offset = mapRva(rva, 1);
|
||||
auto name = ReadName(binary, offset, binary.size() - offset);
|
||||
mapRva(rva, name.size() + 1);
|
||||
if (!result.insert(name).second) throw std::runtime_error("duplicate reference export: " + name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> ReadElfExports(const std::vector<std::uint8_t>& binary) {
|
||||
const auto header = ReadValue<Elf64_Ehdr>(binary, 0);
|
||||
if (header.e_ident[4] != 2 || header.e_ident[5] != 1 || header.e_shentsize != sizeof(Elf64_Shdr)) throw std::runtime_error("unsupported reference ELF layout");
|
||||
RequireRange(binary, header.e_shoff, std::uint64_t{header.e_shnum} * sizeof(Elf64_Shdr));
|
||||
std::unordered_set<std::string> result;
|
||||
for (std::uint16_t index = 0; index < header.e_shnum; ++index) {
|
||||
const auto section = ReadValue<Elf64_Shdr>(binary, header.e_shoff + std::uint64_t{index} * sizeof(Elf64_Shdr));
|
||||
if (section.sh_type != kShtDynsym) continue;
|
||||
if (section.sh_entsize != sizeof(Elf64_Sym) || section.sh_size % sizeof(Elf64_Sym) || section.sh_link >= header.e_shnum) throw std::runtime_error("invalid reference ELF symbol table");
|
||||
RequireRange(binary, section.sh_offset, section.sh_size);
|
||||
const auto strings = ReadValue<Elf64_Shdr>(binary, header.e_shoff + std::uint64_t{section.sh_link} * sizeof(Elf64_Shdr));
|
||||
if (strings.sh_type != 3) throw std::runtime_error("invalid reference ELF string table");
|
||||
RequireRange(binary, strings.sh_offset, strings.sh_size);
|
||||
for (std::uint64_t offset = 0; offset < section.sh_size; offset += sizeof(Elf64_Sym)) {
|
||||
const auto symbol = ReadValue<Elf64_Sym>(binary, section.sh_offset + offset);
|
||||
const auto binding = symbol.st_info >> 4;
|
||||
const auto visibility = symbol.st_other & 3;
|
||||
if (symbol.st_shndx == kShnUndef || (binding != 1 && binding != 2 && binding != 10) || (visibility != 0 && visibility != 3)) continue;
|
||||
if (symbol.st_name >= strings.sh_size) throw std::runtime_error("invalid reference ELF export name");
|
||||
result.insert(ReadName(binary, strings.sh_offset + symbol.st_name, strings.sh_size - symbol.st_name));
|
||||
}
|
||||
}
|
||||
if (result.empty()) throw std::runtime_error("reference ELF has no exports");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string NormalizeExportName(const std::string& name) {
|
||||
if (name.ends_with(Internal::kNidPostfix)) return name.substr(0, name.size() - Internal::kNidPostfixLen);
|
||||
return name;
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> ReadExportExclusions(const std::string& path) {
|
||||
if constexpr (std::endian::native != std::endian::little) throw std::runtime_error("export references require a little-endian host");
|
||||
std::ifstream input(path, std::ios::binary | std::ios::ate);
|
||||
if (!input) throw std::runtime_error("cannot open export reference: " + path);
|
||||
const auto size = input.tellg();
|
||||
if (size <= 0) throw std::runtime_error("empty or unreadable export reference: " + path);
|
||||
std::vector<std::uint8_t> binary(static_cast<std::size_t>(size));
|
||||
input.seekg(0);
|
||||
if (!input.read(reinterpret_cast<char*>(binary.data()), static_cast<std::streamsize>(binary.size()))) throw std::runtime_error("cannot read export reference: " + path);
|
||||
std::unordered_set<std::string> exports;
|
||||
if (binary.size() >= 2 && binary[0] == 'M' && binary[1] == 'Z') {
|
||||
exports = ReadPeExports(binary);
|
||||
} else if (binary.size() >= 4 && binary[0] == 0x7f && binary[1] == 'E' && binary[2] == 'L' && binary[3] == 'F') {
|
||||
exports = ReadElfExports(binary);
|
||||
} else {
|
||||
throw std::runtime_error("unrecognized export reference format: " + path);
|
||||
}
|
||||
std::unordered_set<std::string> result;
|
||||
result.reserve(exports.size());
|
||||
for (const auto& name : exports) {
|
||||
auto normalized = NormalizeExportName(name);
|
||||
if (normalized.empty()) throw std::runtime_error("empty normalized export reference name");
|
||||
result.insert(std::move(normalized));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#include <nid/NidCompute.hpp>
|
||||
#include <nid/Sha1.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
constexpr uint8_t kNidSuffix[16] = {
|
||||
0x51, 0x8D, 0x64, 0xA6, 0x35, 0xDE, 0xD8, 0xC1,
|
||||
0xE6, 0xB0, 0x39, 0xB1, 0xC3, 0xE5, 0x52, 0x30
|
||||
};
|
||||
|
||||
constexpr char kBase64S[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
|
||||
|
||||
std::string ComputeNid(const std::string& symbolName, const std::string& libraryName) {
|
||||
if (symbolName.empty())
|
||||
throw std::invalid_argument("symbolName is empty");
|
||||
|
||||
std::vector<uint8_t> input;
|
||||
input.reserve(symbolName.size() + 16u);
|
||||
for (char c : symbolName)
|
||||
input.push_back(static_cast<uint8_t>(c));
|
||||
for (uint8_t b : kNidSuffix)
|
||||
input.push_back(b);
|
||||
|
||||
const auto digest = Sha1(input);
|
||||
|
||||
uint8_t reversed[8];
|
||||
for (int i = 0; i < 8; i++)
|
||||
reversed[i] = digest[7 - i];
|
||||
|
||||
char nid[12];
|
||||
int nidIndex = 0;
|
||||
for (int i = 0; i < 6; i += 3) {
|
||||
const uint32_t triple = (static_cast<uint32_t>(reversed[i]) << 16) |
|
||||
(static_cast<uint32_t>(reversed[i + 1]) << 8) |
|
||||
static_cast<uint32_t>(reversed[i + 2]);
|
||||
nid[nidIndex++] = kBase64S[(triple >> 18) & 0x3F];
|
||||
nid[nidIndex++] = kBase64S[(triple >> 12) & 0x3F];
|
||||
nid[nidIndex++] = kBase64S[(triple >> 6) & 0x3F];
|
||||
nid[nidIndex++] = kBase64S[triple & 0x3F];
|
||||
}
|
||||
const uint32_t tail = (static_cast<uint32_t>(reversed[6]) << 16) |
|
||||
(static_cast<uint32_t>(reversed[7]) << 8);
|
||||
nid[nidIndex++] = kBase64S[(tail >> 18) & 0x3F];
|
||||
nid[nidIndex++] = kBase64S[(tail >> 12) & 0x3F];
|
||||
nid[nidIndex++] = kBase64S[(tail >> 6) & 0x3F];
|
||||
nid[11] = '\0';
|
||||
|
||||
return std::string(nid, 11);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
#include <nid/NidResolver.hpp>
|
||||
#include <nid/ExportExclusions.hpp>
|
||||
#include <nid/NidCompute.hpp>
|
||||
#include <nid/NidPatcherUtils.hpp>
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
std::string ResolveOneName(const std::string& funcName) {
|
||||
using namespace Internal;
|
||||
|
||||
if (IsNidNoPatchCut(funcName))
|
||||
return StripNidNoPatchCut(funcName);
|
||||
if (IsNidNoPatch(funcName))
|
||||
return funcName;
|
||||
|
||||
return ComputeNid(StripNidPostfix(funcName), "");
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string> ResolveNids(const std::vector<std::string>& exportedNames, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) {
|
||||
using namespace Internal;
|
||||
|
||||
std::unordered_set<std::string> nameSet(exportedNames.begin(), exportedNames.end());
|
||||
|
||||
if (nameSet.size() != exportedNames.size()) {
|
||||
for (std::size_t i = 0u; i < exportedNames.size(); ++i) {
|
||||
for (std::size_t j = i + 1u; j < exportedNames.size(); ++j) {
|
||||
if (exportedNames[i] == exportedNames[j])
|
||||
throw std::runtime_error("duplicate exported symbol \"" + exportedNames[i] + "\" in library \"" + libraryName + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string> result;
|
||||
result.reserve(exportedNames.size());
|
||||
|
||||
for (const std::string& name : exportedNames) {
|
||||
if (excludedExports.contains(NormalizeExportName(name))) {
|
||||
result[name] = name;
|
||||
continue;
|
||||
}
|
||||
if (IsNidNoPatchCut(name)) {
|
||||
result[name] = StripNidNoPatchCut(name);
|
||||
continue;
|
||||
}
|
||||
if (IsNidNoPatch(name)) {
|
||||
result[name] = name;
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string stripped = StripNidPostfix(name);
|
||||
const bool hasPostfix = stripped != name;
|
||||
|
||||
if (!hasPostfix && nameSet.count(name + kNidPostfix)) {
|
||||
result[name] = name;
|
||||
continue;
|
||||
}
|
||||
|
||||
result[name] = ComputeNid(stripped, libraryName);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
#include <nid/PeNidPatcher.hpp>
|
||||
#include <nid/NidResolver.hpp>
|
||||
#include <nid/NidPatcherUtils.hpp>
|
||||
#include <nid/NidCompute.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
namespace {
|
||||
|
||||
std::size_t FindSectionOffsetByRva(const std::vector<std::uint8_t>& pe, std::uint32_t rva, std::uint32_t peHeaderOffset, std::uint16_t numberOfSections, std::uint32_t sizeOfOptionalHeader) {
|
||||
const std::size_t sectionTableOffset = static_cast<std::size_t>(peHeaderOffset) + 4u + 20u + sizeOfOptionalHeader;
|
||||
for (std::uint16_t i = 0u; i < numberOfSections; ++i) {
|
||||
const std::size_t sectionOffset = sectionTableOffset + i * sizeof(PeSectionHeader);
|
||||
if (sectionOffset + sizeof(PeSectionHeader) > pe.size()) throw std::runtime_error("section header out of bounds");
|
||||
const auto section = Internal::Read<PeSectionHeader>(pe, sectionOffset);
|
||||
const std::uint32_t effectiveSize = section.VirtualSize != 0u ? section.VirtualSize : section.SizeOfRawData;
|
||||
if (rva >= section.VirtualAddress && rva < section.VirtualAddress + effectiveSize)
|
||||
return sectionOffset;
|
||||
}
|
||||
throw std::runtime_error("rva not mapped to any section");
|
||||
}
|
||||
|
||||
std::size_t RvaToOffset(const std::vector<std::uint8_t>& pe, std::uint32_t rva, std::uint32_t peHeaderOffset, std::uint16_t numberOfSections, std::uint32_t sizeOfOptionalHeader) {
|
||||
const std::size_t sectionOffset = FindSectionOffsetByRva(pe, rva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
const auto section = Internal::Read<PeSectionHeader>(pe, sectionOffset);
|
||||
return static_cast<std::size_t>(section.PointerToRawData) + (rva - section.VirtualAddress);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const {
|
||||
using namespace Internal;
|
||||
|
||||
if (pe.size() < 0x40) throw std::runtime_error("file too small");
|
||||
|
||||
const auto peHeaderOffset = Read<std::uint32_t>(pe, 0x3cu);
|
||||
if (static_cast<std::size_t>(peHeaderOffset) + 4u > pe.size()) throw std::runtime_error("invalid pe header offset");
|
||||
if (pe[peHeaderOffset] != 'P' || pe[peHeaderOffset + 1u] != 'E' || pe[peHeaderOffset + 2u] != 0u || pe[peHeaderOffset + 3u] != 0u)
|
||||
throw std::runtime_error("not a PE file");
|
||||
|
||||
const std::size_t coffHeaderOffset = static_cast<std::size_t>(peHeaderOffset) + 4u;
|
||||
const auto numberOfSections = Read<std::uint16_t>(pe, coffHeaderOffset + 2u);
|
||||
const auto sizeOfOptionalHeader = Read<std::uint16_t>(pe, coffHeaderOffset + 16u);
|
||||
if (sizeOfOptionalHeader == 0u) throw std::runtime_error("no optional header");
|
||||
|
||||
const std::size_t sectionTableOffset = coffHeaderOffset + 20u + sizeOfOptionalHeader;
|
||||
const auto symbolTable = Read<std::uint32_t>(pe, coffHeaderOffset + 8u);
|
||||
const auto symbolCount = Read<std::uint32_t>(pe, coffHeaderOffset + 12u);
|
||||
for (std::uint16_t i = 0; i < numberOfSections; ++i) {
|
||||
const auto offset = sectionTableOffset + i * sizeof(PeSectionHeader);
|
||||
auto section = Read<PeSectionHeader>(pe, offset);
|
||||
if (pe[offset] != '/' || !symbolTable) continue;
|
||||
const std::string reference(reinterpret_cast<const char*>(pe.data() + offset), 8);
|
||||
const auto stringOffset = std::stoul(reference.substr(1));
|
||||
const auto name = ReadCStr(pe, static_cast<std::size_t>(symbolTable) + static_cast<std::size_t>(symbolCount) * 18 + stringOffset);
|
||||
if (name == ".eh_frame") {
|
||||
const char shortName[8] = ".ehfram";
|
||||
std::memcpy(pe.data() + offset, shortName, 8);
|
||||
}
|
||||
}
|
||||
|
||||
const std::size_t optionalHeaderOffset = coffHeaderOffset + 20u;
|
||||
const auto magic = Read<std::uint16_t>(pe, optionalHeaderOffset);
|
||||
|
||||
std::size_t dataDirectoryOffset;
|
||||
if (magic == 0x20bu) {
|
||||
dataDirectoryOffset = optionalHeaderOffset + 112u;
|
||||
} else if (magic == 0x10bu) {
|
||||
dataDirectoryOffset = optionalHeaderOffset + 96u;
|
||||
} else {
|
||||
throw std::runtime_error("unsupported optional header magic");
|
||||
}
|
||||
|
||||
const auto exportDir = Read<PeDataDirectory>(pe, dataDirectoryOffset);
|
||||
if (exportDir.VirtualAddress == 0u) throw std::runtime_error("no export directory");
|
||||
|
||||
const std::size_t exportDirOffset = RvaToOffset(pe, exportDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
const auto exportTable = Read<PeExportDirectory>(pe, exportDirOffset);
|
||||
|
||||
if (exportTable.NumberOfNames == 0u) throw std::runtime_error("no exported names");
|
||||
|
||||
const std::size_t namesArrayOffset = RvaToOffset(pe, exportTable.AddressOfNames, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
const std::size_t ordinalsArrayOffset = RvaToOffset(pe, exportTable.AddressOfNameOrdinals, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
|
||||
std::vector<std::uint32_t> nameRvas(exportTable.NumberOfNames);
|
||||
std::vector<std::string> names(exportTable.NumberOfNames);
|
||||
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
|
||||
const auto nameRva = Read<std::uint32_t>(pe, namesArrayOffset + i * 4u);
|
||||
const std::size_t nameOffset = RvaToOffset(pe, nameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
const std::string name = ReadCStr(pe, nameOffset);
|
||||
if (name.empty()) throw std::runtime_error("empty exported name");
|
||||
nameRvas[i] = nameRva;
|
||||
names[i] = name;
|
||||
}
|
||||
|
||||
const auto nidMap = ResolveNids(names, libraryName, excludedExports);
|
||||
|
||||
const std::size_t edataSectionOffset = FindSectionOffsetByRva(pe, exportDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
const auto edataSection = Read<PeSectionHeader>(pe, edataSectionOffset);
|
||||
|
||||
const auto fileAlignment = Read<std::uint32_t>(pe, optionalHeaderOffset + 36u);
|
||||
if (fileAlignment == 0u) throw std::runtime_error("invalid file alignment");
|
||||
|
||||
std::uint32_t stringsRegionStart = std::numeric_limits<std::uint32_t>::max();
|
||||
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
|
||||
const std::uint32_t rvaFromSection = nameRvas[i] - edataSection.VirtualAddress;
|
||||
if (rvaFromSection < stringsRegionStart) stringsRegionStart = rvaFromSection;
|
||||
}
|
||||
if (stringsRegionStart == std::numeric_limits<std::uint32_t>::max())
|
||||
throw std::runtime_error("could not determine strings region start");
|
||||
|
||||
const std::uint32_t rawLimit = ((edataSection.SizeOfRawData + fileAlignment - 1u) / fileAlignment) * fileAlignment;
|
||||
|
||||
std::vector<std::string> finalNames(exportTable.NumberOfNames);
|
||||
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
|
||||
const auto it = nidMap.find(names[i]);
|
||||
if (it == nidMap.end()) throw std::runtime_error("symbol not in nid map: " + names[i]);
|
||||
finalNames[i] = it->second;
|
||||
}
|
||||
|
||||
std::uint32_t requiredSize = stringsRegionStart;
|
||||
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i)
|
||||
requiredSize += static_cast<std::uint32_t>(finalNames[i].size()) + 1u;
|
||||
|
||||
if (requiredSize > rawLimit)
|
||||
throw std::runtime_error("not enough raw space in edata section to repack export names");
|
||||
|
||||
std::uint32_t writeOffset = stringsRegionStart;
|
||||
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
|
||||
const std::uint32_t newNameRva = edataSection.VirtualAddress + writeOffset;
|
||||
const std::size_t newNameFileOffset = static_cast<std::size_t>(edataSection.PointerToRawData) + writeOffset;
|
||||
|
||||
if (newNameFileOffset + finalNames[i].size() + 1u > pe.size())
|
||||
throw std::runtime_error("repack write out of file bounds");
|
||||
|
||||
std::memcpy(pe.data() + newNameFileOffset, finalNames[i].data(), finalNames[i].size());
|
||||
pe[newNameFileOffset + finalNames[i].size()] = 0u;
|
||||
Write(pe, namesArrayOffset + i * 4u, newNameRva);
|
||||
writeOffset += static_cast<std::uint32_t>(finalNames[i].size()) + 1u;
|
||||
}
|
||||
|
||||
const std::uint32_t newVirtualSize = std::max(edataSection.VirtualSize, writeOffset);
|
||||
auto patchedSection = edataSection;
|
||||
patchedSection.VirtualSize = newVirtualSize;
|
||||
Write(pe, edataSectionOffset, patchedSection);
|
||||
|
||||
struct ExportName {
|
||||
std::string Name;
|
||||
std::uint32_t Rva;
|
||||
std::uint16_t Ordinal;
|
||||
};
|
||||
|
||||
std::vector<ExportName> exportNames;
|
||||
exportNames.reserve(exportTable.NumberOfNames);
|
||||
for (std::size_t i = 0; i < exportTable.NumberOfNames; ++i) {
|
||||
const auto nameRva = Read<std::uint32_t>(pe, namesArrayOffset + i * sizeof(std::uint32_t));
|
||||
const auto ordinal = Read<std::uint16_t>(pe, ordinalsArrayOffset + i * sizeof(std::uint16_t));
|
||||
if (ordinal >= exportTable.NumberOfFunctions)
|
||||
throw std::runtime_error("export name ordinal out of bounds");
|
||||
const auto nameOffset = RvaToOffset(pe, nameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
exportNames.push_back({ReadCStr(pe, nameOffset), nameRva, ordinal});
|
||||
}
|
||||
std::sort(exportNames.begin(), exportNames.end(), [](const ExportName& left, const ExportName& right) { return left.Name < right.Name; });
|
||||
for (std::size_t i = 0; i < exportNames.size(); ++i) {
|
||||
if (i != 0 && exportNames[i - 1].Name == exportNames[i].Name)
|
||||
throw std::runtime_error("duplicate patched export name: " + exportNames[i].Name);
|
||||
Write(pe, namesArrayOffset + i * sizeof(std::uint32_t), exportNames[i].Rva);
|
||||
Write(pe, ordinalsArrayOffset + i * sizeof(std::uint16_t), exportNames[i].Ordinal);
|
||||
}
|
||||
|
||||
constexpr std::size_t kImportDirIndex = 1u;
|
||||
if (dataDirectoryOffset + (kImportDirIndex + 1u) * sizeof(PeDataDirectory) > pe.size())
|
||||
return;
|
||||
|
||||
const auto importDir = Read<PeDataDirectory>(pe, dataDirectoryOffset + kImportDirIndex * sizeof(PeDataDirectory));
|
||||
if (importDir.VirtualAddress == 0u || importDir.Size == 0u)
|
||||
return;
|
||||
|
||||
struct PeImportDescriptor {
|
||||
std::uint32_t OriginalFirstThunk;
|
||||
std::uint32_t TimeDateStamp;
|
||||
std::uint32_t ForwarderChain;
|
||||
std::uint32_t Name;
|
||||
std::uint32_t FirstThunk;
|
||||
};
|
||||
|
||||
std::size_t importDescOffset = RvaToOffset(pe, importDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
|
||||
while (true) {
|
||||
if (importDescOffset + sizeof(PeImportDescriptor) > pe.size())
|
||||
throw std::runtime_error("import descriptor out of bounds");
|
||||
|
||||
const auto desc = Read<PeImportDescriptor>(pe, importDescOffset);
|
||||
if (desc.OriginalFirstThunk == 0u && desc.FirstThunk == 0u)
|
||||
break;
|
||||
|
||||
const std::uint32_t thunkRva = desc.OriginalFirstThunk != 0u ? desc.OriginalFirstThunk : desc.FirstThunk;
|
||||
std::size_t thunkOffset = RvaToOffset(pe, thunkRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
|
||||
const bool is64 = magic == 0x20bu;
|
||||
const std::size_t thunkEntrySize = is64 ? 8u : 4u;
|
||||
const std::uint64_t ordinalFlag = is64 ? (std::uint64_t{1} << 63u) : (std::uint64_t{1} << 31u);
|
||||
|
||||
while (true) {
|
||||
if (thunkOffset + thunkEntrySize > pe.size())
|
||||
throw std::runtime_error("thunk entry out of bounds");
|
||||
|
||||
const std::uint64_t thunk = is64
|
||||
? Read<std::uint64_t>(pe, thunkOffset)
|
||||
: static_cast<std::uint64_t>(Read<std::uint32_t>(pe, thunkOffset));
|
||||
|
||||
if (thunk == 0u)
|
||||
break;
|
||||
|
||||
if (!(thunk & ordinalFlag)) {
|
||||
const auto hintNameRva = static_cast<std::uint32_t>(thunk & 0x7fffffffffffffffu);
|
||||
const std::size_t hintNameOffset = RvaToOffset(pe, hintNameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
if (hintNameOffset + 2u >= pe.size())
|
||||
throw std::runtime_error("import by name out of bounds");
|
||||
|
||||
const std::string funcName = ReadCStr(pe, hintNameOffset + 2u);
|
||||
if (!funcName.empty()) {
|
||||
const bool hasNidPostfix = funcName.size() >= kNidPostfixLen &&
|
||||
funcName.compare(funcName.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0;
|
||||
const bool hasScePrefix = funcName.size() >= 3u &&
|
||||
std::tolower(static_cast<unsigned char>(funcName[0])) == 's' &&
|
||||
std::tolower(static_cast<unsigned char>(funcName[1])) == 'c' &&
|
||||
std::tolower(static_cast<unsigned char>(funcName[2])) == 'e';
|
||||
if (hasNidPostfix || hasScePrefix) {
|
||||
const std::string nid = ResolveOneName(funcName);
|
||||
if (nid.size() > funcName.size())
|
||||
throw std::runtime_error("import NID longer than original name: " + funcName);
|
||||
std::memcpy(pe.data() + hintNameOffset + 2u, nid.data(), nid.size());
|
||||
pe[hintNameOffset + 2u + nid.size()] = 0u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thunkOffset += thunkEntrySize;
|
||||
}
|
||||
|
||||
importDescOffset += sizeof(PeImportDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
#include <nid/Sha1.hpp>
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace Nid {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::uint32_t _rotl32(std::uint32_t x, unsigned n) {
|
||||
return (x << n) | (x >> (32u - n));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::array<std::uint8_t, 20> Sha1(const std::vector<std::uint8_t>& data) {
|
||||
std::uint32_t h0 = 0x67452301u;
|
||||
std::uint32_t h1 = 0xEFCDAB89u;
|
||||
std::uint32_t h2 = 0x98BADCFEu;
|
||||
std::uint32_t h3 = 0x10325476u;
|
||||
std::uint32_t h4 = 0xC3D2E1F0u;
|
||||
|
||||
std::vector<std::uint8_t> msg(data);
|
||||
|
||||
const std::uint64_t bitLen = static_cast<std::uint64_t>(data.size()) * 8u;
|
||||
|
||||
msg.push_back(0x80u);
|
||||
while ((msg.size() % 64u) != 56u)
|
||||
msg.push_back(0x00u);
|
||||
|
||||
for (int i = 7; i >= 0; --i)
|
||||
msg.push_back(static_cast<std::uint8_t>((bitLen >> (i * 8u)) & 0xffu));
|
||||
|
||||
for (std::size_t offset = 0; offset < msg.size(); offset += 64u) {
|
||||
std::uint32_t w[80];
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
w[i] = (static_cast<std::uint32_t>(msg[offset + i * 4u + 0u]) << 24u)
|
||||
| (static_cast<std::uint32_t>(msg[offset + i * 4u + 1u]) << 16u)
|
||||
| (static_cast<std::uint32_t>(msg[offset + i * 4u + 2u]) << 8u)
|
||||
| (static_cast<std::uint32_t>(msg[offset + i * 4u + 3u]));
|
||||
}
|
||||
for (int i = 16; i < 80; ++i)
|
||||
w[i] = _rotl32(w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16], 1u);
|
||||
|
||||
std::uint32_t a = h0, b = h1, c = h2, d = h3, e = h4;
|
||||
|
||||
for (int i = 0; i < 80; ++i) {
|
||||
std::uint32_t f, k;
|
||||
if (i < 20) {
|
||||
f = (b & c) | ((~b) & d);
|
||||
k = 0x5A827999u;
|
||||
} else if (i < 40) {
|
||||
f = b ^ c ^ d;
|
||||
k = 0x6ED9EBA1u;
|
||||
} else if (i < 60) {
|
||||
f = (b & c) | (b & d) | (c & d);
|
||||
k = 0x8F1BBCDCu;
|
||||
} else {
|
||||
f = b ^ c ^ d;
|
||||
k = 0xCA62C1D6u;
|
||||
}
|
||||
std::uint32_t temp = _rotl32(a, 5u) + f + e + k + w[i];
|
||||
e = d; d = c; c = _rotl32(b, 30u); b = a; a = temp;
|
||||
}
|
||||
|
||||
h0 += a; h1 += b; h2 += c; h3 += d; h4 += e;
|
||||
}
|
||||
|
||||
std::array<std::uint8_t, 20> digest;
|
||||
auto _put = [&](int base, std::uint32_t v) {
|
||||
digest[base+0] = static_cast<std::uint8_t>(v >> 24u);
|
||||
digest[base+1] = static_cast<std::uint8_t>(v >> 16u);
|
||||
digest[base+2] = static_cast<std::uint8_t>(v >> 8u);
|
||||
digest[base+3] = static_cast<std::uint8_t>(v);
|
||||
};
|
||||
_put(0, h0); _put(4, h1); _put(8, h2); _put(12, h3); _put(16, h4);
|
||||
return digest;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
#include <nid/BinaryPatcherFactory.hpp>
|
||||
#include <nid/ExportExclusions.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<std::uint8_t> _readFile(const std::string& path) {
|
||||
std::ifstream f(path, std::ios::binary);
|
||||
if (!f) throw std::runtime_error("cannot open: " + path);
|
||||
return {std::istreambuf_iterator<char>(f), {}};
|
||||
}
|
||||
|
||||
void _writeFile(const std::string& path, const std::vector<std::uint8_t>& data) {
|
||||
std::ofstream f(path, std::ios::binary);
|
||||
if (!f) throw std::runtime_error("cannot write: " + path);
|
||||
f.write(reinterpret_cast<const char*>(data.data()), static_cast<std::streamsize>(data.size()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc < 3) {
|
||||
std::cerr << "Usage: nid_patcher <library_name> [--preserve-exports <unpatched-library>] <file> [file2 ...]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string libraryName = argv[1];
|
||||
std::unordered_set<std::string> excludedExports;
|
||||
std::vector<std::string> paths;
|
||||
try {
|
||||
bool hasReference = false;
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string argument = argv[i];
|
||||
if (argument == "--preserve-exports") {
|
||||
if (hasReference || i + 1 == argc) throw std::runtime_error("--preserve-exports requires exactly one reference library");
|
||||
hasReference = true;
|
||||
excludedExports = Nid::ReadExportExclusions(argv[++i]);
|
||||
} else {
|
||||
if (argument.starts_with("--")) throw std::runtime_error("unknown option: " + argument);
|
||||
paths.push_back(argument);
|
||||
}
|
||||
}
|
||||
if (paths.empty()) throw std::runtime_error("no files to patch");
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "FAIL: " << e.what() << '\n';
|
||||
return 2;
|
||||
}
|
||||
|
||||
for (const std::string& path : paths) {
|
||||
try {
|
||||
auto binary = _readFile(path);
|
||||
const auto patcher = Nid::MakePatcher(binary);
|
||||
patcher->PatchNids(binary, libraryName, excludedExports);
|
||||
_writeFile(path, binary);
|
||||
std::cout << "OK: " << path << "\n";
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "FAIL: " << path << ": " << e.what() << "\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI ErrorDialogClose(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ErrorDialogOpen(const void* param) {
|
||||
(void)param;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ShareGetCurrentStatus(uint32_t feature_flag, ShareCurrentStatus* status) {
|
||||
(void)feature_flag;
|
||||
(void)status;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ShareInitialize(size_t heap_size, int thread_priority, uint64_t affinity_mask) {
|
||||
(void)heap_size;
|
||||
(void)thread_priority;
|
||||
(void)affinity_mask;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ShareTerminate(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI SystemServiceParamGetInt(int param_id, int* value) {
|
||||
(void)param_id;
|
||||
(void)value;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI SystemServiceParamGetString(int param_id, char* buf, size_t buf_size) {
|
||||
(void)param_id;
|
||||
(void)buf;
|
||||
(void)buf_size;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI RemotePlayGetConnectionStatus(int user_id, int* status) {
|
||||
(void)user_id;
|
||||
(void)status;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ShareGetCurrentStatus(uint32_t feature_flag, ShareCurrentStatus* status) {
|
||||
(void)feature_flag;
|
||||
(void)status;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ShareInitialize(size_t heap_size, int thread_priority, uint64_t affinity_mask) {
|
||||
(void)heap_size;
|
||||
(void)thread_priority;
|
||||
(void)affinity_mask;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI ShareTerminate(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
APS5_EXPORT("0DsDTr534gc", renoirStub00);
|
||||
uint64_t APS5_VABI renoirStub00(void) {
|
||||
NotImplemented_nid_no_patch("0DsDTr534gc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("2T56HgbPW08", renoirStub01);
|
||||
uint64_t APS5_VABI renoirStub01(void) {
|
||||
NotImplemented_nid_no_patch("2T56HgbPW08");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("3HnCozh8Az8", renoirStub02);
|
||||
uint64_t APS5_VABI renoirStub02(void) {
|
||||
NotImplemented_nid_no_patch("3HnCozh8Az8");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("5Ysce+s-CWU", renoirStub03);
|
||||
uint64_t APS5_VABI renoirStub03(void) {
|
||||
NotImplemented_nid_no_patch("5Ysce+s-CWU");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("AdlSqA4lGS8", renoirStub04);
|
||||
uint64_t APS5_VABI renoirStub04(void) {
|
||||
NotImplemented_nid_no_patch("AdlSqA4lGS8");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("bC37hk7rHqs", renoirStub05);
|
||||
uint64_t APS5_VABI renoirStub05(void) {
|
||||
NotImplemented_nid_no_patch("bC37hk7rHqs");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("dfPK9R6M0qM", renoirStub06);
|
||||
uint64_t APS5_VABI renoirStub06(void) {
|
||||
NotImplemented_nid_no_patch("dfPK9R6M0qM");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("fZiBbVa2ZDU", renoirStub07);
|
||||
uint64_t APS5_VABI renoirStub07(void) {
|
||||
NotImplemented_nid_no_patch("fZiBbVa2ZDU");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("hkWBH8-WfW4", renoirStub08);
|
||||
uint64_t APS5_VABI renoirStub08(void) {
|
||||
NotImplemented_nid_no_patch("hkWBH8-WfW4");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("hUxvGdi64Io", renoirStub09);
|
||||
uint64_t APS5_VABI renoirStub09(void) {
|
||||
NotImplemented_nid_no_patch("hUxvGdi64Io");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("NxqsZxGisrA", renoirStub10);
|
||||
uint64_t APS5_VABI renoirStub10(void) {
|
||||
NotImplemented_nid_no_patch("NxqsZxGisrA");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("OgZVIkaNmb0", renoirStub11);
|
||||
uint64_t APS5_VABI renoirStub11(void) {
|
||||
NotImplemented_nid_no_patch("OgZVIkaNmb0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("ojLQdRUnVgA", renoirStub12);
|
||||
uint64_t APS5_VABI renoirStub12(void) {
|
||||
NotImplemented_nid_no_patch("ojLQdRUnVgA");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("s0qDfgsAgVg", renoirStub13);
|
||||
uint64_t APS5_VABI renoirStub13(void) {
|
||||
NotImplemented_nid_no_patch("s0qDfgsAgVg");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("sgrd-r1Nw60", renoirStub14);
|
||||
uint64_t APS5_VABI renoirStub14(void) {
|
||||
NotImplemented_nid_no_patch("sgrd-r1Nw60");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("sjTRb8YD7dQ", renoirStub15);
|
||||
uint64_t APS5_VABI renoirStub15(void) {
|
||||
NotImplemented_nid_no_patch("sjTRb8YD7dQ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("tG86XGc2VtE", renoirStub16);
|
||||
uint64_t APS5_VABI renoirStub16(void) {
|
||||
NotImplemented_nid_no_patch("tG86XGc2VtE");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("umlGxOcNzgc", renoirStub17);
|
||||
uint64_t APS5_VABI renoirStub17(void) {
|
||||
NotImplemented_nid_no_patch("umlGxOcNzgc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("vPxA9OFW0os", renoirStub18);
|
||||
uint64_t APS5_VABI renoirStub18(void) {
|
||||
NotImplemented_nid_no_patch("vPxA9OFW0os");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("X2qEBlOLkNo", renoirStub19);
|
||||
uint64_t APS5_VABI renoirStub19(void) {
|
||||
NotImplemented_nid_no_patch("X2qEBlOLkNo");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("ynh4E+BIaqY", renoirStub20);
|
||||
uint64_t APS5_VABI renoirStub20(void) {
|
||||
NotImplemented_nid_no_patch("ynh4E+BIaqY");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("YXe6ABbHZPs", renoirStub21);
|
||||
uint64_t APS5_VABI renoirStub21(void) {
|
||||
NotImplemented_nid_no_patch("YXe6ABbHZPs");
|
||||
return 0;
|
||||
}
|
||||
|
||||
APS5_EXPORT("z0jsXZVz75I", renoirStub22);
|
||||
uint64_t APS5_VABI renoirStub22(void) {
|
||||
NotImplemented_nid_no_patch("z0jsXZVz75I");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include <atomic>
|
||||
|
||||
// Audio co-processor batches complete immediately without producing output; audio is silent.
|
||||
static constexpr int SCE_ACM_ERROR_INVALID_PARAMETER = static_cast<int>(0x80E30002);
|
||||
static std::atomic<uint32_t> g_nextId{1};
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceAcmBatchStartBuffer(AcmContextId context, const void* batch_commands, size_t batch_size, AcmBatchError* batch_error, AcmBatchId* batch) {
|
||||
(void)context;
|
||||
(void)batch_commands;
|
||||
(void)batch_size;
|
||||
(void)batch_error;
|
||||
if (!batch) return SCE_ACM_ERROR_INVALID_PARAMETER;
|
||||
*batch = g_nextId.fetch_add(1, std::memory_order_relaxed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAcmBatchStartBuffers(AcmContextId context, uint32_t batch_info_count, const AcmBatchInfo* const batch_info[], AcmBatchError* batch_error, AcmBatchId* batch) {
|
||||
(void)context;
|
||||
(void)batch_info_count;
|
||||
(void)batch_info;
|
||||
(void)batch_error;
|
||||
if (!batch) return SCE_ACM_ERROR_INVALID_PARAMETER;
|
||||
*batch = g_nextId.fetch_add(1, std::memory_order_relaxed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAcmBatchWait(AcmContextId context, AcmBatchId batch, uint32_t timeout) {
|
||||
(void)context;
|
||||
(void)batch;
|
||||
(void)timeout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAcmContextCreate(AcmContextId* context) {
|
||||
if (!context) return SCE_ACM_ERROR_INVALID_PARAMETER;
|
||||
*context = g_nextId.fetch_add(1, std::memory_order_relaxed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceAcmContextDestroy(AcmContextId context) {
|
||||
(void)context;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Builds a convolution-reverb command into a batch; batches execute as no-ops, so nothing is encoded.
|
||||
int APS5_VABI sceAcm_ConvReverb_SharedInput(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_CONTROL_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_CONTROL_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_DISPATCH_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_DISPATCH_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_MEMORY_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_MEMORY_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_SYNC_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_SYNC_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,92 +0,0 @@
|
||||
#include "prx/libSceAgc/Acb/include/Control.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include "prx/libSceAgc/DcbState/include/Marker.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
// unknown signature
|
||||
APS5_EXPORT("gQkqkLttcpw", sceAgcAcb_gQkqkLttcpw);
|
||||
void* APS5_VABI sceAgcAcb_gQkqkLttcpw (void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbJump(CommandBuffer* buf, std::uint8_t cachePolicy, const std::uint32_t* target, std::uint32_t sizeInDwords) {
|
||||
(void)buf;
|
||||
(void)cachePolicy;
|
||||
(void)target;
|
||||
(void)sizeInDwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcAcbJumpGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Encoded as the custom DISPATCH_RESET NOP packet the driver consumes on compute queues.
|
||||
uint32_t* APS5_VABI sceAgcAcbResetQueue(CommandBuffer* buf, uint32_t op, uint32_t value) {
|
||||
(void)value;
|
||||
Agc::Command::Require(buf != nullptr, __func__, "null command buffer");
|
||||
constexpr std::uint32_t OpcodeNop = 0x10;
|
||||
constexpr std::uint32_t CustomDispatchReset = 0x09;
|
||||
auto* packet = Agc::Command::Allocate(buf, 2, __func__);
|
||||
packet[0] = Agc::Command::Header(OpcodeNop, 2, CustomDispatchReset << 2);
|
||||
packet[1] = op;
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbRewind(CommandBuffer* buf, std::uint32_t initialState) {
|
||||
(void)buf;
|
||||
(void)initialState;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbRewindGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbWaitUntilSafeForRendering(CommandBuffer* buf, std::uint32_t videoOutHandle, std::uint32_t displayBufferIndex) {
|
||||
(void)buf;
|
||||
(void)videoOutHandle;
|
||||
(void)displayBufferIndex;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbSetFlip(CommandBuffer* buf, std::uint32_t videoOutHandle, std::int32_t displayBufferIndex, std::uint32_t flipMode, std::int64_t flipArg) {
|
||||
(void)buf;
|
||||
(void)videoOutHandle;
|
||||
(void)displayBufferIndex;
|
||||
(void)flipMode;
|
||||
(void)flipArg;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbPushMarker(CommandBuffer* buf, const char* str, uint32_t color) {
|
||||
(void)color;
|
||||
return Agc::Marker::Push(buf, str, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbPopMarker(CommandBuffer* buf) {
|
||||
return Agc::Marker::Pop(buf, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbSetMarker(CommandBuffer* buf, const char* str, uint32_t color) {
|
||||
(void)color;
|
||||
auto* packet = Agc::Marker::Push(buf, str, __func__);
|
||||
Agc::Marker::Pop(buf, __func__);
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#include "prx/libSceAgc/Acb/include/Dispatch.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbDispatchIndirect(CommandBuffer* buf, const volatile void* indirect_args, uint32_t modifier) {
|
||||
// Compute queues take the argument address directly (DISPATCH_INDIRECT with a 64-bit address).
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(indirect_args);
|
||||
Agc::Command::CheckAddress(address, 4, __func__);
|
||||
Agc::Command::CheckBits(modifier, 0xa038u | 0x41u, __func__);
|
||||
return Agc::Command::Emit(buf, 0x16u, {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), modifier | 0x41u}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbDispatchIndirectGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
#include "prx/libSceAgc/Acb/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/DcbFlow/include/Memory.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbAcquireMem(CommandBuffer* buf, std::uint32_t gcrControl, const volatile void* base, std::uint64_t sizeBytes, std::uint32_t pollCycles) {
|
||||
return sceAgcDcbAcquireMem(buf, 1, 0, gcrControl, base, sizeBytes, pollCycles);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcAcbAcquireMemGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbCopyData(CommandBuffer* buf, uint8_t dst, uint8_t dst_cache_policy, uint64_t dst_address, uint8_t src, uint8_t src_cache_policy, uint64_t src_address_or_immediate, uint8_t item_size, uint8_t write_confirm) {
|
||||
(void)buf;
|
||||
(void)dst;
|
||||
(void)dst_cache_policy;
|
||||
(void)dst_address;
|
||||
(void)src;
|
||||
(void)src_cache_policy;
|
||||
(void)src_address_or_immediate;
|
||||
(void)item_size;
|
||||
(void)write_confirm;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint64_t APS5_VABI sceAgcAcbCopyDataGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbDmaData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm) {
|
||||
return Agc::Command::WriteDma(buf, true, 0, dst, dstCachePolicy, dstAddress, src, srcCachePolicy, srcAddress, numBytes, waitForPrevious, writeConfirm, 0, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbDmaDataGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbAtomicMem(CommandBuffer* buf, std::uint8_t atomicOp, std::uint8_t command, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t srcData, std::uint64_t compareData, std::uint16_t loopInterval) {
|
||||
(void)buf;
|
||||
(void)atomicOp;
|
||||
(void)command;
|
||||
(void)cachePolicy;
|
||||
(void)address;
|
||||
(void)srcData;
|
||||
(void)compareData;
|
||||
(void)loopInterval;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbAtomicMemGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbAtomicGdsGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbPrimeUtcl2(CommandBuffer* buf, const volatile void* address, std::uint32_t sizeInBytes) {
|
||||
(void)buf;
|
||||
(void)address;
|
||||
(void)sizeInBytes;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbPrimeUtcl2GetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbWriteData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t numDwords, std::uint8_t increment, std::uint8_t writeConfirm) {
|
||||
return Agc::Command::WriteData(buf, true, dst, cachePolicy, address, data, numDwords, increment, writeConfirm, __func__);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "prx/libSceAgc/Acb/include/Sync.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
uint32_t* APS5_VABI sceAgcAcbCondExec(CommandBuffer* buf, const volatile uint32_t* address, uint32_t num_dwords) {
|
||||
(void)buf;
|
||||
(void)address;
|
||||
(void)num_dwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcAcbCondExecGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbWaitRegMem(CommandBuffer* buf, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles) {
|
||||
return Agc::Command::WriteWait(buf, size, compareFunction, 0, cachePolicy, address, reference, mask, pollCycles, __func__);
|
||||
}
|
||||
|
||||
std::uint64_t APS5_VABI sceAgcAcbWaitOnAddressGetSize(std::uint8_t size) {
|
||||
(void)size;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbEventWrite(CommandBuffer* buf, std::uint8_t eventType, const volatile void* address) {
|
||||
Agc::Command::CheckBits(eventType, 0x3fu, __func__);
|
||||
Agc::Command::Require(address == nullptr, __func__, "ACB event address is not supported");
|
||||
return Agc::Command::Emit(buf, 0x46u, {eventType | (eventType == 7 ? 0x400u : 0u)}, __func__);
|
||||
}
|
||||
|
||||
std::uint64_t APS5_VABI sceAgcAcbEventWriteGetSize(std::uint8_t eventType) {
|
||||
(void)eventType;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcAcbQueueEndOfShaderActionGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcAcbMemSemaphore(CommandBuffer* buf, std::uint8_t action, std::uint8_t clientCode, const volatile void* address) {
|
||||
(void)buf;
|
||||
(void)action;
|
||||
(void)clientCode;
|
||||
(void)address;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
add_library(libSceAgc SHARED EXCLUDE_FROM_ALL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Unimplemented.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Control.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Dispatch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Sync.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Branch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Dispatch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Registers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Sync.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/Memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/Draw.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/RegisterDefaults.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/Packet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/DrawIndexed.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/DrawNonIndexed.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/IndexBuffer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/Instancing.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/Stats.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Control.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Dispatch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Sync.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/ContextState.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Display.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Init.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Marker.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Predication.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Registers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Workload.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/PacketInfo.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/RegisterDefaults.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/ShaderFusion.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/Suspend.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/CondExec.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Dma.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/IndirectRegisters.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Jump.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Nop.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/QueueEndOfPipeAction.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Rewind.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/WaitRegMem.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Branch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Predication/src/Predication.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/CreateShader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/InterpolantMapping.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/LinkShaders.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/PrimState.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/ShaderUtils.cpp
|
||||
)
|
||||
|
||||
target_include_directories(libSceAgc PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(libSceAgc PRIVATE libSceAgcDriver libc)
|
||||
|
||||
option(APS5_AGC_CREATE_LOG "Logging sceAgcCreateShader Ok status" ON)
|
||||
|
||||
target_compile_definitions(libSceAgc PRIVATE
|
||||
APS5_AGC_CREATE_LOG=$<BOOL:${APS5_AGC_CREATE_LOG}>
|
||||
)
|
||||
|
||||
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
|
||||
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endforeach()
|
||||
|
||||
add_executable(agc_command_tests EXCLUDE_FROM_ALL tests/Commands.cpp)
|
||||
target_include_directories(agc_command_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(agc_command_tests PRIVATE libSceAgc libc)
|
||||
configure_windows_unwind(agc_command_tests)
|
||||
configure_windows_unwind(libSceAgc)
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_BRANCH_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_BRANCH_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_DISPATCH_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_DISPATCH_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_REGISTERS_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_REGISTERS_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_SYNC_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_SYNC_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "prx/libSceAgc/Cb/include/Branch.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbBranch(CommandBuffer* buf, std::uint8_t mode, std::uint8_t compareFunction, const volatile std::uint64_t* compareAddress, std::uint64_t mask, std::uint64_t reference, std::uint8_t cachePolicy1, const volatile std::uint32_t* buffer1, std::uint32_t sizeInDwords1, std::uint8_t cachePolicy2, const volatile std::uint32_t* buffer2, std::uint32_t sizeInDwords2) {
|
||||
Agc::Command::CheckBits(mode, 3, __func__);
|
||||
Agc::Command::CheckBits(compareFunction, 7, __func__);
|
||||
Agc::Command::CheckBits(cachePolicy1, 3, __func__);
|
||||
Agc::Command::CheckBits(cachePolicy2, 3, __func__);
|
||||
Agc::Command::CheckBits(sizeInDwords1, 0xfffffu, __func__);
|
||||
Agc::Command::CheckBits(sizeInDwords2, 0xfffffu, __func__);
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(compareAddress);
|
||||
const auto first = reinterpret_cast<std::uintptr_t>(buffer1);
|
||||
const auto second = reinterpret_cast<std::uintptr_t>(buffer2);
|
||||
Agc::Command::CheckAddress(address, 8, __func__);
|
||||
Agc::Command::CheckAddress(first, 4, __func__);
|
||||
Agc::Command::CheckAddress(second, 4, __func__);
|
||||
return Agc::Command::Emit(buf, 0x3fu, {mode | (static_cast<std::uint32_t>(compareFunction) << 8u), static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), static_cast<std::uint32_t>(mask), static_cast<std::uint32_t>(mask >> 32u), static_cast<std::uint32_t>(reference), static_cast<std::uint32_t>(reference >> 32u), static_cast<std::uint32_t>(first), static_cast<std::uint32_t>(first >> 32u), sizeInDwords1 | (static_cast<std::uint32_t>(cachePolicy1) << 28u), static_cast<std::uint32_t>(second), static_cast<std::uint32_t>(second >> 32u), sizeInDwords2 | (static_cast<std::uint32_t>(cachePolicy2) << 28u)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcCbBranchGetSize() {
|
||||
return 56;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcCbCondWrite(CommandBuffer* buf, uint32_t cond, uint32_t a, uint32_t b, uint32_t c) {
|
||||
(void)buf;
|
||||
(void)cond;
|
||||
(void)a;
|
||||
(void)b;
|
||||
(void)c;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcCbCondWriteGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "prx/libSceAgc/Cb/include/Dispatch.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbDispatch(CommandBuffer* buf, std::uint32_t threadGroupX, std::uint32_t threadGroupY, std::uint32_t threadGroupZ, std::uint32_t modifier) {
|
||||
Agc::Command::CheckBits(modifier, 0xa038u | 0x41u, __func__);
|
||||
return Agc::Command::Emit(buf, 0x15u, {threadGroupX, threadGroupY, threadGroupZ, modifier | 0x41u}, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbDispatchGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#include "prx/libSceAgc/Cb/include/Registers.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetUcRegisterRangeDirect(CommandBuffer* buf, std::uint32_t offset, const std::uint32_t* values, std::uint32_t numValues) {
|
||||
return Agc::Command::WriteRegisterRange(buf, 0x79u, offset, values, numValues, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetShRegisterRangeDirect(CommandBuffer* buf, std::uint32_t offset, const std::uint32_t* values, std::uint32_t numValues) {
|
||||
return Agc::Command::WriteRegisterRange(buf, 0x76u, offset, values, numValues, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbSetShRegisterRangeDirectGetSize(uint32_t num_values) {
|
||||
(void)num_values;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcCbSetUcRegisterRangeDirectGetSize(std::uint32_t numValues) {
|
||||
(void)numValues;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetShRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
return Agc::Command::WriteRegisters(buf, 0x76u, regs, numRegs, true, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcCbSetShRegistersDirectGetSize(std::uint32_t numRegs) {
|
||||
(void)numRegs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbSetUcRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
|
||||
return Agc::Command::WriteRegisters(buf, 0x79u, regs, numRegs, false, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcCbSetUcRegistersDirectGetSize(std::uint32_t numRegs) {
|
||||
(void)numRegs;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
#include "prx/libSceAgc/Cb/include/Sync.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbNop_nid_postfix(CommandBuffer* buf, std::uint32_t sizeInDwords) {
|
||||
return Agc::Command::WriteNop(buf, sizeInDwords, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcCbNopGetSize(uint32_t size_in_dwords) {
|
||||
(void)size_in_dwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcCbQueueEndOfPipeActionGetSize() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcCbReleaseMem(CommandBuffer* buf, std::uint8_t action, std::uint16_t gcrControl, std::uint8_t dst, std::uint8_t cachePolicy, const volatile Label* address, std::uint8_t dataSelect, std::uint64_t data, std::uint16_t gdsOffset, std::uint16_t gdsSize, std::uint8_t interrupt, std::uint32_t interruptContextId) {
|
||||
Agc::Command::CheckBits(action, 0x3fu, __func__);
|
||||
Agc::Command::CheckBits(gcrControl, 0xfffu, __func__);
|
||||
Agc::Command::CheckBits(dst, 1, __func__);
|
||||
Agc::Command::CheckBits(cachePolicy, 3, __func__);
|
||||
Agc::Command::Require(dataSelect <= 3 || dataSelect == 5, __func__, "invalid release data selector");
|
||||
Agc::Command::Require(interrupt <= 4, __func__, "invalid release interrupt selector");
|
||||
Agc::Command::CheckBits(interruptContextId, 0x7ffffffu, __func__);
|
||||
auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
|
||||
auto value = data;
|
||||
if (interrupt == 4) {
|
||||
Agc::Command::Require(guestAddress == 0 && value == 0, __func__, "interrupt-only release cannot write data");
|
||||
} else if (dataSelect == 5) {
|
||||
Agc::Command::Require(data == 0, __func__, "GDS release cannot use immediate data");
|
||||
value = gdsOffset | (static_cast<std::uint64_t>(gdsSize) << 16u);
|
||||
} else {
|
||||
Agc::Command::Require(gdsOffset == 0 && gdsSize <= 1, __func__, "GDS parameters supplied for a non-GDS release");
|
||||
}
|
||||
// A null label is accepted: games emit releases whose destination is never read.
|
||||
if (dataSelect != 0 && interrupt != 4 && guestAddress != 0) {
|
||||
Agc::Command::CheckAddress(guestAddress, dataSelect == 2 || dataSelect == 3 ? 8 : 4, __func__);
|
||||
}
|
||||
if (dataSelect == 1) {
|
||||
Agc::Command::CheckBits(data, 0xffffffffu, __func__);
|
||||
}
|
||||
std::uint32_t control = gcrControl;
|
||||
if ((control & 0x300u) == 0x100u) {
|
||||
control |= 0x200u;
|
||||
}
|
||||
const auto eventIndex = action >= 0x2fu ? 6u : 5u;
|
||||
auto* packet = Agc::Command::Emit(buf, 0x49u, {action | (eventIndex << 8u) | (control << 12u) | (static_cast<std::uint32_t>(cachePolicy) << 25u), (static_cast<std::uint32_t>(dst) << 16u) | (static_cast<std::uint32_t>(interrupt) << 24u) | (static_cast<std::uint32_t>(dataSelect) << 29u), static_cast<std::uint32_t>(guestAddress), static_cast<std::uint32_t>(guestAddress >> 32u), static_cast<std::uint32_t>(value), static_cast<std::uint32_t>(value >> 32u), interruptContextId}, __func__);
|
||||
static const std::uint64_t traced = [] { const char* value = std::getenv("APS5_TRACE_LABEL"); return value ? std::strtoull(value, nullptr, 16) : 0ull; }();
|
||||
if (traced != 0 && guestAddress == traced) std::fprintf(stderr, "[agc] RELEASE_MEM for 0x%llx recorded at %p" "\n", static_cast<unsigned long long>(guestAddress), static_cast<void*>(packet));
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_DRAW_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_DRAW_HPP
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
std::uint32_t DrawInitiator(std::uint64_t modifier, bool indexed, const char* function);
|
||||
std::uint64_t DrawPatchOffsets(std::uint64_t modifier, const char* function);
|
||||
std::uint32_t DrawIndexLocation(std::uint64_t modifier);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_MEMORY_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_MEMORY_HPP
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
std::uint32_t* WriteDma(CommandBuffer* buffer, bool compute, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine, const char* function);
|
||||
std::uint32_t* WriteData(CommandBuffer* buffer, bool compute, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t count, std::uint8_t increment, std::uint8_t writeConfirm, const char* function);
|
||||
std::uint32_t* WriteWait(CommandBuffer* buffer, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles, const char* function);
|
||||
std::uint32_t* ValidateWait(std::uint32_t* packet, const char* function);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_PACKET_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_PACKET_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include "SceTypes.hpp"
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
void Require(bool condition, const char* function, const char* reason);
|
||||
void CheckBits(std::uint64_t value, std::uint64_t mask, const char* function);
|
||||
void CheckAddress(std::uint64_t address, std::uint32_t alignment, const char* function);
|
||||
std::uint32_t Header(std::uint32_t opcode, std::uint32_t count, std::uint32_t flags = 0);
|
||||
void Reserve(CommandBuffer* buffer, std::uint32_t count, const char* function);
|
||||
std::uint32_t* Allocate(CommandBuffer* buffer, std::uint32_t count, const char* function);
|
||||
std::uint32_t* Emit(CommandBuffer* buffer, std::uint32_t opcode, std::initializer_list<std::uint32_t> payload, const char* function);
|
||||
void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function);
|
||||
std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function);
|
||||
std::uint32_t* WriteRegisterRange(CommandBuffer* buffer, std::uint32_t opcode, std::uint32_t offset, const std::uint32_t* values, std::uint32_t count, const char* function);
|
||||
std::uint32_t* WriteRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, bool snapshotAll, const char* function);
|
||||
std::uint32_t* WriteIndirectRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, const char* function);
|
||||
void PatchIndirectAddress(std::uint32_t* packet, std::uint32_t opcode, const volatile ShaderRegister* registers, const char* function);
|
||||
void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_REGISTERDEFAULTS_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_REGISTERDEFAULTS_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
void* GetRegisterDefaults(std::uint32_t version, bool internal, const char* function);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,32 +0,0 @@
|
||||
#include "prx/libSceAgc/Command/include/Draw.hpp"
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
namespace {
|
||||
|
||||
std::uint32_t sgprBase(std::uint64_t modifier) {
|
||||
const auto stage = static_cast<std::uint32_t>(modifier) >> 29u;
|
||||
return stage == 3 || stage == 5 ? 0x10cu : 0x8cu;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::uint32_t DrawInitiator(std::uint64_t modifier, bool indexed, const char* function) {
|
||||
CheckBits(modifier, 0x1ffffffffull, function);
|
||||
const auto flags = (modifier & 0x100000000ull) != 0 ? 0u : static_cast<std::uint32_t>((modifier >> 3u) & 0x20u);
|
||||
return flags | (indexed ? 0u : 2u);
|
||||
}
|
||||
|
||||
std::uint64_t DrawPatchOffsets(std::uint64_t modifier, const char* function) {
|
||||
CheckBits(modifier, 0x1ffffffffull, function);
|
||||
const auto base = sgprBase(modifier);
|
||||
const auto vertex = (modifier & 1u) != 0 ? base + static_cast<std::uint32_t>((modifier >> 9u) & 0x1fu) : 0x280u;
|
||||
const auto instance = (modifier & 4u) != 0 ? base + static_cast<std::uint32_t>((modifier >> 19u) & 0x1fu) : 0x280u;
|
||||
return vertex | (static_cast<std::uint64_t>(instance) << 32u);
|
||||
}
|
||||
|
||||
std::uint32_t DrawIndexLocation(std::uint64_t modifier) {
|
||||
return (modifier & 8u) != 0 ? sgprBase(modifier) + static_cast<std::uint32_t>((modifier >> 24u) & 0x1fu) : 0x280u;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
std::uint32_t* WriteDma(CommandBuffer* buffer, bool compute, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine, const char* function) {
|
||||
CheckBits(engine, 1, function);
|
||||
CheckBits(dst, 0xfu, function);
|
||||
CheckBits(dstCachePolicy, 3, function);
|
||||
CheckBits(srcCachePolicy, 3, function);
|
||||
CheckBits(waitForPrevious, 1, function);
|
||||
CheckBits(writeConfirm, 1, function);
|
||||
CheckBits(blockEngine, 1, function);
|
||||
CheckBits(numBytes, 0x3ffffffu, function);
|
||||
if (src == 0x14u || src == 0x24u || (!compute && src == 0x64u) || (compute && src == 0x25u)) {
|
||||
const auto slot = src == 0x14u ? 0u : src == 0x24u ? 1u : 2u;
|
||||
srcAddress = (engine == 1 ? 0x30148u : 0x30174u) + slot * 8u;
|
||||
} else {
|
||||
CheckBits(src, 0xfu, function);
|
||||
}
|
||||
const auto control = engine | (static_cast<std::uint32_t>(srcCachePolicy) << 13u) | ((dst & 3u) << 20u) | (static_cast<std::uint32_t>(dstCachePolicy) << 25u) | ((src & 3u) << 29u) | (static_cast<std::uint32_t>(blockEngine) << 31u);
|
||||
const auto command = numBytes | ((src & 4u) << 24u) | ((dst & 4u) << 25u) | ((src & 8u) << 25u) | ((dst & 8u) << 26u) | (static_cast<std::uint32_t>(waitForPrevious) << 30u) | (static_cast<std::uint32_t>(writeConfirm) << 31u);
|
||||
return Emit(buffer, 0x50u, {control, static_cast<std::uint32_t>(srcAddress), static_cast<std::uint32_t>(srcAddress >> 32u), static_cast<std::uint32_t>(dstAddress), static_cast<std::uint32_t>(dstAddress >> 32u), command}, function);
|
||||
}
|
||||
|
||||
std::uint32_t* WriteData(CommandBuffer* buffer, bool compute, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t count, std::uint8_t increment, std::uint8_t writeConfirm, const char* function) {
|
||||
Require(data != nullptr && count != 0 && count <= 0x3ffdu, function, "invalid write data payload");
|
||||
CheckBits(dst, compute ? 0xfu : 0x1fu, function);
|
||||
CheckBits(cachePolicy, 3, function);
|
||||
CheckBits(increment, 1, function);
|
||||
CheckBits(writeConfirm, 1, function);
|
||||
Require(compute || (address & 3u) == 0, function, "misaligned write address");
|
||||
Require(dst != 0 || writeConfirm == 0, function, "register writes do not support write confirmation");
|
||||
std::vector<std::uint32_t> snapshot(count);
|
||||
std::memcpy(snapshot.data(), data, count * sizeof(std::uint32_t));
|
||||
const auto destination = compute ? static_cast<std::uint32_t>(dst) << 8u : ((dst & 1u) << 30u) | ((dst & 0x1eu) << 7u);
|
||||
auto* packet = Allocate(buffer, count + 4u, function);
|
||||
packet[0] = Header(0x37u, count + 4u);
|
||||
packet[1] = destination | (static_cast<std::uint32_t>(increment) << 16u) | (static_cast<std::uint32_t>(writeConfirm) << 20u) | (static_cast<std::uint32_t>(cachePolicy) << 25u);
|
||||
packet[2] = static_cast<std::uint32_t>(address);
|
||||
packet[3] = static_cast<std::uint32_t>(address >> 32u);
|
||||
std::copy(snapshot.begin(), snapshot.end(), packet + 4);
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteWait(CommandBuffer* buffer, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles, const char* function) {
|
||||
CheckBits(size, 1, function);
|
||||
Require(compareFunction <= 6, function, "invalid wait comparison");
|
||||
CheckBits(operation, size == 0 ? 0xfu : 7u, function);
|
||||
CheckBits(cachePolicy, 3, function);
|
||||
Require((pollCycles >> 4u) <= 0xffffu, function, "wait poll interval overflow");
|
||||
if (size == 0) {
|
||||
// 32-bit waits only use the low halves; guests commonly pass a full 64-bit mask.
|
||||
reference &= 0xffffffffu;
|
||||
mask &= 0xffffffffu;
|
||||
}
|
||||
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
|
||||
// The address may be left null and filled in later with sceAgcWaitRegMemPatchAddress.
|
||||
if (guestAddress != 0) CheckAddress(guestAddress, size == 0 ? 4 : 8, function);
|
||||
CheckBits(guestAddress, 0xffffffffffffull, function);
|
||||
const auto waitSize = size == 0 ? 7u : 9u;
|
||||
auto* packet = Allocate(buffer, waitSize + 7u, function);
|
||||
packet[0] = Header(0x79u, 4, 1);
|
||||
packet[1] = 0x342u;
|
||||
packet[2] = (size == 0 ? 0xc8010000u : 0xc8020000u) | static_cast<std::uint32_t>(guestAddress >> 32u);
|
||||
packet[3] = static_cast<std::uint32_t>(guestAddress);
|
||||
auto* wait = packet + 4;
|
||||
wait[0] = Header(size == 0 ? 0x3cu : 0x93u, waitSize);
|
||||
const auto opBits = size == 0 ? ((operation & 3u) << 8u) | ((operation & 0xcu) << 4u) : ((operation & 1u) << 8u) | ((operation & 6u) << 5u);
|
||||
wait[1] = 0x10u | compareFunction | opBits | (static_cast<std::uint32_t>(cachePolicy) << 25u);
|
||||
wait[2] = static_cast<std::uint32_t>(guestAddress);
|
||||
wait[3] = static_cast<std::uint32_t>(guestAddress >> 32u);
|
||||
wait[4] = static_cast<std::uint32_t>(reference);
|
||||
if (size == 0) {
|
||||
wait[5] = static_cast<std::uint32_t>(mask);
|
||||
} else {
|
||||
wait[5] = static_cast<std::uint32_t>(reference >> 32u);
|
||||
wait[6] = static_cast<std::uint32_t>(mask);
|
||||
wait[7] = static_cast<std::uint32_t>(mask >> 32u);
|
||||
}
|
||||
wait[waitSize - 1u] = pollCycles >> 4u;
|
||||
wait[waitSize] = Header(0x79u, 3, 1);
|
||||
wait[waitSize + 1u] = 0x342u;
|
||||
wait[waitSize + 2u] = 0xc8000000u;
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* ValidateWait(std::uint32_t* packet, const char* function) {
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, function);
|
||||
Require(packet[0] == Header(0x79u, 4, 1) && packet[1] == 0x342u, function, "invalid wait wrapper");
|
||||
const auto tag = packet[2] & 0xffff0000u;
|
||||
Require(tag == 0xc8010000u || tag == 0xc8020000u, function, "invalid wait tag");
|
||||
const auto size = tag == 0xc8010000u ? 7u : 9u;
|
||||
auto* wait = packet + 4;
|
||||
ValidatePacket(wait, size == 7 ? 0x3cu : 0x93u, size, function);
|
||||
Require(wait[size] == Header(0x79u, 3, 1) && wait[size + 1u] == 0x342u && wait[size + 2u] == 0xc8000000u, function, "invalid wait end tag");
|
||||
return wait;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
void Require(bool condition, const char* function, const char* reason) {
|
||||
if (!condition) {
|
||||
throw std::runtime_error(std::string(function) + ": " + reason);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckBits(std::uint64_t value, std::uint64_t mask, const char* function) {
|
||||
if ((value & ~mask) == 0) return;
|
||||
char reason[96];
|
||||
std::snprintf(reason, sizeof(reason), "reserved bits are set (value 0x%llx, allowed 0x%llx)", static_cast<unsigned long long>(value), static_cast<unsigned long long>(mask));
|
||||
Require(false, function, reason);
|
||||
}
|
||||
|
||||
void CheckAddress(std::uint64_t address, std::uint32_t alignment, const char* function) {
|
||||
if (address != 0 && (address & (alignment - 1u)) == 0) return;
|
||||
char message[64];
|
||||
std::snprintf(message, sizeof(message), "null or misaligned address 0x%llx", static_cast<unsigned long long>(address));
|
||||
Require(false, function, message);
|
||||
}
|
||||
|
||||
std::uint32_t Header(std::uint32_t opcode, std::uint32_t count, std::uint32_t flags) {
|
||||
Require(count >= 2 && count <= 0x4001u && opcode <= 0xffu && flags <= 0xffu, __func__, "invalid packet header");
|
||||
return 0xc0000000u | ((count - 2u) << 16u) | (opcode << 8u) | flags;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::uint32_t available(const CommandBuffer& buffer, const char* function) {
|
||||
const auto bottom = reinterpret_cast<std::uintptr_t>(buffer.bottom);
|
||||
const auto top = reinterpret_cast<std::uintptr_t>(buffer.top);
|
||||
const auto up = reinterpret_cast<std::uintptr_t>(buffer.cursor_up);
|
||||
const auto down = reinterpret_cast<std::uintptr_t>(buffer.cursor_down);
|
||||
Require(((bottom | top | up | down) & 3u) == 0, function, "misaligned command buffer");
|
||||
Require(bottom <= up && up <= down && down <= top, function, "invalid command buffer cursors");
|
||||
Require(bottom != 0 || top == 0, function, "null command buffer storage");
|
||||
const auto count = (down - up) / sizeof(std::uint32_t);
|
||||
Require(count >= buffer.reserved_dw, function, "reserved space exceeds command buffer capacity");
|
||||
Require(count - buffer.reserved_dw <= std::numeric_limits<std::uint32_t>::max(), function, "command buffer capacity overflow");
|
||||
return static_cast<std::uint32_t>(count - buffer.reserved_dw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Reserve(CommandBuffer* buffer, std::uint32_t count, const char* function) {
|
||||
Require(buffer != nullptr && count != 0, function, "null command buffer or empty allocation");
|
||||
if (available(*buffer, function) < count) {
|
||||
Require(buffer->callback != nullptr, function, "command buffer exhausted");
|
||||
Require(count <= std::numeric_limits<std::uint32_t>::max() - buffer->reserved_dw, function, "command buffer allocation overflow");
|
||||
Require(buffer->callback(buffer, count + buffer->reserved_dw, buffer->user_data), function, "command buffer allocation callback failed");
|
||||
Require(available(*buffer, function) >= count, function, "command buffer allocation callback returned insufficient space");
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t* Allocate(CommandBuffer* buffer, std::uint32_t count, const char* function) {
|
||||
Reserve(buffer, count, function);
|
||||
auto* result = buffer->cursor_up;
|
||||
buffer->cursor_up += count;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::uint32_t* Emit(CommandBuffer* buffer, std::uint32_t opcode, std::initializer_list<std::uint32_t> payload, const char* function) {
|
||||
Require(payload.size() <= 0x4000u, function, "packet payload exceeds maximum size");
|
||||
const auto count = static_cast<std::uint32_t>(payload.size()) + 1u;
|
||||
const auto header = Header(opcode, count);
|
||||
auto* packet = Allocate(buffer, count, function);
|
||||
packet[0] = header;
|
||||
std::copy(payload.begin(), payload.end(), packet + 1);
|
||||
return packet;
|
||||
}
|
||||
|
||||
void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, function);
|
||||
Require(packet[0] == Header(opcode, count), function, "unexpected packet type, size or flags");
|
||||
}
|
||||
|
||||
std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function) {
|
||||
const auto header = Header(0x10u, count);
|
||||
auto* packet = Allocate(buffer, count, function);
|
||||
packet[0] = header;
|
||||
std::fill_n(packet + 1, count - 1u, 0u);
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteRegisterRange(CommandBuffer* buffer, std::uint32_t opcode, std::uint32_t offset, const std::uint32_t* values, std::uint32_t count, const char* function) {
|
||||
Require(count != 0 && count <= 0x3fffu && offset <= 0xffffu && count <= 0x10000u - offset, function, "invalid register range");
|
||||
std::vector<std::uint32_t> snapshot;
|
||||
if (values != nullptr) {
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(values), 4, function);
|
||||
snapshot.assign(values, values + count);
|
||||
}
|
||||
auto* packet = Allocate(buffer, count + 2u, function);
|
||||
packet[0] = Header(opcode, count + 2u);
|
||||
packet[1] = offset;
|
||||
std::copy(snapshot.begin(), snapshot.end(), packet + 2);
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, bool snapshotAll, const char* function) {
|
||||
Require(count != 0, function, "empty register list");
|
||||
CheckAddress(reinterpret_cast<std::uintptr_t>(registers), 4, function);
|
||||
std::vector<ShaderRegister> snapshot;
|
||||
if (snapshotAll) {
|
||||
snapshot.reserve(count);
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
snapshot.push_back({registers[i].offset, registers[i].value});
|
||||
CheckBits(snapshot.back().offset, 0xffffu, function);
|
||||
}
|
||||
}
|
||||
const auto offsetAt = [&](std::uint32_t index) { return snapshotAll ? snapshot[index].offset : registers[index].offset; };
|
||||
const auto valueAt = [&](std::uint32_t index) { return snapshotAll ? snapshot[index].value : registers[index].value; };
|
||||
std::uint32_t* first = nullptr;
|
||||
std::uint32_t index = 0;
|
||||
while (index < count) {
|
||||
const auto offset = offsetAt(index);
|
||||
CheckBits(offset, 0xffffu, function);
|
||||
std::vector<std::uint32_t> values{valueAt(index++)};
|
||||
while (index < count && offsetAt(index) == offset + values.size() && values.size() < 0x3fffu) {
|
||||
CheckBits(offsetAt(index), 0xffffu, function);
|
||||
values.push_back(valueAt(index++));
|
||||
}
|
||||
auto* packet = WriteRegisterRange(buffer, opcode, offset, values.data(), static_cast<std::uint32_t>(values.size()), function);
|
||||
if (first == nullptr) {
|
||||
first = packet;
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
std::uint32_t* WriteIndirectRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, const char* function) {
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(registers);
|
||||
CheckAddress(address, 4, function);
|
||||
CheckBits(count, 0x3fffu, function);
|
||||
return Emit(buffer, opcode, {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), 0x80000000u, count}, function);
|
||||
}
|
||||
|
||||
void PatchIndirectAddress(std::uint32_t* packet, std::uint32_t opcode, const volatile ShaderRegister* registers, const char* function) {
|
||||
ValidatePacket(packet, opcode, 5, function);
|
||||
Require(packet[3] == 0x80000000u && (packet[4] & ~0x3fffu) == 0, function, "invalid indirect register packet");
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(registers);
|
||||
CheckAddress(address, 4, function);
|
||||
packet[1] = static_cast<std::uint32_t>(address);
|
||||
packet[2] = static_cast<std::uint32_t>(address >> 32u);
|
||||
}
|
||||
|
||||
void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
|
||||
ValidatePacket(packet, opcode, 5, function);
|
||||
Require(packet[3] == 0x80000000u && packet[4] <= 0x3fffu && count <= 0x3fffu - packet[4], function, "indirect register count overflow or invalid packet");
|
||||
packet[4] += count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
#include "prx/libSceAgc/Command/include/RegisterDefaults.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace Agc::Command {
|
||||
|
||||
namespace {
|
||||
|
||||
struct RegisterDefaults {
|
||||
ShaderRegister** tables[4];
|
||||
std::uint32_t registerCounts[4];
|
||||
std::uint32_t* types;
|
||||
std::uint32_t count;
|
||||
};
|
||||
|
||||
static_assert(offsetof(RegisterDefaults, count) == 0x38);
|
||||
|
||||
struct CompactBank {
|
||||
ShaderRegister* registers;
|
||||
std::uint32_t registerCount;
|
||||
const std::uint16_t* offsets;
|
||||
std::uint32_t pointerCount;
|
||||
};
|
||||
|
||||
struct CompactRegisterDefaults {
|
||||
CompactBank banks[4];
|
||||
std::uint32_t* types;
|
||||
std::uint32_t count;
|
||||
};
|
||||
|
||||
#include "prx/libSceAgc/Command/include/RegisterDefaultsData.hpp"
|
||||
|
||||
struct Storage {
|
||||
RegisterDefaults defaults{};
|
||||
std::array<std::vector<ShaderRegister*>, 4> pointers;
|
||||
bool initialized = false;
|
||||
};
|
||||
|
||||
std::mutex defaultsMutex;
|
||||
std::array<std::array<Storage, 14>, 2> storage;
|
||||
|
||||
}
|
||||
|
||||
void* GetRegisterDefaults(std::uint32_t version, bool internal, const char* function) {
|
||||
Require(version < 14, function, "unsupported register defaults version");
|
||||
const auto* source = internal ? agcInternalRegDefaultsByVersion[version] : agcPublicRegDefaultsByVersion[version];
|
||||
std::lock_guard lock(defaultsMutex);
|
||||
auto& destination = storage[internal ? 1 : 0][version];
|
||||
if (!destination.initialized) {
|
||||
std::array<std::vector<ShaderRegister*>, 4> pointers;
|
||||
RegisterDefaults defaults{};
|
||||
for (std::size_t bank = 0; bank < pointers.size(); ++bank) {
|
||||
const auto& input = source->banks[bank];
|
||||
Require(input.pointerCount == 0 || (input.registers != nullptr && input.offsets != nullptr), function, "invalid register defaults bank");
|
||||
auto& table = pointers[bank];
|
||||
table.reserve(input.pointerCount);
|
||||
for (std::uint32_t index = 0; index < input.pointerCount; ++index) {
|
||||
Require(input.offsets[index] < input.registerCount, function, "register defaults pointer exceeds bank");
|
||||
table.push_back(input.registers + input.offsets[index]);
|
||||
}
|
||||
defaults.tables[bank] = table.empty() ? nullptr : table.data();
|
||||
defaults.registerCounts[bank] = input.registerCount;
|
||||
}
|
||||
Require(source->count == 0 || source->types != nullptr, function, "missing register defaults types");
|
||||
defaults.types = source->types;
|
||||
defaults.count = source->count;
|
||||
destination.pointers = std::move(pointers);
|
||||
destination.defaults = defaults;
|
||||
destination.initialized = true;
|
||||
}
|
||||
return &destination.defaults;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWINDEXED_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWINDEXED_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWNONINDEXED_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWNONINDEXED_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INDEXBUFFER_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INDEXBUFFER_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INSTANCING_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INSTANCING_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_STATS_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_STATS_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
#include "prx/libSceAgc/Command/include/Draw.hpp"
|
||||
#include "prx/libSceAgc/DcbDraw/include/DrawIndexed.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDrawIndex(CommandBuffer* buf, std::uint32_t indexCount, const volatile void* indexAddress, std::uint64_t modifier) {
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(indexAddress);
|
||||
Agc::Command::CheckAddress(address, 1, __func__);
|
||||
return Agc::Command::Emit(buf, 0x27u, {indexCount, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), indexCount, Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDrawIndexGetSize() {
|
||||
return 24;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDrawIndexAuto(CommandBuffer* buf, std::uint32_t indexCount, std::uint64_t modifier) {
|
||||
return Agc::Command::Emit(buf, 0x2du, {indexCount, Agc::Command::DrawInitiator(modifier, false, __func__)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDrawIndexAutoGetSize() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDrawIndexOffset(CommandBuffer* buf, std::uint32_t indexOffset, std::uint32_t indexCount, std::uint64_t modifier) {
|
||||
return Agc::Command::Emit(buf, 0x35u, {indexCount == 0 ? 1u : indexCount, indexOffset, indexCount, Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbDrawIndexOffsetGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbDrawIndexIndirect(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint64_t modifier) {
|
||||
Agc::Command::Require((data_offset_in_bytes & 3u) == 0, __func__, "misaligned indirect argument offset");
|
||||
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
|
||||
return Agc::Command::Emit(buf, 0x25u, {data_offset_in_bytes, static_cast<std::uint32_t>(offsets), static_cast<std::uint32_t>(offsets >> 32u), Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDrawIndexIndirectGetSize() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbDrawIndexIndirectMulti(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint32_t count_indirect, uint32_t max_count_or_count, const volatile void* count_addr, uint32_t stride_in_bytes, uint64_t modifier) {
|
||||
Agc::Command::CheckBits(count_indirect, 1, __func__);
|
||||
Agc::Command::Require((data_offset_in_bytes & 3u) == 0 && (stride_in_bytes & 3u) == 0 && stride_in_bytes >= 20, __func__, "invalid indirect draw offset or stride");
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(count_addr);
|
||||
if (count_indirect != 0) {
|
||||
Agc::Command::CheckAddress(address, 4, __func__);
|
||||
} else {
|
||||
Agc::Command::Require(address == 0, __func__, "count address supplied for a direct draw count");
|
||||
}
|
||||
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
|
||||
const auto low = static_cast<std::uint32_t>(modifier);
|
||||
const auto control = Agc::Command::DrawIndexLocation(modifier) | ((low & 0x10u) << 23u) | (count_indirect << 30u) | ((low & 8u) << 28u);
|
||||
return Agc::Command::Emit(buf, 0x38u, {data_offset_in_bytes, static_cast<std::uint32_t>(offsets), static_cast<std::uint32_t>(offsets >> 32u), control, max_count_or_count, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), stride_in_bytes, Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDrawIndexIndirectMultiGetSize() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbDrawIndexMultiInstanced(CommandBuffer* buf, uint32_t index_count, const volatile void* index_addr, const volatile void* object_ids, uint32_t instance_count, uint64_t modifier) {
|
||||
(void)buf;
|
||||
(void)index_count;
|
||||
(void)index_addr;
|
||||
(void)object_ids;
|
||||
(void)instance_count;
|
||||
(void)modifier;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbDrawIndexMultiInstancedGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
#include "prx/libSceAgc/Command/include/Draw.hpp"
|
||||
#include "prx/libSceAgc/DcbDraw/include/DrawNonIndexed.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDrawIndirect(CommandBuffer* buf, std::uint32_t dataOffsetInBytes, std::uint64_t modifier) {
|
||||
Agc::Command::Require((dataOffsetInBytes & 3u) == 0, __func__, "misaligned indirect argument offset");
|
||||
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
|
||||
return Agc::Command::Emit(buf, 0x24u, {dataOffsetInBytes, static_cast<std::uint32_t>(offsets), static_cast<std::uint32_t>(offsets >> 32u), Agc::Command::DrawInitiator(modifier, false, __func__)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDrawIndirectGetSize() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDrawIndirectMulti(CommandBuffer* buf, std::uint32_t dataOffsetInBytes, std::uint32_t countIndirect, std::uint32_t maxCountOrCount, const volatile void* countAddress, std::uint32_t strideInBytes, std::uint64_t modifier) {
|
||||
Agc::Command::CheckBits(countIndirect, 1, __func__);
|
||||
Agc::Command::Require((dataOffsetInBytes & 3u) == 0 && (strideInBytes & 3u) == 0 && strideInBytes >= 16, __func__, "invalid indirect draw offset or stride");
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(countAddress);
|
||||
if (countIndirect != 0) {
|
||||
Agc::Command::CheckAddress(address, 4, __func__);
|
||||
} else {
|
||||
Agc::Command::Require(address == 0, __func__, "count address supplied for a direct draw count");
|
||||
}
|
||||
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
|
||||
const auto initiator = Agc::Command::DrawInitiator(modifier, false, __func__);
|
||||
const auto low = static_cast<std::uint32_t>(modifier);
|
||||
const auto control = Agc::Command::DrawIndexLocation(modifier) | ((low & 0x10u) << 23u) | (countIndirect << 30u) | ((low & 8u) << 28u);
|
||||
auto* packet = Agc::Command::Allocate(buf, 16, __func__);
|
||||
packet[0] = Agc::Command::Header(0x79u, 3, 1);
|
||||
packet[1] = 0x342u;
|
||||
packet[2] = 0xc6000008u;
|
||||
packet[3] = Agc::Command::Header(0x2cu, 10);
|
||||
packet[4] = dataOffsetInBytes;
|
||||
packet[5] = static_cast<std::uint32_t>(offsets);
|
||||
packet[6] = static_cast<std::uint32_t>(offsets >> 32u);
|
||||
packet[7] = control;
|
||||
packet[8] = maxCountOrCount;
|
||||
packet[9] = static_cast<std::uint32_t>(address);
|
||||
packet[10] = static_cast<std::uint32_t>(address >> 32u);
|
||||
packet[11] = strideInBytes;
|
||||
packet[12] = initiator;
|
||||
packet[13] = Agc::Command::Header(0x79u, 3, 1);
|
||||
packet[14] = 0x342u;
|
||||
packet[15] = 0xc6000000u;
|
||||
return packet;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDrawIndirectMultiGetSize() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbDraw/include/IndexBuffer.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetIndexBuffer(CommandBuffer* buf, std::uint64_t indexAddress) {
|
||||
if (indexAddress != 0) Agc::Command::CheckAddress(indexAddress, 2, __func__);
|
||||
return Agc::Command::Emit(buf, 0x26u, {static_cast<std::uint32_t>(indexAddress), static_cast<std::uint32_t>(indexAddress >> 32u)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetIndexBufferGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetIndexCount(CommandBuffer* buf, std::uint32_t indexCount) {
|
||||
return Agc::Command::Emit(buf, 0x13u, {indexCount}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetIndexCountGetSize() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetIndexSize(CommandBuffer* buf, std::uint8_t indexSize, std::uint8_t cachePolicy) {
|
||||
Agc::Command::Require(indexSize <= 2, __func__, "invalid index element size");
|
||||
Agc::Command::CheckBits(cachePolicy, 3, __func__);
|
||||
return Agc::Command::Emit(buf, 0x7au, {0x20000243u, 0x400u | indexSize | (static_cast<std::uint32_t>(cachePolicy) << 6u)}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetIndexSizeGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetIndexIndirectArgs(CommandBuffer* buf, std::uint32_t dataOffsetInBytes) {
|
||||
(void)buf;
|
||||
(void)dataOffsetInBytes;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetIndexIndirectArgsGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbDraw/include/Instancing.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbSetNumInstances(CommandBuffer* buf, std::uint32_t numInstances) {
|
||||
return Agc::Command::Emit(buf, 0x2fu, {numInstances}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbSetNumInstancesGetSize() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbSetBaseIndirectArgs(CommandBuffer* buf, uint32_t shader_type, const volatile void* indirect_base_addr) {
|
||||
// SET_BASE with base index 1; header bit 1 selects the dispatch (compute) base over the draw base.
|
||||
Agc::Command::CheckBits(shader_type, 1, __func__);
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(indirect_base_addr);
|
||||
Agc::Command::CheckAddress(address, 8, __func__);
|
||||
Agc::Command::CheckBits(address, 0xffffffffffffull, __func__);
|
||||
auto* packet = Agc::Command::Allocate(buf, 4, __func__);
|
||||
packet[0] = Agc::Command::Header(0x11u, 4, shader_type != 0 ? 2u : 0u);
|
||||
packet[1] = 1;
|
||||
packet[2] = static_cast<std::uint32_t>(address);
|
||||
packet[3] = static_cast<std::uint32_t>(address >> 32u);
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbDraw/include/Stats.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbGetLodStats(CommandBuffer* buf, std::uint8_t cachePolicy, const volatile void* buffer, std::uint32_t bufferSizeInBytes, std::uint32_t resetCount, std::uint8_t forceReset, std::uint8_t reportAndReset, std::uint32_t reportingIntervalIn100kClocks) {
|
||||
Agc::Command::CheckBits(cachePolicy, 3, __func__);
|
||||
Agc::Command::CheckBits(resetCount, 0xffu, __func__);
|
||||
Agc::Command::CheckBits(forceReset, 1, __func__);
|
||||
Agc::Command::CheckBits(reportAndReset, 1, __func__);
|
||||
Agc::Command::CheckBits(reportingIntervalIn100kClocks, 0xffu, __func__);
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(buffer);
|
||||
if (address != 0) Agc::Command::CheckAddress(address, 64, __func__);
|
||||
const auto control = (static_cast<std::uint32_t>(cachePolicy) << 28u) | (static_cast<std::uint32_t>(reportAndReset) << 19u) | (static_cast<std::uint32_t>(forceReset) << 18u) | (resetCount << 10u) | (reportingIntervalIn100kClocks << 2u);
|
||||
// LOD statistics are not collected; a same-sized NOP keeps the packet layout without producing data.
|
||||
return Agc::Command::Emit(buf, 0x10u, {bufferSizeInBytes, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), control}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbBeginOcclusionQueryGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbEndOcclusionQueryGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_CONTROL_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_CONTROL_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_DISPATCH_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_DISPATCH_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_MEMORY_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_MEMORY_HPP
|
||||
|
||||
#include "SceTypes.hpp"
|
||||
|
||||
extern "C" std::uint32_t* APS5_VABI sceAgcDcbAcquireMem(CommandBuffer* buf, std::uint8_t engine, std::uint32_t cbDbOp, std::uint32_t gcrControl, const volatile void* base, std::uint64_t sizeBytes, std::uint32_t pollCycles);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_SYNC_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_SYNC_HPP
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,59 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbFlow/include/Control.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
// unknown signature
|
||||
APS5_EXPORT("zARR5aCmkoY", sceAgcDcbA_zARR5aCmkoY);
|
||||
void* APS5_VABI sceAgcDcbA_zARR5aCmkoY(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbJump(CommandBuffer* buf, uint8_t mode, uint8_t cache_policy, const uint32_t* target, uint32_t size_in_dwords) {
|
||||
(void)buf;
|
||||
(void)mode;
|
||||
(void)cache_policy;
|
||||
(void)target;
|
||||
(void)size_in_dwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbJumpGetSize() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbResetQueue(CommandBuffer* buf, std::uint32_t op, std::uint32_t state) {
|
||||
Agc::Command::CheckBits(op, 0xfffu, __func__);
|
||||
Agc::Command::CheckBits(state, 0xfu, __func__);
|
||||
return Agc::Command::Emit(buf, 0x12u, {state}, __func__);
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbRewind(CommandBuffer* buf, uint32_t initial_state) {
|
||||
(void)buf;
|
||||
(void)initial_state;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbRewindGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbWaitUntilSafeForRendering(CommandBuffer* buf, uint32_t video_out_handle, uint32_t display_buffer_index) {
|
||||
// Presentation copies the display buffer when the flip executes, so the buffer is always safe to
|
||||
// render into; keep the arguments in a NOP for command-buffer dumps.
|
||||
return Agc::Command::Emit(buf, 0x10u, {video_out_handle, display_buffer_index}, __func__);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbFlow/include/Dispatch.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbDispatchIndirect(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint32_t flags) {
|
||||
// Graphics queues read the arguments at an offset from the base set by SetBaseDispatchIndirectArgs.
|
||||
Agc::Command::CheckBits(flags, 0xa038u | 0x41u, __func__);
|
||||
return Agc::Command::Emit(buf, 0x16u, {data_offset_in_bytes, flags | 0x41u}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDispatchIndirectGetSize() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbFlow/include/Memory.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbAcquireMem(CommandBuffer* buf, std::uint8_t engine, std::uint32_t cbDbOp, std::uint32_t gcrControl, const volatile void* base, std::uint64_t sizeBytes, std::uint32_t pollCycles) {
|
||||
Agc::Command::CheckBits(engine, 1, __func__);
|
||||
Agc::Command::CheckBits(cbDbOp, 0x7fffffffu, __func__);
|
||||
Agc::Command::CheckBits(gcrControl, 0x7ffffu, __func__);
|
||||
// The range only scopes cache maintenance, so round it outward to the 256-byte granularity the
|
||||
// packet encodes instead of rejecting unaligned ranges.
|
||||
const auto requested = reinterpret_cast<std::uintptr_t>(base);
|
||||
auto address = requested & ~static_cast<std::uintptr_t>(0xffu);
|
||||
const auto wholeAddressSpace = sizeBytes == 0xffffffffffffffffull || (address >> 40u) != 0 || sizeBytes > (1ull << 40u);
|
||||
if (wholeAddressSpace) address = 0;
|
||||
else sizeBytes = (sizeBytes + (requested - address) + 0xffu) & ~0xffull;
|
||||
Agc::Command::Require(pollCycles / 40u <= 0xffffu, __func__, "acquire poll interval overflow");
|
||||
return Agc::Command::Emit(buf, 0x58u, {(static_cast<std::uint32_t>(engine) << 31u) | cbDbOp, wholeAddressSpace ? 0u : static_cast<std::uint32_t>(sizeBytes >> 8u), 0, static_cast<std::uint32_t>(address >> 8u), 0, pollCycles / 40u, gcrControl}, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbAcquireMemGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbCopyData(CommandBuffer* buf, uint8_t dst, uint8_t dst_cache_policy, uint64_t dst_address, uint8_t src, uint8_t src_cache_policy, uint64_t src_address_or_immediate, uint8_t item_size, uint8_t write_confirm) {
|
||||
(void)buf;
|
||||
(void)dst;
|
||||
(void)dst_cache_policy;
|
||||
(void)dst_address;
|
||||
(void)src;
|
||||
(void)src_cache_policy;
|
||||
(void)src_address_or_immediate;
|
||||
(void)item_size;
|
||||
(void)write_confirm;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint64_t APS5_VABI sceAgcDcbCopyDataGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbDmaData(CommandBuffer* buf, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine) {
|
||||
return Agc::Command::WriteDma(buf, false, engine, dst, dstCachePolicy, dstAddress, src, srcCachePolicy, srcAddress, numBytes, waitForPrevious, writeConfirm, blockEngine, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbDmaDataGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbAtomicMem(CommandBuffer* buf, std::uint8_t atomicOp, std::uint8_t command, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t srcData, std::uint64_t compareData, std::uint16_t loopInterval) {
|
||||
(void)buf;
|
||||
(void)atomicOp;
|
||||
(void)command;
|
||||
(void)cachePolicy;
|
||||
(void)address;
|
||||
(void)srcData;
|
||||
(void)compareData;
|
||||
(void)loopInterval;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbAtomicMemGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbAtomicGdsGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbWriteData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t numDwords, std::uint8_t increment, std::uint8_t writeConfirm) {
|
||||
return Agc::Command::WriteData(buf, false, dst, cachePolicy, address, data, numDwords, increment, writeConfirm, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbWriteDataGetSize(uint32_t num_dwords) {
|
||||
(void)num_dwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "prx/libSceAgc/DcbFlow/include/Sync.hpp"
|
||||
|
||||
#include "prx/libSceAgc/Command/include/Memory.hpp"
|
||||
#include "prx/libSceAgc/Command/include/Packet.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
uint32_t* APS5_VABI sceAgcDcbCondExec(CommandBuffer* buf, const volatile uint32_t* address, uint32_t num_dwords) {
|
||||
(void)buf;
|
||||
(void)address;
|
||||
(void)num_dwords;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbCondExecGetSize(void) {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbWaitRegMem(CommandBuffer* buf, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles) {
|
||||
return Agc::Command::WriteWait(buf, size, compareFunction, operation, cachePolicy, address, reference, mask, pollCycles, __func__);
|
||||
}
|
||||
|
||||
uint32_t APS5_VABI sceAgcDcbWaitOnAddressGetSize(uint32_t size) {
|
||||
(void)size;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbEventWrite(CommandBuffer* buf, std::uint8_t eventType, const volatile void* address) {
|
||||
Agc::Command::CheckBits(eventType, 0x3fu, __func__);
|
||||
if ((eventType & 0xfeu) == 0x38u) {
|
||||
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
|
||||
Agc::Command::CheckAddress(guestAddress, 8, __func__);
|
||||
return Agc::Command::Emit(buf, 0x46u, {0x100u | eventType, static_cast<std::uint32_t>(guestAddress), static_cast<std::uint32_t>(guestAddress >> 32u)}, __func__);
|
||||
}
|
||||
Agc::Command::Require(address == nullptr, __func__, "this event does not use an address");
|
||||
const auto eventIndex = eventType == 7 || eventType == 15 || eventType == 16 ? 0x400u : 0u;
|
||||
return Agc::Command::Emit(buf, 0x46u, {eventIndex | eventType}, __func__);
|
||||
}
|
||||
|
||||
std::uint64_t APS5_VABI sceAgcDcbEventWriteGetSize(std::uint8_t eventType) {
|
||||
(void)eventType;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbStallCommandBufferParser(CommandBuffer* buf) {
|
||||
return Agc::Command::Emit(buf, 0x42u, {0}, __func__);
|
||||
}
|
||||
|
||||
std::uint32_t APS5_VABI sceAgcDcbStallCommandBufferParserGetSize() {
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::uint32_t* APS5_VABI sceAgcDcbMemSemaphore(CommandBuffer* buf, std::uint8_t action, std::uint8_t clientCode, const volatile void* address) {
|
||||
(void)buf;
|
||||
(void)action;
|
||||
(void)clientCode;
|
||||
(void)address;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_CONTEXTSTATE_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_CONTEXTSTATE_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_DISPLAY_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_DISPLAY_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_INIT_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_INIT_HPP
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_MARKER_HPP
|
||||
#define CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_MARKER_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include "SceTypes.hpp"
|
||||
|
||||
namespace Agc::Marker {
|
||||
|
||||
std::uint32_t* Push(CommandBuffer* buf, const char* str, const char* function);
|
||||
std::uint32_t* Pop(CommandBuffer* buf, const char* function);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loaded 100 of 1030 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user