Skip to contentSkip to conversation

Kernel module to control front LED

sparc32 Metalhead 5 participants 9 messages Aug 26, 2005 – Sep 28, 2005

Subsystems (2)
lore
Share & tools
lore

Metalhead

author
#0 lore raw

Hi all,

I've written a kernel module that allows you to control the fron LED on
Sparcstations via /proc. It can also be compiled into the kernel, supporting display of the system load (a la NetBSD and OpenBSD) then.

Please find the patch against a vanilla 2.4.30 tree included. The sources and the patch can also be found at http://www.metalhead.ws/led.tar.gz.

Documentation/Configure.help +11 -0
diff -uprN linux-2.4.30-vanilla/Documentation/Configure.help linux-2.4.30-mod/Documentation/Configure.help
@@ -23069,6 +23083,17 @@ CONFIG_SUN_OPENPROMFS
   <file:Documentation/modules.txt>.
   The module will be called openpromfs.o.  If unsure, say M.
 
+Control front LED on sun4m machines via /proc/led (EXPERIMENTAL)
+CONFIG_SUN_LED
+  This allows you to control the front LED on sun4m machines via /proc/led. The
+  state of the LED can also be queried.
+
+  On, off and toggle do what their names suggest, an integer number makes the
+  LED blink at this interval seconds, load makes it blink according to the
+  system load (not available when compiled as a module).
+
+  If unsure, say N.
+
 Kernel support for Linux/Sparc 32bit binary compatibility
 CONFIG_SPARC32_COMPAT
   This allows you to run 32-bit binaries on your Ultra.
arch/sparc/config.in +4 -0
diff -uprN linux-2.4.30-vanilla/arch/sparc/config.in linux-2.4.30-mod/arch/sparc/config.in
@@ -64,6 +64,10 @@ else
    define_bool CONFIG_PCI n
 fi
 
+if [ "$CONFIG_PROC_FS" = "y" ]; then
+   tristate 'Control front LED on sun4m machines via /proc/led (EXPERIMENTAL)' CONFIG_SUN_LED
+fi
+
 tristate 'Openprom tree appears in /proc/openprom' CONFIG_SUN_OPENPROMFS
 bool 'Networking support' CONFIG_NET
 bool 'System V IPC' CONFIG_SYSVIPC
arch/sparc/kernel/Makefile +1 -0
diff -uprN linux-2.4.30-vanilla/arch/sparc/kernel/Makefile linux-2.4.30-mod/arch/sparc/kernel/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SMP) += trampoline.o smp.o 
 obj-$(CONFIG_SUN_AUXIO) += auxio.o
 obj-$(CONFIG_PCI) += ebus.o
 obj-$(CONFIG_SUN_PM) += apc.o pmc.o
+obj-$(CONFIG_SUN_LED) += led.o
 
 ifdef CONFIG_SUNOS_EMUL
 obj-y += sys_sunos.o sunos_ioctl.o
arch/sparc/kernel/led.c +170 -0

170 lines not on this page · raw message

Signature · 1 line
They say that bandaging one's wounds helps to keep up one's appearance.
maintainer
#1 lore raw

From: Metalhead <[email protected]>
Date: Fri, 26 Aug 2005 19:21:13 +0200

Quoted 8 lines

I've written a kernel module that allows you to control the fron
LED on Sparcstations via /proc. It can also be compiled into the kernel, supporting display of the system load (a la NetBSD and OpenBSD) then.

Please find the patch against a vanilla 2.4.30 tree included. The sources and the patch can also be found at
http://www.metalhead.ws/led.tar.gz.

Thanks for the submission, looks cool.

Can I suggest one cleanup?

