tubttyscl.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  IBM/3270 Driver -- Copyright (C) 2000, 2001 UTS Global LLC
  3.  *
  4.  *  tubttyscl.c -- Linemode tty driver scroll-timing functions
  5.  *
  6.  *
  7.  *
  8.  *
  9.  *
  10.  *  Author:  Richard Hitt
  11.  */
  12. #include "tubio.h"
  13.        void tty3270_scl_settimer(tub_t *);
  14.        void tty3270_scl_resettimer(tub_t *);
  15. static void tty3270_scl_timeout(unsigned long);
  16. void
  17. tty3270_scl_settimer(tub_t *tubp)
  18. {
  19. struct timer_list *tp = &tubp->tty_stimer;
  20. if (tubp->flags & TUB_SCROLLTIMING)
  21. return;
  22. if (tubp->tty_scrolltime == 0)
  23. return;
  24. init_timer(tp);
  25. tp->expires = jiffies + HZ * tubp->tty_scrolltime;
  26. tp->data = (unsigned long)tubp;
  27. tp->function = tty3270_scl_timeout;
  28. add_timer(tp);
  29. tubp->flags |= TUB_SCROLLTIMING;
  30. }
  31. void
  32. tty3270_scl_resettimer(tub_t *tubp)
  33. {
  34. struct timer_list *tp = &tubp->tty_stimer;
  35. if ((tubp->flags & TUB_SCROLLTIMING) == 0)
  36. return;
  37. del_timer(tp);
  38. tubp->flags &= ~TUB_SCROLLTIMING;
  39. }
  40. static void
  41. tty3270_scl_timeout(unsigned long data)
  42. {
  43. tub_t *tubp = (void *)data;
  44. long flags;
  45. TUBLOCK(tubp->irq, flags);
  46. tubp->stat = TBS_RUNNING;
  47. tty3270_scl_resettimer(tubp);
  48. tubp->cmd = TBC_CLRUPDLOG;
  49. tty3270_build(tubp);
  50. TUBUNLOCK(tubp->irq, flags);
  51. }
  52. int
  53. tty3270_scl_set(tub_t *tubp, char *buf, int count)
  54. {
  55. if (strncmp(buf, "scrolltime=", 11) == 0) {
  56. tubp->tty_scrolltime =
  57. simple_strtoul(buf + 11, 0, 0);
  58. return count;
  59. }
  60. return 0;
  61. }
  62. int
  63. tty3270_scl_init(tub_t *tubp)
  64. {
  65. extern int tubscrolltime;
  66. tubp->tty_scrolltime = tubscrolltime;
  67. if (tubp->tty_scrolltime < 0)
  68. tubp->tty_scrolltime = DEFAULT_SCROLLTIME;
  69. return 0;
  70. }
  71. void
  72. tty3270_scl_fini(tub_t *tubp)
  73. {
  74. if ((tubp->flags & TUB_OPEN_STET) == 0)
  75. tty3270_scl_resettimer(tubp);
  76. }