133 Commits
0.27 ... 0.34

Author SHA1 Message Date
souldbminersmwc
ebcf07dab8 update files 2026-02-07 17:51:38 -05:00
souldbminersmwc
d170ca92ad ldr: rework reserved entries 2026-02-07 17:51:18 -05:00
souldbminersmwc
cab8a14b99 Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-02-06 19:43:48 -05:00
souldbminersmwc
b623dabce5 sysclk: fix 1963mhz bug 2026-02-06 19:42:58 -05:00
Dominator
e5eb49f2e5 Merge pull request #33 from Blaise-25/develop 2026-02-06 01:47:22 +02:00
Blaise-25
9f0a609735 Update README.md 2026-02-05 15:20:12 -08:00
Souldbminer
19a2e562bc Update README.md 2026-02-05 16:12:30 -05:00
souldbminersmwc
73c3311251 Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-02-04 19:33:30 -05:00
souldbminersmwc
eb7fca1c1a erista ram overclock support + reserved entried
if you use hoc-clk 0.33 and want to update follow these steps

go to config/horizon-oc/config.ini
remove these two entries:

crc32=xxxxxxxxxxx
is_first_load=0
2026-02-04 19:33:10 -05:00
Dominator
ad1f070a6b Update README.md 2026-02-05 01:17:10 +02:00
souldbminersmwc
3bad144280 sysclk: add cat script 2026-02-03 19:01:49 -05:00
souldbminersmwc
123d4b6080 Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-02-03 18:57:02 -05:00
souldbminersmwc
2f6ed69b92 sysclk: refine misc gui 2026-02-03 18:56:48 -05:00
Souldbminer
337f7e6ac0 Merge pull request #32 from OEMunlag/develop
proper github actions build
2026-02-03 15:57:29 -05:00
2fort sink
a5efa7ae72 Add files via upload 2026-02-03 16:55:48 -03:00
2fort sink
a8ee389681 Revert to last working
Updated the Docker image for the build container and removed unnecessary steps for creating compiler shims. Added packaging of the dist folder as a ZIP file with the commit SHA.
2026-02-03 16:40:38 -03:00
2fort sink
54554bacea Change Docker image and install switch-dev
Updated the Docker image for the build container and added a step to install switch-dev.
2026-02-03 16:28:09 -03:00
2fort sink
3da2fc4b6d Merge branch 'Horizon-OC:develop' into develop 2026-02-03 15:05:11 -03:00
2fort sink
83287b1f5c Update build.yml 2026-02-02 21:53:24 -03:00
2fort sink
4f6756c609 Update build.yml 2026-02-02 21:29:05 -03:00
souldbminersmwc
ef2434c457 try to fix status monitor issues 2026-02-02 19:13:08 -05:00
2fort sink
b0237a2042 Update build.yml 2026-02-02 21:07:54 -03:00
2fort sink
c6275eb977 Update build.yml 2026-02-02 20:51:49 -03:00
2fort sink
72961aa2f1 Update build.yml 2026-02-02 20:46:58 -03:00
2fort sink
9c60697344 Merge branch 'Horizon-OC:develop' into develop 2026-02-02 20:45:15 -03:00
2fort sink
f786d97de1 Update build.yml 2026-02-02 20:44:06 -03:00
2fort sink
20389043ac Enhance build.yml with ccache shims for compilers
very hacky I know but we also fix exosphere hopefully with this
2026-02-02 20:37:56 -03:00
souldbminersmwc
00b9d8550e ldr: fix erista cpu validator
this DOES NOT fix erista cpu uv, but is probably part of the issue
2026-02-02 18:18:22 -05:00
2fort sink
0c0a4b3d6b Merge branch 'Horizon-OC:develop' into develop 2026-02-01 19:14:07 -03:00
2fort sink
61fd9d74d3 Update build.yml 2026-02-01 19:14:00 -03:00
2fort sink
f36383d0e7 Update build.yml 2026-02-01 18:58:52 -03:00
souldbminersmwc
606cafbaad sysclk: rework TDP 2026-02-01 16:33:15 -05:00
2fort sink
cff4267a68 Fix ROOT variable assignment in build workflow 2026-02-01 18:32:01 -03:00
2fort sink
65e7d83972 Update build.yml 2026-02-01 18:26:30 -03:00
2fort sink
e2533e2bb0 Patch exosphere and build, fix comment and zip making redundancy 2026-02-01 18:19:23 -03:00
souldbminersmwc
0d4ca24538 sysclk: add kip auto update feature 2026-02-01 16:15:08 -05:00
2fort sink
6c94f5754c Update build.yml 2026-02-01 17:58:52 -03:00
2fort sink
aaf77997e1 Update build.yml 2026-02-01 17:52:44 -03:00
2fort sink
c933e02aed Merge branch 'Horizon-OC:develop' into develop 2026-02-01 17:46:47 -03:00
2fort sink
770c25dbcb build hoc-clk and shallow clone ams
Updated the build process to use shallow clones and added a new build step for the hoc-clk sysmodule and overlay.
2026-02-01 17:44:20 -03:00
souldbminersmwc
bf8a6c4785 sysclk: fix uv3 cappings 2026-02-01 15:27:17 -05:00
2fort sink
dbb4d698a0 Increase make parallel jobs and update file paths 2026-02-01 16:12:26 -03:00
2fort sink
6ae084433f Update build.yml 2026-02-01 15:58:29 -03:00
2fort sink
32f19c4f0e Update build.yml 2026-02-01 15:48:47 -03:00
2fort sink
05cf2ab4dd Clone Atmosphere with specific branch from file 2026-02-01 14:28:37 -03:00
2fort sink
13a4ea4ca0 create ams_ver.txt
Should be self-explanatory, we use this for the actions build system
2026-02-01 14:27:02 -03:00
2fort sink
e2ef52e095 Update build.yml 2026-02-01 14:25:15 -03:00
2fort sink
bbd3b1a0fc Refactor build.yml for environment setup and ccache
Updated the build workflow to set environment variables using GitHub Actions environment files and improved the ccache installation step.
2026-02-01 14:22:31 -03:00
2fort sink
8dcfb55646 retry
cache and actions cache
2026-02-01 14:15:59 -03:00
2fort sink
ae0f4c7963 Delete .github/workflows/build.yml 2026-02-01 13:54:21 -03:00
2fort sink
222db76200 refactor this test testing woo waa waewewe waowowoewewahaaswadisadasud
Updated comments and modified build steps in the GitHub Actions workflow.
2026-02-01 13:52:55 -03:00
souldbminersmwc
2376b85d3a remove build action
way too slow to be practical
2026-01-31 18:52:23 -05:00
souldbminersmwc
26fb76e448 Update build.yml 2026-01-31 18:42:54 -05:00
souldbminersmwc
159c7567c0 Update build.yml 2026-01-31 18:41:42 -05:00
souldbminersmwc
39366ce238 Update build.yml 2026-01-31 18:40:33 -05:00
souldbminersmwc
da631ad268 Create build.yml 2026-01-31 18:37:47 -05:00
souldbminersmwc
d508177d4b Delete build.yml 2026-01-31 17:31:47 -05:00
souldbminersmwc
d8527410de Update build.yml 2026-01-31 17:30:17 -05:00
souldbminersmwc
bae7216de0 Update build.yml 2026-01-31 17:29:34 -05:00
souldbminersmwc
b3ddf172e8 Update build.yml 2026-01-31 17:28:25 -05:00
souldbminersmwc
cdaea8f729 fix build script 2026-01-31 17:27:18 -05:00
souldbminersmwc
918ca5757c chore: add build script 2026-01-31 17:25:30 -05:00
souldbminersmwc
93cb0e99c4 build: remove broken build script 2026-01-31 17:20:06 -05:00
souldbminersmwc
4692529346 chore: clean up repo 2026-01-31 17:19:33 -05:00
souldbminersmwc
8de1191ed5 sysclk: rename ipc service 2026-01-31 17:15:06 -05:00
souldbminersmwc
1c21187f73 sysclk: remove unused stuff 2026-01-31 17:12:50 -05:00
souldbminersmwc
2646995b72 sysclk: rework clock capping 2026-01-30 19:44:12 -05:00
souldbminersmwc
cf21342b2e Update pcv_erista.cpp 2026-01-28 15:45:45 -05:00
souldbminersmwc
3709fb3fba ldr: fix default gpu vmin 2026-01-28 15:41:50 -05:00
souldbminersmwc
ea754707ee sysclk: fix erista gpu vmin 2026-01-28 15:39:56 -05:00
souldbminersmwc
bb96267d6c Adjust license 2026-01-26 19:30:18 -05:00
souldbminersmwc
a1fa16da3c misc changes 2026-01-26 19:29:45 -05:00
souldbminersmwc
aad126d611 rename uv table 2026-01-26 19:26:30 -05:00
souldbminersmwc
835189febc update 2026-01-26 19:23:28 -05:00
souldbminersmwc
a9cf59fe28 ldr: UV3 doesn't exist anymore 2026-01-26 19:08:27 -05:00
souldbminersmwc
7708e4bae6 Update pcv.cpp 2026-01-26 19:07:52 -05:00
souldbminersmwc
8c71227c63 sysclk: improve cpu fix 2026-01-26 16:41:35 -05:00
souldbminersmwc
627732326b Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-01-26 16:26:09 -05:00
souldbminersmwc
f5d9761853 fix cpu bug 2026-01-26 16:25:25 -05:00
Lightos1
1d219e9425 Extend vdd2 validators 2026-01-25 13:07:13 +01:00
Lightos1
2c14ddad5c Extend vddq validator 2026-01-25 11:41:05 +01:00
souldbminersmwc
fee7e7a4f4 Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-01-24 18:54:58 -05:00
souldbminersmwc
caeee5920b sysclk: fix cpu boost clock 2026-01-24 18:54:56 -05:00
Lightos1
71fbeef32a Revert "Update ptm.cpp", worked before
This reverts commit 86fce20b27.
2026-01-24 22:14:19 +01:00
souldbminersmwc
86fce20b27 Update ptm.cpp 2026-01-24 15:17:50 -05:00
Lightos1
5012836c7e finally fix voltage bug for real 2026-01-24 20:43:35 +01:00
Lightos1
af1c36d00a Fix 1333 base latency at >=2533Mhz 2026-01-24 20:13:48 +01:00
souldbminersmwc
5dca0a9d9b Update clock_manager.cpp 2026-01-23 19:49:43 -05:00
souldbminersmwc
d3b1e9d31d sysclk: revise cpu volt bugfix 2026-01-23 18:33:09 -05:00
souldbminersmwc
64301c6d33 sysclk: fix warnings 2026-01-21 19:55:25 -05:00
souldbminersmwc
9b4544856e Update format.h 2026-01-21 18:54:23 -05:00
souldbminersmwc
d8104bfc6f fix submodules yet again 2026-01-21 18:32:20 -05:00
souldbminersmwc
39e666599d finish submodule linking 2026-01-21 18:30:32 -05:00
souldbminersmwc
d3ff7857e7 sysclk: add licensed and link libultrahand as submodules 2026-01-21 18:29:59 -05:00
souldbminersmwc
662473b2c0 sysclk: include libnx globally 2026-01-21 18:23:30 -05:00
souldbminersmwc
051c637dd8 sysclk: add safety check to misc gui 2026-01-21 18:19:30 -05:00
souldbminersmwc
28a772c546 sysclk: add danger/warning colors to cpu max clock 2026-01-21 18:16:59 -05:00
souldbminersmwc
4a06176897 sysclk: add display unsafe freq option 2026-01-21 18:15:28 -05:00
souldbminersmwc
7325905476 Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-01-21 16:47:25 -05:00
souldbminersmwc
ed8eed2c57 bump version 2026-01-21 16:47:20 -05:00
Lightos1
9723fdc2e0 Lazy timing fix, clean up later 2026-01-21 22:45:47 +01:00
souldbminersmwc
2856f6f778 sysclk: add AUTO vmin to overlay and add warning/danger for LCD 2026-01-21 16:44:24 -05:00
Lightos1
4187daf029 Revert "pcv_mariko: unhardcode pllmb divisor"
This reverts commit 12e6f114a8.
2026-01-21 22:32:54 +01:00
souldbminersmwc
c479f9c53c ldr: allow 1963 cpu cap + revise gpu UV 2026-01-21 16:27:14 -05:00
souldbminersmwc
a5357e298a sysclk: fix typo 2026-01-21 15:53:33 -05:00
souldbminersmwc
045bd81887 pcv: fix auto vmin on low speedos 2026-01-21 15:52:54 -05:00
souldbminersmwc
ae22e70602 Merge branch 'develop' of https://github.com/Horizon-OC/Horizon-OC into develop 2026-01-21 15:49:50 -05:00
souldbminersmwc
12e6f114a8 pcv_mariko: unhardcode pllmb divisor 2026-01-21 15:49:43 -05:00
Lightos1
d6fec8bdaa Fix r2p 2026-01-21 21:49:07 +01:00
souldbminersmwc
5a8a9ae79d ldr: fix wev 2026-01-21 15:48:17 -05:00
souldbminersmwc
6d0399f352 ldr/sysclk: update tWRL setting method 2026-01-21 15:45:51 -05:00
Lightos1
382f6d5834 Bump version 2026-01-21 19:53:30 +01:00
Lightos1
679fd4fd79 1866/1600 support 2026-01-21 18:50:36 +01:00
souldbminersmwc
c4a59d72b7 Update horizon-oc-overlay.ovl 2026-01-18 19:39:20 -05:00
souldbminersmwc
cc2f58f1d7 fix settings button 2026-01-18 19:38:22 -05:00
souldbminersmwc
9b1d2aecbb misc: recompile 0.29 2026-01-18 19:27:52 -05:00
souldbminersmwc
b08dd6c60d easter: improve easter egg 2026-01-18 19:21:36 -05:00
souldbminersmwc
2508cbfd16 sysclk: add licenses 2026-01-18 18:50:33 -05:00
souldbminersmwc
f1a5804b6c easter: add easter_egg 2026-01-18 18:47:43 -05:00
souldbminersmwc
e928eda703 sysclk: merge info/about gui 2026-01-18 18:28:10 -05:00
souldbminersmwc
cb75e79607 hocclk: add about gui 2026-01-18 17:05:48 -05:00
souldbminersmwc
66d3347771 cat: remove cat 2026-01-18 16:51:14 -05:00
souldbminersmwc
1e6d080361 cat: add cat 2026-01-18 16:49:13 -05:00
souldbminersmwc
0ddb5bb828 misc: do stuff 2026-01-18 16:48:05 -05:00
souldbminersmwc
abcf11dc51 configurator: remove 2026-01-18 16:44:09 -05:00
souldbminersmwc
1606b0af11 ondeviceconfig: remove 2026-01-18 16:43:49 -05:00
souldbminersmwc
2060fbe86d sysclk: bump version 2026-01-18 16:33:29 -05:00
souldbminersmwc
2f8cc92e43 sysclk: minor UI changes 2026-01-18 16:28:43 -05:00
souldbminersmwc
b51b8dbbcd sysclk: minor changes 2026-01-18 16:26:30 -05:00
Lightos1
ccb446b1ab bump version 2026-01-14 07:41:05 +01:00
Lightos1
62b77e4a82 bump version 2026-01-14 07:35:25 +01:00
Souldbminer
e078bdb2f8 Update LICENSE 2026-01-13 20:29:23 -05:00
Lightos1
a23db6e63d Better dram timings 2026-01-12 20:49:49 +01:00
259 changed files with 6300 additions and 48568 deletions

