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

Subversion Repositories or1k

[/] [or1k/] [tags/] [tn_m001/] [newlib/] [newlib/] [libc/] [sys/] [arm/] [setjmp.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* This is a simple version of setjmp and longjmp.
2
 
3
   Nick Clifton, Cygnus Solutions, 13 June 1997.  */
4
 
5 56 joel
/* ANSI concatenation macros.  */
6
#define CONCAT(a, b) CONCAT2(a, b)
7
#define CONCAT2(a, b) a ## b
8 39 lampret
 
9 56 joel
#ifdef __USER_LABEL_PREFIX__
10
#define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name)
11
#else
12
#error __USER_LABEL_PREFIX__ is not defined
13
#endif
14
 
15
 
16 39 lampret
        .text
17
        .code 32
18
        .align 2
19
 
20
/* int setjmp (jmp_buf);  */
21 56 joel
        .globl  FUNCTION(setjmp)
22
FUNCTION(setjmp):
23 39 lampret
 
24
        /* Save all the callee-preserved registers into the jump buffer. */
25
        stmea           a1!, { v1-v7, fp, ip, sp, lr }
26
 
27
#if 0   /* Simulator does not cope with FP instructions yet.... */
28
#ifndef __SOFTFP__
29
        /* Save the floating point registers */
30
        sfmea           f4, 4, [a1]
31
#endif
32
#endif
33
        /* When setting up the jump buffer return 0. */
34
        mov             a1, #0
35
 
36
        /* Return to caller, see comment in longjmp below */
37
#ifdef __APCS_26__
38
        movs            pc, lr
39
#else
40
        tst             lr, #1
41
        moveq           pc, lr
42
.word   0xe12fff1e      /*  bx lr */
43
#endif
44
 
45
 
46
/* volatile void longjmp (jmp_buf, int);  */
47 56 joel
        .globl  FUNCTION(longjmp)
48
FUNCTION(longjmp):
49 39 lampret
 
50
        /* If we have stack extension code it ought to be handled here. */
51
 
52
        /* Restore the registers, retrieving the state when setjmp() was called. */
53
        ldmfd           a1!, { v1-v7, fp, ip, sp, lr }
54
 
55
#if 0   /* Simulator does not cope with FP instructions yet.... */
56
#ifndef __SOFTFP__
57
        /* Restore floating point registers as well */
58
        lfmfd           f4, 4, [a1]
59
#endif
60
#endif
61
        /* Put the return value into the integer result register.
62
           But if it is zero then return 1 instead.  */
63
        movs            a1, a2
64
        moveq           a1, #1
65
 
66
        /* Arm/Thumb interworking support:
67
 
68
           The interworking scheme expects functions to use a BX instruction
69
           to return control to their parent.  Since we need this code to work
70
           in both interworked and non-interworked environments as well as with
71
           older processors which do not have the BX instruction we do the
72
           following:
73
                Test the return address.
74
                If the bottom bit is clear perform an "old style" function exit.
75
                (We know that we are in ARM mode and returning to an ARM mode caller).
76
                Otherwise use the BX instruction to perform the function exit.
77
 
78
           We know that we will never attempt to perform the BX instruction on
79
           an older processor, because that kind of processor will never be
80
           interworked, and a return address with the bottom bit set will never
81
           be generated.
82
 
83
           In addition, we do not actually assemble the BX instruction as this would
84
           require us to tell the assembler that the processor is an ARM7TDMI and
85
           it would store this information in the binary.  We want this binary to be
86
           able to be linked with binaries compiled for older processors however, so
87
           we do not want such information stored there.
88
 
89
           If we are running using the APCS-26 convention however, then we never
90
           test the bottom bit, because this is part of the processor status.
91
           Instead we just do a normal return, since we know that we cannot be
92
           returning to a Thumb caller - the Thumb doe snot support APCS-26
93
        */
94
 
95
#ifdef __APCS_26__
96
        movs            pc, lr
97
#else
98
        tst             lr, #1
99
        moveq           pc, lr
100
.word   0xe12fff1e      /* bx lr */
101
#endif
102
 

powered by: WebSVN 2.1.0

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