FreeBSD/sys/dev/hyperv/vmbus/hv_ring_buffer.c
/**
 * @brief Helper routine to copy to source from ring buffer.
 *
 * Assume there is enough room. Handles wrap-around in src case only!
 */
@brief Helper routine to copy to source from ring buffer.
Assume there is enough room. Handles wrap-around in src case only!
@brief Helper routine to copy to source from ring buffer . Assume there is enough room . Handles wrap - around in src case only!
uint32_t
copy_from_ring_buffer(
	hv_vmbus_ring_buffer_info*	ring_info,
	char*				dest,
	uint32_t			dest_len,
	uint32_t			start_read_offset)
{
	uint32_t fragLen;
	char *ring_buffer = get_ring_buffer(ring_info);
	uint32_t ring_buffer_size = get_ring_buffer_size(ring_info);
	if (dest_len > ring_buffer_size - start_read_offset) {
	    fragLen = ring_buffer_size - start_read_offset;
	    memcpy(dest, ring_buffer + start_read_offset, fragLen);
	    memcpy(dest + fragLen, ring_buffer, dest_len - fragLen);
	} else {
	    memcpy(dest, ring_buffer + start_read_offset, dest_len);
	}
	start_read_offset += dest_len;
	start_read_offset %= ring_buffer_size;
	return (start_read_offset);
}
uint32_t copy_from_ring_buffer ( hv_vmbus_ring_buffer_info * ring_info , char * dest , uint32_t dest_len , uint32_t start_read_offset ) { uint32_t fragLen ; char * ring_buffer = get_ring_buffer ( ring_info ) ; uint32_t ring_buffer_size = get_ring_buffer_size ( ring_info ) ; if ( dest_len > ring_buffer_size - start_read_offset ) { fragLen = ring_buffer_size - start_read_offset ; memcpy ( dest , ring_buffer + start_read_offset , fragLen ) ; memcpy ( dest + fragLen , ring_buffer , dest_len - fragLen ) ; } else { memcpy ( dest , ring_buffer + start_read_offset , dest_len ) ; } start_read_offset += dest_len ; start_read_offset %= ring_buffer_size ; return ( start_read_offset ) ; }
@brief Helper routine to copy to source from ring buffer.
@brief Helper routine to copy to source from ring buffer .
/*  wrap-around detected at the src */