promlib.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 ([email protected])
  7. * Compatibility with board caches, Ulf Carlsson
  8. */
  9. #include <linux/kernel.h>
  10. #include <asm/sgialib.h>
  11. #include <asm/bcache.h>
  12. #include <asm/setup.h>
  13. #if defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32)
  14. /*
  15. * For 64bit kernels working with a 32bit ARC PROM pointer arguments
  16. * for ARC calls need to reside in CKEG0/1. But as soon as the kernel
  17. * switches to it's first kernel thread stack is set to an address in
  18. * XKPHYS, so anything on stack can't be used anymore. This is solved
  19. * by using a * static declartion variables are put into BSS, which is
  20. * linked to a CKSEG0 address. Since this is only used on UP platforms
  21. * there is not spinlock needed
  22. */
  23. #define O32_STATIC static
  24. #else
  25. #define O32_STATIC
  26. #endif
  27. /*
  28. * IP22 boardcache is not compatible with board caches. Thus we disable it
  29. * during romvec action. Since r4xx0.c is always compiled and linked with your
  30. * kernel, this shouldn't cause any harm regardless what MIPS processor you
  31. * have.
  32. *
  33. * The ARC write and read functions seem to interfere with the serial lines
  34. * in some way. You should be careful with them.
  35. */
  36. void prom_putchar(char c)
  37. {
  38. O32_STATIC ULONG cnt;
  39. O32_STATIC CHAR it;
  40. it = c;
  41. bc_disable();
  42. ArcWrite(1, &it, 1, &cnt);
  43. bc_enable();
  44. }
  45. char prom_getchar(void)
  46. {
  47. O32_STATIC ULONG cnt;
  48. O32_STATIC CHAR c;
  49. bc_disable();
  50. ArcRead(0, &c, 1, &cnt);
  51. bc_enable();
  52. return c;
  53. }