hvc_tile.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. *
  14. * Tilera TILE Processor hypervisor console
  15. */
  16. #include <linux/console.h>
  17. #include <linux/delay.h>
  18. #include <linux/err.h>
  19. #include <linux/init.h>
  20. #include <linux/moduleparam.h>
  21. #include <linux/types.h>
  22. #include <hv/hypervisor.h>
  23. #include "hvc_console.h"
  24. static int hvc_tile_put_chars(uint32_t vt, const char *buf, int count)
  25. {
  26. return hv_console_write((HV_VirtAddr)buf, count);
  27. }
  28. static int hvc_tile_get_chars(uint32_t vt, char *buf, int count)
  29. {
  30. int i, c;
  31. for (i = 0; i < count; ++i) {
  32. c = hv_console_read_if_ready();
  33. if (c < 0)
  34. break;
  35. buf[i] = c;
  36. }
  37. return i;
  38. }
  39. static const struct hv_ops hvc_tile_get_put_ops = {
  40. .get_chars = hvc_tile_get_chars,
  41. .put_chars = hvc_tile_put_chars,
  42. };
  43. static int __init hvc_tile_console_init(void)
  44. {
  45. extern void disable_early_printk(void);
  46. hvc_instantiate(0, 0, &hvc_tile_get_put_ops);
  47. add_preferred_console("hvc", 0, NULL);
  48. disable_early_printk();
  49. return 0;
  50. }
  51. console_initcall(hvc_tile_console_init);
  52. static int __init hvc_tile_init(void)
  53. {
  54. struct hvc_struct *s;
  55. s = hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128);
  56. return IS_ERR(s) ? PTR_ERR(s) : 0;
  57. }
  58. device_initcall(hvc_tile_init);