Those LEDs in the UNIXpc, one last time; (HwNote01)

John B. Milton jbm at uncle.UUCP
Tue Oct 11 14:54:19 AEST 1988


This is the first in a series of interesting hardware notes.

Yes, there are LEDs in the UNIXpc. They located on the left side of the system
near the front. There are four of them, and this is what they really do while
unix is running:

(left to right)

0 RED:    This is the "user LED". It can be turned on and off with the
          syslocal(2) call. It is not used by any existing applications.
1 GREEN:  This is the one most people get wrong. This LED toggles everytime
          there is a process context change, and is cleared on the whole second
2 YELLOW: This is the idle LED. When it is on, there are no processes in the
          ready to run state.
3 RED:    Heart beat LED. This is toggled on the whole second.

In the I/O scheme of things, they are the low 4 bits of the Micellaneous
Control Register (MCR), at address $4A0000, word access. See the file
/usr/include/sys/hardware.h for more detail.

The user LED comes in handy when goofing around with drivers and when eprintf
would be too expensive. The problem comes with the other bits of the MCR.
Since the MCR is write only, you can't read it to get the current state. The
kernel takes care of this by having a "last written value" variable, in this
case called mcr_save:
/*	mcr_save must be written to whenever the real MCR is written to. */
extern ushort	mcr_save;
#define led_on(x)	*MCR_ADDR = (mcr_save &= ~(ushort)(x))
#define led_off(x)	*MCR_ADDR = (mcr_save |= (ushort)(x))
#define led_toggle(x)	*MCR_ADDR = (mcr_save ^= (ushort)(x))

As as an example, "led_on(LED0)" produces the code:
	and.w	&65279,mcr_save
	mov.w	mcr_save,4849664
Note that since there is no locking here, an interrupt routine that uses the
MCR could run between these two instructions. Knowing which interrupt routines
use the MCR would provide the right kind of information to use the spl stuff
<sys/spl.h> correctly to avoid trouble.

Stay tuned.

John
--
-- 
John Bly Milton IV, jbm at uncle.UUCP, n8emr!uncle!jbm at osu-cis.cis.ohio-state.edu
home (614) 294-4823, work (614) 764-4272;  Send vi tricks, I'm making a manual



More information about the Comp.sys.att mailing list