]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blobdiff - include/rm_policyloc.h
.gitignore left out k2e/k2l makefile
[keystone-rtos/rm-lld.git] / include / rm_policyloc.h
index dc7fbf9daf4dba4e30b32364b6b93bebbe3050a6..96ccbc2300e6919a782ef667a27cb7de7cff7669 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  file  rm_policyloc.h
  *
- *  Prototypes and data structures for the Resource Manager Policies.
+ *  Internal prototypes and data structures for the Resource Manager Policies.
  *
  *  ============================================================================
  *      (C) Copyright 2012-2013, Texas Instruments, Inc.
@@ -50,86 +50,117 @@ extern "C" {
 /* RM internal includes */
 #include <ti/drv/rm/include/rm_treeloc.h>
 
-/** String stored for resource elements that are reserved by the Linux kernel.  These
- *  resources will be in use for the lifetime of the system 
+/* String stored for resource elements that are reserved by the Linux kernel.  These
+ * resources will be in use for the lifetime of the system 
  *
- * TODO: MOVE TO policy.h LATER SO INTEGRATORS KNOW NOT TO NAME RM INSTANCES THIS NAME*/
+ * TODO: MOVE TO policy.h LATER SO INTEGRATORS KNOW NOT TO NAME RM INSTANCES THIS NAME */
 #define RM_ALLOCATED_TO_LINUX "Linux-Kernel"
 
-/* Bit : Description
+/* Policy permission bit storage type
+ * 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  : Shared Linux (sS) - Resource has been reserved by the Linux kernel but can be
- *                           allocated by the specified RM instances
+ *  0  : Init         (i) - RM instance has initialization permission for resource
+ *  1  : Use          (u) - RM instance has usage permission for resource
+ *  2  : Exclusive    (x) - 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 (s) - Resource has been reserved by the Linux kernel but can be
+ *                          allocated by the specified RM instances
  *  4 - 15 : UNUSED
  */
 typedef uint16_t Rm_PolicyPermBits;
 
+/* Initialization permission characters */
 #define RM_POLICY_PERM_INIT_LOWER         'i'
 #define RM_POLICY_PERM_INIT_UPPER         'I'
+/* Initialization permission bit shift */
 #define RM_POLICY_PERM_INIT_SHIFT          0
+/* Usage permission characters */
 #define RM_POLICY_PERM_USE_LOWER          'u'
 #define RM_POLICY_PERM_USE_UPPER          'U'
+/* Usage permission bit shift */
 #define RM_POLICY_PERM_USE_SHIFT           1
+/* Exclusive permission characters */
 #define RM_POLICY_PERM_EXCLUSIVE_LOWER    'x'
 #define RM_POLICY_PERM_EXCLUSIVE_UPPER    'X'
+/* Exclusive permission bit shift */
 #define RM_POLICY_PERM_EXCLUSIVE_SHIFT     2
+/* Shared Linux permission characters */
 #define RM_POLICY_PERM_SHARED_LINUX_LOWER 's'
 #define RM_POLICY_PERM_SHARED_LINUX_UPPER 'S'
+/* Shared Linux permission bit shift */
 #define RM_POLICY_PERM_SHARED_LINUX_SHIFT  3
 
+/* Permissions subgroup start character */
 #define RM_POLICY_PERM_SUBGROUP_START     '('
+/* Permissions subgroup end character */
 #define RM_POLICY_PERM_SUBGROUP_END       ')'
+/* Permissions subgroup terminator */
 #define RM_POLICY_PERM_TERMINATOR         '&'
+/* Permissions assignment character */
 #define RM_POLICY_PERM_ASSIGNMENT         '='
 
+/* Macro to set permissions in a Rm_PolicyPermBits type */
 #define RM_policy_SET_PERM(permBits, permTypeShift, val) \
     permBits = ((permBits & (~(((Rm_PolicyPermBits) 0x1) << permTypeShift))) | \
                ((((Rm_PolicyPermBits) val) & 0x1) << permTypeShift))
+/* Macro to get permissions from Rm_PolicyPermBits type */               
 #define RM_policy_GET_PERM(permBits, permTypeShift) \
     ((permBits >> permTypeShift) & 0x1)
 
+/* Assigned instance permissions linked list node */
 typedef struct Rm_Permission_s {
+    /* Instance name of instance assigned the permissions */
     char                    instName[RM_NAME_MAX_CHARS];
+    /* Permissions assigned to the RM instance with instName */
     Rm_PolicyPermBits       permissionBits;
+    /* Next permissions node */
     struct Rm_Permission_s *nextPermission;
 } Rm_PolicyPermission;
 
-/**********************************************************************
- *********************** Internal Policy APIs *************************
- **********************************************************************/
-
+/* Permission validation types */
 typedef enum {
+    /* Validate exclusive permissions for a resource */
     Rm_policyCheck_EXCLUSIVE = 0,
+    /* Validate initialization permissions for a resource */
     Rm_policyCheck_INIT,
-    Rm_policyCheck_USE
+    /* Validate usage permissions for a resource */
+    Rm_policyCheck_USE,
+    /* Validate shared Linux permissions for a resource */
+    Rm_policyCheck_SHARED_LINUX
 } Rm_PolicyCheckType;
 
+/* Permissions validation configuration structure */
 typedef struct {
+    /* The type of validation to perform */
     Rm_PolicyCheckType      type;
+    /* Policy to validate the permission check against */
     void                   *policyDtb;
+    /* Valid instance node that will have its permissions checked for 
+     * the defined resource */
     Rm_PolicyValidInstNode *validInstNode;
+    /* Resource node offset in the policy DTB */
     int32_t                 resourceOffset;
+    /* Resource base to validate permissions for the valid instance node */
     uint32_t                resourceBase;
+    /* Resource length to validate permissions for the valid instance node */
     uint32_t                resourceLength;
 } Rm_PolicyCheckCfg;
 
-Rm_PolicyValidInstNode *rmPolicyGetValidInstNode(Rm_PolicyValidInstTree *validInstTree, char *instName);
-Rm_PolicyValidInstNode *rmPolicyGetLinuxInstNode(Rm_PolicyValidInstTree *validInstTree);
-bool     rmPolicyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result);
+void *rmPolicyGetPolicy(Rm_Handle rmHandle);
+Rm_PolicyValidInstNode *rmPolicyGetValidInstNode(Rm_Handle rmHandle, char *instName);
+Rm_PolicyValidInstNode *rmPolicyGetLinuxInstNode(Rm_Handle rmHandle);
+int rmPolicyCheckPrivilege(Rm_PolicyCheckCfg *privilegeCfg, int32_t *result);
 uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validInstNode, 
