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

Subversion Repositories aemb

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

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

Line No. Rev Author Line
1 109 sybreon
/* $Id: msr.hh,v 1.2 2008-04-11 11:48:37 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
  const int MSR_TXE = 0x00000100; ///< thread enable
46
  const int MSR_PHA = 0x00000200; ///< thread phase
47
  const int MSR_HTE = 0x00000400; ///< hardware thread capable
48
 
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
  */
65
 
66
  inline void setMSR(int rmsr)
67
  {
68 109 sybreon
    asm volatile ("mts rmsr, %0"::"r"(rmsr));
69 107 sybreon
  }
70
 
71 109 sybreon
  /**
72
  Enable global interrupts
73
  */
74
  inline void enableInterrupts()
75
  {
76
    int rmsr = getMSR();
77
    rmsr |= MSR_IE;
78
    setMSR(rmsr);
79
  }
80
 
81
  /**
82
  Disable global interrupts
83
  */
84
  inline void disableInterrupts()
85
  {
86
    int rmsr = getMSR();
87
    rmsr &= ~MSR_IE;
88
    setMSR(rmsr);
89
  }
90
 
91
 
92 107 sybreon
};
93
#endif
94
 
95
/*
96
  $Log: not supported by cvs2svn $
97 109 sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
98
  Added new C++ files
99
 
100 107 sybreon
*/

powered by: WebSVN 2.1.0

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