console.c 812 B

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