<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Sun, 22 Sep 2002 11:57:40 +0200
From   : John Kortink <kortink@...>
Subject: Re: BBC B with edge-connectors instead of IDC connectors?

On Sun, 22 Sep 2002 10:29:16 +0100, you wrote:

>In article <978qous11ckkbrkmr0vccq2m4jbvb99vj5@...>,
>   John Kortink <kortink@...> wrote:
>> On Sat, 21 Sep 2002 18:51:39 +0100, Sprow wrote:
>
>> >In article <KNEEJIOPPHNNBHBMMGACOEDFCDAA.r.gellman@...>,
>> >   Richard Gellman <r.gellman@...> wrote:
>> >> To summarise everything:
>> >
>> >[snip]
>> >
>> >> The ADFS is Paged ROM 13 in this
>> >> chip, and can be read from the Master as a ROM image using a standard 
>> >> method
>> >> of disabling interrupts, switching banks, copy the data, switch banks back,
>> >> enable interrupts, and save the data.
>> >
>> >No particular reason to disable interrupts,since interrupt handlers must
>> >preserve the ROM state anyway.The important thing is to update the 
>> >softcopy at &F4 *before* you poke the ROM latch,
>
>> No, it's still unsafe. You *have* to disable interrupts to
>> make the combined update of ?&F4 and ROMSEL (?&FE30) atomic.
>>
>> Fatal scenarios are somewhat contrived, but if an interrupt
>> occurs in between updating ?&F4 and ROMSEL, ?&F4 no longer
>> corresponds to ROMSEL during an interrupt handler, and when
>> that handler itself accesses a ROM and then *restores* ROMSEL
>> from ?&F4, it will exit with a different ROM selected than
>> when it was entered.
>
>But in your example here the IRQ happened between writing F4 and FE30,so it
>doesn't matter that both the action of exiting the interrupt routine and the
>next instruction of the foreground task both update FE30 since they both
>update it with the same value.

Depends. One possible scenario is that the interrupt handler
needs to access the ROM that was selected when the interrupt
occurred and needs to do so by explicitly switching to it at
some point (which may be, e.g., if executes partially in a
sideways ROM itself, or if it needs to access other ROMs).
It will access the wrong ROM since ?&F4 has already been
updated and no longer corresponds to the actual ROMSEL.

>As FE30 is readonly,any interrupt routine which feels it necessary to jiggle
>the ROMs around reads and stacks F4.On exit from the interrupt handler it
>pulls and writes to *both* F4 and FE30,hence my comment about writing to F4
>*first* and not bothering to disable IRQs,

Yes, but oftentimes it's 'not bothering' that causes the most
obscure of crashes. ?&F4 is simply meant to reflect the contents
of ROMSEL *at all times*, even during interrupts. You simply do
not, and should not, know what is being done in any interrupt
routines that happen to run while you're switching ROMs.


John Kortink
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>