/[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 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_sparc.c,v 1.11 2005/12/11 21:34:43 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    
46  #define DYNTRANS_DUALMODE_32  #define DYNTRANS_DUALMODE_32
47    #define DYNTRANS_DELAYSLOT
48  #include "tmp_sparc_head.c"  #include "tmp_sparc_head.c"
49    
50    
51  static char *sparc_regnames[N_SPARC_REG] = SPARC_REG_NAMES;  static char *sparc_regnames[N_SPARC_REG] = SPARC_REG_NAMES;
52    static char *sparc_pregnames[N_SPARC_PREG] = SPARC_PREG_NAMES;
53  static char *sparc_regbranch_names[N_SPARC_REGBRANCH_TYPES] =  static char *sparc_regbranch_names[N_SPARC_REGBRANCH_TYPES] =
54          SPARC_REGBRANCH_NAMES;          SPARC_REGBRANCH_NAMES;
55  static char *sparc_branch_names[N_SPARC_BRANCH_TYPES] = SPARC_BRANCH_NAMES;  static char *sparc_branch_names[N_SPARC_BRANCH_TYPES] = SPARC_BRANCH_NAMES;
# Line 86  int sparc_cpu_new(struct cpu *cpu, struc Line 89  int sparc_cpu_new(struct cpu *cpu, struc
89          cpu->byte_order        = EMUL_BIG_ENDIAN;          cpu->byte_order        = EMUL_BIG_ENDIAN;
90          cpu->is_32bit = (cpu->cd.sparc.cpu_type.bits == 32)? 1 : 0;          cpu->is_32bit = (cpu->cd.sparc.cpu_type.bits == 32)? 1 : 0;
91    
92            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 94  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 125  int sparc_cpu_new(struct cpu *cpu, struc Line 135  int sparc_cpu_new(struct cpu *cpu, struc
135                  }                  }
136          }          }
137    
138            /*  After a reset, the Tick register is not readable by user code:  */
139            cpu->cd.sparc.tick |= SPARC_TICK_NPT;
140    
141            /*  Insert number of Windows and Trap levels into the version reg.:  */
142            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 142  void sparc_cpu_list_available_types(void Line 176  void sparc_cpu_list_available_types(void
176          i = 0;          i = 0;
177          while (tdefs[i].name != NULL) {          while (tdefs[i].name != NULL) {
178                  debug("%s", tdefs[i].name);                  debug("%s", tdefs[i].name);
179                  for (j=10 - strlen(tdefs[i].name); j>0; j--)                  for (j=16 - strlen(tdefs[i].name); j>0; j--)
180                          debug(" ");                          debug(" ");
181                  i++;                  i++;
182                  if ((i % 6) == 0 || tdefs[i].name == NULL)                  if ((i % 4) == 0 || tdefs[i].name == NULL)
183                          debug("\n");                          debug("\n");
184          }          }
185  }  }
# Line 182  void sparc_cpu_register_dump(struct cpu Line 216  void sparc_cpu_register_dump(struct cpu
216    
217                  debug("cpu%i: pc = 0x", x);                  debug("cpu%i: pc = 0x", x);
218                  if (bits32)                  if (bits32)
219                          debug("%08x", (int)cpu->pc);                          debug("%08"PRIx32, (uint32_t) cpu->pc);
220                  else                  else
221                          debug("%016llx", (long long)cpu->pc);                          debug("%016"PRIx64, (uint64_t) cpu->pc);
222                  debug("  <%s>\n", symbol != NULL? symbol : " no symbol ");                  debug("  <%s>\n", symbol != NULL? symbol : " no symbol ");
223    
224                    debug("cpu%i: y  = 0x%08"PRIx32"   ",
225                        x, (uint32_t)cpu->cd.sparc.y);
226                    debug("icc = ");
227                    debug(cpu->cd.sparc.ccr & SPARC_CCR_N? "N" : "n");
228                    debug(cpu->cd.sparc.ccr & SPARC_CCR_Z? "Z" : "z");
229                    debug(cpu->cd.sparc.ccr & SPARC_CCR_V? "V" : "v");
230                    debug(cpu->cd.sparc.ccr & SPARC_CCR_C? "C" : "c");
231                    if (!bits32) {
232                            debug("  xcc = ");
233                            debug((cpu->cd.sparc.ccr >> SPARC_CCR_XCC_SHIFT)
234                                & SPARC_CCR_N? "N" : "n");
235                            debug((cpu->cd.sparc.ccr >> SPARC_CCR_XCC_SHIFT)
236                                & SPARC_CCR_Z? "Z" : "z");
237                            debug((cpu->cd.sparc.ccr >> SPARC_CCR_XCC_SHIFT)
238                                & SPARC_CCR_V? "V" : "v");
239                            debug((cpu->cd.sparc.ccr >> SPARC_CCR_XCC_SHIFT)
240                                & SPARC_CCR_C? "C" : "c");
241                    }
242                    debug("\n");
243    
244                    if (bits32)
245                            debug("cpu%i: psr = 0x%08"PRIx32"\n",
246                                x, (uint32_t) cpu->cd.sparc.psr);
247                    else
248                            debug("cpu%i: pstate = 0x%016"PRIx64"\n",
249                                x, (uint64_t) cpu->cd.sparc.pstate);
250    
251                  if (bits32) {                  if (bits32) {
252                          for (i=0; i<N_SPARC_REG; i++) {                          for (i=0; i<N_SPARC_REG; i++) {
253                                  if ((i & 3) == 0)                                  if ((i & 3) == 0)
254                                          debug("cpu%i: ", x);                                          debug("cpu%i: ", x);
255                                  /*  Skip the zero register:  */                                  /*  Skip the zero register:  */
256                                  if (i==0) {                                  if (i == SPARC_ZEROREG) {
257                                          debug("               ");                                          debug("               ");
258                                          continue;                                          continue;
259                                  }                                  }
# Line 208  void sparc_cpu_register_dump(struct cpu Line 269  void sparc_cpu_register_dump(struct cpu
269                                  int r = ((i >> 1) & 15) | ((i&1) << 4);                                  int r = ((i >> 1) & 15) | ((i&1) << 4);
270                                  if ((i & 1) == 0)                                  if ((i & 1) == 0)
271                                          debug("cpu%i: ", x);                                          debug("cpu%i: ", x);
272    
273                                  /*  Skip the zero register:  */                                  /*  Skip the zero register:  */
274                                  if (r==0) {                                  if (i == SPARC_ZEROREG) {
275                                          debug("                         ");                                          debug("                         ");
276                                          continue;                                          continue;
277                                  }                                  }
278    
279                                  debug("%s = ", sparc_regnames[r]);                                  debug("%s = ", sparc_regnames[r]);
280                                  debug("0x%016llx", (long long)                                  debug("0x%016"PRIx64, (uint64_t)
281                                      cpu->cd.sparc.r[r]);                                      cpu->cd.sparc.r[r]);
282    
283                                  if ((i & 1) < 1)                                  if ((i & 1) < 1)
284                                          debug("  ");                                          debug("  ");
285                                  else                                  else
# Line 227  void sparc_cpu_register_dump(struct cpu Line 291  void sparc_cpu_register_dump(struct cpu
291    
292    
293  /*  /*
294   *  sparc_cpu_register_match():   *  sparc_cpu_tlbdump():
295     *
296     *  Called from the debugger to dump the TLB in a readable format.
297     *  x is the cpu number to dump, or -1 to dump all CPUs.
298     *
299     *  If rawflag is nonzero, then the TLB contents isn't formated nicely,
300     *  just dumped.
301   */   */
302  void sparc_cpu_register_match(struct machine *m, char *name,  void sparc_cpu_tlbdump(struct machine *m, int x, int rawflag)
         int writeflag, uint64_t *valuep, int *match_register)  
303  {  {
304          int cpunr = 0;  }
305    
         /*  CPU number:  */  
306    
307          /*  TODO  */  static void add_response_word(struct cpu *cpu, char *r, uint64_t value,
308            size_t maxlen, int len)
309    {
310            char *format = (len == 4)? "%08"PRIx64 : "%016"PRIx64;
311            if (len == 4)
312                    value &= 0xffffffffULL;
313            if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
314                    if (len == 4) {
315                            value = ((value & 0xff) << 24) +
316                                    ((value & 0xff00) << 8) +
317                                    ((value & 0xff0000) >> 8) +
318                                    ((value & 0xff000000) >> 24);
319                    } else {
320                            value = ((value & 0xff) << 56) +
321                                    ((value & 0xff00) << 40) +
322                                    ((value & 0xff0000) << 24) +
323                                    ((value & 0xff000000ULL) << 8) +
324                                    ((value & 0xff00000000ULL) >> 8) +
325                                    ((value & 0xff0000000000ULL) >> 24) +
326                                    ((value & 0xff000000000000ULL) >> 40) +
327                                    ((value & 0xff00000000000000ULL) >> 56);
328                    }
329            }
330            snprintf(r + strlen(r), maxlen - strlen(r), format, (uint64_t)value);
331    }
332    
333    
334          /*  Register name:  */  /*
335          if (strcasecmp(name, "pc") == 0) {   *  sparc_cpu_gdb_stub():
336                  if (writeflag) {   *
337                          m->cpus[cpunr]->pc = *valuep;   *  Execute a "remote GDB" command. Returns a newly allocated response string
338                  } else   *  on success, NULL on failure.
339                          *valuep = m->cpus[cpunr]->pc;   */
340                  *match_register = 1;  char *sparc_cpu_gdb_stub(struct cpu *cpu, char *cmd)
341    {
342            if (strcmp(cmd, "g") == 0) {
343                    int i;
344                    char *r;
345                    size_t wlen = cpu->is_32bit?
346                        sizeof(uint32_t) : sizeof(uint64_t);
347                    size_t len = 1 + 76 * wlen;
348                    r = malloc(len);
349                    if (r == NULL) {
350                            fprintf(stderr, "out of memory\n");
351                            exit(1);
352                    }
353                    r[0] = '\0';
354                    /*  TODO  */
355                    for (i=0; i<128; i++)
356                            add_response_word(cpu, r, i, len, wlen);
357                    return r;
358            }
359    
360            if (cmd[0] == 'p') {
361                    int regnr = strtol(cmd + 1, NULL, 16);
362                    size_t wlen = sizeof(uint32_t);
363                    /*  TODO: cpu->is_32bit? sizeof(uint32_t) : sizeof(uint64_t); */
364                    size_t len = 2 * wlen + 1;
365                    char *r = malloc(len);
366                    r[0] = '\0';
367                    if (regnr >= 0 && regnr < N_SPARC_REG) {
368                            add_response_word(cpu, r,
369                                cpu->cd.sparc.r[regnr], len, wlen);
370                    } else if (regnr == 0x44) {
371                            add_response_word(cpu, r, cpu->pc, len, wlen);
372    /* TODO:
373    20..3f = f0..f31
374    40 = y
375    41 = psr
376    42 = wim
377    43 = tbr
378    45 = npc
379    46 = fsr
380    47 = csr
381    */
382                    } else {
383                            /*  Unimplemented:  */
384                            add_response_word(cpu, r, 0xcc000 + regnr, len, wlen);
385                    }
386                    return r;
387          }          }
388    
389            fatal("sparc_cpu_gdb_stub(): TODO\n");
390            return NULL;
391  }  }
392    
393    
# Line 270  int sparc_cpu_interrupt_ack(struct cpu * Line 412  int sparc_cpu_interrupt_ack(struct cpu *
412    
413    
414  /*  /*
415     *  sparc_cpu_instruction_has_delayslot():
416     *
417     *  Return 1 if an opcode is a branch, 0 otherwise.
418     */
419    int sparc_cpu_instruction_has_delayslot(struct cpu *cpu, unsigned char *ib)
420    {
421            uint32_t iword = *((uint32_t *)&ib[0]);
422            int hi2, op2;
423    
424            iword = BE32_TO_HOST(iword);
425    
426            hi2 = iword >> 30;
427            op2 = (hi2 == 0)? ((iword >> 22) & 7) : ((iword >> 19) & 0x3f);
428    
429            switch (hi2) {
430            case 0: /*  conditional branch  */
431                    switch (op2) {
432                    case 1:
433                    case 2:
434                    case 3: return 1;
435                    }
436                    break;
437            case 1: /*  call  */
438                    return 1;
439            case 2: /*  misc alu instructions  */
440                    switch (op2) {
441                    case 56:/*  jump and link  */
442                            return 1;
443                    case 57:/*  return  */
444                            return 1;
445                    }
446                    break;
447            }
448    
449            return 0;
450    }
451    
452    
453    /*
454   *  sparc_cpu_disassemble_instr():   *  sparc_cpu_disassemble_instr():
455   *   *
456   *  Convert an instruction word into human readable format, for instruction   *  Convert an instruction word into human readable format, for instruction
# Line 282  int sparc_cpu_interrupt_ack(struct cpu * Line 463  int sparc_cpu_interrupt_ack(struct cpu *
463   *  cpu->pc for relative addresses.   *  cpu->pc for relative addresses.
464   */   */
465  int sparc_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr,  int sparc_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr,
466          int running, uint64_t dumpaddr, int bintrans)          int running, uint64_t dumpaddr)
467  {  {
468          uint64_t offset, tmp;          uint64_t offset, tmp;
469          uint32_t iword;          uint32_t iword;
470          int hi2, op2, rd, rs1, rs2, siconst, btype, tmps, no_rd = 0;          int hi2, op2, rd, rs1, rs2, siconst, btype, tmps, no_rd = 0;
471          int asi, no_rs1 = 0, no_rs2 = 0, jmpl = 0, shift_x = 0, cc, p;          int asi, no_rs1 = 0, no_rs2 = 0, jmpl = 0, shift_x = 0, cc, p;
472          char *symbol, *mnem;          char *symbol, *mnem, *rd_name, *rs_name;
473    
474          if (running)          if (running)
475                  dumpaddr = cpu->pc;                  dumpaddr = cpu->pc;
# Line 302  int sparc_cpu_disassemble_instr(struct c Line 483  int sparc_cpu_disassemble_instr(struct c
483                  debug("cpu%i: ", cpu->cpu_id);                  debug("cpu%i: ", cpu->cpu_id);
484    
485          if (cpu->is_32bit)          if (cpu->is_32bit)
486                  debug("%08x", (int)dumpaddr);                  debug("%08"PRIx32, (uint32_t) dumpaddr);
487          else          else
488                  debug("%016llx", (long long)dumpaddr);                  debug("%016"PRIx64, (uint64_t) dumpaddr);
489    
490          iword = *(uint32_t *)&instr[0];          iword = *(uint32_t *)&instr[0];
491          iword = BE32_TO_HOST(iword);          iword = BE32_TO_HOST(iword);
492    
493          debug(": %08x\t", iword);          debug(": %08x", iword);
494    
495            if (running && cpu->delay_slot)
496                    debug(" (d)");
497    
498            debug("\t");
499    
500    
501          /*          /*
502           *  Decode the instruction:           *  Decode the instruction:
# Line 370  int sparc_cpu_disassemble_instr(struct c Line 557  int sparc_cpu_disassemble_instr(struct c
557                          }                          }
558                          tmp = (int64_t)(int32_t)tmps;                          tmp = (int64_t)(int32_t)tmps;
559                          tmp += dumpaddr;                          tmp += dumpaddr;
560                          debug("0x%llx", (long long)tmp);                          debug("0x%"PRIx64, (uint64_t) tmp);
561                          symbol = get_symbol_name(&cpu->machine->                          symbol = get_symbol_name(&cpu->machine->
562                              symbol_context, tmp, &offset);                              symbol_context, tmp, &offset);
563                          if (symbol != NULL)                          if (symbol != NULL)
# Line 391  int sparc_cpu_disassemble_instr(struct c Line 578  int sparc_cpu_disassemble_instr(struct c
578    
579          case 1: tmp = (int32_t)iword << 2;          case 1: tmp = (int32_t)iword << 2;
580                  tmp += dumpaddr;                  tmp += dumpaddr;
581                  debug("call\t0x%llx", (long long)tmp);                  debug("call\t0x%"PRIx64, (uint64_t) tmp);
582                  symbol = get_symbol_name(&cpu->machine->symbol_context,                  symbol = get_symbol_name(&cpu->machine->symbol_context,
583                      tmp, &offset);                      tmp, &offset);
584                  if (symbol != NULL)                  if (symbol != NULL)
# Line 399  int sparc_cpu_disassemble_instr(struct c Line 586  int sparc_cpu_disassemble_instr(struct c
586                  break;                  break;
587    
588          case 2: mnem = sparc_alu_names[op2];          case 2: mnem = sparc_alu_names[op2];
589                    rs_name = sparc_regnames[rs1];
590                    rd_name = sparc_regnames[rd];
591                  switch (op2) {                  switch (op2) {
592                  case 0: /*  add  */                  case 0: /*  add  */
593                          if (rd == rs1 && (iword & 0x3fff) == 0x2001) {                          if (rd == rs1 && (iword & 0x3fff) == 0x2001) {
# Line 433  int sparc_cpu_disassemble_instr(struct c Line 622  int sparc_cpu_disassemble_instr(struct c
622                          } else                          } else
623                                  siconst &= 0x1f;                                  siconst &= 0x1f;
624                          break;                          break;
625                    case 40:/*  rd on pre-sparcv9, membar etc on sparcv9  */
626                            no_rs2 = 1;
627                            rs_name = "UNIMPLEMENTED";
628                            switch (rs1) {
629                            case 0: rs_name = "y"; break;
630                            case 2: rs_name = "ccr"; break;
631                            case 3: rs_name = "asi"; break;
632                            case 4: rs_name = "tick"; break;
633                            case 5: rs_name = "pc"; break;
634                            case 6: rs_name = "fprs"; break;
635                            case 15:/*  membar etc.  */
636                                    if ((iword >> 13) & 1) {
637                                            no_rd = 1;
638                                            mnem = "membar";
639                                            rs_name = "#TODO";
640                                    }
641                                    break;
642                            case 23:rs_name = "tick_cmpr"; break;   /*  v9 ?  */
643                            }
644                            break;
645                    case 41:rs_name = "psr";
646                            no_rs2 = 1;
647                            break;
648                    case 42:/*  TODO: something with wim only, on sparc v8?  */
649                            rs_name = sparc_pregnames[rs1];
650                            no_rs2 = 1;
651                            break;
652                  case 43:/*  ?  */                  case 43:/*  ?  */
653                            /*  TODO: pre-sparcv9: rd, rs_name = "tbr";  */
654                          if (iword == 0x81580000) {                          if (iword == 0x81580000) {
655                                  mnem = "flushw";                                  mnem = "flushw";
656                                  no_rs1 = no_rs2 = no_rd = 1;                                  no_rs1 = no_rs2 = no_rd = 1;
657                          }                          }
658                          break;                          break;
659                    case 48:/*  wr* (SPARCv8)  */
660                            mnem = "wr";
661                            if (rs1 == SPARC_ZEROREG)
662                                    no_rs1 = 1;
663                            switch (rd) {
664                            case 0: rd_name = "y"; break;
665                            case 2: rd_name = "ccr"; break;
666                            case 3: rd_name = "asi"; break;
667                            case 6: rd_name = "fprs"; break;
668                            case 23:rd_name = "tick_cmpr"; break;   /*  v9 ?  */
669                            default:rd_name = "UNIMPLEMENTED";
670                            }
671                            break;
672                  case 49:/*  ?  */                  case 49:/*  ?  */
673                          if (iword == 0x83880000) {                          if (iword == 0x83880000) {
674                                  mnem = "restored";                                  mnem = "restored";
675                                  no_rs1 = no_rs2 = no_rd = 1;                                  no_rs1 = no_rs2 = no_rd = 1;
676                          }                          }
677                          break;                          break;
678                    case 50:/*  wrpr  */
679                            rd_name = sparc_pregnames[rd];
680                            if (rs1 == SPARC_ZEROREG)
681                                    no_rs1 = 1;
682                            break;
683                  case 56:/*  jmpl  */                  case 56:/*  jmpl  */
684                          jmpl = 1;                          jmpl = 1;
685                          if (iword == 0x81c7e008) {                          if (iword == 0x81c7e008) {
# Line 471  int sparc_cpu_disassemble_instr(struct c Line 706  int sparc_cpu_disassemble_instr(struct c
706                          debug("x");                          debug("x");
707                  debug("\t");                  debug("\t");
708                  if (!no_rs1)                  if (!no_rs1)
709                          debug("%%%s", sparc_regnames[rs1]);                          debug("%%%s", rs_name);
710                  if (!no_rs1 && !no_rs2) {                  if (!no_rs1 && !no_rs2) {
711                          if (jmpl)                          if (jmpl)
712                                  debug("+");                                  debug("+");
# Line 482  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 491  int sparc_cpu_disassemble_instr(struct c Line 729  int sparc_cpu_disassemble_instr(struct c
729                  if ((!no_rs1 || !no_rs2) && !no_rd)                  if ((!no_rs1 || !no_rs2) && !no_rd)
730                          debug(",");                          debug(",");
731                  if (!no_rd)                  if (!no_rd)
732                          debug("%%%s", sparc_regnames[rd]);                          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 508  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]);
# Line 520  int sparc_cpu_disassemble_instr(struct c Line 765  int sparc_cpu_disassemble_instr(struct c
765  }  }
766    
767    
768    /*
769     *  sparc_update_pstate():
770     *
771     *  Update the pstate register (64-bit sparcs).
772     */
773    static void sparc_update_pstate(struct cpu *cpu, uint64_t new_pstate)
774    {
775            /*  uint64_t old_pstate = cpu->cd.sparc.pstate;  */
776    
777            /*  TODO: Check individual bits.  */
778    
779            cpu->cd.sparc.pstate = new_pstate;
780    }
781    
782    
783  #include "tmp_sparc_tail.c"  #include "tmp_sparc_tail.c"
784    

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

  ViewVC Help
Powered by ViewVC 1.1.26