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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [aemb/] [hook.hh] - Blame information for rev 111

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 111 sybreon
/* $Id: hook.hh,v 1.2 2008-04-11 15:20:31 sybreon Exp $
2 107 sybreon
**
3
** AEMB2 HI-PERFORMANCE CPU
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see .
20
*/
21
 
22
/**
23
   Basic begin/end hooks
24
   @file hook.hh
25
 
26
   These routines hook themselves onto the startup and ending parts of
27
   the main programme. In order to use it, the main programme needs to
28
   be compiled with optimisations turned on (at least -O1).
29
 */
30
 
31
#include "aemb/stack.hh"
32
#include "aemb/heap.hh"
33
#include "aemb/thread.hh"
34
 
35 111 sybreon
#ifndef __OPTIMIZE__
36
// ugly hack to check if optimisation is used.
37
OPTIMISATION_REQUIRED XXX
38
#endif
39
 
40 107 sybreon
#ifndef AEMB_HOOK_HH
41
#define AEMB_HOOK_HH
42
 
43
namespace aemb {
44
 
45 111 sybreon
  //void hookProgramInit() asm ("_program_init"); // hook aliasing
46
  //void hookProgramClean() asm ("_program_clean"); // hook aliasing
47
  extern "C" void _program_init();
48
  extern "C" void _program_clean();
49 107 sybreon
 
50
  /**
51
  Finalisation hook
52
 
53
  This function executes during the shutdown phase after the
54
  finalisation routine is called. It will merge the changes made
55
  during initialisation.
56
  */
57
 
58 111 sybreon
  //void hookProgramClean()
59
  void _program_clean()
60 107 sybreon
  {
61
    if (aemb::isThread1()) {
62
      // unify the stack backwards
63
      aemb::setStack(aemb::getStack() +
64
                         (aemb::getStackSize() >> 1));
65
 
66
      // FIXME: unify the heap
67
 
68
    }
69
  }
70
 
71
  /**
72
  Initialisation hook
73
 
74
  This function executes during the startup phase before the
75
  initialisation routine is called. It splits the heap and stack
76
  between the threads.
77
  */
78
 
79 111 sybreon
  //void hookProgramInit()
80
  void _program_init()
81 107 sybreon
  {
82
    if (aemb::isThread1()) {  // check if PHASE 1
83
      // split and shift the stack
84
      aemb::setStack(aemb::getStack() -
85
                         (aemb::getStackSize() >> 1));
86
 
87
      // FIXME: split and shift the heap
88
 
89
    }
90
  }
91
};
92
 
93
#endif
94
 
95
/*
96
  $Log: not supported by cvs2svn $
97 111 sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
98
  Added new C++ files
99
 
100 107 sybreon
*/

powered by: WebSVN 2.1.0

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