OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [aeMB/] [sw/] [aemb/] [msr.hh] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 alirezamon
/* $Id: msr.hh,v 1.9 2008-04-28 20:29:15 sybreon Exp $
2
**
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 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
**
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 General Public
16
** License for more details.
17
**
18
** You should have received a copy of the GNU General Public License
19
** along with AEMB.  If not, see .
20
*/
21
 
22
/**
23
   Basic MSR functions
24
   @file msr.hh
25
 
26
   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
// STANDARD BITS
34
#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
#define AEMB_MSR_EE  (1 << 8) ///< Exception Enable
39
#define AEMB_MSR_EIP  (1 << 9) ///< Exception in Progress
40
 
41
#define AEMB_MSR_ITE  (1 << 5) ///< Instruction Cache Enable
42
#define AEMB_MSR_DZ   (1 << 6) ///< Division by Zero
43
#define AEMB_MSR_DTE  (1 << 7) ///< Data Cache Enable
44
 
45
// CUSTOM BITS
46
#define AEMB_MSR_MTX  (1 << 4) ///< Hardware Mutex
47
#define AEMB_MSR_PHA  (1 << 29) ///< Hardware Thread Phase
48
#define AEMB_MSR_HTX  (1 << 30) ///< Hardware Threads Extension
49
#define AEMB_MSR_CC   (1 << 31) ///< Carry Copy
50
 
51
#ifdef __cplusplus
52
extern "C" {
53
#endif
54
 
55
  /**
56
     Read the value of the MSR register
57
     @return register contents
58
  */
59
 
60 48 alirezamon
 static inline int aembGetMSR()
61 17 alirezamon
  {
62
    int rmsr;
63
    asm volatile ("mfs %0, rmsr":"=r"(rmsr));
64
    return rmsr;
65
  }
66
 
67
  /**
68
     Write a value to the MSR register
69
     @param rmsr value to write
70
  */
71
 
72 48 alirezamon
 static inline void aembPutMSR(int rmsr)
73 17 alirezamon
  {
74
    asm volatile ("mts rmsr, %0"::"r"(rmsr));
75
  }
76
 
77
  /**
78
     Read and clear the MSR
79
     @param rmsk clear mask
80
     @return msr value
81
   */
82
 
83 48 alirezamon
 static inline int aembClrMSR(const short rmsk)
84 17 alirezamon
  {
85
    int tmp;
86
    //asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(rmsk):"memory");
87
    return tmp;
88
  }
89
 
90
  /**
91
     Read and set the MSR
92
     @param rmsk set mask
93
     @return msr value
94
   */
95
 
96 48 alirezamon
 static inline int aembSetMSR(const short rmsk)
97 17 alirezamon
  {
98
    int tmp;
99
    //asm volatile ("msrset %0, %1":"=r"(tmp):"K"(rmsk):"memory");
100
    return tmp;
101
  }
102
 
103
  /** Enable global interrupts */
104 48 alirezamon
 static inline int aembEnableInterrupts()
105 17 alirezamon
  {
106
    int msr;
107
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_IE));
108
    return msr;
109
  }
110
 
111
  /** Disable global interrupts */
112 48 alirezamon
 static inline int aembDisableInterrupts()
113 17 alirezamon
  {
114
    int msr;
115
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_IE));
116
    return msr;
117
  }
118
 
119
  /** Enable global exception */
120 48 alirezamon
 static inline int aembEnableException()
121 17 alirezamon
  {
122
    int msr;
123
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_EE));
124
    return msr;
125
  }
126
 
127
  /** Disable global exception */
128 48 alirezamon
  static inline int aembDisableException()
129 17 alirezamon
  {
130
    int msr;
131
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_EE));
132
    return msr;
133
  }
134
 
135
  /** Enable data caches */
136 48 alirezamon
 static inline int aembEnableDataTag()
137 17 alirezamon
  {
138
    int msr;
139
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_DTE));
140
    return msr;
141
  }
142
 
143
  /** Disable data caches */
144 48 alirezamon
 static  inline int aembDisableDataTag()
145 17 alirezamon
  {
146
    int msr;
147
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_DTE));
148
    return msr;
149
  }
150
 
151
  /** Enable inst caches */
152 48 alirezamon
  static inline int aembEnableInstTag()
153 17 alirezamon
  {
154
    int msr;
155
    asm volatile ("msrset %0, %1":"=r"(msr):"K"(AEMB_MSR_ITE));
156
    return msr;
157
  }
158
 
159
  /** Disable inst caches */
160 48 alirezamon
 static inline int aembDisableInstTag()
161 17 alirezamon
  {
162
    int msr;
163
    asm volatile ("msrclr %0, %1":"=r"(msr):"K"(AEMB_MSR_ITE));
164
    return msr;
165
  }
166
 
167
#ifdef __cplusplus
168
}
169
#endif
170
 
171
#endif

powered by: WebSVN 2.1.0

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