171
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,171 @@
name: Build Horizon OC Zeus
on:
push:
branches: [ develop, main, master ]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
# Minimal devkitA64 container, apparently dkp-toolchain isn't needed?
container:
image: devkitpro/devkita64:20251231
steps:
- name: Checkout repository and submodules # needed for hoc-clk
uses: actions/checkout@v6.0.2
with:
submodules: recursive
# -------------------------------------------------
# Fix PATH for devkitA64 and devkitARM
# -------------------------------------------------
- name: Set devkitPro PATH
run: |
echo "DEVKITPRO=/opt/devkitpro" >> $GITHUB_ENV
echo "DEVKITA64=/opt/devkitpro/devkitA64" >> $GITHUB_ENV
echo "DEVKITARM=/opt/devkitpro/devkitARM" >> $GITHUB_ENV
echo "PATH=/opt/devkitpro/devkitA64/bin:/opt/devkitpro/devkitARM/bin:$PATH" >> $GITHUB_ENV
shell: bash
- name: Check devkitPro gcc and g++ versions
run: |
aarch64-none-elf-gcc --version
aarch64-none-elf-g++ --version
shell: bash # is this even needed? but for consistency let's keep using it
- name: Install ccache
run: |
apt-get update
apt-get install -y ccache
shell: bash
# -------------------------------------------------
# Get short commit SHA
# -------------------------------------------------
- name: Set commit SHA
id: vars
run: echo "SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Clone Atmosphere
run: git clone --depth=1 --single-branch https://github.com/Atmosphere-NX/Atmosphere.git atmosphere -b $(cat ams_ver.txt)
- name: Prepare build folder
run: |
mkdir -p build
cp -r atmosphere/* build/
- name: Override ldr_process_creation.cpp
run: |
cp -rf Source/Atmosphere/stratosphere/loader/source/* build/stratosphere/loader/source/
- name: Cache ccache
uses: actions/cache@v5.0.3
with:
path: /root/.cache/ccache
key: ccache-${{ runner.os }}-devkitpro-ams-${{ hashFiles('ams_ver.txt') }} # last key was utter garbage, stick to ams versions,
restore-keys: |
ccache-${{ runner.os }}-devkitpro-
- name: Configure ccache
run: |
export CCACHE_DIR=/root/.cache/ccache
echo "CCACHE_DIR=/root/.cache/ccache" >> $GITHUB_ENV
ccache --set-config=max_size=10G
ccache --set-config=compiler_check=content
ccache --zero-stats
- name: Build hoc-clk sysmodule and overlay
shell: bash
run: |
export CC="ccache aarch64-none-elf-gcc"
export CXX="ccache aarch64-none-elf-g++"
ROOT_DIR="$GITHUB_WORKSPACE/Source/sys-clk"
DIST_DIR="$ROOT_DIR/dist"
mkdir -p "$DIST_DIR"
echo "*** sysmodule ***"
TITLE_ID="$(grep -oP '"title_id":\s*"0x\K(\w+)' \
"$ROOT_DIR/sysmodule/perms.json")"
echo "TITLE_ID: $TITLE_ID"
pushd "$ROOT_DIR/sysmodule"
make -j$(($(nproc) * 2)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc"
popd
mkdir -p "$DIST_DIR/atmosphere/contents/$TITLE_ID/flags"
cp -vf \
"$ROOT_DIR/sysmodule/out/horizon-oc.nsp" \
"$DIST_DIR/atmosphere/contents/$TITLE_ID/exefs.nsp"
: >"$DIST_DIR/atmosphere/contents/$TITLE_ID/flags/boot2.flag"
cp -vf \
"$ROOT_DIR/sysmodule/toolbox.json" \
"$DIST_DIR/atmosphere/contents/$TITLE_ID/toolbox.json"
echo "*** overlay ***"
pushd "$ROOT_DIR/overlay"
make -j$(($(nproc) * 2)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc"
popd
mkdir -p "$DIST_DIR/switch/.overlays"
cp -vf \
"$ROOT_DIR/overlay/out/horizon-oc-overlay.ovl" \
"$DIST_DIR/switch/.overlays/horizon-oc-overlay.ovl"
echo "*** assets ***"
mkdir -p "$DIST_DIR/config/horizon-oc"
cp -vf \
"$ROOT_DIR/config.ini.template" \
"$DIST_DIR/config/horizon-oc/config.ini.template"
cp -vf \
"$ROOT_DIR/README.md" \
"$DIST_DIR/README.md"
- name: Build kip
working-directory: build/stratosphere/loader
run: |
export CC="ccache aarch64-none-elf-gcc"
export CXX="ccache aarch64-none-elf-g++"
make -j$(($(nproc) * 4)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc"
hactool -t kip1 out/nintendo_nx_arm64_armv8a/release/loader.kip --uncompress=hoc.kip
cp hoc.kip ../../../dist/atmosphere/kips/hoc.kip
- name: ccache stats
run: ccache --show-stats
# -------------------------------------------------
# Package dist folder as ZIP with commit SHA
# -------------------------------------------------
- name: Package dist
# working-directory: horizon-oc
run: |
ZIP_NAME="horizon-oc-zeus-dist-${SHORT_SHA}.zip"
zip -r "$ZIP_NAME" dist
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
# -------------------------------------------------
# Upload ZIP artifact
# -------------------------------------------------
- name: Upload build artifact
uses: actions/upload-artifact@v6
with:
name: horizon-oc-zeus-dist-${{ env.SHORT_SHA }}
path: dist/
compression-level: 3

1
.gitignore vendored
View File

@@ -1,6 +1,5 @@
*.DS_Store
.vscode/
dist/
.pyc
build/
__pycache__/

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[submodule "Source/Horizon-OC-Monitor/lib/libultrahand"]
path = Source/Horizon-OC-Monitor/lib/libultrahand
url = https://github.com/ppkantorski/libultrahand
[submodule "Source/sys-clk/overlay/lib/libultrahand"]
path = Source/sys-clk/overlay/lib/libultrahand
url = https://github.com/ppkantorski/libultrahand

View File

@@ -4,8 +4,7 @@
- Tinymembench is under MIT license, which is compatible with GPL v2.
- Although "sys-clk" uses permissive license, all modifications towards it in this repo ("hoc-sys") are licensed under GPL v2.
- Although "sys-clk" uses permissive license, all modifications towards it in this repo ("hoc-clk") are licensed under GPL v2.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

View File

@@ -7,7 +7,7 @@
![License: GPL-2.0](https://img.shields.io/badge/GPL--2.0-red?style=for-the-badge)
![Nintendo Switch](https://img.shields.io/badge/Nintendo_Switch-E60012?style=for-the-badge\&logo=nintendo-switch\&logoColor=white)
[![Discord](https://img.shields.io/badge/Discord-5865F2?style=for-the-badge\&logo=discord\&logoColor=white)](https://discord.com/invite/S3eX47dHsB)
[![Discord](https://img.shields.io/badge/Discord-5865F2?style=for-the-badge\&logo=discord\&logoColor=white)](https://dsc.gg/horizonoc)
![VSCode](https://img.shields.io/badge/VSCode-0078D4?style=for-the-badge\&logo=visual%20studio%20code\&logoColor=white)
![Made with Notepad++](assets/np++.png?raw=true)
![C++](https://img.shields.io/badge/C%2B%2B-00599C?style=for-the-badge\&logo=c%2B%2B\&logoColor=white)
@@ -44,7 +44,7 @@ It enables advanced CPU, GPU, and RAM tuning with user-friendly configuration to
> *Higher (potentially dangerous) frequencies are unlockable via configuration.*
> *Erista and Mariko units can usually push a bit further fully safely with a bit of undervolting, however this may not work on all units.*
> *The exact maximum overclock possible varies per console, although most consoles should be able to do this safely.*
> *You may refer to the Clock Table to see clocks in more detail*
---
## Installation
@@ -69,7 +69,7 @@ It enables advanced CPU, GPU, and RAM tuning with user-friendly configuration to
1. Open the Horizon OC Overlay
2. Open the settings menu
3. Adjust your overclocking settings as desired.
3. Adjust your overclocking settings as desired. A helpful guide can be found [here.](https://rentry.co/mariko#oc-settings-for-horizon-oc)
4. Click **Save KIP Settings** to apply your configuration.
---
@@ -78,6 +78,73 @@ It enables advanced CPU, GPU, and RAM tuning with user-friendly configuration to
Refer to COMPILATION.md
---
## Clock table
### MEM clocks
* 3200 → max on mariko, JEDEC.
* 2933 → JEDEC.
* 2666 → JEDEC.
* 2400 → max on erista, JEDEC.
* 2133 → mariko safe max (4266 Modules), JEDEC.
* 1996 → JEDEC.
* 1866 → mariko safe max (3733 Modules), JEDEC.
* 1600 → official docked, boost mode, erista safe max, JEDEC.
* 1331 → official handheld, JEDEC.
* 1065
* 800
* 665
### CPU clocks
* 2601 → mariko absolute max, very dangerous
* 2499
* 2397
* 2295 → mariko safe max with UV (low speedo)
* 2193
* 2091
* 1963 → mariko no UV max clock
* 1887
* 1785 → erista no UV max clock, boost mode
* 1683
* 1581
* 1428
* 1326
* 1224 → sdev oc
* 1122
* 1020 → official docked & handheld
* 918
* 816
* 714
* 612 → sleep mode
### GPU clocks
* 1536 → absolute max clock on mariko. very dangerous
* 1459
* 1382
* 1305
* 1267 → NVIDIA T214 rating
* 1228 → mariko HiOPT safe clock
* 1152 → mariko SLT max clock
* 1075 → mariko no UV max clock. absolute max clock on erista. very dangerous
* 998 → NVIDIA T210 rating
* 960 (erista only) → erista slt/hiopt safe max clock
* 921 → erista no UV max clock
* 844
* 768 → official docked
* 691
* 614
* 537
* 460 → max handheld
* 384 → official handheld
* 307 → official handheld
* 230
* 153
* 76 → boost mode
**Notes:**
1. GPU overclock is capped at 460MHz in handheld and capped at 768MHz if charging, unless you're using the official charger.
2. Clocks higher than 768MHz need the official charger is plugged in.
---
## Credits
@@ -90,7 +157,7 @@ Refer to COMPILATION.md
* **hanai3bi (meha)** Switch OC Suite, EOS, sys-clk-eos
* **NaGaa95** L4T-OC-kernel
* **B3711 (halop)** EOS
* **sys-clk team (m4xw, p-sam, nautalis)** sys-clk
* **sys-clk team (m4xw, p-sam, natinusala)** sys-clk
* **b0rd2death** Ultrahand sys-clk & Status Monitor fork
* **MasaGratoR and ZachyCatGames** - General help
* **MasaGratoR** - Status Monitor & Display Refresh Rate Driver

View File

@@ -1,6 +1,8 @@
/*
* Copyright (c) Atmosphère-NX
*
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -37,7 +37,7 @@ volatile CustomizeTable C = {
.commonEmcMemVolt = 1175000, // LPDDR4X JEDEC Specification
.eristaEmcMaxClock = 1600000, // Maximum HB-MGCH ram rating
.marikoEmcMaxClock = 2133000,
.marikoEmcMaxClock = 1866000, // 1866MHz @ 1866tWRL is guaranteed to work on all Mariko units
.marikoEmcVddqVolt = 600000,
.emcDvbShift = 0,
@@ -54,8 +54,21 @@ volatile CustomizeTable C = {
/* Set to 4 read and 2 write for 1866b tWRL. */
/* For 2133 tWRL: 8 read and 4 write. */
.mem_burst_read_latency = 8,
.mem_burst_write_latency = 4,
/*
* Read:
* 2133RL = 40
* 1866RL = 36
* 1600RL = 32
* 1331RL = 28
* Write:
* 2133WL = 18
* 1866WL = 16
* 1600WL = 14
* 1331WL = 12
*/
.mem_burst_read_latency = 36,
.mem_burst_write_latency = 16,
.eristaCpuUV = 0,
.eristaCpuVmin = 800,
@@ -65,26 +78,29 @@ volatile CustomizeTable C = {
.marikoCpuUVLow = 0, // No undervolt
.marikoCpuUVHigh = 0, // No undervolt
.tableConf = DEFAULT_TABLE, /* TODO: Add AUTO */
.tableConf = DEFAULT_TABLE,
.marikoCpuLowVmin = 620,
.marikoCpuHighVmin = 750,
.marikoCpuMaxVolt = 1120,
/* Supported values: 2397000, 2499000, 2601000, 2703000. */
/* Supported values: 1963000, 2091000, 2193000, 2295000, 2397000, 2499000, 2601000, 2703000. */
/* 1963000 is official rating of T214/Mariko, fully safe. */
/* 2091000-2295000 is a slight OC which should work on all units, but no guarantees. */
/* 2397000 is the max safe OC for most average units with tuned undervolt. */
/* 2499000 should be used with caution. */
/* 2601000 exceeds pmic limit on most consoles. */
/* 2703000 is potentially dangerous and not advised. */
.marikoCpuMaxClock = 2397000,
.marikoCpuMaxClock = 1963000,
.eristaCpuBoostClock = 1785000, // Default boost clock
.marikoCpuBoostClock = 1963000, // Default boost clock
.eristaGpuUV = 0,
.eristaGpuVmin = 800,
.eristaGpuVmin = 810,
.marikoGpuUV = 0,
/* For automatic vmin detection, set this to AUTO. */
.marikoGpuVmin = 610,
.marikoGpuVmin = AUTO,
.marikoGpuVmax = 800,
@@ -95,8 +111,9 @@ volatile CustomizeTable C = {
/* This table is used with a gpu uv mode of 2. */
/* Setting DEACTIVATED_GPU_FREQ on any freq will disable it and all freqs greater than it. (the latter is a bug :/) */
/* AUTO: Voltage is optimally chosen; with commonGpuVoltOffset applied. */
/* AUTO only works up to 1305 GPU */
/* AUTO only works up to 1305 GPU on Mariko and 921 GPU on Erista */
/* You can overwrite auto with any voltage (in mv) of your choice - offset will not be applied. */
.eristaGpuVoltArray = {
AUTO /* 76 */,
AUTO /* 115 */,
@@ -142,9 +159,9 @@ volatile CustomizeTable C = {
AUTO /* 921 */,
AUTO /* 998 */,
AUTO /* 1075 */,
AUTO /* 1152 */,
AUTO /* 1228 */,
AUTO /* 1267 (Disabled by default) */,
DEACTIVATED_GPU_FREQ /* 1152 */,
DEACTIVATED_GPU_FREQ /* 1228 */,
DEACTIVATED_GPU_FREQ /* 1267 (Disabled by default) */,
DEACTIVATED_GPU_FREQ /* 1305 (Disabled by default) */,
DEACTIVATED_GPU_FREQ /* 1344 (Disabled by default) */,
DEACTIVATED_GPU_FREQ /* 1382 (Disabled by default) */,
@@ -310,7 +327,7 @@ volatile CustomizeTable C = {
{ 2703000, { 1838820, -36648, 113, }, { CPU_MAX_MAX_VOLT, } },
},
.marikoCpuDvfsTableHelios {
.marikoCpuDvfsTableExtreme {
{ 204000, { 732856, -17335, 113, }, { } },
{ 306000, { 760024, -18195, 113, }, { } },
{ 408000, { 789258, -19055, 113, }, { } },

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -38,7 +38,7 @@ enum TableConfig: u32 {
DEFAULT_TABLE = 1,
TBREAK_1581 = 2,
TBREAK_1683 = 3,
HELIOS_TABLE = 4,
EXTREME_TABLE = 4,
};
using CustomizeCpuDvfsTable = pcv::cvb_entry_t[pcv::DvfsTableEntryLimit];
@@ -58,11 +58,9 @@ typedef struct CustomizeTable {
u32 commonEmcMemVolt;
u32 eristaEmcMaxClock;
u32 marikoEmcMaxClock;
u32 marikoEmcVddqVolt;
u32 emcDvbShift;
// advanced config
u32 t1_tRCD;
u32 t2_tRP;
@@ -106,7 +104,7 @@ typedef struct CustomizeTable {
u32 eristaGpuVoltArray[27];
u32 marikoGpuVoltArray[24];
u32 reserved[64];
CustomizeCpuDvfsTable eristaCpuDvfsTable;
CustomizeCpuDvfsTable eristaCpuDvfsTableSLT;
@@ -114,7 +112,7 @@ typedef struct CustomizeTable {
CustomizeCpuDvfsTable marikoCpuDvfsTableSLT;
CustomizeCpuDvfsTable marikoCpuDvfsTable1581Tbreak;
CustomizeCpuDvfsTable marikoCpuDvfsTable1683Tbreak;
CustomizeCpuDvfsTable marikoCpuDvfsTableHelios;
CustomizeCpuDvfsTable marikoCpuDvfsTableExtreme;
CustomizeGpuDvfsTable eristaGpuDvfsTable;
CustomizeGpuDvfsTable eristaGpuDvfsTableSLT;

View File

@@ -27,41 +27,6 @@ namespace ams::ldr::oc::pcv::mariko {
return 0x1A;
}
/* TODO: This function is quite uggly, refactor! */
void CalculateMiscTimings() {
rdv = 0x39 + C.mem_burst_read_latency;
einput_duration = 0x1C;
quse_width = 0x8;
for (u32 i = 0; i < g_misc_table_size; i++) {
const auto& e = g_misc_table[i];
if (C.marikoEmcMaxClock >= e.min_freq) {
rdv += e.rdv_inc;
if (e.einput) einput_duration = e.einput;
if (e.quse_width) quse_width = e.quse_width;
}
}
rext = GetRext();
}
void CalculateIbdly() {
/* Ibdly is so inconsistent, I am using the most common value and then checking with a lookup table. */
ibdly = 0x1000001D + C.mem_burst_read_latency;
if (auto patch = FindIbdlyPatch()) {
ibdly += patch->adjust;
}
}
void CalculateObdly() {
obdly = 0x10000002 + C.mem_burst_write_latency;
if (auto patch = FindObdlyPatch()) {
obdly += patch->adjust;
}
}
void CalculateTWTPDEN() {
tWTPDEN = tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6;
if (C.marikoEmcMaxClock >= 2'233'000 && C.marikoEmcMaxClock < 2'533'000) tWTPDEN++;
@@ -76,37 +41,6 @@ namespace ams::ldr::oc::pcv::mariko {
}
}
void CalculateQrst() {
qrst = 0x00070000;
u32 qrst_calc = ROUND(22.1 - (C.marikoEmcMaxClock / 1000000.0) * 8.0) + C.mem_burst_read_latency;
u32 qrst_low = MAX(static_cast<u32>(0), qrst_calc);
if (C.marikoEmcMaxClock >= 2'533'000) {
qrst = INCREMENT_HIGH_BYTES_BY(qrst, 1);
} else if (C.marikoEmcMaxClock == 2'800'000) {
qrst = SET_HIGH_BYTES(qrst, 6);
}
qrst = SET_LOW_BYTES(qrst, qrst_low);
if (auto patch = FindQrstPatch()) {
qrst = INCREMENT_LOW_BYTES_BY(qrst, patch->adjust);
}
}
void CalculateQsafe() {
qsafe = ROUND((C.marikoEmcMaxClock / 1000.0) / 138.0 + 37.4) + C.mem_burst_read_latency;
if (auto patch = FindQsafePatch()) {
qsafe += patch->adjust;
}
}
void CalculateQpop() {
qpop = FLOOR(((C.marikoEmcMaxClock / 1000.0) - 2133 + 167) / 200.0) + 0x2D + C.mem_burst_read_latency;
if (C.marikoEmcMaxClock >= 3'133'000) qpop++;
}
void CalculatePdex2rw() {
double freq_mhz = C.marikoEmcMaxClock / 1000.0;
@@ -129,17 +63,42 @@ namespace ams::ldr::oc::pcv::mariko {
}
}
void CalculateMrw2() {
static const u8 rlMapDBI[8] = {
6, 12, 16, 22, 28, 32, 36, 40
};
static const u8 wlMapSetA[8] = {
4, 6, 8, 10, 12, 14, 16, 18
};
u32 rlIndex = 0;
u32 wlIndex = 0;
for (u32 i = 0; i < std::size(rlMapDBI); ++i) {
if (rlMapDBI[i] == RL_DBI) {
rlIndex = i;
break;
}
}
for (u32 i = 0; i < std::size(wlMapSetA); ++i) {
if (wlMapSetA[i] == WL) {
wlIndex = i;
break;
}
}
mrw2 = static_cast<u8>(((rlIndex & 0x7) | ((wlIndex & 0x7) << 3) | ((0 & 0x1) << 6)));
}
void CalculateTimings() {
CalculateMiscTimings();
CalculateIbdly();
CalculateObdly();
rext = GetRext();
CalculateTWTPDEN();
CalculateTR2W();
CalculateQrst();
CalculateQsafe();
CalculateQpop();
CalculatePdex2rw();
CalculateCke2pden();
CalculateMrw2();
}
}

View File

@@ -19,34 +19,6 @@
namespace ams::ldr::oc::pcv::mariko {
const MiscTimings g_misc_table[] = {
{1'866'000, 1, 0x20, 0x9, },
{2'133'000, 1, 0x24, 0xA, },
{2'166'000, 1, 0, 0, },
{2'233'000, 0, 0x25, 0, },
{2'300'000, 0, 0x26, 0xB, },
{2'333'000, 0, 0x27, 0, },
{2'366'000, 1, 0x26, 0xA, },
{2'433'000, 0, 0x27, 0, },
{2'466'000, 0, 0x2A, 0, },
{2'500'000, 0, 0x28, 0xB, },
{2'533'000, 0, 0x29, 0, },
{2'566'000, 1, 0, 0, },
{2'633'000, 0, 0x2A, 0, },
{2'700'000, 0, 0x2B, 0xC, },
{2'733'000, 0, 0x2C, 0, },
{2'766'000, 1, 0x2B, 0xB, },
{2'833'000, 0, 0x2C, 0, },
{2'866'000, 0, 0, 0, },
{2'900'000, 0, 0, 0, },
{2'933'000, 0, 0x2E, 0xC, },
{2'966'000, 1, 0, 0, },
{3'033'000, 0, 0x2F, 0, },
{3'133'000, 1, 0x31, 0xD, },
};
const u32 g_misc_table_size = sizeof(g_misc_table) / sizeof(g_misc_table[0]);
const ReplacePatch g_rext_table[] = {
{2'133'000, 0x1A}, {2'166'000, 0x19}, {2'200'000, 0x19},
{2'233'000, 0x19}, {2'266'000, 0x1A}, {2'300'000, 0x1B},
@@ -70,67 +42,6 @@ namespace ams::ldr::oc::pcv::mariko {
return nullptr;
}
const AdjustPatch g_ibdly_patches[] = {
{2'133'000, -2},
{2'166'000, -1},
{2'200'000, -1},
{2'233'000, -1},
{2'266'000, -1},
{2'300'000, -2},
{2'333'000, -2},
{2'500'000, -1},
{2'533'000, -2},
{2'566'000, -1},
{2'600'000, -1},
{2'633'000, -1},
{2'666'000, -1},
{2'700'000, -2},
{2'733'000, -2},
{2'933'000, -1},
};
const u32 g_ibdly_table_size = sizeof(g_ibdly_patches) / sizeof(g_ibdly_patches[0]);
const AdjustPatch *FindIbdlyPatch() {
for (u32 i = 0; i < g_ibdly_table_size; i++)
if (g_ibdly_patches[i].freq == C.marikoEmcMaxClock)
return &g_ibdly_patches[i];
return nullptr;
}
const AdjustPatch g_obdly_patches[] = {
{2'533'000, -2},
{2'566'000, -2},
{2'600'000, -2},
{2'633'000, -2},
{2'666'000, -2},
{2'700'000, -2},
{2'733'000, -2},
{2'766'000, -2},
{2'800'000, -2},
{2'833'000, -2},
{2'866'000, -2},
{2'900'000, -2},
{2'933'000, -2},
{2'966'000, -2},
{3'000'000, -2},
{3'033'000, -2},
{3'066'000, -2},
{3'100'000, -2},
{3'133'000, -2},
{3'166'000, -2},
{3'200'000, -2},
};
const u32 g_obdly_table_size = sizeof(g_obdly_patches) / sizeof(g_obdly_patches[0]);
const AdjustPatch *FindObdlyPatch() {
for (u32 i = 0; i < g_obdly_table_size; i++)
if (g_obdly_patches[i].freq == C.marikoEmcMaxClock)
return &g_obdly_patches[i];
return nullptr;
}
const AdjustPatch g_tr2w_patches[] = {
{2'500'000, 1},
{2'533'000, 1},
@@ -149,73 +60,6 @@ namespace ams::ldr::oc::pcv::mariko {
return nullptr;
}
const AdjustPatch g_qrst_patches[] = {
{2'166'000, 1},
{2'200'000, 1},
{2'233'000, 1},
{2'266'000, 1},
{2'366'000, 2},
{2'400'000, 2},
{2'433'000, 1},
{2'466'000, 2},
{2'500'000, 1},
{2'533'000, -1},
{2'600'000, 1},
{2'700'000, -1},
{2'733'000, -1},
{2'766'000, 1},
{2'800'000, 1},
{2'833'000, 1},
{2'866'000, 1},
{2'900'000, 1},
{2'933'000, -1},
{2'966'000, 1},
{3'000'000, 1},
{3'100'000, 1},
{3'166'000, 1},
{3'200'000, 1},
};
const u32 g_qrst_table_size = sizeof(g_qrst_patches) / sizeof(g_qrst_patches[0]);
const AdjustPatch *FindQrstPatch() {
for (u32 i = 0; i < g_qrst_table_size; i++)
if (g_qrst_patches[i].freq == C.marikoEmcMaxClock)
return &g_qrst_patches[i];
return nullptr;
}
const AdjustPatch g_qsafe_patches[] = {
{2'166'000, 1},
{2'200'000, 1},
{2'500'000, -1},
{2'533'000, -1},
{2'666'000, -1},
{2'700'000, -1},
{2'733'000, -1},
{2'800'000, -1},
{2'833'000, -1},
{2'866'000, -1},
{2'900'000, -1},
{2'933'000, -2},
{2'966'000, -1},
{3'000'000, -1},
{3'033'000, -1},
{3'066'000, -2},
{3'100'000, -2},
{3'166'000, -1},
{3'200'000, -1},
};
const u32 g_qsafe_table_size = sizeof(g_qsafe_patches) / sizeof(g_qsafe_patches[0]);
const AdjustPatch *FindQsafePatch() {
for (u32 i = 0; i < g_qsafe_table_size; i++)
if (g_qsafe_patches[i].freq == C.marikoEmcMaxClock)
return &g_qsafe_patches[i];
return nullptr;
}
const AdjustPatch g_pdex2rw_patches[] = {
{2'166'000, 1},
{2'300'000, 1},

View File

@@ -33,26 +33,10 @@ namespace ams::ldr::oc::pcv::mariko {
s32 adjust;
};
extern const AdjustPatch g_ibdly_patches[];
extern const u32 g_ibdly_table_size;
const AdjustPatch *FindIbdlyPatch();
extern const AdjustPatch g_obdly_patches[];
extern const u32 g_obdly_table_size;
const AdjustPatch *FindObdlyPatch();
extern const AdjustPatch g_tr2w_patches[];
extern const u32 g_tr2w_table_size;
const AdjustPatch *FindTR2WPatch();
extern const AdjustPatch g_qrst_patches[];
extern const u32 q_qrst_table_size;
const AdjustPatch *FindQrstPatch();
extern const AdjustPatch g_qsafe_patches[];
extern const u32 g_qsafe_table_size;
const AdjustPatch *FindQsafePatch();
extern const AdjustPatch g_pdex2rw_patches[];
extern const u32 g_pdex2rw_table_size;
const AdjustPatch *FindPdex2rwPatch();
@@ -61,14 +45,4 @@ namespace ams::ldr::oc::pcv::mariko {
extern const u32 g_cke2pden_table_size;
const AdjustPatch *FindCke2pdenPatch();
struct MiscTimings {
u32 min_freq;
u32 rdv_inc;
u32 einput;
u32 quse_width;
};
extern const MiscTimings g_misc_table[];
extern const u32 g_misc_table_size;
}

View File

@@ -27,37 +27,37 @@ namespace ams::ldr::oc {
#define FLOOR(A) std::floor(A)
#define ROUND(A) std::lround(A)
#define GET_LOW_BYTES(x) ((u16)((x) & 0xFFFF))
#define SET_LOW_BYTES(x, val) (((x) & 0xFFFF0000) | ((u32)(val) & 0xFFFF))
#define INCREMENT_LOW_BYTES_BY(x, n) SET_LOW_BYTES((x), (GET_LOW_BYTES(x) + (n)))
#define GET_HIGH_BYTES(x) ((u16)(((x) >> 16) & 0xFFFF))
#define SET_HIGH_BYTES(x, val) (((x) & 0x0000FFFF) | (((u32)(val) & 0xFFFF) << 16))
#define INCREMENT_HIGH_BYTES_BY(x, n) SET_HIGH_BYTES((x), (GET_HIGH_BYTES(x) + (n)))
#define PACK_U32(high, low) ((static_cast<u32>(high) << 16) | (static_cast<u32>(low) & 0xFFFF))
#define PACK_U32_NIBBLE_HIGH_BYTE_LOW(high, low) ((static_cast<u32>(high & 0xF) << 28) | (static_cast<u32>(low) & 0xFF))
/* Primary timings. */
const std::array<u32, 8> tRCD_values = { 18, 17, 16, 15, 14, 13, 12, 11 };
const std::array<u32, 8> tRP_values = { 18, 17, 16, 15, 14, 13, 12, 11 };
const std::array<u32, 10> tRAS_values = { 42, 36, 34, 32, 30, 28, 26, 24, 22, 20 };
const std::array<double, 7> tRRD_values = { /*10.0,*/ 7.5, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 }; /* 10.0 is used for <2133mhz; do we care? */
const std::array<double, 7> tRRD_values = { /*10.0,*/ 7.5, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 }; /* 10.0 is used for <2133mhz; do we care? 8gb uses 7.5 tRRD on >=1331. */
const std::array<u32, 11> tRFC_values = { 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40 };
const std::array<u32, 10> tWTR_values = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
const std::array<u32, 6> tREFpb_values = { 3900, 5850, 7800, 11700, 15600, 99999 };
/* Burst latency, not to be confused with base latency (tWRL). */
const u32 BL = 16;
const u32 RL = 28 + C.mem_burst_read_latency;
const u32 WL = 14 + C.mem_burst_write_latency;
/* Base latency for read and write (tWRL). */
const u32 RL = C.mem_burst_read_latency - 4; /* (This is a lazy fix for now) */
const u32 WL = C.mem_burst_write_latency;
/* Switch uses RL_DBI, todo: get rid of non DBI_RL. */
const u32 RL_DBI = RL + 4;
/* Precharge to Precharge Delay. (Cycles) */
/* Precharge to Precharge Delay. (tCK) */
const u32 tPPD = 4;
/* DQS output access time from CK_t/CK_c. */
const double tDQSCK_max = 3.5;
/* Write preamble. (tCK) */
const u32 tWPRE = 2;
/* tCK Read postamble. */
/* Read postamble. (tCK) */
const double tRPST = 0.5;
/* Minimum Self-Refresh Time. (Entry to Exit) */
@@ -66,52 +66,18 @@ namespace ams::ldr::oc {
/* Exit power down to next valid command delay. */
const double tXP = 7.5;
/* Write command to first DQS transition (max) (tCK) */
const double tDQSS_max = 1.25;
/* DQ-to-DQS offset(max) (ns) */
const double tDQS2DQ_max = 0.8;
/* Write recovery time. */
const u32 tWR = 18;
/* TOOD: Fix erista */
namespace pcv::erista {
// const double tCK_avg = 1000'000.0 / C.eristaEmcMaxClock;
//
// /* Primary timings. */
// const u32 tRCD = tRCD_values[C.t1_tRCD];
// const u32 tRPpb = tRP_values[C.t2_tRP];
// const u32 tRAS = tRAS_values[C.t3_tRAS];
//
// /* Secondary timings. */
// const double tRRD = tRRD_values[C.t4_tRRD];
// const u32 tRFCpb = tRFC_values[C.t5_tRFC];
// const u32 tWTR = tWTR_values[C.t7_tWTR];
// const u32 tREFpb = tREFpb_values[C.t8_tREFI];
//
// /* Four-bank ACTIVATE Window */
// const u32 tFAW = (u32) (tRRD * 4.0);
//
// /* Latency stuff. */
// const int tR2W = (int)((3.5 / tCK_avg) + 32 + (BL / 2) - 14 - 6 + tWPRE + 12 - (C.t6_tRTW * 3));
// const int tW2R = (int)((tWTR / tCK_avg) + 18 - (BL / 2));
// const int tRW2PDEN = (int)((tDQSS_max / tCK_avg) + 46 + (tDQS2DQ_max / tCK_avg) + 6);
//
// /* Refresh Cycle time. (All Banks) */
// const u32 tRFCab = tRFCpb * 2;
//
// /* ACTIVATE-to-ACTIVATE command period. (same bank) */
// const u32 tRC = tRAS + tRPpb;
//
// /* SELF REFRESH exit to next valid command delay. */
// const double tXSR = (double) (tRFCab + 7.5);
//
// /* u32ernal READ to PRECHARGE command delay. */
// const int pdex2mrr = (tCK_avg * 3.0) + tRCD_values[C.t1_tRCD] + 1;
//
// /* Row Precharge Time. (all banks) */
// const u32 tRPab = tRPpb + 3;
}
namespace pcv::mariko {
const double tCK_avg = 1000'000.0 / C.marikoEmcMaxClock;
const double tCK_avg = 1000'000.0 / C.eristaEmcMaxClock;
const u32 tRCD = tRCD_values[C.t1_tRCD];
const u32 tRPpb = tRP_values[C.t2_tRP];
@@ -126,39 +92,96 @@ namespace ams::ldr::oc {
const u32 tFAW = static_cast<u32>(tRRD * 4.0);
const double tRPab = tRPpb + 3;
const u32 tR2P = 12 + (C.mem_burst_read_latency / 2);
inline u32 tR2W;
const u32 tRTM = RL + 9 + (tDQSCK_max / tCK_avg) + FLOOR(tRPST) + CEIL(10 / tCK_avg); // Fix?
const u32 tRATM = tRTM + CEIL(10 / tCK_avg) - 12; // Fix?
inline u32 rdv;
const u32 quse = FLOOR((-0.0048159 * (C.marikoEmcMaxClock / 1000.0)) + RL_DBI) + (FLOOR((C.marikoEmcMaxClock / 1000.0) * 0.0050997) * 1.5134);
const u32 einput = quse - ((C.marikoEmcMaxClock / 1000.0) * 0.01);
inline u32 einput_duration;
inline u32 ibdly;
inline u32 obdly;
inline u32 quse_width;
inline u32 rext;
inline u32 qrst;
inline u32 qsafe;
inline u32 qpop;
const u32 tR2P = 12;
const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5;
const u32 tW2R = CEIL(MAX(WL + (0.010322547033278747 * (C.eristaEmcMaxClock / 1000.0)), (WL * -0.2067922202979121) + FLOOR(((RL_DBI * -0.1331159971685554) + WL) * 3.654131957826108)) - (tWTR / tCK_avg));
const u32 wdv = WL;
const u32 wsv = WL - 2;
const u32 wev = 0xA + (WL - 14);
const double freq_mhz = C.eristaEmcMaxClock / 1000.0;
const u32 quse_width = CEIL(((3.7165006256863955 - freq_mhz) + (-0.002446584377651142 * freq_mhz)) - FLOOR(freq_mhz / -0.9952024303111688));
const u32 quse = CEIL(MIN(RL_DBI + (2.991255208275918 - (quse_width + (-0.00511180626826906 * freq_mhz))), freq_mhz * 0.021333773138874437));
const u32 ibdly = 0x10000000 + FLOOR(MAX(RL_DBI - 1.9999956603408224, quse - 5.9999987787411175) + (-0.0011929079761504341 * freq_mhz));
const u32 obdlyHigh = 3 / FLOOR(MIN(static_cast<double>(2), tCK_avg * (WL - 7)));
const u32 obdlyLow = WL - MIN(static_cast<double>(WL), 12 - (CEIL(-0.0003991 * freq_mhz) * 2));
const u32 obdly = PACK_U32_NIBBLE_HIGH_BYTE_LOW(obdlyHigh, obdlyLow);
const u32 tCKE = CEIL(1.0795 * CEIL(0.0074472 * (C.eristaEmcMaxClock / 1000.0)));
const double tMMRI = tRCD + (tCK_avg * 3);
const double pdex2mrr = tMMRI + 10;
const u32 tWTPDEN = tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6;
const u32 tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE + FLOOR(tRPST) + 9.0) - (C.t6_tRTW * 3);
const double pdex_local = (0.011 * freq_mhz) - 1.443;
const u32 pdex2rw = static_cast<u32>(ROUND(pdex_local)) < 22 ? 22 : (static_cast<u32>(ROUND(pdex_local)) > 33 ? 33 : static_cast<u32>(ROUND(pdex_local)));
const double cke2pden = (static_cast<double>((C.eristaEmcMaxClock / 1000.0) * 0.00875) - 0.65);
}
namespace pcv::mariko {
const double tCK_avg = 1000'000.0 / C.marikoEmcMaxClock;
const double ramFreqMhz = C.marikoEmcMaxClock / 1000.0;
const u32 tRCD = tRCD_values[C.t1_tRCD];
const u32 tRPpb = tRP_values[C.t2_tRP];
const u32 tRAS = tRAS_values[C.t3_tRAS];
const double tRRD = tRRD_values[C.t4_tRRD];
const u32 tRFCpb = tRFC_values[C.t5_tRFC];
const u32 tWTR = 10 - tWTR_values[C.t7_tWTR];
const u32 tRC = tRAS + tRPpb;
const u32 tRFCab = tRFCpb * 2;
const double tXSR = static_cast<double>(tRFCab + 7.5);
const u32 tFAW = static_cast<u32>(tRRD * 4.0);
const double tRPab = tRPpb + 3;
const u32 tR2P = 12 + ((RL_DBI - 32) / 2);
inline u32 tR2W;
const u32 tRTM = RL + 9 + (tDQSCK_max / tCK_avg) + FLOOR(tRPST) + CEIL(10 / tCK_avg); // Fix?
const u32 tRATM = tRTM + CEIL(10 / tCK_avg) - 12; // Fix?
inline u32 rext;
const u32 rdv = FLOOR(17.02046755653219 + (RL_DBI + (ramFreqMhz * 0.00510056573299173)));
const u32 qpop = rdv - 14;
const u32 quse_width = CEIL(((3.7165006256863955 - ramFreqMhz) + (-0.002446584377651142 * ramFreqMhz)) - FLOOR(ramFreqMhz / -0.9952024303111688));
const u32 quse = CEIL(MIN(RL_DBI + (2.991255208275918 - (quse_width + (-0.00511180626826906 * ramFreqMhz))), ramFreqMhz * 0.021333773138874437));
const u32 einput_duration = CEIL(quse_width + (ramFreqMhz * 0.01) + 4);
const u32 einput = 5 + qpop - einput_duration;
const u32 ibdly = 0x10000000 + FLOOR(MAX(RL_DBI - 1.9999956603408224, quse - 5.9999987787411175) + (-0.0011929079761504341 * ramFreqMhz));
const u32 qrst_duration = FLOOR((ramFreqMhz * 0.001477125119082522) + 4.272302254983803);
const u32 qrstLow = MAX(static_cast<s32>(einput - qrst_duration - 2), static_cast<s32>(0));
const u32 qrst = PACK_U32(qrst_duration, qrstLow);
const u32 qsafe = (einput_duration + 3) + MAX(MIN(qrstLow * rdv, qrst_duration + qrst_duration), einput);
const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5;
inline u32 tWTPDEN;
const u32 tW2R = CEIL(MAX(WL + (0.010322547033278747 * (C.marikoEmcMaxClock / 1000.0)), (WL * -0.2067922202979121) + FLOOR(((RL_DBI * -0.1331159971685554) + WL) * 3.654131957826108)) - (tWTR / tCK_avg));
const u32 tWTM = WL + (BL / 2) + 1 + CEIL(7.5 / tCK_avg);
const u32 tW2R = CEIL(MAX(WL + (0.010322547033278747 * ramFreqMhz), (WL * -0.2067922202979121) + FLOOR(((RL_DBI * -0.1331159971685554) + WL) * 3.654131957826108)) - (tWTR / tCK_avg));
const u32 tWTM = WL + (BL / 2) + 1 + CEIL(7.5 / tCK_avg);
const u32 tWATM = tWTM + CEIL(tWR / tCK_avg);
const u32 wdv = WL;
const u32 wsv = WL - 2;
const u32 wev = 0xA + C.mem_burst_write_latency;
const u32 wev = 0xA + (WL - 14);
const u32 obdlyHigh = 3 / FLOOR(MIN(static_cast<double>(2), tCK_avg * (WL - 7)));
const u32 obdlyLow = WL - MIN(static_cast<double>(WL), 12 - (CEIL(-0.0003991 * ramFreqMhz) * 2));
const u32 obdly = PACK_U32_NIBBLE_HIGH_BYTE_LOW(obdlyHigh, obdlyLow);
inline u32 pdex2rw;
inline u32 cke2pden;
const u32 tCKE = CEIL(1.0795 * CEIL(0.0074472 * (C.marikoEmcMaxClock / 1000.0)));
const u32 tCKE = CEIL(1.0795 * CEIL(0.0074472 * ramFreqMhz));
const double tMMRI = tRCD + (tCK_avg * 3);
const double tMMRI = tRCD + (tCK_avg * 3);
const double pdex2mrr = tMMRI + 10; /* Do this properly? */
inline u8 mrw2;
}
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -115,7 +115,6 @@ void SafetyCheck() {
eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTableSLT)->freq);
break;
case 2:
case 3:
eristaGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.eristaGpuDvfsTableHiOPT)->freq);
break;
default:
@@ -132,7 +131,6 @@ void SafetyCheck() {
marikoGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoGpuDvfsTableSLT)->freq);
break;
case 2:
case 3:
marikoGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoGpuDvfsTableHiOPT)->freq);
break;
default:
@@ -143,12 +141,12 @@ void SafetyCheck() {
sValidator validators[] = {
{ C.eristaCpuBoostClock, 1020'000, 2295'000, true },
{ C.marikoCpuBoostClock, 1020'000, 2703'000, true },
{ C.commonEmcMemVolt, 1100'000, 1350'000 }, // Official burst vmax for the RAMs is 1500mV
{ C.eristaCpuMaxVolt, 1100, 1257 },
{ C.eristaEmcMaxClock, 1600'000, 2600'200 },
{ C.marikoCpuMaxVolt, 1100, 1235 },
{ C.commonEmcMemVolt, 912'500, 1350'000 }, // Official burst vmax for the RAMs is 1500mV
{ C.eristaCpuMaxVolt, 1000, 1257 },
{ C.eristaEmcMaxClock, 1600'000, 2600'000 },
{ C.marikoCpuMaxVolt, 1000, 1235 },
{ C.marikoEmcMaxClock, 1600'000, 3500'000 },
{ C.marikoEmcVddqVolt, 550'000, 700'000 },
{ C.marikoEmcVddqVolt, 250'000, 700'000 },
{ eristaCpuDvfsMaxFreq, 1785'000, 2295'000 },
{ marikoCpuDvfsMaxFreq, 1785'000, 2703'000 },
{ eristaGpuDvfsMaxFreq, 768'000, 1152'000 },
@@ -168,7 +166,7 @@ void Patch(uintptr_t mapped_nso, size_t nso_size) {
if (isMariko)
mariko::Patch(mapped_nso, nso_size);
else
mariko::Patch(mapped_nso, nso_size);
erista::Patch(mapped_nso, nso_size);
#endif
}

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -58,7 +58,7 @@ namespace ams::ldr::oc::pcv {
static const u32 cpuVoltThermalData[] = { 620, 1120, 20000, 620, 1120, 70000, 950, 1132, 0, 950, 1227, 0 };
static const u32 allowedCpuMaxFrequencies[] = { 2'397'000, 2'499'000, 2'601'000, 2'703'000, };
static const u32 allowedCpuMaxFrequencies[] = { 1'963'000, 2'091'000, 2'193'000, 2'295'000, 2'397'000, 2'499'000, 2'601'000, 2'703'000, };
constexpr cvb_entry_t GpuCvbTableDefault[] = {
// GPUB01_NA_CVB_TABLE
@@ -101,6 +101,7 @@ namespace ams::ldr::oc::pcv {
};
static const SpeedoVminTable vminTable[] {
{1400, 610}, // LOW SPEEDO -> use stock vmin
{1560, 590},
{1583, 570},
{1620, 565},
@@ -206,7 +207,7 @@ namespace ams::ldr::oc::pcv {
constexpr u32 CpuVoltL4T = 1235'000;
static const u32 cpuVoltDvfsPattern[] = { 1227, 1000, 100, 1000, 0 };
static const u32 cpuVoltDvfsOffsets[] = { 5, 6, 7, 9, 8 };
static const u32 cpuVoltDvfsOffsets[] = { 5, 6, 7, 8, 9 };
static_assert(sizeof(cpuVoltDvfsPattern) == sizeof(cpuVoltDvfsOffsets), "Invalid cpuVoltDvfsPattern");
static const u32 cpuVoltageThermalPattern[] = { 950, 1132, 0, 950, 1227, 0, 825, 1227, 15000, 825, 1170, 60000, 825, 1132, 80000 };
@@ -215,9 +216,8 @@ namespace ams::ldr::oc::pcv {
constexpr u32 GpuClkPllLimit = 921'600'000;
constexpr u32 GpuVminOfficial = 810;
static const u32 gpuVoltDvfsPattern[] = { 1150, 1000, 100, 1000, 10, };
static const u32 gpuVoltDvfsOffsets[] = { 1, 2, 3, 4, 5, };
static_assert(sizeof(gpuVoltDvfsPattern) == sizeof(gpuVoltDvfsOffsets), "Invalid gpuVoltDvfsPattern");
static const u32 gpuVoltDvfsPattern[] = { 810, 1150, 1000, 100, 1000, 10, };
static_assert(sizeof(gpuVoltDvfsPattern) == (sizeof(u32) * 6), "Invalid gpuVoltDvfsPattern");
static const u32 gpuVoltThermalPattern[] = { 950, 1132, 0, 810, 1132, 15000, 810, 1132, 30000, 810, 1132, 50000, 810, 1132, 70000, 810, 1132, 105000 };
static_assert(sizeof(gpuVoltThermalPattern) == 0x48, "invalid gpuVoltageThermalPattern size");
@@ -308,8 +308,8 @@ namespace ams::ldr::oc::pcv {
customize_table = const_cast<cvb_entry_t *>(C.marikoCpuDvfsTable1581Tbreak);
break;
}
case HELIOS_TABLE: {
customize_table = const_cast<cvb_entry_t *>(C.marikoCpuDvfsTableHelios);
case EXTREME_TABLE: {
customize_table = const_cast<cvb_entry_t *>(C.marikoCpuDvfsTableExtreme);
break;
}
case DEFAULT_TABLE:
@@ -419,27 +419,26 @@ namespace ams::ldr::oc::pcv {
std::memcpy(gpu_cvb_table_head, (void *)customize_table, customize_table_size);
// Patch GPU volt
if (C.marikoGpuUV == 2 || C.eristaGpuUV == 2) {
cvb_entry_t *entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
for (size_t i = 0; i < customize_entry_count; ++i) {
if (isMariko) {
if (C.marikoGpuVoltArray[i] != 0) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.marikoGpuVoltArray[i] * 1000));
ClearCvbPllEntry(entry);
} else {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
}
cvb_entry_t *entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
for (size_t i = 0; i < customize_entry_count; ++i) {
if (isMariko) {
if (C.marikoGpuVoltArray[i] != 0) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.marikoGpuVoltArray[i] * 1000));
ClearCvbPllEntry(entry);
} else {
if (C.eristaGpuVoltArray[i] != 0) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.eristaGpuVoltArray[i] * 1000));
ClearCvbPllEntry(entry);
} else {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
}
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
}
} else {
if (C.eristaGpuVoltArray[i] != 0) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (C.eristaGpuVoltArray[i] * 1000));
ClearCvbPllEntry(entry);
} else {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));
}
++entry;
}
} else if (C.commonGpuVoltOffset) {
++entry;
}
if (C.commonGpuVoltOffset && !(isMariko ? C.marikoGpuUV : C.eristaGpuUV)) {
cvb_entry_t *entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
for (size_t i = 0; i < customize_entry_count; ++i) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), (entry->cvb_pll_param.c0 - C.commonGpuVoltOffset * 1000));

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -45,7 +45,6 @@ namespace ams::ldr::oc::pcv::erista {
Result CpuVoltThermals(u32 *ptr) {
if (std::memcmp(ptr - 6, cpuVoltageThermalPattern, sizeof(cpuVoltageThermalPattern))) {
// AMS_ABORT_UNLESS(0);
R_THROW(ldr::ResultInvalidCpuMinVolt());
}
@@ -67,11 +66,10 @@ namespace ams::ldr::oc::pcv::erista {
Result CpuVoltDfll(u32* ptr) {
cvb_cpu_dfll_data *entry = reinterpret_cast<cvb_cpu_dfll_data *>(ptr);
R_UNLESS(entry->tune0_low == 0x0000FFCF, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune0_high == 0x00000000, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune1_low == 0x012207FF, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune1_high == 0x03FFF7FF, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune0_low == 0xFFEAD0FF, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune0_high == 0x0, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune1_low == 0x0, ldr::ResultInvalidCpuVoltDfllEntry());
R_UNLESS(entry->tune1_high == 0x0, ldr::ResultInvalidCpuVoltDfllEntry());
if( !C.eristaCpuUV) {
R_SKIP();
@@ -105,14 +103,15 @@ namespace ams::ldr::oc::pcv::erista {
}
Result GpuVoltDVFS(u32 *ptr) {
if (MatchesPattern(ptr, gpuVoltDvfsPattern, gpuVoltDvfsOffsets)) {
if (C.eristaGpuVmin) {
PATCH_OFFSET(ptr, C.eristaGpuVmin);
}
R_SUCCEED();
}
u32 result = std::memcmp(ptr, gpuVoltDvfsPattern, sizeof(gpuVoltDvfsPattern));
R_THROW(ldr::ResultInvalidGpuDvfs());
if (result)
R_THROW(ldr::ResultInvalidGpuDvfs());
if (C.eristaGpuVmin)
PATCH_OFFSET(ptr, C.eristaGpuVmin);
R_SUCCEED();
}
Result GpuVoltThermals(u32 *ptr) {
@@ -494,206 +493,154 @@ namespace ams::ldr::oc::pcv::erista {
/* These timings are slightly off from eos, I am not sure why but I am going to figure it out at some point. */
void MemMtcTableAutoAdjust(EristaMtcTable *table) {
(void) table;
// using namespace pcv::erista;
//
/* #define WRITE_PARAM_ALL_REG(TABLE, PARAM, VALUE) // note: add backslashes to make the macro definition work
TABLE->burst_regs.PARAM = VALUE; \
TABLE->shadow_regs_ca_train.PARAM = VALUE; \
TABLE->shadow_regs_quse_train.PARAM = VALUE; \
#define WRITE_PARAM_ALL_REG(TABLE, PARAM, VALUE) \
TABLE->burst_regs.PARAM = VALUE; \
TABLE->shadow_regs_ca_train.PARAM = VALUE; \
TABLE->shadow_regs_rdwr_train.PARAM = VALUE;
*/
// #define GET_CYCLE(PARAM) ((u32)((double)(PARAM) / (1000000.0 / 1600000.0)))
//
// /* This condition is insane but it's done in eos. */
// /* Need to clean up at some point. */
// u32 rext;
// u32 wext;
// if (C.eristaEmcMaxClock < 3200001) {
// if (C.eristaEmcMaxClock < 2133001) {
// rext = 26;
// wext = 22;
// } else {
// rext = 28;
// wext = 22;
//
// if (2400000 < C.eristaEmcMaxClock) {
// wext = 25;
// }
// }
// } else {
// rext = 30;
// wext = 25;
// }
//
// u32 refresh_raw = 0xFFFF;
// u32 trefbw = 0;
//
// if (C.t8_tREFI != 6) {
// refresh_raw = static_cast<u32>(std::floor(static_cast<double>(tREFpb_values[C.t8_tREFI]) / tCK_avg)) - 0x40;
// refresh_raw = MIN(refresh_raw, static_cast<u32>(0xFFFF));
// }
//
// trefbw = refresh_raw + 0x40;
// trefbw = MIN(trefbw, static_cast<u32>(0x3FFF));
//
// /* Primary timings. */
// WRITE_PARAM_ALL_REG(table, emc_rd_rcd, GET_CYCLE(tRCD));
// WRITE_PARAM_ALL_REG(table, emc_wr_rcd, GET_CYCLE(tRCD));
// WRITE_PARAM_ALL_REG(table, emc_ras, GET_CYCLE(tRAS));
// WRITE_PARAM_ALL_REG(table, emc_rp, GET_CYCLE(tRPpb));
//
// /* Secondary timings. */
// WRITE_PARAM_ALL_REG(table, emc_rrd, GET_CYCLE(tRRD));
// WRITE_PARAM_ALL_REG(table, emc_rfc, GET_CYCLE(tRFCab));
// WRITE_PARAM_ALL_REG(table, emc_rfcpb, GET_CYCLE(tRFCpb));
// WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
// WRITE_PARAM_ALL_REG(table, emc_w2r, tW2R);
// WRITE_PARAM_ALL_REG(table, emc_r2p, (u32) 0xC);
// WRITE_PARAM_ALL_REG(table, emc_w2p, (u32) 0x2D);
//
// WRITE_PARAM_ALL_REG(table, emc_rext, rext);
// WRITE_PARAM_ALL_REG(table, emc_wext, wext);
//
// WRITE_PARAM_ALL_REG(table, emc_trpab, GET_CYCLE(tRPab));
// WRITE_PARAM_ALL_REG(table, emc_tfaw, GET_CYCLE(tFAW));
// WRITE_PARAM_ALL_REG(table, emc_rc, GET_CYCLE(tRC));
//
// WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE(tSR));
// WRITE_PARAM_ALL_REG(table, emc_tcke, GET_CYCLE(tXP) + 1);
// WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE(tXP));
// WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE(tXP) + 8);
//
// WRITE_PARAM_ALL_REG(table, emc_txsr, MIN(GET_CYCLE(tXSR), (u32) 1022));
// WRITE_PARAM_ALL_REG(table, emc_txsrdll, MIN(GET_CYCLE(tXSR), (u32) 1022));
//
// const u32 dyn_self_ref_control = (((u32)(7605.0 / tCK_avg)) + 260U) | (table->burst_regs.emc_dyn_self_ref_control & 0xffff0000U);
// WRITE_PARAM_ALL_REG(table, emc_dyn_self_ref_control, dyn_self_ref_control);
//
// WRITE_PARAM_ALL_REG(table, emc_rw2pden, tRW2PDEN);
// WRITE_PARAM_ALL_REG(table, emc_pdex2wr, GET_CYCLE(10.0));
// WRITE_PARAM_ALL_REG(table, emc_pdex2rd, GET_CYCLE(10.0));
//
// WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE(14.0));
// WRITE_PARAM_ALL_REG(table, emc_cke2pden, GET_CYCLE(5.0));
// WRITE_PARAM_ALL_REG(table, emc_pdex2mrr, GET_CYCLE(pdex2mrr));
//
// WRITE_PARAM_ALL_REG(table, emc_refresh, refresh_raw);
// WRITE_PARAM_ALL_REG(table, emc_pre_refresh_req_cnt, (u32) (refresh_raw / 4));
// WRITE_PARAM_ALL_REG(table, emc_trefbw, trefbw);
//
// const u32 mc_tRCD = (int)((double)(GET_CYCLE(tRCD) >> 2) - 2.0);
// const u32 mc_tRPpb = (int)(((double)(GET_CYCLE(tRPpb) >> 2) - 1.0) + 2.0);
// const u32 mc_tRC = (uint)((double)(GET_CYCLE(tRC) >> 2) - 1.0);
// const u32 mc_tR2W = (uint)(((double)((uint)tR2W >> 2) - 1.0) + 2.0);
// const u32 mc_tW2R = (uint)(((double)(tW2R >> 2) - 1.0) + 2.0);
// const u32 mc_tRAS = MIN(GET_CYCLE(tRAS), (u32) 0x7F);
// const u32 mc_tRRD = MIN(GET_CYCLE(tRRD), (u32) 31);
//
// table->burst_mc_regs.mc_emem_arb_cfg = (int)(((double) C.eristaEmcMaxClock / 33300.0) * 0.25);
// table->burst_mc_regs.mc_emem_arb_timing_ras = (int) ((double) (mc_tRAS >> 2) - 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_rcd = (int) ((double) (GET_CYCLE(tRCD) >> 2) - 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_rp = (int) (((double) (GET_CYCLE(tRPpb) >> 2) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_rc = (int) ((double) (GET_CYCLE(tRC) >> 2) - 1.0);
// table->burst_mc_regs.mc_emem_arb_timing_faw = (int) ((double)(GET_CYCLE(tFAW) >> 2) - 1.0);
// table->burst_mc_regs.mc_emem_arb_timing_rrd = (int)((double)(mc_tRRD >> 2) - 1.0);
// table->burst_mc_regs.mc_emem_arb_timing_rap2pre = 3;
// table->burst_mc_regs.mc_emem_arb_timing_wap2pre = 11;
// table->burst_mc_regs.mc_emem_arb_timing_r2w = (uint)(((double)((uint)tR2W >> 2) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_w2r = (uint)(((double)(tW2R >> 2) - 1.0) + 2.0);
//
// u32 mc_r2r = table->burst_mc_regs.mc_emem_arb_timing_r2r;
// if (mc_r2r > 1) {
// mc_r2r = (uint)(((double)(long)((double)rext * 0.25) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_r2r = mc_r2r;
// }
//
// u32 mc_w2w = table->burst_mc_regs.mc_emem_arb_timing_w2w;
// if (mc_w2w > 1) {
// mc_w2w = (uint)(((double)(long)((double)wext / 4.0) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_w2w = mc_w2w;
// }
//
// table->burst_mc_regs.mc_emem_arb_da_turns = ((mc_tW2R >> 1) << 0x18) | ((mc_tR2W >> 1) << 0x10) | ((mc_r2r >> 1) << 8) | ((mc_w2w >> 1));
// table->burst_mc_regs.mc_emem_arb_da_covers = (((uint)(mc_tRCD + 3 + mc_tRPpb) >> 1 & 0xff) << 8) | (((uint)(mc_tRCD + 11 + mc_tRPpb) >> 1 & 0xff) << 0x10) | ((mc_tRC >> 1) & 0xff);
// table->burst_mc_regs.mc_emem_arb_misc0 = (table->burst_mc_regs.mc_emem_arb_misc0 & 0xffe08000U) | ((mc_tRC + 1) & 0xff);
// table->la_scale_regs.mc_mll_mpcorer_ptsa_rate = MIN((u32)((C.eristaEmcMaxClock / 1600000) * 0xd0U), (u32)0x115);
// table->la_scale_regs.mc_ftop_ptsa_rate = MIN((u32)((C.eristaEmcMaxClock / 1600000) * 0x18U), (u32)0x1f);
// table->la_scale_regs.mc_ptsa_grant_decrement = MIN((u32)((C.eristaEmcMaxClock / 1600000) * 0x1203U), (u32)0x17ff);
//
// u32 mc_latency_allowance = 0;
// if (C.eristaEmcMaxClock / 1000 != 0) {
// mc_latency_allowance = 204800 / (C.eristaEmcMaxClock / 1000);
// }
//
// const u32 mc_latency_allowance2 = mc_latency_allowance & 0xFF;
// const u32 mc_latency_allowance3 = (mc_latency_allowance & 0xFF) << 0x10;
// table->la_scale_regs.mc_latency_allowance_xusb_0 = (table->la_scale_regs.mc_latency_allowance_xusb_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmc_0 = (table->la_scale_regs.mc_latency_allowance_sdmmc_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_xusb_1 = (table->la_scale_regs.mc_latency_allowance_xusb_1 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_tsec_0 = (table->la_scale_regs.mc_latency_allowance_tsec_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmca_0 = (table->la_scale_regs.mc_latency_allowance_sdmmca_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmcab_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcab_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_ppcs_1 = (table->la_scale_regs.mc_latency_allowance_ppcs_1 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_mpcore_0 = (table->la_scale_regs.mc_latency_allowance_mpcore_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_avpc_0 = (table->la_scale_regs.mc_latency_allowance_avpc_0 & 0xff00ffffU) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_hc_0 = 0;
// if (C.eristaEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_hc_0 = 35200 / (C.eristaEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_nvdec_0 = (table->la_scale_regs.mc_latency_allowance_nvdec_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_hc_0 = (table->la_scale_regs.mc_latency_allowance_hc_0 & 0xffffff00U) | mc_latency_allowance_hc_0;
//
// table->la_scale_regs.mc_latency_allowance_isp2_1 = (table->la_scale_regs.mc_latency_allowance_isp2_1 & 0xff00ff00U) | mc_latency_allowance3 | mc_latency_allowance2;
// table->la_scale_regs.mc_latency_allowance_hc_1 = (table->la_scale_regs.mc_latency_allowance_hc_1 & 0xffffff00U) | mc_latency_allowance2;
//
// u32 mc_latency_allowance_gpu_0 = 0;
// if (C.eristaEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_gpu_0 = 40000 / (C.eristaEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_gpu_0 = ((mc_latency_allowance_gpu_0 | table->la_scale_regs.mc_latency_allowance_gpu_0) & 0xff00ff00U) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_gpu2_0 = 0;
// if (C.eristaEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_gpu2_0 = 40000 / (C.eristaEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_gpu2_0 = ((mc_latency_allowance_gpu2_0 | table->la_scale_regs.mc_latency_allowance_gpu2_0) & 0xff00ff00U) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_nvenc_0 = 0;
// if (C.eristaEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_nvenc_0 = 38400 / (C.eristaEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_nvenc_0 = ((mc_latency_allowance_nvenc_0 | table->la_scale_regs.mc_latency_allowance_nvenc_0) & 0xff00ff00U) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_vic_0 = 0;
// if (C.eristaEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_vic_0 = 0xb540 / (C.eristaEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_vic_0 = ((mc_latency_allowance_vic_0 | table->la_scale_regs.mc_latency_allowance_vic_0) & 0xff00ff00U) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_vi2_0 = (table->la_scale_regs.mc_latency_allowance_vi2_0 & 0xffffff00U) | mc_latency_allowance2;
//
// table->burst_mc_regs.mc_emem_arb_timing_rfcpb = GET_CYCLE(tRFCpb) >> 2;
//
// if (C.hpMode) {
// WRITE_PARAM_ALL_REG(table, emc_cfg, 0x13200000);
// }
//
// table->dram_timings.t_rp = tRFCpb;
// table->dram_timings.t_rfc = tRFCab;
// table->emc_cfg_2 = 0x11083d;
// #undef GET_CYCLE
}
#define GET_CYCLE_CEIL(PARAM) u32(CEIL(double(PARAM) / tCK_avg))
/* Ram power down */
/* B31: DRAM_CLKSTOP_PD */
/* B30: DRAM_CLKSTOP_SR */
/* B29: DRAM_ACPD */
if (C.hpMode) {
WRITE_PARAM_ALL_REG(table, emc_cfg, 0x13200000);
} else {
WRITE_PARAM_ALL_REG(table, emc_cfg, 0xF3200000);
}
u32 refresh_raw = 0xFFFF;
if (C.t8_tREFI != 6) {
refresh_raw = CEIL(tREFpb_values[C.t8_tREFI] / tCK_avg) - 0x40;
refresh_raw = MIN(refresh_raw, static_cast<u32>(0xFFFF));
}
u32 trefbw = refresh_raw + 0x40;
trefbw = MIN(trefbw, static_cast<u32>(0x3FFF));
WRITE_PARAM_ALL_REG(table, emc_rd_rcd, GET_CYCLE_CEIL(tRCD));
WRITE_PARAM_ALL_REG(table, emc_wr_rcd, GET_CYCLE_CEIL(tRCD));
WRITE_PARAM_ALL_REG(table, emc_rc, MIN(GET_CYCLE_CEIL(tRC), static_cast<u32>(0xB8)));
WRITE_PARAM_ALL_REG(table, emc_ras, MIN(GET_CYCLE_CEIL(tRAS), static_cast<u32>(0x7F)));
WRITE_PARAM_ALL_REG(table, emc_rrd, GET_CYCLE_CEIL(tRRD));
WRITE_PARAM_ALL_REG(table, emc_rfcpb, GET_CYCLE_CEIL(tRFCpb));
WRITE_PARAM_ALL_REG(table, emc_rfc, GET_CYCLE_CEIL(tRFCab));
WRITE_PARAM_ALL_REG(table, emc_rp, GET_CYCLE_CEIL(tRPpb));
WRITE_PARAM_ALL_REG(table, emc_txsr, MIN(GET_CYCLE_CEIL(tXSR), static_cast<u32>(0x3fe)));
WRITE_PARAM_ALL_REG(table, emc_txsrdll, MIN(GET_CYCLE_CEIL(tXSR), static_cast<u32>(0x3fe)));
WRITE_PARAM_ALL_REG(table, emc_tfaw, GET_CYCLE_CEIL(tFAW));
WRITE_PARAM_ALL_REG(table, emc_trpab, MIN(GET_CYCLE_CEIL(tRPab), static_cast<u32>(0x3F)));
WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE_CEIL(tSR));
WRITE_PARAM_ALL_REG(table, emc_tcke, tCKE);
WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE_CEIL(tXP));
WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE_CEIL(tXP) + 8);
WRITE_PARAM_ALL_REG(table, emc_r2p, tR2P);
WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
WRITE_PARAM_ALL_REG(table, emc_w2p, tW2P);
WRITE_PARAM_ALL_REG(table, emc_w2r, tW2R);
WRITE_PARAM_ALL_REG(table, emc_rext, C.eristaEmcMaxClock < 2133001 ? 26 : 28); // rext shouldn't be causing issues?
WRITE_PARAM_ALL_REG(table, emc_wext, (C.eristaEmcMaxClock >= 2533000) ? 0x19 : 0x16);
WRITE_PARAM_ALL_REG(table, emc_refresh, refresh_raw);
WRITE_PARAM_ALL_REG(table, emc_pre_refresh_req_cnt, refresh_raw / 4);
WRITE_PARAM_ALL_REG(table, emc_trefbw, trefbw);
const u32 dyn_self_ref_control = (static_cast<u32>(7605.0 / tCK_avg) + 260) | (table->burst_regs.emc_dyn_self_ref_control & 0xffff0000);
WRITE_PARAM_ALL_REG(table, emc_dyn_self_ref_control, dyn_self_ref_control);
WRITE_PARAM_ALL_REG(table, emc_pdex2wr, pdex2rw);
WRITE_PARAM_ALL_REG(table, emc_pdex2rd, pdex2rw);
WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE_CEIL(1.75));
WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE_CEIL(1.75));
WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE_CEIL(1.05));
WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE_CEIL(14.0));
WRITE_PARAM_ALL_REG(table, emc_cke2pden, /* cke2pden */ GET_CYCLE_CEIL(8.5));
(void) cke2pden;
WRITE_PARAM_ALL_REG(table, emc_pdex2mrr, GET_CYCLE_CEIL(pdex2mrr));
WRITE_PARAM_ALL_REG(table, emc_rw2pden, tWTPDEN);
/* This needs some clean up. */
constexpr double MC_ARB_DIV = 4.0;
constexpr u32 MC_ARB_SFA = 2;
table->burst_mc_regs.mc_emem_arb_cfg = C.eristaEmcMaxClock / (33.3 * 1000) / MC_ARB_DIV;
table->burst_mc_regs.mc_emem_arb_timing_rcd = CEIL(GET_CYCLE_CEIL(tRCD) / MC_ARB_DIV) - 2;
table->burst_mc_regs.mc_emem_arb_timing_rp = CEIL(GET_CYCLE_CEIL(tRPpb) / MC_ARB_DIV) - 1;
table->burst_mc_regs.mc_emem_arb_timing_rc = CEIL(GET_CYCLE_CEIL(tRC) / MC_ARB_DIV) - 1;
table->burst_mc_regs.mc_emem_arb_timing_ras = CEIL(GET_CYCLE_CEIL(tRAS) / MC_ARB_DIV) - 2;
table->burst_mc_regs.mc_emem_arb_timing_faw = CEIL(GET_CYCLE_CEIL(tFAW) / MC_ARB_DIV) - 1;
table->burst_mc_regs.mc_emem_arb_timing_rrd = CEIL(GET_CYCLE_CEIL(tRRD) / MC_ARB_DIV) - 1;
table->burst_mc_regs.mc_emem_arb_timing_rfcpb = CEIL(GET_CYCLE_CEIL(tRFCpb) / MC_ARB_DIV) - 1;
table->burst_mc_regs.mc_emem_arb_timing_rap2pre = CEIL(tR2P / MC_ARB_DIV);
table->burst_mc_regs.mc_emem_arb_timing_wap2pre = CEIL(tW2P / MC_ARB_DIV) + MC_ARB_SFA;
if (table->burst_mc_regs.mc_emem_arb_timing_r2r > 1) {
table->burst_mc_regs.mc_emem_arb_timing_r2r = CEIL(table->burst_regs.emc_rext / 4) - 1 + MC_ARB_SFA;
}
table->burst_mc_regs.mc_emem_arb_timing_r2w = CEIL(tR2W / MC_ARB_DIV) - 1 + MC_ARB_SFA;
table->burst_mc_regs.mc_emem_arb_timing_w2r = CEIL(tW2R / MC_ARB_DIV) - 1 + MC_ARB_SFA;
u32 da_turns = 0;
da_turns |= u8(table->burst_mc_regs.mc_emem_arb_timing_r2w / 2) << 16;
da_turns |= u8(table->burst_mc_regs.mc_emem_arb_timing_w2r / 2) << 24;
table->burst_mc_regs.mc_emem_arb_da_turns = da_turns;
u32 da_covers = 0;
u8 r_cover = (table->burst_mc_regs.mc_emem_arb_timing_rap2pre + table->burst_mc_regs.mc_emem_arb_timing_rp + table->burst_mc_regs.mc_emem_arb_timing_rcd) / 2;
u8 w_cover = (table->burst_mc_regs.mc_emem_arb_timing_wap2pre + table->burst_mc_regs.mc_emem_arb_timing_rp + table->burst_mc_regs.mc_emem_arb_timing_rcd) / 2;
da_covers |= (table->burst_mc_regs.mc_emem_arb_timing_rc / 2);
da_covers |= (r_cover << 8);
da_covers |= (w_cover << 16);
table->burst_mc_regs.mc_emem_arb_da_covers = da_covers;
table->burst_mc_regs.mc_emem_arb_misc0 = (table->burst_mc_regs.mc_emem_arb_misc0 & 0xFFE08000) | (table->burst_mc_regs.mc_emem_arb_timing_rc + 1);
table->la_scale_regs.mc_mll_mpcorer_ptsa_rate = 0x115;
if (C.eristaEmcMaxClock >= 2133000) {
table->la_scale_regs.mc_ftop_ptsa_rate = 0x1F;
} else {
table->la_scale_regs.mc_ftop_ptsa_rate = 0x1B;
}
table->la_scale_regs.mc_ptsa_grant_decrement = 0x17ff;
constexpr u32 MaskHigh = 0xFF00FFFF;
constexpr u32 Mask2 = 0xFFFFFF00;
constexpr u32 Mask3 = 0xFF00FF00;
const u32 allowance1 = static_cast<u32>(0x32000 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
const u32 allowance2 = static_cast<u32>(0x9C40 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
const u32 allowance3 = static_cast<u32>(0xB540 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
const u32 allowance4 = static_cast<u32>(0x9600 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
const u32 allowance5 = static_cast<u32>(0x8980 / (C.eristaEmcMaxClock / 0x3E8)) & 0xFF;
table->la_scale_regs.mc_latency_allowance_xusb_0 = (table->la_scale_regs.mc_latency_allowance_xusb_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_xusb_1 = (table->la_scale_regs.mc_latency_allowance_xusb_1 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_tsec_0 = (table->la_scale_regs.mc_latency_allowance_tsec_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_sdmmcab_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcab_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_sdmmc_0 = (table->la_scale_regs.mc_latency_allowance_sdmmc_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_sdmmca_0 = (table->la_scale_regs.mc_latency_allowance_sdmmca_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_ppcs_1 = (table->la_scale_regs.mc_latency_allowance_ppcs_1 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_nvdec_0 = (table->la_scale_regs.mc_latency_allowance_nvdec_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_mpcore_0 = (table->la_scale_regs.mc_latency_allowance_mpcore_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_avpc_0 = (table->la_scale_regs.mc_latency_allowance_avpc_0 & MaskHigh) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_vic_0 = allowance3 | (table->la_scale_regs.mc_latency_allowance_vic_0 & Mask3) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_isp2_1 = (table->la_scale_regs.mc_latency_allowance_isp2_1 & Mask3) | (allowance1 << 16) | allowance1;
table->la_scale_regs.mc_latency_allowance_nvenc_0 = allowance4 | (table->la_scale_regs.mc_latency_allowance_nvenc_0 & Mask3) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_hc_0 = (table->la_scale_regs.mc_latency_allowance_hc_0 & Mask2) | allowance5;
table->la_scale_regs.mc_latency_allowance_gpu_0 = allowance2 | (table->la_scale_regs.mc_latency_allowance_gpu_0 & Mask3) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_gpu2_0 = allowance2 | (table->la_scale_regs.mc_latency_allowance_gpu2_0 & Mask3) | (allowance1 << 16);
table->la_scale_regs.mc_latency_allowance_hc_1 = (table->la_scale_regs.mc_latency_allowance_hc_1 & Mask2) | allowance1;
table->la_scale_regs.mc_latency_allowance_vi2_0 = (table->la_scale_regs.mc_latency_allowance_vi2_0 & Mask2) | allowance1;
table->dram_timings.t_rp = tRFCpb;
table->dram_timings.t_rfc = tRFCab;
table->dram_timings.rl = RL_DBI;
// WRITE_PARAM_ALL_REG(table, emc_obdly, obdly);
// WRITE_PARAM_ALL_REG(table, emc_ibdly, ibdly);
table->emc_cfg_2 = 0x11083D;
}
Result MemFreqMtcTable(u32 *ptr) {
u32 khz_list[] = {1600000, 1331200, 1065600, 800000, 665600, 408000, 204000, 102000, 68000, 40800};
@@ -732,17 +679,14 @@ namespace ams::ldr::oc::pcv::erista {
}
void Patch(uintptr_t mapped_nso, size_t nso_size) {
u32 CpuCvbDefaultMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(CpuCvbTableDefault)->freq);
u32 GpuCvbDefaultMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(GpuCvbTableDefault)->freq);
PatcherEntry<u32> patches[] = {
{"CPU Freq Table", CpuFreqCvbTable<false>, 1, nullptr, CpuCvbDefaultMaxFreq},
{"CPU Freq Table", CpuFreqCvbTable<false>, 1, nullptr, static_cast<u32>(GetDvfsTableLastEntry(CpuCvbTableDefault)->freq)},
{"CPU Volt DVFS", &CpuVoltDvfs, 1, nullptr, 825},
{"CPU Volt Thermals", &CpuVoltThermals, 1, nullptr, 825},
{"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0xFFD0EAFF},
{"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0xFFEAD0FF},
{"GPU Volt DVFS", &GpuVoltDVFS, 1, nullptr, 810},
{"GPU Volt Thermals", &GpuVoltThermals, 1, nullptr, 810},
{"GPU Freq Table", GpuFreqCvbTable<false>, 1, nullptr, GpuCvbDefaultMaxFreq},
{"GPU Freq Table", GpuFreqCvbTable<false>, 1, nullptr, static_cast<u32>(GetDvfsTableLastEntry(GpuCvbTableDefault)->freq)},
{"GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn},
{"GPU Freq PLL", &GpuFreqPllLimit, 1, nullptr, GpuClkPllLimit},
{"MEM Freq Mtc", &MemFreqMtcTable, 0, nullptr, EmcClkOSLimit},

View File

@@ -378,13 +378,19 @@ namespace ams::ldr::oc::pcv::mariko {
if (prev_freq != 128000 && prev_freq != 1300000 && prev_freq != 76800) {
R_THROW(ldr::ResultInvalidGpuPllEntry());
}
PATCH_OFFSET(ptr, 3600000);
R_SUCCEED();
}
void MemMtcTableAutoAdjust(MarikoMtcTable *table) {
/* Official Tegra X1 TRM, sign up for nvidia developer program (free) to download:
* https://developer.nvidia.com/embedded/dlc/tegra-x1-technical-reference-manual
* Section 18.11.1: MC Registers
* Section 18.11.2: EMC Registers
*/
#define WRITE_PARAM_ALL_REG(TABLE, PARAM, VALUE) \
TABLE->burst_regs.PARAM = VALUE; \
TABLE->shadow_regs_ca_train.PARAM = VALUE; \
@@ -392,6 +398,10 @@ namespace ams::ldr::oc::pcv::mariko {
#define GET_CYCLE_CEIL(PARAM) u32(CEIL(double(PARAM) / tCK_avg))
/* Ram power down */
/* B31: DRAM_CLKSTOP_PD */
/* B30: DRAM_CLKSTOP_SR */
/* B29: DRAM_ACPD */
if (C.hpMode) {
WRITE_PARAM_ALL_REG(table, emc_cfg, 0x13200000);
} else {
@@ -424,7 +434,7 @@ namespace ams::ldr::oc::pcv::mariko {
WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE_CEIL(tSR));
WRITE_PARAM_ALL_REG(table, emc_tcke, tCKE);
WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE_CEIL(tXP));
WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE_CEIL(tXP) + 8);
WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE_CEIL(tXP) + 8); // TODO analyse
WRITE_PARAM_ALL_REG(table, emc_r2p, tR2P);
WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
WRITE_PARAM_ALL_REG(table, emc_trtm, tRTM);
@@ -474,14 +484,12 @@ namespace ams::ldr::oc::pcv::mariko {
WRITE_PARAM_ALL_REG(table, emc_tr_rdv, rdv);
WRITE_PARAM_ALL_REG(table, emc_cmd_brlshft_2, 0x24)
WRITE_PARAM_ALL_REG(table, emc_cmd_brlshft_3, 0x24)
// WRITE_PARAM_ALL_REG(table, emc_mrs_wait_cnt, 0x07FF003C);
// WRITE_PARAM_ALL_REG(table, emc_mrs_wait_cnt2, 0x02DE002A);
/* This needs some clean up. */
constexpr double MC_ARB_DIV = 4.0;
constexpr u32 MC_ARB_SFA = 2;
table->burst_mc_regs.mc_emem_arb_cfg = C.marikoEmcMaxClock / (33.3 * 1000) / MC_ARB_DIV;
table->burst_mc_regs.mc_emem_arb_cfg = C.marikoEmcMaxClock / (33.3 * 1000) / MC_ARB_DIV;
table->burst_mc_regs.mc_emem_arb_timing_rcd = CEIL(GET_CYCLE_CEIL(tRCD) / MC_ARB_DIV) - 2;
table->burst_mc_regs.mc_emem_arb_timing_rp = CEIL(GET_CYCLE_CEIL(tRPpb) / MC_ARB_DIV) - 1;
table->burst_mc_regs.mc_emem_arb_timing_rc = CEIL(GET_CYCLE_CEIL(tRC) / MC_ARB_DIV) - 1;
@@ -492,10 +500,13 @@ namespace ams::ldr::oc::pcv::mariko {
table->burst_mc_regs.mc_emem_arb_timing_rap2pre = CEIL(tR2P / MC_ARB_DIV);
table->burst_mc_regs.mc_emem_arb_timing_wap2pre = CEIL(tW2P / MC_ARB_DIV) + MC_ARB_SFA;
/* Two consecutive reads between two different dram modules. */
/* Only be above 1 for 8gb ram. */
if (table->burst_mc_regs.mc_emem_arb_timing_r2r > 1) {
table->burst_mc_regs.mc_emem_arb_timing_r2r = CEIL(table->burst_regs.emc_rext / 4) - 1 + MC_ARB_SFA;
}
/* Same as r2r but for write. */
if (table->burst_mc_regs.mc_emem_arb_timing_w2w > 1) {
table->burst_mc_regs.mc_emem_arb_timing_w2w = CEIL(table->burst_regs.emc_wext / MC_ARB_DIV) - 1 + MC_ARB_SFA;
}
@@ -561,224 +572,18 @@ namespace ams::ldr::oc::pcv::mariko {
table->dram_timings.t_rp = tRFCpb;
table->dram_timings.t_rfc = tRFCab;
table->dram_timings.rl = RL_DBI;
table->emc_mrw2 = 0x8802003F;
table->emc_mrw2 = (table->emc_mrw2 & ~0xFFu) | static_cast<u32>(mrw2);
table->emc_cfg_2 = 0x11083D;
}
// void MemMtcTableAutoAdjust(MarikoMtcTable *table) {
// /* Official Tegra X1 TRM, sign up for nvidia developer program (free) to download:
// * https://developer.nvidia.com/embedded/dlc/tegra-x1-technical-reference-manual
// * Section 18.11: MC Registers
// *
// * Retail Mariko: 200FBGA 16Gb DDP LPDDR4X SDRAM x 2
// * x16/Ch, 1Ch/die, Double-die, 2Ch, 1CS(rank), 8Gb density per die
// * 64Mb x 16DQ x 8banks x 2channels = 2048MB (x32DQ) per package
// *
// * Devkit Mariko: 200FBGA 32Gb DDP LPDDR4X SDRAM x 2
// * x16/Ch, 1Ch/die, Quad-die, 2Ch, 2CS(rank), 8Gb density per die
// * X1+ EMC can R/W to both ranks at the same time, resulting in doubled DQ
// * 64Mb x 32DQ x 8banks x 2channels = 4096MB (x64DQ) per package
// *
// * If you have access to LPDDR4(X) specs or datasheets (from manufacturers or Google),
// * you'd better calculate timings yourself rather than relying on following algorithm.
// */
//
/* #define WRITE_PARAM_ALL_REG(TABLE, PARAM, VALUE) \
// TABLE->burst_regs.PARAM = VALUE; \
// TABLE->shadow_regs_ca_train.PARAM = VALUE; \
TABLE->shadow_regs_rdwr_train.PARAM = VALUE;
*/
// #define GET_CYCLE(PARAM) u32(CEIL(double(PARAM) / tCK_avg))
/* This condition is insane but it's done in eos. */
/* Need to clean up at some point. */
// u32 rext;
// u32 wext;
// if (C.marikoEmcMaxClock < 3200001) {
// if (C.marikoEmcMaxClock < 2133001) {
// rext = 26;
// wext = 22;
// } else {
// rext = 28;
// wext = 22;
//
// if (2400000 < C.marikoEmcMaxClock) {
// wext = 25;
// }
// }
// } else {
// rext = 30;
// wext = 25;
// }
//
// u32 refresh_raw = 0xFFFF;
// u32 trefbw = 0;
//
// if (C.t8_tREFI != 6) {
// refresh_raw = static_cast<u32>(std::floor(static_cast<double>(tREFpb_values[C.t8_tREFI]) / tCK_avg)) - 0x40;
// refresh_raw = MIN(refresh_raw, static_cast<u32>(0xFFFF));
// }
//
// trefbw = refresh_raw + 0x40;
// trefbw = MIN(trefbw, static_cast<u32>(0x3FFF));
//
// /* Primary timings. */
// WRITE_PARAM_ALL_REG(table, emc_rd_rcd, GET_CYCLE(tRCD));
// WRITE_PARAM_ALL_REG(table, emc_wr_rcd, GET_CYCLE(tRCD));
// WRITE_PARAM_ALL_REG(table, emc_ras, GET_CYCLE(tRAS));
// WRITE_PARAM_ALL_REG(table, emc_rp, GET_CYCLE(tRPpb));
//
// /* Secondary timings. */
// WRITE_PARAM_ALL_REG(table, emc_rrd, GET_CYCLE(tRRD));
// WRITE_PARAM_ALL_REG(table, emc_rfc, GET_CYCLE(tRFCab));
// WRITE_PARAM_ALL_REG(table, emc_rfcpb, GET_CYCLE(tRFCpb));
// WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W);
// WRITE_PARAM_ALL_REG(table, emc_w2r, tW2R);
// WRITE_PARAM_ALL_REG(table, emc_r2p, (u32) 0xC);
// WRITE_PARAM_ALL_REG(table, emc_w2p, (u32) 0x2D);
//
// WRITE_PARAM_ALL_REG(table, emc_rext, rext);
// WRITE_PARAM_ALL_REG(table, emc_wext, wext);
//
// WRITE_PARAM_ALL_REG(table, emc_trpab, GET_CYCLE(tRPab));
// WRITE_PARAM_ALL_REG(table, emc_tfaw, GET_CYCLE(tFAW));
// WRITE_PARAM_ALL_REG(table, emc_rc, GET_CYCLE(tRC));
//
// WRITE_PARAM_ALL_REG(table, emc_tckesr, GET_CYCLE(tSR));
// WRITE_PARAM_ALL_REG(table, emc_tcke, GET_CYCLE(tXP) + 2);
// WRITE_PARAM_ALL_REG(table, emc_tpd, GET_CYCLE(tXP));
// WRITE_PARAM_ALL_REG(table, emc_tclkstop, GET_CYCLE(tXP) + 8);
//
// WRITE_PARAM_ALL_REG(table, emc_txsr, MIN(GET_CYCLE(tXSR), (u32) 1022));
// WRITE_PARAM_ALL_REG(table, emc_txsrdll, MIN(GET_CYCLE(tXSR), (u32) 1022));
//
// const u32 dyn_self_ref_control = (((u32)(7605.0 / tCK_avg)) + 260U) | (table->burst_regs.emc_dyn_self_ref_control & 0xffff0000U);
// WRITE_PARAM_ALL_REG(table, emc_dyn_self_ref_control, dyn_self_ref_control);
//
// WRITE_PARAM_ALL_REG(table, emc_rw2pden, ams::ldr::oc::pcv::erista::tRW2PDEN);
// WRITE_PARAM_ALL_REG(table, emc_pdex2wr, GET_CYCLE(10.0));
// WRITE_PARAM_ALL_REG(table, emc_pdex2rd, GET_CYCLE(10.0));
//
// WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE(14.0));
// WRITE_PARAM_ALL_REG(table, emc_cke2pden, GET_CYCLE(5.0));
// WRITE_PARAM_ALL_REG(table, emc_pdex2mrr, GET_CYCLE(ams::ldr::oc::pcv::erista::pdex2mrr));
//
// WRITE_PARAM_ALL_REG(table, emc_refresh, refresh_raw);
// WRITE_PARAM_ALL_REG(table, emc_pre_refresh_req_cnt, (u32) (refresh_raw / 4));
// WRITE_PARAM_ALL_REG(table, emc_trefbw, trefbw);
//
// const u32 mc_tRCD = (int)((double)(GET_CYCLE(tRCD) >> 2) - 2.0);
// const u32 mc_tRPpb = (int)(((double)(GET_CYCLE(tRPpb) >> 2) - 1.0) + 2.0);
// const u32 mc_tRC = (uint)((double)(GET_CYCLE(tRC) >> 2) - 1.0);
// const u32 mc_tR2W = (uint)(((double)((uint)tR2W >> 2) - 1.0) + 2.0);
// const u32 mc_tW2R = (uint)(((double)(tW2R >> 2) - 1.0) + 2.0);
// const u32 mc_tRAS = MIN(GET_CYCLE(tRAS), (u32) 0x7F);
// const u32 mc_tRRD = MIN(GET_CYCLE(tRRD), (u32) 31);
//
// table->burst_mc_regs.mc_emem_arb_cfg = (int)(((double) C.marikoEmcMaxClock / 33300.0) * 0.25);
// table->burst_mc_regs.mc_emem_arb_timing_ras = (int) ((double) (mc_tRAS >> 2) - 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_rcd = (int) ((double) (GET_CYCLE(tRCD) >> 2) - 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_rp = (int) (((double) (GET_CYCLE(tRPpb) >> 2) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_rc = (int) ((double) (GET_CYCLE(tRC) >> 2) - 1.0);
// table->burst_mc_regs.mc_emem_arb_timing_faw = (int) ((double)(GET_CYCLE(tFAW) >> 2) - 1.0);
// table->burst_mc_regs.mc_emem_arb_timing_rrd = (int)((double)(mc_tRRD >> 2) - 1.0);
// table->burst_mc_regs.mc_emem_arb_timing_rap2pre = 3;
// table->burst_mc_regs.mc_emem_arb_timing_wap2pre = 11;
// table->burst_mc_regs.mc_emem_arb_timing_r2w = (uint)(((double)((uint)tR2W >> 2) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_w2r = (uint)(((double)(tW2R >> 2) - 1.0) + 2.0);
//
// u32 mc_r2r = table->burst_mc_regs.mc_emem_arb_timing_r2r;
// if (mc_r2r > 1) {
// mc_r2r = (uint)(((double)(long)((double)rext * 0.25) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_r2r = mc_r2r;
// }
//
// u32 mc_w2w = table->burst_mc_regs.mc_emem_arb_timing_w2w;
// if (mc_w2w > 1) {
// mc_w2w = (uint)(((double)(long)((double)wext / 4.0) - 1.0) + 2.0);
// table->burst_mc_regs.mc_emem_arb_timing_w2w = mc_w2w;
// }
//
// table->burst_mc_regs.mc_emem_arb_da_turns = ((mc_tW2R >> 1) << 0x18) | ((mc_tR2W >> 1) << 0x10) | ((mc_r2r >> 1) << 8) | ((mc_w2w >> 1));
// table->burst_mc_regs.mc_emem_arb_da_covers = (((uint)(mc_tRCD + 3 + mc_tRPpb) >> 1 & 0xff) << 8) | (((uint)(mc_tRCD + 11 + mc_tRPpb) >> 1 & 0xff) << 0x10) | ((mc_tRC >> 1) & 0xff);
// table->burst_mc_regs.mc_emem_arb_misc0 = (table->burst_mc_regs.mc_emem_arb_misc0 & 0xffe08000U) | ((mc_tRC + 1) & 0xff);
// table->la_scale_regs.mc_mll_mpcorer_ptsa_rate = MIN((u32)((C.marikoEmcMaxClock / 1600000) * 0xd0U), (u32)0x115);
// table->la_scale_regs.mc_ftop_ptsa_rate = MIN((u32)((C.marikoEmcMaxClock / 1600000) * 0x18U), (u32)0x1f);
// table->la_scale_regs.mc_ptsa_grant_decrement = MIN((u32)((C.marikoEmcMaxClock / 1600000) * 0x1203U), (u32)0x17ff);
//
// u32 mc_latency_allowance = 0;
// if (C.marikoEmcMaxClock / 1000 != 0) {
// mc_latency_allowance = 204800 / (C.marikoEmcMaxClock / 1000);
// }
//
// const u32 mc_latency_allowance2 = mc_latency_allowance & 0xFF;
// const u32 mc_latency_allowance3 = (mc_latency_allowance & 0xFF) << 0x10;
// table->la_scale_regs.mc_latency_allowance_xusb_0 = (table->la_scale_regs.mc_latency_allowance_xusb_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmc_0 = (table->la_scale_regs.mc_latency_allowance_sdmmc_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_xusb_1 = (table->la_scale_regs.mc_latency_allowance_xusb_1 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_tsec_0 = (table->la_scale_regs.mc_latency_allowance_tsec_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmca_0 = (table->la_scale_regs.mc_latency_allowance_sdmmca_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcaa_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_sdmmcab_0 = (table->la_scale_regs.mc_latency_allowance_sdmmcab_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_ppcs_1 = (table->la_scale_regs.mc_latency_allowance_ppcs_1 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_mpcore_0 = (table->la_scale_regs.mc_latency_allowance_mpcore_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_avpc_0 = (table->la_scale_regs.mc_latency_allowance_avpc_0 & 0xff00ffffU) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_hc_0 = 0;
// if (C.marikoEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_hc_0 = 35200 / (C.marikoEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_nvdec_0 = (table->la_scale_regs.mc_latency_allowance_nvdec_0 & 0xff00ffffU) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_hc_0 = (table->la_scale_regs.mc_latency_allowance_hc_0 & 0xffffff00U) | mc_latency_allowance_hc_0;
//
// table->la_scale_regs.mc_latency_allowance_isp2_1 = (table->la_scale_regs.mc_latency_allowance_isp2_1 & 0xff00ff00U) | mc_latency_allowance3 | mc_latency_allowance2;
// table->la_scale_regs.mc_latency_allowance_hc_1 = (table->la_scale_regs.mc_latency_allowance_hc_1 & 0xffffff00U) | mc_latency_allowance2;
//
// u32 mc_latency_allowance_gpu_0 = 0;
// if (C.marikoEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_gpu_0 = 40000 / (C.marikoEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_gpu_0 = ((mc_latency_allowance_gpu_0 | table->la_scale_regs.mc_latency_allowance_gpu_0) & 0xff00ff00U) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_gpu2_0 = 0;
// if (C.marikoEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_gpu2_0 = 40000 / (C.marikoEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_gpu2_0 = ((mc_latency_allowance_gpu2_0 | table->la_scale_regs.mc_latency_allowance_gpu2_0) & 0xff00ff00U) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_nvenc_0 = 0;
// if (C.marikoEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_nvenc_0 = 38400 / (C.marikoEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_nvenc_0 = ((mc_latency_allowance_nvenc_0 | table->la_scale_regs.mc_latency_allowance_nvenc_0) & 0xff00ff00U) | mc_latency_allowance3;
//
// u32 mc_latency_allowance_vic_0 = 0;
// if (C.marikoEmcMaxClock / 1000 != 0) {
// mc_latency_allowance_vic_0 = 0xb540 / (C.marikoEmcMaxClock / 1000);
// }
//
// table->la_scale_regs.mc_latency_allowance_vic_0 = ((mc_latency_allowance_vic_0 | table->la_scale_regs.mc_latency_allowance_vic_0) & 0xff00ff00U) | mc_latency_allowance3;
// table->la_scale_regs.mc_latency_allowance_vi2_0 = (table->la_scale_regs.mc_latency_allowance_vi2_0 & 0xffffff00U) | mc_latency_allowance2;
//
// table->burst_mc_regs.mc_emem_arb_timing_rfcpb = GET_CYCLE(tRFCpb) >> 2;
//
// if (C.hpMode) {
// WRITE_PARAM_ALL_REG(table, emc_cfg, 0x13200000);
// }
//
// table->dram_timings.t_rp = tRFCpb;
// table->dram_timings.t_rfc = tRFCab;
// table->emc_cfg_2 = 0x11083d;
// (void) table;
// }
// WRITE_PARAM_ALL_REG(table, emc_pdex2wr, GET_CYCLE(10.0));
// WRITE_PARAM_ALL_REG(table, emc_pdex2rd, GET_CYCLE(10.0));
// WRITE_PARAM_ALL_REG(table, emc_pchg2pden, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_ar2pden, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_pdex2cke, GET_CYCLE(1.75));
// WRITE_PARAM_ALL_REG(table, emc_act2pden, GET_CYCLE(14.0));
// WRITE_PARAM_ALL_REG(table, emc_cke2pden, GET_CYCLE(5.0));
void MemMtcPllmbDivisor(MarikoMtcTable *table) {
constexpr u32 PllOscInKHz = 38400;
@@ -970,10 +775,14 @@ namespace ams::ldr::oc::pcv::mariko {
PATCH_OFFSET(ptr, emc_uv);
i2cInitialize();
I2cSet_U8(I2cDevice_Max77812_2, 0x25, (emc_uv - uv_min) / uv_step);
Result resultI2C = I2cSet_U8(I2cDevice_Max77812_2, 0x25, (emc_uv - uv_min) / uv_step);
i2cExit();
R_SUCCEED();
if (R_SUCCEEDED(resultI2C)) {
R_SUCCEED();
}
return resultI2C;
}
void Patch(uintptr_t mapped_nso, size_t nso_size) {

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) Souldbminer and Horizon OC Contributors
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,

View File

@@ -1,46 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all
datas = [('C:/Users/sould/Documents/GitHub/Switch-OC-Mansion/Source/Configurator/assets', 'assets')]
binaries = []
hiddenimports = []
tmp_ret = collect_all('psutil')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
a = Analysis(
['C:/Users/sould/Documents/GitHub/Switch-OC-Mansion/Source/Configurator/src/main.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='Configurator',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['C:\\Users\\sould\\Documents\\GitHub\\Switch-OC-Mansion\\Source\\Configurator\\assets\\icon.ico'],
)

View File

@@ -1,287 +0,0 @@
Lexend Font:
Copyright 2018 The Lexend Project Authors (https://github.com/googlefonts/lexend), with Reserved Font Name “RevReading Lexend”.
This Font Software is licensed under the SIL Open Font License, Version 1.1 . This license is copied below, and is also available with a FAQ at: https://openfontlicense.org
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
Main Program:
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 KiB

View File

@@ -1,2 +0,0 @@
python -m PyInstaller --onefile --add-data "assets;assets" --icon=assets/icon.ico --noconsole src/main.py --hidden-import=pillow --hidden-import=psutil --hidden-import=dearpygui --hidden-import=numpy --hidden-import=pathlib
move "dist\main.exe" "dist\hocconfig.exe"

View File

@@ -1 +0,0 @@
pip install pyinstaller dearpygui numpy psutil pil

Binary file not shown.

Binary file not shown.

View File

@@ -1,39 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['src\\main.py'],
pathex=[],
binaries=[],
datas=[('assets', 'assets')],
hiddenimports=['pillow', 'psutil', 'dearpygui', 'numpy', 'pathlib'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['assets\\icon.ico'],
)

View File

@@ -1 +0,0 @@
python src/main.py

View File

@@ -1,52 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
import sys
import platform
import common as c
import license
def populate():
dpg.add_text("Horizon OC Configurator")
dpg.add_separator(label="Contributors")
with dpg.group(horizontal=True):
dpg.add_image("soul", width=96, height=96)
dpg.add_image("lightos", width=96, height=96)
dpg.add_image("samy", width=96, height=96)
dpg.add_separator()
dpg.add_text("Souldbminer - Main contributor. Wrote the full configurator")
dpg.add_text("Lightos - Dumped L4T Timings")
dpg.add_text("Lightos, Samybigio, Flopsider - Testers")
dpg.add_separator(label="Information")
dpg.add_text(f"Configurator Version {c.version}")
dpg.add_text(f"Current Python Version: {sys.version}")
dpg.add_text(f"Current DearPyGui Version: {dpg.get_major_version()}.{dpg.get_minor_version()}")
dpg.add_text(f"Current OS Version: {platform.system()} {platform.release()} Build {platform.version()}")
dpg.add_button(label="Debug Mode", callback=lambda: dpg.show_debug())
dpg.add_button(label="License", callback=lambda: c.show_popup_big("License (GPLv2-or-later)", license.gplv2_text))

View File

@@ -1,117 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
from defaults import d
drive = 0
version = "2.0.0"
def show_info_window(sender, app_data, user_data):
window_tag = "info_window" + user_data
if not dpg.does_item_exist(window_tag):
with dpg.window(label="Information", tag=window_tag, width=400, height=200):
wrap_width = dpg.get_item_width(window_tag) - 10
dpg.add_text(user_data, wrap=wrap_width)
else:
dpg.show_item(window_tag)
def store_value(sender, app_data, user_data=None):
var_name = f"{dpg.get_item_(sender)}_value"
globals()[var_name] = app_data
print(f"{var_name} = {app_data}")
def get_value(tag, default=None):
var_name = f"{tag}_value"
return globals().get(var_name, default)
def show_popup(title="Popup", content="Message"):
if dpg.does_item_exist("popup_window"):
dpg.delete_item("popup_window")
with dpg.window(
label=title,
tag="popup_window",
modal=True,
no_close=True,
width=150,
height=150
):
dpg.add_text(content, wrap=145)
dpg.add_separator()
dpg.add_button(label="Close", width=100, callback=lambda: dpg.delete_item("popup_window"))
def show_popup_big(title="Popup", content="Message"):
if dpg.does_item_exist("big_popup_window"):
dpg.delete_item("big_popup_window")
with dpg.window(
label=title,
tag="big_popup_window",
modal=True,
no_close=True,
width=500,
height=500
):
dpg.add_text(content, wrap=495)
dpg.add_separator()
dpg.add_button(label="Close", width=100, callback=lambda: dpg.delete_item("big_popup_window"))
def load_entry_object(var_name, flag=0):
if not hasattr(d, var_name):
print(f"Variable {var_name} not found in d.")
return
value = getattr(d, var_name)
match flag:
case 0:
value_str = str(value)
case 1:
value_str = f"{value / 1000:.1f} MHz"
case 2:
if not value == 0:
value_str = f"{value / 1000:.1f} mV"
else:
value_str = "Disabled"
case 3:
if not value == 0:
value_str = f"{value} mV"
else:
value_str = "Disabled"
case 4:
match value:
case 0:
value_str = "No Table (UV0)"
case 1:
value_str = "Regular Table (UV1)"
case 2:
value_str = "High Table (UV2)"
case 3:
value_str = "Custom Table (UV3)"
case 5:
value_str = value
if dpg.does_item_exist(var_name):
dpg.set_value(var_name, value_str)
else:
print(f"Entry tagged '{var_name}' does not exist.")

View File

@@ -1,166 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
import common
import kip as k
import gpu as g
import settings as s
def populate():
freqs_mhz_cpu_label = [f"{f} MHz" for f in s.freqs_mhz_cpu]
offsets = list(range(0, 101, 5))
processed_offsets = ["Disabled" if v == 0 else f"-{v}mV" for v in offsets]
voltages = [0] + list(range(1000, 1160 + 1, s.mariko_voltage_step)) # 0 first for Disabled
processed_voltages = ["Disabled" if v == 0 else f"{v}mV" for v in voltages]
processed_voltages_default = ["Default" if v == 0 else f"{v}mV" for v in voltages]
voltages_e = [0] + list(range(1120, 1255 + 1, s.mariko_voltage_step)) + [1257] # 0 first for Disabled
processed_voltages_e = ["Disabled" if v == 0 else f"{v}mV" for v in voltages_e]
processed_voltages_default_e = ["Default" if v == 0 else f"{v}mV" for v in voltages_e]
vmin_voltages = list(range(s.mariko_cpu_min_vmin, s.mariko_cpu_max_vmin + 1, s.mariko_voltage_step)) # 0 first for Disabled
vmin_processed_voltages = ["Disabled" if v == 0 else f"{v}mV" for v in vmin_voltages]
dpg.add_separator(label="Frequencies")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="A higher CPU frequency significantly increases power draw. To sustain higher frequencies without exeeding PMIC limit, undervolt your device. \nThe CPU Boost Frequency is used to speed up game loading",
width=120,
height=64, # height=0 makes it match text
small=True,
tag="c_freqs_info"
)
dpg.add_combo(
items=freqs_mhz_cpu_label,
default_value="1963.0MHz",
label="Mariko CPU Boost Frequency",
callback=k.grab_kip_storage_values,
tag="marikoCpuBoostClock"
)
dpg.add_combo(
items=freqs_mhz_cpu_label,
default_value="1785.0MHz",
label="Erista CPU Boost Frequency",
callback=k.grab_kip_storage_values,
tag="eristaCpuBoostClock"
)
dpg.add_separator(label="Voltages")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="Lower voltages reduce power draw and tempratures. Higher voltages can boost available clockspeeds. Choose voltages with caution, as high voltages can cause IRREPERABLE hardware damage",
width=120,
height=64, # height=0 makes it match text
small=True,
tag="c_volt_info"
)
dpg.add_combo(
items=vmin_processed_voltages,
default_value="Default (600mV)",
label="CPU High vMin (Mariko)",
tag="marikoCpuHighVmin",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_combo(
items=vmin_processed_voltages,
default_value="Default (800mV)",
label="CPU Low vMin (Mariko)",
tag="marikoCpuLowVmin",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_combo(
items=processed_voltages,
default_value="Disabled",
label="CPU vMax (Mariko)",
tag="marikoCpuMaxVolt",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_combo(
items=processed_voltages_e,
default_value="Disabled",
label="CPU vMax (Erista)",
tag="eristaCpuMaxVolt",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_separator(label="Undervolt")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="A undervolted device consumes less power, heats up less, which enables higher clocks. \nThe GPU Undervolt mode should be set to Default or High, test which one is suitable to your console. Custom is only meant for ADVANCED USERS, as the values in it could cause HARDWARE DAMAGE! \nThe Offset should be kept at the minumum your GPU requires to function at the high ram clock (high ram clock means more GPU power needed, usually 600mV is sufficient)",
width=120,
height=64, # height=0 makes it match text
small=True,
tag="c_uv_info"
)
dpg.add_combo(
items=list(range(0, 8 + 1, 1)),
default_value="Default Table",
label="Mariko CPU Low Undervolt",
tag="marikoCpuUVLow",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_combo(
items=list(range(0, 12 + 1, 1)),
default_value="Default Table",
label="Mariko CPU High Undervolt",
tag="marikoCpuUVHigh",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_combo(
items=["Auto (Unimplemented) (0)", "Default (1)", "Tbreak Fifteen Eighty One (2)", "Tbreak Sixteen Eighty Three (3)", "HELIOS (4)"],
default_value="Default Table",
label="Table Configuration",
tag="tableConf",
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_combo(
items=list(range(0, 5 + 1, 1)),
default_value="Default Table",
label="Erista CPU Undervolt",
tag="eristaCpuUV",
callback=k.grab_kip_storage_values_no_mult
)
# dpg.add_combo(
# items=["0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
# default_value="0",
# label="High Frequency Undervolt",
# tag="m_cpu_huv",
# callback=k.grab_kip_storage_values_no_mult
# )
# dpg.add_combo(
# items=processed_offsets,
# default_value="Disabled",
# label="CPU Volt Offset",
# callback=k.grab_kip_storage_values_no_mult,
# tag="m_cpu_hv_offset"
# )

View File

@@ -1,27 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
class Defaults: # This almost always never needs to be updated as pulling from the kip takes priority
def __init__(self):
self.autosave = 0
pass
d = Defaults()

View File

@@ -1,230 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import configparser
import dearpygui.dearpygui as dpg
import kip as k
import common
from pathlib import Path
import ini
import settings as s
def unimplemented():
pass
def check_gpu_sched():
if common.drive == 0:
return False
ini_path = Path(common.drive) / "atmosphere/config/system_settings.ini"
if not ini_path.exists():
return False
config = configparser.ConfigParser()
config.read(ini_path)
return config.get("am.gpu", "gpu_scheduling_enabled", fallback="0x0").strip() == "0x1"
def toggle_gpu_sched(sender, app_data):
ini_path = Path(common.drive) / "atmosphere/config/system_settings.ini"
# Determine value
value = "0x1" if app_data else "0x0"
# Ensure the parent folder exists
ini_path.parent.mkdir(parents=True, exist_ok=True)
# Update using the helper function (requires str path)
ini.set_ini_values(str(ini_path), "am.gpu", {"gpu_scheduling_enabled": value})
common.show_popup("Success", f"Set GPU Scheduling to {app_data}")
def populate():
offsets = list(range(0, s.mariko_gpu_offset_max + 1, s.mariko_voltage_step))
processed_offsets = ["Disabled" if v == 0 else f"-{v} mV" for v in offsets]
voltages = [0] + list(range(s.mariko_gpu_min_volt, s.mariko_gpu_max_volt + 1, s.mariko_voltage_step)) # 0 first for Disabled
processed_voltages = ["Disabled" if v == 0 else f"{v} mV" for v in voltages]
voltages_e = [0] + list(range(s.erista_gpu_min_volt, s.erista_gpu_max_volt + 1, s.mariko_voltage_step)) # 0 first for Disabled
processed_voltages_e = ["Disabled" if v == 0 else f"{v} mV" for v in voltages_e]
processed_voltages_default = ["Default" if v == 0 else f"{v} mV" for v in voltages]
voltages_vmin = [0] + list(range(s.mariko_gpu_min_volt, s.mariko_gpu_max_vmin + 1, s.mariko_voltage_step)) # 0 first for Disabled
processed_voltages_vmin = ["Disabled" if v == 0 else f"{v} mV" for v in voltages_vmin]
voltages_vmin_e = [0] + list(range(s.erista_gpu_min_volt, s.erista_gpu_max_vmin + 1, s.mariko_voltage_step)) # 0 first for Disabled
processed_voltages_vmin_e = ["Disabled" if v == 0 else f"{v} mV" for v in voltages_vmin_e]
freqs_mhz_label = [f"{f} MHz" for f in s.freqs_mhz]
dpg.add_separator(label="Frequencies")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="A higher GPU frequency significantly increases power draw. To sustain higher frequencies without exeeding PMIC limit, undervolt your device \nDO NOT disable GPU scheduling without a adequate undervolt as it can cause hardware damage due to the high power consumption",
width=120,
height=64, # height=0 makes it match text
small=True,
tag="freqs_info"
)
dpg.add_checkbox(label="GPU Scheduling", default_value=True, tag="gpu_sched", callback=toggle_gpu_sched)
dpg.add_separator(label="Voltages")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="Lower voltages reduce power draw and tempratures. Higher voltages can boost available clockspeeds. Choose voltages with caution, as high voltages can cause IRREPERABLE hardware damage",
width=120,
height=64, # height=0 makes it match text
small=True,
tag="volt_info"
)
dpg.add_combo(
items=processed_voltages_vmin_e,
default_value="Disabled",
label="Erista GPU vMin",
callback=k.grab_kip_storage_values_no_mult,
tag="eristaGpuVmin"
)
dpg.add_combo(
items=processed_voltages_vmin,
default_value="Disabled",
label="Mariko GPU vMin",
callback=k.grab_kip_storage_values_no_mult,
tag="marikoGpuVmin"
)
dpg.add_combo(
items=processed_voltages,
default_value="Disabled",
label="Mariko GPU vMax",
callback=k.grab_kip_storage_values_no_mult,
tag="marikoGpuVmax"
)
dpg.add_separator(label="Undervolt")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="A undervolted device consumes less power, heats up less, which enables higher clocks. \nThe GPU Undervolt mode should be set to Default or High, test which one is suitable to your console. Custom is only meant for ADVANCED USERS, as the values in it could cause HARDWARE DAMAGE! \nThe Offset should be kept at the minumum your GPU requires to function at the high ram clock (high ram clock means more GPU power needed)",
width=120,
height=64, # height=0 makes it match text
small=True,
tag="uv_info"
)
dpg.add_combo(
items=["No Table (UV0)", "Regular Table (UV1)", "High Table (UV2)", "Custom Table (UV3)"],
default_value="No Table (UV0)",
label="Mariko Undervolt Mode",
callback=k.grab_kip_storage_values_no_mult,
tag="marikoGpuUV"
)
dpg.add_combo(
items=["No Table (UV0)", "Regular Table (UV1)", "High Table (UV2)", "Custom Table (UV3)"],
default_value="No Table (UV0)",
label="Erista Undervolt Mode",
callback=k.grab_kip_storage_values_no_mult,
tag="eristaGpuUV"
)
dpg.add_combo(
items=processed_offsets,
default_value="Disabled",
label="GPU Volt Offset",
callback=k.grab_kip_storage_values_no_mult,
tag="commonGpuVoltOffset"
)
dpg.add_combo(
items=["Disabled (0)", "Enabled (1)"],
default_value="Disabled",
label="Mariko GPU PLL Unlock",
callback=k.grab_kip_storage_values_no_mult,
tag="marikoGpuFullUnlock"
)
dpg.add_separator(label="Custom Table (Mariko)")
for freq in s.freqs_khz:
if(freq > s.mariko_meme_threshold):
mhz_color = s.danger_color
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = ""
elif(freq > s.mariko_dangerous_gpu_threshold):
mhz_color = s.danger_color
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = "(DANGEROUS)"
elif(freq > s.mariko_unsafe_gpu_threshold):
mhz_color = s.unsafe_color
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = "(UNSAFE)"
else:
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = ""
mhz_color = s.safe_color
mhz_tag = f"combo_{freq}"
if freq == s.mariko_meme_threshold:
with dpg.group(horizontal=True): # align horizontally
dpg.add_combo(
items=processed_voltages,
default_value="Disabled",
tag="g_volt_" + str(freq),
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_text(f"{mhz_label} (", color=mhz_color)
dpg.add_image("coolerhd", width=20, height=20)
dpg.add_text(")", color=mhz_color)
else:
with dpg.group(horizontal=True):
dpg.add_combo(
items=processed_voltages,
default_value="Disabled",
tag="g_volt_" + str(freq),
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_text(default_value=f"{mhz_label} {safety_label}", color=mhz_color)
dpg.add_separator(label="Custom Table (Erista)")
for freq in s.freqs_khz_e:
if(freq > s.erista_dangerous_gpu_threshold):
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = "(DANGEROUS)"
mhz_color = s.danger_color
elif(freq > s.erista_unsafe_gpu_threshold):
mhz_color = s.unsafe_color
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = "(UNSAFE)"
else:
mhz_color = s.safe_color
mhz_label = f"{freq / 1000:.1f} MHz"
safety_label = ""
with dpg.group(horizontal=True):
dpg.add_combo(
items=processed_voltages_e,
default_value="Disabled",
tag="g_volt_e_" + str(freq),
callback=k.grab_kip_storage_values_no_mult
)
dpg.add_text(default_value=f"{mhz_label} {safety_label}", color=mhz_color)

View File

@@ -1,101 +0,0 @@
import os
import re
import common as c
def ensure_dir_exists(path: str):
os.makedirs(os.path.dirname(path), exist_ok=True)
def set_ini_values(ini_path, section, entries):
if not c.drive:
c.show_popup("Error", "This feature requires a valid drive to be selected")
return
ini_path = str(ini_path)
try:
with open(ini_path, "r") as f:
lines = f.readlines()
except FileNotFoundError:
lines = []
output_lines = []
current_section = None
section_lines = []
section_found = False
def flush_section():
nonlocal section_lines, output_lines
if section_lines:
output_lines.extend(section_lines)
section_lines = []
for line in lines:
section_match = re.match(r"\s*\[([^\]]+)\]", line)
if section_match:
if current_section == section and entries:
new_lines = []
keys_handled = set()
for l in section_lines[1:]:
key_match = re.match(r"\s*([A-Za-z0-9_.]+)\s*=", l)
if key_match:
key = key_match.group(1)
if key in entries:
val = entries[key]
if val is None:
continue
new_lines.append(f"{key} = {val}\n")
keys_handled.add(key)
else:
new_lines.append(l)
else:
new_lines.append(l)
for k, v in entries.items():
if k not in keys_handled and v is not None:
new_lines.append(f"{k} = {v}\n")
section_lines = [section_lines[0]] + new_lines
flush_section()
current_section = section_match.group(1)
section_lines = [line]
if current_section == section:
section_found = True
continue
section_lines.append(line)
if current_section == section and entries:
new_lines = []
keys_handled = set()
for l in section_lines[1:]:
key_match = re.match(r"\s*([A-Za-z0-9_.]+)\s*=", l)
if key_match:
key = key_match.group(1)
if key in entries:
val = entries[key]
if val is None:
continue
new_lines.append(f"{key} = {val}\n")
keys_handled.add(key)
else:
new_lines.append(l)
else:
new_lines.append(l)
for k, v in entries.items():
if k not in keys_handled and v is not None:
new_lines.append(f"{k} = {v}\n")
section_lines = [section_lines[0]] + new_lines
flush_section()
if not section_found and entries:
output_lines.append(f"\n[{section}]\n")
for k, v in entries.items():
if v is not None:
output_lines.append(f"{k} = {v}\n")
ensure_dir_exists(ini_path)
if output_lines:
with open(ini_path, "w") as f:
f.writelines(output_lines)
else:
if os.path.exists(ini_path):
os.remove(ini_path)

View File

@@ -1,172 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
import psutil
import os
import common as c
import urllib.request
import zipfile
import kip as k
from defaults import d
import settings as s
def autosave_toggle(sender, app_data):
d.autosave=app_data
print(f"Autosave toggled to {d.autosave}")
def get_drives():
drives = []
for part in psutil.disk_partitions(all=False):
drives.append(part.device)
return drives
# Change if you plan to fork
def download_and_extract_zip(c, download_url, zip_filename="temp.zip", success_message="Installed file!"):
"""
Downloads a zip file from the given URL, extracts it to the selected drive,
and cleans up the zip afterwards.
Args:
c: Context object with attributes:
- drive (str): Installation path.
- show_popup (callable): Function to show popup messages.
download_url (str): The URL of the zip file.
zip_filename (str, optional): Name for the downloaded zip file. Defaults to "temp.zip".
success_message (str, optional): Success popup message. Defaults to "Installed hoc-clk!".
"""
if not c.drive or c.drive == "0" or c.drive == 0:
c.show_popup(title="Error", content="Please select an installation drive first!")
return False
zip_path = os.path.join(c.drive, zip_filename)
try:
print(f"Downloading {zip_filename} to {c.drive} ...")
urllib.request.urlretrieve(download_url, zip_path)
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(c.drive)
c.show_popup(title="Success", content=success_message)
return True
except Exception as e:
c.show_popup(title="Error", content=f"Download failed:\n{e}")
return False
finally:
if os.path.exists(zip_path):
os.remove(zip_path)
def downloadLoader(): # This has to be different as it extracts to a custom location and downloads a FILE, not a zip
print("Downloading HOC.kip...")
if c.drive==0:
print("Drive not selected!")
c.show_popup(title="Error:", content="Please select a installation c.drive first!")
else:
try:
directory_make = c.drive + "atmosphere/kips/"
urllib.request.urlretrieve(s.kip_download_link, directory_make + "hoc.kip")
except Exception as e:
c.show_popup(title="Error", content=f"Download failed:\n{e}")
finally:
c.show_popup(title="Info:", content="Downloaded kip!")
drive_list = get_drives()
def check_atmosphere(sender, app_data, user_data):
c.drive = app_data
atmosphere_path = os.path.join(c.drive, "atmosphere")
package3_path = os.path.join(atmosphere_path, "package3")
if os.path.isfile(f"{atmosphere_path}/kips/hoc.kip"):
dpg.set_value("status_text", "Horizon OC Install Found!")
k.kip_file_path = f"{atmosphere_path}/kips/hoc.kip"
k.read_kip(c.drive + "atmosphere/kips/hoc.kip")
print(f"Reading kip from drive {c.drive}")
s.load_all_vars()
elif os.path.isdir(atmosphere_path) and os.path.isfile(package3_path):
dpg.set_value("status_text", "Atmosphere install found!")
else:
dpg.set_value("status_text", "Atmosphere not found!")
def download_and_install(download_url, install_path, c=None,
filename=None, success_message="Download complete!"):
"""
Downloads a file from the given URL, optionally extracts if it's a zip,
and deletes the temporary zip afterwards if extracted.
Args:
download_url (str): The URL of the file.
install_path (str): Directory where the file will be saved or extracted.
c (object, optional): Context object with show_popup(title, content). If given, used for popups.
filename (str, optional): Name for the downloaded file. Defaults to inferred name from URL.
success_message (str, optional): Message shown on success.
"""
def show_popup(title, content):
if c and hasattr(c, "show_popup"):
c.show_popup(title=title, content=content)
else:
print(f"[{title}] {content}")
if not install_path or not os.path.isdir(install_path):
msg = f"Invalid installation path: {install_path}"
show_popup("Error", msg)
return False
# Infer filename if not provided
if not filename:
filename = os.path.basename(download_url) or "downloaded_file"
file_path = os.path.join(install_path, filename)
try:
print(f"Downloading {filename} to {install_path} ...")
urllib.request.urlretrieve(download_url, file_path)
if filename.lower().endswith(".zip"):
try:
with zipfile.ZipFile(file_path, 'r') as zip_ref:
zip_ref.extractall(install_path)
show_popup("Success", success_message)
return True
except zipfile.BadZipFile:
msg = f"Downloaded file '{filename}' is not a valid archive."
show_popup("Error", msg)
return False
finally:
if os.path.exists(file_path):
os.remove(file_path)
else:
# Non-zip file: just keep it
show_popup("Success", success_message)
return True
except Exception as e:
msg = f"Download failed: {e}"
show_popup("Error", msg)
return False

View File

@@ -1,148 +0,0 @@
import dearpygui.dearpygui as dpg
import struct
from defaults import d
import common as c
import gpu as g
import re
import settings as s
g_freq_str = None
kip_file_path = None
def make_struct_format(vars_list):
fmt = "="
for name, t in vars_list:
fmt += s.fmt_map[t]
if name == "tFAW":
fmt += "4x" # i hate hardcoding but this is what it is
return fmt
def freq_to_label(freq):
if freq > 1382400:
return f"{freq / 1000:.1f} MHz (DANGEROUS)"
elif freq > 1152000:
return f"{freq / 1000:.1f} MHz (UNSAFE)"
else:
return f"{freq / 1000:.1f} MHz"
def store(sender, app_data):
global kip_file_path
kip_file_path = app_data['file_path_name']
print("Selected" + kip_file_path)
read_kip(kip_file_path)
s.load_all_vars()
def grab_kip_storage_values(sender, app_data):
tag = dpg.get_item_alias(sender)
if tag and hasattr(d, tag):
numeric_str = str(app_data).split(" ")[0]
try:
value = int(float(numeric_str) * 1000)
except (ValueError, TypeError):
c.show_popup("Error", f"Invalid numeric value for {tag}: {app_data}")
return
setattr(d, tag, value)
print(tag, app_data, getattr(d, tag))
if d.autosave:
write_kip()
def grab_kip_storage_values_no_mult(sender, app_data):
tag = dpg.get_item_alias(sender)
if not tag or not hasattr(d, tag):
return
if isinstance(app_data, str):
numeric_str = re.sub(r"[^0-9.]", "", app_data)
if numeric_str == "":
c.show_popup("Error", f"Invalid numeric value for {tag}: {app_data}")
return
try:
value = int(float(numeric_str))
except (ValueError, TypeError):
c.show_popup("Error", f"Invalid numeric value for {tag}: {app_data}")
return
else:
value = app_data
setattr(d, tag, value)
print(tag, app_data, getattr(d, tag))
if d.autosave:
write_kip()
def grab_value_freq_conversion(sender, app_data):
global g_freq_str
g_freq_str = app_data
try:
g_freq_val = int(float(g_freq_str.replace(" MHz", "")) * 1000)
except Exception:
return
print(g_freq_val)
def write_kip():
global kip_file_path
MAGIC = b"CUST"
struct_fmt = make_struct_format(s.variables)
struct_size = struct.calcsize(struct_fmt)
if kip_file_path is None:
msg = "You need to select a file to use Autosave!" if d.autosave else "You need to select a file to save the KIP!"
c.show_popup("Error", msg)
return
with open(kip_file_path, "r+b") as f:
data = f.read()
idx = data.find(MAGIC)
if idx == -1:
c.show_popup("Error", "KIP is invalid!")
return
pos = idx + len(MAGIC)
values = []
for attr_name, t in s.variables:
val = getattr(d, attr_name)
if t == "u32":
val = int(val) & 0xFFFFFFFF
else:
val = float(val)
values.append(val)
try:
packed = struct.pack(struct_fmt, *values)
except Exception as e:
c.show_popup("Error", f"Packing error: {e}")
return
f.seek(pos)
f.write(packed)
if not d.autosave:
c.show_popup("Success", "KIP saved successfully!")
def read_kip(filename):
MAGIC = b"CUST"
struct_fmt = make_struct_format(s.variables)
struct_size = struct.calcsize(struct_fmt)
with open(filename, "rb") as f:
data = f.read()
idx = data.find(MAGIC)
if idx == -1:
c.show_popup("Fatal Error", "Unable to find CUST header in kip\nTry reinstalling the kip using the install option")
pos = idx + len(MAGIC)
raw = data[pos:pos + struct_size]
values = struct.unpack(struct_fmt, raw)
for (attr_name, _), val in zip(s.variables, values):
setattr(d, attr_name, val)
print("=== value layout ===")
offset = 0
for (attr_name, t) in s.variables:
code = s.fmt_map[t]
align = 8 if code == "d" else 4
padding = (-offset) % align
if padding:
offset += padding
size = struct.calcsize(code)
raw_bytes = raw[offset:offset + size]
val = getattr(d, attr_name)
print(f"{attr_name:<20} | type={t:<6} | offset={offset:<4} | size={size:<2} | raw=0x{raw_bytes.hex()} | val={val}")
offset += size
print("========================")
dpg.set_value("gpu_sched", g.check_gpu_sched())
dpg.show_item("gpu_tab")
dpg.show_item("cpu_tab")
dpg.show_item("emc_tab")
dpg.show_item("misc_tab")

View File

@@ -1,302 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
gplv2_text = """\
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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.
"""

View File

@@ -1,155 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
# This prevents the window from reopening when closed
dpg.create_context()
from PIL import Image
import numpy as np
import common as c
import sys
import os
import webbrowser
import ctypes
import kip as k
import gpu
import cpu
import ram
from defaults import d
import installer as ins
import about
import misc
true = True
false = False
if getattr(sys, 'frozen', False):
assets_path = os.path.join(sys._MEIPASS, 'assets/')
else:
assets_path = os.path.join(os.path.dirname(__file__), '../assets/')
cooler_image_path = assets_path + "coolerhd.png" # coolerHD Emoji from OC server
cooler_image = Image.open(cooler_image_path).convert("RGBA")
cooler_width, cooler_height = cooler_image.size
cooler_image_data = np.array(cooler_image) / 255.0
cooler_image_data = cooler_image_data.flatten()
lightos_image_path = assets_path + "lightos_c.png"
lightos_image = Image.open(lightos_image_path).convert("RGBA")
lightos_width, lightos_height = lightos_image.size
lightos_image_data = np.array(lightos_image) / 255.0
lightos_image_data = lightos_image_data.flatten()
samy_image_path = assets_path + "samy_c.png"
samy_image = Image.open(samy_image_path).convert("RGBA")
samy_width, samy_height = samy_image.size
samy_image_data = np.array(samy_image) / 255.0
samy_image_data = samy_image_data.flatten()
soul_image_path = assets_path + "soul_c.png"
soul_image = Image.open(soul_image_path).convert("RGBA")
soul_width, soul_height = soul_image.size
soul_image_data = np.array(soul_image) / 255.0
soul_image_data = soul_image_data.flatten()
with dpg.font_registry():
lexend = dpg.add_font(assets_path + "Lexend.ttf", 16)
with dpg.texture_registry(show=False):
dpg.add_static_texture(width=cooler_width, height=cooler_height, default_value=cooler_image_data, tag="coolerhd")
dpg.add_static_texture(width=lightos_width, height=lightos_height, default_value=lightos_image_data, tag="lightos")
dpg.add_static_texture(width=samy_width, height=samy_height, default_value=samy_image_data, tag="samy")
dpg.add_static_texture(width=soul_width, height=soul_height, default_value=soul_image_data, tag="soul")
with dpg.file_dialog(directory_selector=False, show=False, tag="file_dialog", width=500, height=300, modal=True, callback=k.store):
dpg.add_file_extension(".kip")
def refresh_drives():
setattr(ins, "drive_list", ins.get_drives())
dpg.configure_item("drive_select", items=ins.drive_list)
with dpg.window(label="Configurator", width=400, height=300,id="main_window"):
with dpg.tab_bar():
with dpg.tab(label="File"):
dpg.add_separator(label="Information")
dpg.add_text("Horizon OC is an open source overclocking tool for the Nintendo Switch Horizon OS")
dpg.add_text("For more information read the README on GitHub")
dpg.add_button(
label="Open GitHub",
callback=lambda: webbrowser.open("https://github.com/souldbminersmwc/Horizon-OC")
)
dpg.add_separator(label="Installation")
dpg.add_button(label="Refresh Drive List", callback=refresh_drives)
dpg.add_combo(
items=ins.drive_list,
default_value="Select a drive!",
tag="drive_select",
callback=ins.check_atmosphere
)
dpg.add_checkbox(label="Autosave", default_value=false, callback=ins.autosave_toggle)
dpg.add_text("", tag="status_text")
dpg.add_button(label="Save settings", callback=k.write_kip)
dpg.add_separator(label="Downloads")
dpg.add_button(label="Install Horizon OC Loader", callback=ins.downloadLoader)
dpg.add_button(label="Install Horizon OC Clock Manager", callback=lambda: ins.download_and_extract_zip(c, ins.hoc_clk_download_link, zip_filename="hoc_clk_temp.zip", success_message="Installed hoc-clk!"))
dpg.add_separator(label="Advanced")
dpg.add_button(label="Manually Select hoc.kip", callback=lambda: dpg.show_item("file_dialog"))
with dpg.tab(label="GPU", tag="gpu_tab"):
gpu.populate()
with dpg.tab(label="CPU", tag="cpu_tab"):
cpu.populate()
with dpg.tab(label="RAM", tag="emc_tab"):
ram.populate()
with dpg.tab(label="Misc", tag="misc_tab"):
misc.populate()
with dpg.tab(label="About", tag="about_tab"):
about.populate()
dpg.hide_item("gpu_tab")
dpg.hide_item("cpu_tab")
dpg.hide_item("emc_tab")
dpg.hide_item("misc_tab")
dpg.bind_font(lexend)
dpg.create_viewport(title="Horizon OC Configurator", width=854, height=480)
dpg.set_viewport_large_icon(assets_path + "icon.ico")
dpg.set_viewport_title("Horizon OC Configurator")
dpg.set_primary_window("main_window", True)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

View File

@@ -1,211 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import os
from pathlib import Path
import dearpygui.dearpygui as dpg
import common
import ini
import re
import installer as ins
from defaults import d
import ram as r
import settings as s
def get_ini_path():
if not common.drive or common.drive == 0:
common.show_popup("Error", "This feature requires a valid drive")
return None
return Path(str(common.drive)) / "atmosphere/config/system_settings.ini"
def set_psm_value(sender, app_data):
ini_path = get_ini_path()
if not ini_path:
return
value = next((x["value"] for x in s.PSM_OPTIONS if x["name"] == app_data), None)
if value:
ini.set_ini_values(str(ini_path), "psm", {"current_psm_mA": value})
common.show_popup("Success", f"Charge Limit set to {app_data}")
def remove_tc_entries():
ini_path = get_ini_path()
if not ini_path:
return
try:
with open(ini_path, "r") as f:
lines = f.readlines()
except FileNotFoundError:
return
output_lines = []
current_section = None
for line in lines:
section_match = re.match(r"\s*\[([^\]]+)\]", line)
if section_match:
current_section = section_match.group(1)
if current_section == "tc":
current_section = "skip"
continue
else:
output_lines.append(line)
continue
if current_section != "skip":
output_lines.append(line)
with open(ini_path, "w") as f:
f.writelines(output_lines)
common.show_popup("Success", "Reset to default fan curve")
def set_ini_from_profile(sender, app_data, user_data):
profile_name = user_data
if profile_name not in s.PROFILES:
print(f"Profile '{profile_name}' not found.")
return
entries = s.PROFILES[profile_name]
ini_path = get_ini_path()
if not ini_path:
return
ini.set_ini_values(str(ini_path), "tc", entries)
common.show_popup("Success", "Profile has been applied")
print(f"Applied profile {profile_name} under [tc]")
def update_skin_target(sender, app_data):
s.skinTarget = app_data
print("skinTarget =", s.skinTarget)
ini_path = get_ini_path()
if not ini_path:
return
ini.set_ini_values(str(ini_path), "tc", s.skin_t_entries)
def toggle_battery_save(sender, user_data):
if not common.drive:
common.show_popup("Error", "No drive selected")
return
ini_path = Path(common.drive) / "atmosphere/config/system_settings.ini"
for section, entries in s.BATTERY_SAVE_OPTIONS.items():
if dpg.get_item_alias(sender) == "enable_battery_fix": # hardcoded but otherwise it doesnt work :(
ini.set_ini_values(str(ini_path), section, entries)
else:
remove_entries = {k: None for k in entries}
ini.set_ini_values(str(ini_path), section, remove_entries)
common.show_popup("Info", f"Sleep Mode Battery Fix {'enabled' if dpg.get_item_alias(sender) == "enable_battery_fix" else 'disabled'}")
def populate():
dpg.add_separator(label="Fan")
dpg.add_button(label="Optimize Fan Curve for V1", user_data="V1_Erista", callback=set_ini_from_profile)
dpg.add_button(label="Optimize Fan Curve for V2", user_data="V2_Mariko", callback=set_ini_from_profile)
dpg.add_button(label="Optimize Fan Curve for Lite", user_data="Lite_Mariko", callback=set_ini_from_profile)
dpg.add_button(label="Optimize Fan Curve for OLED", user_data="OLED_Mariko", callback=set_ini_from_profile)
dpg.add_slider_int(
label="Skin Target (Recommended - 54°C)",
min_value=50, max_value=60,
default_value=s.skinTarget,
callback=update_skin_target
)
dpg.add_button(label="Reset Fan Curve", callback=remove_tc_entries)
dpg.add_separator(label="Battery")
dpg.add_button(
label="What is this?",
callback=common.show_info_window,
user_data="This option fixes battery life drain in sleep mode\nDO NOT use this if you are using online services",
tag="battery_fix_info"
)
dpg.add_button(label="Enable sleep mode battery fix", tag="enable_battery_fix", callback=toggle_battery_save, user_data=1)
dpg.add_button(label="Disable sleep mode battery fix", tag="disable_battery_fix",callback=toggle_battery_save, user_data=0)
dpg.add_separator(label="Downloads")
nx_ovlloader_link = "https://github.com/ppkantorski/nx-ovlloader/releases/latest/download/nx-ovlloader+.zip"
dpg.add_button(label="Install nx-ovlloader", callback=lambda: ins.download_and_extract_zip(common, nx_ovlloader_link, zip_filename="ovll_temp.zip", success_message="Installed nx-ovlloader!"))
ultrahand_link = "https://github.com/ppkantorski/Ultrahand-Overlay/releases/latest/download/ovlmenu.ovl"
dpg.add_button(label="Install Ultrahand Overlay", callback=lambda: ins.download_and_install(c=common, install_path=common.drive + "switch/.overlays/", download_url=ultrahand_link, filename="ovlMenu.ovl", success_message="Installed Ultrahand!"))
status_monitor_link = "https://github.com/ppkantorski/Status-Monitor-Overlay/releases/latest/download/ Status-Monitor-Overlay.ovl "
dpg.add_button(label="Install Status Monitor", callback=lambda: ins.download_and_install(c=common, install_path=common.drive + "switch/.overlays/", download_url=status_monitor_link, filename=" Status-Monitor-Overlay.ovl", success_message="Installed Status Monitor!"))
saltynx_link = "https://github.com/masagrator/SaltyNX/releases/latest/download/SaltyNX.zip"
dpg.add_button(label="Install SaltyNX", callback=lambda: ins.download_and_extract_zip(common, saltynx_link, zip_filename="saltynx_temp.zip", success_message="Installed SaltyNX!"))
reversenx_link = "https://github.com/masagrator/ReverseNX-RT/releases/latest/download/ReverseNX-RT-ovl.ovl"
dpg.add_button(label="Install ReverseNX-RT", callback=lambda: ins.download_and_install(c=common, install_path=common.drive + "switch/.overlays/", download_url=reversenx_link, filename="ReverseNX-RT-ovl.ovl", success_message="Installed ReverseNX-RT!"))
dpg.add_separator(label="Danger Zone")
dpg.add_text("These options are known to cause hardware issues, PMIC issues or overheating.\nUse with extreme caution!", color=(255, 165, 0, 255))
dpg.add_separator()
dpg.add_spacer(height=10)
psm_items = [x["name"] for x in s.PSM_OPTIONS]
dpg.add_combo(items=psm_items, label="Battery Charge Limit", callback=set_psm_value, tag="psm_dropdown", default_value="2048mA (Default)")
dpg.add_spacer(height=5)
dpg.add_separator(label="EXTREME DANGER ZONE")
dpg.add_text("THESE OPTIONS ARE KNOWN TO CAUSE IRREPARABLE HARDWARE DAMAGE THAT CAN AND WILL KILL YOUR CONSOLE\nUSE ONLY IF YOU ARE AN ADVANCED USER AND ARE AWARE OF THE RISKS AND POTENTIAL CONCEQUENCES", color=(255, 0, 0, 255))
dpg.add_spacer(height=10)
with dpg.group(horizontal=True):
dpg.add_checkbox(
label="",
callback=set_white_tiger_clocks
)
dpg.add_image("coolerhd", width=20, height=20)
def set_white_tiger_clocks(app_data):
# cooler aah clocks
# 1400mv emc max
# 1375mv cpu max
# 750mv vdd2 mariko max
base_vddq_uv = list(range(550000, 650001, 5000))
vddq_uv = [0] + list(range(250000, 750001, 5000)) if app_data else base_vddq_uv
vddq_mv = [v // 1000 for v in vddq_uv]
vddq_mv_label = ["Default (600 mV)" if f == 0 else f"{f} mV" for f in vddq_mv]
dpg.configure_item("marikoEmcVddqVolt", items=vddq_mv_label)
base_voltages_uv = list(range(1050000, 1212500 + 1, 12500))
voltages_uv = base_voltages_uv + list(range(1225000, 1400000 + 1, 12500)) if app_data else base_voltages_uv
voltages_mv = [v / 1000 for v in voltages_uv]
voltages_mv_label = ["Default (1175 mV)" if f == 0 else f"{f} mV" for f in voltages_mv]
dpg.configure_item("commonEmcMemVolt", items=voltages_mv_label)
voltages = [0] + list(range(1130, 1375 + 1, 5)) if app_data else [0] + list(range(1000, 1160 + 1, 5))
voltages_e = [0] + list(range(1180, 1375 + 1, 5)) if app_data else [0] + list(range(1120, 1255 + 1, 5)) + [1257]
processed_voltages_e = ["Disabled" if v == 0 else f"{v}mV" for v in voltages_e]
processed_voltages = ["Disabled" if v == 0 else f"{v}mV" for v in voltages]
dpg.configure_item("marikoCpuMaxVolt", items=processed_voltages)
dpg.configure_item("eristaCpuMaxVolt", items=processed_voltages_e)

View File

@@ -1,100 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
from defaults import d
import common as c
import settings as s
def load_defaults():
apply_timing_preset(s.timing_preset_default)
def temporary_presets_unavailable():
c.show_popup_big("We need your help!", "This timing preset currently unavailable due to lack of data. If you have a ram module and want to contribute your data, reach out to me (soul_9017) on the OC discord")
def apply_timing_preset(preset):
if len(preset) != len(s.timing_vars):
raise ValueError("Preset invalid!")
for var_name, value in zip(s.timing_vars, preset):
setattr(d, var_name.split('.')[-1], value)
flag = 0 if var_name.endswith("tBL") else 5
c.load_entry_object(var_name.split('.')[-1], flag)
c.show_popup("Sucess", "Preset Applied!")
def apply_reg_timings(sender, app_data):
ram_selected = dpg.get_value("ram_type")
print(ram_selected)
match(ram_selected):
case "Choose your RAM Type!":
c.show_popup("Error", "You must select a ram type to apply a preset")
case "Samsung AA-MGCL/MGCR":
apply_timing_preset(s.timing_preset_aamgcl_c)
case "SK Hynix NEI/NEE/x267":
apply_timing_preset(s.timing_preset_nee_c)
case "Micron WT:B":
apply_timing_preset(s.timing_preset_wtb_c)
case "Micron AUT:B":
apply_timing_preset(s.timing_preset_wtb_c)
case "Micron WT:F":
apply_timing_preset(s.timing_preset_wtf_c)
case "Samsung AM-MGCJ":
apply_timing_preset(s.timing_preset_mgcj_c)
case "Micron WT:E":
apply_timing_preset(s.timing_preset_wte_c)
case "Samsung AB-MGCL":
apply_timing_preset(s.timing_preset_ab_mgcl_c)
case "SK Hynix NME":
apply_timing_preset(s.timing_preset_nme_c)
case "Samsung HB-MGCH":
apply_timing_preset(s.timing_preset_hb_mgch_c)
case _:
temporary_presets_unavailable()
def apply_st_timings(sender, app_data):
ram_selected = dpg.get_value("ram_type")
match(ram_selected):
case "Choose your RAM Type!":
c.show_popup("Error", "You must select a ram type to apply a preset")
case "Samsung AA-MGCL/MGCR":
apply_timing_preset(s.timing_preset_aamgcl_st)
case "SK Hynix NEI/NEE/x267":
apply_timing_preset(s.timing_preset_nee_st)
case "Micron WT:B":
apply_timing_preset(s.timing_preset_wtb_st)
case "Micron AUT:B":
apply_timing_preset(s.timing_preset_wtb_st)
case "Micron WT:F":
apply_timing_preset(s.timing_preset_wtf_st)
case "Samsung AM-MGCJ":
apply_timing_preset(s.timing_preset_mgcj_st)
case "Micron WT:E":
apply_timing_preset(s.timing_preset_wte_st)
case "Samsung AB-MGCL":
apply_timing_preset(s.timing_preset_ab_mgcl_st)
case "SK Hynix NME":
apply_timing_preset(s.timing_preset_nme_st)
case "Samsung HB-MGCH":
apply_timing_preset(s.timing_preset_hb_mgch_st)
case _:
temporary_presets_unavailable()

View File

@@ -1,157 +0,0 @@
"""
HOC Configurator
Copyright (C) Souldbminer
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
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 <http://www.gnu.org/licenses/>.
"""
import dearpygui.dearpygui as dpg
import common
import kip as k
import preset
from defaults import d
import settings as s
def populate():
# Values in kHz
voltages_mv = [v / 1000 for v in s.voltages_uv]
voltages_mv_label = ["Default (1175 mV)" if f == 0 else f"{f} mV" for f in voltages_mv]
vddq_mv = [v / 1000 for v in s.vddq_uv]
vddq_mv_label = ["Default (600 mV)" if f == 0 else f"{f} mV" for f in vddq_mv]
# Values in MHz (converted)
values_mhz = [v / 1000 for v in s.adjusted_freqs_khz]
values_mhz_label_m = ["Default (1996.8 MHz)" if f == 0 else f"{f} MHz" for f in values_mhz]
values_mhz_label_e = ["Default (1862.4 MHz)" if f == 0 else f"{f} MHz" for f in values_mhz]
dvb = [i for i in range(10)]
dpg.add_separator(label="RAM Types")
dpg.add_combo(
items=["Samsung AA-MGCL/MGCR", "SK Hynix NEI/NEE/x267", "Micron WT:B", "Micron AUT:B", "Micron WT:F", "Samsung AM-MGCJ", "Micron WT:E", "Samsung AB-MGCL", "SK Hynix NME", "Samsung HB-MGCH"],
default_value="Choose your RAM Type!",
label="RAM Type",
tag="ram_type"
)
dpg.add_button(label="Apply Regular Preset", callback=preset.apply_reg_timings)
dpg.add_button(label="Apply Tight Preset", callback=preset.apply_st_timings)
dpg.add_button(label="Load Default Preset", callback=preset.load_defaults)
dpg.add_combo(
items=["0", "1"],
default_value="0",
label="MTC Configuraton",
tag="mtcConf",
callback=k.grab_kip_storage_values
)
dpg.add_combo(
items=["0", "1"],
default_value="0",
label="HP Mode",
tag="hpMode",
callback=k.grab_kip_storage_values
)
dpg.add_separator(label="Frequencies (Mariko)")
dpg.add_text("Multiple Ram Frequencies on Mariko is in development")
dpg.add_combo(
items=values_mhz_label_m,
default_value="Default (1996.8 MHz)",
label="RAM Max Frequency (Mariko)",
tag="marikoEmcMaxClock",
callback=k.grab_kip_storage_values
)
dpg.add_separator(label="Frequencies (Erista)")
dpg.add_text("Multiple Ram Frequencies on Erista is in development")
# dpg.add_combo(
# items=values_mhz_label_e,
# default_value="Default (2132.64 MHz)",
# label="RAM Max Frequency (Erista)",
# tag="e_emc_clock_1",
# callback=k.grab_kip_storage_values
# )
# dpg.add_combo(
# items=values_mhz_label_e,
# default_value="Default (1996.8 MHz)",
# label="RAM Second Frequency (Erista)",
# tag="e_emc_clock_2",
# callback=k.grab_kip_storage_values
# )
dpg.add_combo(
items=values_mhz_label_e,
default_value="Default (1862.4 MHz)",
label="RAM Max Frequency (Erista)",
tag="eristaEmcMaxClock",
callback=k.grab_kip_storage_values
)
dpg.add_separator(label="Voltages")
dpg.add_combo(
items=voltages_mv_label,
default_value="Default (1175 mV)",
label="RAM Primary Voltage (VDD2)",
tag="commonEmcMemVolt",
callback=k.grab_kip_storage_values
)
dpg.add_combo(
items=vddq_mv_label,
default_value="Default (600 mV)",
label="RAM Secondary Voltage (VDDQ, Mariko ONLY)",
tag="marikoEmcVddqVolt",
callback=k.grab_kip_storage_values
)
dpg.add_combo(
items=dvb,
default_value="0",
label="SoC DVB Shift",
callback=k.grab_kip_storage_values_no_mult,
tag="marikoEmcDvbShift"
)
dpg.add_separator(label="Primary Timings")
dpg.add_combo(
items=list(range(0, 12)),
default_value="0",
label="Burst Latency (read)",
callback=k.grab_kip_storage_values_no_mult,
tag="mem_burst_read_latency"
)
dpg.add_combo(
items=list(range(0, 12)),
default_value="0",
label="Burst Latency (write)",
callback=k.grab_kip_storage_values_no_mult,
tag="mem_burst_write_latency"
)
dpg.add_slider_int(label="t1 tRCD", min_value=0, max_value=7, tag="t1_tRCD", callback=k.grab_kip_storage_values_no_mult)
dpg.add_slider_int(label="t2 tRP", min_value=0, max_value=7, tag="t2_tRP", callback=k.grab_kip_storage_values_no_mult)
dpg.add_slider_int(label="t3 tRAS", min_value=0, max_value=9, tag="t3_tRAS", callback=k.grab_kip_storage_values_no_mult)
dpg.add_separator(label="Secondary Timings")
dpg.add_slider_int(label="t4 tRRD", min_value=0, max_value=7, tag="t4_tRRD", callback=k.grab_kip_storage_values_no_mult)
dpg.add_slider_int(label="t5 tRFC", min_value=0, max_value=5, tag="t5_tRFC", callback=k.grab_kip_storage_values_no_mult)
dpg.add_slider_int(label="t6 tRTW", min_value=0, max_value=9, tag="t6_tRTW", callback=k.grab_kip_storage_values_no_mult)
dpg.add_slider_int(label="t7 tWTR", min_value=0, max_value=9, tag="t7_tWTR", callback=k.grab_kip_storage_values_no_mult)
dpg.add_slider_int(label="t8 tREFI", min_value=0, max_value=5, tag="t8_tREFI", callback=k.grab_kip_storage_values_no_mult)

View File

@@ -1,647 +0,0 @@
import common as c
# Links
kip_download_link="https://github.com/souldbminersmwc/Horizon-OC/releases/latest/download/loader.kip"
hoc_clk_download_link="https://github.com/souldbminersmwc/Horizon-OC/releases/latest/download/hoc-clk.zip"
nx_ovlloader_link = "https://github.com/ppkantorski/nx-ovlloader/releases/latest/download/nx-ovlloader+.zip"
ultrahand_link = "https://github.com/ppkantorski/Ultrahand-Overlay/releases/latest/download/ovlmenu.ovl"
status_monitor_link = "https://github.com/ppkantorski/Status-Monitor-Overlay/releases/latest/download/Status-Monitor-Overlay.ovl "
saltynx_link = "https://github.com/masagrator/SaltyNX/releases/latest/download/SaltyNX.zip"
reversenx_link = "https://github.com/masagrator/ReverseNX-RT/releases/latest/download/ReverseNX-RT-ovl.ovl"
# Frequencies
freqs_khz = [
76800, 153600, 230400, 307200, 384000, 460800, 537600, 614400, 691200, 768000,
844800, 921600, 998400, 1075200, 1152000, 1228800, 1267200, 1305600, 1344000, 1382400, 1420800,
1459200, 1497600, 1536000
]
freqs_khz_e = [
76800, 115200, 153600, 192000, 230400, 268800, 307200, 345600, 384000, 422400, 460800, 499200, 537600,
576000,614400, 652800,691200,729600, 768000,806400, 844800,883200, 921600,960000, 998400,1036800, 1075200# ,
]
freqs_mhz = [
76.8, 153.6, 230.4, 307.2, 384.0, 460.8, 537.6, 614.4, 691.2, 768.0,
844.8, 921.6, 998.4, 1075.2, 1152.0, 1228.8, 1267.2, 1305.6, 1344.0, 1382.4,
1420.8, 1459.2, 1497.6, 1536.0
]
adjusted_freqs_khz = [
0, 1600000, 1633000, 1666000, 1700000, 1733000, 1766000, 1800000, 1833000, 1866000, 1900000,
1933000, 1966000, 2000000, 2033000, 2066000, 2100000, 2133000, 2166000, 2200000, 2233000,
2266000, 2300000, 2333000, 2366000, 2400000, 2433000, 2466000, 2500000, 2533000, 2566000,
2600000, 2633000, 2666000, 2700000, 2733000, 2766000, 2800000, 2833000, 2866000, 2900000,
2933000, 2966000, 3000000, 3033000, 3066000, 3100000, 3133000, 3166000, 3200000, 3233000,
3266000, 3300000, 3333000, 3366000, 3400000, 3433000, 3466000, 3500000
]
voltages_uv = [
0, 1050000, 1062500, 1075000, 1087500, 1100000, 1112500, 1125000,
1137500, 1150000, 1162500, 1175000, 1187500, 1200000, 1212500, 1237500
]
vddq_uv = [
0, 550000, 555000, 560000, 565000, 570000, 575000, 580000, 585000, 590000, 595000,
600000, 605000, 610000, 615000, 620000, 625000, 630000, 635000, 640000, 645000,
650000
]
freqs_hz_cpu = [
1020000, 1122000, 1224000, 1326000, 1428000, 1581000, 1683000,
1785000, 1887000, 1963500, 2091000, 2193000, 2295000, 2397000,
2499000, 2601000, 2703000, 2805000, 2907000
]
freqs_mhz_cpu = [
1020.0, 1122.0, 1224.0, 1326.0, 1428.0, 1581.0, 1683.0,
1785.0, 1887.0, 1963.5, 2091.0, 2193.0, 2295.0, 2397.0,
2499.0, 2601.0, 2703.0, 2805.0, 2907.0
]
# Loading/saving
variables = [
("custRev", "u32"),
("mtcConf", "u32"),
("hpMode", "u32"),
("commonEmcMemVolt", "u32"),
("eristaEmcMaxClock", "u32"),
("marikoEmcMaxClock", "u32"),
("marikoEmcVddqVolt", "u32"),
("marikoEmcDvbShift", "u32"),
("t1_tRCD", "u32"),
("t2_tRP", "u32"),
("t3_tRAS", "u32"),
("t4_tRRD", "u32"),
("t5_tRFC", "u32"),
("t6_tRTW", "u32"),
("t7_tWTR", "u32"),
("t8_tREFI", "u32"),
("mem_burst_read_latency", "u32"),
("mem_burst_write_latency", "u32"),
("eristaCpuUV", "u32"),
("eristaCpuMaxVolt", "u32"),
("marikoCpuUVLow", "u32"),
("marikoCpuUVHigh", "u32"),
("tableConf", "u32"),
("marikoCpuLowVmin", "u32"),
("marikoCpuHighVmin", "u32"),
("marikoCpuMaxVolt", "u32"),
("marikoCpuBoostClock", "u32"),
("eristaCpuBoostClock", "u32"),
("eristaGpuUV", "u32"),
("eristaGpuVmin", "u32"),
("marikoGpuUV", "u32"),
("marikoGpuVmin", "u32"),
("marikoGpuVmax", "u32"),
("commonGpuVoltOffset", "u32"),
# advanced config
("gpuSpeedo", "u32"),
("marikoGpuFullUnlock", "u32"),
("g_volt_e_76800", "u32"),
("g_volt_e_115200", "u32"),
("g_volt_e_153600", "u32"),
("g_volt_e_192000", "u32"),
("g_volt_e_230400", "u32"),
("g_volt_e_268800", "u32"),
("g_volt_e_307200", "u32"),
("g_volt_e_345600", "u32"),
("g_volt_e_384000", "u32"),
("g_volt_e_422400", "u32"),
("g_volt_e_460800", "u32"),
("g_volt_e_499200", "u32"),
("g_volt_e_537600", "u32"),
("g_volt_e_576000", "u32"),
("g_volt_e_614400", "u32"),
("g_volt_e_652800", "u32"),
("g_volt_e_691200", "u32"),
("g_volt_e_729600", "u32"),
("g_volt_e_768000", "u32"),
("g_volt_e_806400", "u32"),
("g_volt_e_844800", "u32"),
("g_volt_e_883200", "u32"),
("g_volt_e_921600", "u32"),
("g_volt_e_960000", "u32"),
("g_volt_e_998400", "u32"),
("g_volt_e_1036800", "u32"),
("g_volt_e_1075200", "u32"),
# ("g_volt_e_1152000", "u32"),
# ("g_volt_e_1228800", "u32"),
("g_volt_76800", "u32"),
("g_volt_153600", "u32"),
("g_volt_230400", "u32"),
("g_volt_307200", "u32"),
("g_volt_384000", "u32"),
("g_volt_460800", "u32"),
("g_volt_537600", "u32"),
("g_volt_614400", "u32"),
("g_volt_691200", "u32"),
("g_volt_768000", "u32"),
("g_volt_844800", "u32"),
("g_volt_921600", "u32"),
("g_volt_998400", "u32"),
("g_volt_1075200", "u32"),
("g_volt_1152000", "u32"),
("g_volt_1228800", "u32"),
("g_volt_1267200", "u32"),
("g_volt_1305600", "u32"),
("g_volt_1344000", "u32"),
("g_volt_1382400", "u32"),
("g_volt_1420800", "u32"),
("g_volt_1459200", "u32"),
("g_volt_1497600", "u32"),
("g_volt_1536000", "u32"),
]
fmt_map = {
"u32": "I",
"double": "d",
}
def load_all_vars():
c.load_entry_object("custRev", 0)
c.load_entry_object("mtcConf", 0)
c.load_entry_object("hpMode", 0)
c.load_entry_object("commonEmcMemVolt", 2)
c.load_entry_object("eristaEmcMaxClock", 1)
c.load_entry_object("marikoEmcMaxClock", 1)
c.load_entry_object("marikoEmcVddqVolt", 2)
c.load_entry_object("marikoEmcDvbShift", 0)
# === Advanced memory config ===
c.load_entry_object("t1_tRCD", 5)
c.load_entry_object("t2_tRP", 5)
c.load_entry_object("t3_tRAS", 5)
c.load_entry_object("t4_tRRD", 5)
c.load_entry_object("t5_tRFC", 5)
c.load_entry_object("t6_tRTW", 5)
c.load_entry_object("t7_tWTR", 5)
c.load_entry_object("t8_tREFI", 5)
c.load_entry_object("mem_burst_read_latency", 5)
c.load_entry_object("mem_burst_write_latency", 5)
# === CPU Voltages ===
c.load_entry_object("eristaCpuUV", 5)
c.load_entry_object("eristaCpuMaxVolt", 3)
c.load_entry_object("marikoCpuUVLow", 5)
c.load_entry_object("marikoCpuUVHigh", 5)
c.load_entry_object("tableConf", 5)
c.load_entry_object("marikoCpuLowVmin", 3)
c.load_entry_object("marikoCpuHighVmin", 3)
c.load_entry_object("marikoCpuMaxVolt", 3)
c.load_entry_object("marikoCpuBoostClock", 1)
c.load_entry_object("eristaCpuBoostClock", 1)
# === GPU Voltages ===
c.load_entry_object("eristaGpuUV", 4)
c.load_entry_object("eristaGpuVmin", 3)
c.load_entry_object("marikoGpuUV", 4)
c.load_entry_object("marikoGpuVmin", 3)
c.load_entry_object("marikoGpuVmax", 3)
c.load_entry_object("commonGpuVoltOffset", 3)
c.load_entry_object("gpuSpeedo", 3)
c.load_entry_object("marikoGpuFullUnlock", 3)
erista_freqs = [
"76800", "115200", "153600", "192000", "230400", "268800", "307200",
"345600", "384000", "422400", "460800", "499200", "537600", "576000",
"614400", "652800", "691200", "729600", "768000", "806400", "844800",
"883200", "921600", "960000", "998400", "1036800", "1075200"
]
for freq in erista_freqs:
c.load_entry_object(f"g_volt_e_{freq}", 3)
mariko_freqs = [
"76800", "153600", "230400", "307200", "384000", "460800", "537600",
"614400", "691200", "768000", "844800", "921600", "998400", "1075200",
"1152000", "1228800", "1267200", "1305600", "1344000", "1382400",
"1420800", "1459200", "1497600", "1536000"
]
for freq in mariko_freqs:
c.load_entry_object(f"g_volt_{freq}", 3)
# Timings
timing_vars = [
"d.t1_tRCD",
"d.t2_tRP",
"d.t3_tRAS",
"d.t4_tRRD",
"d.t5_tRFC",
"d.t6_tRTW",
"d.t7_tWTR",
"d.t8_tREFI"
]
timing_preset_default = [
0, # tRCD
0, # tRP
0, # tRAS
0, # tRRD
0, # tRFC
0, # tRTW
0, # tWTR
0, # tREFI
]
timing_preset_aamgcl_c = [
4, # tRCD
4, # tRP
5, # tRAS
5, # tRRD
5, # tRFC
5, # tRTW
7, # tWTR
6, # tREFI
]
timing_preset_aamgcl_st = [
4, # tRCD
4, # tRP
8, # tRAS
6, # tRRD
5, # tRFC
7, # tRTW
8, # tWTR
6, # tREFI
]
timing_preset_mgcj_c = [
3, # tRCD
2, # tRP
4, # tRAS
2, # tRRD
4, # tRFC
4, # tRTW
4, # tWTR
6, # tREFI
]
timing_preset_mgcj_st = [
4, # tRCD
3, # tRP
8, # tRAS
2, # tRRD
5, # tRFC
4, # tRTW
4, # tWTR
6, # tREFI
]
timing_preset_ab_mgcl_c = [
4, # tRCD
4, # tRP
4, # tRAS
4, # tRRD
4, # tRFC
5, # tRTW
6, # tWTR
6, # tREFI
]
timing_preset_ab_mgcl_st = [
4, # tRCD
4, # tRP
8, # tRAS
5, # tRRD
5, # tRFC
6, # tRTW
8, # tWTR
6, # tREFI
]
timing_preset_hb_mgch_c = [
4, # tRCD
4, # tRP
4, # tRAS
0, # tRRD
1, # tRFC
5, # tRTW
4, # tWTR
6, # tREFI
]
timing_preset_hb_mgch_st = [
4, # tRCD
5, # tRP
9, # tRAS
1, # tRRD
2, # tRFC
6, # tRTW
4, # tWTR
6, # tREFI
]
timing_preset_wtf_c = [
4, # tRCD
4, # tRP
2, # tRAS
5, # tRRD
4, # tRFC
6, # tRTW
3, # tWTR
6, # tREFI
]
timing_preset_wtf_st = [
5, # tRCD
5, # tRP
4, # tRAS
5, # tRRD
5, # tRFC
6, # tRTW
5, # tWTR
6, # tREFI
]
timing_preset_wte_c = [
2, # tRCD
2, # tRP
2, # tRAS
2, # tRRD
4, # tRFC
4, # tRTW
4, # tWTR
6, # tREFI
]
timing_preset_wte_st = [
3, # tRCD
5, # tRP
3, # tRAS
3, # tRRD
5, # tRFC
4, # tRTW
5, # tWTR
6, # tREFI
]
timing_preset_wtb_c = [
4, # tRCD
4, # tRP
5, # tRAS
5, # tRRD
2, # tRFC
6, # tRTW
5, # tWTR
6, # tREFI
]
timing_preset_wtb_st = [
6, # tRCD
6, # tRP
7, # tRAS
7, # tRRD
2, # tRFC
6, # tRTW
5, # tWTR
6, # tREFI
]
timing_preset_nee_c = [
3, # tRCD
3, # tRP
2, # tRAS
2, # tRRD
5, # tRFC
5, # tRTW
4, # tWTR
6, # tREFI
]
timing_preset_nee_st = [
4, # tRCD
4, # tRP
4, # tRAS
3, # tRRD
7, # tRFC
6, # tRTW
5, # tWTR
6, # tREFI
]
timing_preset_nme_c = [
2, # tRCD
2, # tRP
1, # tRAS
0, # tRRD
1, # tRFC
4, # tRTW
3, # tWTR
6, # tREFI
]
timing_preset_nme_st = [
3, # tRCD
3, # tRP
4, # tRAS
0, # tRRD
1, # tRFC
4, # tRTW
4, # tWTR
6, # tREFI
]
# INI
skinTarget = 54 # default value
PROFILES = {
"V1_Erista": {
"tskin_pcb_coefficients_console_on_fwdbg": 'str!"[6396, 119440]"',
"tskin_pcb_coefficients_handheld_on_fwdbg": 'str!"[5817, 129580]"',
"tskin_soc_coefficients_console_on_fwdbg": 'str!"[6182, 112480]"',
"tskin_soc_coefficients_handheld_on_fwdbg": 'str!"[5464, 174190]"',
},
"V2_Mariko": {
"tskin_pcb_coefficients_console_on_fwdbg": 'str!"[7338, 112161]"',
"tskin_pcb_coefficients_handheld_on_fwdbg": 'str!"[6357, 168124]"',
"tskin_soc_coefficients_console_on_fwdbg": 'str!"[6728, 129810]"',
"tskin_soc_coefficients_handheld_on_fwdbg": 'str!"[5675, 203453]"',
},
"Lite_Mariko": {
"tskin_pcb_coefficients_console_on_fwdbg": 'str!"[7338, 112161]"',
"tskin_pcb_coefficients_handheld_on_fwdbg": 'str!"[5594, 209601]"',
"tskin_soc_coefficients_console_on_fwdbg": 'str!"[6728, 129810]"',
"tskin_soc_coefficients_handheld_on_fwdbg": 'str!"[5235, 199759]"',
},
"OLED_Mariko": {
"tskin_pcb_coefficients_console_on_fwdbg": 'str!"[8051, -45213]"',
"tskin_pcb_coefficients_handheld_on_fwdbg": 'str!"[7176, -33954]"',
"tskin_soc_coefficients_console_on_fwdbg": 'str!"[7831, 57590]"',
"tskin_soc_coefficients_handheld_on_fwdbg": 'str!"[9029, 4274]"',
},
}
BATTERY_SAVE_OPTIONS = {
"bgtc": {
"enable_halfawake": "u32!0x0",
"minimum_interval_normal": "u32!0x7FFFFFFF",
"minimum_interval_save": "u32!0x7FFFFFFF",
"battery_threshold_save": "u32!0x64",
"battery_threshold_stop": "u32!0x64",
},
"npns": {
"background_processing": "u8!0x0",
"sleep_periodic_interval": "u32!0x7FFFFFFF",
"sleep_processing_timeout": "u32!0x0",
"sleep_max_try_count": "u32!0x0",
},
"ns.notification": {
"enable_download_task_list": "u8!0x0",
"enable_download_ticket": "u8!0x0",
"enable_network_update": "u8!0x0",
"enable_random_wait": "u8!0x0",
"enable_request_on_cold_boot": "u8!0x0",
"enable_send_rights_usage_status_request": "u8!0x0",
"enable_sync_elicense_request": "u8!0x0",
"enable_version_list": "u8!0x0",
"retry_interval_min": "u32!0x7FFFFFFF",
"retry_interval_max": "u32!0x7FFFFFFF",
"version_list_waiting_limit_bias": "u32!0x7FFFFFFF",
"version_list_waiting_limit_min": "u32!0x7FFFFFFF",
},
"account": {
"na_required_for_network_service": "u8!0x0",
"na_license_verification_enabled": "u8!0x0",
},
"account.daemon": {
"background_awaking_periodicity": "u32!0x7FFFFFFF",
"initial_schedule_delay": "u32!0x7FFFFFFF",
"profile_sync_interval": "u32!0x7FFFFFFF",
"na_info_refresh_interval": "u32!0x7FFFFFFF",
},
"capsrv": {
"enable_album_screenshot_filedata_verification": "u8!0x0",
"enable_album_movie_filehash_verification": "u8!0x0",
"enable_album_movie_filesign_verification": "u8!0x0",
},
"friends": {
"background_processing": "u8!0x0",
},
"notification.presenter": {
"snooze_interval_in_seconds": "u32!0x7FFFFFFF",
"connection_retry_count": "u32!0x0",
"alarm_pattern_total_repeat_count": "u32!0x0",
"alarm_pattern_with_vibration_repeat_count": "u32!0x0",
},
"prepo": {
"transmission_interval_min": "u32!0x7FFFFFFF",
"transmission_retry_interval_min": "u32!0x7FFFFFFF",
"transmission_retry_interval_max": "u32!0x7FFFFFFF",
"transmission_interval_in_sleep": "u32!0x7FFFFFFF",
"statistics_save_interval_min": "u32!0x7FFFFFFF",
"statistics_post_interval": "u32!0x7FFFFFFF",
"save_system_report": "u8!0x0",
},
"olsc": {
"default_auto_upload_global_setting": "u8!0x0",
"default_auto_download_global_setting": "u8!0x0",
"autonomy_registration_interval_seconds": "u32!0x7FFFFFFF",
"network_service_license_info_cache_expiration_seconds": "u32!0x7FFFFFFF",
"postponed_transfer_task_processing_interval_seconds": "u32!0x7FFFFFFF",
"retry_offset_seconds": "u32!0x7FFFFFFF",
"network_trouble_detection_span_seconds": "u32!0x7FFFFFFF",
"network_connection_polling_interval_seconds": "u32!0x7FFFFFFF",
"is_save_data_backup_policy_check_required": "u8!0x0",
"is_global_transfer_task_autonomy_registration_enabled": "u8!0x0",
"is_on_event_transfer_task_registration_enabled": "u8!0x0",
"is_periodic_transfer_task_registration_enabled": "u8!0x0",
},
"ntc": {
"is_autonomic_correction_enabled": "u8!0x0",
"autonomic_correction_interval_seconds": "u32!0x7FFFFFFF",
"autonomic_correction_failed_retry_interval_seconds": "u32!0x7FFFFFFF",
"autonomic_correction_immediate_try_count_max": "u32!0x0",
"autonomic_correction_immediate_try_interval_milliseconds": "u32!0x7FFFFFFF",
},
"systemupdate": {
"bgnup_retry_seconds": "u32!0x7FFFFFFF",
},
"ns.rights": {
"skip_account_validation_on_rights_check": "u8!0x1",
"next_available_time_of_unexpected_error": "u32!0x7FFFFFFF",
},
"pctl": {
"intermittent_task_interval_seconds": "u32!0x7FFFFFFF",
},
"sprofile": {
"adjust_polling_interval_by_profile": "u8!0x0",
"polling_interval_sec_max": "u32!0x7FFFFFFF",
"polling_interval_sec_min": "u32!0x7FFFFFFF",
},
}
PSM_OPTIONS = [
{"name": "1024mA", "value": "u32!0x400"},
{"name": "1280mA", "value": "u32!0x500"},
{"name": "1536mA", "value": "u32!0x600"},
{"name": "1660mA (Lite Default)", "value": "u32!0x67C"},
{"name": "1792mA", "value": "u32!0x700"},
{"name": "2048mA (Default)", "value": "u32!0x800"},
{"name": "2304mA (UNSAFE)", "value": "u32!0x900"},
{"name": "2560mA (UNSAFE)", "value": "u32!0xA00"},
{"name": "2816mA (DANGEROUS)", "value": "u32!0xB00"},
{"name": "3072mA (DANGEROUS)", "value": "u32!0xC00"},
]
skin_t_entries = {
"use_configurations_on_fwdbg": "u8!0x1",
"tskin_rate_table_console_on_fwdbg": f'str!"[[-1000000,40000,0,0],[36000,43000,51,51],[43000,49000,51,128],[49000,{skinTarget}000,128,255],[{skinTarget}000,1000000,255,255]]"',
"tskin_rate_table_handheld_on_fwdbg": f'str!"[[-1000000,40000,0,0],[36000,43000,51,51],[43000,49000,51,128],[49000,{skinTarget}000,128,255],[{skinTarget}000,1000000,255,255]]"',
"holdable_tskin": "u32!0xEA60",
"touchable_tskin": "u32!0xEA60"
}
# Thresholds
mariko_meme_threshold = 1536000
mariko_dangerous_gpu_threshold = 1305600
mariko_unsafe_gpu_threshold = 998000
erista_dangerous_gpu_threshold = 1076000
erista_unsafe_gpu_threshold = 884000
mariko_voltage_step = 5
erista_voltage_step = 5
mariko_gpu_offset_max = 50
mariko_gpu_min_volt = 480
erista_gpu_min_volt = 700
mariko_gpu_max_volt = 960
erista_gpu_max_volt = 1000
mariko_gpu_max_vmin = 700
erista_gpu_max_vmin = 850
mariko_cpu_min_vmin = 700
mariko_cpu_max_vmin = 750
# TODO: Make more stuff configurable
# COLORS
danger_color = (255, 0, 0, 255)
unsafe_color = (255, 165, 0, 255)
safe_color = (255, 255, 255, 255)

View File

@@ -1 +0,0 @@
python -m PyInstaller --onefile --noconsole eostimingutil.py

Binary file not shown.

View File

@@ -1,52 +0,0 @@
[
{
"name": "42",
"label": "(42) 0",
"hex": "00"
},
{
"name": "36",
"label": "(36) 1",
"hex": "01"
},
{
"name": "34",
"label": "(34) 2",
"hex": "02"
},
{
"name": "32",
"label": "(32) 3",
"hex": "03"
},
{
"name": "30",
"label": "(30) 4",
"hex": "04"
},
{
"name": "28",
"label": "(28) 5",
"hex": "05"
},
{
"name": "26",
"label": "(26) 6",
"hex": "06"
},
{
"name": "24",
"label": "(24) 7",
"hex": "07"
},
{
"name": "22",
"label": "(22) 8",
"hex": "08"
},
{
"name": "20",
"label": "(20) 9",
"hex": "09"
}
]

View File

@@ -1,42 +0,0 @@
[
{
"name": "18 - (0)",
"label": "(18) 0",
"hex": "00"
},
{
"name": "17 - (1)",
"label": "(17) 1",
"hex": "01"
},
{
"name": "16 - (2)",
"label": "(16) 2",
"hex": "02"
},
{
"name": "15 - (3)",
"label": "(15) 3",
"hex": "03"
},
{
"name": "14 - (4)",
"label": "(14) 4",
"hex": "04"
},
{
"name": "13 - (5)",
"label": "(13) 5",
"hex": "05"
},
{
"name": "12 - (6)",
"label": "(12) 6",
"hex": "06"
},
{
"name": "11 - (7)",
"label": "(11) 7",
"hex": "07"
}
]

View File

@@ -1,37 +0,0 @@
[
{
"name": "(1x REFI) 0",
"label": "0",
"hex": "00"
},
{
"name": "(1.5x REFI) 1",
"label": "1",
"hex": "01"
},
{
"name": "(2x REFI) 2",
"label": "2",
"hex": "02"
},
{
"name": "(3x REFI) 3",
"label": "3",
"hex": "03"
},
{
"name": "(4x REFI) 4",
"label": "4",
"hex": "04"
},
{
"name": "(6x REFI) 5",
"label": "5",
"hex": "05"
},
{
"name": "(MAX REFI) 6",
"label": "6",
"hex": "06"
}
]

View File

@@ -1,47 +0,0 @@
[
{
"name": "(140) 0",
"label": "0",
"hex": "00"
},
{
"name": "(120) 1",
"label": "1",
"hex": "01"
},
{
"name": "(100) 2",
"label": "2",
"hex": "02"
},
{
"name": "(90) 3",
"label": "3",
"hex": "03"
},
{
"name": "(80) 4",
"label": "4",
"hex": "04"
},
{
"name": "(70) 5",
"label": "5",
"hex": "05"
},
{
"name": "(60) 6",
"label": "6",
"hex": "06"
},
{
"name": "(50) 7",
"label": "7",
"hex": "07"
},
{
"name": "(40) 8",
"label": "8",
"hex": "08"
}
]

View File

@@ -1,42 +0,0 @@
[
{
"name": "18 - (0)",
"label": " (18) 0",
"hex": "00"
},
{
"name": "17 - (1)",
"label": " (17) 1",
"hex": "01"
},
{
"name": "16 - (2)",
"label": " (16) 2",
"hex": "02"
},
{
"name": "15 - (3)",
"label": " (15) 3",
"hex": "03"
},
{
"name": "14 - (4)",
"label": " (14) 4",
"hex": "04"
},
{
"name": "13 - (5)",
"label": " (13) 5",
"hex": "05"
},
{
"name": "12 - (6)",
"label": " (12) 6",
"hex": "06"
},
{
"name": "11 - (7)",
"label": " (11) 7",
"hex": "07"
}
]

View File

@@ -1,42 +0,0 @@
[
{
"name": "(10) 0",
"label": "0",
"hex": "00"
},
{
"name": "(7.5) 1",
"label": "1",
"hex": "01"
},
{
"name": "(6) 2",
"label": "2",
"hex": "02"
},
{
"name": "(5) 3",
"label": "3",
"hex": "03"
},
{
"name": "(4) 4",
"label": "4",
"hex": "04"
},
{
"name": "(3) 5",
"label": "5",
"hex": "05"
},
{
"name": "(2) 6",
"label": "6",
"hex": "06"
},
{
"name": "(1) 7",
"label": "7",
"hex": "07"
}
]

View File

@@ -1,52 +0,0 @@
[
{
"name": " 0",
"label": "0",
"hex": "00"
},
{
"name": " 1",
"label": "1",
"hex": "01"
},
{
"name": " 2",
"label": "2",
"hex": "02"
},
{
"name": " 3",
"label": "3",
"hex": "03"
},
{
"name": " 4",
"label": "4",
"hex": "04"
},
{
"name": " 5",
"label": "5",
"hex": "05"
},
{
"name": " 6",
"label": "6",
"hex": "06"
},
{
"name": " 7",
"label": "7",
"hex": "07"
},
{
"name": " 8",
"label": "8",
"hex": "08"
},
{
"name": " 9",
"label": "9",
"hex": "09"
}
]

View File

@@ -1,52 +0,0 @@
[
{
"name": "(10) 0",
"label": "0",
"hex": "00"
},
{
"name": "(9) 1",
"label": "1",
"hex": "01"
},
{
"name": "(8) 2",
"label": "2",
"hex": "02"
},
{
"name": "(7) 3",
"label": "3",
"hex": "03"
},
{
"name": "(6) 4",
"label": "4",
"hex": "04"
},
{
"name": "(5) 5",
"label": "5",
"hex": "05"
},
{
"name": "(4) 6",
"label": "6",
"hex": "06"
},
{
"name": "(3) 7",
"label": "7",
"hex": "07"
},
{
"name": "(2) 8",
"label": "8",
"hex": "08"
},
{
"name": "(1) 9",
"label": "9",
"hex": "09"
}
]

Binary file not shown.

View File

@@ -1,78 +0,0 @@
import json
import dearpygui.dearpygui as dpg
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
timings = {
"tRCD": "mariko/ram_trcd.json",
"tRP": "mariko/ram_trp.json",
"tRAS": "mariko/ram_tras.json",
"tRRD": "mariko/ram_trrd.json",
"tRFC": "mariko/ram_trfc.json",
"tRTW": "mariko/ram_trtw.json",
"tWTR": "mariko/ram_twtr.json",
"tREFI": "mariko/ram_trefi.json"
}
timing_data = {}
for timing_name, rel_path in timings.items():
path = os.path.join(BASE_DIR, rel_path)
if os.path.exists(path):
try:
with open(path, "r") as f:
raw = json.load(f)
steps = {}
if isinstance(raw, list):
for i, entry in enumerate(raw):
if isinstance(entry, dict) and "name" in entry:
steps[i] = entry["name"].strip()
else:
steps[i] = str(entry)
elif isinstance(raw, dict):
for k, entry in raw.items():
if isinstance(entry, dict) and "name" in entry:
steps[int(k)] = entry["name"].strip()
else:
steps[int(k)] = str(entry)
timing_data[timing_name] = steps
except Exception as e:
print(f"Error loading {path}: {e}")
timing_data[timing_name] = {}
else:
print(f"Missing file: {path}")
timing_data[timing_name] = {}
def update_slider_label(sender, app_data, user_data):
timing_name = user_data
step = int(app_data)
name_value = timing_data[timing_name].get(step, "(no name)")
new_label = f"{timing_name}: {name_value}"
dpg.set_item_label(sender, new_label)
# --- GUI ---
dpg.create_context()
dpg.create_viewport(title="EOS Real Timings", width=600, height=500)
with dpg.window(label="Timings", width=580, height=480, tag="main"):
dpg.add_text("Select timings")
for timing_name, steps in timing_data.items():
if steps:
max_step = max(steps.keys())
current_name = steps.get(0, "")
dpg.add_slider_int(
label=f"{timing_name}: {current_name}",
min_value=0,
max_value=max_step,
default_value=0,
callback=update_slider_label,
user_data=timing_name,
width=400
)
else:
dpg.add_text(f"{timing_name}: (JSON not found or invalid)")
dpg.set_primary_window("main", True)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

View File

@@ -1,38 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['eostimingutil.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='eostimingutil',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

View File

@@ -1,52 +0,0 @@
[
{
"name": "42",
"label": "(42) 0",
"hex": "00"
},
{
"name": "36",
"label": "(36) 1",
"hex": "01"
},
{
"name": "34",
"label": "(34) 2",
"hex": "02"
},
{
"name": "32",
"label": "(32) 3",
"hex": "03"
},
{
"name": "30",
"label": "(30) 4",
"hex": "04"
},
{
"name": "28",
"label": "(28) 5",
"hex": "05"
},
{
"name": "26",
"label": "(26) 6",
"hex": "06"
},
{
"name": "24",
"label": "(24) 7",
"hex": "07"
},
{
"name": "22",
"label": "(22) 8",
"hex": "08"
},
{
"name": "20",
"label": "(20) 9",
"hex": "09"
}
]

View File

@@ -1,42 +0,0 @@
[
{
"name": "18 - (0)",
"label": "(18) 0",
"hex": "00"
},
{
"name": "17 - (1)",
"label": "(17) 1",
"hex": "01"
},
{
"name": "16 - (2)",
"label": "(16) 2",
"hex": "02"
},
{
"name": "15 - (3)",
"label": "(15) 3",
"hex": "03"
},
{
"name": "14 - (4)",
"label": "(14) 4",
"hex": "04"
},
{
"name": "13 - (5)",
"label": "(13) 5",
"hex": "05"
},
{
"name": "12 - (6)",
"label": "(12) 6",
"hex": "06"
},
{
"name": "11 - (7)",
"label": "(11) 7",
"hex": "07"
}
]

View File

@@ -1,37 +0,0 @@
[
{
"name": "(1x REFI) 0",
"label": "0",
"hex": "00"
},
{
"name": "(1.5x REFI) 1",
"label": "1",
"hex": "01"
},
{
"name": "(2x REFI) 2",
"label": "2",
"hex": "02"
},
{
"name": "(3x REFI) 3",
"label": "3",
"hex": "03"
},
{
"name": "(4x REFI) 4",
"label": "4",
"hex": "04"
},
{
"name": "(6x REFI) 5",
"label": "5",
"hex": "05"
},
{
"name": "(MAX REFI) 6",
"label": "6",
"hex": "06"
}
]

View File

@@ -1,47 +0,0 @@
[
{
"name": "(140) 0",
"label": "0",
"hex": "00"
},
{
"name": "(120) 1",
"label": "1",
"hex": "01"
},
{
"name": "(100) 2",
"label": "2",
"hex": "02"
},
{
"name": "(90) 3",
"label": "3",
"hex": "03"
},
{
"name": "(80) 4",
"label": "4",
"hex": "04"
},
{
"name": "(70) 5",
"label": "5",
"hex": "05"
},
{
"name": "(60) 6",
"label": "6",
"hex": "06"
},
{
"name": "(50) 7",
"label": "7",
"hex": "07"
},
{
"name": "(40) 8",
"label": "8",
"hex": "08"
}
]

View File

@@ -1,42 +0,0 @@
[
{
"name": "18 - (0)",
"label": " (18) 0",
"hex": "00"
},
{
"name": "17 - (1)",
"label": " (17) 1",
"hex": "01"
},
{
"name": "16 - (2)",
"label": " (16) 2",
"hex": "02"
},
{
"name": "15 - (3)",
"label": " (15) 3",
"hex": "03"
},
{
"name": "14 - (4)",
"label": " (14) 4",
"hex": "04"
},
{
"name": "13 - (5)",
"label": " (13) 5",
"hex": "05"
},
{
"name": "12 - (6)",
"label": " (12) 6",
"hex": "06"
},
{
"name": "11 - (7)",
"label": " (11) 7",
"hex": "07"
}
]

View File

@@ -1,42 +0,0 @@
[
{
"name": "(10) 0",
"label": "0",
"hex": "00"
},
{
"name": "(7.5) 1",
"label": "1",
"hex": "01"
},
{
"name": "(6) 2",
"label": "2",
"hex": "02"
},
{
"name": "(5) 3",
"label": "3",
"hex": "03"
},
{
"name": "(4) 4",
"label": "4",
"hex": "04"
},
{
"name": "(3) 5",
"label": "5",
"hex": "05"
},
{
"name": "(2) 6",
"label": "6",
"hex": "06"
},
{
"name": "(1) 7",
"label": "7",
"hex": "07"
}
]

View File

@@ -1,52 +0,0 @@
[
{
"name": " 0",
"label": "0",
"hex": "00"
},
{
"name": " 1",
"label": "1",
"hex": "01"
},
{
"name": " 2",
"label": "2",
"hex": "02"
},
{
"name": " 3",
"label": "3",
"hex": "03"
},
{
"name": " 4",
"label": "4",
"hex": "04"
},
{
"name": " 5",
"label": "5",
"hex": "05"
},
{
"name": " 6",
"label": "6",
"hex": "06"
},
{
"name": " 7",
"label": "7",
"hex": "07"
},
{
"name": " 8",
"label": "8",
"hex": "08"
},
{
"name": " 9",
"label": "9",
"hex": "09"
}
]

View File

@@ -1,52 +0,0 @@
[
{
"name": "(10) 0",
"label": "0",
"hex": "00"
},
{
"name": "(9) 1",
"label": "1",
"hex": "01"
},
{
"name": "(8) 2",
"label": "2",
"hex": "02"
},
{
"name": "(7) 3",
"label": "3",
"hex": "03"
},
{
"name": "(6) 4",
"label": "4",
"hex": "04"
},
{
"name": "(5) 5",
"label": "5",
"hex": "05"
},
{
"name": "(4) 6",
"label": "6",
"hex": "06"
},
{
"name": "(3) 7",
"label": "7",
"hex": "07"
},
{
"name": "(2) 8",
"label": "8",
"hex": "08"
},
{
"name": "(1) 9",
"label": "9",
"hex": "09"
}
]

View File

@@ -1,2 +0,0 @@
python eostimingutil.py

View File

@@ -83,7 +83,7 @@ Result nvdecCheck = 1;
Result nvencCheck = 1;
Result nvjpgCheck = 1;
Result nifmCheck = 1;
Result sysclkCheck = 1;
Result sysclkCheck = 0;
Result pwmDutyCycleCheck = 1;
//Wi-Fi
@@ -572,21 +572,19 @@ void Misc(void*) {
}
// Get sys-clk data
if (R_SUCCEEDED(sysclkCheck)) {
SysClkContext sysclkCTX;
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
realCPU_Hz = sysclkCTX.realFreqs[SysClkModule_CPU];
realGPU_Hz = sysclkCTX.realFreqs[SysClkModule_GPU];
realRAM_Hz = sysclkCTX.realFreqs[SysClkModule_MEM];
partLoad[SysClkPartLoad_EMC] = sysclkCTX.partLoad[SysClkPartLoad_EMC];
partLoad[SysClkPartLoad_EMCCpu] = sysclkCTX.partLoad[SysClkPartLoad_EMCCpu];
realCPU_mV = sysclkCTX.voltages[HocClkVoltage_CPU];
realGPU_mV = sysclkCTX.voltages[HocClkVoltage_GPU];
realVDD2_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDD2];
realVDDQ_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDDQ_MarikoOnly];
realSOC_mV = sysclkCTX.voltages[HocClkVoltage_SOC];
}
SysClkContext sysclkCTX;
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
realCPU_Hz = sysclkCTX.realFreqs[SysClkModule_CPU];
realGPU_Hz = sysclkCTX.realFreqs[SysClkModule_GPU];
realRAM_Hz = sysclkCTX.realFreqs[SysClkModule_MEM];
partLoad[SysClkPartLoad_EMC] = sysclkCTX.partLoad[SysClkPartLoad_EMC];
partLoad[SysClkPartLoad_EMCCpu] = sysclkCTX.partLoad[SysClkPartLoad_EMCCpu];
realCPU_mV = sysclkCTX.voltages[HocClkVoltage_CPU];
realGPU_mV = sysclkCTX.voltages[HocClkVoltage_GPU];
realVDD2_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDD2];
realVDDQ_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDDQ_MarikoOnly];
realSOC_mV = sysclkCTX.voltages[HocClkVoltage_SOC];
}
// Temperatures
@@ -699,21 +697,7 @@ void Misc3(void*) {
do {
mutexLock(&mutex_Misc);
// Get sys-clk data
if (R_SUCCEEDED(sysclkCheck)) {
SysClkContext sysclkCTX;
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
partLoad[SysClkPartLoad_EMC] = sysclkCTX.partLoad[SysClkPartLoad_EMC];
partLoad[SysClkPartLoad_EMCCpu] = sysclkCTX.partLoad[SysClkPartLoad_EMCCpu];
realCPU_mV = sysclkCTX.voltages[HocClkVoltage_CPU];
realGPU_mV = sysclkCTX.voltages[HocClkVoltage_GPU];
realSOC_mV = sysclkCTX.voltages[HocClkVoltage_SOC];
realVDD2_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDD2];
realVDDQ_mV = sysclkCTX.voltages[HocClkVoltage_EMCVDDQ_MarikoOnly];
}
}
// Temperatures
if (R_SUCCEEDED(i2cCheck)) {
Tmp451GetSocTemp(&SOC_temperatureF);

View File

@@ -446,14 +446,6 @@ public:
if (SaltySD) {
LoadSharedMemoryAndRefreshRate();
}
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
uint32_t sysClkApiVer = 0;
sysclkIpcGetAPIVersion(&sysClkApiVer);
if (sysClkApiVer < 4) {
sysclkIpcExit();
}
else sysclkCheck = 0;
}
if (R_SUCCEEDED(splInitialize())) {
u64 sku = 0;
splGetConfig(SplConfigItem_HardwareType, &sku);
@@ -466,16 +458,14 @@ public:
}
}
splExit();
sysclkIpcInitialize();
});
Hinted = envIsSyscallHinted(0x6F);
}
virtual void exitServices() override {
CloseThreads();
if (R_SUCCEEDED(sysclkCheck)) {
sysclkIpcExit();
}
sysclkIpcExit();
shmemClose(&_sharedmemory);
//Exit services
clkrstExit();
@@ -530,14 +520,6 @@ public:
if (SaltySD) {
LoadSharedMemory();
}
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
uint32_t sysClkApiVer = 0;
sysclkIpcGetAPIVersion(&sysClkApiVer);
if (sysClkApiVer < 4) {
sysclkIpcExit();
}
else sysclkCheck = 0;
}
if (R_SUCCEEDED(splInitialize())) {
u64 sku = 0;
splGetConfig(SplConfigItem_HardwareType, &sku);
@@ -550,6 +532,7 @@ public:
}
}
splExit();
sysclkIpcInitialize();
});
Hinted = envIsSyscallHinted(0x6F);
}
@@ -557,9 +540,7 @@ public:
virtual void exitServices() override {
CloseThreads();
shmemClose(&_sharedmemory);
if (R_SUCCEEDED(sysclkCheck)) {
sysclkIpcExit();
}
sysclkIpcExit();
//Exit services
clkrstExit();
pcvExit();
@@ -617,14 +598,6 @@ public:
if (SaltySD) {
LoadSharedMemory();
}
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
uint32_t sysClkApiVer = 0;
sysclkIpcGetAPIVersion(&sysClkApiVer);
if (sysClkApiVer < 4) {
sysclkIpcExit();
}
else sysclkCheck = 0;
}
if (R_SUCCEEDED(splInitialize())) {
u64 sku = 0;
splGetConfig(SplConfigItem_HardwareType, &sku);
@@ -637,6 +610,7 @@ public:
}
}
splExit();
sysclkIpcInitialize();
});
Hinted = envIsSyscallHinted(0x6F);
@@ -645,9 +619,7 @@ public:
virtual void exitServices() override {
CloseThreads();
shmemClose(&_sharedmemory);
if (R_SUCCEEDED(sysclkCheck)) {
sysclkIpcExit();
}
sysclkIpcExit();
// Exit services
clkrstExit();
pcvExit();
@@ -707,14 +679,6 @@ public:
if (SaltySD) {
LoadSharedMemoryAndRefreshRate();
}
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
uint32_t sysClkApiVer = 0;
sysclkIpcGetAPIVersion(&sysClkApiVer);
if (sysClkApiVer < 4) {
sysclkIpcExit();
}
else sysclkCheck = 0;
}
if (R_SUCCEEDED(splInitialize())) {
u64 sku = 0;
splGetConfig(SplConfigItem_HardwareType, &sku);
@@ -727,6 +691,7 @@ public:
}
}
splExit();
sysclkIpcInitialize();
});
Hinted = envIsSyscallHinted(0x6F);
}
@@ -734,9 +699,7 @@ public:
virtual void exitServices() override {
CloseThreads();
shmemClose(&_sharedmemory);
if (R_SUCCEEDED(sysclkCheck)) {
sysclkIpcExit();
}
sysclkIpcExit();
clkrstExit();
pcvExit();
tsExit();
@@ -790,14 +753,6 @@ public:
if (SaltySD) {
LoadSharedMemoryAndRefreshRate();
}
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
uint32_t sysClkApiVer = 0;
sysclkIpcGetAPIVersion(&sysClkApiVer);
if (sysClkApiVer < 4) {
sysclkIpcExit();
}
else sysclkCheck = 0;
}
if (R_SUCCEEDED(splInitialize())) {
u64 sku = 0;
splGetConfig(SplConfigItem_HardwareType, &sku);
@@ -810,6 +765,7 @@ public:
}
}
splExit();
sysclkIpcInitialize();
});
Hinted = envIsSyscallHinted(0x6F);
}
@@ -817,9 +773,7 @@ public:
virtual void exitServices() override {
CloseThreads();
shmemClose(&_sharedmemory);
if (R_SUCCEEDED(sysclkCheck)) {
sysclkIpcExit();
}
sysclkIpcExit();
clkrstExit();
pcvExit();
tsExit();
@@ -873,14 +827,6 @@ public:
if (SaltySD) {
LoadSharedMemoryAndRefreshRate();
}
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
uint32_t sysClkApiVer = 0;
sysclkIpcGetAPIVersion(&sysClkApiVer);
if (sysClkApiVer < 4) {
sysclkIpcExit();
}
else sysclkCheck = 0;
}
if (R_SUCCEEDED(splInitialize())) {
u64 sku = 0;
splGetConfig(SplConfigItem_HardwareType, &sku);
@@ -893,6 +839,7 @@ public:
}
}
splExit();
sysclkIpcInitialize();
});
Hinted = envIsSyscallHinted(0x6F);
}
@@ -900,9 +847,7 @@ public:
virtual void exitServices() override {
CloseThreads();
shmemClose(&_sharedmemory);
if (R_SUCCEEDED(sysclkCheck)) {
sysclkIpcExit();
}
sysclkIpcExit();
clkrstExit();
pcvExit();
tsExit();

View File

@@ -233,12 +233,10 @@ public:
else if (realRAM_Hz && settings.showDeltas && (settings.showRealFreqs || settings.showTargetFreqs)) {
renderer->drawString(DeltaRAM_c, false, COMMON_MARGIN + deltaOffset, height_offset, 15, (settings.textColor));
}
if (R_SUCCEEDED(sysclkCheck)) {
static std::vector<std::string> PartLoadColoredChars = {"CPU", "GPU"};
//static auto loadLabelWidth = renderer->getTextDimensions("Load: ", false, 15).first;
renderer->drawString("Load", false, COMMON_MARGIN, height_offset+15, 15, (settings.catColor2));
renderer->drawStringWithColoredSections(RAM_load_c, false, PartLoadColoredChars, COMMON_MARGIN + valueOffset, height_offset+15, 15, (settings.textColor), settings.catColor2);
}
static std::vector<std::string> PartLoadColoredChars = {"CPU", "GPU"};
//static auto loadLabelWidth = renderer->getTextDimensions("Load: ", false, 15).first;
renderer->drawString("Load", false, COMMON_MARGIN, height_offset+15, 15, (settings.catColor2));
renderer->drawStringWithColoredSections(RAM_load_c, false, PartLoadColoredChars, COMMON_MARGIN + valueOffset, height_offset+15, 15, (settings.textColor), settings.catColor2);
}
if (R_SUCCEEDED(Hinted)) {
//static auto textWidth = renderer->getTextDimensions("Total \nApplication \nApplet \nSystem \nSystem Unsafe ", false, 15).first;

View File

@@ -354,7 +354,7 @@ public:
else
width = renderer->getTextDimensions("100%@4444.4444 mV", false, fontsize).first;
}
} else if (key == "GPU" || (key == "RAM" && settings.showRAMLoad && R_SUCCEEDED(sysclkCheck))) {
} else if (key == "GPU" || (key == "RAM" && settings.showRAMLoad)) {
//dimensions = renderer->drawString("100.0%@4444.4", false, 0, 0, fontsize, renderer->a(0x0000));
if (!settings.showRAMLoadCPUGPU) {
@@ -370,7 +370,7 @@ public:
width = renderer->getTextDimensions("100%[100%,100%]@4444.4444 mV", false, fontsize).first;
}
}
} else if (key == "RAM" && (!settings.showRAMLoad || R_FAILED(sysclkCheck))) {
} else if (key == "RAM" && (!settings.showRAMLoad)) {
//dimensions = renderer->drawString("44444444MB@4444.4", false, 0, 0, fontsize, renderer->a(0x0000));
if (!settings.realVolts) {
width = renderer->getTextDimensions("100%@4444.4", false, fontsize).first;
@@ -993,51 +993,33 @@ public:
} else {
unsigned PartLoadInt;
if (R_SUCCEEDED(sysclkCheck)) {
PartLoadInt = partLoad[SysClkPartLoad_EMC] / 10;
if (settings.showRAMLoadCPUGPU) {
unsigned ramCpuLoadInt = partLoad[SysClkPartLoad_EMCCpu] / 10;
int RAM_GPU_Load = partLoad[SysClkPartLoad_EMC] - partLoad[SysClkPartLoad_EMCCpu];
unsigned ramGpuLoadInt = RAM_GPU_Load / 10;
if (settings.realFrequencies && realRAM_Hz) {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%[%u%%,%u%%]@%hu.%hhu",
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
} else {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%[%u%%,%u%%]@%hu.%hhu",
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
}
} else {
if (settings.realFrequencies && realRAM_Hz) {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%@%hu.%hhu", PartLoadInt,
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
} else {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%@%hu.%hhu", PartLoadInt,
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
}
}
} else {
const uint64_t RAM_Total_all = RAM_Total_application_u + RAM_Total_applet_u +
RAM_Total_system_u + RAM_Total_systemunsafe_u;
const uint64_t RAM_Used_all = RAM_Used_application_u + RAM_Used_applet_u +
RAM_Used_system_u + RAM_Used_systemunsafe_u;
PartLoadInt = (RAM_Total_all > 0) ? (unsigned)((RAM_Used_all * 100) / RAM_Total_all) : 0;
PartLoadInt = partLoad[SysClkPartLoad_EMC] / 10;
if (settings.showRAMLoadCPUGPU) {
unsigned ramCpuLoadInt = partLoad[SysClkPartLoad_EMCCpu] / 10;
int RAM_GPU_Load = partLoad[SysClkPartLoad_EMC] - partLoad[SysClkPartLoad_EMCCpu];
unsigned ramGpuLoadInt = RAM_GPU_Load / 10;
if (settings.realFrequencies && realRAM_Hz) {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%@%hu.%hhu", PartLoadInt,
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
"%u%%[%u%%,%u%%]@%hu.%hhu",
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
} else {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%@%hu.%hhu", PartLoadInt,
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
"%u%%[%u%%,%u%%]@%hu.%hhu",
PartLoadInt, ramCpuLoadInt, ramGpuLoadInt,
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
}
} else {
if (settings.realFrequencies && realRAM_Hz) {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%@%hu.%hhu", PartLoadInt,
realRAM_Hz / 1000000, (realRAM_Hz / 100000) % 10);
} else {
snprintf(MINI_RAM_var_compressed_c, sizeof(MINI_RAM_var_compressed_c),
"%u%%@%hu.%hhu", PartLoadInt,
RAM_Hz / 1000000, (RAM_Hz / 100000) % 10);
}
}
}

View File

@@ -1,5 +1,21 @@
/*
* --------------------------------------------------------------------------
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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 <http://www.gnu.org/licenses/>.
*
*/
/* --------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
* wrote this file. As long as you retain this notice you can do whatever you
@@ -8,11 +24,12 @@
* --------------------------------------------------------------------------
*/
#define NX_SERVICE_ASSUME_NON_DOMAIN
#include <sysclk/client/ipc.h>
#include <switch.h>
#include <string.h>
#include <stdatomic.h>
#include <sysclk/client/ipc.h>
static Service g_sysclkSrv;
static atomic_size_t g_refCnt;
@@ -20,7 +37,7 @@ static atomic_size_t g_refCnt;
bool sysclkIpcRunning()
{
Handle handle;
const bool running = R_FAILED(smRegisterService(&handle, smEncodeName(SYSCLK_IPC_SERVICE_NAME), false, 1));
bool running = R_FAILED(smRegisterService(&handle, smEncodeName(SYSCLK_IPC_SERVICE_NAME), false, 1));
if (!running)
{
@@ -94,7 +111,10 @@ Result sysclkIpcSetOverride(SysClkModule module, u32 hz)
Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles)
{
return serviceDispatchInOut(&g_sysclkSrv, SysClkIpcCmd_GetProfiles, tid, *out_profiles);
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_GetProfiles, tid,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = {{out_profiles, sizeof(SysClkTitleProfileList)}},
);
}
Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles)
@@ -107,12 +127,18 @@ Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles)
Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues)
{
return serviceDispatchOut(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues, *out_configValues);
return serviceDispatch(&g_sysclkSrv, SysClkIpcCmd_GetConfigValues,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = {{out_configValues, sizeof(SysClkConfigValueList)}},
);
}
Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues)
{
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetConfigValues, *configValues);
return serviceDispatch(&g_sysclkSrv, SysClkIpcCmd_SetConfigValues,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_In },
.buffers = {{configValues, sizeof(SysClkConfigValueList)}},
);
}
Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* outCount)
@@ -125,4 +151,33 @@ Result sysclkIpcGetFreqList(SysClkModule module, u32* list, u32 maxCount, u32* o
.buffer_attrs = { SfBufferAttr_HipcAutoSelect | SfBufferAttr_Out },
.buffers = {{list, maxCount * sizeof(u32)}},
);
}
Result sysclkIpcSetReverseNXRTMode(ReverseNXMode mode)
{
return serviceDispatchIn(&g_sysclkSrv, SysClkIpcCmd_SetReverseNXRTMode, mode);
}
Result hocClkIpcSetKipData()
{
u32 temp = 0;
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_SetKipData, temp);
}
Result hocClkIpcGetKipData()
{
u32 temp = 0;
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_GetKipData, temp);
}
Result hocClkIpcUpdateEmcRegs()
{
u32 temp = 0;
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_UpdateEmcRegs, temp);
}
Result hocClkIpcCalculateGpuVmin()
{
u32 temp = 0;
return serviceDispatchIn(&g_sysclkSrv, HocClkIpcCmd_CalculateGpuVmin, temp);
}

