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

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

revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 44 by dpavlin, Mon Oct 8 16:22:56 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_arm.c,v 1.67 2006/12/30 13:30:53 debug Exp $   *  $Id: cpu_arm.c,v 1.72 2007/06/28 13:36:46 debug Exp $
29   *   *
30   *  ARM CPU emulation.   *  ARM CPU emulation.
31   *   *
# Line 39  Line 39 
39  #include <stdlib.h>  #include <stdlib.h>
40  #include <string.h>  #include <string.h>
41  #include <ctype.h>  #include <ctype.h>
42    #include <unistd.h>
43    
44  #include "arm_cpu_types.h"  #include "arm_cpu_types.h"
45  #include "cpu.h"  #include "cpu.h"
# Line 49  Line 50 
50  #include "of.h"  #include "of.h"
51  #include "settings.h"  #include "settings.h"
52  #include "symbol.h"  #include "symbol.h"
53    #include "useremul.h"
54    
55  #define DYNTRANS_32  #define DYNTRANS_32
56  #include "tmp_arm_head.c"  #include "tmp_arm_head.c"
# Line 190  int arm_cpu_new(struct cpu *cpu, struct Line 192  int arm_cpu_new(struct cpu *cpu, struct
192                  /*  FIQ: TODO  */                  /*  FIQ: TODO  */
193          }          }
194    
   
195          return 1;          return 1;
196  }  }
197    
# Line 726  void arm_cpu_tlbdump(struct machine *m, Line 727  void arm_cpu_tlbdump(struct machine *m,
727  }  }
728    
729    
 static void add_response_word(struct cpu *cpu, char *r, uint32_t value,  
         size_t maxlen)  
 {  
         if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {  
                 value = ((value & 0xff) << 24) +  
                         ((value & 0xff00) << 8) +  
                         ((value & 0xff0000) >> 8) +  
                         ((value & 0xff000000) >> 24);  
         }  
         snprintf(r + strlen(r), maxlen - strlen(r), "%08"PRIx32, value);  
 }  
   
   
 /*  
  *  arm_cpu_gdb_stub():  
  *  
  *  Execute a "remote GDB" command. Returns a newly allocated response string  
  *  on success, NULL on failure.  
  */  
 char *arm_cpu_gdb_stub(struct cpu *cpu, char *cmd)  
 {  
         if (strcmp(cmd, "g") == 0) {  
                 /*  15 gprs, pc, 8 fprs, fps, cpsr.  */  
                 int i;  
                 char *r;  
                 size_t len = 1 + 18 * sizeof(uint32_t);  
                 r = malloc(len);  
                 if (r == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
                 r[0] = '\0';  
                 for (i=0; i<15; i++)  
                         add_response_word(cpu, r, cpu->cd.arm.r[i], len);  
                 add_response_word(cpu, r, cpu->pc, len);  
                 /*  TODO: fprs:  */  
                 for (i=0; i<8; i++)  
                         add_response_word(cpu, r, 0, len);  
                 /*  TODO: fps  */  
                 add_response_word(cpu, r, 0, len);  
                 add_response_word(cpu, r, cpu->cd.arm.cpsr, len);  
                 return r;  
         }  
   
         if (cmd[0] == 'p') {  
                 int regnr = strtol(cmd + 1, NULL, 16);  
                 size_t len = 2 * sizeof(uint32_t) + 1;  
                 char *r = malloc(len);  
                 r[0] = '\0';  
                 if (regnr == ARM_PC) {  
                         add_response_word(cpu, r, cpu->pc, len);  
                 } else if (regnr >= 0 && regnr < ARM_PC) {  
                         add_response_word(cpu, r, cpu->cd.arm.r[regnr], len);  
                 } else if (regnr >= 0x10 && regnr <= 0x17) {  
                         /*  TODO: fprs  */  
                         add_response_word(cpu, r, 0, len);  
                         add_response_word(cpu, r, 0, len);  
                         add_response_word(cpu, r, 0, len);  
                 } else if (regnr == 0x18) {  
                         /*  TODO: fps  */  
                         add_response_word(cpu, r, 0, len);  
                 } else if (regnr == 0x19) {  
                         add_response_word(cpu, r, cpu->cd.arm.cpsr, len);  
                 }  
                 return r;  
         }  
   
         fatal("arm_cpu_gdb_stub(): TODO\n");  
         return NULL;  
 }  
   
   
730  /*  /*
731   *  arm_irq_interrupt_assert():   *  arm_irq_interrupt_assert():
732     *  arm_irq_interrupt_deassert():
733   */   */
734  void arm_irq_interrupt_assert(struct interrupt *interrupt)  void arm_irq_interrupt_assert(struct interrupt *interrupt)
735  {  {
736          struct cpu *cpu = (struct cpu *) interrupt->extra;          struct cpu *cpu = (struct cpu *) interrupt->extra;
737          cpu->cd.arm.irq_asserted = 1;          cpu->cd.arm.irq_asserted = 1;
738  }  }
   
   
 /*  
  *  arm_irq_interrupt_deassert():  
  */  
739  void arm_irq_interrupt_deassert(struct interrupt *interrupt)  void arm_irq_interrupt_deassert(struct interrupt *interrupt)
740  {  {
741          struct cpu *cpu = (struct cpu *) interrupt->extra;          struct cpu *cpu = (struct cpu *) interrupt->extra;

Legend:
Removed from v.34  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26