#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <hardware/context.h>
Go to the source code of this file.
|
uint32_t | stringLength (const char *str) |
| Returns the length of a nullterminated string. More...
|
|
bool | stringIsEqual (const char *str, const char *buf, uint32_t len) |
| Checks if the string is equal to the memory region. More...
|
|
uint32_t | stringParseOctal (const char *str, uint32_t len) |
| Converts an octal string to a integer number. More...
|
|
void * | memset (void *ptr, int value, size_t num) |
| Fills a memory region with some specific byte value. More...
|
|
void * | memcpy (void *destination, const void *source, size_t num) |
| Copies a block of memory from source to destination. More...
|
|
void * | memmove (void *destination, const void *source, size_t num) |
| Moves a block of memory from source to destination. More...
|
|
void | debugCaptureCpuContext (struct taskContext *context) |
|
void | debugAssertFailed (const char *assertion, const char *file, const char *function, const char *line, struct taskContext *context) |
| Used internally to implement assert() More...
|
|
void | debugNotImplemented (const char *file, const char *function, const char *line, struct taskContext *context) |
| Used internally to implement NOTIMPLEMENTED() More...
|
|
void | debugHalt () |
|
◆ _STRINGIZE
◆ _STRINGIZE_DETAIL
#define _STRINGIZE_DETAIL |
( |
|
x | ) |
#x |
◆ assert
Value:do \
{ \
if ((ex)) break; \
debugCaptureCpuContext(&__context); \
debugAssertFailed(#ex, __FILE__, __FUNCTION__,
_STRINGIZE(__LINE__), &__context); \
} \
while(1)
Definition at line 61 of file util.h.
◆ NOTIMPLEMENTED
#define NOTIMPLEMENTED |
( |
| ) |
|
Value:do \
{ \
debugCaptureCpuContext(&__context); \
debugNotImplemented(__FILE__, __FUNCTION__,
_STRINGIZE(__LINE__), &__context); \
} \
while(1)
Definition at line 82 of file util.h.
◆ SYSTEM_FAILURE
#define SYSTEM_FAILURE |
( |
|
lines, |
|
|
|
... |
|
) |
| |
Value:do \
{ \
uint32_t __args[] = {__VA_ARGS__}; \
memset(&__context, 0xFF, sizeof(__context)); \
debugCaptureCpuContext(&__context); \
consoleSystemFailure((lines), sizeof(__args)/sizeof(__args[0]), __args, &__context); \
} \
while(1)
Definition at line 71 of file util.h.
◆ UNUSED
◆ debugAssertFailed()
void debugAssertFailed |
( |
const char * |
assertion, |
|
|
const char * |
file, |
|
|
const char * |
function, |
|
|
const char * |
line, |
|
|
struct taskContext * |
context |
|
) |
| |
Used internally to implement assert()
This function shows an assertion message. Normally it shouldn't be necessary to call this function manually, all values will automatically be filled out by using the assert() macro from util.h.
- Parameters
-
assertion | String containing the condition which failed |
file | File in which the assertion occured |
function | Function in which the assertion occured |
line | String representing the line number, where the assertion occured |
context | Task context structure containing the CPU registers after the error occured |
Definition at line 228 of file util.c.
◆ debugCaptureCpuContext()
void debugCaptureCpuContext |
( |
struct taskContext * |
context | ) |
|
◆ debugHalt()
◆ debugNotImplemented()
void debugNotImplemented |
( |
const char * |
file, |
|
|
const char * |
function, |
|
|
const char * |
line, |
|
|
struct taskContext * |
context |
|
) |
| |
Used internally to implement NOTIMPLEMENTED()
- Parameters
-
file | File in which the feature is missing |
function | Function in which the assertion occured |
line | String representing the line number, where the assertion occured |
context | Task context structure containing the CPU registers |
Definition at line 251 of file util.c.
◆ memcpy()
void* memcpy |
( |
void * |
destination, |
|
|
const void * |
source, |
|
|
size_t |
num |
|
) |
| |
Copies a block of memory from source to destination.
The source and destination blocks shouldn't be overlapping, otherwise it is not safe to call this function. If the regions could be overlapping please use memmove() instead.
- Parameters
-
destination | Pointer to the destination memory region |
source | Pointer to the source memory region |
num | Length of the memory region to copy, in bytes |
- Returns
- destination
Definition at line 141 of file util.c.
◆ memmove()
void* memmove |
( |
void * |
destination, |
|
|
const void * |
source, |
|
|
size_t |
num |
|
) |
| |
Moves a block of memory from source to destination.
Similar to memcpy(), but will also work safely if both source and destination regions are overlapping.
- Parameters
-
destination | Pointer to the destination memory region |
source | Pointer to the source memory region |
num | Length of the memory region to copy, in bytes |
- Returns
- destination
Definition at line 159 of file util.c.
◆ memset()
void* memset |
( |
void * |
ptr, |
|
|
int |
value, |
|
|
size_t |
num |
|
) |
| |
Fills a memory region with some specific byte value.
- Parameters
-
ptr | Pointer to the start of the memory region |
value | Value used to fill the memory region |
num | Length of the memory region in bytes |
- Returns
- ptr
Definition at line 123 of file util.c.
◆ stringIsEqual()
bool stringIsEqual |
( |
const char * |
str, |
|
|
const char * |
buf, |
|
|
uint32_t |
len |
|
) |
| |
Checks if the string is equal to the memory region.
- Parameters
-
str | Pointer to the nullterminated string |
buf | Pointer to a buffer |
len | Length of the buffer |
- Returns
- True if both strings are equal, otherwise false
Definition at line 57 of file util.c.
◆ stringLength()
uint32_t stringLength |
( |
const char * |
str | ) |
|
Returns the length of a nullterminated string.
- Parameters
-
str | Pointer to the nullterminated string |
- Returns
- Length in characters (not including the terminating null character)
Definition at line 37 of file util.c.
◆ stringParseOctal()
uint32_t stringParseOctal |
( |
const char * |
str, |
|
|
uint32_t |
len |
|
) |
| |
Converts an octal string to a integer number.
- Parameters
-
str | Pointer to a string |
len | Length of the buffer |
- Returns
- Parsed integer number
Definition at line 84 of file util.c.