LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Sat Apr 26 20:04:31 CEST 2008
    Subject: [cvs-checkins] MODIFIED: aemb ...
    Top
    Date: 00/08/04 26:20:04

    Modified: aemb/sw/cc/aemb hook.hh stack.hh
    Log:
    Updated software to freeze T0 and run T1.


    Revision Changes Path
    1.6 aemb/sw/cc/aemb/hook.hh

    http://www.opencores.org/cvsweb.shtml/aemb/sw/cc/aemb/hook.hh.diff?r1=1.5&r2=1.6

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: hook.hh
    ===================================================================
    RCS file: /cvsroot/sybreon/aemb/sw/cc/aemb/hook.hh,v
    retrieving revision 1.5
    retrieving revision 1.6
    diff -u -b -r1.5 -r1.6
    --- hook.hh 23 Apr 2008 14:19:39 -0000 1.5
    +++ hook.hh 26 Apr 2008 18:04:31 -0000 1.6
    @@ -1,4 +1,4 @@
    -/* $Id: hook.hh,v 1.5 2008/04/23 14:19:39 sybreon Exp $
    +/* $Id: hook.hh,v 1.6 2008/04/26 18:04:31 sybreon Exp $
    **
    ** AEMB2 HI-PERFORMANCE CPU
    ** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@a...>
    @@ -34,25 +34,19 @@
    #ifndef AEMB_HOOK_HH
    #define AEMB_HOOK_HH

    -#ifdef __cplusplus
    namespace aemb {
    extern "C" {
    +
    void _program_init();
    void _program_clean();
    - void __malloc_lock();
    - void __malloc_unlock();
    - void __env_lock();
    - void __env_unlock();
    +
    + // newlib locks
    + void __malloc_lock(struct _reent *reent);
    + void __malloc_unlock(struct _reent *reent);
    + //void __env_lock(struct _reent *reent);
    + //void __env_unlock(struct _reent *reent);

    }
    -#else
    - void _program_init();
    - void _program_clean();
    - void __malloc_lock();
    - void __malloc_unlock();
    - void __env_lock();
    - void __env_unlock();
    -#endif

    /**
    Finalisation hook
    @@ -61,13 +55,15 @@
    finalisation routine is called. It will merge the changes made
    during initialisation.
    */
    +
    void _program_clean()
    {
    waitMutex(); // enter critical section

    // unify the stack backwards for thread 1
    - if (isThread1())
    + if (isThread0())
    {
    + // TODO: Unify the stack
    setStack(getStack() + (getStackSize() >> 1));
    }

    @@ -79,16 +75,22 @@

    This function executes during the startup phase before the
    initialisation routine is called. It splits the stack between the
    - threads.
    + threads. For now, it will lock up T0 for compatibility purposes.
    */
    +
    void _program_init()
    {
    waitMutex(); // enter critical section

    // split and shift the stack for thread 1
    - if (isThread1())
    + if (isThread0()) // main thread
    {
    - setStack(getStack() - (getStackSize() >> 1));
    + // NOTE: Dupe the stack otherwise it will FAIL!
    + dupStack((int *)setStack(getStack() - (getStackSize() >> 1)),
    + (int *)getStack(),
    + (int *)getStackTop);
    + signalMutex(); // exit critical section
    + while (true) asm volatile ("nop"); // lock thread
    }
    signalMutex(); // exit critical section @@ -102,7 +104,8 @@ This function is called during malloc() to lock out the shared heap to avoid data corruption. */ - void __malloc_lock() + + void __malloc_lock(struct _reent *reent) { waitMutex(); } @@ -113,25 +116,28 @@ This function is called during malloc() to indicate that the shared heap is now available for another thread. */ - void __malloc_unlock() + + void __malloc_unlock(struct _reent *reent) { signalMutex(); } -#ifdef __cplusplus } -#endif #endif #ifndef __OPTIMIZE__ // The main programme needs to be compiled with optimisations turned -// on (at least -O1). +// on (at least -O1). If not, the MUTEX value will be written to the +// same RAM location, giving both threads the same value. OPTIMISATION_REQUIRED XXX #endif /* $Log: hook.hh,v $ + Revision 1.6 2008/04/26 18:04:31 sybreon + Updated software to freeze T0 and run T1. + Revision 1.5 2008/04/23 14:19:39 sybreon Fixed minor bugs. Initial use of hardware mutex. 1.4 aemb/sw/cc/aemb/stack.hh http://www.opencores.org/cvsweb.shtml/aemb/sw/cc/aemb/stack.hh.diff?r1=1.3&r2=1.4 (In the diff below, changes in quantity of whitespace are not shown.) Index: stack.hh =================================================================== RCS file: /cvsroot/sybreon/aemb/sw/cc/aemb/stack.hh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- stack.hh 23 Apr 2008 14:19:39 -0000 1.3 +++ stack.hh 26 Apr 2008 18:04:31 -0000 1.4 @@ -1,4 +1,4 @@ -/* $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 ** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@a...> @@ -27,9 +27,7 @@ #ifndef AEMB_STACK_HH #define AEMB_STACK_HH -#ifdef __cplusplus namespace aemb { -#endif /** Reads the size of the memory space allocated for the stack in bytes. @@ -44,7 +42,8 @@ } /** - 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 */ @@ -56,7 +55,8 @@ } /** - 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 */ @@ -82,21 +82,44 @@ /** Sets register R1 to the 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)); + 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 /* $Log: stack.hh,v $ + Revision 1.4 2008/04/26 18:04:31 sybreon + Updated software to freeze T0 and run T1. + Revision 1.3 2008/04/23 14:19:39 sybreon Fixed minor bugs. Initial use of hardware mutex.

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.