-                                 int32_t resourceOffset, uint32_t allocType, 
+                                 int32_t resourceOffset, Rm_PolicyCheckType policyCheckType, 
                                  int32_t *result);
 uint32_t rmPolicyGetResourceAlignment(void *policyDtb, int32_t resourceOffset);
-int32_t  rmPolicyGetResourceOffset(void *policyDtb, char *resourceName);
-int32_t  rmPolicyValidatePolicyResourceNames(void *policyDtb, void *allocatorList);
-int32_t  rmPolicyValidatePolicy(void *policyDtb, Rm_PolicyValidInstTree *validInstTree);
-Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(void *policyDtb, bool addLinux, int32_t *result);
-void     rmPolicyFreeValidInstTree(Rm_PolicyValidInstTree *validInstTree);
+uint32_t rmPolicyGetResourceCdAllocSize(void *policyDtb, int32_t resourceOffset);
+int32_t rmPolicyGetResourceOffset(void *policyDtb, char *resourceName);
+int32_t rmPolicyValidatePolicyResourceNames(Rm_Handle rmHandle);
+int32_t rmPolicyValidatePolicy(Rm_Handle rmHandle);
+Rm_PolicyValidInstTree *rmPolicyCreateValidInstTree(Rm_Handle rmHandle, int addLinux, int32_t *result);
+void rmPolicyFreeValidInstTree(Rm_Handle rmHandle);
 
 #ifdef __cplusplus
 }