
GoSDC Raw API
-------------

Quick and dirty description of the GoSDC Raw API :

X = low byte of info block address
Y = high byte of info block address

LINK !#FF98

Info block :

+0 = total size of info block (input), derive from descriptions below
+1 = total size of info block (output), derive from descriptions below
+2 = reason code (1,2 or 3 currently)
+3 = reason subcode (depends on reason code)
+4 = must be 1
+5 = reserved, must be 0
+6 onwards depends on reason code and subcode

All reason codes :

+4 on exit is 0 if call was recognized, or 1 if not

Reason code 1 ('return value') :

- Subcode 2 (read flash card size) :

  +6 on exit contains card size in bytes (4 bytes)

- Subcode 3 (read address of last opened file) :

  +6 on exit contains absolute card address (4 bytes)

- Subcode 4 (read size of last opened file) :

  +6 on exit contains file size in bytes (4 bytes)

- Subcode 9 (read flash card type) :

  +6 on exit contains flash card type code (1 byte, 0/1/2/#FF for MMC/SD/SDHC/none)

Reason code 2 ('execute command') :

- Subcode 9/10 (issue flash card CMD9/10, see flash card (SPI mode) low level
  documentation) :

  +5 on exit contains internal error code, or 0 if all ok
  +6 on exit contains info (19 bytes) :

    +0  - command response byte
    +1  - 16 bytes info
    +17 - 2 bytes CRC

Reason code 3 ('raw access') :

Provides raw bulk access to the flash card (don't use unless you know exactly
what you're doing and accept the risk of corrupting all flash card contents).

- Subcode contains flags :

  bit 0  - read (0) or write (1)
  bit 6  - card address is (last opened) file relative (0) or absolute (1)
  others - for internal use (any input values are ignored)

  +6  on entry contains 4-byte memory address
  +10 on entry contains 4-byte card address
  +14 on entry contains 3-byte size in bytes

  +5 on exit contains internal error code, or 0 if all ok


