; ; toolSupprt.s ; ; Support for Toolbox operations ; ; © 1994-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Glass. ; ; Glass is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Glass is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with Glass. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. GET libs:Header GET libs:SWIs ; ; This module attempts to call Wimp_DragBox without it generating exceptions ; within the program. Because most of it is operating system interface, ; I've used standard register names, rather than APCS ones. It does all ; sorts of 'orrible things, and queasy maintenence programmers would be well ; advised to look elsewhere for bits to tweak. ; ;----- External dependencies ------------------------------------------------ AREA |Asm$Code|,CODE,READONLY ;----- External routines ---------------------------------------------------- ; ; toolSupprt_doDrag ; ; Use ; Calls Wimp_DragBox, with suitable binding to prevent nasty errors from ; bringing the system down (with any luck). It usurps a bunch of handlers, ; does the call, and puts the handlers back. Pretty simple, really. ; ; Because it does all sorts of 'orrible things, it doesn't use standard ; APCS headers. Instead, it just stacks everything and gets on with it. ; ; C prototype ; void toolSupprt_doDrag(wimp_dragstr *d); ; ; On entry: a1 points to a Wimp_DragBox structure ; On exit: - ; EXPORT toolSupprt_doDrag toolSupprt_doDrag ROUT STMFD R13!,{R4-R12,R14} ;Save the registers to save MOV R11,R0 ;Look after pointer LDR R8,=toolSupprt__ohand ;Point to old handler buff MOV R0,#2 ;Prefetch abort handler ADR R1,toolSupprt__handler ;Point to handler SWI XOS_ChangeEnvironment ;Register handler STMIA R8!,{R1-R3} ;Store old handler info MOV R0,#3 ;Data abort handler ADR R1,toolSupprt__handler ;Point to handler SWI XOS_ChangeEnvironment ;Register handler STMIA R8!,{R1-R3} ;Store old handler info MOV R0,#4 ;Address exception handler ADR R1,toolSupprt__handler ;Point to handler SWI XOS_ChangeEnvironment ;Register handler STMIA R8!,{R1-R3} ;Store old handler info LDR R0,=toolSupprt__stack ;Ready to store stack ptr STR R13,[R0] ;Stored MOV R1,R11 ;Get block pointer again SWI XWimp_DragBox ;Do the dodgy SWI toolSupprt__handler MOV R0,PC ;Get PSR BIC R0,R0,#3 ;Clear mode flags TEQP R0,#0 ;Back to ol' user mode LDR R0,=toolSupprt__stack ;Where we stored the stack LDR R13,[R0] ;Get stack pointer LDR R8,=toolSupprt__ohand ;Point to old handler buff MOV R0,#2 ;Prefetch abort handler LDMIA R8!,{R1-R3} ;Get old status SWI XOS_ChangeEnvironment ;Put back old handler MOV R0,#3 ;Data abort handler LDMIA R8!,{R1-R3} ;Get old status SWI XOS_ChangeEnvironment ;Put back old handler MOV R0,#4 ;Address exception handler LDMIA R8!,{R1-R3} ;Get old status SWI XOS_ChangeEnvironment ;Put back old handler LDMFD R13!,{R4-R12,PC}^ ;Return to caller ;----- Static data ---------------------------------------------------------- AREA |Asm$Data|,DATA toolSupprt__ohand % 4*3*3 ;Old handler information toolSupprt__stack DCD 0 ;Stack pointer END