solo_page.h 4.37 KB
/********************************************************************************
 * PAGE.H  header file for paging routines                                     *
 ******************************************************************************/

/*************************************************************************
 *                                                                       *
 *               Copyright (C) 1993-1998 Stanford University             *
 *                                                                       *
 *  These coded instructions, statements, and computer programs contain  *
 *  unpublished proprietary information of Stanford University, and      *
 *  are protected by Federal copyright law.  They may not be disclosed   *
 *  to third parties or copied or duplicated in any form, in whole or    *
 *  in part, without the prior written consent of Stanford University.   *
 *                                                                       *
 *************************************************************************/

#ifndef PAGE_H
#define PAGE_H

/* number of bins in tlb hash table  */
#define MAPPING_HASH_SIZE 8192	

#define SOLO_PAGE_SHIFT         12
#define SOLO_PAGE_SIZE          (1 << SOLO_PAGE_SHIFT)
#define SOLO_PAGE_OFFSET_MASK   (SOLO_PAGE_SIZE-1)
#define SOLO_PAGE_NUMBER_MASK   (~SOLO_PAGE_OFFSET_MASK)

#define SOLO_PAGE_SHIFT_LONG         12ULL
#define SOLO_PAGE_SIZE_LONG          (1ULL << SOLO_PAGE_SHIFT_LONG)
#define SOLO_PAGE_OFFSET_MASK_LONG   (SOLO_PAGE_SIZE_LONG-1ULL)
#define SOLO_PAGE_NUMBER_MASK_LONG   (~SOLO_PAGE_OFFSET_MASK_LONG)

typedef long long SoloPA;

#define SOLO_PA_ZERO_SIZE       24
#define SOLO_PA_NODE_SIZE        8       
#define SOLO_PA_SPACE_SIZE       3
#define SOLO_PA_OFFSET_SIZE     29

#define SOLO_PA_NODE_SHIFT      (SOLO_PA_OFFSET_SIZE+SOLO_PA_SPACE_SIZE)
#define SOLO_PA_SPACE_SHIFT     (SOLO_PA_OFFSET_SIZE)
#define SOLO_PA_OFFSET_SHIFT    0

#define SOLO_PA_NODE_MASK ((1LL << SOLO_PA_NODE_SIZE)-1)
#define SOLO_PA_SPACE_MASK ((1LL << SOLO_PA_SPACE_SIZE)-1)
#define SOLO_PA_OFFSET_MASK ((1LL << SOLO_PA_OFFSET_SIZE)-1)

#define SOLO_PA_NODE(_pa)   (((_pa)>>SOLO_PA_NODE_SHIFT)&SOLO_PA_NODE_MASK)
#define SOLO_PA_SPACE(_pa)  (((_pa)>>SOLO_PA_SPACE_SHIFT)&SOLO_PA_SPACE_MASK)
#define SOLO_PA_OFFSET(_pa)  (((_pa)>>SOLO_PA_OFFSET_SHIFT)&SOLO_PA_OFFSET_MASK)

#define SOLO_FORM_PA(_node,_space, _offset)  (((SoloPA)(_node)<<SOLO_PA_NODE_SHIFT) | \
                                              ((SoloPA)(_space)<<SOLO_PA_SPACE_SHIFT) | \
                                              ((SoloPA)(_offset)<<SOLO_PA_OFFSET_SHIFT))

/*
 * SoloCompressAddr - Compress a 64 bit solo physical address (SoloPA) into a 
 * 32bit physical address.
 * SoloDecompressAddr - And decompress it back.
 */

extern int soloPACompressNodeShift;
extern uint soloPACompressOffsetMask;
extern uint soloLockBase; 
extern uint soloBarrierBase; 
extern uint soloTotalMemory;

/* JH: Mendel wants me to reserve a range at the top of the VA space.  There, 
   addresses beginning at soloLockBase really are starting at zero in space 1.
   I convert back and forth when I cross the solo/flashlite boundary.
   7/22/97: now I reserve a second range starting at soloBarrierBase for
   space 2.  Ugh */

#ifdef T5_MODEL
/* In this mode, the addr is actually a 32 bit host addr.  DO NOTHING except
   convert to 32 bits!! Here, you see, I need to keep all 32 bits significant, 
   otherwise I can't use the addresses: consider the stack pointer as an example*/
#define SoloCompressAddr(_soloPA)    ((PA) _soloPA) 
#define SoloDecompressAddr(_space,_pa) ((SoloPA) _pa)
#else
#define SoloCompressAddr(_soloPA)    (((PA)SOLO_PA_NODE(_soloPA)<<soloPACompressNodeShift)| \
                                      (PA)SOLO_PA_OFFSET(_soloPA))
#define SoloDecompressAddr(_space,_pa)      SOLO_FORM_PA((_pa)>>soloPACompressNodeShift,(_space),\
                                                         (_pa)&soloPACompressOffsetMask)
#endif

extern void SoloInitPageTranslation(void);

extern char *SoloGetMemoryAddr(SoloPA p_addr);
extern void SoloEstablishMapping(SoloPA pa, VA va, int space, uint flavor);
extern SoloPA SoloV_to_P(int proc, VA va,int clus, bool isFrame, uint *flavor);
extern bool SoloPageHasBeenMapped(VA va);
extern void Solosys_place_range(VA start, VA stop, int node);

#define VIRTUAL_MSG_MASK 0x80000000
/*  Top nibble specifies VIRTUAL address space mapping */

#endif /* page.h */