View File

@@ -1,186 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# Project Info
#---------------------------------------------------------------------------------
TARGET := hoc-configurator
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#ROMFS := romfs
APP_TITLE := HOC Configurator
APP_AUTHOR := Dominatorul
APP_VERSION := 2.0.0
ICON := icon.jpg
#---------------------------------------------------------------------------------
# Compilation Settings
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lnx
#---------------------------------------------------------------------------------
# Library Paths
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
#---------------------------------------------------------------------------------
# Automatic Build Rules
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(CONFIG_JSON)),)
jsons := $(wildcard *.json)
ifneq (,$(findstring $(TARGET).json,$(jsons)))
export APP_JSON := $(TOPDIR)/$(TARGET).json
else
ifneq (,$(findstring config.json,$(jsons)))
export APP_JSON := $(TOPDIR)/config.json
endif
endif
else
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
endif
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.jpg)
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
else
ifneq (,$(findstring icon.jpg,$(icons)))
export APP_ICON := $(TOPDIR)/icon.jpg
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_ICON)),)
export NROFLAGS += --icon=$(APP_ICON)
endif
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
.PHONY: $(BUILD) clean all rebuild
#---------------------------------------------------------------------------------
# Automatically clean before build
#---------------------------------------------------------------------------------
all: clean $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo "Cleaning..."
ifeq ($(strip $(APP_JSON)),)
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
else
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
#---------------------------------------------------------------------------------
# Optional: Full rebuild command
#---------------------------------------------------------------------------------
rebuild: clean all
@echo "Rebuilt from scratch."
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
ifeq ($(strip $(APP_JSON)),)
all : $(OUTPUT).nro
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf
endif
else
all : $(OUTPUT).nsp
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
$(OUTPUT).nso : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN)
%.bin.o %_bin.h : %.bin
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
endif
#---------------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -1,20 +0,0 @@
/*
* HOC Configurator - Configuration Handler
* Copyright (C) Dominatorul, Souldbminer
*/
#pragma once
#include <string>
class Config {
public:
std::string kipPath;
bool autoSave;
Config();
bool loadConfig();
bool saveConfig();
bool checkKipExists();
bool checkAtmosphereExists();
};

