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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [sys/] [arm/] [trap.S] - Blame information for rev 39

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

Line No. Rev Author Line
1 39 lampret
        /* Run-time exception support */
2
#include "swi.h"
3
        .section .text
4
        .align 0
5
        .global __rt_stkovf_split_big
6
        .global __rt_stkovf_split_small
7
 
8
/* The following functions are provided for software stack checking.
9
   If hardware stack-checking is being used then the code can be
10
   compiled without the PCS entry checks, and simply rely on VM
11
   management to extend the stack for a thread.
12
 
13
   The stack extension event occurs when the PCS function entry code
14
   would result in a stack-pointer beneath the stack-limit register
15
   value.  The system relies on the following map:
16
 
17
        +-----------------------------------+ <-- end of stack block
18
        | ...                               |
19
        | ...                               |
20
        | active stack                      |
21
        | ...                               | <-- sp (stack-pointer) somewhere in here
22
        | ...                               |
23
        +-----------------------------------+ <-- sl (stack-limit)
24
        | stack-extension handler workspace |
25
        +-----------------------------------+ <-- base of stack block
26
 
27
   The "stack-extension handler workspace" is an amount of memory in
28
   which the stack overflow support code must execute.  It must be
29
   large enough to deal with the worst case path through the extension
30
   code.  At the moment the compiler expects this to be AT LEAST
31
   256bytes.  It uses this fact to code functions with small local
32
   data usage within the overflow space.
33
 
34
   In a true target environment We may need to increase the space
35
   between sl and the true limit to allow for the stack extension
36
   code, SWI handlers and for undefined instruction handlers of the
37
   target environment.  */
38
 
39
__rt_stkovf_split_small:
40
        mov     ip,sp   @ Ensure we can calculate the stack required
41
        @ and fall through to...
42
__rt_stkovf_split_big:
43
        @ in:   sp = current stack-pointer (beneath stack-limit)
44
        @       sl = current stack-limit
45
        @       ip = low stack point we require for the current function
46
        @       lr = return address into the current function
47
        @       fp = frame-pointer
48
        @               original sp --> +----------------------------------+
49
        @                               | pc (12 ahead of PCS entry store) |
50
        @               current fp ---> +----------------------------------+
51
        @                               | lr (on entry) pc (on exit)       |
52
        @                               +----------------------------------+
53
        @                               | sp ("original sp" on entry)      |
54
        @                               +----------------------------------+
55
        @                               | fp (on entry to function)        |
56
        @                               +----------------------------------+
57
        @                               |                                  |
58
        @                               | ..argument and work registers..  |
59
        @                               |                                  |
60
        @               current sp ---> +----------------------------------+
61
        @
62
        @ The "current sl" is somewhere between "original sp" and "current sp"
63
        @ but above "true sl". The "current sl" should be at least 256bytes
64
        @ above the "true sl". The 256byte stack guard should be large enough
65
        @ to deal with the worst case function entry stacking (160bytes) plus
66
        @ the stack overflow handler stacking requirements, plus the stack
67
        @ required for the memory allocation routines.
68
        @
69
        @ Normal PCS entry (before stack overflow check) can stack 16
70
        @ standard registers (64bytes) and 8 floating point registers
71
        @ (96bytes). This gives a minimum stack guard of 160bytes (excluding
72
        @ the stack required for the code). (Actually only a maximum of
73
        @ 14standard registers are ever stacked on entry to a function).
74
        @
75
        @ NOTE: Structure returns are performed by the caller allocating a
76
        @       dummy space on the stack and passing in a "phantom" arg1 into
77
        @       the function. This means that we do not need to worry about
78
        @       preserving the stack under "sp" even on function return.
79
        @
80
        @        Code should never poke values beneath sp. The sp register
81
        @        should always be "dropped" first to cover the data. This
82
        @        protects the data against any events that may try and use
83
        @        the stack.
84
 
85
        SUB     ip, sp, ip      @ extra stack required for function
86
        @ Add stack extension code here.  If desired a new stack chunk
87
        @ can be allocated, and the register state updated suitably.
88
 
89
        @ We now know how much extra stack the function requires.
90
        @ Terminate the program for the moment:
91
        swi     SWI_Exit

powered by: WebSVN 2.1.0

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