/[dynamips]/trunk/utils.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/utils.h

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

upstream/dynamips-0.2.6-RC4/utils.h revision 5 by dpavlin, Sat Oct 6 16:08:03 2007 UTC upstream/dynamips-0.2.7-RC3/utils.h revision 9 by dpavlin, Sat Oct 6 16:26:06 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco 7200 (Predator) simulation platform.   * Cisco router simulation platform.
3   * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)   * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4   */   */
5    
# Line 22  Line 22 
22  #define TRUE  1  #define TRUE  1
23  #endif  #endif
24    
25    /* Host CPU Types */
26    #define CPU_x86    0
27    #define CPU_amd64  1
28    #define CPU_nojit  2
29    
30    /* Number of host registers available for JIT */
31    #if JIT_CPU == CPU_x86
32    #define JIT_HOST_NREG  8
33    #elif JIT_CPU == CPU_amd64
34    #define JIT_HOST_NREG  16
35    #else
36    #define JIT_HOST_NREG  0
37    #endif
38    
39  /* Endianness */  /* Endianness */
40  #define ARCH_BIG_ENDIAN     0x4321  #define ARCH_BIG_ENDIAN     0x4321
41  #define ARCH_LITTLE_ENDIAN  0x1234  #define ARCH_LITTLE_ENDIAN  0x1234
# Line 99  typedef unsigned long m_iptr_t; Line 113  typedef unsigned long m_iptr_t;
113  typedef m_uint64_t m_tmcnt_t;  typedef m_uint64_t m_tmcnt_t;
114    
115  /* Forward declarations */  /* Forward declarations */
116    typedef struct cpu_gen cpu_gen_t;
117  typedef struct vm_instance vm_instance_t;  typedef struct vm_instance vm_instance_t;
118  typedef struct insn_block insn_block_t;  typedef struct mips64_jit_tcb mips64_jit_tcb_t;
119    typedef struct ppc32_jit_tcb ppc32_jit_tcb_t;
120    typedef struct jit_op jit_op_t;
121    
122    /* Translated block function pointer */
123    typedef void (*insn_tblock_fptr)(void);
124    
125    /* Host executable page */
126  typedef struct insn_exec_page insn_exec_page_t;  typedef struct insn_exec_page insn_exec_page_t;
127    struct insn_exec_page {
128       u_char *ptr;
129       insn_exec_page_t *next;
130    };
131    
132  /* MIPS instruction */  /* MIPS instruction */
133  typedef m_uint32_t mips_insn_t;  typedef m_uint32_t mips_insn_t;
134    
135    /* PowerPC instruction */
136    typedef m_uint32_t ppc_insn_t;
137    
138  /* Max and min macro */  /* Max and min macro */
139  #define m_max(a,b) (((a) > (b)) ? (a) : (b))  #define m_max(a,b) (((a) > (b)) ? (a) : (b))
140  #define m_min(a,b) (((a) < (b)) ? (a) : (b))  #define m_min(a,b) (((a) < (b)) ? (a) : (b))
# Line 140  typedef struct { Line 169  typedef struct {
169     m_uint32_t tlb_index;     m_uint32_t tlb_index;
170  }mts_map_t;  }mts_map_t;
171    
172    /* Invalid VTLB entry */
173    #define MTS_INV_ENTRY_MASK  0x00000001
174    
175    /* MTS entry flags */
176    #define MTS_FLAG_DEV   0x000000001   /* Virtual device used */
177    #define MTS_FLAG_COW   0x000000002   /* Copy-On-Write */
178    #define MTS_FLAG_EXEC  0x000000004   /* Exec page */
179    
180    /* Virtual TLB entry (32-bit MMU) */
181    typedef struct mts32_entry mts32_entry_t;
182    struct mts32_entry {
183       m_uint32_t gvpa;   /* Guest Virtual Page Address */
184       m_uint32_t gppa;   /* Guest Physical Page Address */
185       m_iptr_t   hpa;    /* Host Page Address */
186       m_uint32_t flags;  /* Flags */
187    }__attribute__ ((aligned(16)));
188    
189    /* Virtual TLB entry (64-bit MMU) */
190    typedef struct mts64_entry mts64_entry_t;
191    struct mts64_entry {
192       m_uint64_t gvpa;   /* Guest Virtual Page Address */
193       m_uint64_t gppa;   /* Guest Physical Page Address */
194       m_iptr_t   hpa;    /* Host Page Address */
195       m_uint32_t flags;  /* Flags */
196    }__attribute__ ((aligned(16)));
197    
198    /* Host register allocation */
199    #define HREG_FLAG_ALLOC_LOCKED  1
200    #define HREG_FLAG_ALLOC_FORCED  2
201    
202    struct hreg_map {
203       int hreg,vreg;
204       int flags;
205       struct hreg_map *prev,*next;
206    };
207    
208  /* Global logfile */  /* Global logfile */
209  extern FILE *log_file;  extern FILE *log_file;
210    
# Line 165  static forced_inline m_int64_t sign_exte Line 230  static forced_inline m_int64_t sign_exte
230     return (x << len) >> len;     return (x << len) >> len;
231  }  }
232    
233    /* Sign-extension (32-bit) */
234    static forced_inline m_int32_t sign_extend_32(m_int32_t x,int len)
235    {
236       len = 32 - len;
237       return (x << len) >> len;
238    }
239    
240  /* Extract bits from a 32-bit values */  /* Extract bits from a 32-bit values */
241  static inline int bits(m_uint32_t val,int start,int end)  static inline int bits(m_uint32_t val,int start,int end)
242  {  {
# Line 311  int memzone_open_file(char *filename,u_c Line 383  int memzone_open_file(char *filename,u_c
383  /* Compute NVRAM checksum */  /* Compute NVRAM checksum */
384  m_uint16_t nvram_cksum(m_uint16_t *ptr,size_t count);  m_uint16_t nvram_cksum(m_uint16_t *ptr,size_t count);
385    
386    /* Byte-swap a memory block */
387    void mem_bswap32(void *ptr,size_t len);
388    
389    /* Reverse a byte */
390    m_uint8_t m_reverse_u8(m_uint8_t val);
391    
392  #endif  #endif

Legend:
Removed from v.5  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26