Lines Matching full:cp

78 static void con3270_set_timer(struct con3270 *cp, int expires)  in con3270_set_timer()  argument
81 del_timer(&cp->timer); in con3270_set_timer()
83 mod_timer(&cp->timer, jiffies + expires); in con3270_set_timer()
92 con3270_update_status(struct con3270 *cp) in con3270_update_status() argument
96 str = (cp->nr_up != 0) ? "History" : "Running"; in con3270_update_status()
97 memcpy(cp->status->string + 24, str, 7); in con3270_update_status()
98 codepage_convert(cp->view.ascebc, cp->status->string + 24, 7); in con3270_update_status()
99 cp->update_flags |= CON_UPDATE_STATUS; in con3270_update_status()
103 con3270_create_status(struct con3270 *cp) in con3270_create_status() argument
110 cp->status = alloc_string(&cp->freemem, sizeof(blueprint)); in con3270_create_status()
112 memcpy(cp->status->string, blueprint, sizeof(blueprint)); in con3270_create_status()
114 raw3270_buffer_address(cp->view.dev, cp->status->string + 1, in con3270_create_status()
115 cp->view.cols * (cp->view.rows - 1)); in con3270_create_status()
116 raw3270_buffer_address(cp->view.dev, cp->status->string + 21, in con3270_create_status()
117 cp->view.cols * cp->view.rows - 8); in con3270_create_status()
119 codepage_convert(cp->view.ascebc, cp->status->string + 8, 12); in con3270_create_status()
120 codepage_convert(cp->view.ascebc, cp->status->string + 24, 7); in con3270_create_status()
127 con3270_update_string(struct con3270 *cp, struct string *s, int nr) in con3270_update_string() argument
136 raw3270_buffer_address(cp->view.dev, s->string + s->len - 3, in con3270_update_string()
137 cp->view.cols * (nr + 1)); in con3270_update_string()
144 con3270_rebuild_update(struct con3270 *cp) in con3270_rebuild_update() argument
153 list_for_each_entry_safe(s, n, &cp->update, update) in con3270_rebuild_update()
155 nr = cp->view.rows - 2 + cp->nr_up; in con3270_rebuild_update()
156 list_for_each_entry_reverse(s, &cp->lines, list) { in con3270_rebuild_update()
157 if (nr < cp->view.rows - 1) in con3270_rebuild_update()
158 list_add(&s->update, &cp->update); in con3270_rebuild_update()
162 cp->line_nr = 0; in con3270_rebuild_update()
163 cp->update_flags |= CON_UPDATE_LIST; in con3270_rebuild_update()
170 con3270_alloc_string(struct con3270 *cp, size_t size) in con3270_alloc_string() argument
174 s = alloc_string(&cp->freemem, size); in con3270_alloc_string()
177 list_for_each_entry_safe(s, n, &cp->lines, list) { in con3270_alloc_string()
181 cp->nr_lines--; in con3270_alloc_string()
182 if (free_string(&cp->freemem, s) >= size) in con3270_alloc_string()
185 s = alloc_string(&cp->freemem, size); in con3270_alloc_string()
187 if (cp->nr_up != 0 && cp->nr_up + cp->view.rows > cp->nr_lines) { in con3270_alloc_string()
188 cp->nr_up = cp->nr_lines - cp->view.rows + 1; in con3270_alloc_string()
189 con3270_rebuild_update(cp); in con3270_alloc_string()
190 con3270_update_status(cp); in con3270_alloc_string()
211 struct con3270 *cp = from_timer(cp, t, timer); in con3270_update() local
219 if (!auto_update && !raw3270_view_active(&cp->view)) in con3270_update()
221 if (cp->view.dev) in con3270_update()
222 raw3270_activate_view(&cp->view); in con3270_update()
224 wrq = xchg(&cp->write, 0); in con3270_update()
226 con3270_set_timer(cp, 1); in con3270_update()
230 spin_lock_irqsave(&cp->view.lock, flags); in con3270_update()
232 if (cp->update_flags & CON_UPDATE_ALL) { in con3270_update()
233 con3270_rebuild_update(cp); in con3270_update()
234 con3270_update_status(cp); in con3270_update()
235 cp->update_flags = CON_UPDATE_ERASE | CON_UPDATE_LIST | in con3270_update()
238 if (cp->update_flags & CON_UPDATE_ERASE) { in con3270_update()
251 if (cp->update_flags & CON_UPDATE_STATUS) in con3270_update()
252 if (raw3270_request_add_data(wrq, cp->status->string, in con3270_update()
253 cp->status->len) == 0) in con3270_update()
256 if (cp->update_flags & CON_UPDATE_LIST) { in con3270_update()
261 raw3270_buffer_address(cp->view.dev, prolog + 1, in con3270_update()
262 cp->view.cols * cp->line_nr); in con3270_update()
265 list_for_each_entry_safe(s, n, &cp->update, update) { in con3270_update()
266 if (s != cp->cline) in con3270_update()
267 con3270_update_string(cp, s, cp->line_nr); in con3270_update()
272 if (s != cp->cline) in con3270_update()
273 cp->line_nr++; in con3270_update()
275 if (list_empty(&cp->update)) in con3270_update()
279 rc = raw3270_start(&cp->view, wrq); in con3270_update()
281 cp->update_flags &= ~updated; in con3270_update()
282 if (cp->update_flags) in con3270_update()
283 con3270_set_timer(cp, 1); in con3270_update()
286 xchg(&cp->write, wrq); in con3270_update()
288 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_update()
299 struct con3270 *cp; in con3270_read_tasklet() local
304 cp = (struct con3270 *) rrq->view; in con3270_read_tasklet()
305 spin_lock_irqsave(&cp->view.lock, flags); in con3270_read_tasklet()
306 nr_up = cp->nr_up; in con3270_read_tasklet()
309 switch (cp->input->string[0]) { in con3270_read_tasklet()
317 cp->update_flags = CON_UPDATE_ALL; in con3270_read_tasklet()
318 con3270_set_timer(cp, 1); in con3270_read_tasklet()
321 nr_up += cp->view.rows - 2; in con3270_read_tasklet()
322 if (nr_up + cp->view.rows - 1 > cp->nr_lines) { in con3270_read_tasklet()
323 nr_up = cp->nr_lines - cp->view.rows + 1; in con3270_read_tasklet()
329 nr_up -= cp->view.rows - 2; in con3270_read_tasklet()
334 if (nr_up != cp->nr_up) { in con3270_read_tasklet()
335 cp->nr_up = nr_up; in con3270_read_tasklet()
336 con3270_rebuild_update(cp); in con3270_read_tasklet()
337 con3270_update_status(cp); in con3270_read_tasklet()
338 con3270_set_timer(cp, 1); in con3270_read_tasklet()
340 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_read_tasklet()
343 raw3270_request_reset(cp->kreset); in con3270_read_tasklet()
344 raw3270_request_set_cmd(cp->kreset, TC_WRITE); in con3270_read_tasklet()
345 raw3270_request_add_data(cp->kreset, &kreset_data, 1); in con3270_read_tasklet()
346 raw3270_start(&cp->view, cp->kreset); in con3270_read_tasklet()
349 raw3270_deactivate_view(&cp->view); in con3270_read_tasklet()
352 xchg(&cp->read, rrq); in con3270_read_tasklet()
353 raw3270_put_view(&cp->view); in con3270_read_tasklet()
371 con3270_issue_read(struct con3270 *cp) in con3270_issue_read() argument
376 rrq = xchg(&cp->read, 0); in con3270_issue_read()
381 rrq->callback_data = cp; in con3270_issue_read()
383 raw3270_request_set_data(rrq, cp->input->string, cp->input->len); in con3270_issue_read()
385 rc = raw3270_start_irq(&cp->view, rrq); in con3270_issue_read()
396 struct con3270 *cp; in con3270_activate() local
398 cp = (struct con3270 *) view; in con3270_activate()
399 cp->update_flags = CON_UPDATE_ALL; in con3270_activate()
400 con3270_set_timer(cp, 1); in con3270_activate()
407 struct con3270 *cp; in con3270_deactivate() local
409 cp = (struct con3270 *) view; in con3270_deactivate()
410 del_timer(&cp->timer); in con3270_deactivate()
414 con3270_irq(struct con3270 *cp, struct raw3270_request *rq, struct irb *irb) in con3270_irq() argument
418 con3270_issue_read(cp); in con3270_irq()
428 cp->update_flags = CON_UPDATE_ALL; in con3270_irq()
429 con3270_set_timer(cp, 1); in con3270_irq()
441 con3270_cline_add(struct con3270 *cp) in con3270_cline_add() argument
443 if (!list_empty(&cp->cline->list)) in con3270_cline_add()
446 list_add_tail(&cp->cline->list, &cp->lines); in con3270_cline_add()
447 cp->nr_lines++; in con3270_cline_add()
448 con3270_rebuild_update(cp); in con3270_cline_add()
452 con3270_cline_insert(struct con3270 *cp, unsigned char c) in con3270_cline_insert() argument
454 cp->cline->string[cp->cline->len++] = in con3270_cline_insert()
455 cp->view.ascebc[(c < ' ') ? ' ' : c]; in con3270_cline_insert()
456 if (list_empty(&cp->cline->update)) { in con3270_cline_insert()
457 list_add_tail(&cp->cline->update, &cp->update); in con3270_cline_insert()
458 cp->update_flags |= CON_UPDATE_LIST; in con3270_cline_insert()
463 con3270_cline_end(struct con3270 *cp) in con3270_cline_end() argument
469 size = (cp->cline->len < cp->view.cols - 5) ? in con3270_cline_end()
470 cp->cline->len + 4 : cp->view.cols; in con3270_cline_end()
471 s = con3270_alloc_string(cp, size); in con3270_cline_end()
472 memcpy(s->string, cp->cline->string, cp->cline->len); in con3270_cline_end()
473 if (cp->cline->len < cp->view.cols - 5) { in con3270_cline_end()
477 while (--size >= cp->cline->len) in con3270_cline_end()
478 s->string[size] = cp->view.ascebc[' ']; in con3270_cline_end()
481 list_add(&s->list, &cp->cline->list); in con3270_cline_end()
482 list_del_init(&cp->cline->list); in con3270_cline_end()
483 if (!list_empty(&cp->cline->update)) { in con3270_cline_end()
484 list_add(&s->update, &cp->cline->update); in con3270_cline_end()
485 list_del_init(&cp->cline->update); in con3270_cline_end()
487 cp->cline->len = 0; in con3270_cline_end()
496 struct con3270 *cp; in con3270_write() local
500 cp = condev; in con3270_write()
501 spin_lock_irqsave(&cp->view.lock, flags); in con3270_write()
504 if (cp->cline->len == 0) in con3270_write()
505 con3270_cline_add(cp); in con3270_write()
507 con3270_cline_insert(cp, c); in con3270_write()
508 if (c == '\n' || cp->cline->len >= cp->view.cols) in con3270_write()
509 con3270_cline_end(cp); in con3270_write()
512 cp->nr_up = 0; in con3270_write()
513 if (cp->view.dev && !timer_pending(&cp->timer)) in con3270_write()
514 con3270_set_timer(cp, HZ/10); in con3270_write()
515 spin_unlock_irqrestore(&cp->view.lock,flags); in con3270_write()
529 con3270_wait_write(struct con3270 *cp) in con3270_wait_write() argument
531 while (!cp->write) { in con3270_wait_write()
532 raw3270_wait_cons_dev(cp->view.dev); in con3270_wait_write()
548 struct con3270 *cp; in con3270_notify() local
551 cp = condev; in con3270_notify()
552 if (!cp->view.dev) in con3270_notify()
554 if (!raw3270_view_lock_unavailable(&cp->view)) in con3270_notify()
555 raw3270_activate_view(&cp->view); in con3270_notify()
556 if (!spin_trylock_irqsave(&cp->view.lock, flags)) in con3270_notify()
558 con3270_wait_write(cp); in con3270_notify()
559 cp->nr_up = 0; in con3270_notify()
560 con3270_rebuild_update(cp); in con3270_notify()
561 con3270_update_status(cp); in con3270_notify()
562 while (cp->update_flags != 0) { in con3270_notify()
563 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_notify()
564 con3270_update(&cp->timer); in con3270_notify()
565 spin_lock_irqsave(&cp->view.lock, flags); in con3270_notify()
566 con3270_wait_write(cp); in con3270_notify()
568 spin_unlock_irqrestore(&cp->view.lock, flags); in con3270_notify()