psptool 3.4__tar.gz → 3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {psptool-3.4 → psptool-3.6}/.github/workflows/publish.yml +9 -7
  2. psptool-3.6/.github/workflows/python-tests.yml +136 -0
  3. {psptool-3.4 → psptool-3.6}/PKG-INFO +1 -1
  4. {psptool-3.4 → psptool-3.6}/psptool/directory.py +20 -3
  5. {psptool-3.4 → psptool-3.6}/psptool/file.py +1 -4
  6. {psptool-3.4 → psptool-3.6}/tests/gha_metrics.py +3 -1
  7. psptool-3.4/.github/workflows/gha-metrics.yml +0 -34
  8. psptool-3.4/.github/workflows/python-tests.yml +0 -37
  9. {psptool-3.4 → psptool-3.6}/.gitignore +0 -0
  10. {psptool-3.4 → psptool-3.6}/.gitmodules +0 -0
  11. {psptool-3.4 → psptool-3.6}/LICENSE +0 -0
  12. {psptool-3.4 → psptool-3.6}/README.md +0 -0
  13. {psptool-3.4 → psptool-3.6}/psptool/__init__.py +0 -0
  14. {psptool-3.4 → psptool-3.6}/psptool/__main__.py +0 -0
  15. {psptool-3.4 → psptool-3.6}/psptool/blob.py +0 -0
  16. {psptool-3.4 → psptool-3.6}/psptool/cert_tree.py +0 -0
  17. {psptool-3.4 → psptool-3.6}/psptool/crypto.py +0 -0
  18. {psptool-3.4 → psptool-3.6}/psptool/entry.py +0 -0
  19. {psptool-3.4 → psptool-3.6}/psptool/errors.py +0 -0
  20. {psptool-3.4 → psptool-3.6}/psptool/fet.py +0 -0
  21. {psptool-3.4 → psptool-3.6}/psptool/firmware.py +0 -0
  22. {psptool-3.4 → psptool-3.6}/psptool/header_file.py +0 -0
  23. {psptool-3.4 → psptool-3.6}/psptool/key_store_file.py +0 -0
  24. {psptool-3.4 → psptool-3.6}/psptool/microcode_file.py +0 -0
  25. {psptool-3.4 → psptool-3.6}/psptool/psptool.py +0 -0
  26. {psptool-3.4 → psptool-3.6}/psptool/pubkey_file.py +0 -0
  27. {psptool-3.4 → psptool-3.6}/psptool/rom.py +0 -0
  28. {psptool-3.4 → psptool-3.6}/psptool/utils.py +0 -0
  29. {psptool-3.4 → psptool-3.6}/pyproject.toml +0 -0
  30. {psptool-3.4 → psptool-3.6}/tests/__init__.py +0 -0
  31. {psptool-3.4 → psptool-3.6}/tests/create_metrics.sh +0 -0
  32. {psptool-3.4 → psptool-3.6}/tests/integration/__init__.py +0 -0
  33. {psptool-3.4 → psptool-3.6}/tests/integration/test_psptrace.py +0 -0
  34. {psptool-3.4 → psptool-3.6}/tests/integration/test_rom_files.py +0 -0
  35. {psptool-3.4 → psptool-3.6}/tests/metrics.txt +0 -0
  36. {psptool-3.4 → psptool-3.6}/tests/unit/__init__.py +0 -0
  37. {psptool-3.4 → psptool-3.6}/tests/unit/test_cli.py +0 -0
@@ -1,20 +1,22 @@
1
1
  name: Publish Python distribution to PyPI and TestPyPI
2
2
 
3
- on: push
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
4
7
 
5
8
  jobs:
6
9
  build:
7
10
  name: Build distribution
8
11
  runs-on: ubuntu-latest
9
-
10
12
  steps:
11
- - uses: actions/checkout@v4
13
+ - uses: actions/checkout@v6
12
14
  with:
13
15
  persist-credentials: false
14
16
  - name: Set up Python
15
- uses: actions/setup-python@v5
17
+ uses: actions/setup-python@v6
16
18
  with:
17
- python-version: "3.11"
19
+ python-version: "3.14"
18
20
  - name: Install pypa/build
19
21
  run: >-
20
22
  python3 -m
@@ -24,7 +26,7 @@ jobs:
24
26
  - name: Build a binary wheel and a source tarball
25
27
  run: python3 -m build
26
28
  - name: Store the distribution packages
27
- uses: actions/upload-artifact@v4
29
+ uses: actions/upload-artifact@v7
28
30
  with:
29
31
  name: python-package-distributions
30
32
  path: dist/
@@ -43,7 +45,7 @@ jobs:
43
45
  id-token: write # important for trusted publishing
44
46
  steps:
45
47
  - name: Download all the dists
46
- uses: actions/download-artifact@v4
48
+ uses: actions/download-artifact@v8
47
49
  with:
