home *** CD-ROM | disk | FTP | other *** search
- > <WimpDebug$Dir>.Docs.TechInfo
-
- *** WimpDebug technical information ***
- Last revised 26 August 1991
- Documents version 1.21
-
-
- ________________ Technical details (ARM SWI interface) ______________________
-
- The WimpDebug ARM SWI interface is very non-standard - it does not follow
- the SWI allocation scheme normally used by modules. This is caused by the
- need to pass on all parameters within the SWI number itself, often requiring
- 12 bits or more of data, which does not fit at all within the normal system
- of 64 SWI numbers per chunk.
- In order to implement the ARM SWI scheme, WimpDebug claims the SWI
- hardware vector. Upon receiving an SWI call, it checks its number to find out
- if it's a debug SWI. If it is, it's processed, and control returns to the
- calling program; otherwise, the call is passed on to the previous owner of
- the SWI hardware vector (normally the operating system).
- The WimpDebug SWI handler code looks like this:
-
- ;==============================================================================
- ; SWI hardware vector handler
- ;==============================================================================
- SWIhandler STMFD SP!,{R10-R12,R14}; Get me some work registers
- BIC R12,R14,#&FC000003; Fetch the SWI instruction
- LDR R11,[R12,#-4] ; which invoked the handler
- AND R10,R11,#&FF0000; Is it one of my routines?
- TEQ R10,#&FF0000
- BEQ SWIhandler1 ; Branch to handler code if so
-
- ; OS SWI received - pass it on
-
- MOV R10,PC ; Restore the NZCV flags to the status
- BIC R10,R10,#ms4 ; they were in when my SWI handler
- AND R11,R14,#ms4 ; was entered
- TEQP R10,R11
- LDR R10,OldSWIvector; Branch to the old SWI handler by
- LDR R10,[R10] ; replacing the stacked R14 with the
- STR R10,[SP,#12] ; vector to the old handler
- LDMFD SP!,{R10-R12,PC}
-
- ; One of my SWIs encountered - process it
-
- SWIhandler1 ADR R10,RegBuffer ; Store unbanked regs.
- STMIA R10!,{R0-R7}
- MOV R0,R10 ; Move regbuffer ptr & SWI number
- MOV R1,R11 ; to the freed regs
- LDMFD SP!,{R10-R12,R14}; Restore the workspace registers
- STMIA R0!,{R8-R14}^ ; Store the top half of USR regs รท PC
- MOV R0,R0 ; (safety NOP)
- STR R14,[R0] ; R14_SVC holds R15_USR
- .
- .
- Show handler code
- .
- .
-
- ; Exit from debug SWI handler
-
- SWI_Exit ADR R14,RegBuffer ; Restore R0-R12_USR
- LDMIA R14!,{R0-R12}^
- MOV R0,R0 ; (safety NOP)
- LDR R14,[R14,#8] ; Fetch return address separately
- MOVS PC,R14 ; and exit with correct PSR status
-
- RegBuffer % 16*4
-
-
- Although Acorn advise against claiming the SWI hardware vector, I figured
- it would be the best solution to use with this program. I have checked the
- behaviour of the module comprehensively, and I am quite certain that it
- behaves well when exposed to soft resets, RMTidy and other rough treatment.
- I have also tested it quite thoroughly with some test programs which did
- nothing but send display requests to WimpDebug in the background. I have
- been using the machine for long periods of time with WimpDebug and the test
- programs running while doing DTP work etc., and it has never crached or
- misbehaved. Of course, that doesn't prove anything about the reliability of
- WimpDebug, but at least it hasn't been left untested.
-
- The WimpDebug SWI handler does call normal OS SWIs, mainly for doing
- number conversions etc. But all the SWIs used are re-entrant, meaning that
- WimpDebug SWIs may be used safely when the processor is in IRQ mode. So if
- you find yourself writing an interrupt service routine, you can use
- WimpDebug then, too!
-
- No registers are altered by the ARM debug SWI routines. Note that
- WimpDebug will always display User Mode registers only - this implies that
- the SVC or IRQ versions of R13 and R14 can not be displayed.
- WimpDebug will always trap and process any debug SWIs when the module is
- present in the machine; it doesn't matter whether the display window is open
- or not, or the WimpDebug task is not running. Thus, if you run a program in
- the Supervisor which issues debug SWIs, WimpDebug still catches any shown
- data. To see the end result, either use the *WDList command or enter the
- desktop and look at the display window.
-
- All debug SWIs may be executed conditionally, except those that expect
- literal data to follow the SWI instruction.
-
- "What happens if a debug SWI is issued and the WimpDebug module is not
- present in the machine?", I hear you ask. Well, to be honest, I'm not quite
- sure about it. I have experienced two possibilities: either the call is
- ignored completely (or so it appears), or an "Unknown SWI" error is given. I
- have not been able to sort out any systematic explanation of what is going
- on - it's really quite unpredictable.
- Anyway, whatever is going on, it's not good programming to leave debug
- SWIs in a finished program, even if they seem to be completely harmless.
-
-
-
- ____________________ Technical details: (Display window) ___________________
-
- The display window consists of 32 virtual text icons. Virtual because
- they are not part of the actual window definition, but drawn 'manually'
- whenever redraw requests are issued.
-
- The contents of the Display window icons is not altered directly by the
- various *commands or SWIs which display something. Instead, when something
- is to be shown, all the SWI does is to store away the necessary data in a
- buffer (there is one 256 char. buffer for each icon), which holds the text
- to be shown in the icon. In addition, information about the display style
- used and the (register) value given is stored.
- For updating the contents of the display window, WimpDebug relies on
- receiving Null events from Wimp_Poll. Upon receiving such an event, all
- icons are checked to see if they have been flagged for update by the SWI
- handlers. Then, for all icons to be updated, the data stored in the buffer
- by the SWI handler is made the current icon data for that particular icon,
- and the icon is redrawn on the screen.
- Thus, WimpDebug will correctly display all given values as long as the
- Wimp is working. If your program calls some debug SWIs and then terminates
- (perhaps with an error), then WimpDebug will show the values it did send
- the next time it receives a Null event.
- In addition to null events, the *WDListIcons command also refreshes the
- contents of the icons, so that the information it shows is always up to
- date.
-