]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blobdiff - include/rm_loc.h
.gitignore left out k2e/k2l makefile
[keystone-rtos/rm-lld.git] / include / rm_loc.h
index 5806800691c46278ab838e97c519974c3e896f6e..dd6539ff6f938771ad989acc9ba25a64e3ae7964 100644 (file)
@@ -4,7 +4,7 @@
  *  General private data structures of Resource Manager.
  *
  *  ============================================================================
- *      (C) Copyright 2012, Texas Instruments, Inc.
+ *      (C) Copyright 2012-2013, Texas Instruments, Inc.
  * 
  *  Redistribution and use in source and binary forms, with or without 
  *  modification, are permitted provided that the following conditions 
  *  \par
 */
 
-#ifndef RMLOC_H_
-#define RMLOC_H_
+#ifndef RM_LOC_H_
+#define RM_LOC_H_
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /* RM external includes */
+#include <ti/drv/rm/rm.h>
 #include <ti/drv/rm/rm_services.h>
-#include <ti/drv/rm/rm_transport.h>
-
-/* AVL BBST includes */
-#include <ti/drv/rm/include/tree.h>
-
-/** Maximum size of a transmittable RM policy in bytes */
-#define RM_MAX_POLICY_SIZE_BYTES (64)  // Placeholder: This will change 
-                                       // during development
-
-/** Pointer to RM instance's transport routing map */
-typedef void *Rm_TransportRouteMap;
-
-/** Pointer to RM instance's transaction queue */
-typedef void *Rm_TransactionQueue;
-
-/** Pointer to the RM instance's allocators */
-typedef void *Rm_Allocators;
-
-/** Pointer to the RM instance's NameServer (Valid only on Server) */
-typedef void *Rm_NameServer;
-
-/** Pointer to the RM instance's policy information */
-typedef void *Rm_Policy;
-
-/** Pointer to the RM instance's valid policy instances */
-typedef void *Rm_PolicyValidInstances;
 
+/* RM internal includes */
+#include <ti/drv/rm/include/rm_internal.h>
+#include <ti/drv/rm/include/rm_allocatorloc.h>
+#include <ti/drv/rm/include/rm_policyloc.h>
+#include <ti/drv/rm/include/rm_transportloc.h>
+#include <ti/drv/rm/include/rm_nameserverloc.h>
+#include <ti/drv/rm/include/rm_treeloc.h>
+
+/* Service transaction linked list node */
+typedef struct Rm_Transaction_s {
+    /* Transaction service type */
+    Rm_ServiceType           type;
+    /* Local ID of the transaction. */
+    uint32_t                 localId;
+    /* ID of transaction in RM instance that generated the
+     * packet that resulted in the creation of the transaction.  The
+     * originating ID will be placed in the transaction's response packet
+     * The RM instance that receives the response will 
+     * match the response packet with the originating request using the ID */
+    uint32_t                 remoteOriginatingId;
+    /* Transaction response mechanism union */
+    union {
+        /* Service callback function if received locally via Service API */
+        Rm_ServiceCallback   callback;
+        /* Transport handle to send response packet on if received via Transport rcv API */
+        Rm_Transport        *respTrans;
+    } u;
+    /* Transaction state.  The codes are defined in rm.h */
+    int32_t                  state;
+    /* Transaction has been forwarded to CD or Server instance.  Waiting for response */
+    int8_t                   hasBeenForwarded;
+    /* The transaction ID for a transaction pending on a CD while this
+     * transaction is sent to the Server as a request for data required to complete
+     * pending transaction */
+    uint32_t                 pendingTransactionId;
+    /* Name of the RM instance the service originated from */
+    char                     serviceSrcInstName[RM_NAME_MAX_CHARS];    
+    /* Resource information */
+    Rm_ResourceInfo          resourceInfo;
+    /* Link to the next transaction in the queue */
+    struct Rm_Transaction_s *nextTransaction;    
+} Rm_Transaction;
 
