TianoCore EDK2 master
|
#include <AmlInclude.h>
Go to the source code of this file.
Data Structures | |
struct | AmlStream |
Macros | |
#define | IS_STREAM(Stream) |
#define | IS_END_OF_STREAM(Stream) |
#define | IS_STREAM_FORWARD(Stream) |
#define | IS_STREAM_BACKWARD(Stream) |
Typedefs | |
typedef enum EAmlStreamDirection | EAML_STREAM_DIRECTION |
typedef struct AmlStream | AML_STREAM |
Enumerations | |
enum | EAmlStreamDirection { EAmlStreamDirectionInvalid , EAmlStreamDirectionForward , EAmlStreamDirectionBackward , EAmlStreamDirectionMax } |
AML Stream.
Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file AmlStream.h.
#define IS_END_OF_STREAM | ( | Stream | ) |
Check whether a Stream is at the end of its buffer.
[in] | Stream | Pointer to a stream. |
TRUE | Stream is a pointer to a non-full stream. |
FALSE | Otherwise. |
Definition at line 80 of file AmlStream.h.
#define IS_STREAM | ( | Stream | ) |
Check whether a StreamPtr is a valid Stream.
[in] | Stream | Pointer to a stream. |
TRUE | Stream is a pointer to a stream. |
FALSE | Otherwise. |
Definition at line 69 of file AmlStream.h.
#define IS_STREAM_BACKWARD | ( | Stream | ) |
Check Stream goes backward.
[in] | Stream | Pointer to a stream. |
TRUE | Stream goes backward. |
FALSE | Otherwise. |
Definition at line 101 of file AmlStream.h.
#define IS_STREAM_FORWARD | ( | Stream | ) |
Check Stream goes forward.
[in] | Stream | Pointer to a stream. |
TRUE | Stream goes forward. |
FALSE | Otherwise. |
Definition at line 91 of file AmlStream.h.
typedef struct AmlStream AML_STREAM |
Stream.
This structure is used as a wrapper around a buffer. It allows to do common buffer manipulations (read, write, etc.) while preventing buffer overflows.
typedef enum EAmlStreamDirection EAML_STREAM_DIRECTION |
Stream direction.
Enum to choose the direction the stream is progressing.
enum EAmlStreamDirection |
Stream direction.
Enum to choose the direction the stream is progressing.
Definition at line 18 of file AmlStream.h.
EFI_STATUS EFIAPI AmlStreamClone | ( | IN CONST AML_STREAM * | Stream, |
OUT AML_STREAM * | ClonedStream | ||
) |
Clone a stream.
Cloning a stream means copying all the values of the input Stream in the ClonedStream.
[in] | Stream | Pointer to the stream to clone. |
[in] | ClonedStream | Pointer to the stream to initialize. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Clone a stream.
Cloning a stream means copying all the values of the input Stream in the ClonedStream.
[in] | Stream | Pointer to the stream to clone. |
[out] | ClonedStream | Pointer to the stream to initialize. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 63 of file AmlStream.c.
BOOLEAN EFIAPI AmlStreamCmp | ( | IN CONST AML_STREAM * | Stream1, |
IN CONST AML_STREAM * | Stream2, | ||
IN UINT32 | Size | ||
) |
Compare Size bytes between Stream1 and Stream2 from their respective current position.
Stream1 and Stream2 must go in the same direction. Stream1 and Stream2 are left unchanged.
[in] | Stream1 | First stream to compare. The stream must not be at its end. |
[in] | Stream2 | Second stream to compare. The stream must not be at its end. |
[in] | Size | Number of bytes to compare. Must be lower than the minimum remaining space of Stream1 and Stream2. Must be non-zero. |
TRUE | If Stream1 and Stream2 have Size bytes equal, from their respective current position. The function completed successfully. |
FALSE | Otherwise. |
Definition at line 569 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamCpyS | ( | OUT CHAR8 * | DstBuffer, |
IN UINT32 | MaxDstBufferSize, | ||
IN AML_STREAM * | Stream, | ||
IN UINT32 | Size | ||
) |
Copy Size bytes of the stream's data to DstBuffer.
For a backward stream, the bytes are copied starting from the current stream position.
[out] | DstBuffer | Destination Buffer to copy the data to. |
[in] | MaxDstBufferSize | Maximum size of DstBuffer. Must be non-zero. |
[in] | Stream | Pointer to the stream to copy the data from. |
[in] | Size | Number of bytes to copy from the stream buffer. Must be lower than MaxDstBufferSize. Must be lower than Stream's MaxBufferSize. Return success if zero. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 650 of file AmlStream.c.
UINT8 *EFIAPI AmlStreamGetBuffer | ( | IN CONST AML_STREAM * | Stream | ) |
Get the buffer of a stream.
[in] | Stream | Pointer to a stream. |
Definition at line 146 of file AmlStream.c.
UINT8 *EFIAPI AmlStreamGetCurrPos | ( | IN CONST AML_STREAM * | Stream | ) |
Return a pointer to the current position in the stream.
[in] | Stream | Pointer to a stream. |
Definition at line 264 of file AmlStream.c.
EAML_STREAM_DIRECTION EFIAPI AmlStreamGetDirection | ( | IN CONST AML_STREAM * | Stream | ) |
Get Stream's Direction.
[in] | Stream | Pointer to a stream. |
Definition at line 243 of file AmlStream.c.
UINT32 EFIAPI AmlStreamGetFreeSpace | ( | IN CONST AML_STREAM * | Stream | ) |
Get the space available in the stream.
[in] | Stream | Pointer to a stream. |
Definition at line 292 of file AmlStream.c.
UINT32 EFIAPI AmlStreamGetIndex | ( | IN CONST AML_STREAM * | Stream | ) |
Get Stream's Index.
Stream's Index is incremented when writing data, reading data, or moving the position in the Stream. It can be seen as an index:
[in] | Stream | Pointer to a stream. |
Definition at line 222 of file AmlStream.c.
UINT32 EFIAPI AmlStreamGetMaxBufferSize | ( | IN CONST AML_STREAM * | Stream | ) |
Get the size of Stream's Buffer.
[in] | Stream | Pointer to a stream. |
Definition at line 167 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamInit | ( | IN OUT AML_STREAM * | Stream, |
IN UINT8 * | Buffer, | ||
IN UINT32 | MaxBufferSize, | ||
IN EAML_STREAM_DIRECTION | Direction | ||
) |
Initialize a stream.
[in,out] | Stream | Pointer to the stream to initialize. |
[in] | Buffer | Buffer to initialize Stream with. Point to the beginning of the Buffer. |
[in] | MaxBufferSize | Maximum size of Buffer. |
[in] | Direction | Direction Stream is progressing (forward, backward). |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 25 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamInitSubStream | ( | IN CONST AML_STREAM * | Stream, |
OUT AML_STREAM * | SubStream | ||
) |
Initialize a sub-stream from a stream.
A sub-stream is a stream initialized at the current position of the input stream:
E.g.: For a forward stream: +-------------—+-------------—+ |ABCD.........XYZ| Free Space | +-------------—+-------------—+ ^ ^ ^ Stream: Buffer CurrPos EndOfBuff Sub-stream: Buffer/CurrPos EndOfBuff
[in] | Stream | Pointer to the stream from which a sub-stream is created. |
[in] | SubStream | Pointer to the stream to initialize. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Initialize a sub-stream from a stream.
A sub-stream is a stream initialized at the current position of the input stream:
E.g.: For a forward stream: +-------------—+-------------—+ |ABCD.........XYZ| Free Space | +-------------—+-------------—+ ^ ^ ^ Stream: Buffer CurrPos EndOfBuff Sub-stream: Buffer/CurrPos EndOfBuff
[in] | Stream | Pointer to the stream from which a sub-stream is created. |
[out] | SubStream | Pointer to the stream to initialize. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 109 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamPeekByte | ( | IN AML_STREAM * | Stream, |
OUT UINT8 * | OutByte | ||
) |
Peek one byte at Stream's current position.
Stream's position is not moved when peeking.
[in] | Stream | Pointer to a stream. The stream must not be at its end. |
[out] | OutByte | Pointer holding the byte value of the stream current position. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
Definition at line 421 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamProgress | ( | IN AML_STREAM * | Stream, |
IN UINT32 | Offset | ||
) |
Move Stream by Offset bytes.
The stream current position is moved according to the stream direction (forward, backward).
[in] | Stream | Pointer to a stream. The stream must not be at its end. |
[in] | Offset | Offset to move the stream of. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
Definition at line 324 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamReadByte | ( | IN AML_STREAM * | Stream, |
OUT UINT8 * | OutByte | ||
) |
Read one byte at Stream's current position.
The stream current position is moved when reading.
[in] | Stream | Pointer to a stream. The stream must not be at its end. |
[out] | OutByte | Pointer holding the byte value of the stream current position. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
Definition at line 461 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamReduceMaxBufferSize | ( | IN AML_STREAM * | Stream, |
IN UINT32 | Diff | ||
) |
Reduce the maximal size of Stream's Buffer (MaxBufferSize field).
[in] | Stream | Pointer to a stream. |
[in] | Diff | Value to subtract to the Stream's MaxBufferSize. 0 < x < MaxBufferSize - Index. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 190 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamReset | ( | IN AML_STREAM * | Stream | ) |
Reset the Stream (move the current position to the initial position).
[in] | Stream | Pointer to a stream. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 392 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamRewind | ( | IN AML_STREAM * | Stream, |
IN UINT32 | Offset | ||
) |
Rewind Stream of Offset bytes.
The stream current position is rewound according to the stream direction (forward, backward). A stream going forward will be rewound backward.
[in] | Stream | Pointer to a stream. |
[in] | Offset | Offset to rewind the stream of. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
Definition at line 361 of file AmlStream.c.
EFI_STATUS EFIAPI AmlStreamWrite | ( | IN AML_STREAM * | Stream, |
IN CONST UINT8 * | Buffer, | ||
IN UINT32 | Size | ||
) |
Write Size bytes in the stream.
If the stream goes backward (toward lower addresses), the bytes written to the stream are not reverted. In the example below, writing "Hello" to the stream will not revert the string. The end of the stream buffer will contain "Hello world!". Stream buffer: +------------—+--—+--—+--—+--—+--—+--—+-— +---—+ | ..... | ' ' | 'w' | 'o' | 'r' | 'l' | 'd' | '!' | '\0' | +------------—+--—+--—+--—+--—+--—+--—+-— +---—+ ^ Current position.
[in] | Stream | Pointer to a stream. The stream must not be at its end. |
[in] | Buffer | Pointer to the data to write. |
[in] | Size | Number of bytes to write. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
Definition at line 512 of file AmlStream.c.