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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [aemb/] [stack.hh] - Diff between revs 145 and 151

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 145 Rev 151
Line 1... Line 1...
/* $Id: stack.hh,v 1.7 2008-04-27 16:33:42 sybreon Exp $
/* $Id: stack.hh,v 1.8 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.
Line 22... Line 22...
/**
/**
   Basic stack related functions
   Basic stack related functions
   @file stack.hh
   @file stack.hh
 */
 */
 
 
#ifndef AEMB_STACK_HH
#ifndef _AEMB_STACK_HH
#define AEMB_STACK_HH
#define _AEMB_STACK_HH
 
 
#ifdef __cplusplus
#ifdef __cplusplus
namespace aemb {
extern "C" {
#endif
#endif
 
 
  /**
  /**
  Reads the size of the memory space allocated for the stack in bytes.
  Reads the size of the memory space allocated for the stack in bytes.
  @return size of stack
  @return size of stack
  */
  */
 
 
  inline int getStackSize()
  inline int aembGetStackSize()
  {
  {
    int tmp;
    int tmp;
    asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
    asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
    return tmp;
    return tmp;
  }
  }
Line 47... Line 47...
  Reads the end of the memory space allocated for the stack. This is
  Reads the end of the memory space allocated for the stack. This is
  where the stack ends.
  where the stack ends.
  @return end of stack
  @return end of stack
  */
  */
 
 
  inline int getStackEnd()
  inline int aembGetStackEnd()
  {
  {
    int tmp;
    int tmp;
    asm ("la %0, r0, _stack_end":"=r"(tmp));
    asm ("la %0, r0, _stack_end":"=r"(tmp));
    return tmp;
    return tmp;
  }
  }
Line 60... Line 60...
  Reads the top of the memory space allocated for the stack. This is
  Reads the top of the memory space allocated for the stack. This is
  where the stack starts.
  where the stack starts.
  @return top of stack
  @return top of stack
  */
  */
 
 
  inline int getStackTop()
  inline int aembGetStackTop()
  {
  {
    int tmp;
    int tmp;
    asm ("la %0, r0, _stack":"=r"(tmp));
    asm ("la %0, r0, _stack":"=r"(tmp));
    return tmp;
    return tmp;
  }
  }
Line 72... Line 72...
  /**
  /**
  Reads register R1 which is the designated stack pointer.
  Reads register R1 which is the designated stack pointer.
  @return stack pointer
  @return stack pointer
  */
  */
 
 
  inline int getStack()
  inline int aembGetStack()
  {
  {
    int tmp;
    int tmp;
    asm ("addk %0, r0, r1":"=r"(tmp));
    asm ("addk %0, r0, r1":"=r"(tmp));
    return tmp;
    return tmp;
  }
  }
Line 85... Line 85...
  Sets register R1 to the new stack pointer.
  Sets register R1 to the new stack pointer.
  @param stk new stack pointer
  @param stk new stack pointer
  @return new stack pointer
  @return new stack pointer
  */
  */
 
 
  inline int setStack(int stk)
  inline int aembSetStack(int stk)
  {
  {
    asm ("addk r1, r0, %0"::"r"(stk));
    asm ("addk r1, r0, %0"::"r"(stk));
    return stk;
    return stk;
  }
  }
 
 
Line 98... Line 98...
     @param newp new stack pointer
     @param newp new stack pointer
     @param oldp old stack pointer
     @param oldp old stack pointer
     @param endp end of the stack
     @param endp end of the stack
  */
  */
 
 
  inline void dupStack(unsigned int *newp, unsigned int *oldp, unsigned int *endp)
  inline void aembDupStack(unsigned int *newp, unsigned int *oldp, unsigned int *endp)
  {
  {
    while (oldp < endp)
    while (oldp < endp)
      {
      {
        // copy the stack content
        // copy the stack content
        *newp = *oldp;
        *newp = *oldp;
 
 
        // this increments 1 word (not 1 byte)
        // this increments 1 word (not 1 byte)
        newp++;
        newp++;
        oldp++;
        oldp++;
      }
      }
  }
  }
Line 119... Line 118...
 
 
#endif
#endif
 
 
/*
/*
  $Log: not supported by cvs2svn $
  $Log: not supported by cvs2svn $
 
  Revision 1.7  2008/04/27 16:33:42  sybreon
 
  License change to GPL3.
 
 
  Revision 1.6  2008/04/27 16:04:42  sybreon
  Revision 1.6  2008/04/27 16:04:42  sybreon
  Minor cosmetic changes.
  Minor cosmetic changes.
 
 
  Revision 1.5  2008/04/26 19:31:35  sybreon
  Revision 1.5  2008/04/26 19:31:35  sybreon
  Made headers C compatible.
  Made headers C compatible.

powered by: WebSVN 2.1.0

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