Lines Matching refs:tp

123 static void tty3270_set_timer(struct tty3270 *tp, int expires)
126 del_timer(&tp->timer);
128 mod_timer(&tp->timer, jiffies + expires);
135 tty3270_update_prompt(struct tty3270 *tp, char *input, int count)
140 line = tp->prompt;
144 line->string[5] = tp->inattr;
145 if (count > tp->view.cols * 2 - 11)
146 count = tp->view.cols * 2 - 11;
150 if (count < tp->view.cols * 2 - 11) {
153 off = tp->view.cols * tp->view.rows - 9;
154 raw3270_buffer_address(tp->view.dev, line->string+count+8, off);
158 tp->update_flags |= TTY_UPDATE_INPUT;
162 tty3270_create_prompt(struct tty3270 *tp)
171 line = alloc_string(&tp->freemem,
172 sizeof(blueprint) + tp->view.cols * 2 - 9);
173 tp->prompt = line;
174 tp->inattr = TF_INPUT;
179 offset = tp->view.cols * (tp->view.rows - 2);
180 raw3270_buffer_address(tp->view.dev, line->string + 1, offset);
181 offset = tp->view.cols * tp->view.rows - 9;
182 raw3270_buffer_address(tp->view.dev, line->string + 8, offset);
185 tp->input = alloc_string(&tp->freemem, tp->view.cols * 2 - 9 + 6);
193 tty3270_update_status(struct tty3270 * tp)
197 str = (tp->nr_up != 0) ? "History" : "Running";
198 memcpy(tp->status->string + 8, str, 7);
199 codepage_convert(tp->view.ascebc, tp->status->string + 8, 7);
200 tp->update_flags |= TTY_UPDATE_STATUS;
204 tty3270_create_status(struct tty3270 * tp)
213 line = alloc_string(&tp->freemem,sizeof(blueprint));
214 tp->status = line;
218 offset = tp->view.cols * tp->view.rows - 9;
219 raw3270_buffer_address(tp->view.dev, line->string + 1, offset);
227 tty3270_update_string(struct tty3270 *tp, struct string *line, int nr)
231 raw3270_buffer_address(tp->view.dev, line->string + 1,
232 tp->view.cols * nr);
235 raw3270_buffer_address(tp->view.dev, cp + 1,
236 tp->view.cols * (nr + 1));
243 tty3270_rebuild_update(struct tty3270 *tp)
252 list_for_each_entry_safe(s, n, &tp->update, update)
254 line = tp->view.rows - 3;
255 nr_up = tp->nr_up;
256 list_for_each_entry_reverse(s, &tp->lines, list) {
261 tty3270_update_string(tp, s, line);
262 list_add(&s->update, &tp->update);
266 tp->update_flags |= TTY_UPDATE_LIST;
274 tty3270_alloc_string(struct tty3270 *tp, size_t size)
278 s = alloc_string(&tp->freemem, size);
281 list_for_each_entry_safe(s, n, &tp->lines, list) {
282 BUG_ON(tp->nr_lines <= tp->view.rows - 2);
286 tp->nr_lines--;
287 if (free_string(&tp->freemem, s) >= size)
290 s = alloc_string(&tp->freemem, size);
292 if (tp->nr_up != 0 &&
293 tp->nr_up + tp->view.rows - 2 >= tp->nr_lines) {
294 tp->nr_up = tp->nr_lines - tp->view.rows + 2;
295 tty3270_rebuild_update(tp);
296 tty3270_update_status(tp);
305 tty3270_blank_line(struct tty3270 *tp)
312 s = tty3270_alloc_string(tp, sizeof(blueprint));
315 list_add_tail(&s->list, &tp->lines);
316 tp->nr_lines++;
317 if (tp->nr_up != 0)
318 tp->nr_up++;
327 struct tty3270 *tp;
329 tp = (struct tty3270 *) rq->view;
332 tp->update_flags = TTY_UPDATE_ALL;
333 tty3270_set_timer(tp, 1);
336 xchg(&tp->write, rq);
343 tty3270_update(struct tty3270 *tp)
352 wrq = xchg(&tp->write, 0);
354 tty3270_set_timer(tp, 1);
358 spin_lock(&tp->view.lock);
360 if (tp->update_flags & TTY_UPDATE_ALL) {
361 tty3270_rebuild_update(tp);
362 tty3270_update_status(tp);
363 tp->update_flags = TTY_UPDATE_ERASE | TTY_UPDATE_LIST |
366 if (tp->update_flags & TTY_UPDATE_ERASE) {
373 raw3270_request_add_data(wrq, &tp->wcc, 1);
374 tp->wcc = TW_NONE;
379 if (tp->update_flags & TTY_UPDATE_STATUS)
380 if (raw3270_request_add_data(wrq, tp->status->string,
381 tp->status->len) == 0)
387 if (tp->update_flags & TTY_UPDATE_INPUT)
388 if (raw3270_request_add_data(wrq, tp->prompt->string,
389 tp->prompt->len) == 0)
394 if (tp->update_flags & TTY_UPDATE_LIST) {
396 list_for_each_entry_safe(s, n, &tp->update, update) {
411 if (list_empty(&tp->update))
415 rc = raw3270_start(&tp->view, wrq);
417 tp->update_flags &= ~updated;
418 if (tp->update_flags)
419 tty3270_set_timer(tp, 1);
422 xchg(&tp->write, wrq);
424 spin_unlock(&tp->view.lock);
431 tty3270_rcl_add(struct tty3270 *tp, char *input, int len)
435 tp->rcl_walk = NULL;
438 if (tp->rcl_nr >= tp->rcl_max) {
439 s = list_entry(tp->rcl_lines.next, struct string, list);
441 free_string(&tp->freemem, s);
442 tp->rcl_nr--;
444 s = tty3270_alloc_string(tp, len);
446 list_add_tail(&s->list, &tp->rcl_lines);
447 tp->rcl_nr++;
453 struct tty3270 *tp;
456 tp = kbd->tty->driver_data;
457 spin_lock_bh(&tp->view.lock);
458 if (tp->inattr == TF_INPUT) {
459 if (tp->rcl_walk && tp->rcl_walk->prev != &tp->rcl_lines)
460 tp->rcl_walk = tp->rcl_walk->prev;
461 else if (!list_empty(&tp->rcl_lines))
462 tp->rcl_walk = tp->rcl_lines.prev;
463 s = tp->rcl_walk ?
464 list_entry(tp->rcl_walk, struct string, list) : NULL;
465 if (tp->rcl_walk) {
466 s = list_entry(tp->rcl_walk, struct string, list);
467 tty3270_update_prompt(tp, s->string, s->len);
469 tty3270_update_prompt(tp, NULL, 0);
470 tty3270_set_timer(tp, 1);
472 spin_unlock_bh(&tp->view.lock);
481 struct tty3270 *tp;
483 tp = kbd->tty->driver_data;
484 raw3270_deactivate_view(&tp->view);
493 struct tty3270 *tp;
496 tp = kbd->tty->driver_data;
497 spin_lock_bh(&tp->view.lock);
498 nr_up = tp->nr_up - tp->view.rows + 2;
501 if (nr_up != tp->nr_up) {
502 tp->nr_up = nr_up;
503 tty3270_rebuild_update(tp);
504 tty3270_update_status(tp);
505 tty3270_set_timer(tp, 1);
507 spin_unlock_bh(&tp->view.lock);
516 struct tty3270 *tp;
519 tp = kbd->tty->driver_data;
520 spin_lock_bh(&tp->view.lock);
521 nr_up = tp->nr_up + tp->view.rows - 2;
522 if (nr_up + tp->view.rows - 2 > tp->nr_lines)
523 nr_up = tp->nr_lines - tp->view.rows + 2;
524 if (nr_up != tp->nr_up) {
525 tp->nr_up = nr_up;
526 tty3270_rebuild_update(tp);
527 tty3270_update_status(tp);
528 tty3270_set_timer(tp, 1);
530 spin_unlock_bh(&tp->view.lock);
540 struct tty3270 *tp;
544 tp = (struct tty3270 *) rrq->view;
545 spin_lock_bh(&tp->view.lock);
553 if (tp->input->string[0] == 0x7d) {
555 input = tp->input->string + 6;
556 len = tp->input->len - 6 - rrq->rescnt;
557 if (tp->inattr != TF_INPUTN)
558 tty3270_rcl_add(tp, input, len);
559 if (tp->nr_up > 0) {
560 tp->nr_up = 0;
561 tty3270_rebuild_update(tp);
562 tty3270_update_status(tp);
565 tty3270_update_prompt(tp, NULL, 0);
566 tty3270_set_timer(tp, 1);
567 } else if (tp->input->string[0] == 0x6d) {
569 tp->update_flags = TTY_UPDATE_ALL;
570 tty3270_set_timer(tp, 1);
572 spin_unlock_bh(&tp->view.lock);
575 raw3270_request_reset(tp->kreset);
576 raw3270_request_set_cmd(tp->kreset, TC_WRITE);
577 raw3270_request_add_data(tp->kreset, &kreset_data, 1);
578 raw3270_start(&tp->view, tp->kreset);
581 if (tp->tty) {
583 kbd_keycode(tp->kbd, *input++);
585 kbd_keycode(tp->kbd, 256 + tp->input->string[0]);
589 xchg(&tp->read, rrq);
590 raw3270_put_view(&tp->view);
608 tty3270_issue_read(struct tty3270 *tp, int lock)
613 rrq = xchg(&tp->read, 0);
618 rrq->callback_data = tp;
620 raw3270_request_set_data(rrq, tp->input->string, tp->input->len);
623 rc = raw3270_start(&tp->view, rrq);
625 rc = raw3270_start_irq(&tp->view, rrq);
628 xchg(&tp->read, rrq);
638 struct tty3270 *tp;
640 tp = (struct tty3270 *) view;
641 tp->update_flags = TTY_UPDATE_ALL;
642 tty3270_set_timer(tp, 1);
649 struct tty3270 *tp;
651 tp = (struct tty3270 *) view;
652 del_timer(&tp->timer);
656 tty3270_irq(struct tty3270 *tp, struct raw3270_request *rq, struct irb *irb)
660 if (!tp->throttle)
661 tty3270_issue_read(tp, 0);
663 tp->attn = 1;
682 struct tty3270 *tp;
685 tp = kzalloc(sizeof(struct tty3270), GFP_KERNEL);
686 if (!tp)
688 tp->freemem_pages =
690 if (!tp->freemem_pages)
692 INIT_LIST_HEAD(&tp->freemem);
694 tp->freemem_pages[pages] = (void *)
696 if (!tp->freemem_pages[pages])
698 add_string_memory(&tp->freemem,
699 tp->freemem_pages[pages], PAGE_SIZE);
701 tp->write = raw3270_request_alloc(TTY3270_OUTPUT_BUFFER_SIZE);
702 if (IS_ERR(tp->write))
704 tp->read = raw3270_request_alloc(0);
705 if (IS_ERR(tp->read))
707 tp->kreset = raw3270_request_alloc(1);
708 if (IS_ERR(tp->kreset))
710 tp->kbd = kbd_alloc();
711 if (!tp->kbd)
713 return tp;
716 raw3270_request_free(tp->kreset);
718 raw3270_request_free(tp->read);
720 raw3270_request_free(tp->write);
723 free_pages((unsigned long) tp->freemem_pages[pages], 0);
724 kfree(tp->freemem_pages);
726 kfree(tp);
735 tty3270_free_view(struct tty3270 *tp)
739 del_timer_sync(&tp->timer);
740 kbd_free(tp->kbd);
741 raw3270_request_free(tp->kreset);
742 raw3270_request_free(tp->read);
743 raw3270_request_free(tp->write);
745 free_pages((unsigned long) tp->freemem_pages[pages], 0);
746 kfree(tp->freemem_pages);
747 kfree(tp);
754 tty3270_alloc_screen(struct tty3270 *tp)
759 size = sizeof(struct tty3270_line) * (tp->view.rows - 2);
760 tp->screen = kzalloc(size, GFP_KERNEL);
761 if (!tp->screen)
763 for (lines = 0; lines < tp->view.rows - 2; lines++) {
764 size = sizeof(struct tty3270_cell) * tp->view.cols;
765 tp->screen[lines].cells = kzalloc(size, GFP_KERNEL);
766 if (!tp->screen[lines].cells)
772 kfree(tp->screen[lines].cells);
773 kfree(tp->screen);
782 tty3270_free_screen(struct tty3270 *tp)
786 for (lines = 0; lines < tp->view.rows - 2; lines++)
787 kfree(tp->screen[lines].cells);
788 kfree(tp->screen);
797 struct tty3270 *tp;
800 tp = (struct tty3270 *) view;
801 tty = tp->tty;
804 tp->tty = tp->kbd->tty = NULL;
806 raw3270_put_view(&tp->view);
826 struct tty3270 *tp;
830 tp = (struct tty3270 *)
832 if (!IS_ERR(tp))
833 raw3270_del_view(&tp->view);
851 struct tty3270 *tp;
857 tp = (struct tty3270 *)
860 if (!IS_ERR(tp)) {
861 tty->driver_data = tp;
862 tty->winsize.ws_row = tp->view.rows - 2;
863 tty->winsize.ws_col = tp->view.cols;
865 tp->tty = tty;
866 tp->kbd->tty = tty;
867 tp->inattr = TF_INPUT;
874 if (PTR_ERR(tp) == -ENODEV)
878 tp = tty3270_alloc_view();
879 if (IS_ERR(tp))
880 return PTR_ERR(tp);
882 INIT_LIST_HEAD(&tp->lines);
883 INIT_LIST_HEAD(&tp->update);
884 INIT_LIST_HEAD(&tp->rcl_lines);
885 tp->rcl_max = 20;
886 setup_timer(&tp->timer, (void (*)(unsigned long)) tty3270_update,
887 (unsigned long) tp);
888 tasklet_init(&tp->readlet,
890 (unsigned long) tp->read);
892 rc = raw3270_add_view(&tp->view, &tty3270_fn,
895 tty3270_free_view(tp);
899 rc = tty3270_alloc_screen(tp);
901 raw3270_put_view(&tp->view);
902 raw3270_del_view(&tp->view);
906 tp->tty = tty;
908 tty->driver_data = tp;
909 tty->winsize.ws_row = tp->view.rows - 2;
910 tty->winsize.ws_col = tp->view.cols;
912 tty3270_create_prompt(tp);
913 tty3270_create_status(tp);
914 tty3270_update_status(tp);
917 for (i = 0; i < tp->view.rows - 2; i++)
918 tty3270_blank_line(tp);
920 tp->kbd->tty = tty;
921 tp->kbd->fn_handler[KVAL(K_INCRCONSOLE)] = tty3270_exit_tty;
922 tp->kbd->fn_handler[KVAL(K_SCROLLBACK)] = tty3270_scroll_backward;
923 tp->kbd->fn_handler[KVAL(K_SCROLLFORW)] = tty3270_scroll_forward;
924 tp->kbd->fn_handler[KVAL(K_CONS)] = tty3270_rcl_backward;
925 kbd_ascebc(tp->kbd, tp->view.ascebc);
927 raw3270_activate_view(&tp->view);
938 struct tty3270 *tp;
942 tp = (struct tty3270 *) tty->driver_data;
943 if (tp) {
945 tp->tty = tp->kbd->tty = NULL;
946 raw3270_put_view(&tp->view);
963 static void tty3270_put_character(struct tty3270 *tp, char ch)
968 line = tp->screen + tp->cy;
969 if (line->len <= tp->cx) {
970 while (line->len < tp->cx) {
972 cell->character = tp->view.ascebc[' '];
973 cell->highlight = tp->highlight;
974 cell->f_color = tp->f_color;
979 cell = line->cells + tp->cx;
980 cell->character = tp->view.ascebc[(unsigned int) ch];
981 cell->highlight = tp->highlight;
982 cell->f_color = tp->f_color;
989 tty3270_convert_line(struct tty3270 *tp, int line_nr)
1001 line = tp->screen + line_nr;
1019 if (line->len < tp->view.cols)
1023 i = tp->view.rows - 2 - line_nr;
1024 list_for_each_entry_reverse(s, &tp->lines, list)
1032 n = tty3270_alloc_string(tp, flen);
1037 free_string(&tp->freemem, s);
1074 if (line->len < tp->view.cols) {
1081 if (tp->nr_up + line_nr < tp->view.rows - 2) {
1083 tty3270_update_string(tp, s, line_nr);
1086 list_add_tail(&s->update, &tp->update);
1087 tp->update_flags |= TTY_UPDATE_LIST;
1096 tty3270_cr(struct tty3270 *tp)
1098 tp->cx = 0;
1105 tty3270_lf(struct tty3270 *tp)
1110 tty3270_convert_line(tp, tp->cy);
1111 if (tp->cy < tp->view.rows - 3) {
1112 tp->cy++;
1116 tty3270_blank_line(tp);
1117 temp = tp->screen[0];
1119 for (i = 0; i < tp->view.rows - 3; i++)
1120 tp->screen[i] = tp->screen[i+1];
1121 tp->screen[tp->view.rows - 3] = temp;
1122 tty3270_rebuild_update(tp);
1126 tty3270_ri(struct tty3270 *tp)
1128 if (tp->cy > 0) {
1129 tty3270_convert_line(tp, tp->cy);
1130 tp->cy--;
1138 tty3270_insert_characters(struct tty3270 *tp, int n)
1143 line = tp->screen + tp->cy;
1144 while (line->len < tp->cx) {
1145 line->cells[line->len].character = tp->view.ascebc[' '];
1150 if (n > tp->view.cols - tp->cx)
1151 n = tp->view.cols - tp->cx;
1152 k = min_t(int, line->len - tp->cx, tp->view.cols - tp->cx - n);
1154 line->cells[tp->cx + n + k] = line->cells[tp->cx + k];
1156 if (line->len > tp->view.cols)
1157 line->len = tp->view.cols;
1159 line->cells[tp->cx + n].character = tp->view.ascebc[' '];
1160 line->cells[tp->cx + n].highlight = tp->highlight;
1161 line->cells[tp->cx + n].f_color = tp->f_color;
1169 tty3270_delete_characters(struct tty3270 *tp, int n)
1174 line = tp->screen + tp->cy;
1175 if (line->len <= tp->cx)
1177 if (line->len - tp->cx <= n) {
1178 line->len = tp->cx;
1181 for (i = tp->cx; i + n < line->len; i++)
1190 tty3270_erase_characters(struct tty3270 *tp, int n)
1195 line = tp->screen + tp->cy;
1196 while (line->len > tp->cx && n-- > 0) {
1197 cell = line->cells + tp->cx++;
1202 tp->cx += n;
1203 tp->cx = min_t(int, tp->cx, tp->view.cols - 1);
1213 tty3270_erase_line(struct tty3270 *tp, int mode)
1219 line = tp->screen + tp->cy;
1221 line->len = tp->cx;
1223 for (i = 0; i < tp->cx; i++) {
1229 if (line->len <= tp->cx)
1230 line->len = tp->cx + 1;
1233 tty3270_convert_line(tp, tp->cy);
1243 tty3270_erase_display(struct tty3270 *tp, int mode)
1248 tty3270_erase_line(tp, 0);
1249 for (i = tp->cy + 1; i < tp->view.rows - 2; i++) {
1250 tp->screen[i].len = 0;
1251 tty3270_convert_line(tp, i);
1254 for (i = 0; i < tp->cy; i++) {
1255 tp->screen[i].len = 0;
1256 tty3270_convert_line(tp, i);
1258 tty3270_erase_line(tp, 1);
1260 for (i = 0; i < tp->view.rows - 2; i++) {
1261 tp->screen[i].len = 0;
1262 tty3270_convert_line(tp, i);
1265 tty3270_rebuild_update(tp);
1273 tty3270_set_attributes(struct tty3270 *tp)
1281 for (i = 0; i <= tp->esc_npar; i++) {
1282 attr = tp->esc_par[i];
1285 tp->highlight = TAX_RESET;
1286 tp->f_color = TAC_RESET;
1290 tp->highlight = TAX_UNDER;
1293 tp->highlight = TAX_BLINK;
1296 tp->highlight = TAX_REVER;
1299 if (tp->highlight == TAX_UNDER)
1300 tp->highlight = TAX_RESET;
1303 if (tp->highlight == TAX_BLINK)
1304 tp->highlight = TAX_RESET;
1307 if (tp->highlight == TAX_REVER)
1308 tp->highlight = TAX_RESET;
1320 tp->f_color = f_colors[attr - 30];
1327 tty3270_getpar(struct tty3270 *tp, int ix)
1329 return (tp->esc_par[ix] > 0) ? tp->esc_par[ix] : 1;
1333 tty3270_goto_xy(struct tty3270 *tp, int cx, int cy)
1338 tp->cx = min_t(int, tp->view.cols - 1, max_cx);
1339 cy = min_t(int, tp->view.rows - 3, max_cy);
1340 if (cy != tp->cy) {
1341 tty3270_convert_line(tp, tp->cy);
1342 tp->cy = cy;
1367 tty3270_escape_sequence(struct tty3270 *tp, char ch)
1371 if (tp->esc_state == ESnormal) {
1374 tp->esc_state = ESesc;
1377 if (tp->esc_state == ESesc) {
1378 tp->esc_state = ESnormal;
1381 tp->esc_state = ESsquare;
1384 tty3270_cr(tp);
1385 tty3270_lf(tp);
1388 tty3270_ri(tp);
1391 tty3270_lf(tp);
1394 kbd_puts_queue(tp->tty, "\033[?6c");
1397 tp->saved_cx = tp->cx;
1398 tp->saved_cy = tp->cy;
1399 tp->saved_highlight = tp->highlight;
1400 tp->saved_f_color = tp->f_color;
1403 tty3270_convert_line(tp, tp->cy);
1404 tty3270_goto_xy(tp, tp->saved_cx, tp->saved_cy);
1405 tp->highlight = tp->saved_highlight;
1406 tp->f_color = tp->saved_f_color;
1409 tp->cx = tp->saved_cx = 0;
1410 tp->cy = tp->saved_cy = 0;
1411 tp->highlight = tp->saved_highlight = TAX_RESET;
1412 tp->f_color = tp->saved_f_color = TAC_RESET;
1413 tty3270_erase_display(tp, 2);
1418 if (tp->esc_state == ESsquare) {
1419 tp->esc_state = ESgetpars;
1420 memset(tp->esc_par, 0, sizeof(tp->esc_par));
1421 tp->esc_npar = 0;
1422 tp->esc_ques = (ch == '?');
1423 if (tp->esc_ques)
1426 if (tp->esc_state == ESgetpars) {
1427 if (ch == ';' && tp->esc_npar < ESCAPE_NPAR - 1) {
1428 tp->esc_npar++;
1432 tp->esc_par[tp->esc_npar] *= 10;
1433 tp->esc_par[tp->esc_npar] += ch - '0';
1437 tp->esc_state = ESnormal;
1438 if (ch == 'n' && !tp->esc_ques) {
1439 if (tp->esc_par[0] == 5) /* Status report. */
1440 kbd_puts_queue(tp->tty, "\033[0n");
1441 else if (tp->esc_par[0] == 6) { /* Cursor report. */
1443 sprintf(buf, "\033[%d;%dR", tp->cy + 1, tp->cx + 1);
1444 kbd_puts_queue(tp->tty, buf);
1448 if (tp->esc_ques)
1452 tty3270_set_attributes(tp);
1456 tty3270_goto_xy(tp, tty3270_getpar(tp, 1) - 1,
1457 tty3270_getpar(tp, 0) - 1);
1460 tty3270_goto_xy(tp, tp->cx, tty3270_getpar(tp, 0) - 1);
1464 tty3270_goto_xy(tp, tp->cx, tp->cy - tty3270_getpar(tp, 0));
1469 tty3270_goto_xy(tp, tp->cx, tp->cy + tty3270_getpar(tp, 0));
1473 tty3270_goto_xy(tp, tp->cx + tty3270_getpar(tp, 0), tp->cy);
1476 tty3270_goto_xy(tp, tp->cx - tty3270_getpar(tp, 0), tp->cy);
1480 tty3270_goto_xy(tp, tty3270_getpar(tp, 0), tp->cy);
1483 tty3270_erase_characters(tp, tty3270_getpar(tp, 0));
1486 tty3270_erase_display(tp, tp->esc_par[0]);
1489 tty3270_erase_line(tp, tp->esc_par[0]);
1492 tty3270_delete_characters(tp, tty3270_getpar(tp, 0));
1495 tty3270_insert_characters(tp, tty3270_getpar(tp, 0));
1498 tp->saved_cx = tp->cx;
1499 tp->saved_cy = tp->cy;
1500 tp->saved_highlight = tp->highlight;
1501 tp->saved_f_color = tp->f_color;
1504 tty3270_convert_line(tp, tp->cy);
1505 tty3270_goto_xy(tp, tp->saved_cx, tp->saved_cy);
1506 tp->highlight = tp->saved_highlight;
1507 tp->f_color = tp->saved_f_color;
1516 tty3270_do_write(struct tty3270 *tp, const unsigned char *buf, int count)
1520 spin_lock_bh(&tp->view.lock);
1521 for (i_msg = 0; !tp->tty->stopped && i_msg < count; i_msg++) {
1522 if (tp->esc_state != 0) {
1524 tty3270_escape_sequence(tp, buf[i_msg]);
1530 tp->wcc |= TW_PLUSALARM;
1533 if (tp->cx > 0) {
1534 tp->cx--;
1535 tty3270_put_character(tp, ' ');
1539 for (i = tp->cx % 8; i < 8; i++) {
1540 if (tp->cx >= tp->view.cols) {
1541 tty3270_cr(tp);
1542 tty3270_lf(tp);
1545 tty3270_put_character(tp, ' ');
1546 tp->cx++;
1550 tty3270_cr(tp);
1551 tty3270_lf(tp);
1554 tty3270_erase_display(tp, 2);
1555 tp->cx = tp->cy = 0;
1558 tp->cx = 0;
1563 tty3270_escape_sequence(tp, buf[i_msg]);
1566 if (tp->cx >= tp->view.cols) {
1567 tty3270_cr(tp);
1568 tty3270_lf(tp);
1570 tty3270_put_character(tp, buf[i_msg]);
1571 tp->cx++;
1576 tty3270_convert_line(tp, tp->cy);
1579 if (!timer_pending(&tp->timer))
1580 tty3270_set_timer(tp, HZ/10);
1582 spin_unlock_bh(&tp->view.lock);
1592 struct tty3270 *tp;
1594 tp = tty->driver_data;
1595 if (!tp)
1597 if (tp->char_count > 0) {
1598 tty3270_do_write(tp, tp->char_buf, tp->char_count);
1599 tp->char_count = 0;
1601 tty3270_do_write(tp, buf, count);
1610 struct tty3270 *tp;
1612 tp = tty->driver_data;
1613 if (!tp || tp->char_count >= TTY3270_CHAR_BUF_SIZE)
1615 tp->char_buf[tp->char_count++] = ch;
1626 struct tty3270 *tp;
1628 tp = tty->driver_data;
1629 if (!tp)
1631 if (tp->char_count > 0) {
1632 tty3270_do_write(tp, tp->char_buf, tp->char_count);
1633 tp->char_count = 0;
1659 struct tty3270 *tp;
1662 tp = tty->driver_data;
1663 if (!tp)
1665 spin_lock_bh(&tp->view.lock);
1668 if (new != tp->inattr) {
1669 tp->inattr = new;
1670 tty3270_update_prompt(tp, NULL, 0);
1671 tty3270_set_timer(tp, 1);
1674 spin_unlock_bh(&tp->view.lock);
1683 struct tty3270 *tp;
1685 tp = tty->driver_data;
1686 if (!tp)
1688 tp->throttle = 1;
1697 struct tty3270 *tp;
1699 tp = tty->driver_data;
1700 if (!tp)
1702 tp->throttle = 0;
1703 if (tp->attn)
1704 tty3270_issue_read(tp, 1);
1724 struct tty3270 *tp;
1726 tp = tty->driver_data;
1727 if (!tp)
1731 return kbd_ioctl(tp->kbd, cmd, arg);
1738 struct tty3270 *tp;
1740 tp = tty->driver_data;
1741 if (!tp)
1745 return kbd_ioctl(tp->kbd, cmd, (unsigned long)compat_ptr(arg));