Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/sfxge/common/ef10_nvram.c
Show First 20 Lines • Show All 895 Lines • ▼ Show 20 Lines | __in_bcount(buffer_size) | ||||
caddr_t bufferp, | caddr_t bufferp, | ||||
__in size_t buffer_size, | __in size_t buffer_size, | ||||
__in uint32_t offset, | __in uint32_t offset, | ||||
__out uint32_t *endp) | __out uint32_t *endp) | ||||
{ | { | ||||
// Read to end of partition | // Read to end of partition | ||||
tlv_cursor_t cursor; | tlv_cursor_t cursor; | ||||
efx_rc_t rc; | efx_rc_t rc; | ||||
uint32_t *segment_used; | |||||
if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)bufferp, | if ((rc = tlv_init_cursor_from_size(&cursor, (uint8_t *)bufferp, | ||||
buffer_size)) != 0) { | buffer_size)) != 0) { | ||||
rc = EFAULT; | rc = EFAULT; | ||||
goto fail1; | goto fail1; | ||||
} | } | ||||
if ((rc = tlv_require_end(&cursor)) != 0) | segment_used = cursor.block; | ||||
/* | |||||
* Go through each segment and check that it has an end tag. If there | |||||
* is no end tag then the previous segment was the last valid one, | |||||
* so return the used space including that end tag. | |||||
*/ | |||||
while (tlv_tag(&cursor) == TLV_TAG_PARTITION_HEADER) { | |||||
if (tlv_require_end(&cursor) != 0) { | |||||
if (segment_used == cursor.block) { | |||||
/* | |||||
* First segment is corrupt, so there is | |||||
* no valid data in partition. | |||||
*/ | |||||
rc = EINVAL; | |||||
goto fail2; | goto fail2; | ||||
} | |||||
break; | |||||
} | |||||
segment_used = cursor.end + 1; | |||||
*endp = byte_offset(tlv_last_segment_end(&cursor)+1, cursor.block); | cursor.current = segment_used; | ||||
} | |||||
/* Return space used (including the END tag) */ | |||||
*endp = (segment_used - cursor.block) * sizeof (uint32_t); | |||||
return (0); | return (0); | ||||
fail2: | fail2: | ||||
EFSYS_PROBE(fail2); | EFSYS_PROBE(fail2); | ||||
fail1: | fail1: | ||||
EFSYS_PROBE1(fail1, efx_rc_t, rc); | EFSYS_PROBE1(fail1, efx_rc_t, rc); | ||||
▲ Show 20 Lines • Show All 1,411 Lines • Show Last 20 Lines |