summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 00edf74)
raw | patch | inline | side by side (parent: 00edf74)
author | Justin Sobota <jsobota@ti.com> | |
Tue, 15 Jan 2013 22:47:51 +0000 (17:47 -0500) | ||
committer | Justin Sobota <jsobota@ti.com> | |
Tue, 15 Jan 2013 22:47:51 +0000 (17:47 -0500) |
include/rm_loc.h | patch | blob | history | |
include/rm_policyloc.h | patch | blob | history | |
rm.h | patch | blob | history | |
src/rm.c | patch | blob | history | |
src/rm_policy.c | patch | blob | history |
diff --git a/include/rm_loc.h b/include/rm_loc.h
index f1d651341040cc1982dcad7c9b2fc468da4d5f89..efb5f07aef10dbee4e03a84594a73a96190115cc 100644 (file)
--- a/include/rm_loc.h
+++ b/include/rm_loc.h
**********************************************************************/
/* Declare the tree structure nodes */
+typedef struct Rm_AllocatedTo_s {
+ char instName[RM_INSTANCE_NAME_MAX_CHARS];
+ struct Rm_AllocatedTo_s *nextAllocatedTo;
+} Rm_AllocatedTo;
+
typedef struct _Rm_ResourceNode {
RB_ENTRY(_Rm_ResourceNode) linkage;
uint32_t base;
uint32_t length;
- char allocatedTo[RM_INSTANCE_NAME_MAX_CHARS];
+ Rm_AllocatedTo *allocatedTo;
} Rm_ResourceNode;
/* Declare the tree head structure. A structure of type Rm_ResourceTree will need to be
diff --git a/include/rm_policyloc.h b/include/rm_policyloc.h
index a7592c252dc91448d5121642f7aae90dea07bb3f..b51e746803764a55c99c49ea8c80869d953cc2af 100644 (file)
--- a/include/rm_policyloc.h
+++ b/include/rm_policyloc.h
/* Bit : Description
*-----------------------------
- * 0 : Init (iI) - RM instance has initialization permission for resource
- * 1 : Use (uU) - RM instance has usage permission for resource
- * 2 : Exclusive (xX) - RM instance has exclusive allocation privilege for resource
- * i.e. No other RM instance can reserve the resource if a RM
- * instance with exclusive privilege reserves the resource
- * 3 - 15 : UNUSED
+ * 0 : Init (iI) - RM instance has initialization permission for resource
+ * 1 : Use (uU) - RM instance has usage permission for resource
+ * 2 : Exclusive (xX) - RM instance has exclusive allocation privilege for resource
+ * i.e. No other RM instance can reserve the resource if a RM
+ * instance with exclusive privilege reserves the resource
+ * 3 : Shared Linux (sS) - Resource has been reserved by the Linux kernel but can be
+ * allocated by the specified RM instances
+ * 4 - 15 : UNUSED
*/
typedef uint16_t Rm_PermissionBits;
#define RM_POLICY_PERM_EXCLUSIVE_LOWER 'x'
#define RM_POLICY_PERM_EXCLUSIVE_UPPER 'X'
#define RM_POLICY_PERM_EXCLUSIVE_SHIFT 2
+#define RM_POLICY_PERM_SHARED_LINUX_LOWER 's'
+#define RM_POLICY_PERM_SHARED_LINUX_UPPER 'S'
+#define RM_POLICY_PERM_SHARED_LINUX_SHIFT 3
#define RM_POLICY_PERM_SUBGROUP_START '('
#define RM_POLICY_PERM_SUBGROUP_END ')'
index c9d08257e370a67a01379bd3c50ed932e09eb5ce..d5f2cb23c62f92cbc37d36ae57f93555090a3e6c 100644 (file)
--- a/rm.h
+++ b/rm.h
#define RM_INIT_OK 0
#define RM_INIT_ERROR_INSTANCE_NAME_TOO_BIG -256
#define RM_INIT_ERROR_POLICY_NO_VALID_INSTANCES_DEFINED -257
-#define RM_INIT_ERROR_POLICY_UNKNOWN_VALID_INSTANCE -258
+#define RM_INIT_ERROR_POLICY_UNKNOWN_INSTANCE -258
#define RM_INIT_ERROR_POLICY_PERMISSION_SYNTAX_ERROR -259
#define RM_INIT_ERROR_POLICY_UNKNOWN_RESOURCE -260
#define RM_INIT_ERROR_POLICY_SYNTAX_ERROR - 261
diff --git a/src/rm.c b/src/rm.c
index 43a54602c6e31d7fccf0fc973348f2efc818832c..64d79f07d8891390a6cbb90442fbcd24805e460a 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
/* Populate the RM relevant fields */\r
newNode->base = resourceBase;\r
newNode->length = resourceLength;\r
- strcpy(newNode->allocatedTo, allocatedTo);\r
+ newNode->allocatedTo = Rm_osalMalloc(sizeof(Rm_AllocatedTo);\r
+ strcpy(newNode->allocatedTo->instName, allocatedTo);\r
+ newNode->allocatedTo->nextAllocatedTo = NULL;\r
\r
return(newNode);\r
}\r
diff --git a/src/rm_policy.c b/src/rm_policy.c
index 2118e224669270d1482fbc5bce17cd0e4fdde0a1..f741468a790a287ea4a515abbc289e2ba196fd14 100644 (file)
--- a/src/rm_policy.c
+++ b/src/rm_policy.c
/* RM OSAL layer */
#include <rm_osal.h>
+char Rm_policyAllInstances[] = "*";
+
int32_t Rm_policyCheckInstances(Rm_PolicyValidInst *validInstList,
Rm_PolicyPermission *permissionsList)
{
+ Rm_PolicyValidInst *validInst = validInstList;
+ Rm_PolicyPermission *permission = permissionsList;
+ bool instNameMatch = FALSE;
+
+ /* Check each instance name in the permission list against the list of valid instance
+ * names. Return an error if any permission instance name is not in the valid instance
+ * name list */
+ while (permission)
+ {
+ /* Instantly declare a name match if the permission's instance name is the "all"
+ * wildcard */
+ if (strcmp(permission->instName, Rm_policyAllInstances) == 0)
+ {
+ instNameMatch = TRUE;
+ }
+ else
+ {
+ while (validInst)
+ {
+ if (strcmp(permission->instName, validInst->instName) == 0)
+ {
+ instNameMatch = TRUE;
+ }
+ validInst = validInst->nextValidInst;
+ }
+ }
+ if (!instNameMatch)
+ {
+ return(RM_INIT_ERROR_POLICY_UNKNOWN_INSTANCE);
+ }
+
+ /* Get the next permission and reset to the beginning of the valid instance list */
+ permission = permission->nextPermission;
+ validInst = validInstList;
+ instNameMatch = FALSE;
+ }
+
return(RM_INIT_OK);
}
@@ -116,9 +155,10 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
instNameIndex = 0;
foundInstName = FALSE;
instNameComplete = FALSE;
- while (permStrPtr < subgroupEnd)
+ while (permStrPtr <= subgroupEnd)
{
- if (isspace(*permStrPtr) && foundInstName)
+ if ((isspace(*permStrPtr) || (*permStrPtr == RM_POLICY_PERM_SUBGROUP_END))
+ && foundInstName)
{
/* First space encountered after copying an instance name. This
* terminates the instance name. All other space characters are
@@ -202,25 +242,47 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
if ((*permStrPtr == RM_POLICY_PERM_INIT_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_INIT_UPPER))
{
-
- /* Set the init permissions */
- RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
- permStrPtr++;
+ /* Set the init permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
}
else if ((*permStrPtr == RM_POLICY_PERM_USE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_USE_UPPER))
{
- /* Set the use permissions */
- RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
- permStrPtr++;
+ /* Set the use permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
}
else if ((*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_UPPER))
{
- /* Set the exclusive permissions */
- RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
- permStrPtr++;
+ /* Set the exclusive permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
}
+ else if ((*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_LOWER) ||
+ (*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_UPPER))
+ {
+ /* Set the shared Linux permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_SHARED_LINUX_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
+ }
else
{
/* Invalid permission character. This is a
@@ -289,25 +351,47 @@ Rm_PolicyPermission *Rm_policyParseSubPermission(char *permStrStart, char *permS
if ((*permStrPtr == RM_POLICY_PERM_INIT_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_INIT_UPPER))
{
-
- /* Set the init permissions */
- RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
- permStrPtr++;
+ /* Set the init permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_INIT_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
}
else if ((*permStrPtr == RM_POLICY_PERM_USE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_USE_UPPER))
{
- /* Set the use permissions */
- RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
- permStrPtr++;
+ /* Set the use permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_USE_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
}
else if ((*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_LOWER) ||
(*permStrPtr == RM_POLICY_PERM_EXCLUSIVE_UPPER))
{
- /* Set the exclusive permissions */
- RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
- permStrPtr++;
+ /* Set the exclusive permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_EXCLUSIVE_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
}
+ else if ((*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_LOWER) ||
+ (*permStrPtr == RM_POLICY_PERM_SHARED_LINUX_UPPER))
+ {
+ /* Set the shared Linux permissions for each of the instances specified in the group */
+ newPerm = startPerm;
+ while (newPerm)
+ {
+ RM_POLICY_SET_PERM(newPerm->permissionBits, RM_POLICY_PERM_SHARED_LINUX_SHIFT, 1);
+ newPerm = newPerm->nextPermission;
+ }
+ }
else
{
/* Invalid permission character. This is a