Line 1... |
Line 1... |
/* $Id: msr.hh,v 1.8 2008-04-27 16:33:42 sybreon Exp $
|
/* $Id: msr.hh,v 1.9 2008-04-28 20:29:15 sybreon Exp $
|
**
|
**
|
** AEMB2 HI-PERFORMANCE CPU
|
** AEMB2 HI-PERFORMANCE CPU
|
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap
|
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap
|
**
|
**
|
** This file is part of AEMB.
|
** This file is part of AEMB.
|
Line 25... |
Line 25... |
|
|
These functions provide read/write access to the Machine Status
|
These functions provide read/write access to the Machine Status
|
Register. It also contains the bit definitions of the register.
|
Register. It also contains the bit definitions of the register.
|
*/
|
*/
|
|
|
#ifndef AEMB_MSR_HH
|
#ifndef _AEMB_MSR_HH
|
#define AEMB_MSR_HH
|
#define _AEMB_MSR_HH
|
|
|
// STANDARD BITS
|
// STANDARD BITS
|
#define MSR_BE (1 << 0) ///< Buslock Enable
|
#define AEMB_MSR_BE (1 << 0) ///< Buslock Enable
|
#define MSR_IE (1 << 1) ///< Interrupt Enable
|
#define AEMB_MSR_IE (1 << 1) ///< Interrupt Enable
|
#define MSR_C (1 << 2) ///< Arithmetic Carry
|
#define AEMB_MSR_C (1 << 2) ///< Arithmetic Carry
|
#define MSR_BIP (1 << 3) ///< Break in Progress
|
#define AEMB_MSR_BIP (1 << 3) ///< Break in Progress
|
|
|
#define MSR_ICE (1 << 5) ///< Instruction Cache Enable
|
#define AEMB_MSR_ITE (1 << 5) ///< Instruction Cache Enable
|
#define MSR_DZ (1 << 6) ///< Division by Zero
|
#define AEMB_MSR_DZ (1 << 6) ///< Division by Zero
|
#define MSR_DCE (1 << 7) ///< Data Cache Enable
|
#define AEMB_MSR_DTE (1 << 7) ///< Data Cache Enable
|
|
|
// CUSTOM BITS
|
// CUSTOM BITS
|
#define MSR_MTX (1 << 4) ///< Hardware Mutex
|
#define AEMB_MSR_MTX (1 << 4) ///< Hardware Mutex
|
#define MSR_PHA (1 << 29) ///< Hardware Thread Phase
|
#define AEMB_MSR_PHA (1 << 29) ///< Hardware Thread Phase
|
#define MSR_HTX (1 << 30) ///< Hardware Threads Extension
|
#define AEMB_MSR_HTX (1 << 30) ///< Hardware Threads Extension
|
#define MSR_CC (1 << 31) ///< Carry Copy
|
#define AEMB_MSR_CC (1 << 31) ///< Carry Copy
|
|
|
#ifdef __cplusplus
|
#ifdef __cplusplus
|
namespace aemb {
|
extern "C" {
|
#endif
|
#endif
|
|
|
/**
|
/**
|
Read the value of the MSR register
|
Read the value of the MSR register
|
@return register contents
|
@return register contents
|
*/
|
*/
|
|
|
inline int getMSR()
|
inline int aembGetMSR()
|
{
|
{
|
int rmsr;
|
int rmsr;
|
asm volatile ("mfs %0, rmsr":"=r"(rmsr));
|
asm volatile ("mfs %0, rmsr":"=r"(rmsr));
|
return rmsr;
|
return rmsr;
|
}
|
}
|
Line 65... |
Line 65... |
/**
|
/**
|
Write a value to the MSR register
|
Write a value to the MSR register
|
@param rmsr value to write
|
@param rmsr value to write
|
*/
|
*/
|
|
|
inline void putMSR(int rmsr)
|
inline void aembPutMSR(int rmsr)
|
{
|
{
|
asm volatile ("mts rmsr, %0"::"r"(rmsr));
|
asm volatile ("mts rmsr, %0"::"r"(rmsr));
|
}
|
}
|
|
|
/**
|
/**
|
Read and clear the MSR
|
Read and clear the MSR
|
@param rmsk clear mask
|
@param rmsk clear mask
|
@return msr value
|
@return msr value
|
*/
|
*/
|
|
|
inline int clrMSR(const short rmsk)
|
inline int aembClrMSR(const short rmsk)
|
{
|
{
|
int tmp;
|
int tmp;
|
//asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(rmsk):"memory");
|
//asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(rmsk):"memory");
|
return tmp;
|
return tmp;
|
}
|
}
|
Line 89... |
Line 89... |
Read and set the MSR
|
Read and set the MSR
|
@param rmsk set mask
|
@param rmsk set mask
|
@return msr value
|
@return msr value
|
*/
|
*/
|
|
|
inline int setMSR(const short rmsk)
|
inline int aembSetMSR(const short rmsk)
|
{
|
{
|
int tmp;
|
int tmp;
|
//asm volatile ("msrset %0, %1":"=r"(tmp):"K"(rmsk):"memory");
|
//asm volatile ("msrset %0, %1":"=r"(tmp):"K"(rmsk):"memory");
|
return tmp;
|
return tmp;
|
}
|
}
|
|
|
/** Enable global interrupts */
|
/** Enable global interrupts */
|
inline void enableInterrupts()
|
inline int aembEnableInterrupts()
|
{
|
{
|
asm volatile ("msrset r0, %0"::"K"(MSR_IE):"memory");
|
int msr;
|
|
asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_IE));
|
|
return msr;
|
}
|
}
|
|
|
/** Disable global interrupts */
|
/** Disable global interrupts */
|
inline void disableInterrupts()
|
inline int aembDisableInterrupts()
|
{
|
{
|
asm volatile ("msrclr r0, %0"::"K"(MSR_IE));
|
int msr;
|
|
asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_IE));
|
|
return msr;
|
}
|
}
|
|
|
/** Enable data caches */
|
/** Enable data caches */
|
inline void enableDataCache()
|
inline int aembEnableDataTag()
|
{
|
{
|
asm volatile ("msrset r0, %0"::"K"(MSR_DCE));
|
int msr;
|
|
asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_DTE));
|
|
return msr;
|
}
|
}
|
|
|
/** Disable data caches */
|
/** Disable data caches */
|
inline void disableDataCache()
|
inline int aembDisableDataTag()
|
{
|
{
|
asm volatile ("msrclr r0, %0"::"K"(MSR_DCE));
|
int msr;
|
|
asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_DTE));
|
|
return msr;
|
}
|
}
|
|
|
/** Enable inst caches */
|
/** Enable inst caches */
|
inline void enableInstCache()
|
inline int aembEnableInstTag()
|
{
|
{
|
asm volatile ("msrset r0, %0"::"K"(MSR_ICE));
|
int msr;
|
|
asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_ITE));
|
|
return msr;
|
}
|
}
|
|
|
/** Disable inst caches */
|
/** Disable inst caches */
|
inline void disableInstCache()
|
inline int aembDisableInstTag()
|
{
|
{
|
asm volatile ("msrclr r0, %0"::"K"(MSR_ICE));
|
int msr;
|
|
asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_ITE));
|
|
return msr;
|
}
|
}
|
|
|
#ifdef __cplusplus
|
#ifdef __cplusplus
|
}
|
}
|
#endif
|
#endif
|
|
|
#endif
|
#endif
|
|
|
/*
|
/*
|
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
|
Revision 1.8 2008/04/27 16:33:42 sybreon
|
|
License change to GPL3.
|
|
|
Revision 1.7 2008/04/26 19:31:35 sybreon
|
Revision 1.7 2008/04/26 19:31:35 sybreon
|
Made headers C compatible.
|
Made headers C compatible.
|
|
|
Revision 1.6 2008/04/26 18:05:22 sybreon
|
Revision 1.6 2008/04/26 18:05:22 sybreon
|
Minor cosmetic changes.
|
Minor cosmetic changes.
|