🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.acorn.tech
Article #433

Disrupting program flow of control from interrupts

#433
From: Clive Jones
Date: Sun, 27 Sep 1992 23:47
37 lines
2220 bytes
I want to write a *safe* *tidy* routine that can, from interrupts,
schedule a given procedure to be called instantly in a foreground
program. The only assumptions I want to make are:
  My program is still the current Wimp task.
  My program adheres to ARM Procedure Call Standard.

In other words, I can't guarantee that the interrupt that is
triggering my code was raised while the processor was in user mode,
not supervisor mode - if it happens while in supervisor mode, I want
to wait for the operating system to become unthreaded before calling
the routine.

Basically, therefore, I want to:
  Store usr_LR onto the user mode stack
  Move the value the PC would otherwise have held immediately on user
  mode re-entry into usr_LR
  Ensure that the PC instead holds a value of my choosing immediately
  on re-entry.

The tricky bit in this is getting at the PC value!

The rest (stack R0-R3,LR, F0-F3, jump to the real routine I want to call,
and on return unstack R0-R3, F0-F3 then simultaneously restore the old
PC and LR) is comparatively easy.


So far, the only way I can think of of doing this is for my interrupt
routine to temporarily patch the IRQ and SWI hardware vectors to
include a small veneer that does what I want. This ensures that I know
the *precise* state of the registers for the various modes (the
elusive PC value has just been moved to svc_LR for me by the ARM). I
can't think of any way of getting the operating system to divulge the
information - even the TaskWindow module seems to just save off the
supervisor stack in its entirety rather than getting information such
as this out of it!

--Clive.
Technical Details
Message-ID: <1992Sep27.234759.24911@infodev.cam.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!spool.mu.edu!agate!doc.ic.ac.uk!uknet!pavo.csi.cam.ac.uk!cl.cam.ac.uk!crj10

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!spool.mu.edu!agate!doc.ic.ac.uk!uknet!pavo.csi.cam.ac.uk!cl.cam.ac.uk!crj10
From: crj10@phx.cam.ac.uk (Clive Jones)
Newsgroups: comp.sys.acorn.tech
Subject: Disrupting program flow of control from interrupts
Message-ID: <1992Sep27.234759.24911@infodev.cam.ac.uk>
Date: 27 Sep 92 23:47:59 GMT
Sender: news@infodev.cam.ac.uk (USENET news)
Organization: 6am Digital Playground
Lines: 37
Telephone-Messages: +44 223 33 4900
Address: Christ's College, Cambridge CB2 3BU, ENGLAND.
Nntp-Posting-Host: ashley.cl.cam.ac.uk