+ } else if((*buf > '0') && (*buf <= '9')) { /* 0 would cause division by
+ zero */
+ for(l = 0; *buf != '\0'; buf++) { /* convert to number */
+ l = 10 * l + (*buf - '0');
+ }
+ print_debug("Starting to blink...");
+ led_blink(l);

The kernel has a library function called simple_strtoul() which you should probably use instead of this hand-crafted version.

Also, when you resubmit with this fixed, please provide a "Signed-off-by: " for yourself so that I can apply your patch.

Thanks a lot.

#2 lore raw
In reply to Metalhead

Em Tue, Sep 27, 2005 at 01:28:28PM -0700, David S. Miller escreveu:

Quoted 24 lines

From: Metalhead <[email protected]>
Date: Fri, 26 Aug 2005 19:21:13 +0200

Quoted 8 lines

I've written a kernel module that allows you to control the fron
LED on Sparcstations via /proc. It can also be compiled into the kernel, supporting display of the system load (a la NetBSD and OpenBSD) then.

Please find the patch against a vanilla 2.4.30 tree included. The sources and the patch can also be found at
http://www.metalhead.ws/led.tar.gz.

Thanks for the submission, looks cool.

Can I suggest one cleanup?

arch/sparc/kernel/led.c +7 -0
+	} else if((*buf > '0') && (*buf <= '9')) { /* 0 would cause division by
+						      zero */
+		for(l = 0; *buf != '\0'; buf++) { /* convert to number */
+			l = 10 * l + (*buf - '0');
+		}
+		print_debug("Starting to blink...");
+		led_blink(l);
Quoted 7 lines

The kernel has a library function called simple_strtoul() which you should probably use instead of this hand-crafted version.

Also, when you resubmit with this fixed, please provide a "Signed-off-by: " for yourself so that I can apply your patch.

Thanks a lot.

Is this in any way similar to what the guardian service processor in PARISC64 machines provide? I.e. one can see what the leds in the machine front panel remotely :-)

- Arnaldo

GSP>
********** VIRTUAL FRONT PANEL **********
System Boot detected
*****************************************

LEDs:  RUN      ATTENTION     FAULT     REMOTE     POWER
       FLASH    FLASH         OFF       ON         ON

LED State: Running non-OS code. Non-critical error detected. Check Chassis and Console Logs for error messages.

platform config

maintainer
#3 lore raw
In reply to Metalhead

From: [email protected] (Arnaldo Carvalho de Melo)
Date: Tue, 27 Sep 2005 18:18:59 -0300

Quoted 3 lines

Is this in any way similar to what the guardian service processor in PARISC64 machines provide? I.e. one can see what the leds in the machine front panel remotely :-)

Nah, this is just a physical single LED on the front panel of the machine that you can toggle on an off by flipping a bit in an I/O register.

#4 lore raw
In reply to Metalhead
Quoted 10 lines · David S. Miller

From: [email protected] (Arnaldo Carvalho de Melo)
Date: Tue, 27 Sep 2005 18:18:59 -0300

Quoted 3 lines

Is this in any way similar to what the guardian service processor in PARISC64 machines provide? I.e. one can see what the leds in the machine front panel remotely :-)

Nah, this is just a physical single LED on the front panel of the machine that you can toggle on an off by flipping a bit in an I/O register.

Arnaldo,

Certain Sun systems do have this sort of feature-- it has been called Lights Out Management (LOM), Remote System Control (RSC) and the like.
Basically, proprietary, pre-IPMI management controllers of varying
functionality. As DaveM mentions, this isn't it, though... :)

There is ongoing work to support such controllers (e.g. on Sun E250 and E450 servers).
--
E

#5 lore raw
In reply to Metalhead
Quoted 14 lines · Eric Brower
Quoted 10 lines · David S. Miller

From: [email protected] (Arnaldo Carvalho de Melo)
Date: Tue, 27 Sep 2005 18:18:59 -0300

Quoted 3 lines

Is this in any way similar to what the guardian service processor in PARISC64 machines provide? I.e. one can see what the leds in the machine front panel remotely :-)

Nah, this is just a physical single LED on the front panel of the machine that you can toggle on an off by flipping a bit in an I/O register.

Arnaldo,

Quoted 7 lines

