Line 1... |
Line 1... |
/* $Id: hook.hh,v 1.1 2008-04-09 19:48:37 sybreon Exp $
|
/* $Id: hook.hh,v 1.2 2008-04-11 15:20: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 26... |
Line 26... |
These routines hook themselves onto the startup and ending parts of
|
These routines hook themselves onto the startup and ending parts of
|
the main programme. In order to use it, the main programme needs to
|
the main programme. In order to use it, the main programme needs to
|
be compiled with optimisations turned on (at least -O1).
|
be compiled with optimisations turned on (at least -O1).
|
*/
|
*/
|
|
|
#include "aemb/msr.hh"
|
|
#include "aemb/stack.hh"
|
#include "aemb/stack.hh"
|
#include "aemb/heap.hh"
|
#include "aemb/heap.hh"
|
#include "aemb/thread.hh"
|
#include "aemb/thread.hh"
|
|
|
|
#ifndef __OPTIMIZE__
|
|
// ugly hack to check if optimisation is used.
|
|
OPTIMISATION_REQUIRED XXX
|
|
#endif
|
|
|
#ifndef AEMB_HOOK_HH
|
#ifndef AEMB_HOOK_HH
|
#define AEMB_HOOK_HH
|
#define AEMB_HOOK_HH
|
|
|
namespace aemb {
|
namespace aemb {
|
|
|
void hookProgramInit() asm ("_program_init"); // hook aliasing
|
//void hookProgramInit() asm ("_program_init"); // hook aliasing
|
void hookProgramClean() asm ("_program_clean"); // hook aliasing
|
//void hookProgramClean() asm ("_program_clean"); // hook aliasing
|
|
extern "C" void _program_init();
|
|
extern "C" void _program_clean();
|
|
|
/**
|
/**
|
Finalisation hook
|
Finalisation hook
|
|
|
This function executes during the shutdown phase after the
|
This function executes during the shutdown phase after the
|
finalisation routine is called. It will merge the changes made
|
finalisation routine is called. It will merge the changes made
|
during initialisation.
|
during initialisation.
|
*/
|
*/
|
|
|
void hookProgramClean()
|
//void hookProgramClean()
|
|
void _program_clean()
|
{
|
{
|
if (aemb::isThread1()) {
|
if (aemb::isThread1()) {
|
// unify the stack backwards
|
// unify the stack backwards
|
aemb::setStack(aemb::getStack() +
|
aemb::setStack(aemb::getStack() +
|
(aemb::getStackSize() >> 1));
|
(aemb::getStackSize() >> 1));
|
Line 67... |
Line 74... |
This function executes during the startup phase before the
|
This function executes during the startup phase before the
|
initialisation routine is called. It splits the heap and stack
|
initialisation routine is called. It splits the heap and stack
|
between the threads.
|
between the threads.
|
*/
|
*/
|
|
|
void hookProgramInit()
|
//void hookProgramInit()
|
|
void _program_init()
|
{
|
{
|
if (aemb::isThread1()) { // check if PHASE 1
|
if (aemb::isThread1()) { // check if PHASE 1
|
// split and shift the stack
|
// split and shift the stack
|
aemb::setStack(aemb::getStack() -
|
aemb::setStack(aemb::getStack() -
|
(aemb::getStackSize() >> 1));
|
(aemb::getStackSize() >> 1));
|
Line 84... |
Line 92... |
|
|
#endif
|
#endif
|
|
|
/*
|
/*
|
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
|
Revision 1.1 2008/04/09 19:48:37 sybreon
|
|
Added new C++ files
|
|
|
*/
|
*/
|