Lines Matching refs:cursor
56 __in tlv_cursor_t *cursor);
64 __in tlv_cursor_t *cursor)
68 dword = cursor->current[0];
76 __in tlv_cursor_t *cursor)
80 if (tlv_tag(cursor) == TLV_TAG_END)
83 dword = cursor->current[1];
91 __in tlv_cursor_t *cursor)
93 if (tlv_tag(cursor) == TLV_TAG_END)
96 return ((uint8_t *)(&cursor->current[2]));
101 __in tlv_cursor_t *cursor)
103 if (tlv_tag(cursor) == TLV_TAG_END)
106 return ((uint8_t *)cursor->current);
119 __in tlv_cursor_t *cursor)
123 length = tlv_length(cursor);
125 return (cursor->current + TLV_DWORD_COUNT(length));
130 __in tlv_cursor_t *cursor)
134 if ((rc = tlv_validate_state(cursor)) != 0)
137 if (cursor->current == cursor->end) {
139 cursor->current = NULL;
145 cursor->current = tlv_next_item_ptr(cursor);
147 if ((rc = tlv_validate_state(cursor)) != 0)
164 __in tlv_cursor_t *cursor)
168 cursor->current = cursor->block;
170 if ((rc = tlv_validate_state(cursor)) != 0)
183 __in tlv_cursor_t *cursor,
188 rc = tlv_rewind(cursor);
190 if (tlv_tag(cursor) == tag)
193 rc = tlv_advance(cursor);
200 __in tlv_cursor_t *cursor)
204 /* Check cursor position */
205 if (cursor->current < cursor->block) {
209 if (cursor->current > cursor->limit) {
214 if (tlv_tag(cursor) != TLV_TAG_END) {
216 if (cursor->current > (cursor->limit - 2)) {
217 cursor->current = NULL;
223 if (tlv_next_item_ptr(cursor) > (cursor->limit - 1)) {
224 cursor->current = NULL;
246 __in tlv_cursor_t *cursor,
250 cursor->block = block;
251 cursor->limit = limit;
253 cursor->current = cursor->block;
254 cursor->end = NULL;
256 return (tlv_validate_state(cursor));
261 __in tlv_cursor_t *cursor,
267 return (tlv_init_cursor(cursor, (uint32_t *)block, limit));
272 __in tlv_cursor_t *cursor)
277 if (cursor->end == NULL) {
278 pos = cursor->current;
279 if ((rc = tlv_find(cursor, TLV_TAG_END)) != 0)
282 cursor->end = cursor->current;
283 cursor->current = pos;
296 __in tlv_cursor_t *cursor)
300 if ((rc = tlv_validate_state(cursor)) != 0)
303 if ((rc = tlv_require_end(cursor)) != 0)
307 return (cursor->end + 1 - cursor->block) * sizeof (uint32_t);
320 __in tlv_cursor_t *cursor,
328 ptr = cursor->current;
344 __in tlv_cursor_t *cursor,
352 if ((rc = tlv_validate_state(cursor)) != 0)
355 if ((rc = tlv_require_end(cursor)) != 0)
364 if (cursor->end + 1 + delta > cursor->limit) {
369 /* Move data up: new space at cursor->current */
370 memmove(cursor->current + delta, cursor->current,
371 (cursor->end + 1 - cursor->current) * sizeof (uint32_t));
374 cursor->end += delta;
377 tlv_write(cursor, tag, data, size);
395 __in tlv_cursor_t *cursor,
406 if ((rc = tlv_validate_state(cursor)) != 0)
409 if (tlv_tag(cursor) == TLV_TAG_END) {
413 if (tlv_tag(cursor) != tag) {
418 old_ndwords = TLV_DWORD_COUNT(tlv_length(cursor));
421 if ((rc = tlv_require_end(cursor)) != 0)
427 pos = cursor->current + old_ndwords;
429 if (cursor->end + 1 + delta > cursor->limit) {
434 /* Move up: new space at (cursor->current + old_ndwords) */
436 (cursor->end + 1 - pos) * sizeof (uint32_t));
439 cursor->end += delta;
444 pos = cursor->current + new_ndwords;
446 /* Move down: remove words at (cursor->current + new_ndwords) */
448 (cursor->end + 1 - pos) * sizeof (uint32_t));
451 memset(cursor->end + 1 - delta, 0, delta * sizeof (uint32_t));
454 cursor->end -= delta;
458 tlv_write(cursor, tag, data, size);
484 tlv_cursor_t cursor;
500 if ((rc = tlv_init_cursor_from_size(&cursor, partn_data,
505 if (tlv_tag(&cursor) != TLV_TAG_PARTITION_HEADER) {
509 header = (struct tlv_partition_header *)tlv_item(&cursor);
519 if ((rc = tlv_find(&cursor, TLV_TAG_PARTITION_TRAILER)) != 0) {
523 trailer = (struct tlv_partition_trailer *)tlv_item(&cursor);
525 if ((rc = tlv_advance(&cursor)) != 0) {
529 if (tlv_tag(&cursor) != TLV_TAG_END) {
582 tlv_cursor_t cursor;
604 if ((rc = tlv_init_cursor_from_size(&cursor, partn_data,
609 if (tlv_tag(&cursor) != TLV_TAG_PARTITION_HEADER) {
613 header = (struct tlv_partition_header *)tlv_item(&cursor);
632 if ((rc = tlv_find(&cursor, TLV_TAG_PARTITION_TRAILER)) != 0) {
636 trailer = (struct tlv_partition_trailer *)tlv_item(&cursor);
638 if ((rc = tlv_advance(&cursor)) != 0) {
642 if (tlv_tag(&cursor) != TLV_TAG_END) {
710 tlv_cursor_t cursor;
722 if ((rc = tlv_init_cursor_from_size(&cursor, partn_data,
727 if ((rc = tlv_find(&cursor, tag)) != 0) {
731 value = tlv_value(&cursor);
732 length = tlv_length(&cursor);
855 tlv_cursor_t cursor;
864 if ((rc = tlv_init_cursor_from_size(&cursor, partn_data,
869 if (tlv_tag(&cursor) != TLV_TAG_PARTITION_HEADER) {
873 header = (struct tlv_partition_header *)tlv_item(&cursor);
876 if ((rc = tlv_find(&cursor, tag)) == 0) {
878 if ((rc = tlv_modify(&cursor, tag,
883 rc = tlv_find(&cursor, TLV_TAG_PARTITION_TRAILER);
888 if ((rc = tlv_insert(&cursor, tag,
896 if ((rc = tlv_find(&cursor, TLV_TAG_PARTITION_TRAILER)) != 0) {
900 trailer = (struct tlv_partition_trailer *)tlv_item(&cursor);
903 *total_lengthp = tlv_block_length_used(&cursor);