hpsim_console.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Platform dependent support for HP simulator.
  3. *
  4. * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
  5. * David Mosberger-Tang <davidm@hpl.hp.com>
  6. * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/param.h>
  11. #include <linux/string.h>
  12. #include <linux/types.h>
  13. #include <linux/tty.h>
  14. #include <linux/kdev_t.h>
  15. #include <linux/console.h>
  16. #include <asm/delay.h>
  17. #include <asm/irq.h>
  18. #include <asm/pal.h>
  19. #include <asm/machvec.h>
  20. #include <asm/pgtable.h>
  21. #include <asm/sal.h>
  22. #include <asm/hpsim.h>
  23. #include "hpsim_ssc.h"
  24. static int simcons_init (struct console *, char *);
  25. static void simcons_write (struct console *, const char *, unsigned);
  26. static struct tty_driver *simcons_console_device (struct console *, int *);
  27. static struct console hpsim_cons = {
  28. .name = "simcons",
  29. .write = simcons_write,
  30. .device = simcons_console_device,
  31. .setup = simcons_init,
  32. .flags = CON_PRINTBUFFER,
  33. .index = -1,
  34. };
  35. static int
  36. simcons_init (struct console *cons, char *options)
  37. {
  38. return 0;
  39. }
  40. static void
  41. simcons_write (struct console *cons, const char *buf, unsigned count)
  42. {
  43. unsigned long ch;
  44. while (count-- > 0) {
  45. ch = *buf++;
  46. ia64_ssc(ch, 0, 0, 0, SSC_PUTCHAR);
  47. if (ch == '\n')
  48. ia64_ssc('\r', 0, 0, 0, SSC_PUTCHAR);
  49. }
  50. }
  51. static struct tty_driver *simcons_console_device (struct console *c, int *index)
  52. {
  53. *index = c->index;
  54. return hp_simserial_driver;
  55. }
  56. int simcons_register(void)
  57. {
  58. if (!ia64_platform_is("hpsim"))
  59. return 1;
  60. if (hpsim_cons.flags & CON_ENABLED)
  61. return 1;
  62. register_console(&hpsim_cons);
  63. return 0;
  64. }