SekRunPS Cyclone integration
[picodrive.git] / cpu / Cyclone / Main.cpp
index 2f92c5c..aca7f4f 100644 (file)
@@ -93,7 +93,7 @@ void CheckInterrupt(int op)
   ot("  ldrleb r1,[r7,#0x44] ;@ Get SR high: T_S__III\n");\r
   ot("  andle r1,r1,#7 ;@ Get interrupt mask\n");\r
   ot("  cmple r0,r1 ;@ irq<=6: Is irq<=mask ?\n");\r
-  ot("  blgt DoInterrupt\n");\r
+  ot("  blgt CycloneDoInterrupt\n");\r
   ot("NoInts%x%s\n", op,ms?"":":");\r
   ot("\n");\r
 }\r
@@ -109,7 +109,7 @@ static void PrintFramework()
   ot("  mov r7,r0          ;@ r7 = Pointer to Cpu Context\n");\r
   ot("                     ;@ r0-3 = Temporary registers\n");\r
   ot("  ldrb r9,[r7,#0x46] ;@ r9 = Flags (NZCV)\n");\r
-  ot("  ldr r6,=JumpTab    ;@ r6 = Opcode Jump table\n");\r
+  ot("  ldr r6,=CycloneJumpTab ;@ r6 = Opcode Jump table\n");\r
   ot("  ldr r5,[r7,#0x5c]  ;@ r5 = Cycles\n");\r
   ot("  ldr r4,[r7,#0x40]  ;@ r4 = Current PC + Memory Base\n");\r
   ot("                     ;@ r8 = Current Opcode\n");\r
@@ -124,7 +124,7 @@ static void PrintFramework()
   ot("  ldrleb r1,[r7,#0x44] ;@ Get SR high: T_S__III\n");\r
   ot("  andle r1,r1,#7 ;@ Get interrupt mask\n");\r
   ot("  cmple r0,r1 ;@ irq<=6: Is irq<=mask ?\n");\r
-  ot("  blgt DoInterrupt\n");\r
+  ot("  blgt CycloneDoInterrupt\n");\r
   ot(";@ Check if interrupt used up all the cycles:\n");\r
   ot("  subs r5,r5,#0\n");\r
   ot("  blt CycloneEndNoBack\n");\r
@@ -143,7 +143,14 @@ static void PrintFramework()
   ot("CycloneEnd%s\n", ms?"":":");\r
   ot("  sub r4,r4,#2\n");\r
   ot("CycloneEndNoBack%s\n", ms?"":":");\r
+#ifdef CYCLONE_FOR_PICODRIVE\r
+  ot("  ldr r1,[r7,#0x54]\n");\r
   ot("  mov r9,r9,lsr #28\n");\r
+  ot("  tst r1,r1\n");\r
+  ot("  bxne r1            ;@ jump to alternative CycloneEnd\n");\r
+#else\r
+  ot("  mov r9,r9,lsr #28\n");\r
+#endif\r
   ot("  str r4,[r7,#0x40]  ;@ Save Current PC + Memory Base\n");\r
   ot("  str r5,[r7,#0x5c]  ;@ Save Cycles\n");\r
   ot("  strb r9,[r7,#0x46] ;@ Save Flags (NZCV)\n");\r
@@ -161,7 +168,7 @@ static void PrintFramework()
     ot(";@ uncompress jump table\n");\r
     if (ms) ot("CycloneInit\n");\r
     else    ot("CycloneInit:\n");\r
-    ot("  ldr r12,=JumpTab\n");\r
+    ot("  ldr r12,=CycloneJumpTab\n");\r
     ot("  add r0,r12,#0xe000*4 ;@ ctrl code pointer\n");\r
     ot("  ldr r1,[r0,#-4]\n");\r
     ot("  tst r1,r1\n");\r
@@ -187,7 +194,7 @@ static void PrintFramework()
     ot("  bgt unc_loop_in\n");\r
     ot("  b unc_loop\n");\r
     ot("unc_finish%s\n", ms?"":":");\r
-    ot("  ldr r12,=JumpTab\n");\r
+    ot("  ldr r12,=CycloneJumpTab\n");\r
     ot("  ;@ set a-line and f-line handlers\n");\r
     ot("  add r0,r12,#0xa000*4\n");\r
     ot("  ldr r1,[r0,#4] ;@ a-line handler\n");\r
@@ -255,7 +262,7 @@ static void PrintFramework()
   ot("\n");\r
 \r
   ot(";@ DoInterrupt - r0=IRQ number\n");\r
-  ot("DoInterrupt%s\n", ms?"":":");\r
+  ot("CycloneDoInterrupt%s\n", ms?"":":");\r
   ot("  stmdb sp!,{lr} ;@ Push ARM return address\n");\r
 \r
   ot(";@ Get IRQ Vector address:\n");\r
@@ -475,7 +482,7 @@ static void PrintJumpTable()
        // space for decompressed table\r
        ot(ms?"  area |.data|, data\n":"  .data\n  .align 4\n\n");\r
 \r
-       ot("JumpTab%s\n", ms?"":":");\r
+       ot("CycloneJumpTab%s\n", ms?"":":");\r
        if(ms) {\r
          for(i = 0; i < 0xa000/8; i++)\r
            ot("  dcd 0,0,0,0,0,0,0,0\n");\r
@@ -548,7 +555,7 @@ static void PrintJumpTable()
        ot("\n");\r
        free(indexes);\r
 #else\r
-       ot("JumpTab%s\n", ms?"":":");\r
+       ot("CycloneJumpTab%s\n", ms?"":":");\r
     len=0xfffe; // Hmmm, armasm 2.50.8684 messes up with a 0x10000 long jump table\r
                 // notaz: same thing with GNU as 2.9-psion-98r2 (reloc overflow)\r
                 // this is due to COFF objects using only 2 bytes for reloc count\r
@@ -613,6 +620,10 @@ static int CycloneMake()
     ot("  .global CycloneSetSr\n");\r
     ot("  .global CycloneGetSr\n");\r
     ot("  .global CycloneVer\n");\r
+#ifdef CYCLONE_FOR_PICODRIVE\r
+    ot("  .global CycloneDoInterrupt\n");\r
+    ot("  .global CycloneJumpTab\n");\r
+#endif\r
     ot("CycloneVer: .long 0x%.4x\n",CycloneVer);\r
   }\r
   ot("\n");\r
@@ -623,6 +634,8 @@ static int CycloneMake()
 \r
   if (ms) ot("  END\n");\r
 \r
+  ot("\n\n;@ vim:filetype=armasm\n");\r
+\r
   fclose(AsmFile); AsmFile=NULL;\r
 \r
 #if 0\r