]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - include/rm_nameserverloc.h
Bug fixes, cleanup, expanded test code
[keystone-rtos/rm-lld.git] / include / rm_nameserverloc.h
1 /*
2  *  file  rm_nameserverloc.h
3  *
4  *  Prototypes and data structures for the Resource Manager NameServer.
5  *
6  *  ============================================================================
7  *      (C) Copyright 2012, Texas Instruments, Inc.
8  * 
9  *  Redistribution and use in source and binary forms, with or without 
10  *  modification, are permitted provided that the following conditions 
11  *  are met:
12  *
13  *    Redistributions of source code must retain the above copyright 
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  *    Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the 
18  *    documentation and/or other materials provided with the   
19  *    distribution.
20  *
21  *    Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
29  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
31  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
34  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  *  \par
38 */
40 #ifndef RM_NAMESERVERLOC_H_
41 #define RM_NAMESERVERLOC_H_
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 /* RM external includes */
48 #include <ti/drv/rm/rm.h>
50 /* RM internal includes */
51 #include <ti/drv/rm/include/rm_loc.h>
53 /* AVL BBST includes */
54 #include <ti/drv/rm/include/tree.h>
56 #define RM_NS_ACTION_APPROVED 0
57 #define RM_NS_OBJECT_FOUND 1
58 #define RM_NS_OBJECT_NOT_FOUND 2
60 #define RM_NS_ACTION_DENIED -1
61 #define RM_NS_ERROR_NAME_ALREADY_EXISTS -2
62 #define RM_NS_ERROR_NAME_DOES_NOT_EXIST -3
64 int32_t Rm_nsInit(Rm_Inst *rmInst);
65 int32_t Rm_nsAddObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
66 void Rm_nsPrintObjects(Rm_Inst *rmInst);
67 int32_t Rm_nsFindObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
68 int32_t Rm_nsDeleteObject(Rm_Inst *rmInst, Rm_ResourceInfo *resourceInfo);
70 /**********************************************************************
71  ******************* Red-Black Tree BBST Defines **********************
72  **********************************************************************/
74 /* Declare the tree structure nodes */
75 typedef struct _Rm_NameServerNode {
76     RB_ENTRY(_Rm_NameServerNode) linkage;
77     char name[RM_RESOURCE_NAME_MAX_CHARS];
78     uint32_t base;
79     uint32_t length;
80 } Rm_NameServerNode;
82 /* Declare the tree head structure. */
83 typedef RB_HEAD(_Rm_NameServerTree, _Rm_NameServerNode) Rm_NameServerTree;
85 Rm_NameServerNode *Rm_newNameServerNode(char *name, uint32_t resourceBase, 
86                                         uint32_t resourceLength);
87 void Rm_freeNameServerNode(Rm_NameServerNode *node);
88 /* Prototype for NameServer node comparison function
89  * element1 < element2 --> return < 0
90  * element1 = element2 --> return 0
91  * element1 > element2 --> return > 0 */
92 int Rm_NameServerNodeCompare(Rm_NameServerNode *element1, Rm_NameServerNode *element2); 
94 /* Generate the tree prototypes */
95 RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, Rm_NameServerNodeCompare);
97 #ifdef __cplusplus
98 }
99 #endif
101 #endif /* RM_NAMESERVERLOC_H_ */