-/**
- * @brief RM protocol packet resource information
- */
+/* Server-specific instance data */
 typedef struct {
-    /** Resource name of resource affected by command */
-    char     name[RM_RESOURCE_NAME_MAX_CHARS];
-    /** If applicable, start of resource range affected by command.  If
-     *  RM_RESOURCE_UNSPECIFIED is assigned the higher level RM agent*/
-    int32_t  base;
-    /** If applicable, number of specified resource, starting from base, affected by command */
-    uint32_t length;
-    /** If applicable, the alignment of the resource affected by the command */
-    int32_t  alignment;
-    /** If applicable, the NameServer name assigned to the specified
-     *  resource.  Used for commands centering on RM NameServer actions */
-    char     nsName[RM_RESOURCE_NAME_MAX_CHARS];
-} Rm_ResourceInfo;
-
-/**
- * @brief RM transactions are the internalized version of service requests received 
- *        from components and RM commands received from other RM instances.
- *        Transactions that cannot immediately be serviced are placed in the RM
- *        instance's transaction queue.  The transactions track all service
- *        requests within the RM infrastructure.
- */
+    /* Pointer to the global policy */
+    void                   *globalPolicy;
+    /* Policy size in bytes */
+    uint32_t                policySize;
+    /* 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 {
-    /** Transaction service type */
-    Rm_ServiceType type;
-    /** Local ID of the transaction. */
-    uint32_t localId;
-    /** ID of transaction in RM instance that generated the
-     *  packet that resulted in the creation of the transaction.  The
-     *  originating ID will be placed in the transaction's response packet
-     *  to the lower level RM instance.  The lower level RM instance will 
-     *  match the response packet with the originating request using the ID */
-    uint32_t remoteOriginatingId;
-    /** Name of the RM instance the RM packet, that spawned the transaction,
-     *  originated from */
-    char pktSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];
-    /** Transaction's associated callback function */
-    Rm_ServiceCallback callback;
-    /** Transaction state.  The codes are externally visible and tracked
-     *  in rmservices.h */
-    int32_t state;
-    /** Name of the RM instance the service originated from */
-    char serviceSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];    
-    /** Resource information */
-    Rm_ResourceInfo resourceInfo;
-    /** Link to the next transaction in the queue */
-    void *nextTransaction;    
-} Rm_Transaction;
-
+    /* Pointer to the cd policy if provided */
+    void                   *cdPolicy;
+    /* Pointer to the root entry of the valid instance tree
+     * extracted from the cd policy */
+    Rm_PolicyValidInstTree *cdValidInstTree;
+    /* Pointer to the linked list of allocators */
+    Rm_Allocator           *allocators;    
+} Rm_ClientDelegateInstData;
+
+/* Client-specific instance data */
 typedef struct {
-    const void *rangeData;
-    int32_t     rangeLen;
-    const void *nsAssignData;
-    int32_t     nsAssignLen;
-    const void *linuxAliasData;
-    int32_t     linuxAliasLen;
-} Rm_ResourceProperties;
-
-typedef enum {
-    Rm_allocatorOp_ALLOCATE = 0,
-    Rm_allocatorOp_FREE,
-    Rm_allocatorOp_PRE_ALLOCATE
-} Rm_AllocatorOp;
-
+    /* 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;
+
+/* Shared Client-specific instance data */
 typedef struct {
-    void            *serviceSrcInstNode;
-    Rm_AllocatorOp   operation;
-    uint32_t         allocType;
-    Rm_ResourceInfo *resourceInfo;
-} Rm_AllocatorOpInfo;
-
-typedef struct Rm_Allocator_s {
-    char resourceName[RM_RESOURCE_NAME_MAX_CHARS];
-    /** Pointer to the first resource entry in the allocator */
-    void *allocatorRootEntry;
-    /** Pointer to next resource allocator */
-    struct Rm_Allocator_s *nextAllocator;
-} Rm_Allocator;
+    /* Shared Server instance handle */
+    Rm_Handle sharedServerHandle;
+} Rm_SharedClientInstData;
 
