OpenCores
URL https://opencores.org/ocsvn/aemb/aemb/trunk

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [aemb/] [msr.hh] - Blame information for rev 137

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 137 sybreon
/* $Id: msr.hh,v 1.6 2008-04-26 18:05:22 sybreon Exp $
2 107 sybreon
**
3
** AEMB2 HI-PERFORMANCE CPU
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see .
20
*/
21
 
22
/**
23
   Basic MSR functions
24
   @file msr.hh
25 121 sybreon
 
26 107 sybreon
   These functions provide read/write access to the Machine Status
27
   Register. It also contains the bit definitions of the register.
28
 */
29
 
30
#ifndef AEMB_MSR_HH
31
#define AEMB_MSR_HH
32
 
33
namespace aemb {
34
 
35
  const int MSR_BE  = 0x00000001; ///< Buslock Enable
36
  const int MSR_IE  = 0x00000002; ///< Interrupt Enable
37
  const int MSR_C   = 0x00000004; ///< Arithmetic Carry
38
  const int MSR_BIP = 0x00000008; ///< Break in Progress
39
 
40 121 sybreon
  const int MSR_MTX = 0x00000010; ///< Hardware Mutex
41 107 sybreon
  const int MSR_ICE = 0x00000020; ///< Instruction Cache Enable
42
  const int MSR_DZ  = 0x00000040; ///< Division by Zero
43
  const int MSR_DCE = 0x00000080; ///< Data Cache Enable
44 121 sybreon
 
45
  //const int MSR_HTE = 0x10000000; ///< Hardware Threads Enable
46
  const int MSR_PHA = 0x20000000; ///< Hardware Thread Phase
47 114 sybreon
  const int MSR_HTX = 0x40000000; ///< Hardware Threads Extension
48 121 sybreon
  const int MSR_CC  = 0x80000004; ///< Carry Copy
49 107 sybreon
 
50
  /**
51 121 sybreon
     Read the value of the MSR register
52
     @return register contents
53 107 sybreon
  */
54
 
55
  inline int getMSR()
56
  {
57
    int rmsr;
58 109 sybreon
    asm volatile ("mfs %0, rmsr":"=r"(rmsr));
59 107 sybreon
    return rmsr;
60
  }
61
 
62
  /**
63 121 sybreon
     Write a value to the MSR register
64
     @param rmsr value to write
65 110 sybreon
  */
66 107 sybreon
 
67 121 sybreon
  inline void putMSR(int rmsr)
68 110 sybreon
  {
69
    asm volatile ("mts rmsr, %0"::"r"(rmsr));
70 109 sybreon
  }
71
 
72 121 sybreon
 
73
  /**
74
     Read and clear the MSR
75
     @param rmsk clear mask
76
     @return msr value
77
   */
78
  inline int clrMSR(const short rmsk)
79
  {
80
    int tmp;
81
    asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(rmsk));
82
    return tmp;
83
  }
84
 
85
  /**
86
     Read and set the MSR
87
     @param rmsk set mask
88
     @return msr value
89
   */
90
  inline int setMSR(const short rmsk)
91
  {
92
    int tmp;
93
    asm volatile ("msrset %0, %1":"=r"(tmp):"K"(rmsk));
94
    return tmp;
95
  }
96
 
97 110 sybreon
  /** Enable global interrupts */
98 121 sybreon
  inline void enableInterrupts()
99
  {
100
    putMSR(getMSR() | MSR_IE);
101
  }
102 109 sybreon
 
103 110 sybreon
  /** Disable global interrupts */
104 121 sybreon
  inline void disableInterrupts()
105
  {
106
    putMSR(getMSR() & ~MSR_IE);
107
  }
108 110 sybreon
 
109
  /** Enable data caches */
110 121 sybreon
  inline void enableDataCache()
111
  {
112
    putMSR(getMSR() | MSR_DCE);
113
  }
114 110 sybreon
 
115
  /** Disable data caches */
116 121 sybreon
  inline void disableDataCache()
117
  {
118
    putMSR(getMSR() & ~MSR_DCE);
119
  }
120 110 sybreon
 
121
  /** Enable inst caches */
122 121 sybreon
  inline void enableInstCache()
123
  {
124
    putMSR(getMSR() | MSR_ICE);
125
  }
126 110 sybreon
 
127
  /** Disable inst caches */
128 121 sybreon
  inline void disableInstCache()
129
  {
130
    putMSR(getMSR() & ~MSR_ICE);
131
  }
132 110 sybreon
 
133 121 sybreon
}
134 107 sybreon
 
135 121 sybreon
#endif
136
 
137 107 sybreon
/*
138
  $Log: not supported by cvs2svn $
139 137 sybreon
  Revision 1.5  2008/04/20 16:35:53  sybreon
140
  Added C/C++ compatible #ifdef statements
141
 
142 121 sybreon
  Revision 1.4  2008/04/11 15:53:03  sybreon
143
  changed MSR bits
144
 
145 114 sybreon
  Revision 1.3  2008/04/11 12:24:12  sybreon
146
  added cache controls
147
 
148 110 sybreon
  Revision 1.2  2008/04/11 11:48:37  sybreon
149
  added interrupt controls (may need to be factorised out)
150
 
151 109 sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
152
  Added new C++ files
153
 
154 107 sybreon
*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.