View File

@@ -1,143 +0,0 @@
/*
* HOC Configurator - Constants
* Copyright (C) Dominatorul, Souldbminer
*/
#pragma once
#include <cstdint>
#include <string>
namespace Constants {
// Application info
constexpr const char* APP_VERSION = "2.0.0";
constexpr const char* APP_NAME = "HOC Configurator";
constexpr const char* APP_AUTHOR = "Dominatorul";
// Paths
constexpr const char* DEFAULT_KIP_PATH = "sdmc:/atmosphere/kips/loader.kip";
constexpr const char* CONFIG_DIR = "sdmc:/config/hoc-configurator";
constexpr const char* CONFIG_FILE = "sdmc:/config/hoc-configurator/config.ini";
constexpr const char* ATMOSPHERE_PATH = "sdmc:/atmosphere";
constexpr const char* SYSTEM_SETTINGS_INI = "sdmc:/atmosphere/config/system_settings.ini";
// Frequency arrays (in kHz)
constexpr uint32_t MARIKO_GPU_FREQS[] = {
76800, 153600, 230400, 307200, 384000, 460800, 537600, 614400,
691200, 768000, 844800, 921600, 998400, 1075200, 1152000, 1228800,
1267200, 1305600, 1344000, 1382400, 1420800, 1459200, 1497600, 1536000
};
constexpr uint32_t ERISTA_GPU_FREQS[] = {
76800, 153600, 230400, 307200, 384000, 460800, 537600, 614400,
691200, 768000, 844800, 921600, 998400, 1075200
};
constexpr uint32_t CPU_FREQS[] = {
1020000, 1122000, 1224000, 1326000, 1428000, 1581000, 1683000,
1785000, 1887000, 1963500, 2091000, 2193000, 2295000, 2397000,
2499000, 2601000, 2703000, 2805000, 2907000
};
constexpr uint32_t RAM_FREQS[] = {
0, 1600000, 1633000, 1666000, 1700000, 1733000, 1766000, 1800000,
1833000, 1866000, 1900000, 1933000, 1966000, 2000000, 2033000, 2066000,
2100000, 2133000, 2166000, 2200000, 2233000, 2266000, 2300000
};
// Voltage ranges
constexpr uint32_t MARIKO_GPU_MIN_VOLT = 480;
constexpr uint32_t MARIKO_GPU_MAX_VOLT = 960;
constexpr uint32_t MARIKO_GPU_MAX_VMIN = 700;
constexpr uint32_t ERISTA_GPU_MIN_VOLT = 700;
constexpr uint32_t ERISTA_GPU_MAX_VOLT = 1000;
constexpr uint32_t ERISTA_GPU_MAX_VMIN = 850;
constexpr uint32_t MARIKO_CPU_MIN_VMIN = 700;
constexpr uint32_t MARIKO_CPU_MAX_VMIN = 750;
constexpr uint32_t VOLTAGE_STEP = 5;
constexpr uint32_t GPU_OFFSET_MAX = 50;
// Thresholds
constexpr uint32_t MARIKO_MEME_THRESHOLD = 1536000;
constexpr uint32_t MARIKO_DANGEROUS_GPU_THRESHOLD = 1382400;
constexpr uint32_t MARIKO_UNSAFE_GPU_THRESHOLD = 1152000;
constexpr uint32_t ERISTA_DANGEROUS_GPU_THRESHOLD = 1151000;
constexpr uint32_t ERISTA_UNSAFE_GPU_THRESHOLD = 922000;
// RAM Types
const std::string RAM_TYPES[] = {
"Samsung AA-MGCL/MGCR",
"SK Hynix NEI/NEE/x267",
"Micron WT:B",
"Micron AUT:B",
"Micron WT:F",
"Samsung AM-MGCJ",
"Micron WT:E",
"Samsung AB-MGCL",
"SK Hynix NME",
"Samsung HB-MGCH"
};
// Fan curve profiles
namespace FanProfiles {
constexpr const char* V1_ERISTA = "V1_Erista";
constexpr const char* V2_MARIKO = "V2_Mariko";
constexpr const char* LITE_MARIKO = "Lite_Mariko";
constexpr const char* OLED_MARIKO = "OLED_Mariko";
}
// PSM (Battery) options
struct PSMOption {
const char* name;
uint32_t value;
};
constexpr PSMOption PSM_OPTIONS[] = {
{"1024mA", 0x400},
{"1280mA", 0x500},
{"1536mA", 0x600},
{"1660mA (Lite Default)", 0x67C},
{"1792mA", 0x700},
{"2048mA (Default)", 0x800},
{"2304mA (UNSAFE)", 0x900},
{"2560mA (UNSAFE)", 0xA00},
{"2816mA (DANGEROUS)", 0xB00},
{"3072mA (DANGEROUS)", 0xC00}
};
// Memory timing presets
struct TimingPreset {
uint32_t tRCD;
uint32_t tRP;
uint32_t tRAS;
uint32_t tRRD;
uint32_t tRFC;
uint32_t tRTW;
uint32_t tWTR;
uint32_t tREFI;
};
// Default timing preset
constexpr TimingPreset TIMING_DEFAULT = {0, 0, 0, 0, 0, 0, 0, 0};
// Samsung AA-MGCL/MGCR presets
constexpr TimingPreset TIMING_AAMGCL_CONSERVATIVE = {4, 4, 5, 5, 5, 5, 7, 6};
constexpr TimingPreset TIMING_AAMGCL_TIGHT = {4, 4, 8, 6, 5, 7, 8, 6};
// SK Hynix NEE presets
constexpr TimingPreset TIMING_NEE_CONSERVATIVE = {3, 3, 2, 2, 5, 5, 4, 6};
constexpr TimingPreset TIMING_NEE_TIGHT = {4, 4, 4, 3, 7, 6, 5, 6};
// Micron WT:B presets
constexpr TimingPreset TIMING_WTB_CONSERVATIVE = {4, 4, 5, 5, 2, 6, 5, 6};
constexpr TimingPreset TIMING_WTB_TIGHT = {6, 6, 7, 7, 2, 6, 5, 6};
// UI Constants
constexpr int MAX_VISIBLE_ITEMS = 20;
constexpr int MENU_START_Y = 7;
constexpr int SCREEN_WIDTH = 80;
constexpr int SCREEN_HEIGHT = 45;
}

