/* Return a pointer to, and the length of, the contiguous free region available for output in a ring buffer. */
STATIC VOID* XenStoreGetOutputChunk(IN XENSTORE_RING_IDX Cons, IN XENSTORE_RING_IDX Prod, IN CHAR8 *Buffer, OUT UINT32 *LenPtr)
/* Return a pointer to, and the length of, the contiguous free region available for output in a ring buffer. */
STATIC VOID* XenStoreGetOutputChunk(IN XENSTORE_RING_IDX Cons, IN XENSTORE_RING_IDX Prod, IN CHAR8 *Buffer, OUT UINT32 *LenPtr)
{
  UINT32  Len;
  Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Prod);
  if ((XENSTORE_RING_SIZE - (Prod - Cons)) < Len) {
    Len = XENSTORE_RING_SIZE - (Prod - Cons);
  }
  *LenPtr = Len;
  return (Buffer + MASK_XENSTORE_IDX (Prod));
}