Advertisement
atreyu187

Dreamcast Guides : System Calls

Jan 4th, 2013
3,216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.19 KB | None | 0 0
  1. The Dreamcast ROM does not offer much in terms of system calls for applications to use. If fact, the few that are available are not even executed from the ROM, but reside in the RAM area 8C000000-8C007FFF together with the default exception and interrupt handlers. Any functionality not provided by these syscalls (graphics/sound/whatnot) must be performed by the application itself banging the hardware. The official devkit provides link libraries to perform these duties.
  2.  
  3.  
  4. Each system call is performed via an indirect vector. This means that rather than calling a fixed address, a function pointer is fetched from the fixed address and the call goes through this pointer. For each vector there is a number of different functions available, selected by register r7. Sometimes there is also a superfunction to be selected by register r6. Any arguments to the syscall is passed in registers r4 and r5 (and r6, if it is not used to select superfunction) as in a normal function call. The ROMFONT syscalls are a bit peculiar by using r1 instead of r7 to select function.
  5.  
  6.  
  7.  
  8. This is a list of all known system calls. They are sorted first by vector, and then by (superfunction and) function code. Detailed descriptions follow below. (The names selected for the syscalls below are totally arbitrary, and is only intended as a mnemonic for the function of the call.)
  9.  
  10. Vector 8C0000B0 - System information functions
  11. r7=0 - SYSINFO_INIT
  12. r7=1 - not a valid syscall
  13. r7=2 - SYSINFO_ICON
  14. r7=3 - SYSINFO_ID
  15. Vector 8C0000B4 - Boot-ROM font functions
  16. r1=0 - ROMFONT_ADDRESS
  17. r1=1 - ROMFONT_LOCK
  18. r1=2 - ROMFONT_UNLOCK
  19. Vector 8C0000B8 - Flash ROM functions
  20. r7=0 - FLASHROM_INFO
  21. r7=1 - FLASHROM_READ
  22. r7=2 - FLASHROM_WRITE
  23. r7=3 - FLASHROM_DELETE
  24. Vector 8C0000BC - MISC/GDROM functions
  25. r6=-1 - MISC superfunction
  26. r7=0 - MISC_INIT
  27. r7=1 - MISC_SETVECTOR
  28. r6=0 - GDROM superfunction
  29. r7=0 - GDROM_SEND_COMMAND
  30. r7=1 - GDROM_CHECK_COMMAND
  31. r7=2 - GDROM_MAINLOOP
  32. r7=3 - GDROM_INIT
  33. r7=4 - GDROM_CHECK_DRIVE
  34. r7=5 - GDROM_?DMA?
  35. r7=6 - GDROM_?DMA?
  36. r7=7 - GDROM_?DMA?
  37. r7=8 - GDROM_ABORT_COMMAND
  38. r7=9 - GDROM_RESET
  39. r7=10 - GDROM_SECTOR_MODE
  40. r7=11 - GDROM_?
  41. r7=12 - GDROM_?
  42. r7=13 - GDROM_?
  43. r7=14-15 - not implemented
  44. r6=1-7 - user defined superfunctions
  45.  
  46.  
  47. SYSINFO_INIT (r7=0)
  48. Prepares the other two SYSINFO calls for use by copying the relevant data from the system flashrom into 8C000068-8C00007F. Always call this function before using the other two calls.
  49.  
  50. Args: none
  51.  
  52. Returns: zero
  53.  
  54. SYSINFO_ICON (r7=2)
  55. Read an icon from the flashrom. The format those icons are in is not known. SYSINFO_INIT must have been called first.
  56.  
  57. Args:
  58.  
  59. r4 = icon number (0-9, but only 5-9 seems to really be icons)
  60. r5 = destination buffer (704 bytes in size)
  61. Returns: number of read bytes if successful, negative if read failed
  62.  
  63. SYSINFO_ID (r7=3)
  64. Query the unique 64 bit ID number of this Dreamcast. SYSINFO_INIT must have been called first.
  65.  
  66. Args: none
  67.  
  68. Returns: A pointer to where the ID is stored as 8 contiguous bytes
  69.  
  70.  
  71.  
  72. ROMFONT_ADDRESS (r1=0)
  73. Returns the address of the ROM font. The font is organized as 288 narrow characters (12 × 24 pixels), followed by 7078 wide characters (24 × 24 pixels), finally followed by 129 VMS icons (32 × 32 pixels). The total size of the font is thus (288 * 12 * 24 / 8) + (7078 * 24 * 24 / 8) + (129 * 32 *32 / 8) = (288 * 36) + (7078 * 72) + (129 * 128) = 10368 + 509616 + 16512 = 536496 bytes. Note that the narrow characters are stored as three nybbles per line, so each pair of two lines occupy three bytes together.
  74.  
  75. The organization of the narrow characters are as follows:
  76. Position Glyphs
  77. 0 Overbar (Æ)
  78. 1-94 ASCII characters 33-126
  79. 95 Yen („)
  80. 96-191 ISO-8859-1 characters 160-255
  81. 192-287 JISX-0201 characters 160-255
  82. (As there is no glyph for ASCII space, use glyph 96 = ISO-8859-1 unbreakable space instead.)
  83.  
  84. The organization of the wide characters are as follows (a row is 94 characters):
  85. Position Glyphs
  86. 0-657 JISX-0208 row 33-39
  87. 658-7049 JISX-0208 row 48-115
  88. 7050-7055 JISX-0208 row 116 (first 6 characters)
  89. 7056-7077 Dreamcast specific glyphs (A,B,X,Y, direction arrows, etc.)
  90. The organization of the VMS icons are as follows:
  91. Position Glyphs
  92. 0 Invalid VMS icon (circle + cross)
  93. 1-4 Hourglass animation
  94. 5-128 User selectable icons
  95. Args: none
  96.  
  97. Returns: A pointer to the first narrow character
  98.  
  99. ROMFONT_LOCK (r1=1)
  100. Tries to lock a mutex for exclusive access to the ROM font. Quite why anyone would want to arbitrate for access to a resource that resides in ROM is beyond me, but there you have it... The mutex is not checked by ROMFONT_ADDRESS, only by this function.
  101.  
  102. Args: none
  103.  
  104. Returns: 0 if you got the mutex (unlock it with ROMFONT_UNLOCK when you're done), -1 if it was already taken by someone else
  105.  
  106. ROMFONT_UNLOCK (r1=2)
  107. Releases the mutex locked with ROMFONT_LOCK. Only call this function if you actually got the mutex.
  108.  
  109. Args: none
  110.  
  111. Returns: no return value
  112.  
  113.  
  114.  
  115. FLASHROM_INFO (r7=0)
  116. Queries the extent of a single partition in the system flashrom.
  117.  
  118. Args:
  119.  
  120. r4 = partition number (0-4)
  121. r5 = pointer to two 32 bit integers to receive the result. The first will be the offset of the partition start, in bytes from the start of the flashrom. The second will be the size of the partition, in bytes.
  122. Returns: zero if successful, -1 if no such partition exists
  123.  
  124. FLASHROM_READ (r7=1)
  125. Read data from the system flashrom.
  126.  
  127. Args:
  128.  
  129. r4 = read start position, in bytes from the start of the flashrom
  130. r5 = pointer to destination buffer
  131. r6 = number of bytes to read
  132. Returns: number of read bytes if successful, -1 if read failed
  133.  
  134. FLASHROM_WRITE (r7=2)
  135. Write data to the system flashrom. Important: It is only possible to overwrite 1:s with 0:s, 0:s can not be written back to 1:s. General overwriting is therefore not possible. Only bytes containing all ones ($FF) can be written with arbitrary values.
  136.  
  137. Args:
  138.  
  139. r4 = write start position, in bytes from the start of the flashrom
  140. r5 = pointer to source buffer
  141. r6 = number of bytes to write
  142. Returns: number of written bytes if successful, -1 if write failed
  143.  
  144. FLASHROM_DELETE (r7=3)
  145. Return a flashrom partition to all ones, so that it may be rewritten. Danger Will Robinson: ALL data in the entire partition will be lost.
  146.  
  147. Args:
  148.  
  149. r4 = offset of the start of the partition you want to delete, in bytes from the start of the flashrom
  150. Returns: zero if successful, -1 if delete failed
  151.  
  152.  
  153.  
  154. MISC_INIT (r6=-1, r7=0)
  155. Initializes all the syscall vectors to their default values.
  156.  
  157. Args: none
  158.  
  159. Returns: zero
  160.  
  161. MISC_SETVECTOR (r6=-1, r7=1)
  162. Sets/clears the handler for one of the eight superfunctions for this vector. Setting a handler is only allowed if it not currently set.
  163.  
  164. Args:
  165.  
  166. r4 = superfunction number (0-7)
  167. r5 = pointer to handler function, or NULL to clear
  168. Returns: zero if successful, -1 if setting/clearing the handler fails
  169.  
  170. GDROM_SEND_COMMAND (r6=0, r7=0)
  171. Enqueue a command for the GDROM subsystem to execute.
  172.  
  173. Args:
  174.  
  175. r4 = command code
  176. r5 = pointer to parameter block for the command, can be NULL if the command does not take parameters
  177. Returns: a request id (>=0) if successful, negative error code if failed
  178.  
  179. GDROM_CHECK_COMMAND (r6=0, r7=1)
  180. Check if an enqueued command has completed.
  181.  
  182. Args:
  183.  
  184. r4 = request id
  185. r5 = pointer to four 32 bit integers to receive extended status information. The first is a generic error code.
  186. Returns:
  187.  
  188. 0 - no such request active
  189. 1 - request is still being processed
  190. 2 - request has completed (if queried again, you will get a 0)
  191. 3 - request was aborted(?)
  192. -1 - request has failed (examine extended status information for cause of failure)
  193. GDROM_MAINLOOP (r6=0, r7=2)
  194. In order for enqueued commands to get processed, this function must be called a few times. It can be called from a periodic interrupt, or just keep calling it manually until GDROM_CHECK_COMMAND says that your command has stopped processing.
  195.  
  196. Args: none
  197.  
  198. Returns: no return value
  199.  
  200. GDROM_INIT (r6=0, r7=3)
  201. Initialize the GDROM subsystem. Should be called before any requests are enqueued.
  202.  
  203. Args: none
  204.  
  205. Returns: no return value
  206.  
  207. GDROM_CHECK_DRIVE (r6=0, r7=4)
  208. Checks the general condition of the drive.
  209.  
  210. Args:
  211.  
  212. r4 = pointer to two 32 bit integers, to receive the drive status. The first is the current drive status, the second is the type of disc inserted (if any).
  213. Drive status
  214. 0 Drive is busy
  215. 1 Drive is paused
  216. 2 Drive is in standby
  217. 3 Drive is playing
  218. 4 Drive is seeking
  219. 5 Drive is scanning
  220. 6 Drive lid is open
  221. 7 Lid is closed, but there is no disc
  222.  
  223. Disk type
  224. $00 CDDA
  225. $10 CDROM
  226. $20 CDROM/XA
  227. $30 CDI
  228. $80 GDROM
  229. Returns: zero if successful, nonzero if failure
  230.  
  231. GDROM_ABORT_COMMAND (r6=0, r7=8)
  232. Tries to abort a previously enqueued command.
  233.  
  234. Args:
  235.  
  236. r4 = request id
  237. Returns: zero if successful, nonzero if failure
  238.  
  239. GDROM_RESET (r6=0, r7=9)
  240. Resets the drive.
  241.  
  242. Args: none
  243.  
  244. Returns: no return value
  245.  
  246. GDROM_SECTOR_MODE (r6=0, r7=10)
  247. Sets/gets the sector format for read commands.
  248.  
  249. Args:
  250.  
  251. r4 = pointer to a struct of four 32 bit integers containing new values, or to receive the old values
  252. Field Function
  253. 0 Get/Set, if 0 the mode will be set, if 1 it will be queried.
  254. 1 ? (always 8192)
  255. 2 1024 = mode 1, 2048 = mode 2, 0 = auto detect
  256. 3 Sector size in bytes (normally 2048)
  257. Returns: zero if successful, -1 if failure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement