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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file "COPYING" in the main directory of this archive
  4.  * for more details.
  5.  *
  6.  * Copyright (C) 1996 David S. Miller (dm@sgi.com)
  7.  * Compability with board caches, Ulf Carlsson
  8.  */
  9. #include <linux/kernel.h>
  10. #include <asm/sgialib.h>
  11. #include <asm/bcache.h>
  12. /*
  13.  * IP22 boardcache is not compatible with board caches.  Thus we disable it
  14.  * during romvec action.  Since r4xx0.c is always compiled and linked with your
  15.  * kernel, this shouldn't cause any harm regardless what MIPS processor you
  16.  * have.
  17.  *
  18.  * The ARC write and read functions seem to interfere with the serial lines
  19.  * in some way. You should be careful with them.
  20.  */
  21. void prom_putchar(char c)
  22. {
  23. ULONG cnt;
  24. CHAR it = c;
  25. bc_disable();
  26. ArcWrite(1, &it, 1, &cnt);
  27. bc_enable();
  28. }
  29. char prom_getchar(void)
  30. {
  31. ULONG cnt;
  32. CHAR c;
  33. bc_disable();
  34. ArcRead(0, &c, 1, &cnt);
  35. bc_enable();
  36. return c;
  37. }
  38. void prom_printf(char *fmt, ...)
  39. {
  40. va_list args;
  41. char ppbuf[1024];
  42. char *bptr;
  43. va_start(args, fmt);
  44. vsprintf(ppbuf, fmt, args);
  45. bptr = ppbuf;
  46. while (*bptr != 0) {
  47. if (*bptr == 'n')
  48. prom_putchar('r');
  49. prom_putchar(*bptr++);
  50. }
  51. va_end(args);
  52. }