summaryrefslogtreecommitdiffstats
path: root/private/crt32/misc/ppc/jmpuwind.s
blob: dcd129f2952b713f707dc73e72852006ca42aae4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//++
//
// Copyright (c) 1992  Microsoft Corporation
//
// Module Name:
//
//    jmpuwind.s
//
// Abstract:
//
//    This module implements the MIPS specific routine to jump to the runtime
//    time library unwind routine.
//
// Author:
//
//    David N. Cutler (davec) 12-Sep-1990
//
// Environment:
//
//    Any mode.
//
// Revision History:
//
//    Tom Wood (twood) 1-Nov-1993
//      Added __C_ExecuteExceptionFilter and __C_ExecuteTerminationHandler
//      previously deleted from the MIPS version.
//--

//list(off)
#include "ksppc.h"
//list(on)
                .extern ..RtlUnwind

//
// Define the call frame for calling the exception filter and termination
// handler.
//
                .struct 0
CfBackChain:    .space  4       // chain to previous call frame
CfSavedR31:     .space  4       // glue-saved register
CfSavedRtoc:    .space  4       // glue-saved register
                .space  3*4     // remaining part of the frame header
//++
//
// ULONG
// __C_ExecuteExceptionFilter (
//    PEXCEPTION_POINTERS ExceptionPointers,
//    EXCEPTION_FILTER ExceptionFilter,
//    ULONG EstablisherFrame
//    )
//
// Routine Description:
//
//    This function calls the specified exception filter routine with the
//    establisher environment passed in the TOC register.
//
// Arguments:
//
//    ExceptionPointers (r.3) - Supplies a pointer to the exception pointers
//       structure.
//
//    ExceptionFilter (r.4) - Supplies the address of the exception filter
//       routine.
//
//    EstablisherFrame (r.5) - Supplies the establisher frame pointer.
//
// Return Value:
//
//    The value returned by the exception filter routine.
//
//--
        SPECIAL_ENTRY(__C_ExecuteExceptionFilter)
        stw     r.31, CfSavedR31 (r.sp)         // save r.31 before using it.
        mtctr   r.4                             // get ready to call the filter.
        mflr    r.31                            // save the link register in r.31.
        stw     r.toc, CfSavedRtoc (r.sp)       // save r.toc
        PROLOGUE_END(__C_ExecuteExceptionFilter)
        or      r.toc,r.5,r.5                   // pass the establisher environment in r.toc
        bctrl                                   // branch and link to the filter.
        mtlr    r.31                            // get ready to return
        lwz     r.31, CfSavedR31 (r.sp)         // restore r.31
        lwz     r.toc, CfSavedRtoc (r.sp)       // restore r.toc
        SPECIAL_EXIT(__C_ExecuteExceptionFilter)

//++
//
// VOID
// __C_ExecuteTerminationHandler (
//    BOOLEAN AbnormalTermination,
//    TERMINATION_HANDLER TerminationHandler,
//    ULONG EstablisherFrame
//    )
//
// Routine Description:
//
//    This function calls the specified termination handler routine with the
//    establisher environment passed in the TOC register.
//
// Arguments:
//
//    AbnormalTermination (r.3) - Supplies a boolean value that determines
//       whether the termination is abnormal.
//
//    TerminationHandler (r.4) - Supplies the address of the termination
//       handler routine.
//
//    EstablisherFrame (r.5) - Supplies the establisher frame pointer.
//
// Return Value:
//
//    None.
//
//--
        SPECIAL_ENTRY(__C_ExecuteTerminationHandler)
        stw     r.31, CfSavedR31 (r.sp)         // save r.31 before using it.
        mtctr   r.4                             // get ready to call the filter.
        mflr    r.31                            // save the link register in r.31.
        stw     r.toc, CfSavedRtoc (r.sp)       // save r.toc
        PROLOGUE_END(__C_ExecuteTerminationHandler)
        or      r.toc,r.5,r.5                   // pass the establisher environment in r.toc
        bctrl                                   // branch and link to the filter.
        mtlr    r.31                            // get ready to return
        lwz     r.31, CfSavedR31 (r.sp)         // restore r.31
        lwz     r.toc, CfSavedRtoc (r.sp)       // restore r.toc
        SPECIAL_EXIT(__C_ExecuteTerminationHandler)

//++
//
// VOID
// __jump_unwind (
//    IN PVOID EstablishFrame,
//    IN PVOID TargetPc
//    )
//
// Routine Description:
//
//    This function transfer control to unwind. It is used by the MIPS
//    compiler when a goto out of the body or a try statement occurs.
//
// Arguments:
//
//    EstablishFrame (r.3) - Supplies the establisher frame pointer of the
//       target of the unwind.
//
//    TargetPc (r.4) - Supplies the target instruction address where control
//       is to be transfered to after the unwind operation is complete.
//
// Return Value:
//
//    None.
//
//--

        NESTED_ENTRY (__jump_unwind, STK_MIN_FRAME+8, 0, 0)
        PROLOGUE_END(__jump_unwind)

        li      r.5, 0                  // set NULL exception record address
        li      r.6, 0                  // set destination return value
        bl      ..RtlUnwind             // unwind to specified target
	.znop   ..RtlUnwind 

        NESTED_EXIT (__jump_unwind, STK_MIN_FRAME+8, 0, 0)