summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg/Library/Common/AmlLib/Stream
diff options
context:
space:
mode:
Diffstat (limited to 'DynamicTablesPkg/Library/Common/AmlLib/Stream')
-rw-r--r--DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.c154
-rw-r--r--DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.h82
2 files changed, 126 insertions, 110 deletions
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.c b/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.c
index 08ee959475..6cd1c21196 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.c
@@ -23,25 +23,26 @@
EFI_STATUS
EFIAPI
AmlStreamInit (
- IN OUT AML_STREAM * Stream,
- IN UINT8 * Buffer,
- IN UINT32 MaxBufferSize,
- IN EAML_STREAM_DIRECTION Direction
+ IN OUT AML_STREAM *Stream,
+ IN UINT8 *Buffer,
+ IN UINT32 MaxBufferSize,
+ IN EAML_STREAM_DIRECTION Direction
)
{
if ((Stream == NULL) ||
(Buffer == NULL) ||
(MaxBufferSize == 0) ||
((Direction != EAmlStreamDirectionForward) &&
- (Direction != EAmlStreamDirectionBackward))) {
+ (Direction != EAmlStreamDirectionBackward)))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
- Stream->Buffer = Buffer;
+ Stream->Buffer = Buffer;
Stream->MaxBufferSize = MaxBufferSize;
- Stream->Index = 0;
- Stream->Direction = Direction;
+ Stream->Index = 0;
+ Stream->Direction = Direction;
return EFI_SUCCESS;
}
@@ -60,20 +61,21 @@ AmlStreamInit (
EFI_STATUS
EFIAPI
AmlStreamClone (
- IN CONST AML_STREAM * Stream,
- OUT AML_STREAM * ClonedStream
+ IN CONST AML_STREAM *Stream,
+ OUT AML_STREAM *ClonedStream
)
{
if (!IS_STREAM (Stream) ||
- (ClonedStream == NULL)) {
+ (ClonedStream == NULL))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
- ClonedStream->Buffer = Stream->Buffer;
+ ClonedStream->Buffer = Stream->Buffer;
ClonedStream->MaxBufferSize = Stream->MaxBufferSize;
- ClonedStream->Index = Stream->Index;
- ClonedStream->Direction = Stream->Direction;
+ ClonedStream->Index = Stream->Index;
+ ClonedStream->Direction = Stream->Direction;
return EFI_SUCCESS;
}
@@ -105,12 +107,13 @@ AmlStreamClone (
EFI_STATUS
EFIAPI
AmlStreamInitSubStream (
- IN CONST AML_STREAM * Stream,
- OUT AML_STREAM * SubStream
+ IN CONST AML_STREAM *Stream,
+ OUT AML_STREAM *SubStream
)
{
if (!IS_STREAM (Stream) ||
- (SubStream == NULL)) {
+ (SubStream == NULL))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -125,8 +128,8 @@ AmlStreamInitSubStream (
}
SubStream->MaxBufferSize = AmlStreamGetFreeSpace (Stream);
- SubStream->Index = 0;
- SubStream->Direction = Stream->Direction;
+ SubStream->Index = 0;
+ SubStream->Direction = Stream->Direction;
return EFI_SUCCESS;
}
@@ -141,13 +144,14 @@ AmlStreamInitSubStream (
UINT8 *
EFIAPI
AmlStreamGetBuffer (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
ASSERT (0);
return NULL;
}
+
return Stream->Buffer;
}
@@ -161,13 +165,14 @@ AmlStreamGetBuffer (
UINT32
EFIAPI
AmlStreamGetMaxBufferSize (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
ASSERT (0);
return 0;
}
+
return Stream->MaxBufferSize;
}
@@ -183,13 +188,14 @@ AmlStreamGetMaxBufferSize (
EFI_STATUS
EFIAPI
AmlStreamReduceMaxBufferSize (
- IN AML_STREAM * Stream,
- IN UINT32 Diff
+ IN AML_STREAM *Stream,
+ IN UINT32 Diff
)
{
if (!IS_STREAM (Stream) ||
(Diff == 0) ||
- ((Stream->MaxBufferSize - Diff) <= Stream->Index)) {
+ ((Stream->MaxBufferSize - Diff) <= Stream->Index))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -214,13 +220,14 @@ AmlStreamReduceMaxBufferSize (
UINT32
EFIAPI
AmlStreamGetIndex (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
ASSERT (0);
return 0;
}
+
return Stream->Index;
}
@@ -234,13 +241,14 @@ AmlStreamGetIndex (
EAML_STREAM_DIRECTION
EFIAPI
AmlStreamGetDirection (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
ASSERT (0);
return EAmlStreamDirectionInvalid;
}
+
return Stream->Direction;
}
@@ -254,7 +262,7 @@ AmlStreamGetDirection (
UINT8 *
EFIAPI
AmlStreamGetCurrPos (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
@@ -282,7 +290,7 @@ AmlStreamGetCurrPos (
UINT32
EFIAPI
AmlStreamGetFreeSpace (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
@@ -314,13 +322,14 @@ AmlStreamGetFreeSpace (
EFI_STATUS
EFIAPI
AmlStreamProgress (
- IN AML_STREAM * Stream,
- IN UINT32 Offset
+ IN AML_STREAM *Stream,
+ IN UINT32 Offset
)
{
if (!IS_STREAM (Stream) ||
- IS_END_OF_STREAM (Stream) ||
- (Offset == 0)) {
+ IS_END_OF_STREAM (Stream) ||
+ (Offset == 0))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -350,12 +359,13 @@ AmlStreamProgress (
EFI_STATUS
EFIAPI
AmlStreamRewind (
- IN AML_STREAM * Stream,
- IN UINT32 Offset
+ IN AML_STREAM *Stream,
+ IN UINT32 Offset
)
{
if (!IS_STREAM (Stream) ||
- (Offset == 0)) {
+ (Offset == 0))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -380,7 +390,7 @@ AmlStreamRewind (
EFI_STATUS
EFIAPI
AmlStreamReset (
- IN AML_STREAM * Stream
+ IN AML_STREAM *Stream
)
{
if (!IS_STREAM (Stream)) {
@@ -409,15 +419,16 @@ AmlStreamReset (
EFI_STATUS
EFIAPI
AmlStreamPeekByte (
- IN AML_STREAM * Stream,
- OUT UINT8 * OutByte
+ IN AML_STREAM *Stream,
+ OUT UINT8 *OutByte
)
{
- UINT8 * CurPos;
+ UINT8 *CurPos;
if (!IS_STREAM (Stream) ||
IS_END_OF_STREAM (Stream) ||
- (OutByte == NULL)) {
+ (OutByte == NULL))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -448,15 +459,16 @@ AmlStreamPeekByte (
EFI_STATUS
EFIAPI
AmlStreamReadByte (
- IN AML_STREAM * Stream,
- OUT UINT8 * OutByte
+ IN AML_STREAM *Stream,
+ OUT UINT8 *OutByte
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (!IS_STREAM (Stream) ||
IS_END_OF_STREAM (Stream) ||
- (OutByte == NULL)) {
+ (OutByte == NULL))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -498,17 +510,18 @@ AmlStreamReadByte (
EFI_STATUS
EFIAPI
AmlStreamWrite (
- IN AML_STREAM * Stream,
- IN CONST UINT8 * Buffer,
- IN UINT32 Size
+ IN AML_STREAM *Stream,
+ IN CONST UINT8 *Buffer,
+ IN UINT32 Size
)
{
- UINT8 * CurrPos;
+ UINT8 *CurrPos;
if (!IS_STREAM (Stream) ||
IS_END_OF_STREAM (Stream) ||
(Buffer == NULL) ||
- (Size == 0)) {
+ (Size == 0))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -554,21 +567,22 @@ AmlStreamWrite (
BOOLEAN
EFIAPI
AmlStreamCmp (
- IN CONST AML_STREAM * Stream1,
- IN CONST AML_STREAM * Stream2,
- IN UINT32 Size
+ IN CONST AML_STREAM *Stream1,
+ IN CONST AML_STREAM *Stream2,
+ IN UINT32 Size
)
{
- UINT32 MinSize;
- UINT8 * CurrPosStream1;
- UINT8 * CurrPosStream2;
+ UINT32 MinSize;
+ UINT8 *CurrPosStream1;
+ UINT8 *CurrPosStream2;
if (!IS_STREAM (Stream1) ||
IS_END_OF_STREAM (Stream1) ||
!IS_STREAM (Stream2) ||
IS_END_OF_STREAM (Stream2) ||
(Stream1->Direction != Stream2->Direction) ||
- (Size == 0)) {
+ (Size == 0))
+ {
ASSERT (0);
return FALSE;
}
@@ -589,6 +603,7 @@ AmlStreamCmp (
ASSERT (0);
return FALSE;
}
+
CurrPosStream2 = AmlStreamGetCurrPos (Stream2);
if (CurrPosStream2 == NULL) {
ASSERT (0);
@@ -606,10 +621,10 @@ AmlStreamCmp (
// ^
// CurrPos
return (0 == CompareMem (
- CurrPosStream1 - (MinSize - 1),
- CurrPosStream2 - (MinSize - 1),
- MinSize
- ));
+ CurrPosStream1 - (MinSize - 1),
+ CurrPosStream2 - (MinSize - 1),
+ MinSize
+ ));
}
/** Copy Size bytes of the stream's data to DstBuffer.
@@ -633,19 +648,20 @@ AmlStreamCmp (
EFI_STATUS
EFIAPI
AmlStreamCpyS (
- OUT CHAR8 * DstBuffer,
- IN UINT32 MaxDstBufferSize,
- IN AML_STREAM * Stream,
- IN UINT32 Size
+ OUT CHAR8 *DstBuffer,
+ IN UINT32 MaxDstBufferSize,
+ IN AML_STREAM *Stream,
+ IN UINT32 Size
)
{
- CHAR8 * StreamBufferStart;
+ CHAR8 *StreamBufferStart;
// Stream is checked in the function call.
if ((DstBuffer == NULL) ||
(MaxDstBufferSize == 0) ||
(Size > MaxDstBufferSize) ||
- (Size > AmlStreamGetMaxBufferSize (Stream))) {
+ (Size > AmlStreamGetMaxBufferSize (Stream)))
+ {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
@@ -655,9 +671,9 @@ AmlStreamCpyS (
}
// Find the address at which the data is starting.
- StreamBufferStart = (CHAR8*)(IS_STREAM_FORWARD (Stream) ?
- Stream->Buffer :
- AmlStreamGetCurrPos (Stream));
+ StreamBufferStart = (CHAR8 *)(IS_STREAM_FORWARD (Stream) ?
+ Stream->Buffer :
+ AmlStreamGetCurrPos (Stream));
CopyMem (DstBuffer, StreamBufferStart, Size);
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.h b/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.h
index cd2da89b07..35d7c875bf 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.h
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Stream/AmlStream.h
@@ -31,17 +31,17 @@ typedef enum EAmlStreamDirection {
*/
typedef struct AmlStream {
/// Pointer to a buffer.
- UINT8 * Buffer;
+ UINT8 *Buffer;
/// Size of Buffer.
- UINT32 MaxBufferSize;
+ UINT32 MaxBufferSize;
/// Index in the Buffer.
/// The Index field allows to keep track of how many bytes have been
/// read/written in the Buffer, and to retrieve the current stream position.
/// 0 <= Index <= MaxBufferSize.
/// If Index == MaxBufferSize, no more action is allowed on the stream.
- UINT32 Index;
+ UINT32 Index;
/// The direction the stream is progressing.
/// If the stream goes backward (toward lower addresses), the bytes written
@@ -56,7 +56,7 @@ typedef struct AmlStream {
/// +---------------+-----+-----+-----+-----+-----+-----+---- +------+
/// ^
/// Current position.
- EAML_STREAM_DIRECTION Direction;
+ EAML_STREAM_DIRECTION Direction;
} AML_STREAM;
/** Check whether a StreamPtr is a valid Stream.
@@ -88,7 +88,7 @@ typedef struct AmlStream {
@retval TRUE Stream goes forward.
@retval FALSE Otherwise.
*/
-#define IS_STREAM_FORWARD(Stream) ( \
+#define IS_STREAM_FORWARD(Stream) ( \
((AML_STREAM*)Stream)->Direction == EAmlStreamDirectionForward)
/** Check Stream goes backward.
@@ -98,7 +98,7 @@ typedef struct AmlStream {
@retval TRUE Stream goes backward.
@retval FALSE Otherwise.
*/
-#define IS_STREAM_BACKWARD(Stream) ( \
+#define IS_STREAM_BACKWARD(Stream) ( \
((AML_STREAM*)Stream)->Direction == EAmlStreamDirectionBackward)
/** Initialize a stream.
@@ -116,10 +116,10 @@ typedef struct AmlStream {
EFI_STATUS
EFIAPI
AmlStreamInit (
- IN OUT AML_STREAM * Stream,
- IN UINT8 * Buffer,
- IN UINT32 MaxBufferSize,
- IN EAML_STREAM_DIRECTION Direction
+ IN OUT AML_STREAM *Stream,
+ IN UINT8 *Buffer,
+ IN UINT32 MaxBufferSize,
+ IN EAML_STREAM_DIRECTION Direction
);
/** Clone a stream.
@@ -136,8 +136,8 @@ AmlStreamInit (
EFI_STATUS
EFIAPI
AmlStreamClone (
- IN CONST AML_STREAM * Stream,
- OUT AML_STREAM * ClonedStream
+ IN CONST AML_STREAM *Stream,
+ OUT AML_STREAM *ClonedStream
);
/** Initialize a sub-stream from a stream.
@@ -167,8 +167,8 @@ AmlStreamClone (
EFI_STATUS
EFIAPI
AmlStreamInitSubStream (
- IN CONST AML_STREAM * Stream,
- OUT AML_STREAM * SubStream
+ IN CONST AML_STREAM *Stream,
+ OUT AML_STREAM *SubStream
);
/** Get the buffer of a stream.
@@ -181,7 +181,7 @@ AmlStreamInitSubStream (
UINT8 *
EFIAPI
AmlStreamGetBuffer (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
);
/** Get the size of Stream's Buffer.
@@ -194,7 +194,7 @@ AmlStreamGetBuffer (
UINT32
EFIAPI
AmlStreamGetMaxBufferSize (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
);
/** Reduce the maximal size of Stream's Buffer (MaxBufferSize field).
@@ -209,8 +209,8 @@ AmlStreamGetMaxBufferSize (
EFI_STATUS
EFIAPI
AmlStreamReduceMaxBufferSize (
- IN AML_STREAM * Stream,
- IN UINT32 Diff
+ IN AML_STREAM *Stream,
+ IN UINT32 Diff
);
/** Get Stream's Index.
@@ -229,7 +229,7 @@ AmlStreamReduceMaxBufferSize (
UINT32
EFIAPI
AmlStreamGetIndex (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
);
/** Get Stream's Direction.
@@ -242,7 +242,7 @@ AmlStreamGetIndex (
EAML_STREAM_DIRECTION
EFIAPI
AmlStreamGetDirection (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
);
/** Return a pointer to the current position in the stream.
@@ -255,7 +255,7 @@ AmlStreamGetDirection (
UINT8 *
EFIAPI
AmlStreamGetCurrPos (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
);
/** Get the space available in the stream.
@@ -268,7 +268,7 @@ AmlStreamGetCurrPos (
UINT32
EFIAPI
AmlStreamGetFreeSpace (
- IN CONST AML_STREAM * Stream
+ IN CONST AML_STREAM *Stream
);
/** Move Stream by Offset bytes.
@@ -287,8 +287,8 @@ AmlStreamGetFreeSpace (
EFI_STATUS
EFIAPI
AmlStreamProgress (
- IN AML_STREAM * Stream,
- IN UINT32 Offset
+ IN AML_STREAM *Stream,
+ IN UINT32 Offset
);
/** Rewind Stream of Offset bytes.
@@ -306,8 +306,8 @@ AmlStreamProgress (
EFI_STATUS
EFIAPI
AmlStreamRewind (
- IN AML_STREAM * Stream,
- IN UINT32 Offset
+ IN AML_STREAM *Stream,
+ IN UINT32 Offset
);
/** Reset the Stream (move the current position to the initial position).
@@ -320,7 +320,7 @@ AmlStreamRewind (
EFI_STATUS
EFIAPI
AmlStreamReset (
- IN AML_STREAM * Stream
+ IN AML_STREAM *Stream
);
/** Peek one byte at Stream's current position.
@@ -339,8 +339,8 @@ AmlStreamReset (
EFI_STATUS
EFIAPI
AmlStreamPeekByte (
- IN AML_STREAM * Stream,
- OUT UINT8 * OutByte
+ IN AML_STREAM *Stream,
+ OUT UINT8 *OutByte
);
/** Read one byte at Stream's current position.
@@ -359,8 +359,8 @@ AmlStreamPeekByte (
EFI_STATUS
EFIAPI
AmlStreamReadByte (
- IN AML_STREAM * Stream,
- OUT UINT8 * OutByte
+ IN AML_STREAM *Stream,
+ OUT UINT8 *OutByte
);
/** Write Size bytes in the stream.
@@ -388,9 +388,9 @@ AmlStreamReadByte (
EFI_STATUS
EFIAPI
AmlStreamWrite (
- IN AML_STREAM * Stream,
- IN CONST UINT8 * Buffer,
- IN UINT32 Size
+ IN AML_STREAM *Stream,
+ IN CONST UINT8 *Buffer,
+ IN UINT32 Size
);
/** Compare Size bytes between Stream1 and Stream2 from their
@@ -416,9 +416,9 @@ AmlStreamWrite (
BOOLEAN
EFIAPI
AmlStreamCmp (
- IN CONST AML_STREAM * Stream1,
- IN CONST AML_STREAM * Stream2,
- IN UINT32 Size
+ IN CONST AML_STREAM *Stream1,
+ IN CONST AML_STREAM *Stream2,
+ IN UINT32 Size
);
/** Copy Size bytes of the stream's data to DstBuffer.
@@ -442,10 +442,10 @@ AmlStreamCmp (
EFI_STATUS
EFIAPI
AmlStreamCpyS (
- OUT CHAR8 * DstBuffer,
- IN UINT32 MaxDstBufferSize,
- IN AML_STREAM * Stream,
- IN UINT32 Size
+ OUT CHAR8 *DstBuffer,
+ IN UINT32 MaxDstBufferSize,
+ IN AML_STREAM *Stream,
+ IN UINT32 Size
);
#endif // AML_STREAM_H_