~ubuntu-branches/ubuntu/lucid/skyeye/lucid-proposed

« back to all changes in this revision

Viewing changes to utils/debugger/mips_regdefs.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2007-02-09 20:24:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070209202429-jknfb98t9ggaoz02
Tags: 1.2.1-2
Disable DBCT again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        mips_regdefs.c - necessary mips definition for skyeye debugger
 
3
        Copyright (C) 2003 Skyeye Develop Group
 
4
        for help please send mail to <skyeye-developer@lists.sf.linuxforum.net>
 
5
 
 
6
        This program is free software; you can redistribute it and/or modify
 
7
        it under the terms of the GNU General Public License as published by
 
8
        the Free Software Foundation; either version 2 of the License, or
 
9
        (at your option) any later version.
 
10
 
 
11
        This program is distributed in the hope that it will be useful,
 
12
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
        GNU General Public License for more details.
 
15
 
 
16
        You should have received a copy of the GNU General Public License
 
17
        along with this program; if not, write to the Free Software
 
18
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 
 
20
*/
 
21
/*
 
22
 * 12/21/2006   Michael.Kang  <blackfin.kang@gmail.com>
 
23
 */
 
24
 
 
25
/*
 
26
 * according to GDB_SOURCE/gdb/regformats/mips-reg.dat
 
27
 *
 
28
        32:zero 32:at 32:v0  32:v1
 
29
        32:a0   32:a1 32:a2  32:a3
 
30
        32:t0   32:t1 32:t2  32:t3
 
31
        32:t4   32:t5 32:t6  32:t7
 
32
        32:s0   32:s1 32:s2 32:s3
 
33
        32:s4   32:s5 32:s6 32:s7
 
34
        32:t8   32:t9 32:k0 32:k1
 
35
        32:gp   32:sp 32:s8 32:ra
 
36
 
 
37
        32:sr   32:lo 32:hi 32:bad
 
38
        32:cause 32:pc
 
39
 
 
40
        32:f0   32:f1 32:f2 32:f3
 
41
        32:f4   32:f5 32:f6 32:f7
 
42
        32:f8   32:f9  32:f10  32:f11
 
43
        32:f12  32:f13 32:f14 32:f15
 
44
        32:f16  32:f17 32:f18 32:f19
 
45
        32:f20  32:f21 32:f22 32:f23
 
46
        32:f24  32:f25 32:f26 32:f27
 
47
        32:f28  32:f29 32:f30 32:f31
 
48
 
 
49
        32:fsr  32:fir 32:fp
 
50
*/
 
51
 
 
52
#include <skyeye_defs.h>
 
53
#include "skyeye2gdb.h"
 
54
#include <emul.h>
 
55
 
 
56
static int mips_register_raw_size(int x){
 
57
        return 32;
 
58
}
 
59
static int mips_register_byte(int x){
 
60
        return 32 * x;
 
61
}
 
62
 
 
63
extern int bigendSig;
 
64
 
 
65
extern MIPS_State* mstate;
 
66
 
 
67
static int mips_store_register(int rn, unsigned char * memory){
 
68
        uint32_t v = frommem(memory);
 
69
        if(rn >= 0 && rn < 32)
 
70
                mstate->gpr[rn] = v;
 
71
        else if(rn == 32)/* SR register of CP0 */
 
72
                mstate->cp0[12] = v;
 
73
        else if(rn == 33)
 
74
                mstate->lo = v;
 
75
        else if(rn == 34)
 
76
                mstate->hi = v;
 
77
        else if(rn == 35) /* Bad Vaddr */
 
78
                mstate->cp0[8] = v;
 
79
        else if(rn == 36) /* Cause */
 
80
                mstate->cp0[13] = v;
 
81
        else if(rn == 37)
 
82
                mstate->pc = v;
 
83
        else if(rn >= 38 && rn < 70)
 
84
                mstate->fpr[rn] = v;                    
 
85
        else if(rn == 70 || rn == 71 || rn == 72) /* fsr, fir, fp */
 
86
                ; /* do nothing */
 
87
        return 0;
 
88
}
 
89
static int mips_fetch_register(int rn, unsigned char * memory){
 
90
        uint32_t v;
 
91
        if(rn >= 0 && rn < 32)
 
92
                v = mstate->gpr[rn];
 
93
        else if(rn == 32)/* SR register of CP0 */
 
94
                v = mstate->cp0[12];
 
95
        else if(rn == 33)
 
96
                v = mstate->lo;
 
97
        else if(rn == 34)
 
98
                v = mstate->hi;
 
99
        else if(rn == 35) /* Bad Vaddr */
 
100
                v = mstate->cp0[8];
 
101
        else if(rn == 36) /* Cause */
 
102
                v = mstate->cp0[13];
 
103
        else if(rn == 37)
 
104
                v = mstate->pc;
 
105
        else if(rn >= 38 && rn < 70)
 
106
                v = mstate->fpr[rn];                    
 
107
        else if(rn == 70 || rn == 71 || rn == 72) /* fsr, fir, fp */
 
108
                ; /* do nothing */
 
109
 
 
110
        tomem (memory, v);
 
111
        return 0;
 
112
}
 
113
 
 
114
 
 
115
/*
 
116
 * register powerpc register type to the array
 
117
 */
 
118
void init_mips_register_defs(void){
 
119
        /* initialize the struct of powerpc register defination */
 
120
        static register_defs_t mips_reg_defs;
 
121
        mips_reg_defs.name = "mips";
 
122
        mips_reg_defs.register_raw_size = mips_register_raw_size;
 
123
        mips_reg_defs.register_bytes = (32 + 6 + 32 + 3)*4;     
 
124
        mips_reg_defs.register_byte = mips_register_byte;
 
125
        mips_reg_defs.num_regs = 73; /* the total number of mips register is 73 */
 
126
        mips_reg_defs.max_register_raw_size = 4;
 
127
        mips_reg_defs.store_register = mips_store_register;
 
128
        mips_reg_defs.fetch_register = mips_fetch_register;
 
129
        
 
130
        register_reg_type(&mips_reg_defs);
 
131
}