Initialization
The Name Server is a task, which means it must be created to execute its main function. It is achieved with PxNamesrvInit
.
PxNamesrvInit
PxTask_t PxNamesrvInit(PxPrio_t srvprio, PxMemAligned_t *membase, PxSize_t memsize);
Parameters:
-
srvprio - the priority of the Name Server task
-
membase - start address of the memory area assigned to the Name Server
-
memsize - the size of the memory area in bytes
Error codes:
-
PXERR_NAME_MEM - not enough memory (memsize too short)
-
all errors from PxTaskCreate()
-
all errors from PxMcRequest()
-
all errors from PxMsgRequest()
-
all errors from PxMsgSend()
Return values:
-
valid task handle on success
-
invalid task handle on failure
Description:
PxNamesrvInit
creates and initializes the Name Server with priority srvprio
, and the memory class of the Name Server. The memory area assigned as data storage starts at membase
and is memsize
bytes long. The Name Server later allocates all entries from this memory class.
The following code snippet shows how to initialize Name Server on the core specified by NAMESERVER_CORE
. This code assumes the memory for Name Server is reserved in the linker script and symbols PxNameServerSpaceBase
, PxNameServerSpaceEnd
for defining base
and end
of the memory section are provided.
/* NameServer memory coordinates needed during NameServer Task creation.
* Coordinates come from Linker files.
*/
extern PxMemAligned_t PxNameServerSpaceBase[];
extern PxMemAligned_t PxNameServerSpaceEnd[];
#define NAMESRV_PRIORITY 8
...
/* Only Name Server core can call PxNamesrvInit() */
if (coreId == NAMESERVER_CORE)
{
PxUInt_t nameserverSize = (PxUInt_t) PxNameServerSpaceEnd
- (PxUInt_t) PxNameServerSpaceBase;
PxTask_t NameSrv = PxNamesrvInit(NAMESRV_PRIORITY,
PxNameServerSpaceBase,
nameserverSize);
if (PxTaskIdError(NameSrv) != PXERR_NOERROR)
PxPanic();
}
...