printf.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * This program is free software; you can distribute it and/or modify it
  6. * under the terms of the GNU General Public License (Version 2) as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  17. *
  18. * Putting things on the screen/serial line using YAMONs facilities.
  19. */
  20. #include <linux/init.h>
  21. #include <linux/kernel.h>
  22. #include <linux/serial_reg.h>
  23. #include <linux/spinlock.h>
  24. #include <asm/io.h>
  25. #ifdef CONFIG_MIPS_ATLAS
  26. #include <asm/mips-boards/atlas.h>
  27. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  28. #define PORT(offset) (ATLAS_UART_REGS_BASE + ((offset)<<3))
  29. #else
  30. #define PORT(offset) (ATLAS_UART_REGS_BASE + 3 + ((offset)<<3))
  31. #endif
  32. #elif defined(CONFIG_MIPS_SEAD)
  33. #include <asm/mips-boards/sead.h>
  34. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  35. #define PORT(offset) (SEAD_UART0_REGS_BASE + ((offset)<<3))
  36. #else
  37. #define PORT(offset) (SEAD_UART0_REGS_BASE + 3 + ((offset)<<3))
  38. #endif
  39. #else
  40. #define PORT(offset) (0x3f8 + (offset))
  41. #endif
  42. static inline unsigned int serial_in(int offset)
  43. {
  44. return inb(PORT(offset));
  45. }
  46. static inline void serial_out(int offset, int value)
  47. {
  48. outb(value, PORT(offset));
  49. }
  50. int prom_putchar(char c)
  51. {
  52. while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0)
  53. ;
  54. serial_out(UART_TX, c);
  55. return 1;
  56. }
  57. char prom_getchar(void)
  58. {
  59. while (!(serial_in(UART_LSR) & UART_LSR_DR))
  60. ;
  61. return serial_in(UART_RX);
  62. }