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

Subversion Repositories aemb

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 151 sybreon
/* $Id: msr.hh,v 1.9 2008-04-28 20:29:15 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 145 sybreon
** under the terms of the GNU General Public License as published by
10
** the Free Software Foundation, either version 3 of the License, or
11
** (at your option) any later version.
12 107 sybreon
**
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 145 sybreon
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
** License for more details.
17 107 sybreon
**
18 145 sybreon
** You should have received a copy of the GNU General Public License
19
** along with AEMB.  If not, see .
20 107 sybreon
*/
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 151 sybreon
#ifndef _AEMB_MSR_HH
31
#define _AEMB_MSR_HH
32 107 sybreon
 
33 145 sybreon
// STANDARD BITS
34 151 sybreon
#define AEMB_MSR_BE   (1 << 0) ///< Buslock Enable
35
#define AEMB_MSR_IE   (1 << 1) ///< Interrupt Enable
36
#define AEMB_MSR_C    (1 << 2) ///< Arithmetic Carry
37
#define AEMB_MSR_BIP  (1 << 3) ///< Break in Progress
38 107 sybreon
 
39 151 sybreon
#define AEMB_MSR_ITE  (1 << 5) ///< Instruction Cache Enable
40
#define AEMB_MSR_DZ   (1 << 6) ///< Division by Zero
41
#define AEMB_MSR_DTE  (1 << 7) ///< Data Cache Enable
42 121 sybreon
 
43 145 sybreon
// CUSTOM BITS
44 151 sybreon
#define AEMB_MSR_MTX  (1 << 4) ///< Hardware Mutex
45
#define AEMB_MSR_PHA  (1 << 29) ///< Hardware Thread Phase
46
#define AEMB_MSR_HTX  (1 << 30) ///< Hardware Threads Extension
47
#define AEMB_MSR_CC   (1 << 31) ///< Carry Copy
48 107 sybreon
 
49 145 sybreon
#ifdef __cplusplus
50 151 sybreon
extern "C" {
51 145 sybreon
#endif
52
 
53 107 sybreon
  /**
54 121 sybreon
     Read the value of the MSR register
55
     @return register contents
56 107 sybreon
  */
57
 
58 151 sybreon
  inline int aembGetMSR()
59 107 sybreon
  {
60
    int rmsr;
61 109 sybreon
    asm volatile ("mfs %0, rmsr":"=r"(rmsr));
62 107 sybreon
    return rmsr;
63
  }
64
 
65
  /**
66 121 sybreon
     Write a value to the MSR register
67
     @param rmsr value to write
68 110 sybreon
  */
69 107 sybreon
 
70 151 sybreon
  inline void aembPutMSR(int rmsr)
71 110 sybreon
  {
72
    asm volatile ("mts rmsr, %0"::"r"(rmsr));
73 109 sybreon
  }
74
 
75 121 sybreon
  /**
76
     Read and clear the MSR
77
     @param rmsk clear mask
78
     @return msr value
79
   */
80 139 sybreon
 
81 151 sybreon
  inline int aembClrMSR(const short rmsk)
82 121 sybreon
  {
83
    int tmp;
84 139 sybreon
    //asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(rmsk):"memory");
85 121 sybreon
    return tmp;
86
  }
87
 
88
  /**
89
     Read and set the MSR
90
     @param rmsk set mask
91
     @return msr value
92
   */
93 139 sybreon
 
94 151 sybreon
  inline int aembSetMSR(const short rmsk)
95 121 sybreon
  {
96
    int tmp;
97 139 sybreon
    //asm volatile ("msrset %0, %1":"=r"(tmp):"K"(rmsk):"memory");
98 121 sybreon
    return tmp;
99
  }
100
 
101 110 sybreon
  /** Enable global interrupts */
102 151 sybreon
  inline int aembEnableInterrupts()
103 121 sybreon
  {
104 151 sybreon
    int msr;
105
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_IE));
106
    return msr;
107 121 sybreon
  }
108 109 sybreon
 
109 110 sybreon
  /** Disable global interrupts */
110 151 sybreon
  inline int aembDisableInterrupts()
111 121 sybreon
  {
112 151 sybreon
    int msr;
113
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_IE));
114
    return msr;
115 121 sybreon
  }
116 110 sybreon
 
117
  /** Enable data caches */
118 151 sybreon
  inline int aembEnableDataTag()
119 121 sybreon
  {
120 151 sybreon
    int msr;
121
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_DTE));
122
    return msr;
123 121 sybreon
  }
124 110 sybreon
 
125
  /** Disable data caches */
126 151 sybreon
  inline int aembDisableDataTag()
127 121 sybreon
  {
128 151 sybreon
    int msr;
129
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_DTE));
130
    return msr;
131 121 sybreon
  }
132 110 sybreon
 
133
  /** Enable inst caches */
134 151 sybreon
  inline int aembEnableInstTag()
135 121 sybreon
  {
136 151 sybreon
    int msr;
137
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_ITE));
138
    return msr;
139 121 sybreon
  }
140 110 sybreon
 
141
  /** Disable inst caches */
142 151 sybreon
  inline int aembDisableInstTag()
143 121 sybreon
  {
144 151 sybreon
    int msr;
145
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_ITE));
146
    return msr;
147 121 sybreon
  }
148 110 sybreon
 
149 139 sybreon
#ifdef __cplusplus
150 121 sybreon
}
151 139 sybreon
#endif
152 107 sybreon
 
153 121 sybreon
#endif
154
 
155 107 sybreon
/*
156
  $Log: not supported by cvs2svn $
157 151 sybreon
  Revision 1.8  2008/04/27 16:33:42  sybreon
158
  License change to GPL3.
159
 
160 145 sybreon
  Revision 1.7  2008/04/26 19:31:35  sybreon
161
  Made headers C compatible.
162
 
163 139 sybreon
  Revision 1.6  2008/04/26 18:05:22  sybreon
164
  Minor cosmetic changes.
165
 
166 137 sybreon
  Revision 1.5  2008/04/20 16:35:53  sybreon
167
  Added C/C++ compatible #ifdef statements
168
 
169 121 sybreon
  Revision 1.4  2008/04/11 15:53:03  sybreon
170
  changed MSR bits
171
 
172 114 sybreon
  Revision 1.3  2008/04/11 12:24:12  sybreon
173
  added cache controls
174
 
175 110 sybreon
  Revision 1.2  2008/04/11 11:48:37  sybreon
176
  added interrupt controls (may need to be factorised out)
177
 
178 109 sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
179
  Added new C++ files
180
 
181 107 sybreon
*/

powered by: WebSVN 2.1.0

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