promcon.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:1k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Wrap-around code for a console using the
  3.  * DECstation PROM io-routines.
  4.  *
  5.  * Copyright (c) 1998 Harald Koerfgen
  6.  */
  7. #include <linux/tty.h>
  8. #include <linux/major.h>
  9. #include <linux/ptrace.h>
  10. #include <linux/init.h>
  11. #include <linux/console.h>
  12. #include <linux/fs.h>
  13. extern int (*prom_getchar) (void);
  14. extern int (*prom_printf) (char *,...);
  15. static void prom_console_write(struct console *co, const char *s,
  16.        unsigned count)
  17. {
  18.     unsigned i;
  19.     /*
  20.      *    Now, do each character
  21.      */
  22.     for (i = 0; i < count; i++) {
  23. if (*s == 10)
  24.     prom_printf("%c", 13);
  25. prom_printf("%c", *s++);
  26.     }
  27. }
  28. static int __init prom_console_setup(struct console *co, char *options)
  29. {
  30.     return 0;
  31. }
  32. static kdev_t prom_console_device(struct console *c)
  33. {
  34.     return MKDEV(TTY_MAJOR, 64 + c->index);
  35. }
  36. static struct console sercons =
  37. {
  38.     name: "ttyS",
  39.     write: prom_console_write,
  40.     device: prom_console_device,
  41.     setup: prom_console_setup,
  42.     flags: CON_PRINTBUFFER,
  43.     index: -1,
  44. };
  45. /*
  46.  *    Register console.
  47.  */
  48. long __init prom_console_init(long kmem_start, long kmem_end)
  49. {
  50.     register_console(&sercons);
  51.     return kmem_start;
  52. }