Skip to content

Instantly share code, notes, and snippets.

View patrickschur's full-sized avatar

Patrick Schur patrickschur

View GitHub Profile
import os
import struct
SMN_INDEX_REG = 0x60
SMN_DATA_REG = 0x64
SMN_MSG_REG = 0x3b10a20
SMN_RSP_REG = 0x3b10a80
SMN_ARG_REG = 0x3b10a88
@patrickschur
patrickschur / pmtable.py
Last active August 28, 2023 17:25
Reads the PMTable on Cezanne
import os
import struct
import sys
SMN_INDEX_REG = 0x60
SMN_DATA_REG = 0x64
SMN_MSG_REG = 0x3b10a20
SMN_RSP_REG = 0x3b10a80
SMN_ARG_REG = 0x3b10a88
@patrickschur
patrickschur / agesa.py
Created March 30, 2021 22:38
Reads the AGESA version from an UEFI image
#!/usr/bin/python3
import lzma
import sys
with open(sys.argv[1], "rb") as f:
image = f.read()
offset = image.find(b"\x93\xFD\x21\x9E\x72\x9C\x15\x4C\x8C\x4B\xE7\x7F\x1D\xB2\xD7\x92") + 0x30
CHUNK_SIZE = 2048
@patrickschur
patrickschur / spi.py
Created March 30, 2021 21:58
Reads the SPI flash memory via SMN space
#!/usr/bin/python3
import struct
import io
import sys
import os
IOHC_NB_SMN_INDEX_REG = 0xC4
config = os.open("/sys/devices/pci0000:00/0000:00:00.0/config", os.O_RDWR)