diff --git a/src/rm.c b/src/rm.c
index d19ca1c34a2779e8a939af04eb3da74257df3342..1cfd0a41313066b758685b5d0b3e7655eae4b439 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
*/
Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
{
- Rm_Inst *rmInst = NULL;
- Rm_Inst *sharedServerInst = NULL;
- void *globalResourceDtb = NULL;
- void *linuxResourceDtb = NULL;
- int addLinux = RM_FALSE;
- void *key;
+ Rm_Inst *rmInst = NULL;
+ Rm_Inst *sharedServerInst = NULL;
+ uint32_t policySize;
+ void *globalResourceDtb = NULL;
+ void *linuxResourceDtb = NULL;
+ int addLinux = RM_FALSE;
+ void *key;
*result = RM_OK;
}
/* Create and initialize instance */
- rmInst = Rm_osalMalloc (sizeof(Rm_Inst));
- memset ((void *) rmInst, 0, sizeof(Rm_Inst));
+ rmInst = Rm_osalMalloc(sizeof(*rmInst));
+ memset ((void *)rmInst, 0, sizeof(*rmInst));
rmInst->isLocked = RM_FALSE;
rmInst->registeredWithDelegateOrServer = RM_FALSE;
rmInst->transactionSeqNum = transactionInitSequenceNum();
goto errorExit;
}
- rmInst->u.server.globalPolicy = initCfg->instCfg.serverCfg.globalPolicy;
+ if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+ /* Shared Server makes copy of policy in shared memory for Shared Clients
+ * on other cores */
+ policySize = fdt_totalsize(initCfg->instCfg.serverCfg.globalPolicy);
+ /* Align policy size to cache boundary */
+ if (policySize % RM_MAX_CACHE_ALIGN) {
+ policySize += (RM_MAX_CACHE_ALIGN - (policySize % RM_MAX_CACHE_ALIGN));
+ }
+ rmInst->u.server.policySize = policySize;
+ rmInst->u.server.globalPolicy = Rm_osalMalloc(rmInst->u.server.policySize);
+ memcpy(rmInst->u.server.globalPolicy, initCfg->instCfg.serverCfg.globalPolicy, rmInst->u.server.policySize);
+ }
+ else {
+ rmInst->u.server.globalPolicy = initCfg->instCfg.serverCfg.globalPolicy;
+ }
if (initCfg->instCfg.serverCfg.linuxDtb) {
linuxResourceDtb = initCfg->instCfg.serverCfg.linuxDtb;
Rm_osalCsExit(key);
goto errorExit;
}
+ else {
+ /* Invalidate the policy */
+ Rm_osalBeginMemAccess((void *)sharedServerInst->u.server.globalPolicy,
+ sharedServerInst->u.server.policySize);
+ }
Rm_osalCsExit(key);
}
else {
}
if (initCfg->instType == Rm_instType_SHARED_SERVER) {
- /* Writeback the instance for other cores */
+ /* Writeback the instance and policy for other cores */
Rm_osalEndMemAccess ((void *)rmInst, sizeof(Rm_Inst));
+ Rm_osalEndMemAccess ((void *)rmInst->u.server.globalPolicy, rmInst->u.server.policySize);
}
else if (rmInst->instType != Rm_instType_SHARED_CLIENT) {
/* Create the instance's task blocking mechanism */
rmAllocatorDeleteResources(rmHandle);
rmNameServerDelete(rmHandle);
rmInst->u.server.allocators = NULL;
+
+ if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+ Rm_osalFree((void *)rmInst->u.server.globalPolicy, rmInst->u.server.policySize);
+ }
}
else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
rmAllocatorDeleteResources(rmHandle);