Emulator idle detect [was Re: Clock Error]

Mouse <[email protected]>
Newsgroups gmane.os.netbsd.ports.vax
Message-ID <[email protected]>
[bqt@]
> Unless I misremember, it raises the IPL to 1.  A level that is
> otherwise meaningless, so not something done by mistake, and not
> something used by anything.

But setting IPL to 1 being "otherwise meaningless" or "not [] used by
anything" are very OS-specific things.

I suppose that's at least one reason why, as quoted below, simh has a
BSD-specific internal flag controlling idle detection.

[kwellsch@]
> ... and FWIW, this it the hackish patch I made to SIMH 3.12-4 to
> carry over the correct IDLE detection code that is part of open-simh
> (4.1).

>      case MT_IPL:                                        /* IPL */
>          PSL = (PSL & ~PSL_IPL) | ((val & PSL_M_IPL) << PSL_V_IPL);
> +        if ((VAX_IDLE_BSD & cpu_idle_mask) &&           /* New NetBSD and OpenBSD */
> +            (0 != (PC & 0x80000000)) &&                 /* System Space (Not BOOT ROM) */
> +            (val == 1))                                 /* IPL 1 */
> +            cpu_idle();                                 /* idle loop */
>          break;

Ah, glad I asked!  Just from the kernel code jbglaw@ quoted, I would
not have inferred the "PC must be in system space" condition.

I wonder if I could autodetect idle loops as "any loop within the body
of which no writes, and no reads of anything but main memory, are
done".  For a simple implementation I'd probably have to limit the size
of the loop to something like maybe 8 or 16 instructions, but it might
be doable.  (Idle would have to be broken by not just interrupts but
also DMA, though, for that to work properly in full generality.)

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		[email protected]
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.