Lines Matching refs:buffer

42  * Setup a sclp write buffer. Gets a page as input (4K) and returns
44 * end of the input page. This reduces the buffer space by a few
50 struct sclp_buffer *buffer;
58 buffer = ((struct sclp_buffer *) ((addr_t) sccb + PAGE_SIZE)) - 1;
59 buffer->sccb = sccb;
60 buffer->retry_count = 0;
61 buffer->messages = 0;
62 buffer->char_sum = 0;
63 buffer->current_line = NULL;
64 buffer->current_length = 0;
65 buffer->columns = columns;
66 buffer->htab = htab;
72 return buffer;
77 * the buffer.
80 sclp_unmake_buffer(struct sclp_buffer *buffer)
82 return buffer->sccb;
86 * Initialize a new message the end of the provided buffer with
90 sclp_initialize_mto(struct sclp_buffer *buffer, int max_len)
102 /* check if current buffer sccb can contain the mto */
103 sccb = buffer->sccb;
128 buffer->current_msg = msg;
129 buffer->current_line = (char *) (mto + 1);
130 buffer->current_length = 0;
137 * updating the sizes of MTO, enclosing MDB, event buffer and SCCB.
140 sclp_finalize_mto(struct sclp_buffer *buffer)
149 sccb = buffer->sccb;
150 msg = buffer->current_msg;
151 msg->header.length += buffer->current_length;
152 msg->mdb.header.length += buffer->current_length;
153 msg->mdb.mto.length += buffer->current_length;
161 buffer->messages++;
162 buffer->char_sum += buffer->current_length;
164 buffer->current_line = NULL;
165 buffer->current_length = 0;
166 buffer->current_msg = NULL;
177 sclp_write(struct sclp_buffer *buffer, const unsigned char *msg, int count)
192 * next message. Besides we avoid a buffer overrun by writing its
209 if (buffer->current_line == NULL) {
210 rc = sclp_initialize_mto(buffer, 0);
214 sclp_finalize_mto(buffer);
218 if (buffer->current_line == NULL) {
219 rc = sclp_initialize_mto(buffer,
220 buffer->columns);
224 buffer->current_msg->mdb.go.general_msg_flags |=
229 if (buffer->current_line == NULL) {
230 rc = sclp_initialize_mto(buffer,
231 buffer->columns);
237 if (buffer->current_length >= buffer->columns)
240 *buffer->current_line++ = 0x40;
241 buffer->current_length++;
242 } while (buffer->current_length % buffer->htab);
248 if (buffer->current_line != NULL) {
249 spaces = buffer->current_length;
250 sclp_finalize_mto(buffer);
251 rc = sclp_initialize_mto(buffer,
252 buffer->columns);
255 memset(buffer->current_line, 0x40, spaces);
256 buffer->current_line += spaces;
257 buffer->current_length = spaces;
260 rc = sclp_initialize_mto(buffer,
261 buffer->columns);
264 sclp_finalize_mto(buffer);
271 if (buffer->current_line != NULL &&
272 buffer->current_length > 0) {
273 buffer->current_length--;
274 buffer->current_line--;
279 if (buffer->current_line != NULL)
280 sclp_finalize_mto(buffer);
289 if (buffer->current_line == NULL) {
290 rc = sclp_initialize_mto(buffer,
291 buffer->columns);
295 *buffer->current_line++ = sclp_ascebc(msg[i_msg]);
296 buffer->current_length++;
300 if (buffer->current_line != NULL &&
301 buffer->current_length >= buffer->columns)
302 sclp_finalize_mto(buffer);
313 sclp_buffer_space(struct sclp_buffer *buffer)
318 sccb = buffer->sccb;
320 if (buffer->current_line != NULL)
321 count -= sizeof(struct msg_buf) + buffer->current_length;
326 * Return number of characters in buffer
329 sclp_chars_in_buffer(struct sclp_buffer *buffer)
333 count = buffer->char_sum;
334 if (buffer->current_line != NULL)
335 count += buffer->current_length;
367 struct sclp_buffer *buffer;
370 buffer = (struct sclp_buffer *) data;
371 sccb = buffer->sccb;
374 if (buffer->callback != NULL)
375 buffer->callback(buffer, -EIO);
381 /* Normal completion, buffer processed, message(s) sent */
386 if (++buffer->retry_count > SCLP_BUFFER_MAX_RETRY) {
394 buffer->request.status = SCLP_REQ_FILLED;
404 if (++buffer->retry_count > SCLP_BUFFER_MAX_RETRY) {
410 buffer->request.status = SCLP_REQ_FILLED;
422 if (buffer->callback != NULL)
423 buffer->callback(buffer, rc);
432 sclp_emit_buffer(struct sclp_buffer *buffer,
436 if (buffer->current_line != NULL)
437 sclp_finalize_mto(buffer);
439 /* Are there messages in the output buffer ? */
440 if (buffer->messages == 0)
443 buffer->request.command = SCLP_CMDW_WRITE_EVENT_DATA;
444 buffer->request.status = SCLP_REQ_FILLED;
445 buffer->request.callback = sclp_writedata_callback;
446 buffer->request.callback_data = buffer;
447 buffer->request.sccb = buffer->sccb;
448 buffer->callback = callback;
449 return sclp_add_request(&buffer->request);