Lines Matching full:cp

77 static void con3270_set_timer(struct con3270 *cp, int expires)  in con3270_set_timer()  argument
80 del_timer(&cp->timer); in con3270_set_timer()
82 mod_timer(&cp->timer, jiffies + expires); in con3270_set_timer()
91 con3270_update_status(struct con3270 *cp) in con3270_update_status() argument
95 str = (cp->nr_up != 0) ? "History" : "Running"; in con3270_update_status()
96 memcpy(cp->status->string + 24, str, 7); in con3270_update_status()
97 codepage_convert(cp->view.ascebc, cp->status->string + 24, 7); in con3270_update_status()
98 cp->update_flags |= CON_UPDATE_STATUS; in con3270_update_status()
102 con3270_create_status(struct con3270 *cp) in con3270_create_status() argument
109 cp->status = alloc_string(&cp->freemem, sizeof(blueprint)); in con3270_create_status()
111 memcpy(cp->status->string, blueprint, sizeof(blueprint)); in con3270_create_status()
113 raw3270_buffer_address(cp->view.dev, cp->status->string + 1, in con3270_create_status()
114 cp->view.cols * (cp->view.rows - 1)); in con3270_create_status()
115 raw3270_buffer_address(cp->view.dev, cp->status->string + 21, in con3270_create_status()
116 cp->view.cols * cp->view.rows - 8); in con3270_create_status()
118 codepage_convert(cp->view.ascebc, cp->status->string + 8, 12); in con3270_create_status()
119 codepage_convert(cp->view.ascebc, cp->status->string + 24, 7); in con3270_create_status()
126 con3270_update_string(struct con3270 *cp, struct string *s, int nr) in con3270_update_string() argument
135 raw3270_buffer_address(cp->view.dev, s->string + s->len - 3, in con3270_update_string()
136 cp->view.cols * (nr + 1)); in con3270_update_string()
143 con3270_rebuild_update(struct con3270 *cp) in con3270_rebuild_update() argument
152 list_for_each_entry_safe(s, n, &cp->update, update) in con3270_rebuild_update()
154 nr = cp->view.rows - 2 + cp->nr_up; in con3270_rebuild_update()
155 list_for_each_entry_reverse(s, &cp->lines, list) { in con3270_rebuild_update()
156 if (nr < cp->view.rows - 1) in con3270_rebuild_update()
157 list_add(&s->update, &cp->update); in con3270_rebuild_update()
161 cp->line_nr = 0; in con3270_rebuild_update()
162 cp->update_flags |= CON_UPDATE_LIST; in con3270_rebuild_update()
169 con3270_alloc_string(struct con3270 *cp, size_t size) in con3270_alloc_string() argument
173 s = alloc_string(&cp->freemem, size); in con3270_alloc_string()
176 list_for_each_entry_safe(s, n, &cp->lines, list) { in con3270_alloc_string()
180 cp->nr_lines--; in con3270_alloc_string()
181 if (free_string(&cp->freemem, s) >= size) in con3270_alloc_string()
184 s = alloc_string(&cp->freemem, size); in con3270_alloc_string()
186 if (cp->nr_up != 0 && cp->nr_up + cp->view.rows > cp->nr_lines) { in con3270_alloc_string()
187 cp->nr_up = cp->nr_lines - cp->view.rows + 1; in con3270_alloc_string()
188 con3270_rebuild_update(cp); in con3270_alloc_string()
189 con3270_update_status(cp); in con3270_alloc_string()
210 struct con3270 *cp = from_timer(cp, t, timer); in con3270_update() local
218 if (!auto_update && !raw3270_view_active(&cp->view)) in con3270_update()
220 if (cp->view.dev) in con3270_update()
221 raw3270_activate_view(&cp->view); in con3270_update()
223 wrq = xchg(&cp->write, 0); in con3270_update()
225 con3270_set_timer(cp, 1); in con3270_update()
229 spin_lock_irqsave(&cp->view.lock, flags); in con3270_update()
231 if (cp->update_flags & CON_UPDATE_ALL) { in con3270_update()
232 con3270_rebuild_update(cp); in con3270_update()
233 con3270_update_status(cp); in con3270_update()
234 cp->update_flags = CON_UPDATE_ERASE | CON_UPDATE_LIST | in con3270_update()
237 if (cp->update_flags & CON_UPDATE_ERASE) { in con3270_update()
250 if (cp->update_flags & CON_UPDATE_STATUS) in con3270_update()
251 if (raw3270_request_add_data(wrq, cp->status->string, in con3270_update()
252 cp->status->len) == 0) in con3270_update()
255 if (cp->update_flags & CON_UPDATE_LIST) { in con3270_update()
260 raw3270_buffer_address(cp->view.dev, prolog + 1, in con3270_update()
261 cp->view.cols * cp->line_nr); in con3270_update()
264 list_for_each_entry_safe(s, n, &cp->update, update) { in con3270_update()
265 if (s != cp->cline) in con3270_update()
266 con3270_update_string(cp, s, cp->line_nr); in con3270_update()
271 if (s != cp->cline) in con3270_update()
272 cp->line_nr++; in con3270_update()
274 if (list_empty(&cp->update)) in con3270_update()
278 rc = raw3270_start(&cp->view, wrq); in con3270_update()
280 cp->update_flags &= ~updated; in con3270_update()
281 if (cp->update_flags) in con3270_update()
282 con3270_set_timer(cp, 1); in con3270_update()
285 xchg(&cp->write, wrq); in con3270_update()
287 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_update()
297 struct con3270 *cp; in con3270_read_tasklet() local
301 cp = (struct con3270 *) rrq->view; in con3270_read_tasklet()
302 spin_lock_irqsave(&cp->view.lock, flags); in con3270_read_tasklet()
303 nr_up = cp->nr_up; in con3270_read_tasklet()
306 switch (cp->input->string[0]) { in con3270_read_tasklet()
314 cp->update_flags = CON_UPDATE_ALL; in con3270_read_tasklet()
315 con3270_set_timer(cp, 1); in con3270_read_tasklet()
318 nr_up += cp->view.rows - 2; in con3270_read_tasklet()
319 if (nr_up + cp->view.rows - 1 > cp->nr_lines) { in con3270_read_tasklet()
320 nr_up = cp->nr_lines - cp->view.rows + 1; in con3270_read_tasklet()
326 nr_up -= cp->view.rows - 2; in con3270_read_tasklet()
331 if (nr_up != cp->nr_up) { in con3270_read_tasklet()
332 cp->nr_up = nr_up; in con3270_read_tasklet()
333 con3270_rebuild_update(cp); in con3270_read_tasklet()
334 con3270_update_status(cp); in con3270_read_tasklet()
335 con3270_set_timer(cp, 1); in con3270_read_tasklet()
337 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_read_tasklet()
340 raw3270_request_reset(cp->kreset); in con3270_read_tasklet()
341 raw3270_request_set_cmd(cp->kreset, TC_WRITE); in con3270_read_tasklet()
342 raw3270_request_add_data(cp->kreset, &kreset_data, 1); in con3270_read_tasklet()
343 raw3270_start(&cp->view, cp->kreset); in con3270_read_tasklet()
346 raw3270_deactivate_view(&cp->view); in con3270_read_tasklet()
349 xchg(&cp->read, rrq); in con3270_read_tasklet()
350 raw3270_put_view(&cp->view); in con3270_read_tasklet()
368 con3270_issue_read(struct con3270 *cp) in con3270_issue_read() argument
373 rrq = xchg(&cp->read, 0); in con3270_issue_read()
378 rrq->callback_data = cp; in con3270_issue_read()
380 raw3270_request_set_data(rrq, cp->input->string, cp->input->len); in con3270_issue_read()
382 rc = raw3270_start_irq(&cp->view, rrq); in con3270_issue_read()
393 struct con3270 *cp; in con3270_activate() local
395 cp = (struct con3270 *) view; in con3270_activate()
396 cp->update_flags = CON_UPDATE_ALL; in con3270_activate()
397 con3270_set_timer(cp, 1); in con3270_activate()
404 struct con3270 *cp; in con3270_deactivate() local
406 cp = (struct con3270 *) view; in con3270_deactivate()
407 del_timer(&cp->timer); in con3270_deactivate()
411 con3270_irq(struct con3270 *cp, struct raw3270_request *rq, struct irb *irb) in con3270_irq() argument
415 con3270_issue_read(cp); in con3270_irq()
425 cp->update_flags = CON_UPDATE_ALL; in con3270_irq()
426 con3270_set_timer(cp, 1); in con3270_irq()
438 con3270_cline_add(struct con3270 *cp) in con3270_cline_add() argument
440 if (!list_empty(&cp->cline->list)) in con3270_cline_add()
443 list_add_tail(&cp->cline->list, &cp->lines); in con3270_cline_add()
444 cp->nr_lines++; in con3270_cline_add()
445 con3270_rebuild_update(cp); in con3270_cline_add()
449 con3270_cline_insert(struct con3270 *cp, unsigned char c) in con3270_cline_insert() argument
451 cp->cline->string[cp->cline->len++] = in con3270_cline_insert()
452 cp->view.ascebc[(c < ' ') ? ' ' : c]; in con3270_cline_insert()
453 if (list_empty(&cp->cline->update)) { in con3270_cline_insert()
454 list_add_tail(&cp->cline->update, &cp->update); in con3270_cline_insert()
455 cp->update_flags |= CON_UPDATE_LIST; in con3270_cline_insert()
460 con3270_cline_end(struct con3270 *cp) in con3270_cline_end() argument
466 size = (cp->cline->len < cp->view.cols - 5) ? in con3270_cline_end()
467 cp->cline->len + 4 : cp->view.cols; in con3270_cline_end()
468 s = con3270_alloc_string(cp, size); in con3270_cline_end()
469 memcpy(s->string, cp->cline->string, cp->cline->len); in con3270_cline_end()
470 if (cp->cline->len < cp->view.cols - 5) { in con3270_cline_end()
474 while (--size >= cp->cline->len) in con3270_cline_end()
475 s->string[size] = cp->view.ascebc[' ']; in con3270_cline_end()
478 list_add(&s->list, &cp->cline->list); in con3270_cline_end()
479 list_del_init(&cp->cline->list); in con3270_cline_end()
480 if (!list_empty(&cp->cline->update)) { in con3270_cline_end()
481 list_add(&s->update, &cp->cline->update); in con3270_cline_end()
482 list_del_init(&cp->cline->update); in con3270_cline_end()
484 cp->cline->len = 0; in con3270_cline_end()
493 struct con3270 *cp; in con3270_write() local
497 cp = condev; in con3270_write()
498 spin_lock_irqsave(&cp->view.lock, flags); in con3270_write()
501 if (cp->cline->len == 0) in con3270_write()
502 con3270_cline_add(cp); in con3270_write()
504 con3270_cline_insert(cp, c); in con3270_write()
505 if (c == '\n' || cp->cline->len >= cp->view.cols) in con3270_write()
506 con3270_cline_end(cp); in con3270_write()
509 cp->nr_up = 0; in con3270_write()
510 if (cp->view.dev && !timer_pending(&cp->timer)) in con3270_write()
511 con3270_set_timer(cp, HZ/10); in con3270_write()
512 spin_unlock_irqrestore(&cp->view.lock,flags); in con3270_write()
526 con3270_wait_write(struct con3270 *cp) in con3270_wait_write() argument
528 while (!cp->write) { in con3270_wait_write()
529 raw3270_wait_cons_dev(cp->view.dev); in con3270_wait_write()
541 struct con3270 *cp; in con3270_flush() local
544 cp = condev; in con3270_flush()
545 if (!cp->view.dev) in con3270_flush()
547 raw3270_pm_unfreeze(&cp->view); in con3270_flush()
548 raw3270_activate_view(&cp->view); in con3270_flush()
549 spin_lock_irqsave(&cp->view.lock, flags); in con3270_flush()
550 con3270_wait_write(cp); in con3270_flush()
551 cp->nr_up = 0; in con3270_flush()
552 con3270_rebuild_update(cp); in con3270_flush()
553 con3270_update_status(cp); in con3270_flush()
554 while (cp->update_flags != 0) { in con3270_flush()
555 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_flush()
556 con3270_update(&cp->timer); in con3270_flush()
557 spin_lock_irqsave(&cp->view.lock, flags); in con3270_flush()
558 con3270_wait_write(cp); in con3270_flush()
560 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_flush()