chiark / gitweb /
Initial revision
[ssr] / StraySrc / Glass / !Glass / s / toolSupprt
1 ;
2 ; toolSupprt.s
3 ;
4 ; Support for Toolbox operations
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Glass.
12 ;
13 ; Glass is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Glass is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Glass.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27                    GET     libs:Header
28                    GET     libs:SWIs
29
30 ;
31 ; This module attempts to call Wimp_DragBox without it generating exceptions
32 ; within the program.  Because most of it is operating system interface,
33 ; I've used standard register names, rather than APCS ones.  It does all
34 ; sorts of 'orrible things, and queasy maintenence programmers would be well
35 ; advised to look elsewhere for bits to tweak.
36 ;
37
38 ;----- External dependencies ------------------------------------------------
39
40                    AREA    |Asm$Code|,CODE,READONLY
41
42 ;----- External routines ----------------------------------------------------
43
44 ;
45 ; toolSupprt_doDrag
46 ;
47 ; Use
48 ;  Calls Wimp_DragBox, with suitable binding to prevent nasty errors from
49 ;  bringing the system down (with any luck).  It usurps a bunch of handlers,
50 ;  does the call, and puts the handlers back.  Pretty simple, really.
51 ;
52 ;  Because it does all sorts of 'orrible things, it doesn't use standard
53 ;  APCS headers.  Instead, it just stacks everything and gets on with it.
54 ;
55 ; C prototype
56 ;  void toolSupprt_doDrag(wimp_dragstr *d);
57 ;
58 ; On entry: a1 points to a Wimp_DragBox structure
59 ; On exit:  -
60 ;
61
62                    EXPORT  toolSupprt_doDrag
63 toolSupprt_doDrag  ROUT
64                    STMFD   R13!,{R4-R12,R14}  ;Save the registers to save
65                    MOV     R11,R0             ;Look after pointer
66                    LDR     R8,=toolSupprt__ohand ;Point to old handler buff
67                    MOV     R0,#2              ;Prefetch abort handler
68                    ADR     R1,toolSupprt__handler ;Point to handler
69                    SWI     XOS_ChangeEnvironment ;Register handler
70                    STMIA   R8!,{R1-R3}        ;Store old handler info
71                    MOV     R0,#3              ;Data abort handler
72                    ADR     R1,toolSupprt__handler ;Point to handler
73                    SWI     XOS_ChangeEnvironment ;Register handler
74                    STMIA   R8!,{R1-R3}        ;Store old handler info
75                    MOV     R0,#4              ;Address exception handler
76                    ADR     R1,toolSupprt__handler ;Point to handler
77                    SWI     XOS_ChangeEnvironment ;Register handler
78                    STMIA   R8!,{R1-R3}        ;Store old handler info
79                    LDR     R0,=toolSupprt__stack ;Ready to store stack ptr
80                    STR     R13,[R0]           ;Stored
81
82                    MOV     R1,R11             ;Get block pointer again
83                    SWI     XWimp_DragBox      ;Do the dodgy SWI
84
85 toolSupprt__handler
86                    MOV     R0,PC              ;Get PSR
87                    BIC     R0,R0,#3           ;Clear mode flags
88                    TEQP    R0,#0              ;Back to ol' user mode
89                    LDR     R0,=toolSupprt__stack ;Where we stored the stack
90                    LDR     R13,[R0]           ;Get stack pointer
91                    LDR     R8,=toolSupprt__ohand ;Point to old handler buff
92                    MOV     R0,#2              ;Prefetch abort handler
93                    LDMIA   R8!,{R1-R3}        ;Get old status
94                    SWI     XOS_ChangeEnvironment ;Put back old handler
95                    MOV     R0,#3              ;Data abort handler
96                    LDMIA   R8!,{R1-R3}        ;Get old status
97                    SWI     XOS_ChangeEnvironment ;Put back old handler
98                    MOV     R0,#4              ;Address exception handler
99                    LDMIA   R8!,{R1-R3}        ;Get old status
100                    SWI     XOS_ChangeEnvironment ;Put back old handler
101                    LDMFD   R13!,{R4-R12,PC}^  ;Return to caller
102
103 ;----- Static data ----------------------------------------------------------
104
105                    AREA    |Asm$Data|,DATA
106
107 toolSupprt__ohand  %       4*3*3              ;Old handler information
108 toolSupprt__stack  DCD     0                  ;Stack pointer
109
110                    END