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 |
|
|
100 |
|
|
101 |
/* Forward declarations */ |
/* Forward declarations */ |
102 |
typedef struct vm_instance vm_instance_t; |
typedef struct vm_instance vm_instance_t; |
103 |
typedef struct insn_block insn_block_t; |
typedef struct mips64_jit_tcb mips64_jit_tcb_t; |
104 |
|
typedef struct ppc32_jit_tcb ppc32_jit_tcb_t; |
105 |
|
|
106 |
|
/* Translated block function pointer */ |
107 |
|
typedef void (*insn_tblock_fptr)(void); |
108 |
|
|
109 |
|
/* Host executable page */ |
110 |
typedef struct insn_exec_page insn_exec_page_t; |
typedef struct insn_exec_page insn_exec_page_t; |
111 |
|
struct insn_exec_page { |
112 |
|
u_char *ptr; |
113 |
|
insn_exec_page_t *next; |
114 |
|
}; |
115 |
|
|
116 |
/* MIPS instruction */ |
/* MIPS instruction */ |
117 |
typedef m_uint32_t mips_insn_t; |
typedef m_uint32_t mips_insn_t; |
118 |
|
|
119 |
|
/* PowerPC instruction */ |
120 |
|
typedef m_uint32_t ppc_insn_t; |
121 |
|
|
122 |
/* Max and min macro */ |
/* Max and min macro */ |
123 |
#define m_max(a,b) (((a) > (b)) ? (a) : (b)) |
#define m_max(a,b) (((a) > (b)) ? (a) : (b)) |
124 |
#define m_min(a,b) (((a) < (b)) ? (a) : (b)) |
#define m_min(a,b) (((a) < (b)) ? (a) : (b)) |
153 |
m_uint32_t tlb_index; |
m_uint32_t tlb_index; |
154 |
}mts_map_t; |
}mts_map_t; |
155 |
|
|
156 |
|
/* Invalid VTLB entry */ |
157 |
|
#define MTS_INV_ENTRY_MASK 0x00000001 |
158 |
|
|
159 |
|
/* MTS entry flags */ |
160 |
|
#define MTS_FLAG_DEV 0x000000001 /* Virtual device used */ |
161 |
|
#define MTS_FLAG_COW 0x000000002 /* Copy-On-Write */ |
162 |
|
|
163 |
|
/* Virtual TLB entry (32-bit MMU) */ |
164 |
|
typedef struct mts32_entry mts32_entry_t; |
165 |
|
struct mts32_entry { |
166 |
|
m_uint32_t gvpa; /* Guest Virtual Page Address */ |
167 |
|
m_uint32_t gppa; /* Guest Physical Page Address */ |
168 |
|
m_iptr_t hpa; /* Host Page Address */ |
169 |
|
m_uint32_t flags; /* Flags */ |
170 |
|
}__attribute__ ((aligned(16))); |
171 |
|
|
172 |
|
/* Virtual TLB entry (64-bit MMU) */ |
173 |
|
typedef struct mts64_entry mts64_entry_t; |
174 |
|
struct mts64_entry { |
175 |
|
m_uint64_t gvpa; /* Guest Virtual Page Address */ |
176 |
|
m_uint64_t gppa; /* Guest Physical Page Address */ |
177 |
|
m_iptr_t hpa; /* Host Page Address */ |
178 |
|
m_uint32_t flags; /* Flags */ |
179 |
|
}__attribute__ ((aligned(16))); |
180 |
|
|
181 |
/* Global logfile */ |
/* Global logfile */ |
182 |
extern FILE *log_file; |
extern FILE *log_file; |
183 |
|
|
203 |
return (x << len) >> len; |
return (x << len) >> len; |
204 |
} |
} |
205 |
|
|
206 |
|
/* Sign-extension (32-bit) */ |
207 |
|
static forced_inline m_int32_t sign_extend_32(m_int32_t x,int len) |
208 |
|
{ |
209 |
|
len = 32 - len; |
210 |
|
return (x << len) >> len; |
211 |
|
} |
212 |
|
|
213 |
/* Extract bits from a 32-bit values */ |
/* Extract bits from a 32-bit values */ |
214 |
static inline int bits(m_uint32_t val,int start,int end) |
static inline int bits(m_uint32_t val,int start,int end) |
215 |
{ |
{ |
356 |
/* Compute NVRAM checksum */ |
/* Compute NVRAM checksum */ |
357 |
m_uint16_t nvram_cksum(m_uint16_t *ptr,size_t count); |
m_uint16_t nvram_cksum(m_uint16_t *ptr,size_t count); |
358 |
|
|
359 |
|
/* Byte-swap a memory block */ |
360 |
|
void mem_bswap32(void *ptr,size_t len); |
361 |
|
|
362 |
#endif |
#endif |