48
50
  name: python-package-distributions
49
51
  path: dist/
@@ -0,0 +1,136 @@
1
+ name: Python tests
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request_target:
7
+
8
+ jobs:
9
+ get-fixtures:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Get fixtures
13
+ uses: actions/checkout@v6
14
+ with:
15
+ submodules: recursive
16
+ ssh-key: ${{ secrets.PSPTOOL_FIXTURES_NEW_PRIVATE_KEY }}
17
+
18
+ - name: Save fixtures
19
+ uses: actions/upload-artifact@v7
20
+ with:
21
+ name: saved-fixtures
22
+ path: tests/integration/fixtures
23
+ retention-days: 1
24
+
25
+ test:
26
+ needs: get-fixtures
27
+ runs-on: ubuntu-latest
28
+ permissions:
29
+ contents: read
30
+ strategy:
31
+ matrix:
32
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
33
+
34
+ steps:
35
+ - name: Checkout PR
36
+ uses: actions/checkout@v6
37
+ with:
38
+ ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
39
+
40
+ - name: Download fixtures
41
+ uses: actions/download-artifact@v8
42
+ with:
43
+ name: saved-fixtures
44
+ path: tests/integration/fixtures
45
+
46
+ - name: Set up Python ${{ matrix.python-version }}
47
+ uses: actions/setup-python@v6
48
+ with:
49
+ python-version: ${{ matrix.python-version }}
50
+ cache: 'pip'
51
+
52
+ - name: Install dependencies
53
+ run: |
54
+ python -m pip install --upgrade pip
55
+ pip install flake8
56
+ pip install psptrace # for integration tests
57
+ pip install .
58
+
59
+ - name: Lint with flake8
60
+ run: |
61
+ # stop the build if there are Python syntax errors or undefined names
62
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
63
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
64
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
65
+ - name: Test with unittest
66
+ run: |
67
+ python -m unittest discover -s tests -v
68
+
69
+ create-metrics:
70
+ runs-on: ubuntu-latest
71
+ needs: get-fixtures
72
+ permissions:
73
+ contents: read
74
+ steps:
75
+ - name: Checkout PR
76
+ uses: actions/checkout@v6
77
+ with:
78
+ ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
79
+
80
+ - name: Download fixtures
81
+ uses: actions/download-artifact@v8
82
+ with:
83
+ name: saved-fixtures
84
+ path: tests/integration/fixtures
85
+
86
+ - name: Set up Python
87
+ uses: actions/setup-python@v6
88
+ with:
89
+ python-version: "3.14"
90
+ cache: 'pip'
91
+
92
+ - name: Install dependencies
93
+ run: |
94
+ python -m pip install --upgrade pip
95
+ pip install .
96
+
97
+ - name: Create Metrics
98
+ run: |
99
+ python tests/gha_metrics.py > metrics.md
100
+ cat metrics.md >> $GITHUB_STEP_SUMMARY
101
+
102
+ - name: Upload metrics
103
+ if: github.event_name == 'pull_request_target'
104
+ uses: actions/upload-artifact@v7
105
+ with:
106
+ name: metrics-data
107
+ path: metrics.md
108
+
109
+ comment-metrics:
110
+ if: github.event_name == 'pull_request_target'
111
+ runs-on: ubuntu-latest
112
+ needs: create-metrics
113
+ permissions:
114
+ pull-requests: write
115
+ actions: read
116
+ steps:
117
+ - name: Download metrics
118
+ uses: actions/download-artifact@v8
119
+ with:
120
+ name: metrics-data
121
+
122
+ - name: find comment
123
+ uses: peter-evans/find-comment@v4
124
+ id: fc
125
+ with:
126
+ issue-number: ${{ github.event.pull_request.number }}
127
+ comment-author: 'github-actions[bot]'
128
+ body-includes: '<!-- PSPTOOL-METRICS-MARKER -->'
129
+
130
+ - name: create or update comment
131
+ uses: peter-evans/create-or-update-comment@v5
132
+ with:
133
+ comment-id: ${{ steps.fc.outputs.comment-id }}
134
+ issue-number: ${{ github.event.pull_request.number }}
135
+ body-path: metrics.md
136
+ edit-mode: replace
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: psptool
3
- Version: 3.4
3
+ Version: 3.6
4
4
  Summary: PSPTool is a tool for dealing with AMD binary blobs
5
5
  Author-email: Christian Werling <cwerling@posteo.de>
6
6
  License-File: LICENSE
@@ -216,9 +216,26 @@ class Directory(NestedBuffer):
216
216
 
217
217
  # 2. Update fields
218
218
  entry.type = type_
