Revision 1a14026e target-sparc/cpu.h

b/target-sparc/cpu.h
170 170
#define PG_MODIFIED_MASK (1 << PG_MODIFIED_BIT)
171 171
#define PG_CACHE_MASK    (1 << PG_CACHE_BIT)
172 172

  
173
/* 2 <= NWINDOWS <= 32. In QEMU it must also be a power of two. */
174
#define NWINDOWS  8
173
/* 3 <= NWINDOWS <= 32. */
174
#define MIN_NWINDOWS 3
175
#define MAX_NWINDOWS 32
175 176

  
176 177
#if !defined(TARGET_SPARC64)
177 178
#define NB_MMU_MODES 2
......
222 223
    uint32_t mmu_cxr_mask;
223 224
    uint32_t mmu_sfsr_mask;
224 225
    uint32_t mmu_trcr_mask;
226
    uint32_t nwindows;
225 227
    /* NOTE: we allow 8 more registers to handle wrapping */
226
    target_ulong regbase[NWINDOWS * 16 + 8];
228
    target_ulong regbase[MAX_NWINDOWS * 16 + 8];
227 229

  
228 230
    CPU_COMMON
229 231

  
......
330 332

  
331 333
#ifndef NO_CPU_IO_DEFS
332 334
void cpu_set_cwp(CPUSPARCState *env1, int new_cwp);
335

  
336
static inline int cpu_cwp_inc(CPUSPARCState *env1, int cwp)
337
{
338
    if (unlikely(cwp >= env1->nwindows))
339
        cwp -= env1->nwindows;
340
    return cwp;
341
}
342

  
343
static inline int cpu_cwp_dec(CPUSPARCState *env1, int cwp)
344
{
345
    if (unlikely(cwp < 0))
346
        cwp += env1->nwindows;
347
    return cwp;
348
}
333 349
#endif
334 350

  
335 351
#define PUT_PSR(env, val) do { int _tmp = val;                          \
......
348 364
        env->xcc = (_tmp >> 4) << 20;                                   \
349 365
        env->psr = (_tmp & 0xf) << 20;                                  \
350 366
    } while (0)
351
#define GET_CWP64(env) (NWINDOWS - 1 - (env)->cwp)
352
#define PUT_CWP64(env, val) \
353
    cpu_set_cwp(env, NWINDOWS - 1 - ((val) & (NWINDOWS - 1)))
367
#define GET_CWP64(env) (env->nwindows - 1 - (env)->cwp)
368

  
369
static inline void PUT_CWP64(CPUSPARCState *env1, int cwp)
370
{
371
    if (unlikely(cwp >= env1->nwindows || cwp < 0))
372
        cwp = 0;
373
    cpu_set_cwp(env1, env1->nwindows - 1 - cwp);
374
}
354 375

  
355 376
#endif
356 377

  

Also available in: Unified diff