/* For a backward stream, the bytes are copied starting from the current stream position. */
EFI_STATUS EFIAPI AmlStreamCpyS(OUT CHAR8 *DstBuffer, IN UINT32 MaxDstBufferSize, IN AML_STREAM *Stream, IN UINT32 Size)
/* For a backward stream, the bytes are copied starting from the current stream position. */
EFI_STATUS EFIAPI AmlStreamCpyS(OUT CHAR8 *DstBuffer, IN UINT32 MaxDstBufferSize, IN AML_STREAM *Stream, IN UINT32 Size)
{
  CHAR8  *StreamBufferStart;
  if ((DstBuffer == NULL)       ||
      (MaxDstBufferSize == 0)   ||
      (Size > MaxDstBufferSize) ||
      (Size > AmlStreamGetMaxBufferSize (Stream)))
  {
    ASSERT (0);
    return EFI_INVALID_PARAMETER;
  }
  if (Size == 0) {
    return EFI_SUCCESS;
  }
  StreamBufferStart = (CHAR8 *)(IS_STREAM_FORWARD (Stream) ?
                                Stream->Buffer :
                                AmlStreamGetCurrPos (Stream));
  CopyMem (DstBuffer, StreamBufferStart, Size);
  return EFI_SUCCESS;
}