My current emulation writes the outgoing I/O (ASM OUT instruction or emulator handler doing the same, e.g. INT 10h handler) to all hardware devices. The hardware itself (VGA, PIC, PIT, DMA, Adlib, Debugger(See Bochs E9 Hack, but with some extras added for control of the emulator using a special output command read/written to port E9&EA), 8042 chip, CMOS, FDC, UART) processes the outgoing byte and gives 1 when processed or 0 when ignored(not processed because it's not listening to the I/O port). The same happens during reads, which give a result (the data read from the I/O port) and status (1 when processed or 0 when ignored).
My current error handling mechanism simply gives all values from the hardware OR'ed with each other for devices giving a 1 (processed) during reads. When no hardware is found (nothing is listening to the I/O port) during reads or writes, the error handling mechanism invokes an emulated (so for the currently emulated CPU) NMI when possible (not already an NMI running, see behaviour of IRET during NMI). When it launches an NMI it sets bit in I/O port 0x61 according to the thing that went wrong:
Bit 6 (value 0x40) is set when a Bus error has occurred. Currently only I/O port instructions (IN, OUT, INS and OUTS instructions) with nothing listening to them triggers this bit set and executes an NMI interrupt.
Bit 7 (value 0x80) is set when a Memory access error has occurred. Currently only the MMU triggers this bit with an NMI executed when it notices that memory is written to that doesn't exist (e.g. writing or reading to/from an address above 1MB memory with only 1MB memory or less emulated).
Is this behaviour correct?