raw3270.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * IBM/3270 Driver
  4. *
  5. * Author(s):
  6. * Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
  7. * Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
  8. * Copyright IBM Corp. 2003, 2009
  9. */
  10. #include <uapi/asm/raw3270.h>
  11. #include <asm/idals.h>
  12. #include <asm/ioctl.h>
  13. struct raw3270;
  14. struct raw3270_view;
  15. extern const struct class class3270;
  16. /* 3270 CCW request */
  17. struct raw3270_request {
  18. struct list_head list; /* list head for request queueing. */
  19. struct raw3270_view *view; /* view of this request */
  20. struct ccw1 ccw; /* single ccw. */
  21. void *buffer; /* output buffer. */
  22. size_t size; /* size of output buffer. */
  23. int rescnt; /* residual count from devstat. */
  24. int rc; /* return code for this request. */
  25. /* Callback for delivering final status. */
  26. void (*callback)(struct raw3270_request *rq, void *data);
  27. void *callback_data;
  28. };
  29. struct raw3270_request *raw3270_request_alloc(size_t size);
  30. void raw3270_request_free(struct raw3270_request *rq);
  31. int raw3270_request_reset(struct raw3270_request *rq);
  32. void raw3270_request_set_cmd(struct raw3270_request *rq, u8 cmd);
  33. int raw3270_request_add_data(struct raw3270_request *rq, void *data, size_t size);
  34. void raw3270_request_set_data(struct raw3270_request *rq, void *data, size_t size);
  35. void raw3270_request_set_idal(struct raw3270_request *rq, struct idal_buffer *ib);
  36. static inline int
  37. raw3270_request_final(struct raw3270_request *rq)
  38. {
  39. return list_empty(&rq->list);
  40. }
  41. void raw3270_buffer_address(struct raw3270 *, char *, int, int);
  42. /*
  43. * Functions of a 3270 view.
  44. */
  45. struct raw3270_fn {
  46. int (*activate)(struct raw3270_view *rq);
  47. void (*deactivate)(struct raw3270_view *rq);
  48. void (*intv)(struct raw3270_view *view,
  49. struct raw3270_request *rq, struct irb *ib);
  50. void (*release)(struct raw3270_view *view);
  51. void (*free)(struct raw3270_view *view);
  52. void (*resize)(struct raw3270_view *view,
  53. int new_model, int new_cols, int new_rows,
  54. int old_model, int old_cols, int old_rows);
  55. };
  56. /*
  57. * View structure chaining. The raw3270_view structure is meant to
  58. * be embedded at the start of the real view data structure, e.g.:
  59. * struct example {
  60. * struct raw3270_view view;
  61. * ...
  62. * };
  63. */
  64. struct raw3270_view {
  65. struct list_head list;
  66. spinlock_t lock; /* protects members of view */
  67. #define RAW3270_VIEW_LOCK_IRQ 0
  68. #define RAW3270_VIEW_LOCK_BH 1
  69. atomic_t ref_count;
  70. struct raw3270 *dev;
  71. struct raw3270_fn *fn;
  72. unsigned int model;
  73. unsigned int rows, cols; /* # of rows & colums of the view */
  74. unsigned char *ascebc; /* ascii -> ebcdic table */
  75. };
  76. int raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor, int subclass);
  77. int raw3270_view_lock_unavailable(struct raw3270_view *view);
  78. int raw3270_activate_view(struct raw3270_view *view);
  79. void raw3270_del_view(struct raw3270_view *view);
  80. void raw3270_deactivate_view(struct raw3270_view *view);
  81. struct raw3270_view *raw3270_find_view(struct raw3270_fn *fn, int minor);
  82. int raw3270_start(struct raw3270_view *view, struct raw3270_request *rq);
  83. int raw3270_start_locked(struct raw3270_view *view, struct raw3270_request *rq);
  84. int raw3270_start_irq(struct raw3270_view *view, struct raw3270_request *rq);
  85. int raw3270_reset(struct raw3270_view *view);
  86. struct raw3270_view *raw3270_view(struct raw3270_view *view);
  87. int raw3270_view_active(struct raw3270_view *view);
  88. int raw3270_start_request(struct raw3270_view *view, struct raw3270_request *rq,
  89. int cmd, void *data, size_t len);
  90. void raw3270_read_modified_cb(struct raw3270_request *rq, void *data);
  91. /* Reference count inliner for view structures. */
  92. static inline void
  93. raw3270_get_view(struct raw3270_view *view)
  94. {
  95. atomic_inc(&view->ref_count);
  96. }
  97. extern wait_queue_head_t raw3270_wait_queue;
  98. static inline void
  99. raw3270_put_view(struct raw3270_view *view)
  100. {
  101. if (atomic_dec_return(&view->ref_count) == 0)
  102. wake_up(&raw3270_wait_queue);
  103. }
  104. struct raw3270 *raw3270_setup_console(void);
  105. void raw3270_wait_cons_dev(struct raw3270 *rp);
  106. /* Notifier for device addition/removal */
  107. struct raw3270_notifier {
  108. struct list_head list;
  109. void (*create)(int minor);
  110. void (*destroy)(int minor);
  111. };
  112. int raw3270_register_notifier(struct raw3270_notifier *notifier);
  113. void raw3270_unregister_notifier(struct raw3270_notifier *notifier);