View File

@@ -1,90 +0,0 @@
/*
* HOC Configurator - Default Values
* Copyright (C) Dominatorul, Souldbminer
*/
#pragma once
#include <cstdint>
class KipHandler;
class Defaults {
public:
template<typename T>
static void initDefaults(T& data) {
data.custRev = 0;
data.mtcConf = 0;
data.commonCpuBoostClock = 1785000;
data.commonEmcMemVolt = 1175000;
data.eristaCpuMaxVolt = 1235;
data.eristaEmcMaxClock = 1862400;
data.marikoCpuMaxVolt = 1120;
data.marikoEmcMaxClock = 1996800;
data.marikoEmcVddqVolt = 600000;
data.marikoCpuUV = 0;
data.marikoGpuUV = 0;
data.eristaCpuUV = 0;
data.eristaGpuUV = 0;
data.commonGpuVoltOffset = 0;
data.marikoEmcDvbShift = 0;
// Memory timings
data.t1_tRCD = 0;
data.t2_tRP = 0;
data.t3_tRAS = 0;
data.t4_tRRD = 0;
data.t5_tRFC = 0;
data.t6_tRTW = 0;
data.t7_tWTR = 0;
data.t8_tREFI = 0;
data.mem_burst_latency = 2;
// Additional voltages
data.marikoCpuVmin = 0;
data.eristaGpuVmin = 0;
data.marikoGpuVmin = 0;
data.marikoGpuVmax = 0;
// Initialize all GPU voltages to 600 (default safe value)
data.g_volt_76800 = 600;
data.g_volt_153600 = 600;
data.g_volt_230400 = 600;
data.g_volt_307200 = 600;
data.g_volt_384000 = 600;
data.g_volt_460800 = 600;
data.g_volt_537600 = 600;
data.g_volt_614400 = 600;
data.g_volt_691200 = 600;
data.g_volt_768000 = 600;
data.g_volt_844800 = 605;
data.g_volt_921600 = 635;
data.g_volt_998400 = 665;
data.g_volt_1075200 = 695;
data.g_volt_1152000 = 730;
data.g_volt_1228800 = 760;
data.g_volt_1267200 = 785;
data.g_volt_1305600 = 800;
data.g_volt_1344000 = 0;
data.g_volt_1382400 = 0;
data.g_volt_1420800 = 0;
data.g_volt_1459200 = 0;
data.g_volt_1497600 = 0;
data.g_volt_1536000 = 0;
// Erista GPU voltages
data.g_volt_e_76800 = 700;
data.g_volt_e_153600 = 700;
data.g_volt_e_230400 = 700;
data.g_volt_e_307200 = 700;
data.g_volt_e_384000 = 700;
data.g_volt_e_460800 = 700;
data.g_volt_e_537600 = 700;
data.g_volt_e_614400 = 700;
data.g_volt_e_691200 = 700;
data.g_volt_e_768000 = 700;
data.g_volt_e_844800 = 710;
data.g_volt_e_921600 = 740;
data.g_volt_e_998400 = 770;
data.g_volt_e_1075200 = 800;
}
};

