/* Populate pipe descriptors for copying to/from pipe buffer. 
This routine is only called if the pipe buffer is not empty (when reading), or if not full (when writing).  */
static size_t pipe_buffer_list_populate(sys_dlist_t *list, struct _pipe_desc *desc, unsigned char *buffer, size_t size, size_t start, size_t end)
/* Populate pipe descriptors for copying to/from pipe buffer. 
This routine is only called if the pipe buffer is not empty (when reading), or if not full (when writing).  */
static size_t pipe_buffer_list_populate(sys_dlist_t *list, struct _pipe_desc *desc, unsigned char *buffer, size_t size, size_t start, size_t end)
{
	sys_dlist_append(list, &desc[0].node);
	desc[0].thread = NULL;
	desc[0].buffer = &buffer[start];
	if (start < end) {
		desc[0].bytes_to_xfer = end - start;
		return end - start;
	}
	desc[0].bytes_to_xfer = size - start;
	desc[1].thread = NULL;
	desc[1].buffer = &buffer[0];
	desc[1].bytes_to_xfer = end;
	sys_dlist_append(list, &desc[1].node);
	return size - start + end;
}