diff options
Diffstat (limited to 'drivers/staging/nmf-cm/cm/engine/component/inc')
9 files changed, 1268 insertions, 0 deletions
diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/bind.h b/drivers/staging/nmf-cm/cm/engine/component/inc/bind.h new file mode 100644 index 00000000000..325703e3367 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/bind.h @@ -0,0 +1,443 @@ +/* + * 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 Binding Factories internal API. + * + * \defgroup BF_COMMON Binding factories: Common API + * \defgroup BF_PRIMITIVE Binding Factories: Primitive API + * \defgroup BF_TRACE Binding Factories: Trace API + * \defgroup BF_ASYNCHRONOUS Binding Factories: Asynchronous API + * \defgroup BF_DISTRIBUTED Binding Factories: Distributed API + */ +#ifndef __INC_CM_BIND_H +#define __INC_CM_BIND_H + +#include <cm/engine/component/inc/introspection.h> +#include <cm/engine/communication/inc/communication.h> +#include <cm/engine/utils/inc/table.h> + +/** + * \internal + * \ingroup BF_COMMON + * + * \brief Identification number of prefedined Binding Factories + */ +typedef enum { + BF_SYNCHRONOUS, //!< Intra-DSP Synchronous Binding Factory Identifier + BF_TRACE, //!< Intra-DSP trace synchronous Binding Factory Identifier + BF_ASYNCHRONOUS, //!< Intra-DSP Asynchronous Binding Factory Identifier + BF_DSP2HOST, //!< DSP to Host Binding Factory Identifier + BF_HOST2DSP, //!< Host to DSP Binding Factory Identifier + BF_DSP2DSP, //!< DSP to DSP Binding Factory Identifier +} t_bf_info_ID; + +/*! + * \internal + * \brief Description of a provided interface + * + * \ingroup COMPONENT_INTERNAL + */ +typedef struct _t_interface_reference { + const t_component_instance *instance; //!< Component instance that provide this interface + t_uint8 provideIndex; //!< Index of the interface in the provide array + t_uint8 collectionIndex;//!< Index in the collection if provided interface is a collection + t_bf_info_ID bfInfoID; //!< Identification of BF used for creating binding + void* bfInfo; //!< Storage of the binding factory info +} t_interface_reference; + +/** + * \internal + * \ingroup BF_COMMON + * + * Make some basic sanity check for a client: + * - component stopped + * - Interface really required + * + * \param[in] client The client component instance handle. + * \param[in] requiredItfClientName The client required interface name + * \param[out] requiredItf return the required interface (avoid user searching) + */ +t_cm_error cm_checkValidClient( + const t_component_instance* client, + const char* requiredItfClientName, + t_interface_require_description *itfRequire, + t_bool *bindable); +/** + * \internal + * \ingroup BF_COMMON + * + * Make some basic sanity check for a server: + * - Interface really provided + * + * \param[in] server The server component instance handle. + * \param[in] providedItfServerName The server provided interface name + * \param[out] itf return the provided interface (avoid user searching) + */ +t_cm_error cm_checkValidServer( + const t_component_instance* server, + const char* providedItfServerName, + t_interface_provide_description *itfProvide); + +/** + * \internal + * \ingroup BF_COMMON + * + * Make some basic sanity check for a binding: + * - Sanity check for a server + * - Sanity check for a client (and potentially wait initialisation) + * - Provided and required interface matches + * + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + * \param[in] server The server component instance handle + * \param[in] providedItfServerName The server provided interface name + * \param[out] requiredItf return the required interface (avoid user searching) + * \param[out] itf return the provided interface (avoid user searching) + */ +t_cm_error cm_checkValidBinding( + const t_component_instance* client, + const char* requiredItfClientName, + const t_component_instance* server, + const char* requiredItfServerName, + t_interface_require_description *itfRequire, + t_interface_provide_description *itfProvide, + t_bool *bindable); + +/** + * \internal + * \ingroup BF_COMMON + * + * Make some basic sanity check for each unbinding: + * - Interface really required + * - Component stopped + * + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + * \param[out] itfRequire return the previously binded required interface (avoid user searching) + * \param[out] itfProvide return the previously binded provided interface (avoid user searching) + * \param[out] bfInfoID return the binding factory identifiant which done the previously bind + * \param[out] bfInfo return the binding factory information which done the previously bind + */ +t_cm_error cm_checkValidUnbinding( + const t_component_instance* client, + const char* requiredItfClientName, + t_interface_require_description *itfRequire, + t_interface_provide_description *itfProvide); + +/** + * \internal + * \ingroup BF_PRIMITIVE + * + * Create a primitive binding between a client to a server interface. + * + * \param[in] itfRequire The client required interface description + * \param[in] itfProvide The server provided interface description + */ +t_cm_error cm_bindInterface( + const t_interface_require_description *itfRequire, + const t_interface_provide_description *itfProvide); + +/** + * \internal + * \ingroup BF_PRIMITIVE + * + * Unbind a previously binded client. + * + * \param[in] itfRequire The client required interafce description + */ +void cm_unbindInterface( + const t_interface_require_description *itfRequire); + +/** + * \internal + * \ingroup BF_PRIMITIVE + * + * Get a server interface previouly binded to a client + * + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + * \param[out] itf The server interface + */ +t_cm_error cm_lookupInterface( + const t_interface_require_description *itfRequire, + t_interface_provide_description *itfProvide); + +/** + * \internal + * \ingroup BF_PRIMITIVE + * + * Create a void binding. + * + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + */ +t_cm_error cm_bindInterfaceToVoid( + const t_interface_require_description *itfRequire); + +/** + * \internal + * \ingroup BF_TRACE + * + * Trace synchronous binding factory Information + */ +typedef struct { + t_component_instance *traceInstance; //!< Trace binding component instance +} t_trace_bf_info; + +/** + * \internal + * \ingroup BF_TRACE + * + * Create a traced binding between a client to a server interface. + * + * \param[in] itfRequire The client required interface description + * \param[in] itfProvide The server provided interface description + */ +t_cm_error cm_bindInterfaceTrace( + const t_interface_require_description *itfRequire, + const t_interface_provide_description *itfProvide, + t_elfdescription *elfhandleTrace); + +/** + * \internal + * \ingroup BF_TRACE + * + * Unbind a previously binded client. + * + * \param[in] itfRequire The client required interafce description + */ +void cm_unbindInterfaceTrace( + const t_interface_require_description *itfRequire, + t_trace_bf_info *bfInfo); + + +/** + * \internal + * \ingroup BF_ASYNCHRONOUS + * + * Asynchronous binding factory Information + */ +typedef struct { + t_component_instance *eventInstance; //!< Event binding component instance + t_memory_handle dspfifoHandle; //!< Memory handle of allocated event fifo (pass to the event binding component) +} t_async_bf_info; + +/** + * \internal + * \ingroup BF_ASYNCHRONOUS + * + * Create a asynchronous binding between a client to a server interface. + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + * \param[in] itf The server interface + * \param[in] fifosize Number of waited event in the fifo + */ +t_cm_error cm_bindInterfaceAsynchronous( + const t_interface_require_description *itfRequire, + const t_interface_provide_description *itfProvide, + t_uint32 fifosize, + t_dsp_memory_type_id dspEventMemType, + t_elfdescription *elfhandleEvent); +/** + * \internal + * \ingroup BF_ASYNCHRONOUS + * + * Destroy a asynchronous binding between a client to a server interface. + * \param[in] itfRequire the required interface + */ +void cm_unbindInterfaceAsynchronous( + const t_interface_require_description *itfRequire, + t_async_bf_info *bfInfo); + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Stub information in distributed binding factory (client side) + */ +typedef struct { + t_component_instance *stubInstance; //!< Stub +} t_dspstub_bf_info; + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Skeleton information in distributed binding factory (server side) + */ +typedef struct { + t_component_instance *skelInstance; //!< Skeleton binding component instance + t_memory_handle dspfifoHandle; //!< Memory handle of allocated event fifo (pass to the event binding component) +} t_dspskel_bf_info; + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Host to DSP distributed binding factory Information + */ +typedef struct { + t_dspskel_bf_info dspskeleton; //!< Information about the DSP skeleton (server side) + t_nmf_fifo_arm_desc* fifo; //!< Handle of the fifo params + t_nmf_client_id clientId; //!< Client ID of the host client +} t_host2mpc_bf_info; + +/* + * Table of instantiated of host2mpc bindings + */ +extern t_nmf_table Host2MpcBindingTable; /**< list (table) of host2mpc bindings */ + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Create a Host to DSP distributed binding between a host client interface to a server interface. + * (Not manage in the same way as distributed binding since the Host programming model is not component aware). + * \param[in] itfServer The server interface + * \param[in] fifosize Number of waited event in the fifo + * \param[in] dspEventMemType The type of memory to use + * \param[in] bfInfo info structure + */ +t_cm_error cm_bindComponentFromCMCore( + const t_interface_provide_description *itfProvide, + t_uint32 fifosize, + t_dsp_memory_type_id dspEventMemType, + t_elfdescription *elfhandleSkeleton, + t_host2mpc_bf_info **bfInfo); + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Destroy a Host to DSP distributed binding between a host client interface to a server interface. + * \param[in] bfInfo The Host to DSP distributed binding factory information + */ +void cm_unbindComponentFromCMCore( + t_host2mpc_bf_info *bfInfo); + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * DSP to Host distributed binding factory Information + */ +typedef struct { + t_dspstub_bf_info dspstub; //!< Information about the DSP stub (client side) + t_nmf_fifo_arm_desc* fifo; //!< Handle of the fifo params + t_uint32 context; +} t_mpc2host_bf_info; + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Create a DSP to Host distributed binding between a client interface to a host server interface. + * (Not manage in the same way as distributed binding since the Host programming model is not component aware). + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + * \param[in] itfref The host server interface to be called + * \param[in] fifosize Number of waited event in the fifo + */ +t_cm_error cm_bindComponentToCMCore( + const t_interface_require_description *itfRequire, + t_uint32 fifosize, + t_uint32 context, + t_elfdescription *elfhandleStub, + t_mpc2host_bf_info ** bfInfo); + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Destroy a DSP to Host distributed binding between a client interface to a server interface. + * \param[in] itfRequire The required interface + * \param[out] upLayerThis The 'THIS' context of upper layer + */ +void cm_unbindComponentToCMCore( + const t_interface_require_description *itfRequire, + t_mpc2host_bf_info *bfInfo); + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Asynchronous distributed binding factory Information + */ +typedef struct { + t_nmf_fifo_arm_desc* fifo; //!< Handle of the fifo params + t_dspstub_bf_info dspstub; //!< Information about the DSP stub (client side) + t_dspskel_bf_info dspskeleton; //!< Information about the DSP skeleton (server side) +} t_mpc2mpc_bf_info; + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Create a asynchronous distributed binding between a client interface to a server interface. + * \param[in] client The client component instance handle + * \param[in] requiredItfClientName The client required interface name + * \param[in] itf The server interface + * \param[in] fifosize Number of waited event in the fifo + */ +t_cm_error cm_bindInterfaceDistributed( + const t_interface_require_description *itfRequire, + const t_interface_provide_description *itfProvide, + t_uint32 fifosize, + t_dsp_memory_type_id dspEventMemType, + t_elfdescription *elfhandleSkeleton, + t_elfdescription *elfhandleStub); + +/** + * \internal + * \ingroup BF_DISTRIBUTED + * + * Destroy a asynchronous distributed binding between a client interface to a server interface. + * \param[in] itfRequire The required interface + */ +void cm_unbindInterfaceDistributed( + const t_interface_require_description *itfRequire, + t_mpc2mpc_bf_info *bfInfo); + +/** + * \internal + * + * Bind a static interrupt to server provide interface name. + * \param[in] coreId The core to which component is loaded + * \param[in] interruptLine Interrupt line number to use + * \param[in] server Server instance that provide interrupt service + * \param[in] providedItfServerName Interface name hat provide interrupt service + */ +t_cm_error cm_bindInterfaceStaticInterrupt( + const t_nmf_core_id coreId, + const int interruptLine, + const t_component_instance *server, + const char* providedItfServerName); + +/** + * \internal + * + * Unbind a static interrupt. + * \param[in] coreId The core to which component is loaded + * \param[in] interruptLine Interrupt line number to use + */ +t_cm_error cm_unbindInterfaceStaticInterrupt( + const t_nmf_core_id coreId, + const int interruptLine); + +void cm_destroyRequireInterface(t_component_instance* component, t_nmf_client_id clientId); +void cm_registerSingletonBinding( + t_component_instance* component, + t_interface_require_description* itfRequire, + t_interface_provide_description* itfProvide, + t_nmf_client_id clientId); +t_bool cm_unregisterSingletonBinding( + t_component_instance* component, + t_interface_require_description* itfRequire, + t_interface_provide_description* itfProvide, + t_nmf_client_id clientId); + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/component_type.h b/drivers/staging/nmf-cm/cm/engine/component/inc/component_type.h new file mode 100644 index 00000000000..2e769ec8b22 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/component_type.h @@ -0,0 +1,64 @@ +/* + * 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, with + * user space exemption described in the top-level COPYING file in + * the Linux kernel source tree. + */ +/*! + * \brief Components Component Manager API type. + * + * \defgroup COMPONENT CM Components API + * \ingroup CM_USER_API + */ + +#ifndef COMPONENT_TYPE_H_ +#define COMPONENT_TYPE_H_ + +#include <cm/inc/cm_type.h> +#include <nmf/inc/component_type.h> + +/*! + * @defgroup t_nmf_ee_priority t_nmf_ee_priority + * \brief Identification of the execution engine priority and sub priority. + * @{ + * \ingroup COMPONENT + */ +typedef t_uint32 t_nmf_ee_priority; //!< Fake enumeration type + +#define NMF_SCHED_BACKGROUND ((t_nmf_ee_priority)0) //!< Background priority +#define NMF_SCHED_NORMAL ((t_nmf_ee_priority)1) //!< Normal priority +#define NMF_SCHED_URGENT ((t_nmf_ee_priority)2) //!< Urgent priority +/* @} */ + + +/*! + * \brief Identification of host component returned during introspection + * + * \ingroup COMPONENT_INTROSPECTION + */ +#define NMF_HOST_COMPONENT ((t_cm_instance_handle)0xFFFFFFFF) + +/*! + * \brief Identification of void component returned during introspection + * + * \ingroup COMPONENT_INTROSPECTION + */ +#define NMF_VOID_COMPONENT ((t_cm_instance_handle)0xFFFFFFFE) + + +/*! + * @defgroup t_nmf_ee_priority t_nmf_ee_priority + * \brief Identification of the execution engine priority and sub priority. + * @{ + * \ingroup COMPONENT + */ +typedef t_uint8 t_cm_require_state; //!< Fake enumeration type + +#define CM_REQUIRE_STATIC ((t_cm_require_state)0) //!< Required interface is static +#define CM_REQUIRE_OPTIONAL ((t_cm_require_state)1) //!< Required interface is optional +#define CM_REQUIRE_COLLECTION ((t_cm_require_state)2) //!< Required interface is a collection + +/* @} */ + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/description.h b/drivers/staging/nmf-cm/cm/engine/component/inc/description.h new file mode 100644 index 00000000000..882dc1ea873 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/description.h @@ -0,0 +1,108 @@ +/* + * 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. + */ +#ifndef __INC_CM_COMPONENT_DESCRIPTION_H +#define __INC_CM_COMPONENT_DESCRIPTION_H + +#include <cm/engine/elf/inc/memory.h> +#include <cm/engine/utils/inc/string.h> + +#include <inc/nmf-limits.h> + +/*! + * \internal + * \brief Description of an interface + * \ingroup COMPONENT_INTERNAL + */ +typedef struct _t_interface_description { + t_dup_char type; //!< Type of the interface + t_uint16 referenceCounter; //!< Number of template referencing the interface + t_uint8 methodNumber; //!< Number of method in the interfaces + struct _t_interface_description* next; + t_dup_char methodNames[1]; //!< Array of method names +} t_interface_description; + +/*! + * \internal + * \brief Description of a variable memory on a collection index + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_uint32 offset; //!< Offset in the memory + const t_elfmemory *memory; //!< Memory +} t_memory_reference; + +/*! + * \internal + * \brief Description of a required interface on a collection index + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_uint32 numberOfClient; //!< Number of interface descriptor really connected to this interface + t_memory_reference *memories; /*!< Memory where each interface reference descriptor resides + \note memories[numberOfClient] */ +} t_interface_require_index; + +/*! + * \internal + * \brief Description of a required interface + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_dup_char name; //!< Name of the interface + t_interface_description *interface; //!< Description of the interface + t_uint8 requireTypes; //!< Mask of t_elf_interface_require_type + t_uint8 collectionSize; //!< Size of the collection (1 if not a collection) + t_interface_require_index *indexes; /*!< Require information for each collection index + \note indexes[collectionSize] */ +} t_interface_require; + +/*! + * \internal + * \brief Description of a provided interface method on a collection index + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_memory_reference memory; //!< Memory of the method +} t_interface_provide_index; + +/*! + * \internal + * \brief Description of a provided interface + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_dup_char name; //!< Name of the interface + t_interface_description *interface; //!< Description of the interface + t_uint8 provideTypes; //!< Mask of t_elf_interface_provide_type + t_uint8 interruptLine; //!< Interrupt line if interrupt (0 if not) + t_uint8 collectionSize; //!< Size of the collection (1 if not a collection) + t_interface_provide_index **indexes; //!< Provide information for each collection index +} t_interface_provide; + +/*! + * \internal + * \brief Description of a attribute + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_dup_char name; //!< Name of the attribute + t_memory_reference memory; //!< Memory where the attribute reside +} t_attribute; + +/*! + * \internal + * \brief Description of a property + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_dup_char name; //!< Name of this attribute + t_dup_char value; //!< String of the value +} t_property; + + + + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/dspevent.h b/drivers/staging/nmf-cm/cm/engine/component/inc/dspevent.h new file mode 100644 index 00000000000..bb47363c0ae --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/dspevent.h @@ -0,0 +1,28 @@ +/* + * 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 + */ +#ifndef __INC_DSP_EVENT +#define __INC_DSP_EVENT + +#include <cm/inc/cm_type.h> +#include <cm/engine/component/inc/instance.h> +#include <cm/engine/memory/inc/memory.h> + +/* value should be size of t_remote_event in mmdsp word */ +#define DSP_REMOTE_EVENT_SIZE_IN_DSPWORD 5 + +t_cm_error dspevent_createDspEventFifo( + const t_component_instance *pComp, + const char* nameOfTOP, + t_uint32 fifoNbElem, + t_uint32 fifoElemSizeInWord, + t_dsp_memory_type_id dspEventMemType, + t_memory_handle *pHandle); +void dspevent_destroyDspEventFifo(t_memory_handle handle); + +#endif /* __INC_DSP_EVENT */ diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/initializer.h b/drivers/staging/nmf-cm/cm/engine/component/inc/initializer.h new file mode 100644 index 00000000000..5ac9ec453b7 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/initializer.h @@ -0,0 +1,30 @@ +/* + * 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 + */ +#ifndef __INC_NMF_INITIALIZER +#define __INC_NMF_INITIALIZER + +#include <cm/inc/cm_type.h> +#include <cm/engine/component/inc/instance.h> +#include <share/communication/inc/initializer.h> + +PUBLIC t_cm_error cm_COMP_INIT_Init(t_nmf_core_id coreId); +PUBLIC t_cm_error cm_COMP_CallService(int serviceIndex, t_component_instance *pComp, t_uint32 methodAddress); +PUBLIC void cm_COMP_Flush(t_nmf_core_id coreId); +PUBLIC void cm_COMP_INIT_Close(t_nmf_core_id coreId); +PUBLIC t_cm_error cm_COMP_UpdateStack(t_nmf_core_id coreId, t_uint32 stackSize); +PUBLIC t_cm_error cm_COMP_ULPForceWakeup(t_nmf_core_id coreId); +PUBLIC t_cm_error cm_COMP_ULPAllowSleep(t_nmf_core_id coreId); +PUBLIC t_cm_error cm_COMP_InstructionCacheLock(t_nmf_core_id coreId, t_uint32 mmdspAddr, t_uint32 mmdspSize); +PUBLIC t_cm_error cm_COMP_InstructionCacheUnlock(t_nmf_core_id coreId, t_uint32 mmdspAddr, t_uint32 mmdspSize); + + +PUBLIC void processAsyncAcknowledge(t_nmf_core_id coreId, t_event_params_handle pParam); +PUBLIC void processSyncAcknowledge(t_nmf_core_id coreId, t_event_params_handle pParam); + +#endif /* __INC_NMF_INITIALIZER */ diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/instance.h b/drivers/staging/nmf-cm/cm/engine/component/inc/instance.h new file mode 100644 index 00000000000..0a7d80e2e02 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/instance.h @@ -0,0 +1,222 @@ +/* + * 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 Components Management internal methods - Instance API. + * + */ +#ifndef __INC_CM_INSTANCE_H +#define __INC_CM_INSTANCE_H + +#include <cm/engine/component/inc/template.h> +#include <cm/engine/repository_mgt/inc/repository_mgt.h> +#include <cm/engine/memory/inc/domain.h> +#include <cm/engine/utils/inc/table.h> +#include <cm/engine/utils/inc/string.h> + +/*---------------------------------------------------------------------------- + * Component Instance API. + *----------------------------------------------------------------------------*/ +struct _t_interface_reference; + +/*! + * \internal + * \brief Component life cycle state + * + * \ingroup COMPONENT_INTERNAL + */ +typedef enum { + STATE_NONE, + STATE_STOPPED, + STATE_RUNNABLE, + // STATE_DESTROYED identified when component remove from component list +} t_component_state; + +struct t_client_of_singleton +{ + struct t_client_of_singleton *next; + t_nmf_client_id clientId; + t_uint16 numberOfInstance; + t_uint16 numberOfStart; + t_uint16 numberOfBind; +}; + +/*! + * \internal + * \brief Description of a component instance + * + * \ingroup COMPONENT_INTERNAL + */ +typedef struct t_component_instance { + t_dup_char pathname; //!< Path Name of this component in the components architecture + + t_component_state state; //!< Component state + t_nmf_ee_priority priority; //!< Executive engine component priority + t_component_template *Template; //!< Component template + + t_uint32 thisAddress; //!< Cached value of cm_DSP_GetDspAddress(component->memories[data], &thisAddress); + + t_memory_handle memories[NUMBER_OF_MMDSP_MEMORY]; //!<Reference in different memory where datas are (YES, we fix implementation to MMDSP) + + struct _t_interface_reference **interfaceReferences; /*!< Interface references + (Share same index as template->u.p.requires) + type == targets[interface_index][collection_index] */ + + t_uint16 providedItfUsedCount; //!< Use count to reference the number of components binded to this once, ie count the number of provided interfaces in use + t_cm_instance_handle instance; //!< index of this component within the ComponentTable + t_cm_domain_id domainId; //!< Domain where the component has been installed + + struct t_client_of_singleton *clientOfSingleton; //!< Client of singleton list + t_memory_handle loadMapHandle; // handle of allocated memory for the loadMap structure and name; + void *dbgCooky; //!< pointer to OS internal data +} t_component_instance; + +t_component_template* cm_lookupTemplate(t_nmf_core_id dspId, t_dup_char str); + +/*! + * \internal + * \brief Load a component template. + * + * ... + * + * \param[in] templateName name of the template to load + * \param[in] coreId DSP where template must be loaded + * \praem[in] pRepComponent Pointer to the component entry stored in the Component Cache Repository + * \param[in, out] template reference to put the loaded template (null if first instance) + * + * \exception CM_COMPONENT_NOT_FOUND + * \exception CM_NO_MORE_MEMORY + * + * \return exception number. + * + * \warning For Component manager use only. + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_loadComponent( + t_dup_char templateName, + t_cm_domain_id domainId, + t_elfdescription* elfhandle, + t_component_template **reftemplate); + +/*! + * \internal + * \brief Unload a component template. + * + * ... + * + * \param[in] template template to be unloaded + * \praem[in] Private memories that has been created from component binary file + * + * \return exception number. + * + * \warning For Component manager use only. + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_unloadComponent( + t_component_template *reftemplate); + +/*! + * \internal + * \brief Instantiate a component. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_instantiateComponent(const char* templateName, + t_cm_domain_id domainId, + t_nmf_ee_priority priority, + const char* pathName, + t_elfdescription *elfhandle, + t_component_instance** refcomponent); + +struct t_client_of_singleton* cm_getClientOfSingleton(t_component_instance* component, t_bool createdIfNotExist, t_nmf_client_id clientId); + +/*! + * \internal + * \brief Start a component. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_startComponent(t_component_instance* component, t_nmf_client_id clientId); + +/*! + * \internal + * \brief Stop a component. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_stopComponent(t_component_instance* component, t_nmf_client_id clientId); + +/*! + * \internal + */ +typedef enum { + DESTROY_NORMAL, + DESTROY_WITHOUT_CHECK, + DESTROY_WITHOUT_CHECK_CALL +} t_destroy_state; + +/*! + * \internal + * \brief Destroy a component instance. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_destroyInstance(t_component_instance* component, t_destroy_state forceDestroy); + +/*! + * \internal + * \brief Destroy a component instance. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_destroyInstanceForClient(t_component_instance* component, t_destroy_state forceDestroy, t_nmf_client_id clientId); + +/*! + * \internal + * \brief + * + * \ingroup COMPONENT_INTERNAL + */ +void cm_delayedDestroyComponent(t_component_instance *component); + +/*! + * \internal + * \brief + * + * \ingroup COMPONENT_INTERNAL + */ +t_component_instance *cm_lookupComponent(const t_cm_instance_handle hdl); + +/*! + * \internal + * \brief + * + * \ingroup COMPONENT_INTERNAL + */ +t_bool cm_isComponentOnCoreId(t_nmf_core_id coreId); + +/*! + * \internal + * \brief + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_COMP_Init(void); + +/*! + * \internal + * \brief + * + * \ingroup COMPONENT_INTERNAL + */ +void cm_COMP_Destroy(void); + +/* + * Table of instantiated components. + */ +extern t_nmf_table ComponentTable; /**< list (table) of components */ +#define componentEntry(i) ((t_component_instance *)ComponentTable.entries[i]) +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/introspection.h b/drivers/staging/nmf-cm/cm/engine/component/inc/introspection.h new file mode 100644 index 00000000000..cfb55c91779 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/introspection.h @@ -0,0 +1,109 @@ +/* + * 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 Components Management internal methods - Introspection. + * + */ +#ifndef __INC_CM_INTROSPECTION_H +#define __INC_CM_INTROSPECTION_H + +#include <cm/engine/component/inc/instance.h> + +/*! + * \internal + * \brief Description of a required interface reference + * + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + const t_component_instance *client; //!< Component that provide this interface + t_uint8 requireIndex; //!< Index of the interface in the require array + t_uint8 collectionIndex; //!< Index in the collection if required interface is a collection + const char* origName; //!< Name of the component interface +} t_interface_require_description; + +/*! + * \internal + * \brief Description of a provided interface + * + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + const t_component_instance *server; //!< Component that provide this interface + t_uint8 provideIndex; //!< Index of the interface in the provide array + t_uint8 collectionIndex; //!< Index in the collection if provided interface is a collection + const char* origName; //!< Name of the component interface +} t_interface_provide_description; + + +/*! + * \internal + * \brief Get property of a component. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_getComponentProperty( + const t_component_instance *component, + const char *propName, + char value[MAX_PROPERTY_VALUE_LENGTH], + t_uint32 valueLength); + + +t_dsp_address cm_getAttributeMpcAddress( + const t_component_instance *component, + const char *attrName); + +t_cm_logical_address cm_getAttributeHostAddr( + const t_component_instance *component, + const char *attrName); + +t_uint32 cm_readAttributeNoError( + const t_component_instance *component, + const char *attrName); + +t_cm_error cm_readAttribute( + const t_component_instance *component, + const char *attrName, + t_uint32 *value); + +t_cm_error cm_writeAttribute( + const t_component_instance *component, + const char *attrName, + t_uint32 value); + +/*! + * \internal + * \brief Get internal component symbol + * + * \ingroup COMPONENT_INTERNAL + */ +t_dsp_address cm_getFunction( + const t_component_instance* component, + const char* interfaceName, + const char* methodName); + +/*! + * \internal + * \brief Get interface provided by a component instance. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_getProvidedInterface(const t_component_instance* server, + const char* itfName, + t_interface_provide_description *itfProvide); + +/*! + * \internal + * \brief Get interface required by a component instance. + * + * \ingroup COMPONENT_INTERNAL + */ +t_cm_error cm_getRequiredInterface(const t_component_instance* server, + const char* itfName, + t_interface_require_description *itfRequire); + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/nmfheaderabi.h b/drivers/staging/nmf-cm/cm/engine/component/inc/nmfheaderabi.h new file mode 100644 index 00000000000..9eae19b2f70 --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/nmfheaderabi.h @@ -0,0 +1,154 @@ +/* + * 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. + */ +/*! + * \brief NMF component description ABI + * + * \defgroup NMF_HEADER NMF Component Description ABI + * The NMF component description ABI is stored in the nmf_segment in the ELF component file. + * The NMF component description section start by the t_elf_component_header structure. + * + * \warning <B>The format of this section is not fixed and is able to be changed without concerting.</B> + * \note You can use the nmfHeaderVersion to check if the format has changed. + * \note Each pointers in this section is relative to the beginning of the section and must be relocated before used. + * \ingroup NMF_ABI + */ +#ifndef __INC_CM_NMF_HEADERABI_H +#define __INC_CM_NMF_HEADERABI_H + +#include <cm/inc/cm_type.h> + +/*! + * \brief Description of a interface + * \ingroup NMF_HEADER + */ +typedef struct { + char *type; //!< Type of this Interface + t_uint8 methodNumber; //!< Number of method in the interfaces + t_uint8 reserved1, reserved2, reserved3; + char *methodNames[1]; //!< Array of method names [methodNumber] +} t_elf_interface_description; + +/*! + * \brief Description of required interface type (value could be combinated) + * \ingroup NMF_HEADER + */ +typedef enum { + COLLECTION_REQUIRE = 1, //!< Required interface is a collection + OPTIONAL_REQUIRE = 2, //!< Required interface if optional + STATIC_REQUIRE = 4, //!< Required interface is static + VIRTUAL_REQUIRE = 8, //!< Required interface is virtual (only for introspection purpose) + INTRINSEC_REQUIRE = 16 //!< Required interface is intrinsec (bind automatically done by runtime) +} t_elf_interface_require_type; + +/*! + * \brief Description of a required interface on a collection index + * \ingroup NMF_HEADER + */ +typedef struct { + t_uint32 numberOfClient; //!< Number of interface descriptor really connected to this interface + t_uint32 symbols[1]; /*!< Symbol of the real name of the attribute + \note Real type symbols[numberOfClient] + \note Use relocation in order to get symbol information */ +} t_elf_interface_require_index; + +/*! + * \brief Description of an interface required + * \ingroup NMF_HEADER + */ +typedef struct { + char *name; //!< name of the interface: offset in string segment + t_uint8 requireTypes; //!< Mask of t_elf_interface_require_type + t_uint8 collectionSize; //!< Size of the collection (1 if not a collection) + t_uint8 reserved1, reserved2; + t_elf_interface_description *interface; //!< Interface description + t_elf_interface_require_index indexes[1]; /*!< Require information for each collection index + \note Real type: indexes[collectionSize], + available only if not static interface */ +} t_elf_required_interface; + +/*! + * \brief Description of provided interface type (value could be combinated) + * \ingroup NMF_HEADER + */ +typedef enum { + COLLECTION_PROVIDE = 1, //!< Provided interface is a collection + VIRTUAL_PROVIDE = 2 //!< Provided interface is virtual (only for introspection purpose) +} t_elf_interface_provide_type; + +/*! + * \brief Description of an interface provided + * \ingroup NMF_HEADER + */ +typedef struct { + char* name; //!< name of the interface: offset in string segment + t_uint8 provideTypes; //!< Mask of t_elf_interface_provide_type + t_uint8 interruptLine; //!< Interrupt line if interrupt (0 if not) + t_uint8 collectionSize; //!< Size of the collection (1 if not a collection) + t_uint8 reserved1; + t_elf_interface_description *interface; //!< Interface description + t_uint32 methodSymbols[1]; /*!< Symbol of the real name of methods of the interface for each collection index + \note Real type: methodSymbols[collectionSize][methodNumber] + \note Use relocation in order to get symbol information*/ +} t_elf_provided_interface; + +/*! + * \brief Description of an attribute + * \ingroup NMF_HEADER + */ +typedef struct { + char* name; //!< Name of this attribute + t_uint32 symbols; /*!< Symbol of the real name of the attribute + \note Use relocation in order to get symbol information */ +} t_elf_attribute; + +/*! + * \brief Description of an property + * \ingroup NMF_HEADER + */ +typedef struct { + char* name; //!< Name of this attribute + char* value; //!< String of the value +} t_elf_property; + +#define MAGIC_COMPONENT 0x123 //!< Magic Number for a component \ingroup NMF_HEADER +#define MAGIC_SINGLETON 0x321 //!< Magic Number for a singleton component \ingroup NMF_HEADER +#define MAGIC_FIRMWARE 0x456 //!< Magic Number for Execution Engine Component \ingroup NMF_HEADER + +/*! + * \brief Description of a ELF component header + * + * The NMF component description section start by this structure. + * + * \ingroup NMF_HEADER + */ +typedef struct { + t_uint32 magic; //!< Magic Number + t_uint32 nmfVersion; //!< Version of the NMF Header + + char* templateName; //!< Name of the component template + + t_uint32 LCCConstruct; //!< Life cycle Constructor offset + t_uint32 LCCStart; //!< Life cycle Starter offset + t_uint32 LCCStop; //!< Life cycle Stopper offset + t_uint32 LCCDestroy; //!< Life cycle Destructer offset + + t_uint32 minStackSize; //!< Minimum stack size + + t_uint32 attributeNumber;//!< Number of attributes + t_elf_attribute *attributes; //!< Array of attributes (be careful, this reference must be relocated before use) + + t_uint32 propertyNumber; //!< Number of properties + t_elf_property *properties; //!< Array of properties (be careful, this reference must be relocated before use) + + t_uint32 provideNumber; //!< Number of interfaces provided + t_elf_provided_interface *provides; //!< Array of interfaces provided (be careful, this reference must be relocated before use) + + t_uint32 requireNumber; //!< Array of interfaces required + t_elf_required_interface *requires; //!< Array of interfaces required (be careful, this reference must be relocated before use) + +} t_elf_component_header; + +#endif diff --git a/drivers/staging/nmf-cm/cm/engine/component/inc/template.h b/drivers/staging/nmf-cm/cm/engine/component/inc/template.h new file mode 100644 index 00000000000..2718d8ae9fb --- /dev/null +++ b/drivers/staging/nmf-cm/cm/engine/component/inc/template.h @@ -0,0 +1,110 @@ +/* + * 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 Components Management internal methods - Template API. + * + * \defgroup COMPONENT_INTERNAL Private component instances API + */ +#ifndef __INC_CM_TEMPLATE_H +#define __INC_CM_TEMPLATE_H + +#include <cm/engine/dsp/inc/dsp.h> +#include <cm/engine/component/inc/description.h> +#include <cm/engine/elf/inc/elfapi.h> +#include <cm/engine/utils/inc/string.h> + + +/*! + * \internal + * \brief Class of a component + * \ingroup COMPONENT_INTERNAL + */ +typedef enum { + COMPONENT, //!< Primitive component + SINGLETON, //!< Singleton component + FIRMWARE, //!< Firmware composite component +} t_component_classe; + +/*! + * \internal + * \brief Description of delayed relocation + * \ingroup COMPONENT_INTERNAL + */ +typedef struct _t_function_relocation { + t_dup_char symbol_name; + t_uint32 type; + char *reloc_addr; + struct _t_function_relocation *next; +} t_function_relocation; + +struct t_component_instance; + +/*! + * \internal + * \brief Description of a provided interface method on a collection index ; Available only when template loaded + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_uint32 methodAddresses; //!< Address of each method +} t_interface_provide_index_loaded; + +/*! + * \internal + * \brief Description of a provided interface ; Available only when template loaded + * \ingroup COMPONENT_INTERNAL + */ +typedef struct { + t_interface_provide_index_loaded **indexesLoaded; //!< Provide information for each collection index +} t_interface_provide_loaded; + + +/*! + * \internal + * \brief Description of a component template + * \ingroup COMPONENT_INTERNAL + */ +typedef struct _t_component_template { + t_dup_char name; //!< Template name (a.k.a component type) + + t_component_classe classe; //!< Class of the component + //TODO, juraj, remove dspId + t_nmf_core_id dspId; //!< Reference on DSP where template is loaded + + t_uint8 numberOfInstance; //!< Number of same instance (or singleton copy) create from this template + + t_uint8 propertyNumber; //!< Number of properties in this template + t_uint8 attributeNumber; //!< Number of attributes in this template + t_uint8 provideNumber; //!< Number of interface provided by this template + t_uint8 requireNumber; //!< Number of interface required by this template + + t_uint32 LCCConstructAddress; //!< Life cycle Constructor address + t_uint32 LCCStartAddress; //!< Life cycle Starter address + t_uint32 LCCStopAddress; //!< Life cycle Stopper address + t_uint32 LCCDestroyAddress; //!< Life cycle Destructer address + + t_uint32 minStackSize; //!< Minimum stack size + + t_memory_handle memories[NUMBER_OF_MMDSP_MEMORY]; //!< Reference in different memory where datas are (YES, we fix implementation to MMDSP) + const t_elfmemory *thisMemory; //!< Memory used to determine this + const t_elfmemory *codeMemory; //!< Memory used to determine code + + t_function_relocation *delayedRelocation; //!< List of reference that can't been relocatable while appropritae binding done. + + t_property *properties; //!< Array of properties in this template + t_attribute *attributes; //!< Array of attributes in this template + t_interface_provide *provides; //!< Array of interface provided by this template + t_interface_require *requires; //!< Array of interface required by this template + + t_interface_provide_loaded *providesLoaded; //!< Array of interface provided by this template ; Available when loaded + + t_bool descriptionAssociatedWithTemplate; + + struct _t_component_template *prev, *next; + struct t_component_instance *singletonIfAvaliable; +} t_component_template; + +#endif |