Line 1... |
Line 1... |
/* $Id: stack.hh,v 1.3 2008-04-23 14:19:39 sybreon Exp $
|
/* $Id: stack.hh,v 1.4 2008-04-26 18:04:31 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 25... |
Line 25... |
*/
|
*/
|
|
|
#ifndef AEMB_STACK_HH
|
#ifndef AEMB_STACK_HH
|
#define AEMB_STACK_HH
|
#define AEMB_STACK_HH
|
|
|
#ifdef __cplusplus
|
|
namespace aemb {
|
namespace aemb {
|
#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
|
*/
|
*/
|
Line 42... |
Line 40... |
asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
|
asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
|
return tmp;
|
return tmp;
|
}
|
}
|
|
|
/**
|
/**
|
Reads the end of the memory space allocated for the stack.
|
Reads the end of the memory space allocated for the stack. This is
|
|
where the stack ends.
|
@return end of stack
|
@return end of stack
|
*/
|
*/
|
|
|
inline int getStackEnd()
|
inline int getStackEnd()
|
{
|
{
|
Line 54... |
Line 53... |
asm ("la %0, r0, _stack_end":"=r"(tmp));
|
asm ("la %0, r0, _stack_end":"=r"(tmp));
|
return tmp;
|
return tmp;
|
}
|
}
|
|
|
/**
|
/**
|
Reads the top of the memory space allocated for the stack.
|
Reads the top of the memory space allocated for the stack. This is
|
|
where the stack starts.
|
@return top of stack
|
@return top of stack
|
*/
|
*/
|
|
|
inline int getStackTop()
|
inline int getStackTop()
|
{
|
{
|
Line 80... |
Line 80... |
}
|
}
|
|
|
/**
|
/**
|
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
|
*/
|
*/
|
|
|
inline void setStack(int stk)
|
inline int setStack(int stk)
|
{
|
{
|
asm ("addk r1, r0, %0"::"r"(stk));
|
asm ("addk r1, r0, %0"::"r"(stk));
|
|
return stk;
|
|
}
|
|
|
|
/**
|
|
Duplicates the stack
|
|
@param newp new stack pointer
|
|
@param oldp old stack pointer
|
|
@param endp end of the stack
|
|
*/
|
|
|
|
inline void dupStack(int *newp, int *oldp, int *endp)
|
|
{
|
|
while (oldp < endp)
|
|
{
|
|
// copy the stack content
|
|
*newp = *oldp;
|
|
|
|
// this increments 1 word (not 1 byte)
|
|
newp++;
|
|
oldp++;
|
|
}
|
}
|
}
|
|
|
#ifdef __cplusplus
|
|
}
|
}
|
#endif
|
|
|
|
#endif
|
#endif
|
|
|
/*
|
/*
|
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
|
Revision 1.3 2008/04/23 14:19:39 sybreon
|
|
Fixed minor bugs.
|
|
Initial use of hardware mutex.
|
|
|
Revision 1.2 2008/04/20 16:35:53 sybreon
|
Revision 1.2 2008/04/20 16:35:53 sybreon
|
Added C/C++ compatible #ifdef statements
|
Added C/C++ compatible #ifdef statements
|
|
|
Revision 1.1 2008/04/09 19:48:37 sybreon
|
Revision 1.1 2008/04/09 19:48:37 sybreon
|
Added new C++ files
|
Added new C++ files
|