839 lines
22 KiB
C
839 lines
22 KiB
C
/* wmbComponentLib.c - Wind River CLI, Web, MIBway component library */
|
|
|
|
/*
|
|
* Copyright (c) 2001-2010, 2012 Wind River Systems, Inc.
|
|
*
|
|
* The right to copy, distribute, modify or otherwise make use
|
|
* of this software may be licensed only pursuant to the terms
|
|
* of an applicable Wind River license agreement.
|
|
*/
|
|
|
|
/*
|
|
modification history
|
|
--------------------
|
|
01i,17may12,h_l replace NO_STRING with NULL_STRING (WIND00032212)
|
|
01h,19jul10,h_y modified for WIND00223629
|
|
01g,01apr10,f_f VxWorks 64bit support (WIND00193649)
|
|
01f,24feb07,msa Correct the apigen comments so they match the actual
|
|
routines.
|
|
01e,16feb06,ps changes for webcli on linux
|
|
01d,15sep04,gsr to enable listner task to be spawned only when event manager
|
|
is defined SPR#101289
|
|
01c,22aug03,jws fix compiler warnings, SPR 90282
|
|
01b,08oct01,rws comments modified
|
|
01a,01aug01,pns written
|
|
*/
|
|
|
|
/*
|
|
DESCRIPTION
|
|
This module provides routines for registering and managing RCB management
|
|
components. An RCB management component is an application--a group of data
|
|
producers, data consumers, event producers, and event consumers--that
|
|
communicates with the backplane to monitor, control, or configure a device.
|
|
|
|
Typical examples of RCB management components include Wind River Web Server,
|
|
for web-based device management, and Wind River CLI--a command line device
|
|
management interface.
|
|
|
|
INCLUDE FILES: wm.h wmb.h
|
|
*/
|
|
|
|
#undef __DEBUG_MESSAGES_OFF__ /* undefine to allow debugging messages */
|
|
|
|
/* includes */
|
|
|
|
#include "wrn/wm/common/wm.h"
|
|
#include "wrn/wm/backplane/wmb.h"
|
|
|
|
#ifndef WMB_QUEUE_SIZE_K
|
|
#define WMB_QUEUE_SIZE_K 32
|
|
#endif
|
|
|
|
#define wmbComponentBackplaneSet(x,y) wmbComponent(x)->backplane = y
|
|
#define wmbComponentNameSet(x,y) STRNCPY(wmbComponent(x)->name, y, WMB_COMPONENT_NAME_MAX_K)
|
|
#define wmbComponentCidSet(x,y) wmbComponent(x)->cid = y
|
|
#define wmbComponentFlagsSet(x,y) wmbComponent(x)->flags = y
|
|
#define wmbComponentDeregSet(x,y) wmbComponent(x)->deregister = y
|
|
#define wmbComponentCtrlSet(x,y) wmbComponent(x)->cookie = y
|
|
#define wmbComponentQidSet(x,y) wmbComponent(x)->qid = y
|
|
#define wmbComponentListenerSet(x,y) wmbComponent(x)->listener = (WMB_LISTENER_T) y
|
|
#define wmbComponentDBSet(x,y) wmbComponent(x)->pDB = y
|
|
/*
|
|
#define wmbComponentStateSet(x,y) wmbComponent(x)->pState = y
|
|
*/
|
|
#define wmbComponentObjectsSet(x,y) wmbComponent(x)->shares.pObjects = y
|
|
#define wmbComponentBuffersSet(x,y) wmbComponent(x)->shares.pBuffer = y
|
|
#define wmbComponentDataSet(x,y) wmbComponent(x)->shares.pool = y
|
|
#define wmbComponentMemSet(x,y) wmbComponent(x)->memID = y
|
|
/*
|
|
#define wmbComponentLockHeadSet(x,y) wmbComponent(x)->pLockHead = y
|
|
*/
|
|
#define wmbComponentHandlerSet(x,y) wmbComponent(x)->handler = y
|
|
|
|
|
|
LOCAL OS_SEM_T mComponentMutex;
|
|
LOCAL sbyte4 mCID;
|
|
LOCAL sbyte4 blockSize = 0;
|
|
|
|
#ifndef WMB_LISTENER_SUFFIX_K
|
|
#define WMB_LISTENER_SUFFIX_K "listener"
|
|
#endif
|
|
|
|
#define THREAD_NAME_SIZE_K WMB_COMPONENT_NAME_MAX_K + \
|
|
sizeof(WMB_LISTENER_SUFFIX_K) + \
|
|
2 /* for space between and null at end */
|
|
|
|
#define FLAG_COMPONENT_DOMAIN_K 0x0001
|
|
#define FLAG_COMPONENT_REMOTE_K 0x0002
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentMemGet - Return component's pool id.
|
|
*
|
|
* RETURNS: MEM_POOL_ID
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
MEM_POOL_ID wmbComponentMemGet
|
|
(
|
|
WMB_CID_T cid /* [in] Component ID */
|
|
)
|
|
{
|
|
WMB_ID_T backplane;
|
|
|
|
if ((! wmbComponentBad(cid)) && NULL != wmbComponent(cid)->pPooled)
|
|
return wmbComponent(cid)->pPooled->pool;
|
|
|
|
backplane = wmbBackplaneGet();
|
|
return wmbBackplaneMemGet(backplane);
|
|
}
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentLockHeadSet - Set the Lock queue head
|
|
*
|
|
* RETURNS: none
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
void wmbComponentLockHeadSet
|
|
(
|
|
WMB_CID_T component, /* [in] Component ID */
|
|
WMB_LOCK_HEAD_T * pHead /* [in] Lock Queue Head */
|
|
)
|
|
{
|
|
wmbComponent(component)->pLockHead = pHead;
|
|
}
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentStateSet - Set the cookie of the component.
|
|
*
|
|
* RETURNS: none
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
void wmbComponentStateSet
|
|
(
|
|
WMB_CID_T component, /* [in] component ID */
|
|
void * pState /* [in] Pointer to the cookie */
|
|
)
|
|
{
|
|
wmbComponent(component)->pState = pState;
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentDeregister - Handle deregister requests from components.
|
|
*
|
|
* If a component is restarting or being removed from the system,
|
|
* it should de-register using the following call. If the component
|
|
* has not already de-registered any associated resources, archives or events,
|
|
* they will be de-registered (using the calls passed in on registration) as a
|
|
* result of this call.
|
|
*
|
|
* RETURNS: OK or ERROR
|
|
*/
|
|
STATUS wmbComponentDeregister
|
|
(
|
|
WMB_CID_T cid /* [in] Component identifier */
|
|
)
|
|
{
|
|
STATUS status;
|
|
|
|
if (wmbComponentBad(cid))
|
|
return wmError(ERROR_GENERAL_INVALID, "invalid component");
|
|
|
|
/* remove any registered windmark resources */
|
|
|
|
wmbDBRemove(cid);
|
|
|
|
/* if there is a listener, tell it to stop */
|
|
|
|
wmbComponentSend(cid, WMB_QUIT_K, sizeof(WMB_QUIT_K));
|
|
|
|
/*
|
|
if (FLAG_SET(cid, FLAG_COMPONENT_DOMAIN_K))
|
|
wmosQueueDelete(wmbComponentQidGet(cid));
|
|
*/
|
|
/* remove ourselves from the backplane */
|
|
|
|
status = wmbBackplaneComponentDestroy(cid);
|
|
|
|
return status;
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentResourceLoad - Load an array of database entries.
|
|
*
|
|
* This routine loads an array of database entries [<pTable>,<rows>] into
|
|
* the database referenced by <pDB>, in the managament component referenced
|
|
* by <pComponent>.
|
|
*
|
|
* RETURNS: OK or ERROR
|
|
*
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
|
|
STATUS wmbComponentResourceLoad
|
|
(
|
|
WMB_CID_T component, /* [in] management component name pointer */
|
|
WMB_ENTRY_T * pEntries, /* [in] database table pointer */
|
|
sbyte4 rows, /* [in] number of rows in database */
|
|
sbyte * pPath /* [in] path is prepended to name */
|
|
)
|
|
{
|
|
WMB_ID_T backplane;
|
|
WMB_DB_T * pDB;
|
|
|
|
#if 0
|
|
DB_ENTRY_T * pEntry;
|
|
DB_NAMES_T * pFields;
|
|
sbyte4 index;
|
|
sbyte * pName;
|
|
WMB_HANDLER_T handler;
|
|
#endif
|
|
|
|
/* Is there anything to register? */
|
|
if (0 == rows)
|
|
return OK;
|
|
|
|
/* make sure starting with valid data */
|
|
|
|
backplane = wmbComponentBackplaneGet(component);
|
|
if wmbBackplaneBad(backplane)
|
|
return wmError(ERROR_WMB_BACKPLANE_INVALID, "wmbComponentResourceLoad: no backplane");
|
|
|
|
if (wmbComponentBad(component))
|
|
return wmError(ERROR_GENERAL_INVALID, "wmbComponentResourceLoad: no component");
|
|
|
|
if (NULL == pEntries)
|
|
return wmError(ERROR_GENERAL_NO_DATA, "wmbComponentResourceLoad: no entries");
|
|
|
|
if (NULL == (pDB = wmbBackplaneDBGet(backplane)))
|
|
return wmError(ERROR_DB_NO_DATABASE, "wmbComponentResourceLoad: no database");
|
|
|
|
return wmbDBAdd(pDB, component, pEntries, rows, pPath);
|
|
|
|
} /* wmbComponentResourceLoad */
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentTableLoad - Load an array of database entries.
|
|
*
|
|
* This routine loads an array of database entries [<pTable>,<rows>] into
|
|
* the database referenced by <pDB>, in the managament component referenced
|
|
* by <pComponent>.
|
|
*
|
|
* RETURNS: OK or ERROR
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
STATUS wmbComponentTableLoad
|
|
(
|
|
WMB_CID_T component, /* [in] management component name pointer */
|
|
WMB_TABLE_T * pTable, /* [in] database table pointer */
|
|
sbyte4 tableSize, /* [in] number of rows in database */
|
|
sbyte * pPath /* [in] path is prepended to name */
|
|
)
|
|
{
|
|
WMB_ID_T backplane;
|
|
WMB_DB_T * pDB;
|
|
|
|
/* Is there anything to register? */
|
|
if (0 == tableSize)
|
|
return OK;
|
|
|
|
/* make sure starting with valid data */
|
|
|
|
backplane = wmbComponentBackplaneGet(component);
|
|
if wmbBackplaneBad(backplane)
|
|
return wmError(ERROR_WMB_BACKPLANE_INVALID, "wmbComponentTableLoad: no backplane");
|
|
|
|
if (wmbComponentBad(component))
|
|
return wmError(ERROR_GENERAL_INVALID, "wmbComponentTableLoad: no component");
|
|
|
|
if (NULL == pTable)
|
|
return wmError(ERROR_GENERAL_NO_DATA, "wmbComponentTableLoad: no table entries");
|
|
|
|
if (NULL == (pDB = wmbBackplaneDBGet(backplane)))
|
|
return wmError(ERROR_DB_NO_DATABASE, "wmbComponentTableLoad: no database");
|
|
|
|
return wmbDBTableAdd(pDB, component, pTable, tableSize,pPath);
|
|
|
|
} /* wmbComponentTableLoad */
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentStart - Initializes a management component.
|
|
*
|
|
* Initializes a registered management component. !rws
|
|
*
|
|
* RETURNS: OK or ERROR
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
STATUS wmbComponentStart
|
|
(
|
|
sbyte4 block_size /* [in] Block size of pool */
|
|
)
|
|
{
|
|
blockSize = block_size;
|
|
/*
|
|
WM_BLOCK_T * pRegistry;
|
|
*/
|
|
|
|
mCID = 0;
|
|
|
|
/*
|
|
pRegistry = wmBlockCreate (wmbBackplaneMemGet(backplane), NULL, blocksize,
|
|
sizeof(WMB_COMPONENT_T));
|
|
|
|
wmbBackplaneComponentsSet(backplane, pRegistry);
|
|
*/
|
|
return wmosSemCreate(&mComponentMutex, 1, 0);
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentStop - Destroys the mutex sem when leaving the backplane.
|
|
*
|
|
* RETURNS: n/a
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
void wmbComponentStop
|
|
(
|
|
WMB_ID_T backplane /* [in] Backplane ID to stop */
|
|
)
|
|
{
|
|
wmosSemDestroy(mComponentMutex);
|
|
}
|
|
|
|
|
|
|
|
#ifdef __WM_EVENT_MANAGER__
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentListenerStart - Start a event listener thread.
|
|
*
|
|
* RETURNS: OK or ERROR
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
LOCAL STATUS wmbComponentListenerStart
|
|
(
|
|
WMB_CID_T component /* [in] Component ID */
|
|
)
|
|
{
|
|
#ifndef __DEBUG_SINGLE_THREAD__
|
|
sbyte threadName[THREAD_NAME_SIZE_K];
|
|
ubyte4 nameSize = THREAD_NAME_SIZE_K;
|
|
sbyte * pName;
|
|
OS_THREAD_T tid;
|
|
OS_MSGQ_T qid;
|
|
|
|
/* create a unique name for the task */
|
|
|
|
pName = wmbComponentNameGet(component);
|
|
STRNCPY(threadName, pName, nameSize);
|
|
nameSize -= (ubyte4)STRLEN(pName);
|
|
STRNCAT(threadName, "_", nameSize);
|
|
nameSize--;
|
|
STRNCAT(threadName, WMB_LISTENER_SUFFIX_K, nameSize);
|
|
|
|
/*
|
|
* we create the queue here instead of wmbComponentListener,
|
|
* because that provides no visibility to the queue create failing
|
|
*/
|
|
|
|
if (OK != wmosQueueCreate (WMB_QUEUE_SIZE_K, sizeof(MSG_IPC_T), 0, &qid))
|
|
return ERROR;
|
|
|
|
wmbComponentQidSet (component, qid);
|
|
|
|
wmosThreadCreate ((VOIDFUNCPTR) wmbComponentListener, threadName,
|
|
component, 0, 0, &tid);
|
|
|
|
/* yield to give listener a chance to start */
|
|
|
|
#ifdef WEBCLI_ON_LINUX
|
|
sched_yield ();
|
|
#else
|
|
taskDelay(0);
|
|
#endif
|
|
|
|
DEBUG_MSG_3 ("wmbComponentListener: %s listening to %d in thread %d\n", pName, qid, tid);
|
|
#endif
|
|
|
|
return OK;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentRegister - Initialize a management component.
|
|
*
|
|
* This routine registers (initializes) the management component <pName> with
|
|
* the backplane instance 'WMB_ID_T'. RCB management components must
|
|
* register with the RCB before any transactions can occur between the
|
|
* backplane and that component.
|
|
*
|
|
* RETURNS: OK or ERROR
|
|
*
|
|
*/
|
|
|
|
STATUS wmbComponentRegister
|
|
(
|
|
sbyte * pBackplane, /* [in] backplane name */
|
|
sbyte * pName, /* [in] component name */
|
|
WMBFUNCPTR pfDeregister, /* [in] deregistration handler */
|
|
void * deregCookie, /* [in] deregistration state */
|
|
WMB_CID_T * pComponent /* [out] Component identifier */
|
|
)
|
|
{
|
|
sbyte * pMaster;
|
|
|
|
#ifdef __WM_EVENT_MANAGER__
|
|
BOOL isLocal;
|
|
#endif
|
|
|
|
WMB_ID_T backplane;
|
|
sbyte4 queueSize; /* depth of message queue listener */
|
|
WMB_CID_T component;
|
|
|
|
queueSize = 0;
|
|
|
|
if (NULL_STRING(pBackplane))
|
|
return wmError(ERROR_GENERAL_BAD_NAME, "no name");
|
|
|
|
/* registering w/ default backplane as real component? */
|
|
|
|
backplane = wmbBackplaneGet();
|
|
if (wmbBackplaneBad(backplane))
|
|
return wmError(ERROR_WMB_BACKPLANE_INVALID, "no backplane");
|
|
|
|
if (NULL == (pMaster = wmbBackplaneNameGet(backplane)))
|
|
return wmError(ERROR_WMB_BACKPLANE_INVALID, "no backplane name");
|
|
|
|
#ifdef __WM_EVENT_MANAGER__
|
|
isLocal = (0 == STRCMP(pBackplane, pMaster));
|
|
#endif
|
|
|
|
if (OK != wmbBackplaneComponentCreate(backplane, &component))
|
|
return ERROR;
|
|
|
|
wmbComponentBless (component);
|
|
wmbComponentBackplaneSet (component, backplane);
|
|
wmbComponentNameSet (component, pName);
|
|
wmbComponentFlagsSet (component, 0);
|
|
wmbComponentDeregSet (component, pfDeregister);
|
|
wmbComponentPoolSet (component, wmbBackplanePoolGet(backplane));
|
|
DEBUG_MSG_2("component: 0x%x pool: 0x%x\n",
|
|
component, wmbComponentPoolGet(component));
|
|
|
|
#ifdef __WM_EVENT_MANAGER__
|
|
if (isLocal)
|
|
wmbComponentListenerStart(component);
|
|
#endif
|
|
|
|
if (NULL != pComponent)
|
|
*pComponent = component;
|
|
|
|
return OK;
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentBackplaneGet - Return backplane ID of a component.
|
|
*
|
|
* RETURNS: Component ID
|
|
*
|
|
*/
|
|
|
|
WMB_ID_T wmbComponentBackplaneGet
|
|
(
|
|
WMB_CID_T cid /* [in] Component ID */
|
|
)
|
|
{
|
|
if (wmbComponentBad(cid))
|
|
return NULL;
|
|
|
|
return wmbComponent(cid)->backplane;
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentListener - Management component listener.
|
|
*
|
|
* This routine initailizes the management component <pComponent> as an
|
|
* event consumer (listener). !rws
|
|
*
|
|
* RETURNS: n/a
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
void wmbComponentListener
|
|
(
|
|
WMB_CID_T component /*[in] management component pointer*/
|
|
)
|
|
{
|
|
OS_MSGQ_T qid;
|
|
MSG_IPC_T ipc;
|
|
long received;
|
|
sbyte * pName;
|
|
|
|
/* make sure component is still valid */
|
|
|
|
if (wmbComponentBad(component))
|
|
return;
|
|
|
|
if (0 == (qid = wmbComponentQidGet(component)))
|
|
{
|
|
DEBUG_MSG_0 ("No queue open for component listener!\n");
|
|
return;
|
|
}
|
|
|
|
pName = wmbComponentNameGet(component);
|
|
|
|
while (TRUE)
|
|
{
|
|
#ifndef _WRS_CONFIG_LP64
|
|
if (OK != wmosQueueReceive (qid, (sbyte *) &ipc, sizeof(ipc),
|
|
WAIT_FOREVER_K, (sbyte4 *)&received))
|
|
#else
|
|
if (OK != wmosQueueReceive (qid, (sbyte *) &ipc, sizeof(ipc),
|
|
WAIT_FOREVER_K, (sbyte8 *)&received))
|
|
#endif
|
|
{
|
|
DEBUG_MSG_0 ("wmbComponentListener: error \n");
|
|
break;
|
|
}
|
|
|
|
if (wmbQuit(&ipc, received))
|
|
break;
|
|
|
|
DEBUG_MSG_2 ("wmbComponentListener: %s received %d bytes\n",
|
|
pName, received);
|
|
|
|
if (OK == wmbRequest(component, (sbyte *) &ipc, (sbyte4)received))
|
|
continue;
|
|
|
|
if (ERROR_GENERAL_QUIT == wmErrNo())
|
|
break;
|
|
}
|
|
|
|
wmosQueueDelete (qid);
|
|
wmTaskEnd();
|
|
}
|
|
|
|
|
|
#ifdef __WM_DEBUG__
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentShow - Show registered components.
|
|
*
|
|
* This routine shows all management components registered with the
|
|
* backplane instance <pSession>.
|
|
*
|
|
* RETURNS: n/a
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
void wmbComponentShow
|
|
(
|
|
WMB_SESSION_T * pSession /* backplane instance (session) pointer */
|
|
)
|
|
{
|
|
WMB_ID_T backplane;
|
|
WMB_COMPONENT_T * * pComponent;
|
|
/*
|
|
WM_BLOCK_T * pBlock;
|
|
*/
|
|
sbyte4 index;
|
|
sbyte4 count;
|
|
backplane = wmbBackplaneGet();
|
|
|
|
/*
|
|
pBlock = wmbBackplaneComponentsGet(backplane);
|
|
pComponent = pBlock->pData;
|
|
count = pBlock->count;
|
|
*/
|
|
pComponent = wmbBackplaneComponentsGet(backplane);
|
|
count = wmbBackplaneComponentCountGet(backplane);
|
|
|
|
for (index = 0; index < count; index++)
|
|
{
|
|
printf("Component: %s\r\n", pComponent[index]->name);
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentLookup - Find component by name.
|
|
*
|
|
* This routine returns the component registered with current backplane
|
|
*
|
|
* RETURNS: OK or ERROR if not found
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
WMB_CID_T wmbComponentLookup
|
|
(
|
|
sbyte * pName /* [in] component name */
|
|
)
|
|
{
|
|
WMB_ID_T backplane;
|
|
WMB_CID_T component;
|
|
WMB_COMPONENT_T * * ppList;
|
|
sbyte4 index;
|
|
sbyte4 count;
|
|
sbyte * pComponentName;
|
|
|
|
DEBUG_MSG_1("wmbComponentLookup: looking for : %s\n", pName);
|
|
|
|
backplane = wmbBackplaneGet();
|
|
|
|
ppList = wmbBackplaneComponentsGet(backplane);
|
|
count = wmbBackplaneComponentCountGet(backplane);
|
|
|
|
for (index = 0; index < count; index++)
|
|
{
|
|
component = ppList[index];
|
|
DEBUG_MSG_1("wmbComponentLookup: component: 0x%x?\n", component);
|
|
|
|
if (wmbComponentBad(component))
|
|
continue;
|
|
|
|
if (NULL == (pComponentName = wmbComponentNameGet(component)))
|
|
continue;
|
|
|
|
DEBUG_MSG_1("wmbComponentLookup: is it: %s?\n", pComponentName);
|
|
if (0 != STRCMP(pName, pComponentName))
|
|
continue;
|
|
|
|
DEBUG_MSG_1("wmbComponentLookup: FOUND: %s!\n", pComponentName);
|
|
|
|
return component;
|
|
}
|
|
|
|
/* don't set error -- this may just be a query for existance */
|
|
|
|
DEBUG_MSG_1("wmbComponentLookup: BUMMER! missing : %s\n", pName);
|
|
return NULL;
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentRemote - Find component by name in default backplnae
|
|
*
|
|
* !!! right now REMOTE == DOMAINS -- need to add socket support !!!!
|
|
*
|
|
* RETURNS: OK or ERROR if not found
|
|
*
|
|
* NOMANUAL
|
|
*
|
|
*/
|
|
|
|
STATUS wmbComponentRemote
|
|
(
|
|
WMB_CID_T component, /* [in] Component ID */
|
|
OS_MSGQ_T queue /* [in] Queue to use */
|
|
)
|
|
{
|
|
wmbComponentQidSet(component, queue);
|
|
SET_FLAG(wmbComponent(component), FLAG_COMPONENT_REMOTE_K);
|
|
return OK;
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentLocal - component member of local backplnae
|
|
*
|
|
*
|
|
* !!! right now REMOTE == DOMAINS -- need to add socket support !!!!
|
|
*
|
|
*
|
|
* RETURNS: OK or ERROR if not found
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
BOOL wmbComponentLocal
|
|
(
|
|
WMB_CID_T component /* [in] Component ID */
|
|
)
|
|
{
|
|
return FLAG_SET(wmbComponent(component), FLAG_COMPONENT_DOMAIN_K);
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentSend - send data to remote component
|
|
*
|
|
* RETURNS: OK or ERROR if not found
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
STATUS wmbComponentSend
|
|
(
|
|
WMB_CID_T component, /* [in] Component ID */
|
|
void * pData, /* [in] Data to send */
|
|
size_t length /* [in] Data length */
|
|
)
|
|
{
|
|
OS_MSGQ_T qid;
|
|
|
|
if (wmbComponentBad(component))
|
|
return wmError(ERROR_GENERAL_INVALID, "wmbComponentSend: invalid component");
|
|
|
|
if (NULL == pData || 1 > length)
|
|
return wmError(ERROR_GENERAL_NO_DATA, "wmbComponentSend: no data");
|
|
|
|
if (0 == (qid = wmbComponentQidGet(component)))
|
|
return OK;
|
|
/*
|
|
return wmError(ERROR, "wmbComponentSend: no message queue");
|
|
*/
|
|
return wmosQueueSend(qid, pData, length, 0, 0);
|
|
}
|
|
|
|
|
|
void wmbComponentPoolSet
|
|
(
|
|
WMB_CID_T component,
|
|
WMB_POOL_T * pPool
|
|
)
|
|
{
|
|
if (wmbComponentBad(component))
|
|
return;
|
|
|
|
wmbComponent(component)->pPooled = pPool;
|
|
}
|
|
|
|
|
|
#if defined __WMB_VIEW_ACCESS_MODEL__
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentViewLoad - Load the views to the backplane.
|
|
*
|
|
* RETURNS: ERROR, OK
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
|
|
STATUS wmbComponentViewLoad
|
|
(
|
|
WMB_CID_T component, /* [in] Component */
|
|
WMB_VACM_VIEW_ENTRY_T * pEntry, /* [in] Pointer to the start of Entry array */
|
|
ubyte2 numEntries /* [in] Number of entries to register */
|
|
)
|
|
{
|
|
WMB_VIEW_DB_T * pViewDB;
|
|
|
|
if (wmbComponentBad(component))
|
|
return wmError(ERROR_GENERAL_NOT_FOUND, "wmbComponentViewLoad");
|
|
|
|
if (! wmNew(pViewDB))
|
|
return wmError(ERROR_MEMMGR_NO_MEMORY, "wmbComponentViewLoad");
|
|
|
|
pViewDB->numViews = numEntries;
|
|
pViewDB->pComponent = component;
|
|
pViewDB->pEntry = pEntry;
|
|
|
|
return wmbBackplaneViewAdd(wmbComponentBackplaneGet(component), pViewDB);
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
*
|
|
* wmbComponentViewDelete - Delete the view for the component.
|
|
*
|
|
* RETURNS: ERROR, OK
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
STATUS wmbComponentViewDelete
|
|
(
|
|
WMB_CID_T component /* [in] Component */
|
|
)
|
|
{
|
|
WMB_VIEW_DB_T *pViewDB;
|
|
|
|
if (wmbComponentBad(component))
|
|
return wmError(ERROR_GENERAL_NOT_FOUND, "wmbComponentViewLoad");
|
|
|
|
pViewDB = wmbBackplaneViewDBGet(wmbComponentBackplaneGet(component));
|
|
while (NULL != pViewDB)
|
|
{
|
|
if (component == pViewDB->pComponent)
|
|
break;
|
|
|
|
pViewDB = pViewDB->pNext;
|
|
}
|
|
|
|
if (NULL != pViewDB)
|
|
{
|
|
wmbBackplaneViewDelete(wmbComponentBackplaneGet(component), pViewDB);
|
|
wmFree(pViewDB);
|
|
}
|
|
|
|
return OK;
|
|
}
|
|
|
|
#endif /* __WMB_VIEW_ACCESS_MODEL__ */
|
|
|
|
/* eof wmbComponentLib.c */
|