BigDumbDinosaur wrote:
Proxy wrote:
I Agree that NMI should be used for the periodic interrupt and task switching instead of IRQ.
...something I would never do. In my POC units, an NMI is the means by which I regain control when a programming error causes the MPU to get stuck in a loop.
well that's not really necessary as in that case the NMI would fire periodically instead of at a press of a button, making it functionally almost the same, but automated. so if a task gets stuck in a loop the whole system isn't brought to a halt.
(that also makes me wonder, how would an OS detect if a task is stuck in a loop?)
BigDumbDinosaur wrote:
In my more than 50 years of working with preemptive, multitasking, multiuser systems, I have yet to see any of them use NMIs for jiffy interrupt generation and task switching.
seems perfect to me if you have nothing else on the board using NMI. plus it could be routed through the MMU to only allow NMIs to pass when the system is in user-mode. meaning the system won't receive another NMI while it's already handling one. effectly turning it into an IRQ but not in control of the CPU itself, making it easier to protect against user tasks compared to the internal interrupt flag.
BigDumbDinosaur wrote:
Once an NMI occurs, no more NMIs will be recognized until all causes of the original NMI have been cleared. A trivial logic error in the NMI code could fail to detect a still-pending NMI, ultimately resulting in deadlock.
this assumes the interrupt source would keep the NMI line low instead of just pulsing it, in which case yes, additional NMIs coming in wouldn't be recognized.
but if i were to design a board around a 65816 with an MMU i would have exactly 1 device on the NMI line, the jiffy timer, to avoid ambiguity and this issue above.
but that's just how i would design it. if you build the timer around the IRQ instead then you either need a more sophisticated MMU (or HMU) to avoid interrupt flag changing instructions or just trust user programs to not mess with the i flag and simply deal with accidents that mess with it anyways.
and i do agree with BigEd. feature creep is a slippery slope!
so i'll just lock down the MMU/MPU idea i had to just be simple 2 segment memory protection, with bank 0 relocation, interrupt detection to switch into a supervisor mode, and a counter-delayed swich back to user mode when writing to a specific IO register.
it won't ptotect against STP or messing with the interrupt flag, but that's good enough.