Skip to content

Instantly share code, notes, and snippets.

@hh1599
Created September 27, 2022 16:34
Show Gist options
  • Save hh1599/c8d6c7ffca6089eb9498e4cbace2f3a2 to your computer and use it in GitHub Desktop.
Save hh1599/c8d6c7ffca6089eb9498e4cbace2f3a2 to your computer and use it in GitHub Desktop.
modified scan.py
import os
import struct
SMN_INDEX_REG = 0x60
SMN_DATA_REG = 0x64
SMN_MSG_REG = 0x3b10a20
SMN_RSP_REG = 0x3b10a80
SMN_ARG_REG = 0x3b10a88
SMN_STATUS_OK = 1
SKIP_COMMANDS = []
config = os.open('/sys/devices/pci0000:00/0000:00:00.0/config', os.O_RDWR)
def smn_read(address):
os.pwrite(config, struct.pack('I', address), SMN_INDEX_REG)
return struct.unpack('I', os.pread(config, 4, SMN_DATA_REG))[0]
def smn_write(address, data):
os.pwrite(config, struct.pack('I', address), SMN_INDEX_REG)
os.pwrite(config, struct.pack('I', data), SMN_DATA_REG)
def smn_send_msg(msg, *args):
status = 0
smn_write(SMN_RSP_REG, status)
for j, arg in enumerate(args):
smn_write(SMN_ARG_REG + (j << 2), arg)
smn_write(SMN_MSG_REG, msg)
while (status := smn_read(SMN_RSP_REG)) == 0:
pass
if status != SMN_STATUS_OK:
return [status]
return [smn_read(SMN_ARG_REG + (k << 2)) for k in range(5)]
for i in range(1, 192):
if i not in SKIP_COMMANDS:
r = [hex(v) for v in smn_send_msg(i, 0, 0)]
out = open('out.txt','a')
out.write(f'{i:02x}: {r}')
out.write("\n")
out.close()
os.close(config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment