/[gxemul]/trunk/src/cpus/cpu_hppa.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_hppa.c

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

revision 18 by dpavlin, Mon Oct 8 16:19:11 2007 UTC revision 28 by dpavlin, Mon Oct 8 16:20:26 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 15  Line 15 
15   *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND   *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16   *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17   *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE   *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18   *  ARE DISCLAIMED.  IN NO EVENT HPPAALL THE AUTHOR OR CONTRIBUTORS BE LIABLE     *  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE  
19   *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL   *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20   *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS   *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21   *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)   *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_hppa.c,v 1.2 2005/10/22 17:24:20 debug Exp $   *  $Id: cpu_hppa.c,v 1.15 2006/07/16 13:32:26 debug Exp $
29   *   *
30   *  HP PA-RISC CPU emulation.   *  HP PA-RISC CPU emulation.
31   *   *
# Line 70  int hppa_cpu_new(struct cpu *cpu, struct Line 70  int hppa_cpu_new(struct cpu *cpu, struct
70          cpu->cd.hppa.bits = 32;          cpu->cd.hppa.bits = 32;
71    
72          if (cpu->is_32bit) {          if (cpu->is_32bit) {
73                    cpu->run_instr = hppa32_run_instr;
74                  cpu->update_translation_table = hppa32_update_translation_table;                  cpu->update_translation_table = hppa32_update_translation_table;
75                  cpu->invalidate_translation_caches =                  cpu->invalidate_translation_caches =
76                      hppa32_invalidate_translation_caches;                      hppa32_invalidate_translation_caches;
77                  cpu->invalidate_code_translation =                  cpu->invalidate_code_translation =
78                      hppa32_invalidate_code_translation;                      hppa32_invalidate_code_translation;
79          } else {          } else {
80                    cpu->run_instr = hppa_run_instr;
81                  cpu->update_translation_table = hppa_update_translation_table;                  cpu->update_translation_table = hppa_update_translation_table;
82                  cpu->invalidate_translation_caches =                  cpu->invalidate_translation_caches =
83                      hppa_invalidate_translation_caches;                      hppa_invalidate_translation_caches;
# Line 83  int hppa_cpu_new(struct cpu *cpu, struct Line 85  int hppa_cpu_new(struct cpu *cpu, struct
85                      hppa_invalidate_code_translation;                      hppa_invalidate_code_translation;
86          }          }
87    
88          /*  Only hppaow name and caches etc for CPU nr 0 (in SMP machines):  */          /*  Only show name and caches etc for CPU nr 0 (in SMP machines):  */
89          if (cpu_id == 0) {          if (cpu_id == 0) {
90                  debug("%s", cpu->name);                  debug("%s", cpu->name);
91          }          }
# Line 125  void hppa_cpu_dumpinfo(struct cpu *cpu) Line 127  void hppa_cpu_dumpinfo(struct cpu *cpu)
127  void hppa_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs)  void hppa_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs)
128  {  {
129          char *symbol;          char *symbol;
130          uint64_t offset, tmp;          uint64_t offset;
131          int i, x = cpu->cpu_id, nregs = 32;          int i, x = cpu->cpu_id, nregs = 32;
132          int bits32 = cpu->cd.hppa.bits == 32;          int bits32 = cpu->cd.hppa.bits == 32;
133    
# Line 136  void hppa_cpu_register_dump(struct cpu * Line 138  void hppa_cpu_register_dump(struct cpu *
138    
139                  debug("cpu%i: pc  = 0x", x);                  debug("cpu%i: pc  = 0x", x);
140                  if (bits32)                  if (bits32)
141                          debug("%08x", (int)cpu->pc);                          debug("%08"PRIx32, (uint32_t) cpu->pc);
142                  else                  else
143                          debug("%016llx", (long long)cpu->pc);                          debug("%016"PRIx64, (uint64_t) cpu->pc);
144                  debug("  <%s>\n", symbol != NULL? symbol : " no symbol ");                  debug("  <%s>\n", symbol != NULL? symbol : " no symbol ");
145    
146                  if (bits32) {                  if (bits32) {
# Line 146  void hppa_cpu_register_dump(struct cpu * Line 148  void hppa_cpu_register_dump(struct cpu *
148                          for (i=0; i<nregs; i++) {                          for (i=0; i<nregs; i++) {
149                                  if ((i % 4) == 0)                                  if ((i % 4) == 0)
150                                          debug("cpu%i:", x);                                          debug("cpu%i:", x);
151                                  debug(" r%02i = 0x%08x ", i,                                  debug(" r%02i = 0x%08"PRIx32" ", i,
152                                      (int)cpu->cd.hppa.r[i]);                                      (uint32_t)cpu->cd.hppa.r[i]);
153                                  if ((i % 4) == 3)                                  if ((i % 4) == 3)
154                                          debug("\n");                                          debug("\n");
155                          }                          }
# Line 157  void hppa_cpu_register_dump(struct cpu * Line 159  void hppa_cpu_register_dump(struct cpu *
159                                  int r = (i >> 1) + ((i & 1) << 4);                                  int r = (i >> 1) + ((i & 1) << 4);
160                                  if ((i % 2) == 0)                                  if ((i % 2) == 0)
161                                          debug("cpu%i:", x);                                          debug("cpu%i:", x);
162                                  debug(" r%02i = 0x%016llx ", r,                                  debug(" r%02i = 0x%016"PRIx64" ", r,
163                                      (long long)cpu->cd.hppa.r[r]);                                      (uint64_t) cpu->cd.hppa.r[r]);
164                                  if ((i % 2) == 1)                                  if ((i % 2) == 1)
165                                          debug("\n");                                          debug("\n");
166                          }                          }
# Line 191  void hppa_cpu_register_match(struct mach Line 193  void hppa_cpu_register_match(struct mach
193    
194    
195  /*  /*
  *  hppa_cpu_show_full_statistics():  
  *  
  *  Show detailed statistics on opcode usage on each cpu.  
  */  
 void hppa_cpu_show_full_statistics(struct machine *m)  
 {  
         fatal("hppa_cpu_show_full_statistics(): TODO\n");  
 }  
   
   
 /*  
196   *  hppa_cpu_tlbdump():   *  hppa_cpu_tlbdump():
197   *   *
198   *  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 212  void hppa_cpu_show_full_statistics(struc Line 203  void hppa_cpu_show_full_statistics(struc
203   */   */
204  void hppa_cpu_tlbdump(struct machine *m, int x, int rawflag)  void hppa_cpu_tlbdump(struct machine *m, int x, int rawflag)
205  {  {
206          fatal("hppa_cpu_tlbdump(): TODO\n");  }
207    
208    
209    /*
210     *  hppa_cpu_gdb_stub():
211     *
212     *  Execute a "remote GDB" command. Returns a newly allocated response string
213     *  on success, NULL on failure.
214     */
215    char *hppa_cpu_gdb_stub(struct cpu *cpu, char *cmd)
216    {
217            fatal("hppa_cpu_gdb_stub(): TODO\n");
218            return NULL;
219  }  }
220    
221    
# Line 242  int hppa_cpu_interrupt_ack(struct cpu *c Line 245  int hppa_cpu_interrupt_ack(struct cpu *c
245   *  Convert an instruction word into human readable format, for instruction   *  Convert an instruction word into human readable format, for instruction
246   *  tracing.   *  tracing.
247   *   *
248   *  If running is 1, cpu->pc hppaould be the address of the instruction.   *  If running is 1, cpu->pc should be the address of the instruction.
249   *   *
250   *  If running is 0, things that depend on the runtime environment (eg.   *  If running is 0, things that depend on the runtime environment (eg.
251   *  register contents) will not be hppaown, and addr will be used instead of   *  register contents) will not be shown, and addr will be used instead of
252   *  cpu->pc for relative addresses.   *  cpu->pc for relative addresses.
253   */   */
254  int hppa_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr,  int hppa_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr,
255          int running, uint64_t dumpaddr, int bintrans)          int running, uint64_t dumpaddr)
256  {  {
257          uint64_t offset, addr;          uint64_t offset;
258          uint32_t iword;          uint32_t iword;
259          int hi6;          char *symbol;
         char *symbol, *mnem = "ERROR";  
260    
261          if (running)          if (running)
262                  dumpaddr = cpu->pc;                  dumpaddr = cpu->pc;
# Line 268  int hppa_cpu_disassemble_instr(struct cp Line 270  int hppa_cpu_disassemble_instr(struct cp
270                  debug("cpu%i: ", cpu->cpu_id);                  debug("cpu%i: ", cpu->cpu_id);
271    
272          if (cpu->cd.hppa.bits == 32)          if (cpu->cd.hppa.bits == 32)
273                  debug("%08x", (int)dumpaddr);                  debug("%08"PRIx32, (uint32_t) dumpaddr);
274          else          else
275                  debug("%016llx", (long long)dumpaddr);                  debug("%016"PRIx64, (uint64_t) dumpaddr);
276    
277          if (cpu->byte_order == EMUL_BIG_ENDIAN)          if (cpu->byte_order == EMUL_BIG_ENDIAN)
278                  iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8)                  iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8)
# Line 279  int hppa_cpu_disassemble_instr(struct cp Line 281  int hppa_cpu_disassemble_instr(struct cp
281                  iword = (instr[3] << 24) + (instr[2] << 16) + (instr[1] << 8)                  iword = (instr[3] << 24) + (instr[2] << 16) + (instr[1] << 8)
282                      + instr[0];                      + instr[0];
283    
284          debug(": %08x\t", iword);          debug(": %08"PRIx32"\t", (uint32_t) iword);
285    
286          /*          /*
287           *  Decode the instruction:           *  Decode the instruction:

Legend:
Removed from v.18  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26