Update ia64 patch to 2.5.69-030521, throwing away the parts included
[linux-flexiantxendom0-3.2.10.git] / kernel / printk.c
index a7a9811..1defc9f 100644 (file)
@@ -308,6 +308,12 @@ static void _call_console_drivers(unsigned long start, unsigned long end, int ms
                        __call_console_drivers(start, end);
                }
        }
+#ifdef CONFIG_IA64_EARLY_PRINTK
+       if (!console_drivers) {
+               void early_printk (const char *str, size_t len);
+               early_printk(&LOG_BUF(start), end - start);
+       }
+#endif
 }
 
 /*
@@ -625,7 +631,11 @@ void register_console(struct console * console)
                 * for us.
                 */
                spin_lock_irqsave(&logbuf_lock, flags);
+#ifdef CONFIG_IA64_EARLY_PRINTK
+               con_start = log_end;
+#else
                con_start = log_start;
+#endif
                spin_unlock_irqrestore(&logbuf_lock, flags);
        }
        release_console_sem();
@@ -678,3 +688,110 @@ void tty_write_message(struct tty_struct *tty, char *msg)
                tty->driver->write(tty, 0, msg, strlen(msg));
        return;
 }
+
+#ifdef CONFIG_IA64_EARLY_PRINTK
+
+#include <asm/io.h>
+
+# ifdef CONFIG_IA64_EARLY_PRINTK_VGA
+
+
+#define VGABASE                ((char *)0xc0000000000b8000)
+#define VGALINES       24
+#define VGACOLS                80
+
+static int current_ypos = VGALINES, current_xpos = 0;
+
+static void
+early_printk_vga (const char *str, size_t len)
+{
+       char c;
+       int  i, k, j;
+
+       while (len-- > 0) {
+               c = *str++;
+               if (current_ypos >= VGALINES) {
+                       /* scroll 1 line up */
+                       for (k = 1, j = 0; k < VGALINES; k++, j++) {
+                               for (i = 0; i < VGACOLS; i++) {
+                                       writew(readw(VGABASE + 2*(VGACOLS*k + i)),
+                                              VGABASE + 2*(VGACOLS*j + i));
+                               }
+                       }
+                       for (i = 0; i < VGACOLS; i++) {
+                               writew(0x720, VGABASE + 2*(VGACOLS*j + i));
+                       }
+                       current_ypos = VGALINES-1;
+               }
+               if (c == '\n') {
+                       current_xpos = 0;
+                       current_ypos++;
+               } else if (c != '\r')  {
+                       writew(((0x7 << 8) | (unsigned short) c),
+                              VGABASE + 2*(VGACOLS*current_ypos + current_xpos++));
+                       if (current_xpos >= VGACOLS) {
+                               current_xpos = 0;
+                               current_ypos++;
+                       }
+               }
+       }
+}
+
+# endif /* CONFIG_IA64_EARLY_PRINTK_VGA */
+
+# ifdef CONFIG_IA64_EARLY_PRINTK_UART
+
+#include <linux/serial_reg.h>
+#include <asm/system.h>
+
+static void early_printk_uart(const char *str, size_t len)
+{
+       static char *uart = NULL;
+       unsigned long uart_base;
+       char c;
+
+       if (!uart) {
+               uart_base = 0;
+#  ifdef CONFIG_SERIAL_8250_HCDP
+               {
+                       extern unsigned long hcdp_early_uart(void);
+                       uart_base = hcdp_early_uart();
+               }
+#  endif
+#  if CONFIG_IA64_EARLY_PRINTK_UART_BASE
+               if (!uart_base)
+                       uart_base = CONFIG_IA64_EARLY_PRINTK_UART_BASE;
+#  endif
+               if (!uart_base)
+                       return;
+
+               uart = ioremap(uart_base, 64);
+               if (!uart)
+                       return;
+       }
+
+       while (len-- > 0) {
+               c = *str++;
+               while ((readb(uart + UART_LSR) & UART_LSR_TEMT) == 0)
+                       cpu_relax(); /* spin */
+
+               writeb(c, uart + UART_TX);
+
+               if (c == '\n')
+                       writeb('\r', uart + UART_TX);
+       }
+}
+
+# endif /* CONFIG_IA64_EARLY_PRINTK_UART */
+
+void early_printk(const char *str, size_t len)
+{
+#ifdef CONFIG_IA64_EARLY_PRINTK_UART
+       early_printk_uart(str, len);
+#endif
+#ifdef CONFIG_IA64_EARLY_PRINTK_VGA
+       early_printk_vga(str, len);
+#endif
+}
+
+#endif /* CONFIG_IA64_EARLY_PRINTK */