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] - Diff between revs 17 and 48

Only display areas with differences | Details | Blame | View Log

Rev 17 Rev 48
/* $Id: thread.hh,v 1.10 2008-04-28 20:29:15 sybreon Exp $
/* $Id: thread.hh,v 1.10 2008-04-28 20:29:15 sybreon Exp $
**
**
** AEMB2 HI-PERFORMANCE CPU
** AEMB2 HI-PERFORMANCE CPU
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
**
**
** This file is part of AEMB.
** This file is part of AEMB.
**
**
** AEMB is free software: you can redistribute it and/or modify it
** AEMB is free software: you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by
** under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** (at your option) any later version.
**
**
** AEMB is distributed in the hope that it will be useful, but WITHOUT
** AEMB is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
** License for more details.
** License for more details.
**
**
** You should have received a copy of the GNU General Public License
** You should have received a copy of the GNU General Public License
** along with AEMB.  If not, see .
** along with AEMB.  If not, see .
*/
*/
/**
/**
   Basic thread functions
   Basic thread functions
   @file thread.hh
   @file thread.hh
   These functions deal with the various hardware threads. It also
   These functions deal with the various hardware threads. It also
   provides simple mechanisms for toggling semaphores.
   provides simple mechanisms for toggling semaphores.
 */
 */
#include "msr.hh"
#include "msr.hh"
#ifndef _AEMB_THREAD_HH
#ifndef _AEMB_THREAD_HH
#define _AEMB_THREAD_HH
#define _AEMB_THREAD_HH
#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#endif
  /**
  /**
     Checks to see if currently executing Thread 1
     Checks to see if currently executing Thread 1
     @return true if is Thread 1
     @return true if is Thread 1
  */
  */
 
 
  inline int aembIsThread1()
  static inline int aembIsThread1()
  {
  {
    int rmsr = aembGetMSR();
    int rmsr = aembGetMSR();
    return ((rmsr & AEMB_MSR_PHA));
    return ((rmsr & AEMB_MSR_PHA));
  }
  }
  /**
  /**
     Checks to see if currently executing Thread 0
     Checks to see if currently executing Thread 0
     @return true if is Thread 0
     @return true if is Thread 0
  */
  */
 
 
  inline int aembIsThread0()
  static inline int aembIsThread0()
  {
  {
    int rmsr = aembGetMSR();
    int rmsr = aembGetMSR();
    return (!(rmsr & AEMB_MSR_PHA));
    return (!(rmsr & AEMB_MSR_PHA));
  }
  }
  /**
  /**
     Checks to see if it is multi-threaded or not.
     Checks to see if it is multi-threaded or not.
     @return true if thread capable
     @return true if thread capable
  */
  */
  inline int aembIsThreaded()
  static inline int aembIsThreaded()
  {
  {
    int rmsr = aembGetMSR();
    int rmsr = aembGetMSR();
    return (rmsr & AEMB_MSR_HTX);
    return (rmsr & AEMB_MSR_HTX);
  }
  }
  /**
  /**
     Hardware Mutex Signal.
     Hardware Mutex Signal.
     Unlock the hardware mutex, which is unlocked on reset.
     Unlock the hardware mutex, which is unlocked on reset.
   */
   */
  inline void _aembFreeMTX()
  static inline void _aembFreeMTX()
  {
  {
    int tmp;
    int tmp;
    asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(AEMB_MSR_MTX));
    asm volatile ("msrclr %0, %1":"=r"(tmp):"K"(AEMB_MSR_MTX));
  }
  }
  /**
  /**
     Hardware Mutex Wait.
     Hardware Mutex Wait.
     Waits until the hardware mutex is unlocked. This should be used
     Waits until the hardware mutex is unlocked. This should be used
     as part of a larger software mutex mechanism.
     as part of a larger software mutex mechanism.
   */
   */
  inline void _aembLockMTX()
  static inline void _aembLockMTX()
  {
  {
    int rmsr;
    int rmsr;
    do
    do
      {
      {
        asm volatile ("msrset %0, %1":"=r"(rmsr):"K"(AEMB_MSR_MTX));
        asm volatile ("msrset %0, %1":"=r"(rmsr):"K"(AEMB_MSR_MTX));
      }
      }
    while (rmsr & AEMB_MSR_MTX);
    while (rmsr & AEMB_MSR_MTX);
  }
  }
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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