View File

@@ -1,24 +0,0 @@
#pragma once
#include <string>
#include <map>
#include <vector>
class IniHandler {
private:
std::string iniPath;
std::map<std::string, std::map<std::string, std::string>> sections;
public:
IniHandler(const std::string& path);
bool load();
bool save();
void setValue(const std::string& section, const std::string& key, const std::string& value);
std::string getValue(const std::string& section, const std::string& key, const std::string& defaultValue = "");
void removeKey(const std::string& section, const std::string& key);
void removeSection(const std::string& section);
bool sectionExists(const std::string& section);
bool keyExists(const std::string& section, const std::string& key);
};

View File

@@ -1,119 +0,0 @@
/*
* HOC Configurator - KIP Handler
* Copyright (C) Dominatorul, Souldbminer
*/
#pragma once
#include <string>
#include <cstdint>
#include <vector>
#include "defaults.hpp"
class KipHandler {
private:
std::string kipPath;
const uint8_t MAGIC[4] = {'C', 'U', 'S', 'T'};
struct KipData {
uint32_t custRev;
uint32_t mtcConf;
uint32_t commonCpuBoostClock;
uint32_t commonEmcMemVolt;
uint32_t eristaCpuMaxVolt;
uint32_t eristaEmcMaxClock;
uint32_t marikoCpuMaxVolt;
uint32_t marikoEmcMaxClock;
uint32_t marikoEmcVddqVolt;
uint32_t marikoCpuUV;
uint32_t marikoGpuUV;
uint32_t eristaCpuUV;
uint32_t eristaGpuUV;
uint32_t commonGpuVoltOffset;
uint32_t marikoEmcDvbShift;
// Memory timings
uint32_t t1_tRCD;
uint32_t t2_tRP;
uint32_t t3_tRAS;
uint32_t t4_tRRD;
uint32_t t5_tRFC;
uint32_t t6_tRTW;
uint32_t t7_tWTR;
uint32_t t8_tREFI;
uint32_t mem_burst_latency;
// Additional voltages
uint32_t marikoCpuVmin;
uint32_t eristaGpuVmin;
uint32_t marikoGpuVmin;
uint32_t marikoGpuVmax;
// GPU voltages for each frequency (Mariko)
uint32_t g_volt_76800;
uint32_t g_volt_153600;
uint32_t g_volt_230400;
uint32_t g_volt_307200;
uint32_t g_volt_384000;
uint32_t g_volt_460800;
uint32_t g_volt_537600;
uint32_t g_volt_614400;
uint32_t g_volt_691200;
uint32_t g_volt_768000;
uint32_t g_volt_844800;
uint32_t g_volt_921600;
uint32_t g_volt_998400;
uint32_t g_volt_1075200;
uint32_t g_volt_1152000;
uint32_t g_volt_1228800;
uint32_t g_volt_1267200;
uint32_t g_volt_1305600;
uint32_t g_volt_1344000;
uint32_t g_volt_1382400;
uint32_t g_volt_1420800;
uint32_t g_volt_1459200;
uint32_t g_volt_1497600;
uint32_t g_volt_1536000;
// GPU voltages for each frequency (Erista)
uint32_t g_volt_e_76800;
uint32_t g_volt_e_153600;
uint32_t g_volt_e_230400;
uint32_t g_volt_e_307200;
uint32_t g_volt_e_384000;
uint32_t g_volt_e_460800;
uint32_t g_volt_e_537600;
uint32_t g_volt_e_614400;
uint32_t g_volt_e_691200;
uint32_t g_volt_e_768000;
uint32_t g_volt_e_844800;
uint32_t g_volt_e_921600;
uint32_t g_volt_e_998400;
uint32_t g_volt_e_1075200;
};
KipData data;
public:
KipHandler(const std::string& path) : kipPath(path) {
// Initialize with defaults
Defaults::initDefaults(data);
}
bool readKip();
bool writeKip();
// Getters
KipData& getData() { return data; }
const KipData& getData() const { return data; }
// Setters for common values
void setCommonCpuBoostClock(uint32_t val) { data.commonCpuBoostClock = val; }
void setCommonEmcMemVolt(uint32_t val) { data.commonEmcMemVolt = val; }
void setMarikoCpuMaxVolt(uint32_t val) { data.marikoCpuMaxVolt = val; }
void setMarikoEmcMaxClock(uint32_t val) { data.marikoEmcMaxClock = val; }
void setMarikoEmcVddqVolt(uint32_t val) { data.marikoEmcVddqVolt = val; }
// Utility
std::string getKipPath() const { return kipPath; }
void setKipPath(const std::string& path) { kipPath = path; }
};

