Subject: Re: lcd shutdown message in 1.6.1
To: None <port-cobalt@netbsd.org>
From: Dennis Chernoivanov <cdi@mawhrin.net>
List: port-cobalt
Date: 10/01/2003 22:00:27
--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


I've just finished a little hack to get this message on the LCD screen. The
patch is attached, lcd.diff is for 1.6.x kernels and panel.diff is for
-current.

SY,
--cdi

On Mon, Sep 29, 2003 at 10:24:59PM +0100, jallan@freeuk.com wrote:
> just a passing muse.
> 
> you remember a few posts asking about the lack of a message that says it is now 
> safe to shutdown your qube as per original Linux/Qube install?
> 
> I know that this had not been cracked yet. just a thought, is there any chance 
> that it is loaded into RAM to be dumped when the HD etc power down?
> 
> actually my fan is so loud, I dont know if it does power down and without the 
> message or serial connection it is hard to know what it is safe to switch off.
> 
> nice to read of so many Mac users on this list ... it must be a Cube-Qube 
> thing. or just the attraction of attractive computers.
> 
> John
> Delete | Reply | Reply to All | Forward | Redirect | Message Source | S

--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="lcd.diff"

--- orig.lcd.c	Wed Oct  1 21:39:54 2003
+++ lcd.c	Wed Oct  1 21:42:57 2003
@@ -69,6 +69,10 @@
 static void	lcd_cbt_rwrite(bus_space_tag_t, bus_space_handle_t, u_int8_t);
 static u_int8_t	lcd_cbt_rread(bus_space_tag_t, bus_space_handle_t);
 
+static void	poweroff_hook(void *);
+static void	greeting(struct hd44780_chip *);
+static void	lcd_print(struct hd44780_chip *, const char *);
+
 struct cfattach lcd_ca = {
 	sizeof(struct lcd_softc), lcd_match, lcd_attach
 };
@@ -124,6 +128,9 @@
 	lcdkp_attach_subr(&sc->sc_kp);
 
 	callout_init(&sc->sc_callout);
+ 
+	greeting(&sc->sc_lcd);
+	shutdownhook_establish(poweroff_hook, &sc->sc_lcd);
 
 	printf("\n");
 }
@@ -255,4 +262,37 @@
 		selwakeup(&sc->sc_selq);
 	else
 		callout_reset(&sc->sc_callout, LCD_POLLRATE, lcdsoft, sc);
+}
+
+static void
+greeting(sc)
+	struct hd44780_chip *sc;
+{
+	char buf[HD_MAX_CHARS + 1];
+
+	buf[HD_MAX_CHARS] = 0;
+	snprintf(buf, HD_MAX_CHARS, "%s %s", ostype, osrelease);
+	lcd_print(sc, buf);
+}
+
+static void
+lcd_print(sc, s)
+	struct hd44780_chip *sc;
+	const char *s;
+{
+	struct hd44780_io io;
+
+	if ( (io.len = strlen(s)) > HD_MAX_CHARS)
+		io.len = HD_MAX_CHARS;
+	io.dat = 0;
+	memcpy(io.buf, s, io.len);
+	hd44780_ddram_redraw(sc, &io);
+}
+
+static void
+poweroff_hook(p)
+	void *p;
+{
+	struct hd44780_chip *sc_lcd = p;
+	lcd_print(sc_lcd, "System halted.");
 }

--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="panel.diff"

Index: panel.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/dev/panel.c,v
retrieving revision 1.3
diff -u -r1.3 panel.c
--- panel.c	2003/09/12 14:59:14	1.3
+++ panel.c	2003/09/22 08:23:36
@@ -71,6 +71,10 @@
 static void	panel_cbt_rwrite(bus_space_tag_t, bus_space_handle_t, u_int8_t);
 static u_int8_t	panel_cbt_rread(bus_space_tag_t, bus_space_handle_t);
 
+static void	poweroff_hook(void *);
+static void	greeting(struct hd44780_chip *);
+static void	panel_print(struct hd44780_chip *, const char *);
+
 dev_type_open(panelopen);
 dev_type_close(panelclose);
 dev_type_read(panelread);
@@ -141,6 +145,9 @@
 
 	callout_init(&sc->sc_callout);
 
+	greeting(&sc->sc_lcd);
+	shutdownhook_establish(poweroff_hook, &sc->sc_lcd);
+
 	printf("\n");
 }
 
@@ -269,4 +276,37 @@
 		selwakeup(&sc->sc_selq);
 	else
 		callout_reset(&sc->sc_callout, PANEL_POLLRATE, panel_soft, sc);
+}
+
+static void
+greeting(sc)
+	struct hd44780_chip *sc;
+{
+	char buf[HD_MAX_CHARS + 1];
+
+	buf[HD_MAX_CHARS] = 0;
+	snprintf(buf, HD_MAX_CHARS, "%s %s", ostype, osrelease);
+	panel_print(sc, buf);
+}
+
+static void
+panel_print(sc, s)
+	struct hd44780_chip *sc;
+	const char *s;
+{
+	struct hd44780_io io;
+
+	if ( (io.len = strlen(s)) > HD_MAX_CHARS)
+		io.len = HD_MAX_CHARS;
+	io.dat = 0;
+	memcpy(io.buf, s, io.len);
+	hd44780_ddram_redraw(sc, &io);
+}
+
+static void
+poweroff_hook(p)
+	void *p;
+{
+	struct hd44780_chip *sc_lcd = p;
+	panel_print(sc_lcd, "System halted.");
 }

--FCuugMFkClbJLl1L--