10 #include <linux/module.h>
14 #include <linux/list.h>
15 #include <linux/slab.h>
16 #include <linux/types.h>
17 #include <linux/wait.h>
27 #include <linux/kdev_t.h>
28 #include <linux/device.h>
31 static struct class *class3270;
57 #define RAW3270_FLAGS_14BITADDR 0
58 #define RAW3270_FLAGS_BUSY 1
59 #define RAW3270_FLAGS_ATTN 2
60 #define RAW3270_FLAGS_READY 4
61 #define RAW3270_FLAGS_CONSOLE 8
62 #define RAW3270_FLAGS_FROZEN 16
75 static int raw3270_registered;
78 static bool tubxcorrect = 0;
89 static unsigned char raw3270_ebcgraf[64] = {
90 0x40, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
91 0xc8, 0xc9, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
92 0x50, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
93 0xd8, 0xd9, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
94 0x60, 0x61, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
95 0xe8, 0xe9, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
96 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
97 0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
104 cp[0] = (addr >> 8) & 0x3f;
107 cp[0] = raw3270_ebcgraf[(addr >> 6) & 0x3f];
108 cp[1] = raw3270_ebcgraf[addr & 0x3f];
134 INIT_LIST_HEAD(&rq->
list);
162 rq->
ccw.cmd_code = 0;
185 if (size + rq->
ccw.count > rq->
size)
222 if (raw3270_request_final(rq))
225 for (retries = 0; retries < 5; retries++) {
243 rc = raw3270_halt_io_nolock(rp, rq);
257 raw3270_get_view(view);
262 (
unsigned long) rq, 0, 0);
264 raw3270_put_view(view);
281 if (!rp || rp->
view != view ||
287 rc = __raw3270_start(rp, view, rq);
299 if (!rp || rp->
view != view ||
305 rc = __raw3270_start(rp, view, rq);
316 raw3270_get_view(view);
357 rc = view->
fn->intv(view, rq, irb);
374 (
unsigned long) rq, 0, 0);
381 raw3270_halt_io_nolock(rp, rq);
390 list_del_init(&rq->
list);
394 raw3270_put_view(view);
403 (
unsigned long) rq, 0, 0);
407 list_del_init(&rq->
list);
411 raw3270_put_view(view);
480 rq->rescnt = irb->scsw.cmd.count;
490 .intv = raw3270_init_irq
494 .fn = &raw3270_init_fn
519 #ifdef CONFIG_TN3270_CONSOLE
520 if (raw3270_registered == 0) {
523 rc = __raw3270_start(rp, view, rq);
525 while (!raw3270_request_final(rq)) {
536 rc = __raw3270_start(rp, view, rq);
542 raw3270_request_final(rq));
544 raw3270_halt_io(view->
dev, rq);
546 wait_event(raw3270_wait_queue, raw3270_request_final(rq));
553 __raw3270_size_device_vm(
struct raw3270 *rp)
559 raw3270_init_diag210.vrdcdvno =
dev_id.devno;
560 raw3270_init_diag210.vrdclen =
sizeof(
struct diag210);
561 rc =
diag210(&raw3270_init_diag210);
564 model = raw3270_init_diag210.vrdccrmd;
594 __raw3270_size_device(
struct raw3270 *rp)
596 static const unsigned char wbuf[] =
597 { 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 };
620 rc = raw3270_start_init(rp, &raw3270_init_view, &rp->
init_request);
626 #ifdef CONFIG_TN3270_CONSOLE
627 if (raw3270_registered == 0) {
649 rc = raw3270_start_init(rp, &raw3270_init_view, &rp->
init_request);
658 rp->
rows = uap->uab.
h;
659 rp->
cols = uap->uab.
w;
661 if ((uap->uab.
flags0 & 0x0d) == 0x01)
665 uap->aua.sdpid == 0x02) {
666 rp->
rows = uap->aua.hauai;
667 rp->
cols = uap->aua.wauai;
673 raw3270_size_device(
struct raw3270 *rp)
678 rp->
view = &raw3270_init_view;
679 raw3270_init_view.dev =
rp;
681 rc = __raw3270_size_device_vm(rp);
683 rc = __raw3270_size_device(rp);
684 raw3270_init_view.dev =
NULL;
690 if (rp->
rows == 24 && rp->
cols == 80)
692 if (rp->
rows == 32 && rp->
cols == 80)
694 if (rp->
rows == 43 && rp->
cols == 80)
696 if (rp->
rows == 27 && rp->
cols == 132)
709 raw3270_reset_device(
struct raw3270 *rp)
723 rp->
view = &raw3270_init_view;
724 raw3270_init_view.dev =
rp;
725 rc = raw3270_start_init(rp, &raw3270_init_view, &rp->
init_request);
726 raw3270_init_view.dev =
NULL;
739 if (!rp || rp->
view != view ||
745 rc = raw3270_reset_device(view->
dev);
788 if (tmp->
minor > minor) {
809 #ifdef CONFIG_TN3270_CONSOLE
821 rc = raw3270_setup_device(cdev, rp, ascebc);
825 rc = raw3270_reset_device(rp);
828 rc = raw3270_size_device(rp);
831 rc = raw3270_reset_device(rp);
854 raw3270_create_device(
struct ccw_device *cdev)
868 rc = raw3270_setup_device(cdev, rp, ascebc);
894 if (rp->
view == view)
904 oldview->
fn->deactivate(oldview);
907 rc = view->
fn->activate(view);
911 if (!oldview || oldview->
fn->activate(oldview) != 0) {
914 if (nv != view && nv != oldview) {
916 if (nv->
fn->activate(nv) == 0)
940 if (rp->
view == view) {
941 view->
fn->deactivate(view);
944 list_del_init(&view->
list);
951 if (view->
fn->activate(view) == 0)
975 if (rp->
minor != minor)
1005 unsigned long flags;
1010 if (rp->
minor != minor)
1016 if (tmp->
fn == fn) {
1017 raw3270_get_view(tmp);
1036 unsigned long flags;
1042 if (rp->
view == view) {
1043 view->
fn->deactivate(view);
1046 list_del_init(&view->
list);
1051 if (nv->
fn->activate(nv) == 0) {
1062 view->
fn->free(view);
1069 raw3270_delete_device(
struct raw3270 *rp)
1079 list_del_init(&rp->
list);
1129 static struct attribute * raw3270_attrs[] = {
1130 &dev_attr_model.attr,
1131 &dev_attr_rows.attr,
1132 &dev_attr_columns.attr,
1137 .attrs = raw3270_attrs,
1140 static int raw3270_create_attributes(
struct raw3270 *rp)
1150 "tty%s", dev_name(&rp->
cdev->dev));
1158 "tub%s", dev_name(&rp->
cdev->dev));
1194 notifier(rp->
minor, 1);
1224 rp = raw3270_create_device(cdev);
1227 rc = raw3270_reset_device(rp);
1230 rc = raw3270_size_device(rp);
1233 rc = raw3270_reset_device(rp);
1236 rc = raw3270_create_attributes(rp);
1247 raw3270_delete_device(rp);
1257 unsigned long flags;
1278 rp->
view->fn->deactivate(rp->
view);
1297 raw3270_reset_device(rp);
1299 raw3270_delete_device(rp);
1313 raw3270_remove(cdev);
1317 static int raw3270_pm_stop(
struct ccw_device *cdev)
1321 unsigned long flags;
1328 rp->
view->fn->deactivate(rp->
view);
1335 if (view->
fn->release)
1336 view->
fn->release(view);
1344 static int raw3270_pm_start(
struct ccw_device *cdev)
1347 unsigned long flags;
1362 #ifdef CONFIG_TN3270_CONSOLE
1386 static struct ccw_driver raw3270_ccw_driver = {
1392 .probe = &raw3270_probe,
1393 .remove = &raw3270_remove,
1394 .set_online = &raw3270_set_online,
1395 .set_offline = &raw3270_set_offline,
1396 .freeze = &raw3270_pm_stop,
1397 .thaw = &raw3270_pm_start,
1398 .restore = &raw3270_pm_start,
1408 if (raw3270_registered)
1410 raw3270_registered = 1;
1418 raw3270_create_attributes(rp);