Skip to content

Instantly share code, notes, and snippets.

@startergo
Last active October 23, 2023 14:52
Show Gist options
  • Save startergo/ebd22628a755495a640e12298ce6427d to your computer and use it in GitHub Desktop.
Save startergo/ebd22628a755495a640e12298ce6427d to your computer and use it in GitHub Desktop.
Extract PowerPlay table and convert to SSDT format

Download and cd to upp

git clone https://github.com/sibradzic/upp.git && cd upp
python3 setup.py build
sudo python3 setup.py install

Install the click table:

sudo python3 -m pip install click
upp --pp-file=extracted.pp_table extract -r AMD.RX6900XT.16384.201104.rom
thefile=/Users/mbp114/Downloads/upp-0.1.3/extracted.pp_table \
printf  "\tPP_PhmSoftWTTable,\n\t\tBuffer (0x%X)\n\t\t{\n" $(stat -f %z "$thefile")
xxd -u -g 1 < "$thefile" | \
perl -nE '
	if ( m|^0000([0-9A-Za-z]+): (([0-9A-Z]{2} )+)( +)(.*)| ) {
		$o = $1; $b = $2; $s = $4; $c = $5;
		print "\t\t\t/* " . (uc $o) . " */  " . $b =~ s/(..) /0x$1, /gr . $s =~ s/   /      /gr . "// " . $c . "\n"
	}
'
printf  "\t\t},\n"
@klich3
Copy link

klich3 commented Oct 23, 2023

Hi there, here you have a little aportation las block script same script but written in Shell

#!/bin/bash

thefile="./extracted.pp_table"

file_size=$(stat -f %z "$thefile")

printf "\tPP_PhmSoftWTTable,\n\t\tBuffer (0x%X)\n\t\t{\n" "$file_size"

while IFS= read -r line; do
    if [[ $line =~ ^0000([0-9A-Za-z]+):\ (([0-9A-Z]{2}\ )+)(\ +)(.*) ]]; then
        o=${BASH_REMATCH[1]}
        b=${BASH_REMATCH[2]}
        s=${BASH_REMATCH[4]}
        c=${BASH_REMATCH[5]}
        b=$(echo "$b" | sed 's/.. /0x&, /g')
        s=$(echo "$s" | sed 's/   /      /g')
        printf "\t\t\t/* %s */  %s// %s\n" "$(echo "$o" | tr 'a-f' 'A-F')" "$b" "$c"
    fi
done < <(xxd -u -g 1 < "$thefile")

printf "\t\t},\n"

@klich3
Copy link

klich3 commented Oct 23, 2023

After run command sudo python3 setup.py install it's need run this one sudo python3 -m pip install click for correct decode ROM.
Regards.

@startergo
Copy link
Author

Updated for the click table. Thanks for the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment