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

Subversion Repositories aemb

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

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

Line No. Rev Author Line
1 114 sybreon
/* $Id: msr.hh,v 1.4 2008-04-11 15:53:03 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
 
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
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
  const int MSR_FSL = 0x00000010; ///< FSL Error
41
  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
 
45 114 sybreon
  const int MSR_HTE = 0x10000000; ///< Hardware Threads Enable
46
  const int MSR_HTP = 0x20000000; ///< Hardware Thread Phase
47
  const int MSR_HTX = 0x40000000; ///< Hardware Threads Extension
48 107 sybreon
 
49
  /**
50
  Read the value of the MSR register
51
  @return register contents
52
  */
53
 
54
  inline int getMSR()
55
  {
56
    int rmsr;
57 109 sybreon
    asm volatile ("mfs %0, rmsr":"=r"(rmsr));
58 107 sybreon
    return rmsr;
59
  }
60
 
61
  /**
62
  Write a value to the MSR register
63
  @param rmsr value to write
64 110 sybreon
  */
65 107 sybreon
 
66 110 sybreon
  inline void setMSR(int rmsr)
67
  {
68
    asm volatile ("mts rmsr, %0"::"r"(rmsr));
69 109 sybreon
  }
70
 
71 110 sybreon
  /** Enable global interrupts */
72
  inline void enableInterrupts() { setMSR(getMSR() | MSR_IE); }
73 109 sybreon
 
74 110 sybreon
  /** Disable global interrupts */
75
  inline void disableInterrupts() { setMSR(getMSR() & ~MSR_IE); }
76
 
77
  /** Enable data caches */
78
  inline void enableDataCache() { setMSR(getMSR() | MSR_DCE); }
79
 
80
  /** Disable data caches */
81
  inline void disableDataCache()  { setMSR(getMSR() & ~MSR_DCE); }
82
 
83
  /** Enable inst caches */
84
  inline void enableInstCache() { setMSR(getMSR() | MSR_ICE); }
85
 
86
  /** Disable inst caches */
87
  inline void disableInstCache()  { setMSR(getMSR() & ~MSR_ICE); }
88
 
89 107 sybreon
};
90
#endif
91
 
92
/*
93
  $Log: not supported by cvs2svn $
94 114 sybreon
  Revision 1.3  2008/04/11 12:24:12  sybreon
95
  added cache controls
96
 
97 110 sybreon
  Revision 1.2  2008/04/11 11:48:37  sybreon
98
  added interrupt controls (may need to be factorised out)
99
 
100 109 sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
101
  Added new C++ files
102
 
103 107 sybreon
*/

powered by: WebSVN 2.1.0

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