summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9e93a0)
raw | patch | inline | side by side (parent: c9e93a0)
author | Justin Sobota <jsobota@ti.com> | |
Tue, 26 Feb 2013 23:57:44 +0000 (18:57 -0500) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Tue, 26 Feb 2013 23:57:44 +0000 (18:57 -0500) |
diff --git a/include/rm_loc.h b/include/rm_loc.h
index ca4cd1c7a024e7b40ab138c0ed9c64a3a71f409c..41caccd564ef171771edcb82fb4924a592a68cc8 100644 (file)
--- a/include/rm_loc.h
+++ b/include/rm_loc.h
#include <ti/drv/rm/include/rm_nameserverloc.h>
#include <ti/drv/rm/include/rm_treeloc.h>
+/* Static allocation configuration structure */
+typedef struct {
+ /* Instance name */
+ char *instName;
+ /* Static policy */
+ void *staticPolicy;
+ /* Static valid instance tree */
+ Rm_PolicyValidInstTree *staticValidInstTree;
+} Rm_StaticAllocCfg;
+
/* Service transaction linked list node */
typedef struct Rm_Transaction_s {
/* Transaction service type */
struct Rm_Transaction_s *nextTransaction;
} Rm_Transaction;
-/* Static policy information */
+/* Server-specific instance data */
+typedef struct {
+ /* Pointer to the global policy */
+ void *globalPolicy;
+ /* Pointer to root entry of the global policy valid instance tree */
+ Rm_PolicyValidInstTree *globalValidInstTree;
+ /* Pointer to the linked list of allocators */
+ Rm_Allocator *allocators;
+ /* Pointer to the root entry of the NameServer */
+ Rm_NameServerTree *nameServer;
+} Rm_ServerInstData;
+
+/* Client Delegate-specific instance data */
typedef struct {
/* Pointer to the static policy if provided */
void *staticPolicy;
/* Pointer to the root entry of the valid instance tree
* extracted from the static policy */
Rm_PolicyValidInstTree *staticValidInstTree;
-} Rm_StaticInfo;
+} Rm_ClientDelegateInstData;
+
+/* Client-specific instance data */
+typedef struct {
+ /* Pointer to the static policy if provided */
+ void *staticPolicy;
+ /* Pointer to the root entry of the valid instance tree
+ * extracted from the static policy */
+ Rm_PolicyValidInstTree *staticValidInstTree;
+} Rm_ClientInstData;
/* RM instance structure */
typedef struct {
/* Name given to the RM instance. Policy will assign resources based
* on the names assigned to instances at instance init */
- char instName[RM_NAME_MAX_CHARS];
+ char instName[RM_NAME_MAX_CHARS];
/* Instance type */
- Rm_InstType instType;
+ Rm_InstType instType;
/* Instance lock status. Instance locks if static request fails when
* checked against global policy */
- bool isLocked;
+ bool isLocked;
/* Pointer to the serviceHandle opened from the instance */
- Rm_ServiceHandle *serviceHandle;
+ Rm_ServiceHandle *serviceHandle;
/* Tracks whether the instance has registered with a CD or Server.
* Applicable to CD and Client instances */
- bool registeredWithDelegateOrServer;
+ bool registeredWithDelegateOrServer;
/* Linked list of transports registered by the application */
- Rm_Transport *transports;
+ Rm_Transport *transports;
/* Service transaction sequence number tracker */
- uint32_t transactionSeqNum;
+ uint32_t transactionSeqNum;
/* Service transaction linked list queue */
- Rm_Transaction *transactionQueue;
- /* [Server] Pointer to the global policy */
- void *policy;
- /* [Server] Pointer to root entry of the global policy valid instance tree */
- Rm_PolicyValidInstTree *validInstances;
- /* [Server] Pointer to the linked list of allocators */
- Rm_Allocator *allocators;
- /* [Server] Pointer to the root entry of the NameServer */
- Rm_NameServerTree *nameServer;
- /* [CD or Client] Static policy data */
- Rm_StaticInfo staticInfo;
+ Rm_Transaction *transactionQueue;
+ /* Instance-type specific constructs */
+ union {
+ /* Server-specific instance data */
+ Rm_ServerInstData server;
+ /* Client Delegate-specific instance data */
+ Rm_ClientDelegateInstData cd;
+ /* Client-specific instance data */
+ Rm_ClientInstData client;
+ } u;
} Rm_Inst;
Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
index 845cb45f3400aa99a4eecd6c3734088dc4d2952f..d4d44182427e547cab8af91d7b1eff9124053091 100644 (file)
int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg);
void rmNameServerPrintObjects(Rm_NameServerTree *nameServerTree);
Rm_NameServerTree *rmNameServerInit(void);
+void rmNameServerDelete(Rm_NameServerTree *nameServerTree);
#ifdef __cplusplus
}
diff --git a/src/rm.c b/src/rm.c
index 06ca39cd4daf310d43aab879f241935c35aed70b..8c9159a2e7347b6208bfbd8123fc50fedb607d4c 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
* with a Server. The allocation request is validated
* against a static policy.
*/
-static void staticAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void staticAllocationHandler (Rm_StaticAllocCfg *staticAllocCfg, Rm_Transaction *transaction)
{
- Rm_PolicyCheckCfg privCheckCfg;
+ Rm_PolicyCheckCfg privCheckCfg;
- if (rmInst->staticInfo.staticPolicy) {
+ if (staticAllocCfg->staticPolicy) {
if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
(transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
/* Check request against startup policy */
@@ -373,10 +373,10 @@ static void staticAllocationHandler (Rm_Inst *rmInst, Rm_Transaction *transactio
else {
privCheckCfg.type = Rm_policyCheck_USE;
}
- privCheckCfg.policyDtb = rmInst->staticInfo.staticPolicy;
- privCheckCfg.validInstNode = rmPolicyGetValidInstNode(rmInst->staticInfo.staticValidInstTree,
- rmInst->instName);
- privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(rmInst->staticInfo.staticPolicy,
+ privCheckCfg.policyDtb = staticAllocCfg->staticPolicy;
+ privCheckCfg.validInstNode = rmPolicyGetValidInstNode(staticAllocCfg->staticValidInstTree,
+ staticAllocCfg->instName);
+ privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(staticAllocCfg->staticPolicy,
transaction->resourceInfo.name);
privCheckCfg.resourceBase = transaction->resourceInfo.base;
privCheckCfg.resourceLength = transaction->resourceInfo.length;
else if (rmInst->instType == Rm_instType_SERVER) {
memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
- opInfo.policy = rmInst->policy;
+ opInfo.policy = rmInst->u.server.globalPolicy;
opInfo.resourceInfo = &transaction->resourceInfo;
- opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);
+ opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->u.server.globalValidInstTree, transaction->serviceSrcInstName);
if (opInfo.serviceSrcInstNode) {
switch (transaction->type) {
case Rm_service_RESOURCE_ALLOCATE_INIT:
(transaction->resourceInfo.length == 0) &&
(transaction->resourceInfo.alignment == 0)) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
- nameServerObjCfg.nameServerTree = rmInst->nameServer;
+ nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
else if (rmInst->instType == Rm_instType_SERVER) {
memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
- opInfo.policy = rmInst->policy;
+ opInfo.policy = rmInst->u.server.globalPolicy;
opInfo.resourceInfo = &transaction->resourceInfo;
- opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->validInstances, transaction->serviceSrcInstName);
+ opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->u.server.globalValidInstTree, transaction->serviceSrcInstName);
if (opInfo.serviceSrcInstNode) {
/* Populated NameServer name has precedence over base */
if (strlen(transaction->resourceInfo.nameServerName) > 0) {
(transaction->resourceInfo.length == 0) &&
(transaction->resourceInfo.alignment == 0)) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
- nameServerObjCfg.nameServerTree = rmInst->nameServer;
+ nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
*/
static void clientProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
- Rm_Transaction *transQ = rmInst->transactionQueue;
+ Rm_StaticAllocCfg staticAllocCfg;
+ Rm_Transaction *transQ = rmInst->transactionQueue;
if (!rmInst->registeredWithDelegateOrServer) {
- staticAllocationHandler(rmInst, transaction);
+ staticAllocCfg.instName = rmInst->instName;
+ staticAllocCfg.staticPolicy = rmInst->u.client.staticPolicy;
+ staticAllocCfg.staticValidInstTree = rmInst->u.client.staticValidInstTree;
+ staticAllocationHandler(&staticAllocCfg, transaction);
}
else {
if (transaction->state == RM_SERVICE_PROCESSING) {
*/
static void clientDelegateProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
{
- Rm_Transaction *transQ = rmInst->transactionQueue;
+ Rm_StaticAllocCfg staticAllocCfg;
+ Rm_Transaction *transQ = rmInst->transactionQueue;
if (!rmInst->registeredWithDelegateOrServer) {
if ((transaction->state == RM_SERVICE_PROCESSING) &&
- (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {
- staticAllocationHandler(rmInst, transaction);
+ (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {
+ staticAllocCfg.instName = rmInst->instName;
+ staticAllocCfg.staticPolicy = rmInst->u.cd.staticPolicy;
+ staticAllocCfg.staticValidInstTree = rmInst->u.cd.staticValidInstTree;
+ staticAllocationHandler(&staticAllocCfg, transaction);
}
/* Everything else left in transaction queue for forwarding once transport to
* Server is registered */
case Rm_service_RESOURCE_MAP_TO_NAME:
case Rm_service_RESOURCE_GET_BY_NAME:
case Rm_service_RESOURCE_UNMAP_NAME:
- if (rmInst->nameServer) {
+ if (rmInst->u.server.nameServer) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
- nameServerObjCfg.nameServerTree = rmInst->nameServer;
+ nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
nameServerObjCfg.nodeCfg.resourceName = transaction->resourceInfo.name;
void Rm_printResourceStatus(Rm_Handle rmServerHandle)
{
Rm_Inst *rmInst = (Rm_Inst *)rmServerHandle;
- Rm_Allocator *allocator = rmInst->allocators;
+ Rm_Allocator *allocator = rmInst->u.server.allocators;
Rm_Owner *owners;
Rm_ResourceTree *treeRoot;
Rm_ResourceNode *treeNode;
}
allocator = allocator->nextAllocator;
}
- rmNameServerPrintObjects(rmInst->nameServer);
+ rmNameServerPrintObjects(rmInst->u.server.nameServer);
}
}
*/
Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
{
- Rm_Inst *rmInst;
+ Rm_Inst *rmInst = NULL;
void *globalResourceDtb = NULL;
void *linuxResourceDtb = NULL;
bool addLinux = false;
if ((initCfg->instName == NULL) ||
((strlen(initCfg->instName) + 1) > RM_NAME_MAX_CHARS)) {
*result = RM_ERROR_INVALID_INST_NAME;
- return (NULL);
+ goto errorExit;
}
if (initCfg->instType >= Rm_instType_LAST) {
*result = RM_ERROR_INVALID_INST_TYPE;
+ goto errorExit;
}
/* Create and initialize instance */
if (!initCfg->instCfg.serverCfg.globalResourceList ||
!initCfg->instCfg.serverCfg.globalPolicy) {
*result = RM_ERROR_INVALID_SERVER_CONFIGURATION;
- Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));
- return(NULL);
+ goto errorExit;
}
- rmInst->policy = initCfg->instCfg.serverCfg.globalPolicy;
+ rmInst->u.server.globalPolicy = initCfg->instCfg.serverCfg.globalPolicy;
if (initCfg->instCfg.serverCfg.linuxDtb) {
linuxResourceDtb = initCfg->instCfg.serverCfg.linuxDtb;
/* Create valid instance list from policy. Must be done prior to parsing
* GRL so that Linux resources can be reserved correctly */
- rmInst->validInstances = rmPolicyCreateValidInstTree(rmInst->policy, addLinux, result);
- /* Validate policy assignment strings */
- *result = rmPolicyValidatePolicy(rmInst->policy, rmInst->validInstances);
+ rmInst->u.server.globalValidInstTree = rmPolicyCreateValidInstTree(rmInst->u.server.globalPolicy,
+ addLinux, result);
+ if (*result == RM_OK) {
+ *result = rmPolicyValidatePolicy(rmInst->u.server.globalPolicy, rmInst->u.server.globalValidInstTree);
+ }
+
+ if (*result != RM_OK) {
+ if (rmInst->u.server.globalValidInstTree) {
+ rmPolicyFreeValidInstTree(rmInst->u.server.globalValidInstTree);
+ }
+ goto errorExit;
+ }
+ else {
+ rmInst->u.server.nameServer = rmNameServerInit();
- rmInst->nameServer = rmNameServerInit();
+ globalResourceDtb = initCfg->instCfg.serverCfg.globalResourceList;
- globalResourceDtb = initCfg->instCfg.serverCfg.globalResourceList;
+ if ((*result = rmAllocatorInitializeResources((Rm_Handle) rmInst, globalResourceDtb, linuxResourceDtb)) == RM_OK) {
+ *result = rmPolicyValidatePolicyResourceNames(rmInst->u.server.globalPolicy, (void *)rmInst->u.server.allocators);
+ }
- if ((*result = rmAllocatorInitializeResources((Rm_Handle) rmInst, globalResourceDtb, linuxResourceDtb)) == RM_OK) {
- *result = rmPolicyValidatePolicyResourceNames(rmInst->policy, (void *)rmInst->allocators);
- }
- if (*result < RM_OK) {
- Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));
- return(NULL);
+ if (*result != RM_OK) {
+ /* Clean up allocators */
+ rmNameServerDelete(rmInst->u.server.nameServer);
+ goto errorExit;
+ }
}
}
+ else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+ if (initCfg->instCfg.clientCfg.staticPolicy) {
+ rmInst->u.cd.staticPolicy = initCfg->instCfg.cdCfg.staticPolicy;
+ rmInst->u.cd.staticValidInstTree = rmPolicyCreateValidInstTree(rmInst->u.cd.staticPolicy,
+ addLinux, result);
+ if (*result == RM_OK) {
+ *result = rmPolicyValidatePolicy(rmInst->u.cd.staticPolicy, rmInst->u.cd.staticValidInstTree);
+ }
- if ((rmInst->instType == Rm_instType_CLIENT) &&
- (initCfg->instCfg.clientCfg.staticPolicy)) {
- rmInst->staticInfo.staticPolicy = initCfg->instCfg.clientCfg.staticPolicy;
- }
- else if ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) &&
- (initCfg->instCfg.cdCfg.staticPolicy)) {
- rmInst->staticInfo.staticPolicy = initCfg->instCfg.cdCfg.staticPolicy;
- }
- if (rmInst->staticInfo.staticPolicy) {
- rmInst->staticInfo.staticValidInstTree = rmPolicyCreateValidInstTree(rmInst->staticInfo.staticPolicy,
- addLinux, result);
- if (*result == RM_OK) {
- /* Validate policy assignment strings */
- *result = rmPolicyValidatePolicy(rmInst->staticInfo.staticPolicy, rmInst->staticInfo.staticValidInstTree);
+ if (*result != RM_OK) {
+ if (rmInst->u.cd.staticValidInstTree) {
+ rmPolicyFreeValidInstTree(rmInst->u.cd.staticValidInstTree);
+ }
+ goto errorExit;
+ }
}
- if (*result != RM_OK) {
- if (rmInst->staticInfo.staticValidInstTree) {
- rmPolicyFreeValidInstTree(rmInst->staticInfo.staticValidInstTree);
+ }
+ else if (rmInst->instType == Rm_instType_CLIENT) {
+ if (initCfg->instCfg.cdCfg.staticPolicy) {
+ rmInst->u.client.staticPolicy = initCfg->instCfg.clientCfg.staticPolicy;
+ rmInst->u.client.staticValidInstTree = rmPolicyCreateValidInstTree(rmInst->u.client.staticPolicy,
+ addLinux, result);
+ if (*result == RM_OK) {
+ *result = rmPolicyValidatePolicy(rmInst->u.client.staticPolicy, rmInst->u.client.staticValidInstTree);
+ }
+
+ if (*result != RM_OK) {
+ if (rmInst->u.client.staticValidInstTree) {
+ rmPolicyFreeValidInstTree(rmInst->u.client.staticValidInstTree);
+ }
+ goto errorExit;
}
- Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));
- rmInst = NULL;
}
}
return ((Rm_Handle) rmInst);
+errorExit:
+ if (rmInst) {
+ Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));
+ }
+ return (NULL);
}
/* FUNCTION PURPOSE: Returns RM version information
diff --git a/src/rm_allocator.c b/src/rm_allocator.c
index 803ba5e60a8398c0a4b44cb1e5a2a40a205f1ca9..a5fd9d0530dbc3aae6fc3d9bed92aa42ce769450 100644 (file)
--- a/src/rm_allocator.c
+++ b/src/rm_allocator.c
static Rm_Allocator *allocatorAdd(Rm_Handle rmHandle, const char *resourceName)
{
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
- Rm_Allocator *allocators = rmInst->allocators;
+ Rm_Allocator *allocators = rmInst->u.server.allocators;
Rm_Allocator *newAllocator = NULL;
newAllocator = Rm_osalMalloc(sizeof(Rm_Allocator));
allocators->nextAllocator = newAllocator;
}
else {
- rmInst->allocators = newAllocator;
+ rmInst->u.server.allocators = newAllocator;
}
}
return (newAllocator);
static int32_t allocatorDelete(Rm_Handle rmHandle, char *resourceName)
{
Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
- Rm_Allocator *allocator = rmInst->allocators;
+ Rm_Allocator *allocator = rmInst->u.server.allocators;
Rm_Allocator *prevAllocator = NULL;
int32_t retVal = RM_OK;
if (allocator) {
if (prevAllocator == NULL) {
- rmInst->allocators = allocator->nextAllocator;
+ rmInst->u.server.allocators = allocator->nextAllocator;
}
else {
prevAllocator->nextAllocator = allocator->nextAllocator;
@@ -410,7 +410,7 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
if (nodePassesPolicy && (matchingNode->allocationCount > 0)) {
policyCheckCfg.validInstNode = opInfo->serviceSrcInstNode;
- if (allocatorResNodeIsOwnedBy(matchingNode, rmPolicyGetLinuxInstNode(rmInst->validInstances))) {
+ if (allocatorResNodeIsOwnedBy(matchingNode, rmPolicyGetLinuxInstNode(rmInst->u.server.globalValidInstTree))) {
/* Check if instance requesting resource has privileges to share
* a resource already reserved by Linux */
policyCheckCfg.type = Rm_policyCheck_SHARED_LINUX;
@@ -515,7 +515,7 @@ static int32_t allocatorAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator, in
matchingEnd = matchingNode->base + matchingNode->length - 1;
if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {
- if (opInfo->serviceSrcInstNode == rmPolicyGetLinuxInstNode(rmInst->validInstances)) {
+ if (opInfo->serviceSrcInstNode == rmPolicyGetLinuxInstNode(rmInst->u.server.globalValidInstTree)) {
/* Bypass policy checks since Linux Kernel has full privileges */
allocPassesPolicy = true;
}
@@ -538,7 +538,7 @@ static int32_t allocatorAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator, in
if (!allocatorResNodeIsOwnedBy(matchingNode, opInfo->serviceSrcInstNode)) {
if (allocPassesPolicy && (matchingNode->allocationCount > 0)) {
- if (allocatorResNodeIsOwnedBy(matchingNode, rmPolicyGetLinuxInstNode(rmInst->validInstances))) {
+ if (allocatorResNodeIsOwnedBy(matchingNode, rmPolicyGetLinuxInstNode(rmInst->u.server.globalValidInstTree))) {
/* Check if instance requesting resource has privileges to share
* a resource already reserved by Linux */
policyCheckCfg.type = Rm_policyCheck_SHARED_LINUX;
@@ -973,6 +973,9 @@ static int32_t allocatorReserveLinuxResource(Rm_Handle rmHandle, Rm_LinuxAlias *
else {
/* Allocate resource to Linux */
retVal = rmAllocatorOperation(rmHandle, opInfo);
+ if (retVal == RM_SERVICE_APPROVED) {
+ retVal = RM_OK;
+ }
}
return (retVal);
}
@@ -1007,8 +1010,8 @@ static int32_t allocatorFindLinuxResource(Rm_Handle rmHandle, const char *resour
memset((void *) &resourceInfo, 0, sizeof(Rm_ResourceInfo));
strncpy(resourceInfo.name, resourceName, RM_NAME_MAX_CHARS);
- opInfo.policy = rmInst->policy;
- opInfo.serviceSrcInstNode = rmPolicyGetLinuxInstNode(rmInst->validInstances);
+ opInfo.policy = rmInst->u.server.globalPolicy;
+ opInfo.serviceSrcInstNode = rmPolicyGetLinuxInstNode(rmInst->u.server.globalValidInstTree);
opInfo.operation = Rm_allocatorOp_ALLOCATE;
opInfo.resourceInfo = &resourceInfo;
@@ -1128,7 +1131,7 @@ static int32_t allocatorExtractGrlResProps(Rm_Handle rmHandle, const char *resou
nsAssignmentBasePtr = nsAssignments;
while (nsAssignments) {
memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
- nameServerObjCfg.nameServerTree = rmInst->nameServer;
+ nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
nameServerObjCfg.nodeCfg.objName = nsAssignments->nsName;
nameServerObjCfg.nodeCfg.resourceName = (char *)resourceName;
nameServerObjCfg.nodeCfg.resourceBase= nsAssignments->resourceBase;
@@ -1148,96 +1151,6 @@ static int32_t allocatorExtractGrlResProps(Rm_Handle rmHandle, const char *resou
return(retVal);
}
-/* FUNCTION PURPOSE: Recursively parses GRL resource properties
- ***********************************************************************
- * DESCRIPTION: Recursively parses and stores GRL resource node
- * properties using the LIBFDT APIs
- */
-static int32_t allocatorParseGrlResProp(void *globalResourceDtb, int32_t offset,
- Rm_ResourceProperties *propertyInfo)
-{
- int32_t propertyLen;
- const char *propertyName;
- const void *propertyData;
- Rm_ResourcePropType propertyType;
- int32_t retVal = RM_OK;
-
- propertyData = fdt_getprop_by_offset(globalResourceDtb, offset, &propertyName, &propertyLen);
- propertyType = rmDtbUtilResGetPropertyType(propertyName);
- if (propertyType == Rm_resourcePropType_RESOURCE_RANGE) {
- propertyInfo->rangeData = propertyData;
- propertyInfo->rangeLen = propertyLen;
- }
- else if (propertyType == Rm_resourcePropType_NSASSIGNMENT) {
- propertyInfo->nsAssignData = propertyData;
- propertyInfo->nsAssignLen = propertyLen;
- }
- else if (propertyType == Rm_resourcePropType_RESOURCE_LINUX_ALIAS) {
- propertyInfo->linuxAliasData = propertyData;
- propertyInfo->linuxAliasLen = propertyLen;
- }
- else {
- retVal = RM_ERROR_GRL_UNKNOWN_RESOURCE_PROPERTY;
- }
-
- if (retVal == RM_OK) {
- offset = fdt_next_property_offset(globalResourceDtb, offset);
- if (offset >= 0) {
- retVal = allocatorParseGrlResProp(globalResourceDtb, offset, propertyInfo);
- }
- else if (offset != -FDT_ERR_NOTFOUND) {
- /* Error returned by LIBFDT */
- retVal = offset;
- }
- }
- return (retVal);
-}
-
-/* FUNCTION PURPOSE: Recursively parses GRL resource nodes
- ***********************************************************************
- * DESCRIPTION: Recursively parses GRL resource nodes looking for
- * resource properties to create the resource allocators.
- * The LIBFDT APIs are used to parse the GRL.
- */
-static int32_t allocatorParseGrlResNode(Rm_Handle rmHandle, void *globalResourceDtb, int32_t nodeOffset,
- int32_t depth, void *linuxDtb)
-{
- const char *resourceName = fdt_get_name(globalResourceDtb, nodeOffset, NULL);
- Rm_ResourceProperties resourceProperties;
- int32_t retVal = RM_OK;
- int32_t offset;
-
- memset((void *)&resourceProperties, 0, sizeof(Rm_ResourceProperties));
- /* Get properties of resource node */
- offset = fdt_first_property_offset(globalResourceDtb, nodeOffset);
- if (offset >= RM_DTB_UTIL_STARTING_NODE_OFFSET) {
- retVal = allocatorParseGrlResProp(globalResourceDtb, offset, &resourceProperties);
- if (retVal < -FDT_ERR_NOTFOUND) {
- return (retVal);
- }
- if (retVal = allocatorExtractGrlResProps(rmHandle, resourceName, &resourceProperties, linuxDtb) < RM_OK) {
- return (retVal);
- }
- }
- else if (offset != -FDT_ERR_NOTFOUND) {
- /* Error returned by LIBFDT */
- return (offset);
- }
-
- offset = fdt_next_node(globalResourceDtb, nodeOffset, &depth);
- if ((offset >= RM_DTB_UTIL_STARTING_NODE_OFFSET) && (depth >= RM_DTB_UTIL_STARTING_DEPTH)) {
- retVal = allocatorParseGrlResNode(rmHandle, globalResourceDtb, offset, depth, linuxDtb);
- if (retVal < -FDT_ERR_NOTFOUND) {
- return (retVal);
- }
- }
- else if (offset < -FDT_ERR_NOTFOUND) {
- /* Error returned by LIBFDT */
- return (offset);
- }
- return (retVal);
-}
-
/**********************************************************************
********************** Internal Functions ****************************
**********************************************************************/
int32_t retVal;
resourceOffsetInPolicy = rmPolicyGetResourceOffset(opInfo->policy, opInfo->resourceInfo->name);
- allocator = rmAllocatorFind(rmInst->allocators, opInfo->resourceInfo->name);
+ allocator = rmAllocatorFind(rmInst->u.server.allocators, opInfo->resourceInfo->name);
if ((resourceOffsetInPolicy > 0) && allocator) {
if (opInfo->operation == Rm_allocatorOp_PRE_ALLOCATE) {
@@ -1300,14 +1213,70 @@ int32_t rmAllocatorOperation(Rm_Handle rmHandle, Rm_AllocatorOpInfo *opInfo)
*/
int32_t rmAllocatorInitializeResources(Rm_Handle rmHandle, void *globalResourceDtb, void *linuxDtb)
{
- int32_t nodeOffset = RM_DTB_UTIL_STARTING_NODE_OFFSET;
- int32_t startDepth = RM_DTB_UTIL_STARTING_DEPTH;
- int32_t result = RM_OK;
-
- /* Recursively parse the Global Resource List, creating an allocator for
- * each resource as specified in the node */
- result = allocatorParseGrlResNode(rmHandle, globalResourceDtb, nodeOffset, startDepth, linuxDtb);
+ int32_t nodeOffset = RM_DTB_UTIL_STARTING_NODE_OFFSET;
+ int32_t nodeDepth = RM_DTB_UTIL_STARTING_DEPTH;
+ Rm_ResourceProperties resProperties;
+ int32_t propOffset;
+ int32_t propertyLen;
+ const char *propertyName;
+ const void *propertyData;
+ Rm_ResourcePropType propertyType;
+ int32_t retVal = RM_OK;
- return(result);
+ /* Parse the Global Resource List, creating an allocator for each specified resource node */
+ while ((nodeOffset >= RM_DTB_UTIL_STARTING_NODE_OFFSET) && (nodeDepth >= RM_DTB_UTIL_STARTING_DEPTH)) {
+ memset((void *)&resProperties, 0, sizeof(Rm_ResourceProperties));
+ /* Get properties of resource node */
+ propOffset = fdt_first_property_offset(globalResourceDtb, nodeOffset);
+ while (propOffset >= RM_DTB_UTIL_STARTING_NODE_OFFSET) {
+ propertyData = fdt_getprop_by_offset(globalResourceDtb, propOffset, &propertyName, &propertyLen);
+ propertyType = rmDtbUtilResGetPropertyType(propertyName);
+ if (propertyType == Rm_resourcePropType_RESOURCE_RANGE) {
+ resProperties.rangeData = propertyData;
+ resProperties.rangeLen = propertyLen;
+ }
+ else if (propertyType == Rm_resourcePropType_NSASSIGNMENT) {
+ resProperties.nsAssignData = propertyData;
+ resProperties.nsAssignLen = propertyLen;
+ }
+ else if (propertyType == Rm_resourcePropType_RESOURCE_LINUX_ALIAS) {
+ resProperties.linuxAliasData = propertyData;
+ resProperties.linuxAliasLen = propertyLen;
+ }
+ else {
+ retVal = RM_ERROR_GRL_UNKNOWN_RESOURCE_PROPERTY;
+ goto exitAllocInit;
+ }
+
+ propOffset = fdt_next_property_offset(globalResourceDtb, propOffset);
+ if (propOffset == -FDT_ERR_NOTFOUND) {
+ /* No more resource properties but at least one found. Extract the property values */
+ retVal = allocatorExtractGrlResProps(rmHandle, fdt_get_name(globalResourceDtb, nodeOffset, NULL),
+ &resProperties, linuxDtb);
+ if (retVal < RM_OK) {
+ goto exitAllocInit;
+ }
+ }
+ else if (propOffset < -FDT_ERR_NOTFOUND) {
+ /* Error returned by LIBFDT */
+ retVal = propOffset;
+ goto exitAllocInit;
+ }
+ }
+ if (propOffset < -FDT_ERR_NOTFOUND) {
+ /* Error returned by LIBFDT */
+ retVal = propOffset;
+ goto exitAllocInit;
+ }
+
+ nodeOffset = fdt_next_node(globalResourceDtb, nodeOffset, &nodeDepth);
+ if (nodeOffset < -FDT_ERR_NOTFOUND) {
+ /* Error returned by LIBFDT */
+ retVal = nodeOffset;
+ goto exitAllocInit;
+ }
+ }
+exitAllocInit:
+ return(retVal);
}
diff --git a/src/rm_nameserver.c b/src/rm_nameserver.c
index b6293fc74a1609cbf6009bea6cc5a6fa76b48f63..3b6a3a76afd6106bdf9dcf1725d815450677d4d1 100644 (file)
--- a/src/rm_nameserver.c
+++ b/src/rm_nameserver.c
return(rootEntry);
}
+/* FUNCTION PURPOSE: Deletes the NameServer tree
+ ***********************************************************************
+ * DESCRIPTION: Removes all objects from the NameServer tree
+ * and deletes the NameServer tree root node.
+ */
+void rmNameServerDelete(Rm_NameServerTree *nameServerTree)
+{
+ Rm_NameServerNode *node;
+ Rm_NameServerObjCfg objCfg;
+
+ RB_FOREACH(node, _Rm_NameServerTree, nameServerTree) {
+ objCfg.nameServerTree = nameServerTree;
+ objCfg.nodeCfg.objName = node->objName;
+ rmNameServerDeleteObject(&objCfg);
+ }
+ if (RB_MIN(_Rm_NameServerTree, nameServerTree) == NULL) {
+ /* No more object nodes in tree */
+ Rm_osalFree((void *)nameServerTree, sizeof(Rm_NameServerTree));
+ }
+}
+