View File

@@ -1,91 +0,0 @@
/*
* HOC Configurator - UI Handler
* Copyright (C) Dominatorul, Souldbminer
*/
#pragma once
#include <string>
#include <vector>
#include <functional>
#include <switch.h>
// Forward declarations
class KipHandler;
class ValueEditor;
enum class EditorType {
TOGGLE,
FREQUENCY,
VOLTAGE,
SLIDER,
LIST
};
enum class MenuState {
MAIN,
GPU,
CPU,
RAM,
MISC,
ABOUT,
SETTINGS
};
class UI {
private:
MenuState currentState;
int selectedIndex;
int scrollOffset;
std::string statusMessage;
std::string kipPath;
bool kipLoaded;
bool autoSave;
KipHandler* kipHandler;
ValueEditor* editor;
const int MAX_VISIBLE_ITEMS = 20;
void renderMainMenu();
void renderGPUMenu();
void renderCPUMenu();
void renderRAMMenu();
void renderMiscMenu();
void renderAboutMenu();
void renderSettingsMenu();
void handleMainMenuInput(u64 kDown);
void handleGPUMenuInput(u64 kDown);
void handleCPUMenuInput(u64 kDown);
void handleRAMMenuInput(u64 kDown);
void handleMiscMenuInput(u64 kDown);
void handleAboutMenuInput(u64 kDown);
void handleSettingsMenuInput(u64 kDown);
void drawHeader();
void drawFooter();
void drawMenuItem(const std::string& text, bool selected, int y);
void drawText(const std::string& text, int x, int y);
void showValueEditor(const std::string& title, EditorType type, int currentValue,
std::function<void(int)> callback,
const std::vector<std::string>& options = {},
int min = 0, int max = 100, int step = 1);
public:
UI();
~UI();
void render();
void handleInput(u64 kDown);
void setStatus(const std::string& msg) { statusMessage = msg; }
void setKipPath(const std::string& path) { kipPath = path; }
void setKipLoaded(bool loaded) { kipLoaded = loaded; }
void setAutoSave(bool enabled) { autoSave = enabled; }
void setKipHandler(KipHandler* handler) { kipHandler = handler; }
std::string getStatus() const { return statusMessage; }
std::string getKipPath() const { return kipPath; }
bool isKipLoaded() const { return kipLoaded; }
bool isAutoSaveEnabled() const { return autoSave; }
};

