diff options
Diffstat (limited to 'drivers/staging/nmf-cm/cm/engine/utils/inc')
-rw-r--r-- | drivers/staging/nmf-cm/cm/engine/utils/inc/convert.h | 21 | ||||
-rw-r--r-- | drivers/staging/nmf-cm/cm/engine/utils/inc/mem.h | 19 | ||||
-rw-r--r-- | drivers/staging/nmf-cm/cm/engine/utils/inc/string.h | 33 | ||||
-rw-r--r-- | drivers/staging/nmf-cm/cm/engine/utils/inc/swap.h | 23 | ||||
-rw-r--r-- | drivers/staging/nmf-cm/cm/engine/utils/inc/table.h | 59 |
5 files changed, 155 insertions, 0 deletions
diff --git a/drivers/staging/nmf-cm/cm/engine/utils/inc/convert.h b/drivers/staging/nmf-cm/cm/engine/utils/inc/convert.h new file mode 100644 index 00000000000..d6912e58687 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/utils/inc/convert.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) ST-Ericsson SA 2010 + * Author: Jean-Philippe FASSINO <jean-philippe.fassino@stericsson.com> for ST-Ericsson. + * License terms: GNU General Public License (GPL) version 2. + */ +/*! + * \internal + * \brief Conversion utility methods. + */ +#ifndef H_CM_CONVERTS_MEM +#define H_CM_CONVERTS_MEM + +#include <share/inc/nmf.h> + +/* + * Utils convert methods + */ +const char* cm_getDspName(t_nmf_core_id dsp); + + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/utils/inc/mem.h b/drivers/staging/nmf-cm/cm/engine/utils/inc/mem.h new file mode 100644 index 00000000000..c950a94023d --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/utils/inc/mem.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) ST-Ericsson SA 2010 + * Author: Jean-Philippe FASSINO <jean-philippe.fassino@stericsson.com> for ST-Ericsson. + * License terms: GNU General Public License (GPL) version 2. + */ +/*! + * \internal + * \brief Memory manipulation. + */ +#ifndef H_CM_UTILS_MEM +#define H_CM_UTILS_MEM + +/* + * Utils libc methods + */ +void cm_MemCopy(void* dest, const void *src, int count); +void cm_MemSet(void *str, int c, int count); + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/utils/inc/string.h b/drivers/staging/nmf-cm/cm/engine/utils/inc/string.h new file mode 100644 index 00000000000..d2b7c0b0823 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/utils/inc/string.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) ST-Ericsson SA 2010 + * Author: Jean-Philippe FASSINO <jean-philippe.fassino@stericsson.com> for ST-Ericsson. + * License terms: GNU General Public License (GPL) version 2. + */ +/*! + * \internal + * \brief String manipulation. + */ +#ifndef H_CM_UTILS_STRING +#define H_CM_UTILS_STRING + +#include <cm/engine/memory/inc/memory.h> + +#define MAX_INTERNAL_STRING_LENGTH 2048 + +typedef const char *t_dup_char; + +t_dup_char cm_StringGet(const char* str); +t_dup_char cm_StringReference(t_dup_char str); +t_dup_char cm_StringDuplicate(const char* orig); +void cm_StringRelease(t_dup_char orig); + +/* + * Utils libc methods + */ +void cm_StringCopy(char* dest, const char* src, int count); +int cm_StringCompare(const char* str1, const char* str2, int count); +int cm_StringLength(const char * str, int count); +void cm_StringConcatenate(char* dest, const char* src, int count); +char* cm_StringSearch(const char* str, int c); + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/utils/inc/swap.h b/drivers/staging/nmf-cm/cm/engine/utils/inc/swap.h new file mode 100644 index 00000000000..e4f5acb3010 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/utils/inc/swap.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) ST-Ericsson SA 2010 + * Author: Jean-Philippe FASSINO <jean-philippe.fassino@stericsson.com> for ST-Ericsson. + * License terms: GNU General Public License (GPL) version 2. + */ +/*! + * \internal + * \brief Swap integer manipulation. + */ +#ifndef H_CM_UTILS_SWAP +#define H_CM_UTILS_SWAP + +#include <cm/inc/cm_type.h> + +/* + * Swap methods + */ +t_uint16 swap16(t_uint16 x); +t_uint32 swap32(t_uint32 x); +t_uint64 swap64(t_uint64 x); +t_uint32 noswap32(t_uint32 x); + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/utils/inc/table.h b/drivers/staging/nmf-cm/cm/engine/utils/inc/table.h new file mode 100644 index 00000000000..9d9828a81f6 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/utils/inc/table.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) ST-Ericsson SA 2010 + * Author: Jean-Philippe FASSINO <jean-philippe.fassino@stericsson.com> for ST-Ericsson. + * License terms: GNU General Public License (GPL) version 2. + */ +/*! + * \internal + * \brief Dynamic table manipulation. + */ +#ifndef H_CM_UTILS_TABLE +#define H_CM_UTILS_TABLE + +#include <cm/inc/cm_type.h> + +/* + This implement a (generic) dynamic table (the size is dynamic) + to register some pointers of a given kind of elements + + It also allows to compute/convert each kernel pointer registered in the + table to a user handler, that can be checked. + + The "user" handler is composed by the index in this table + (the low INDEX_SHIFT bits) and the low bits of the "local" pointer + shifted by INDEX_SHIFT are stored in the high bits: + + handle bits: 31 ................................ 12 11 ...... 0 + | lower bits of of the local pointer | index | + + This allows a straight translation from a user handle to a local pointer + + a strong check to validate the value of a user handle. + The reverse translation from pointer to a user handle is + slower as it requires an explicit search in the list. + */ + + +/* INDEX_SHIFT determines the index size and thus the max index */ +#define INDEX_SHIFT 12 +#define INDEX_MAX (1UL << INDEX_SHIFT) +#define INDEX_MASK (INDEX_MAX-1) +#define ENTRY2HANDLE(pointer, index) (((unsigned int)pointer << INDEX_SHIFT) | index) +#define TABLE_DEF_SIZE 0x1000 + +typedef struct { + t_uint32 idxNb; /**< number of entries used */ + t_uint32 idxCur; /**< current index: point to next supposed + free entry: used to look for the next + free entry */ + t_uint32 idxMax; /**< index max currently allowed */ + void **entries; /**< table itself */ +} t_nmf_table; + +t_cm_error cm_initTable(t_nmf_table* table); +void cm_destroyTable(t_nmf_table* table); +t_uint32 cm_addEntry(t_nmf_table *table, void *entry); +void cm_delEntry(t_nmf_table *table, t_uint32 idx); +void *cm_lookupEntry(const t_nmf_table *table, const t_uint32 hdl); +t_uint32 cm_lookupHandle(const t_nmf_table *table, const void *entry); + +#endif |