resource: add configurable 'fifo' and 'lifo' ordering to application classes
[profile/ivi/murphy.git] / src / resource / data-types.h
1 /*
2  * Copyright (c) 2012, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *  * Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *  * Neither the name of Intel Corporation nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __MURPHY_DATA_TYPES_H__
31 #define __MURPHY_DATA_TYPES_H__
32
33 #include <stdint.h>
34 #include <stdbool.h>
35
36 #include <murphy-db/mqi-types.h>
37
38 #define MRP_ZONE_MAX            8
39
40 #define MRP_KEY_STAMP_BITS      27
41 #define MRP_KEY_STATE_BITS      1
42 #define MRP_KEY_USAGE_BITS      1
43 #define MRP_KEY_PRIORITY_BITS   3
44
45 #define MRP_ZONE_ID_INVALID        (~(uint32_t)0)
46 #define MRP_RESOURCE_ID_INVALID    (~(uint32_t)0)
47 #define MRP_RESOURCE_REQNO_INVALID (~(uint32_t)0)
48
49 #define MRP_RESOURCE_MAX  (sizeof(mrp_resource_mask_t) * 8)
50 #define MRP_ATTRIBUTE_MAX (sizeof(mrp_attribute_mask_t) * 8)
51
52 typedef enum   mrp_resource_state_e     mrp_resource_state_t;
53 typedef enum   mrp_resource_order_e     mrp_resource_order_t;
54 typedef enum   mrp_resource_access_e    mrp_resource_access_t;
55
56 typedef struct mrp_resource_client_s    mrp_resource_client_t;
57 typedef union  mrp_attr_value_u         mrp_attr_value_t;
58 typedef struct mrp_attr_def_s           mrp_attr_def_t;
59 typedef struct mrp_attr_s               mrp_attr_t;
60 typedef struct mrp_zone_def_s           mrp_zone_def_t;
61 typedef struct mrp_zone_s               mrp_zone_t;
62 typedef struct mrp_application_class_s  mrp_application_class_t;
63 typedef struct mrp_resource_owner_s     mrp_resource_owner_t;
64 typedef struct mrp_resource_set_s       mrp_resource_set_t;
65 typedef struct mrp_resource_def_s       mrp_resource_def_t;
66 typedef struct mrp_resource_s           mrp_resource_t;
67 typedef struct mrp_resource_mgr_ftbl_s  mrp_resource_mgr_ftbl_t;
68 typedef struct mrp_resource_mgr_s       mrp_resource_mgr_t;
69
70 typedef struct mrp_resource_ownersref_s mrp_resource_ownersref_t;
71 typedef struct mrp_resource_setref_s    mrp_resource_setref_t;
72
73 typedef uint32_t                        mrp_resource_mask_t;
74 typedef uint32_t                        mrp_attribute_mask_t;
75
76
77 enum mrp_resource_state_e {
78     mrp_resource_no_request = 0,
79     mrp_resource_release,
80     mrp_resource_acquire,
81 };
82
83
84 enum mrp_resource_access_e {
85     MRP_RESOURCE_ACCESS_NONE  = 0,
86     MRP_RESOURCE_READ  = 1,
87     MRP_RESOURCE_WRITE = 2,
88     MRP_RESOURCE_RW    = (MRP_RESOURCE_READ | MRP_RESOURCE_WRITE)
89 };
90
91 enum mrp_resource_order_e {
92     MRP_RESOURCE_ORDER_UNKNOWN = 0,
93     MRP_RESOURCE_ORDER_FIFO,
94     MRP_RESOURCE_ORDER_LIFO
95 };
96
97 union mrp_attr_value_u {
98     const char  *string;
99     int32_t      integer;
100     uint32_t     unsignd;
101     double       floating;
102 };
103
104 struct mrp_attr_def_s {
105     const char            *name;
106     mrp_resource_access_t  access;
107     mqi_data_type_t        type;
108     mrp_attr_value_t       value;
109 };
110
111 struct mrp_attr_s {
112     const char      *name;
113     mqi_data_type_t  type;
114     mrp_attr_value_t value;
115 };
116
117
118 typedef void (*mrp_resource_event_cb_t)(uint32_t, mrp_resource_set_t *, void*);
119
120 typedef void (*mrp_manager_init_func_t)(mrp_zone_t *, void *);
121 typedef bool (*mrp_manager_alloc_func_t)(mrp_zone_t *,mrp_resource_t *,void*);
122 typedef void (*mrp_manager_free_func_t)(mrp_zone_t *,mrp_resource_t *,void *);
123 typedef bool (*mrp_manager_advice_func_t)(mrp_zone_t *,mrp_resource_t*,void *);
124 typedef void (*mrp_manager_commit_func_t)(mrp_zone_t *, void *);
125
126 struct mrp_resource_mgr_ftbl_s  {
127     mrp_manager_init_func_t     init;
128     mrp_manager_alloc_func_t    allocate;
129     mrp_manager_free_func_t     free;
130     mrp_manager_advice_func_t   advice;
131     mrp_manager_commit_func_t   commit;
132 };
133
134
135
136 #endif  /* __MURPHY_DATA_TYPES_H__ */
137
138 /*
139  * Local Variables:
140  * c-basic-offset: 4
141  * indent-tabs-mode: nil
142  * End:
143  *
144  */