/[gxemul]/trunk/src/cpus/cpu_sparc.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpus/cpu_sparc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 26 by dpavlin, Mon Oct 8 16:20:10 2007 UTC revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_sparc.c,v 1.31 2006/06/24 21:47:23 debug Exp $   *  $Id: cpu_sparc.c,v 1.38 2006/09/19 10:50:08 debug Exp $
29   *   *
30   *  SPARC CPU emulation.   *  SPARC CPU emulation.
31   */   */
# Line 39  Line 39 
39  #include "machine.h"  #include "machine.h"
40  #include "memory.h"  #include "memory.h"
41  #include "misc.h"  #include "misc.h"
42    #include "settings.h"
43  #include "symbol.h"  #include "symbol.h"
44    
45    
# Line 90  int sparc_cpu_new(struct cpu *cpu, struc Line 91  int sparc_cpu_new(struct cpu *cpu, struc
91    
92          cpu->instruction_has_delayslot = sparc_cpu_instruction_has_delayslot;          cpu->instruction_has_delayslot = sparc_cpu_instruction_has_delayslot;
93    
94            /*  TODO: Separate this into 64-bit vs 32-bit?  */
95            cpu->translate_v2p = sparc_translate_v2p;
96    
97          if (cpu->is_32bit) {          if (cpu->is_32bit) {
98                    cpu->run_instr = sparc32_run_instr;
99                  cpu->update_translation_table =                  cpu->update_translation_table =
100                      sparc32_update_translation_table;                      sparc32_update_translation_table;
101                  cpu->invalidate_translation_caches =                  cpu->invalidate_translation_caches =
# Line 98  int sparc_cpu_new(struct cpu *cpu, struc Line 103  int sparc_cpu_new(struct cpu *cpu, struc
103                  cpu->invalidate_code_translation =                  cpu->invalidate_code_translation =
104                      sparc32_invalidate_code_translation;                      sparc32_invalidate_code_translation;
105          } else {          } else {
106                    cpu->run_instr = sparc_run_instr;
107                  cpu->update_translation_table = sparc_update_translation_table;                  cpu->update_translation_table = sparc_update_translation_table;
108                  cpu->invalidate_translation_caches =                  cpu->invalidate_translation_caches =
109                      sparc_invalidate_translation_caches;                      sparc_invalidate_translation_caches;
# Line 135  int sparc_cpu_new(struct cpu *cpu, struc Line 141  int sparc_cpu_new(struct cpu *cpu, struc
141          /*  Insert number of Windows and Trap levels into the version reg.:  */          /*  Insert number of Windows and Trap levels into the version reg.:  */
142          cpu->cd.sparc.ver |= MAXWIN | (MAXTL << SPARC_VER_MAXTL_SHIFT);          cpu->cd.sparc.ver |= MAXWIN | (MAXTL << SPARC_VER_MAXTL_SHIFT);
143    
144            /*  Misc. initial settings suitable for userland emulation:  */
145            cpu->cd.sparc.cansave = cpu->cd.sparc.cpu_type.nwindows - 1;
146            cpu->cd.sparc.cleanwin = cpu->cd.sparc.cpu_type.nwindows / 2;
147    
148            if (cpu->cd.sparc.cpu_type.nwindows >= MAXWIN) {
149                    fatal("Fatal internal error: nwindows = %1 is more than %i\n",
150                        cpu->cd.sparc.cpu_type.nwindows, MAXWIN);
151                    exit(1);
152            }
153    
154            CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc);
155            CPU_SETTINGS_ADD_REGISTER64("y", cpu->cd.sparc.y);
156            CPU_SETTINGS_ADD_REGISTER64("pstate", cpu->cd.sparc.pstate);
157            for (i=0; i<N_SPARC_REG; i++)
158                    CPU_SETTINGS_ADD_REGISTER64(sparc_regnames[i],
159                        cpu->cd.sparc.r[i]);
160            /*  TODO: Handler for writes to the zero register!  */
161    
162          return 1;          return 1;
163  }  }
164    
# Line 267  void sparc_cpu_register_dump(struct cpu Line 291  void sparc_cpu_register_dump(struct cpu
291    
292    
293  /*  /*
  *  sparc_cpu_register_match():  
  */  
 void sparc_cpu_register_match(struct machine *m, char *name,  
         int writeflag, uint64_t *valuep, int *match_register)  
 {  
         int i, cpunr = 0;  
   
         /*  CPU number:  */  
         /*  TODO  */  
   
         for (i=0; i<N_SPARC_REG; i++) {  
                 if (strcasecmp(name, sparc_regnames[i]) == 0) {  
                         if (writeflag && i != SPARC_ZEROREG)  
                                 m->cpus[cpunr]->cd.sparc.r[i] = *valuep;  
                         else  
                                 *valuep = m->cpus[cpunr]->cd.sparc.r[i];  
                         *match_register = 1;  
                 }  
         }  
   
         if (strcasecmp(name, "pc") == 0) {  
                 if (writeflag) {  
                         m->cpus[cpunr]->pc = *valuep;  
                 } else {  
                         *valuep = m->cpus[cpunr]->pc;  
                 }  
                 *match_register = 1;  
         }  
   
         if (strcasecmp(name, "y") == 0) {  
                 if (writeflag) {  
                         m->cpus[cpunr]->cd.sparc.y = (uint32_t) *valuep;  
                 } else {  
                         *valuep = (uint32_t) m->cpus[cpunr]->cd.sparc.y;  
                 }  
                 *match_register = 1;  
         }  
   
         if (*match_register && m->cpus[cpunr]->is_32bit)  
                 (*valuep) &= 0xffffffffULL;  
 }  
   
   
 /*  
294   *  sparc_cpu_tlbdump():   *  sparc_cpu_tlbdump():
295   *   *
296   *  Called from the debugger to dump the TLB in a readable format.   *  Called from the debugger to dump the TLB in a readable format.
# Line 460  int sparc_cpu_instruction_has_delayslot( Line 440  int sparc_cpu_instruction_has_delayslot(
440                  switch (op2) {                  switch (op2) {
441                  case 56:/*  jump and link  */                  case 56:/*  jump and link  */
442                          return 1;                          return 1;
443                    case 57:/*  return  */
444                            return 1;
445                  }                  }
446                  break;                  break;
447          }          }
# Line 663  int sparc_cpu_disassemble_instr(struct c Line 645  int sparc_cpu_disassemble_instr(struct c
645                  case 41:rs_name = "psr";                  case 41:rs_name = "psr";
646                          no_rs2 = 1;                          no_rs2 = 1;
647                          break;                          break;
648                  case 42:rs_name = "wim";                  case 42:/*  TODO: something with wim only, on sparc v8?  */
649                            rs_name = sparc_pregnames[rs1];
650                          no_rs2 = 1;                          no_rs2 = 1;
651                          break;                          break;
652                  case 43:/*  ?  */                  case 43:/*  ?  */
# Line 734  int sparc_cpu_disassemble_instr(struct c Line 717  int sparc_cpu_disassemble_instr(struct c
717                          if ((iword >> 13) & 1) {                          if ((iword >> 13) & 1) {
718                                  if (siconst >= -9 && siconst <= 9)                                  if (siconst >= -9 && siconst <= 9)
719                                          debug("%i", siconst);                                          debug("%i", siconst);
720                                    else if (siconst < 0 && (op2 == 0 ||
721                                        op2 == 4 || op2 == 20 || op2 == 60))
722                                            debug("-0x%x", -siconst);
723                                  else                                  else
724                                          debug("0x%x", siconst);                                          debug("0x%x", siconst);
725                          } else {                          } else {
# Line 746  int sparc_cpu_disassemble_instr(struct c Line 732  int sparc_cpu_disassemble_instr(struct c
732                          debug("%%%s", rd_name);                          debug("%%%s", rd_name);
733                  break;                  break;
734    
735          case 3: debug("%s\t", sparc_loadstore_names[op2]);          case 3: mnem = sparc_loadstore_names[op2];
736                    switch (op2) {
737                    case 0: /*  'lduw' was called only 'ld' in pre-v9  */
738                            if (cpu->cd.sparc.cpu_type.v < 9)
739                                    mnem = "ld";
740                            break;
741                    }
742                    debug("%s\t", mnem);
743                  if (op2 & 4)                  if (op2 & 4)
744                          debug("%%%s,", sparc_regnames[rd]);                          debug("%%%s,", sparc_regnames[rd]);
745                  debug("[%%%s", sparc_regnames[rs1]);                  debug("[%%%s", sparc_regnames[rs1]);
# Line 760  int sparc_cpu_disassemble_instr(struct c Line 753  int sparc_cpu_disassemble_instr(struct c
753                                  debug("+%%%s", sparc_regnames[rs2]);                                  debug("+%%%s", sparc_regnames[rs2]);
754                  }                  }
755                  debug("]");                  debug("]");
756                  if (asi != 0)                  if ((op2 & 0x30) == 0x10)
757                          debug("(%i)", asi);                          debug("(%i)", asi);
758                  if (!(op2 & 4))                  if (!(op2 & 4))
759                          debug(",%%%s", sparc_regnames[rd]);                          debug(",%%%s", sparc_regnames[rd]);

Legend:
Removed from v.26  
changed lines
  Added in v.32

  ViewVC Help
Powered by ViewVC 1.1.26