65816 Hardware Memory Protection
Posted: Sun May 01, 2005 7:23 am
I don't know a ton so this is all theoretical, but I believe I have generated a rough method of adding memory protection to a 65816 and would like to spark discussion on this.
This won't work on 6502 because of lack of an ABORTB pin+interrupt that cancels the currently executing instruction.
The basic idea is to intercept the address bus and compare it via some gates to an eight-bit latch or outputs from a CIA or VIA on a port. If the address bus bank (A16-A23) match the set protection range while protection is enabled (probably by cutting out A16 and protecting 256K or by using another I/O port) then the R/W line (intercepted by this mechanism on all transactions) would be disconnected and the ABORTB pin triggered, and the protect enable would be toggled off. This will allow the ABORT NMI to take effect without re-triggering the protection until enabled again. The ABORT handler can terminate the process that was executing at the time of the IRQ and continue OS operation. This protection mechanism would provide a "user mode" and "kernel mode" like modern i386, SPARC, 680x0, PPC, etc. systems.
Actual implementation would be a bit heavy on gates, probably best to do with FPGA(?). NAND gates on the address bus and the latch or port can provide the ABORT + disable protection + cut R/W for one cycle signal. Throw some flip-flops in there for toggling. I'm sure it can be done but I am a bit more of a software guy.
Let's talk about this, or shoot it down in flames. Either way I'd like to know if this thinking was worth the time :)
This won't work on 6502 because of lack of an ABORTB pin+interrupt that cancels the currently executing instruction.
The basic idea is to intercept the address bus and compare it via some gates to an eight-bit latch or outputs from a CIA or VIA on a port. If the address bus bank (A16-A23) match the set protection range while protection is enabled (probably by cutting out A16 and protecting 256K or by using another I/O port) then the R/W line (intercepted by this mechanism on all transactions) would be disconnected and the ABORTB pin triggered, and the protect enable would be toggled off. This will allow the ABORT NMI to take effect without re-triggering the protection until enabled again. The ABORT handler can terminate the process that was executing at the time of the IRQ and continue OS operation. This protection mechanism would provide a "user mode" and "kernel mode" like modern i386, SPARC, 680x0, PPC, etc. systems.
Actual implementation would be a bit heavy on gates, probably best to do with FPGA(?). NAND gates on the address bus and the latch or port can provide the ABORT + disable protection + cut R/W for one cycle signal. Throw some flip-flops in there for toggling. I'm sure it can be done but I am a bit more of a software guy.
Let's talk about this, or shoot it down in flames. Either way I'd like to know if this thinking was worth the time :)