+/* RM instance structure */
 typedef struct {
-    char name[RM_INSTANCE_NAME_MAX_CHARS];
-    Rm_InstType instType;
-    bool registeredWithDelegateOrServer;
-    Rm_Policy policy;
-    Rm_PolicyValidInstances validInstances;    
-    Rm_Allocators allocators;
-    Rm_NameServer nameServer;
-    /* RM instance transport parameters */
-    Rm_TransportRouteMap routeMap;
-    /* RM Transaction sequence number counter */
-    uint32_t transactionSeqNum;
-    /* RM transaction queue */
-    Rm_TransactionQueue transactionQueue;
-    /* Transport API function pointers - not global in case application wants to
-      * hook up different transports to RM */
-    Rm_TransportCallouts transport;
+    /* 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];
+    /* Instance type */
+    Rm_InstType       instType;
+    /* Instance lock status.  Instance locks if static request fails when
+     * checked against global policy */
+    int8_t            isLocked;
+    /* Tracks whether the instance has registered with a CD or Server.
+     * Applicable to CD and Client instances */
+    int8_t            registeredWithDelegateOrServer;    
+    /* Pointer to the serviceHandle opened from the instance */
+    Rm_ServiceHandle *serviceHandle;
+    /* Linked list of transports registered by the application */
+    Rm_Transport     *transports;
+    /* Service transaction sequence number tracker */
+    uint32_t          transactionSeqNum;
+    /* Service transaction linked list queue */
+    Rm_Transaction   *transactionQueue; 
+    /* Block handle provided through OSAL for when RM needs to block due to
+     * a service request that requires a blocking operation to complete and
+     * a service callback function has not been provided */
+    void             *blockHandle;
+    /* 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;
+        /* Shared Client-specific instance data */
+        Rm_SharedClientInstData   sharedClient;
+    } u;
 } Rm_Inst;
 
-Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst);
-Rm_Transaction *Rm_transactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
-int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
-uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst);
-
-Rm_Allocator *Rm_allocatorFind(Rm_Inst *rmInst, char *resourceName);
-
-void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction);
-void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction);
-void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
-
-/**********************************************************************
- ******************* Red-Black Tree BBST Defines **********************
- **********************************************************************/
-
-/* Declare the tree structure nodes */
-typedef struct Rm_AllocatedTo_s {
-    void                    *instNameNode;
-    struct Rm_AllocatedTo_s *nextAllocatedTo;
-} Rm_AllocatedTo;
-
-typedef struct _Rm_ResourceNode {
-    RB_ENTRY(_Rm_ResourceNode)  linkage;
-    uint32_t                    base;
-    uint32_t                    length;
-    uint16_t                    allocationCount;
-    Rm_AllocatedTo             *allocatedTo;
-} Rm_ResourceNode;
-
-/* Declare the tree head structure.  A structure of type Rm_ResourceTree will need to be
- * malloc'd for each tree that is to be created. */
-typedef RB_HEAD(_Rm_ResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
-
-Rm_ResourceNode *Rm_newResourceNode(uint32_t resourceBase, uint32_t resourceLength);
-void Rm_freeResourceNode(Rm_ResourceNode *node);
-/* Prototype for tree node comparison function
- * element1 < element2 --> return < 0
- * element1 = element2 --> return 0
- * element1 > element2 --> return > 0 */
-int Rm_ResourceNodeCompare(Rm_ResourceNode *element1, Rm_ResourceNode *element2); 
-
-/* Generate the tree prototypes */
-RB_PROTOTYPE(_Rm_ResourceTree, _Rm_ResourceNode, linkage, Rm_ResourceNodeCompare);
+Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
+Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
+int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
+void rmProcessRouter(Rm_Inst *rmInst, Rm_Transaction *transaction);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* RMLOC_H_ */
+#endif /* RM_LOC_H_ */