Certain Sun systems do have this sort of feature-- it has been called Lights Out Management (LOM), Remote System Control (RSC) and the like.
Basically, proprietary, pre-IPMI management controllers of varying
functionality. As DaveM mentions, this isn't it, though... :)

There is ongoing work to support such controllers (e.g. on Sun E250 and E450 servers).

Thanks for the information! I have to find time to get my SS 10 back to life and use it to test my kernel hacks :-)

BTW, is 2.6.latest working well on Sparcstation 10s?

- Arnaldo

maintainer
#6 lore raw
In reply to Metalhead

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Tue, 27 Sep 2005 21:48:47 -0300

Quoted 1 line

BTW, is 2.6.latest working well on Sparcstation 10s?

For some people yes, for some other folks no. Sparc32 doesn't get much tender love & care lately. :-/

#7 lore raw
In reply to Metalhead
Quoted 7 lines · David S. Miller

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Tue, 27 Sep 2005 21:48:47 -0300

Quoted 1 line

BTW, is 2.6.latest working well on Sparcstation 10s?

For some people yes, for some other folks no. Sparc32 doesn't get much tender love & care lately. :-/

(sorry dave for the duplicate...)

how about hyperSPARC? how about SMP on 32 bit?

I am merely interested in an update...

--
Cheers,

/ChJ

author
#8 lore raw
In reply to Metalhead

Hi,

I've changed the patch to use simple_strtoul() and included a signed-off-by
line, thanks for the tip. Although this change was small, please be aware that I didn't test this version, as I unfortunately don't have access to a sparcstation right now.

Thanks.

Lars

Documentation/Configure.help +11 -0
diff -uprN linux-2.4.30-vanilla/Documentation/Configure.help linux-2.4.30-mod/Documentation/Configure.help
@@ -23069,6 +23083,17 @@ CONFIG_SUN_OPENPROMFS
   <file:Documentation/modules.txt>.
   The module will be called openpromfs.o.  If unsure, say M.
 
+Control front LED on sun4m machines via /proc/led (EXPERIMENTAL)
+CONFIG_SUN_LED
+  This allows you to control the front LED on sun4m machines via /proc/led. The
+  state of the LED can also be queried.
+
+  On, off and toggle do what their names suggest, an integer number makes the
+  LED blink at this interval seconds, load makes it blink according to the
+  system load (not available when compiled as a module).
+
+  If unsure, say N.
+
 Kernel support for Linux/Sparc 32bit binary compatibility
 CONFIG_SPARC32_COMPAT
   This allows you to run 32-bit binaries on your Ultra.
arch/sparc/config.in +4 -0
diff -uprN linux-2.4.30-vanilla/arch/sparc/config.in linux-2.4.30-mod/arch/sparc/config.in
@@ -64,6 +64,10 @@ else
    define_bool CONFIG_PCI n
 fi
 
+if [ "$CONFIG_PROC_FS" = "y" ]; then
+   tristate 'Control front LED on sun4m machines via /proc/led (EXPERIMENTAL)' CONFIG_SUN_LED
+fi
+
 tristate 'Openprom tree appears in /proc/openprom' CONFIG_SUN_OPENPROMFS
 bool 'Networking support' CONFIG_NET
 bool 'System V IPC' CONFIG_SYSVIPC
arch/sparc/kernel/Makefile +1 -0
diff -uprN linux-2.4.30-vanilla/arch/sparc/kernel/Makefile linux-2.4.30-mod/arch/sparc/kernel/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SMP) += trampoline.o smp.o 
 obj-$(CONFIG_SUN_AUXIO) += auxio.o
 obj-$(CONFIG_PCI) += ebus.o
 obj-$(CONFIG_SUN_PM) += apc.o pmc.o
+obj-$(CONFIG_SUN_LED) += led.o
 
 ifdef CONFIG_SUNOS_EMUL
 obj-y += sys_sunos.o sunos_ioctl.o
arch/sparc/kernel/led.c +167 -0

167 lines not on this page · raw message

Signed-off-by Lars Kotthoff
Signature · 1 line
Horses trust their riders, even when not so deserved.