View File

@@ -1,43 +0,0 @@
/*
* HOC Configurator - Value Editor
* Copyright (C) Dominatorul, Souldbminer
*/
#pragma once
#include <string>
#include <vector>
#include <functional>
#include <switch.h>
#include "ui.hpp" // This includes EditorType
class KipHandler;
struct EditorConfig {
std::string title;
EditorType type;
int currentValue;
int minValue;
int maxValue;
int step;
std::vector<std::string> options;
std::function<void(int)> onValueChange;
};
class ValueEditor {
private:
EditorConfig config;
int selectedValue;
bool active;
public:
ValueEditor();
void show(const EditorConfig& cfg);
void hide();
bool isActive() const { return active; }
void handleInput(u64 kDown);
void render();
int getSelectedValue() const { return selectedValue; }
};

View File

@@ -1,59 +0,0 @@
/*
* HOC Configurator - Configuration Implementation
* Copyright (C) Dominatorul, Souldbminer
*/
#include "config.hpp"
#include <fstream>
#include <sys/stat.h>
Config::Config() {
kipPath = "sdmc:/atmosphere/kips/loader.kip";
autoSave = false;
}
bool Config::loadConfig() {
std::ifstream file("sdmc:/config/hoc-configurator/config.ini");
if (!file.is_open()) {
return false;
}
std::string line;
while (std::getline(file, line)) {
if (line.find("kip_path=") == 0) {
kipPath = line.substr(9);
} else if (line.find("auto_save=") == 0) {
autoSave = (line.substr(10) == "1");
}
}
file.close();
return true;
}
bool Config::saveConfig() {
// Create directory if it doesn't exist
mkdir("sdmc:/config", 0777);
mkdir("sdmc:/config/hoc-configurator", 0777);
std::ofstream file("sdmc:/config/hoc-configurator/config.ini");
if (!file.is_open()) {
return false;
}
file << "kip_path=" << kipPath << "\n";
file << "auto_save=" << (autoSave ? "1" : "0") << "\n";
file.close();
return true;
}
bool Config::checkKipExists() {
struct stat buffer;
return (stat(kipPath.c_str(), &buffer) == 0);
}
bool Config::checkAtmosphereExists() {
struct stat buffer;
return (stat("sdmc:/atmosphere", &buffer) == 0);
}

View File

@@ -1,24 +0,0 @@
#pragma once
#include <string>
#include <map>
#include <vector>
class IniHandler {
private:
std::string iniPath;
std::map<std::string, std::map<std::string, std::string>> sections;
public:
IniHandler(const std::string& path);
bool load();
bool save();
void setValue(const std::string& section, const std::string& key, const std::string& value);
std::string getValue(const std::string& section, const std::string& key, const std::string& defaultValue = "");
void removeKey(const std::string& section, const std::string& key);
void removeSection(const std::string& section);
bool sectionExists(const std::string& section);
bool keyExists(const std::string& section, const std::string& key);
};

View File

@@ -1,246 +0,0 @@
/*
* HOC Configurator - KIP Handler Implementation
* Copyright (C) Dominatorul, Souldbminer
*/
#include "kip_handler.hpp"
#include <fstream>
#include <cstring>
#include <vector>
bool KipHandler::readKip() {
std::ifstream file(kipPath, std::ios::binary);
if (!file.is_open()) {
return false;
}
// Read entire file
file.seekg(0, std::ios::end);
size_t fileSize = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<uint8_t> buffer(fileSize);
file.read(reinterpret_cast<char*>(buffer.data()), fileSize);
file.close();
// Find CUST magic
size_t magicPos = 0;
bool found = false;
for (size_t i = 0; i < fileSize - 4; i++) {
if (memcmp(&buffer[i], MAGIC, 4) == 0) {
magicPos = i + 4;
found = true;
break;
}
}
if (!found) {
return false;
}
// Read structure (assuming packed uint32_t structure)
size_t offset = magicPos;
auto readU32 = [&]() -> uint32_t {
uint32_t val;
memcpy(&val, &buffer[offset], sizeof(uint32_t));
offset += sizeof(uint32_t);
return val;
};
data.custRev = readU32();
data.mtcConf = readU32();
data.commonCpuBoostClock = readU32();
data.commonEmcMemVolt = readU32();
data.eristaCpuMaxVolt = readU32();
data.eristaEmcMaxClock = readU32();
data.marikoCpuMaxVolt = readU32();
data.marikoEmcMaxClock = readU32();
data.marikoEmcVddqVolt = readU32();
data.marikoCpuUV = readU32();
data.marikoGpuUV = readU32();
data.eristaCpuUV = readU32();
data.eristaGpuUV = readU32();
data.commonGpuVoltOffset = readU32();
data.marikoEmcDvbShift = readU32();
// Memory timings
data.t1_tRCD = readU32();
data.t2_tRP = readU32();
data.t3_tRAS = readU32();
data.t4_tRRD = readU32();
data.t5_tRFC = readU32();
data.t6_tRTW = readU32();
data.t7_tWTR = readU32();
data.t8_tREFI = readU32();
data.mem_burst_latency = readU32();
// Additional voltages
data.marikoCpuVmin = readU32();
data.eristaGpuVmin = readU32();
data.marikoGpuVmin = readU32();
data.marikoGpuVmax = readU32();
// GPU voltages Mariko
data.g_volt_76800 = readU32();
data.g_volt_153600 = readU32();
data.g_volt_230400 = readU32();
data.g_volt_307200 = readU32();
data.g_volt_384000 = readU32();
data.g_volt_460800 = readU32();
data.g_volt_537600 = readU32();
data.g_volt_614400 = readU32();
data.g_volt_691200 = readU32();
data.g_volt_768000 = readU32();
data.g_volt_844800 = readU32();
data.g_volt_921600 = readU32();
data.g_volt_998400 = readU32();
data.g_volt_1075200 = readU32();
data.g_volt_1152000 = readU32();
data.g_volt_1228800 = readU32();
data.g_volt_1267200 = readU32();
data.g_volt_1305600 = readU32();
data.g_volt_1344000 = readU32();
data.g_volt_1382400 = readU32();
data.g_volt_1420800 = readU32();
data.g_volt_1459200 = readU32();
data.g_volt_1497600 = readU32();
data.g_volt_1536000 = readU32();
// GPU voltages Erista
data.g_volt_e_76800 = readU32();
data.g_volt_e_153600 = readU32();
data.g_volt_e_230400 = readU32();
data.g_volt_e_307200 = readU32();
data.g_volt_e_384000 = readU32();
data.g_volt_e_460800 = readU32();
data.g_volt_e_537600 = readU32();
data.g_volt_e_614400 = readU32();
data.g_volt_e_691200 = readU32();
data.g_volt_e_768000 = readU32();
data.g_volt_e_844800 = readU32();
data.g_volt_e_921600 = readU32();
data.g_volt_e_998400 = readU32();
data.g_volt_e_1075200 = readU32();
return true;
}
bool KipHandler::writeKip() {
std::fstream file(kipPath, std::ios::in | std::ios::out | std::ios::binary);
if (!file.is_open()) {
return false;
}
// Read entire file
file.seekg(0, std::ios::end);
size_t fileSize = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<uint8_t> buffer(fileSize);
file.read(reinterpret_cast<char*>(buffer.data()), fileSize);
// Find CUST magic
size_t magicPos = 0;
bool found = false;
for (size_t i = 0; i < fileSize - 4; i++) {
if (memcmp(&buffer[i], MAGIC, 4) == 0) {
magicPos = i + 4;
found = true;
break;
}
}
if (!found) {
file.close();
return false;
}
// Write structure
size_t offset = magicPos;
auto writeU32 = [&](uint32_t val) {
memcpy(&buffer[offset], &val, sizeof(uint32_t));
offset += sizeof(uint32_t);
};
writeU32(data.custRev);
writeU32(data.mtcConf);
writeU32(data.commonCpuBoostClock);
writeU32(data.commonEmcMemVolt);
writeU32(data.eristaCpuMaxVolt);
writeU32(data.eristaEmcMaxClock);
writeU32(data.marikoCpuMaxVolt);
writeU32(data.marikoEmcMaxClock);
writeU32(data.marikoEmcVddqVolt);
writeU32(data.marikoCpuUV);
writeU32(data.marikoGpuUV);
writeU32(data.eristaCpuUV);
writeU32(data.eristaGpuUV);
writeU32(data.commonGpuVoltOffset);
writeU32(data.marikoEmcDvbShift);
// Memory timings
writeU32(data.t1_tRCD);
writeU32(data.t2_tRP);
writeU32(data.t3_tRAS);
writeU32(data.t4_tRRD);
writeU32(data.t5_tRFC);
writeU32(data.t6_tRTW);
writeU32(data.t7_tWTR);
writeU32(data.t8_tREFI);
writeU32(data.mem_burst_latency);
// Additional voltages
writeU32(data.marikoCpuVmin);
writeU32(data.eristaGpuVmin);
writeU32(data.marikoGpuVmin);
writeU32(data.marikoGpuVmax);
// GPU voltages Mariko
writeU32(data.g_volt_76800);
writeU32(data.g_volt_153600);
writeU32(data.g_volt_230400);
writeU32(data.g_volt_307200);
writeU32(data.g_volt_384000);
writeU32(data.g_volt_460800);
writeU32(data.g_volt_537600);
writeU32(data.g_volt_614400);
writeU32(data.g_volt_691200);
writeU32(data.g_volt_768000);
writeU32(data.g_volt_844800);
writeU32(data.g_volt_921600);
writeU32(data.g_volt_998400);
writeU32(data.g_volt_1075200);
writeU32(data.g_volt_1152000);
writeU32(data.g_volt_1228800);
writeU32(data.g_volt_1267200);
writeU32(data.g_volt_1305600);
writeU32(data.g_volt_1344000);
writeU32(data.g_volt_1382400);
writeU32(data.g_volt_1420800);
writeU32(data.g_volt_1459200);
writeU32(data.g_volt_1497600);
writeU32(data.g_volt_1536000);
// GPU voltages Erista
writeU32(data.g_volt_e_76800);
writeU32(data.g_volt_e_153600);
writeU32(data.g_volt_e_230400);
writeU32(data.g_volt_e_307200);
writeU32(data.g_volt_e_384000);
writeU32(data.g_volt_e_460800);
writeU32(data.g_volt_e_537600);
writeU32(data.g_volt_e_614400);
writeU32(data.g_volt_e_691200);
writeU32(data.g_volt_e_768000);
writeU32(data.g_volt_e_844800);
writeU32(data.g_volt_e_921600);
writeU32(data.g_volt_e_998400);
writeU32(data.g_volt_e_1075200);
// Write back to file
file.seekp(0, std::ios::beg);
file.write(reinterpret_cast<char*>(buffer.data()), fileSize);
file.close();
return true;
}

View File

@@ -1,108 +0,0 @@
/*
* HOC Configurator - Nintendo Switch Homebrew
* Copyright (C) Dominatorul, Souldbminer
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*/
#include <switch.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <algorithm>
#include "kip_handler.hpp"
#include "ui.hpp"
#include "config.hpp"
#include "defaults.hpp"
int main(int argc, char* argv[]) {
// Initialize services
socketInitializeDefault();
nxlinkStdio();
consoleInit(NULL);
// Configure input
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
PadState pad;
padInitializeDefault(&pad);
// Initialize configuration
Config config;
config.loadConfig();
// Initialize KIP handler
KipHandler* kipHandler = new KipHandler(config.kipPath);
// Initialize UI
UI ui;
ui.setKipPath(config.kipPath);
ui.setKipHandler(kipHandler);
ui.setAutoSave(config.autoSave);
// Check if KIP exists and load it
if (config.checkKipExists()) {
if (kipHandler->readKip()) {
ui.setStatus("KIP loaded successfully from " + config.kipPath);
ui.setKipLoaded(true);
} else {
ui.setStatus("ERROR: Failed to parse KIP file!");
ui.setKipLoaded(false);
}
} else if (config.checkAtmosphereExists()) {
ui.setStatus("Atmosphere found, but KIP not found at: " + config.kipPath);
ui.setKipLoaded(false);
} else {
ui.setStatus("ERROR: Atmosphere not detected! Is your SD card mounted?");
ui.setKipLoaded(false);
}
bool running = true;
u64 kDownOld = 0;
int frameCounter = 0;
const int FRAME_DELAY = 3; // Add input delay for better responsiveness
while (running && appletMainLoop()) {
padUpdate(&pad);
u64 kDown = padGetButtonsDown(&pad);
// Exit on Plus button
if (kDown & HidNpadButton_Plus) {
running = false;
break;
}
// Process input with debouncing and frame delay
if (kDown && kDown != kDownOld && frameCounter >= FRAME_DELAY) {
ui.handleInput(kDown);
frameCounter = 0;
}
// Render UI
ui.render();
consoleUpdate(NULL);
kDownOld = kDown;
frameCounter++;
// Frame limiter - 30 FPS
svcSleepThread(33333333); // ~33ms
}
// Save config before exit
config.autoSave = ui.isAutoSaveEnabled();
config.kipPath = ui.getKipPath();
config.saveConfig();
// Cleanup
delete kipHandler;
consoleExit(NULL);
socketExit();
return 0;
}

Some files were not shown because too many files have changed in this diff Show More