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/] [thread.hh] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 alirezamon
/* $Id: thread.hh,v 1.10 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 thread functions
24
   @file thread.hh
25
 
26
   These functions deal with the various hardware threads. It also
27
   provides simple mechanisms for toggling semaphores.
28
 */
29
 
30
#include "msr.hh"
31
 
32
#ifndef _AEMB_THREAD_HH
33
#define _AEMB_THREAD_HH
34
 
35
#ifdef __cplusplus
36
extern "C" {
37
#endif
38
 
39
  /**
40
     Checks to see if currently executing Thread 1
41
     @return true if is Thread 1
42
  */
43
 
44 48 alirezamon
  static inline int aembIsThread1()
45 17 alirezamon
  {
46
    int rmsr = aembGetMSR();
47
    return ((rmsr & AEMB_MSR_PHA));
48
  }
49
 
50
  /**
51
     Checks to see if currently executing Thread 0
52
     @return true if is Thread 0
53
  */
54
 
55 48 alirezamon
  static inline int aembIsThread0()
56 17 alirezamon
  {
57
    int rmsr = aembGetMSR();
58
    return (!(rmsr & AEMB_MSR_PHA));
59
  }
60
 
61
  /**
62
     Checks to see if it is multi-threaded or not.
63
     @return true if thread capable
64
  */
65 48 alirezamon
  static inline int aembIsThreaded()
66 17 alirezamon
  {
67
    int rmsr = aembGetMSR();
68
    return (rmsr & AEMB_MSR_HTX);
69
  }
70
 
71
  /**
72
     Hardware Mutex Signal.
73
     Unlock the hardware mutex, which is unlocked on reset.
74
   */
75 48 alirezamon
  static inline void _aembFreeMTX()
76 17 alirezamon
  {
77
    int tmp;
78
    asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(AEMB_MSR_MTX));
79
  }
80
 
81
  /**
82
     Hardware Mutex Wait.
83
 
84
     Waits until the hardware mutex is unlocked. This should be used
85
     as part of a larger software mutex mechanism.
86
   */
87 48 alirezamon
  static inline void _aembLockMTX()
88 17 alirezamon
  {
89
    int rmsr;
90
    do
91
      {
92
        asm volatile ("msrset %0, %1":"=r"(rmsr):"K"(AEMB_MSR_MTX));
93
      }
94
    while (rmsr & AEMB_MSR_MTX);
95
  }
96
 
97
#ifdef __cplusplus
98
}
99
#endif
100
 
101
#endif

powered by: WebSVN 2.1.0

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