mem_control.h 2.54 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */

#ifndef MEM_DRIVER_H
#define MEM_DRIVER_H

#ifndef _LANGUAGE_ASSEMBLY
#include "machine_params.h"
#endif

/* #define STATIC_SCACHE_PARAMS  */
#ifdef STATIC_SCACHE_PARAMS
#define SCACHE_SIZE          (1024*1024)
#define log2SCACHE_SIZE      (20)
#define SCACHE_LINE_SIZE     (128)
#define log2SCACHE_LINE_SIZE (7)
#define SCACHE_ASSOC         (1)
#define log2SCACHE_ASSOC     (0)
#endif

#define LINES_PER_PAGE (DEFAULT_PAGESZ >> log2SCACHE_LINE_SIZE)
#define LINES_PER_CACHE (SCACHE_ASSOC*(1<<(log2SCACHE_SIZE - log2SCACHE_LINE_SIZE)))
#define ADDR2SLINE(_addr) (((VA)(_addr)) >> log2SCACHE_LINE_SIZE)
#define SLINE2ADDR(_addr) ((VA)(_addr) << log2SCACHE_LINE_SIZE)
#define SCACHE_TAG(_a) ((VA)(_a)>>(log2SCACHE_SIZE - log2SCACHE_ASSOC))
#define SCACHE_INDEXOF(_a) (((VA)(_a) >> log2SCACHE_LINE_SIZE) & (SCACHE_INDEX-1))

#define TLBENT2SLINE(_ent) ADDR2SLINE(TLBHI2ADDR(_ent))
#define INVALID_PLN(_m) (ADDR2SLINE(MEM_SIZE(_m))+1)

#ifndef _LANGUAGE_ASSEMBLY

C_LINK MA  mem_ref( VA, EmVQCMemState new_state, int cpuNum );
/* Essentially to allow access to text segment.  It handles jumps to */
/* backdoor code */
extern PA  mem_translate( int cpuNum, VA );


/*
 * TC-coherence check + handle in case of conflict
 */

extern int EmbraTCCoherenceCheck(int cpuNum, VA vAddr, PA pAddr, PA end);



/* remap regions:  the low pages of the physical address space on
 * every node are remapped.  When a cpu accesses a low address, it
 * gets the data from that offset into its node.
 *
 * Functions that control remap are in simos_interface.c.
 *
 * Warning: the K0_TO_PHYS_REMAP macro expects a k0 argument.  If you
 * pass it a zero argument (eg. a quick check miss) it will be remapped
 * and look like a quick check hit.
 */

#ifdef DEBUG_TRANSLATOR
#define K0_TO_PHYS_REMAP(k0a,cpunum) K0_TO_PHYS(k0a)
#else
#define __EM_REMAP(paddr,cpunum)                                            \
   ( (PA)(paddr)+                                                          \
     ( ( (((PA)(paddr)) & remapVec->RemapMask[cpunum]) != 0 ||             \
	 !remapVec->RemapEnable[cpunum] ) ? 0 : remapVec->NodeAddr[cpunum] ) )
#define K0_TO_PHYS_REMAP(k0a,cpunum) __EM_REMAP(K0_TO_PHYS(k0a),cpunum)
#endif

#define MEMADDR_TO_PHYS_REMAP(mA,cpuNum) \
   (K0_TO_PHYS_REMAP(MEMADDR_TO_K0(M_FROM_CPU(cpuNum), mA),cpuNum))
#define REMAP_PHYS(pA,cpuNum) (__EM_REMAP(pA,cpuNum))
#endif /* _LANGUAGE_ASSEMBLY */

#endif