console.c 786 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * (C) P. Horton 2006
  3. */
  4. #include <linux/init.h>
  5. #include <linux/kernel.h>
  6. #include <linux/console.h>
  7. #include <linux/serial_reg.h>
  8. #include <asm/addrspace.h>
  9. #include <asm/mach-cobalt/cobalt.h>
  10. static void putchar(int c)
  11. {
  12. if(c == '\n')
  13. putchar('\r');
  14. while(!(COBALT_UART[UART_LSR] & UART_LSR_THRE))
  15. ;
  16. COBALT_UART[UART_TX] = c;
  17. }
  18. static void cons_write(struct console *c, const char *s, unsigned n)
  19. {
  20. while(n-- && *s)
  21. putchar(*s++);
  22. }
  23. static struct console cons_info =
  24. {
  25. .name = "uart",
  26. .write = cons_write,
  27. .flags = CON_PRINTBUFFER | CON_BOOT,
  28. .index = -1,
  29. };
  30. void __init cobalt_early_console(void)
  31. {
  32. register_console(&cons_info);
  33. printk("Cobalt: early console registered\n");
  34. }
  35. void __init disable_early_printk(void)
  36. {
  37. unregister_console(&cons_info);
  38. }