PSPReverse / PSPEmu

PSP emulator
GNU General Public License v3.0
86 stars 11 forks source link

Psp test device #3

Closed hnj2 closed 4 years ago

hnj2 commented 4 years ago

This is a test device which adds access to stdio and an exit capability as a MMIO device to the emulator.

hnj2 commented 4 years ago

Okay, found the error: the mmio region was already taken. Moved it to 0x3000000

hnj2 commented 4 years ago

And for some reason I couldn't figure out it still didn't work. But now with 0x03133700 as base address it works.

AlexanderEichner commented 4 years ago

Please open a separate pull request for the openssl thing because it isn't specific to the test device implementation.

hnj2 commented 4 years ago

Please open a separate pull request for the openssl thing because it isn't specific to the test device implementation.

Sure.

Is the memory range 0x03133700 to 0x03133710 okay?

hnj2 commented 4 years ago

Here is a little test program that uses the device to echo stdin back to stdout and quits the emulator with exit code 137 if a q is entered.

.section .text

. = 0x100

echo:
// read avail register
  ldr r1, =avail_reg
  ldr r1, [r1]
  ldr r1, [r1]
  cmp r1, #0
  beq echo
// read byte
  ldr r1, =read_reg
  ldr r1, [r1]
  ldr r0, [r1]
// print r0
  ldr r1, =write_reg
  ldr r1, [r1]
  str r0, [r1]
// continue untill printed char was a 'q'
  cmp r0, #'q'
  bne echo

quit:
// should make the emulator quit with exit code 137 = (68 << 1) | 1
  ldr r0, =#68
  ldr r1, =quit_reg
  ldr r1, [r1]
  str r0, [r1]

avail_reg:
  .word 0x03133700
read_reg:
  .word 0x03133704
write_reg:
  .word 0x03133708
quit_reg:
  .word 0x0313370c
AlexanderEichner commented 4 years ago

Merged, thanks!