/[gxemul]/trunk/src/include/cpu_sparc.h
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/include/cpu_sparc.h

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

revision 24 by dpavlin, Mon Oct 8 16:19:56 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 2  Line 2 
2  #define CPU_SPARC_H  #define CPU_SPARC_H
3    
4  /*  /*
5   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2007  Anders Gavare.  All rights reserved.
6   *   *
7   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
8   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 28  Line 28 
28   *  SUCH DAMAGE.   *  SUCH DAMAGE.
29   *   *
30   *   *
31   *  $Id: cpu_sparc.h,v 1.38 2006/05/18 05:10:44 debug Exp $   *  $Id: cpu_sparc.h,v 1.48 2007/06/07 15:36:25 debug Exp $
32   */   */
33    
34  #include "misc.h"  #include "misc.h"
35    
36    
37  struct cpu_family;  struct cpu_family;
38    struct timer;
39    
40    
41  /*  SPARC CPU types:  */  /*  SPARC CPU types:  */
42  struct sparc_cpu_type_def {  struct sparc_cpu_type_def {
43          char            *name;          char            *name;
44          int             bits;          int             v;                      /*  v8, v9 etc  */
45            int             h;                      /*  hypervisor? sun4v = 1  */
46            int             bits;                   /*  32 or 64  */
47            int             nwindows;               /*  usually 8 or more  */
48          int             icache_shift;          int             icache_shift;
49          int             ilinesize;          int             ilinesize;
50          int             iway;          int             iway;
# Line 52  struct sparc_cpu_type_def { Line 56  struct sparc_cpu_type_def {
56          int             l2way;          int             l2way;
57  };  };
58    
59    /*  NOTE/TODO: Maybe some of the types listed below as v8 are in
60        fact v7; I haven't had time to check. Also, the nwindows value is
61        just bogus.  */
62    /*  See http://www.sparc.com/standards/v8v9-numbers.html for
63        implementation numbers!  */
64    /*  Note/TODO: sun4v is listed as 10  */
65    
66  #define SPARC_CPU_TYPE_DEFS     {                                       \  #define SPARC_CPU_TYPE_DEFS     {                                       \
67          { "TMS390Z50",          32, 14,5,2, 14,5,2,  0,0,0 },           \          { "TMS390Z50",          8, 0, 32, 8, 14,5,2, 14,5,2,  0,0,0 },  \
68          { "MB86904",            32, 14,5,2, 13,4,2,  0,0,0 },           \          { "MB86904",            8, 0, 32, 8, 14,5,2, 13,4,2,  0,0,0 },  \
69          { "MB86907",            32, 14,5,2, 14,5,2, 19,5,1 },           \          { "MB86907",            8, 0, 32, 8, 14,5,2, 14,5,2, 19,5,1 },  \
70          { "UltraSPARC",         64, 14,5,4, 14,5,4, 19,6,1 },           \          { "UltraSPARC",         9, 0, 64, 8, 14,5,4, 14,5,4, 19,6,1 },  \
71          { "UltraSPARC-IIi",     64, 15,5,2, 14,5,2, 21,6,1 },           \          { "UltraSPARC-IIi",     9, 0, 64, 8, 15,5,2, 14,5,2, 21,6,1 },  \
72          { "UltraSPARC-II",      64, 15,5,2, 14,5,2, 22,6,1 },           \          { "UltraSPARC-II",      9, 0, 64, 8, 15,5,2, 14,5,2, 22,6,1 },  \
73          { NULL,                 0,  0,0,0,  0,0,0,   0,0,0 }            \          { "T1",                 9, 1, 64, 8, 15,5,2, 14,5,2, 22,6,1 },  \
74            { NULL,                 0, 0,  0, 0,  0,0,0,  0,0,0,  0,0,0 }   \
75          }          }
76    
77    
# Line 83  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC Line 95  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC
95    
96    
97  #define N_SPARC_REG             32  #define N_SPARC_REG             32
98    #define N_SPARC_GLOBAL_REG      8
99    #define N_SPARC_INOUT_REG       8
100    #define N_SPARC_LOCAL_REG       8
101  #define SPARC_REG_NAMES {                               \  #define SPARC_REG_NAMES {                               \
102          "g0","g1","g2","g3","g4","g5","g6","g7",        \          "g0","g1","g2","g3","g4","g5","g6","g7",        \
103          "o0","o1","o2","o3","o4","o5","sp","o7",        \          "o0","o1","o2","o3","o4","o5","sp","o7",        \
# Line 128  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC Line 143  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC
143  #define SPARC_PREG_NAMES        {                                       \  #define SPARC_PREG_NAMES        {                                       \
144          "tpc", "tnpc", "tstate", "tt", "tick", "tba", "pstate", "tl",   \          "tpc", "tnpc", "tstate", "tt", "tick", "tba", "pstate", "tl",   \
145          "pil", "cwp", "cansave", "canrestore", "cleanwin", "otherwin",  \          "pil", "cwp", "cansave", "canrestore", "cleanwin", "otherwin",  \
146          "wstate", "reserved15", "reserved16", "reserved17", "reserved18", \          "wstate", "fq", "reserved16", "reserved17", "reserved18", \
147          "reserved19", "reserved20", "reserved21", "reserved22", \          "reserved19", "reserved20", "reserved21", "reserved22", \
148          "reserved23", "reserved24", "reserved25", "reserved26", \          "reserved23", "reserved24", "reserved25", "reserved26", \
149          "reserved27", "reserved28", "reserved29", "reserved30", \          "reserved27", "reserved28", "reserved29", "reserved30", \
150          "reserved31" }          "ver" }
151    
152  #define N_SPARC_BRANCH_TYPES    16  #define N_SPARC_BRANCH_TYPES    16
153  #define SPARC_BRANCH_NAMES {                                            \  #define SPARC_BRANCH_NAMES {                                            \
# Line 158  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC Line 173  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC
173    
174  #define N_LOADSTORE_TYPES       64  #define N_LOADSTORE_TYPES       64
175  #define SPARC_LOADSTORE_NAMES {                                         \  #define SPARC_LOADSTORE_NAMES {                                         \
176          "ld","ldub","lduh","ldd", "st","stb","sth","std",               \          "lduw","ldub","lduh","ldd", "st","stb","sth","std",             \
177          "[8]","ldsb","ldsh","ldx", "[12]","ldstub","stx","swap",        \          "ldsw","ldsb","ldsh","ldx", "[12]","ldstub","stx","swap",       \
178          "lda","lduba","lduha","ldda", "sta","stba","stha","stda",       \          "lda","lduba","lduha","ldda", "sta","stba","stha","stda",       \
179          "[24]","ldsba","ldsha","ldxa", "[28]","ldstuba","stxa","swapa",  \          "[24]","ldsba","ldsha","ldxa", "[28]","ldstuba","stxa","swapa",  \
180          "ldf","ldfsr","[34]","lddf", "stf","stfsr","stdfq","stdf",      \          "ldf","ldfsr","[34]","lddf", "stf","stfsr","stdfq","stdf",      \
# Line 168  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC Line 183  DYNTRANS_MISC64_DECLARATIONS(sparc,SPARC
183          "[56]","[57]","[58]","[59]", "[60]","prefetcha","casxa","[63]" }          "[56]","[57]","[58]","[59]", "[60]","prefetcha","casxa","[63]" }
184    
185    
186  /*  Max number of Trap Levels and Windows:  */  /*  Max number of Trap Levels, Global Levels, and Register Windows:  */
187  #define MAXTL                   4  #define MAXTL                   6
188  #define MAXWIN                  32  #define MAXGL                   7
189    #define N_REG_WINDOWS           8
190    
191    
192  struct sparc_cpu {  struct sparc_cpu {
# Line 179  struct sparc_cpu { Line 195  struct sparc_cpu {
195          /*  Registers in the Current Window:  */          /*  Registers in the Current Window:  */
196          uint64_t        r[N_SPARC_REG];          uint64_t        r[N_SPARC_REG];
197    
198            uint64_t        r_inout[N_REG_WINDOWS][N_SPARC_INOUT_REG];
199            uint64_t        r_local[N_REG_WINDOWS][N_SPARC_LOCAL_REG];
200    
201            uint64_t        r_global[MAXGL+1][N_SPARC_GLOBAL_REG];
202    
203          uint64_t        scratch;          uint64_t        scratch;
204    
205          /*  Pre-SPARCv9 specific:  */          /*  Pre-SPARCv9 specific:  */
# Line 205  struct sparc_cpu { Line 226  struct sparc_cpu {
226          uint8_t         ccr;            /*  Condition Code Register  */          uint8_t         ccr;            /*  Condition Code Register  */
227          uint8_t         asi;            /*  Address Space Identifier  */          uint8_t         asi;            /*  Address Space Identifier  */
228          uint8_t         tl;             /*  Trap Level Register  */          uint8_t         tl;             /*  Trap Level Register  */
229            uint8_t         gl;             /*  Global Level Register  */
230          uint8_t         pil;            /*  Processor Interrupt Level Reg.  */          uint8_t         pil;            /*  Processor Interrupt Level Reg.  */
231    
232          uint64_t        tpc[MAXTL];     /*  Trap Program Counter  */          uint64_t        tpc[MAXTL];     /*  Trap Program Counter  */
# Line 214  struct sparc_cpu { Line 236  struct sparc_cpu {
236    
237          uint64_t        tba;            /*  Trap Base Address  */          uint64_t        tba;            /*  Trap Base Address  */
238    
239            uint64_t        hpstate;        /*  Hyper-Privileged State Register  */
240            uint64_t        htstate[MAXTL]; /*  Hyper-Privileged Trap State  */
241            uint64_t        hintp;          /*  Hyper-Privileged InterruptPending */
242            uint64_t        htba;           /*  Hyper-Privileged Trap Base Addr  */
243            uint64_t        hver;           /*  Hyper-Privileged Version Reg.  */
244    
245    
246          /*          /*
247           *  Instruction translation cache and Virtual->Physical->Host           *  Instruction translation cache and Virtual->Physical->Host
248           *  address translation:           *  address translation:
249           */           */
250          DYNTRANS_ITC(sparc)          DYNTRANS_ITC(sparc)
251          VPH_TLBS(sparc,SPARC)          VPH_TLBS(sparc,SPARC)
252          VPH32(sparc,SPARC,uint64_t,uint8_t)          VPH32(sparc,SPARC)
253          VPH64(sparc,SPARC,uint8_t)          VPH64(sparc,SPARC)
254  };  };
255    
256    
# Line 240  struct sparc_cpu { Line 269  struct sparc_cpu {
269  #define SPARC_PSTATE_AG         0x001   /*  Alternate Globals  */  #define SPARC_PSTATE_AG         0x001   /*  Alternate Globals  */
270    
271    
272    /*  Hyper-Privileged State Register (HPSTATE) bit definitions:  */
273    #define SPARC_HPSTATE_ID        0x800
274    #define SPARC_HPSTATE_IBE       0x400   /*  Instruction Break Enable  */
275    #define SPARC_HPSTATE_RED       0x020   /*  Reset/Error/Debug state  */
276    #define SPARC_HPSTATE_HPRIV     0x004   /*  Hyper-Privileged mode  */
277    #define SPARC_HPSTATE_TLZ       0x001   /*  Trap Level Zero trap enable  */
278    
279    
280  /*  Condition Code Register bit definitions:  */  /*  Condition Code Register bit definitions:  */
281  #define SPARC_CCR_XCC_MASK      0xf0  #define SPARC_CCR_XCC_MASK      0xf0
282  #define SPARC_CCR_XCC_SHIFT     4  #define SPARC_CCR_XCC_SHIFT     4
# Line 302  struct sparc_cpu { Line 339  struct sparc_cpu {
339    
340  /*  cpu_sparc.c:  */  /*  cpu_sparc.c:  */
341  int sparc_cpu_instruction_has_delayslot(struct cpu *cpu, unsigned char *ib);  int sparc_cpu_instruction_has_delayslot(struct cpu *cpu, unsigned char *ib);
342    int sparc_run_instr(struct cpu *cpu);
343  void sparc_update_translation_table(struct cpu *cpu, uint64_t vaddr_page,  void sparc_update_translation_table(struct cpu *cpu, uint64_t vaddr_page,
344          unsigned char *host_page, int writeflag, uint64_t paddr_page);          unsigned char *host_page, int writeflag, uint64_t paddr_page);
345  void sparc_invalidate_translation_caches(struct cpu *cpu, uint64_t, int);  void sparc_invalidate_translation_caches(struct cpu *cpu, uint64_t, int);
346  void sparc_invalidate_code_translation(struct cpu *cpu, uint64_t, int);  void sparc_invalidate_code_translation(struct cpu *cpu, uint64_t, int);
347    int sparc32_run_instr(struct cpu *cpu);
348  void sparc32_update_translation_table(struct cpu *cpu, uint64_t vaddr_page,  void sparc32_update_translation_table(struct cpu *cpu, uint64_t vaddr_page,
349          unsigned char *host_page, int writeflag, uint64_t paddr_page);          unsigned char *host_page, int writeflag, uint64_t paddr_page);
350  void sparc32_invalidate_translation_caches(struct cpu *cpu, uint64_t, int);  void sparc32_invalidate_translation_caches(struct cpu *cpu, uint64_t, int);
351  void sparc32_invalidate_code_translation(struct cpu *cpu, uint64_t, int);  void sparc32_invalidate_code_translation(struct cpu *cpu, uint64_t, int);
352  void sparc_init_64bit_dummy_tables(struct cpu *cpu);  void sparc_init_64bit_dummy_tables(struct cpu *cpu);
353    void sparc_timer_sample_tick(struct timer *, void *);
354  int sparc_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr,  int sparc_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr,
355          unsigned char *data, size_t len, int writeflag, int cache_flags);          unsigned char *data, size_t len, int writeflag, int cache_flags);
356  int sparc_cpu_family_init(struct cpu_family *);  int sparc_cpu_family_init(struct cpu_family *);
357    
358    /*  memory_sparc.c:  */
359    int sparc_translate_v2p(struct cpu *cpu, uint64_t vaddr,
360            uint64_t *return_addr, int flags);
361    
362    
363  #endif  /*  CPU_SPARC_H  */  #endif  /*  CPU_SPARC_H  */

Legend:
Removed from v.24  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26