Fork of the official mbed C/C++ SDK provides the software platform and libraries to build your applications. The fork has the documentation converted to Doxygen format

Dependents:   NervousPuppySprintOne NervousPuppySprint2602 Robot WarehouseBot1 ... more

Fork of mbed by mbed official

Committer:
simon.ford@mbed.co.uk
Date:
Thu Nov 27 16:23:24 2008 +0000
Revision:
4:5d1359a283bc
Parent:
1:6b7f447ca868
New version of framework: vectors, environment, platform, base and file system

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon.ford@mbed.co.uk 0:82220227f4fa 1 /* mbed Microcontroller Library - stackheap
simon.ford@mbed.co.uk 0:82220227f4fa 2 * Copyright (c) 2007-2008, sford
simon.ford@mbed.co.uk 0:82220227f4fa 3 */
simon.ford@mbed.co.uk 0:82220227f4fa 4
simon.ford@mbed.co.uk 0:82220227f4fa 5 #ifndef MBED_STACKHEAP_H
simon.ford@mbed.co.uk 0:82220227f4fa 6 #define MBED_STACKHEAP_H
simon.ford@mbed.co.uk 0:82220227f4fa 7
simon.ford@mbed.co.uk 0:82220227f4fa 8 namespace mbed {
simon.ford@mbed.co.uk 0:82220227f4fa 9
simon.ford@mbed.co.uk 0:82220227f4fa 10 /* Section: stackheap
simon.ford@mbed.co.uk 0:82220227f4fa 11 * Useful functions for seeing what is going on with the stack and heap
simon.ford@mbed.co.uk 0:82220227f4fa 12 */
simon.ford@mbed.co.uk 0:82220227f4fa 13
simon.ford@mbed.co.uk 0:82220227f4fa 14 /* Function: code_base
simon.ford@mbed.co.uk 0:82220227f4fa 15 * Return the address of the fixed base of the code region
simon.ford@mbed.co.uk 0:82220227f4fa 16 */
simon.ford@mbed.co.uk 0:82220227f4fa 17 int code_base();
simon.ford@mbed.co.uk 0:82220227f4fa 18
simon.ford@mbed.co.uk 0:82220227f4fa 19 /* Function: code_limit
simon.ford@mbed.co.uk 0:82220227f4fa 20 * Return the address of the top of the code region
simon.ford@mbed.co.uk 0:82220227f4fa 21 */
simon.ford@mbed.co.uk 0:82220227f4fa 22 int code_limit();
simon.ford@mbed.co.uk 0:82220227f4fa 23
simon.ford@mbed.co.uk 0:82220227f4fa 24 /* Function: rw_base
simon.ford@mbed.co.uk 0:82220227f4fa 25 * Return the address of the fixed base of the rw region
simon.ford@mbed.co.uk 0:82220227f4fa 26 */
simon.ford@mbed.co.uk 0:82220227f4fa 27 int rw_base();
simon.ford@mbed.co.uk 0:82220227f4fa 28
simon.ford@mbed.co.uk 0:82220227f4fa 29 /* Function: rw_limit
simon.ford@mbed.co.uk 0:82220227f4fa 30 * Return the address of the top of the rw region
simon.ford@mbed.co.uk 0:82220227f4fa 31 */
simon.ford@mbed.co.uk 0:82220227f4fa 32 int rw_limit();
simon.ford@mbed.co.uk 0:82220227f4fa 33
simon.ford@mbed.co.uk 0:82220227f4fa 34 /* Function: heap_base
simon.ford@mbed.co.uk 0:82220227f4fa 35 * Return the address of the fixed base of the heap
simon.ford@mbed.co.uk 0:82220227f4fa 36 */
simon.ford@mbed.co.uk 0:82220227f4fa 37 int heap_base();
simon.ford@mbed.co.uk 0:82220227f4fa 38
simon.ford@mbed.co.uk 0:82220227f4fa 39 /* Function: heap_limit
simon.ford@mbed.co.uk 0:82220227f4fa 40 * Return the address of the current top of the heap
simon.ford@mbed.co.uk 0:82220227f4fa 41 */
simon.ford@mbed.co.uk 0:82220227f4fa 42 int heap_limit();
simon.ford@mbed.co.uk 0:82220227f4fa 43
simon.ford@mbed.co.uk 0:82220227f4fa 44 /* Function: stack_base
simon.ford@mbed.co.uk 0:82220227f4fa 45 * Return the address of the fixed base of the stack
simon.ford@mbed.co.uk 0:82220227f4fa 46 */
simon.ford@mbed.co.uk 0:82220227f4fa 47 int stack_base();
simon.ford@mbed.co.uk 0:82220227f4fa 48
simon.ford@mbed.co.uk 0:82220227f4fa 49 /* Function: stack_limit
simon.ford@mbed.co.uk 0:82220227f4fa 50 * Return the address of the current top of the stack
simon.ford@mbed.co.uk 0:82220227f4fa 51 */
simon.ford@mbed.co.uk 0:82220227f4fa 52 //int stack_limit();
simon.ford@mbed.co.uk 0:82220227f4fa 53
simon.ford@mbed.co.uk 0:82220227f4fa 54 /* Function: code_size
simon.ford@mbed.co.uk 0:82220227f4fa 55 * Return the size of the code region
simon.ford@mbed.co.uk 0:82220227f4fa 56 */
simon.ford@mbed.co.uk 0:82220227f4fa 57 int code_size();
simon.ford@mbed.co.uk 0:82220227f4fa 58
simon.ford@mbed.co.uk 0:82220227f4fa 59 /* Function: rw_size
simon.ford@mbed.co.uk 0:82220227f4fa 60 * Return the size of the rw region
simon.ford@mbed.co.uk 0:82220227f4fa 61 */
simon.ford@mbed.co.uk 0:82220227f4fa 62 int rw_size();
simon.ford@mbed.co.uk 0:82220227f4fa 63
simon.ford@mbed.co.uk 0:82220227f4fa 64 /* Function: heap_size
simon.ford@mbed.co.uk 0:82220227f4fa 65 * Return the current size of the heap pool allocated
simon.ford@mbed.co.uk 0:82220227f4fa 66 */
simon.ford@mbed.co.uk 0:82220227f4fa 67 int heap_size();
simon.ford@mbed.co.uk 0:82220227f4fa 68
simon.ford@mbed.co.uk 0:82220227f4fa 69 /* Function: stack_size
simon.ford@mbed.co.uk 0:82220227f4fa 70 * Return the current size of the stack used
simon.ford@mbed.co.uk 0:82220227f4fa 71 */
simon.ford@mbed.co.uk 0:82220227f4fa 72 //int stack_size();
simon.ford@mbed.co.uk 0:82220227f4fa 73
simon.ford@mbed.co.uk 0:82220227f4fa 74
simon.ford@mbed.co.uk 0:82220227f4fa 75 inline int stack_limit() {
simon.ford@mbed.co.uk 4:5d1359a283bc 76 #ifdef __GNUC__
simon.ford@mbed.co.uk 4:5d1359a283bc 77 return (unsigned)__builtin_frame_address(0);
simon.ford@mbed.co.uk 4:5d1359a283bc 78 #else
simon.ford@mbed.co.uk 0:82220227f4fa 79 return __current_sp();
simon.ford@mbed.co.uk 4:5d1359a283bc 80 #endif
simon.ford@mbed.co.uk 0:82220227f4fa 81 }
simon.ford@mbed.co.uk 0:82220227f4fa 82
simon.ford@mbed.co.uk 0:82220227f4fa 83 inline int stack_size() {
simon.ford@mbed.co.uk 0:82220227f4fa 84 return stack_base() - stack_limit();
simon.ford@mbed.co.uk 0:82220227f4fa 85 }
simon.ford@mbed.co.uk 0:82220227f4fa 86
simon.ford@mbed.co.uk 0:82220227f4fa 87 } // namespace mbed
simon.ford@mbed.co.uk 0:82220227f4fa 88
simon.ford@mbed.co.uk 1:6b7f447ca868 89 #endif
simon.ford@mbed.co.uk 1:6b7f447ca868 90