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

Subversion Repositories or1k

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

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

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

powered by: WebSVN 2.1.0

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