Port-cobalt archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: LCD messages on boot/shutdown (Re: Shutdown does not finish outputon LCD)



I wrote:
> If there is no objection, I'd also like to commit this patch
> (which shows "NetBSD/cobalt Startuping up..." on boot and
>  "NetBSD/cobalt Shutting down..." on shutdown to the LCD panel)
> soon.

I've changed code a bit for readability:
---
Index: dev/panel.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/dev/panel.c,v
retrieving revision 1.14
diff -u -r1.14 panel.c
--- dev/panel.c 17 Oct 2007 19:54:08 -0000      1.14
+++ dev/panel.c 2 Mar 2008 11:35:07 -0000
@@ -54,6 +54,9 @@
 #define PANEL_POLLRATE (hz / 10)
 #define PANEL_REGION   0x20
 #define DATA_OFFSET    0x10
+#define PANEL_COLS     16
+#define PANEL_VCOLS    40
+#define PANEL_ROWS     2
 
 struct panel_softc {
        struct device sc_dev;
@@ -65,8 +68,22 @@
        struct callout sc_callout;
 };
 
+struct lcd_message {
+       const char firstcol[PANEL_VCOLS];
+       const char secondcol[PANEL_VCOLS];
+};
+static const struct lcd_message startup_message = {
+       "NetBSD/cobalt   ",
+       "Starting up...  "
+};
+static const struct lcd_message shutdown_message = {
+       "NetBSD/cobalt   ",
+       "Shutting down..."
+};
+
 static int     panel_match(struct device *, struct cfdata *, void *);
 static void    panel_attach(struct device *, struct device *, void *);
+static void    panel_shutdown(void *);
 
 static void    panel_soft(void *);
 
@@ -102,7 +119,7 @@
 {
        struct panel_softc *sc = (void *)self;
        struct mainbus_attach_args *maa = aux;
-
+       struct hd44780_io io;
        static struct lcdkp_xlate keys[] = {
                { 0xfa, 'h' },
                { 0xf6, 'k' },
@@ -122,8 +139,8 @@
            1, &sc->sc_lcd.sc_iodr);
 
        sc->sc_lcd.sc_dev_ok = 1;
-       sc->sc_lcd.sc_cols = 16;
-       sc->sc_lcd.sc_vcols = 40;
+       sc->sc_lcd.sc_cols = PANEL_COLS;
+       sc->sc_lcd.sc_vcols = PANEL_VCOLS;
        sc->sc_lcd.sc_flags = HD_8BIT | HD_MULTILINE | HD_KEYPAD;
 
        sc->sc_lcd.sc_writereg = panel_cbt_hdwritereg;
@@ -132,6 +149,15 @@
 
        hd44780_attach_subr(&sc->sc_lcd);
 
+       /* Hello World */
+       io.dat = 0;
+       io.len = PANEL_VCOLS * PANEL_ROWS;
+       memcpy(io.buf, &startup_message, io.len);
+       hd44780_ddram_io(&sc->sc_lcd, sc->sc_lcd.sc_curchip, &io,
+           HD_DDRAM_WRITE);
+
+       shutdownhook_establish(panel_shutdown, sc);
+
        sc->sc_kp.sc_iot = maa->ma_iot;
        sc->sc_kp.sc_ioh = MIPS_PHYS_TO_KSEG1(0x1d000000); /* XXX */
 
@@ -146,6 +172,20 @@
        printf("\n");
 }
 
+static void
+panel_shutdown(void *arg)
+{
+       struct panel_softc *sc = arg;
+       struct hd44780_io io;
+
+       /* Goodbye World */
+       io.dat = 0;
+       io.len = PANEL_VCOLS * PANEL_ROWS;
+       memcpy(io.buf, &shutdown_message, io.len);
+       hd44780_ddram_io(&sc->sc_lcd, sc->sc_lcd.sc_curchip, &io,
+           HD_DDRAM_WRITE);
+}
+
 static uint8_t
 panel_cbt_kprread(bus_space_tag_t iot, bus_space_handle_t ioh)
 {

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index