Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XBDM hack is slow #13

Open
JayFoxRox opened this issue Jun 30, 2018 · 0 comments
Open

XBDM hack is slow #13

JayFoxRox opened this issue Jun 30, 2018 · 0 comments

Comments

@JayFoxRox
Copy link
Member

JayFoxRox commented Jun 30, 2018

Current code (eb69c7fba9cdd1bb1e81eec60f4fed4394a42c67):

def xbdm_hack(address, operation, data=0):
  SetMem(hack_bank, struct.pack("<III", address, operation, data))
  xbdm_command("resume thread=0x" + format(hack_bank, 'X'))
  return GetMem(hack_bank + 8, 4)

(Also see xbdm-hack.md for more information)

Here is what the hack does for reads and writes:

Reads

def xbdm_read_8(address):
  return xbdm_hack(address, 1)
  1. xbdm_hack will call SetMem, which is the first communication with Xbox, to setup the next step
  2. xbdm_hack will call xbdm_command which is another communiation with Xbox
  3. xbdm_hack will readback the result which is another communication with Xbox

That is 3 back-and-forth transfers for a single read.

Writes

def xbdm_write_8(address, data):
  xbdm_hack(address, 4, int.from_bytes(data, byteorder='little', signed=False))
  1. xbdm_hack will call SetMem, which is the first communication with Xbox, to setup the next step
  2. xbdm_hack will call xbdm_command which is another communiation with Xbox
  3. xbdm_hack will readback the result which is another communication with Xbox, even if it isn't returned from xbdm_write.

That is 3 back-and-forth transfers for a single read, with one of them being completly useless.
There's various ways to optimize it.

Calls

def xbdm_call(address, stack):
  assert(len(stack) < 64)
  SetMem(hack_bank + 12, stack)
  return xbdm_hack(address, 7, len(stack))
  1. xbdm_call will call SetMem, which is the first communication with Xbox
  2. xbdm_hack will call SetMem, which is the more communication with Xbox, to setup the next step
  3. xbdm_hack will call xbdm_command which is another communiation with Xbox
  4. xbdm_hack will readback the result which is another communication with Xbox

Ideally we'd pass all optional input data in the xbdm_hack request, and return all optional output data in the response.
Maybe we should also allow packing of commands, simply to avoid XBDM command processing overhead.

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

No branches or pull requests

1 participant