219
- entry.size = size
220
- entry.offset = offset
221
- # todo: allow updating the address_mode which consists of two bytes right here
219
+ if entry.type not in File.NO_SIZE_ENTRY_TYPES:
220
+ entry.size = size
221
+
222
+ # Convert the ROM buffer offset back to the value the entry expects, preserving address mode.
223
+ # This mirrors the inverse of file_offset() in entry.py.
224
+ addr_mode = self.address_mode
225
+ if addr_mode == 2 or addr_mode == 3:
226
+ addr_mode = entry.address_mode
227
+
228
+ if addr_mode == 0:
229
+ # x86 physical: preserve upper bits (e.g. 0xFF000000), replace lower bits
230
+ addr_mask = self.rom.addr_mask
231
+ upper_mask = 0xFFFFFFFF ^ addr_mask
232
+ entry.offset = (entry.offset & upper_mask) | (offset & addr_mask)
233
+ elif addr_mode == 1:
234
+ entry.offset = offset
235
+ elif addr_mode == 2 or addr_mode == 3:
236
+ entry.offset = offset - self.buffer_offset
237
+ else:
238
+ entry.offset = offset
222
239
 
223
240
  # 3. Update checksum
224
241
  self.update_checksum()
@@ -146,7 +146,7 @@ class File(NestedBuffer):
146
146
  0x59: 'DMCU_ISR',
147
147
  0x5a: 'MSMU_BINARY_0',
148
148
  0x5b: 'MSMU_BINARY_1',
149
- 0x5c: 'WMOS',
149
+ 0x5c: 'SPI_ROM_CONFIG',
150
150
  0x5d: 'MPIO_FW',
151
151
  0x5e: 'DF_TOPOLOGY',
152
152
  0x5f: 'FW_PSP_SMUSCS_OR_TPMLITE',
@@ -248,9 +248,6 @@ class File(NestedBuffer):
248
248
 
249
249
  @classmethod
250
250
  def from_entry(cls, parent_directory, parent_buffer, entry, blob, psptool):
251
- if entry.type in cls.NO_SIZE_ENTRY_TYPES:
252
- entry.size = 0
253
-
254
251
  assert entry.file_offset() < len(parent_directory.rom), "File offset overflows ROM bounds!"
255
252
  file_args = [parent_directory, parent_buffer, entry.file_offset(), entry, blob, psptool]
256
253
 
@@ -77,4 +77,6 @@ if failed_files:
77
77
  for file in failed_files:
78
78
  print(f"- `{file}`")
79
79
  else:
80
- print("*All files parsed successfully!*")
80
+ print("*All files parsed successfully!*")
81
+
82
+ print("<!-- PSPTOOL-METRICS-MARKER -->")
@@ -1,34 +0,0 @@
1
- name: Post metrics comment
2
-
3
- on: [pull_request_target]
4
-
5
- jobs:
6
- test:
7
-
8
- runs-on: ubuntu-latest
9
- strategy:
10
- matrix:
11
- python-version: ["3.9"]
12
-
13
- steps:
14
- - uses: actions/checkout@v3
15
- with:
16
- ref: ${{ github.event.pull_request.head.sha }}
17
- submodules: recursive
18
- ssh-key: ${{ secrets.PSPTOOL_FIXTURES_NEW_PRIVATE_KEY }}
19
- - name: Set up Python ${{ matrix.python-version }}
20
- uses: actions/setup-python@v3
21
- with:
22
- python-version: ${{ matrix.python-version }}
23
- - name: Install dependencies
24
- run: |
25
- python -m pip install --upgrade pip
26
- pip install .
27
- - name: Run metrics and post comment
28
- run: |
29
- python tests/gha_metrics.py > metrics.md
30
- gh pr comment $PRNUM --body-file metrics.md
31
- env:
32
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33
- GH_REPO: ${{ github.repository }}
34
- PRNUM: ${{ github.event.pull_request.number }}
@@ -1,37 +0,0 @@
1
- name: Python tests
2
-
3
- on: [push, pull_request_target]
4
-
5
- jobs:
6
- test:
7
-
8
- runs-on: ubuntu-latest
9
- strategy:
10
- matrix:
11
- python-version: ["3.8", "3.9"]
12
-
13
- steps:
14
- - uses: actions/checkout@v3
15
- with:
16
- ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
17
- submodules: recursive
18
- ssh-key: ${{ secrets.PSPTOOL_FIXTURES_NEW_PRIVATE_KEY }}
19
- - name: Set up Python ${{ matrix.python-version }}
20
- uses: actions/setup-python@v3
21
- with:
22
- python-version: ${{ matrix.python-version }}
23
- - name: Install dependencies
24
- run: |
25
- python -m pip install --upgrade pip
26
- pip install flake8
27
- pip install psptrace # for integration tests
28
- pip install .
29
- - name: Lint with flake8
30
- run: |
31
- # stop the build if there are Python syntax errors or undefined names
32
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
33
- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
34
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35
- - name: Test with unittest
36
- run: |
37
- python -m unittest discover -s tests -v
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes