<html>
<body>
<div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src</tt></b></td></tr>
<tr><td><tt><a href="#file1">bios.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+156</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-72</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">78e762cec843 -> 957b76b312cc</td></tr>
</table>
<div class="tasklist" style="padding:4px;border:1px dashed #000000;margin-top:1em;" ><ul>
<li><a href="#task1">FIXME: This isn't completely correct, but it works</a></li>
</ul></div>
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Split BIOS vectors into separate functions, implement parts of sysinfo and
flashrom calls
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>bios.c</b></big> <small id="info" style="color: #888888;" >78e762cec843 -> 957b76b312cc</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/bios.c
+++ lxdream/src/bios.c
@@ -199,84 +199,168 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
/**
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- * Syscall list courtesy of Marcus Comstedt
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ * Address of the system information block (in the flash rom). Also repeats
+ * at FLASH_SYSINFO_SEGMENT+0xA0
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > */
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#define FLASH_SYSINFO_SEGMENT 0x0021a000
+#define FLASH_CONFIG_SEGMENT 0x0021c000
+#define FLASH_CONFIG_LENGTH 0x00004000
+#define FLASH_PARTITION_MAGIC "KATANA_FLASH____"
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void bios_syscall( uint32_t syscallid )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+/**
<a name="task1" />+ * Locate the active config block. <span class="task" style="background-color:#ffff00;" >FIXME</span>: This isn't completely correct, but it works
+ * under at least some circumstances.
+ */
+static char *bios_find_flash_config( sh4addr_t segment, uint32_t length )
+{
+ char *start = mem_get_region(segment);
+ char *p = start + 0x80;
+ char *end = p + length;
+ char *result = NULL;
+
+ if( memcmp( start, FLASH_PARTITION_MAGIC, 16 ) != 0 )
+ return NULL; /* Missing magic */
+ while( p < end ) {
+ if( p[0] == 0x05 && p[1] == 0 ) {
+ result = p;
+ }
+ p += 0x40;
+ }
+ return result;
+}
+
+/**
+ * Syscall information courtesy of Marcus Comstedt
+ */
+static void bios_sysinfo_vector( uint32_t syscallid )
+{
+ char *flash_segment, *flash_config;
+ char *dest;
+ DEBUG( "BIOS SYSINFO: r4 = %08X, r5 = %08X, r6 = %08x, r7= %08X", sh4r.r[4], sh4r.r[5], sh4r.r[6], sh4r.r[7] );
+
+ switch( sh4r.r[7] ) {
+ case 0: /* SYSINFO_INIT */
+ /* Initialize the region 8c000068 .. 8c00007f from the flash rom
+ * uint64_t system_id;
+ * char [5] system_props;
+ * char [3] zero_pad (?)
+ * char [8] settings;
+ **/
+ flash_segment = mem_get_region(FLASH_SYSINFO_SEGMENT);
+ flash_config = bios_find_flash_config(FLASH_CONFIG_SEGMENT,FLASH_CONFIG_LENGTH);
+ dest = mem_get_region( 0x8c000068 );
+ memset( dest, 0, 24 );
+ memcpy( dest, flash_segment + 0x56, 8 );
+ memcpy( dest + 8, flash_segment, 5 );
+ if( flash_config != NULL ) {
+ memcpy( dest+16, flash_config+2, 8 );
+ }
+ break;
+ case 2: /* SYSINFO_ICON */
+ /* Not supported yet */
+ break;
+ case 3: /* SYSINFO_ID */
+ sh4r.r[0] = 0x8c000068;
+ break;
+ }
+}
+
+static void bios_flashrom_vector( uint32_t syscallid )
+{
+ char *dest;
+ DEBUG( "BIOS FLASHROM: r4 = %08X, r5 = %08X, r6 = %08x, r7= %08X", sh4r.r[4], sh4r.r[5], sh4r.r[6], sh4r.r[7] );
+
+ switch( sh4r.r[7] ) {
+ case 0: /* FLASHROM_INFO */
+ break;
+ case 1: /* FLASHROM_READ */
+
+ break;
+ case 2: /* FLASHROM_WRITE */
+ break;
+ case 3: /* FLASHROM_DELETE */
+ break;
+ }
+}
+
+static void bios_romfont_vector( uint32_t syscallid )
+{
+ DEBUG( "BIOS ROMFONT: r4 = %08X, r5 = %08X, r6 = %08x, r7= %08X", sh4r.r[4], sh4r.r[5], sh4r.r[6], sh4r.r[7] );
+ /* Not implemented */
+}
+
+static void bios_gdrom_vector( uint32_t syscallid )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
gdrom_queue_entry_t cmd;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- switch( syscallid ) {
- case 0xB0: /* sysinfo */
- break;
- case 0xB4: /* Font */
- break;
- case 0xB8: /* Flash */
- break;
- case 0xBC: /* Misc/GD-Rom */
- switch( sh4r.r[6] ) {
- case 0: /* GD-Rom */
- switch( sh4r.r[7] ) {
- case 0: /* Send command */
- sh4r.r[0] = bios_gdrom_enqueue( sh4r.r[4], sh4r.r[5] );
- break;
- case 1: /* Check command */
- cmd = bios_gdrom_get_command( sh4r.r[4] );
- if( cmd == NULL ) {
- sh4r.r[0] = GD_CMD_STATUS_NONE;
- } else {
- sh4r.r[0] = cmd->status;
- if( cmd->status == GD_CMD_STATUS_ERROR &&
- sh4r.r[5] != 0 ) {
- mem_copy_to_sh4( sh4r.r[5], (sh4ptr_t)&cmd->result, sizeof(cmd->result) );
- }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ DEBUG( "BIOS GDROM: r4 = %08X, r5 = %08X, r6 = %08x, r7= %08X", sh4r.r[4], sh4r.r[5], sh4r.r[6], sh4r.r[7] );
+
+ switch( sh4r.r[6] ) {
+ case 0: /* GD-Rom */
+ switch( sh4r.r[7] ) {
+ case 0: /* Send command */
+ sh4r.r[0] = bios_gdrom_enqueue( sh4r.r[4], sh4r.r[5] );
+ break;
+ case 1: /* Check command */
+ cmd = bios_gdrom_get_command( sh4r.r[4] );
+ if( cmd == NULL ) {
+ sh4r.r[0] = GD_CMD_STATUS_NONE;
+ } else {
+ sh4r.r[0] = cmd->status;
+ if( cmd->status == GD_CMD_STATUS_ERROR &&
+ sh4r.r[5] != 0 ) {
+ mem_copy_to_sh4( sh4r.r[5], (sh4ptr_t)&cmd->result, sizeof(cmd->result) );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- break;
- case 2: /* Mainloop */
- bios_gdrom_run_queue();
- break;
- case 3: /* Init */
- bios_gdrom_init();
- break;
- case 4: /* Drive status */
- if( sh4r.r[4] != 0 ) {
- mem_copy_to_sh4( sh4r.r[4], (sh4ptr_t)&bios_gdrom_status,
- sizeof(bios_gdrom_status) );
- }
- sh4r.r[0] = 0;
- break;
- case 8: /* Abort command */
- cmd = bios_gdrom_get_command( sh4r.r[4] );
- if( cmd == NULL || cmd->status != GD_CMD_STATUS_ACTIVE ) {
- sh4r.r[0] = -1;
- } else {
- cmd->status = GD_CMD_STATUS_ABORT;
- sh4r.r[0] = 0;
- }
- break;
- case 9: /* Reset */
- break;
- case 10: /* Set mode */
- sh4r.r[0] = 0;
- break;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
break;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- case -1: /* Misc */
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ case 2: /* Mainloop */
+ bios_gdrom_run_queue();
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > break;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- default: /* ??? */
- break;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ case 3: /* Init */
+ bios_gdrom_init();
+ break;
+ case 4: /* Drive status */
+ if( sh4r.r[4] != 0 ) {
+ mem_copy_to_sh4( sh4r.r[4], (sh4ptr_t)&bios_gdrom_status,
+ sizeof(bios_gdrom_status) );
+ }
+ sh4r.r[0] = 0;
+ break;
+ case 8: /* Abort command */
+ cmd = bios_gdrom_get_command( sh4r.r[4] );
+ if( cmd == NULL || cmd->status != GD_CMD_STATUS_ACTIVE ) {
+ sh4r.r[0] = -1;
+ } else {
+ cmd->status = GD_CMD_STATUS_ABORT;
+ sh4r.r[0] = 0;
+ }
+ break;
+ case 9: /* Reset */
+ break;
+ case 10: /* Set mode */
+ sh4r.r[0] = 0;
+ break;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
break;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- case 0xE0: /* Menu */
- switch( sh4r.r[7] ) {
- case 0:
- WARN( "Entering main program" );
- break;
- case 1:
- WARN( "Program aborted to DC menu");
- dreamcast_stop();
- break;
- }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ case -1: /* Misc */
+ break;
+ default: /* ??? */
+ break;
+ }
+}
+
+static void bios_menu_vector( uint32_t syscallid )
+{
+ DEBUG( "BIOS MENU: r4 = %08X, r5 = %08X, r6 = %08x, r7= %08X", sh4r.r[4], sh4r.r[5], sh4r.r[6], sh4r.r[7] );
+
+ switch( sh4r.r[4] ) {
+ case 0:
+ WARN( "Entering main program" );
+ break;
+ case 1:
+ WARN( "Program aborted to DC menu");
+ dreamcast_stop();
+ break;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
}
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -294,11 +378,11 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > void bios_install( void )
{
bios_gdrom_init();
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- syscall_add_hook_vector( 0xB0, 0x8C0000B0, bios_syscall );
- syscall_add_hook_vector( 0xB4, 0x8C0000B4, bios_syscall );
- syscall_add_hook_vector( 0xB8, 0x8C0000B8, bios_syscall );
- syscall_add_hook_vector( 0xBC, 0x8C0000BC, bios_syscall );
- syscall_add_hook_vector( 0xE0, 0x8C0000E0, bios_syscall );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+ syscall_add_hook_vector( 0xB0, 0x8C0000B0, bios_sysinfo_vector );
+ syscall_add_hook_vector( 0xB4, 0x8C0000B4, bios_romfont_vector );
+ syscall_add_hook_vector( 0xB8, 0x8C0000B8, bios_flashrom_vector );
+ syscall_add_hook_vector( 0xBC, 0x8C0000BC, bios_gdrom_vector );
+ syscall_add_hook_vector( 0xE0, 0x8C0000E0, bios_menu_vector );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
#define MIN_ISO_SECTORS 32
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>