|
| 1 | +/* |
| 2 | + **************************************************************************** |
| 3 | + * Copyright 2011 Broadcom Corporation. All rights reserved. |
| 4 | + * |
| 5 | + * Unless you and Broadcom execute a separate written software license |
| 6 | + * agreement governing use of this software, this software is licensed to you |
| 7 | + * under the terms of the GNU General Public License version 2, available at |
| 8 | + * http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). |
| 9 | + * |
| 10 | + * Notwithstanding the above, under no circumstances may you combine this |
| 11 | + * software in any way with any other Broadcom software provided under a |
| 12 | + * license other than the GPL, without Broadcom's express prior written |
| 13 | + * consent. |
| 14 | + **************************************************************************** |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndef __VC_SM_DEFS_H__INCLUDED__ |
| 18 | +#define __VC_SM_DEFS_H__INCLUDED__ |
| 19 | + |
| 20 | +/* FourCC code used for VCHI connection */ |
| 21 | +#define VC_SM_SERVER_NAME MAKE_FOURCC("SMEM") |
| 22 | + |
| 23 | +/* Maximum message length */ |
| 24 | +#define VC_SM_MAX_MSG_LEN (sizeof(union vc_sm_msg_union_t) + \ |
| 25 | + sizeof(struct vc_sm_msg_hdr_t)) |
| 26 | +#define VC_SM_MAX_RSP_LEN (sizeof(union vc_sm_msg_union_t)) |
| 27 | + |
| 28 | +/* Resource name maximum size */ |
| 29 | +#define VC_SM_RESOURCE_NAME 32 |
| 30 | + |
| 31 | +enum vc_sm_msg_type { |
| 32 | + /* Message types supported for HOST->VC direction */ |
| 33 | + |
| 34 | + /* Allocate shared memory block */ |
| 35 | + VC_SM_MSG_TYPE_ALLOC, |
| 36 | + /* Lock allocated shared memory block */ |
| 37 | + VC_SM_MSG_TYPE_LOCK, |
| 38 | + /* Unlock allocated shared memory block */ |
| 39 | + VC_SM_MSG_TYPE_UNLOCK, |
| 40 | + /* Unlock allocated shared memory block, do not answer command */ |
| 41 | + VC_SM_MSG_TYPE_UNLOCK_NOANS, |
| 42 | + /* Free shared memory block */ |
| 43 | + VC_SM_MSG_TYPE_FREE, |
| 44 | + /* Resize a shared memory block */ |
| 45 | + VC_SM_MSG_TYPE_RESIZE, |
| 46 | + /* Walk the allocated shared memory block(s) */ |
| 47 | + VC_SM_MSG_TYPE_WALK_ALLOC, |
| 48 | + |
| 49 | + /* A previously applied action will need to be reverted */ |
| 50 | + VC_SM_MSG_TYPE_ACTION_CLEAN, |
| 51 | + |
| 52 | + /* |
| 53 | + * Import a physical address and wrap into a MEM_HANDLE_T. |
| 54 | + * Release with VC_SM_MSG_TYPE_FREE. |
| 55 | + */ |
| 56 | + VC_SM_MSG_TYPE_IMPORT, |
| 57 | + |
| 58 | + /* Message types supported for VC->HOST direction */ |
| 59 | + |
| 60 | + /* |
| 61 | + * VC has finished with an imported memory allocation. |
| 62 | + * Release any Linux reference counts on the underlying block. |
| 63 | + */ |
| 64 | + VC_SM_MSG_TYPE_RELEASED, |
| 65 | + |
| 66 | + VC_SM_MSG_TYPE_MAX |
| 67 | +}; |
| 68 | + |
| 69 | +/* Type of memory to be allocated */ |
| 70 | +enum vc_sm_alloc_type_t { |
| 71 | + VC_SM_ALLOC_CACHED, |
| 72 | + VC_SM_ALLOC_NON_CACHED, |
| 73 | +}; |
| 74 | + |
| 75 | +/* Message header for all messages in HOST->VC direction */ |
| 76 | +struct vc_sm_msg_hdr_t { |
| 77 | + int32_t type; |
| 78 | + uint32_t trans_id; |
| 79 | + uint8_t body[0]; |
| 80 | + |
| 81 | +}; |
| 82 | + |
| 83 | +/* Request to allocate memory (HOST->VC) */ |
| 84 | +struct vc_sm_alloc_t { |
| 85 | + /* type of memory to allocate */ |
| 86 | + enum vc_sm_alloc_type_t type; |
| 87 | + /* byte amount of data to allocate per unit */ |
| 88 | + uint32_t base_unit; |
| 89 | + /* number of unit to allocate */ |
| 90 | + uint32_t num_unit; |
| 91 | + /* alignement to be applied on allocation */ |
| 92 | + uint32_t alignement; |
| 93 | + /* identity of who allocated this block */ |
| 94 | + uint32_t allocator; |
| 95 | + /* resource name (for easier tracking on vc side) */ |
| 96 | + char name[VC_SM_RESOURCE_NAME]; |
| 97 | + |
| 98 | +}; |
| 99 | + |
| 100 | +/* Result of a requested memory allocation (VC->HOST) */ |
| 101 | +struct vc_sm_alloc_result_t { |
| 102 | + /* Transaction identifier */ |
| 103 | + uint32_t trans_id; |
| 104 | + |
| 105 | + /* Resource handle */ |
| 106 | + uint32_t res_handle; |
| 107 | + /* Pointer to resource buffer */ |
| 108 | + uint32_t res_mem; |
| 109 | + /* Resource base size (bytes) */ |
| 110 | + uint32_t res_base_size; |
| 111 | + /* Resource number */ |
| 112 | + uint32_t res_num; |
| 113 | + |
| 114 | +}; |
| 115 | + |
| 116 | +/* Request to free a previously allocated memory (HOST->VC) */ |
| 117 | +struct vc_sm_free_t { |
| 118 | + /* Resource handle (returned from alloc) */ |
| 119 | + uint32_t res_handle; |
| 120 | + /* Resource buffer (returned from alloc) */ |
| 121 | + uint32_t res_mem; |
| 122 | + |
| 123 | +}; |
| 124 | + |
| 125 | +/* Request to lock a previously allocated memory (HOST->VC) */ |
| 126 | +struct vc_sm_lock_unlock_t { |
| 127 | + /* Resource handle (returned from alloc) */ |
| 128 | + uint32_t res_handle; |
| 129 | + /* Resource buffer (returned from alloc) */ |
| 130 | + uint32_t res_mem; |
| 131 | + |
| 132 | +}; |
| 133 | + |
| 134 | +/* Request to resize a previously allocated memory (HOST->VC) */ |
| 135 | +struct vc_sm_resize_t { |
| 136 | + /* Resource handle (returned from alloc) */ |
| 137 | + uint32_t res_handle; |
| 138 | + /* Resource buffer (returned from alloc) */ |
| 139 | + uint32_t res_mem; |
| 140 | + /* Resource *new* size requested (bytes) */ |
| 141 | + uint32_t res_new_size; |
| 142 | + |
| 143 | +}; |
| 144 | + |
| 145 | +/* Result of a requested memory lock (VC->HOST) */ |
| 146 | +struct vc_sm_lock_result_t { |
| 147 | + /* Transaction identifier */ |
| 148 | + uint32_t trans_id; |
| 149 | + |
| 150 | + /* Resource handle */ |
| 151 | + uint32_t res_handle; |
| 152 | + /* Pointer to resource buffer */ |
| 153 | + uint32_t res_mem; |
| 154 | + /* |
| 155 | + * Pointer to former resource buffer if the memory |
| 156 | + * was reallocated |
| 157 | + */ |
| 158 | + uint32_t res_old_mem; |
| 159 | + |
| 160 | +}; |
| 161 | + |
| 162 | +/* Generic result for a request (VC->HOST) */ |
| 163 | +struct vc_sm_result_t { |
| 164 | + /* Transaction identifier */ |
| 165 | + uint32_t trans_id; |
| 166 | + |
| 167 | + int32_t success; |
| 168 | + |
| 169 | +}; |
| 170 | + |
| 171 | +/* Request to revert a previously applied action (HOST->VC) */ |
| 172 | +struct vc_sm_action_clean_t { |
| 173 | + /* Action of interest */ |
| 174 | + enum vc_sm_msg_type res_action; |
| 175 | + /* Transaction identifier for the action of interest */ |
| 176 | + uint32_t action_trans_id; |
| 177 | + |
| 178 | +}; |
| 179 | + |
| 180 | +/* Request to remove all data associated with a given allocator (HOST->VC) */ |
| 181 | +struct vc_sm_free_all_t { |
| 182 | + /* Allocator identifier */ |
| 183 | + uint32_t allocator; |
| 184 | +}; |
| 185 | + |
| 186 | +/* Request to import memory (HOST->VC) */ |
| 187 | +struct vc_sm_import { |
| 188 | + /* type of memory to allocate */ |
| 189 | + enum vc_sm_alloc_type_t type; |
| 190 | + /* pointer to the VC (ie physical) address of the allocated memory */ |
| 191 | + uint32_t addr; |
| 192 | + /* size of buffer */ |
| 193 | + uint32_t size; |
| 194 | + /* opaque handle returned in RELEASED messages */ |
| 195 | + int32_t kernel_id; |
| 196 | + /* Allocator identifier */ |
| 197 | + uint32_t allocator; |
| 198 | + /* resource name (for easier tracking on vc side) */ |
| 199 | + char name[VC_SM_RESOURCE_NAME]; |
| 200 | +}; |
| 201 | + |
| 202 | +/* Result of a requested memory import (VC->HOST) */ |
| 203 | +struct vc_sm_import_result { |
| 204 | + /* Transaction identifier */ |
| 205 | + uint32_t trans_id; |
| 206 | + |
| 207 | + /* Resource handle */ |
| 208 | + uint32_t res_handle; |
| 209 | +}; |
| 210 | + |
| 211 | +/* Notification that VC has finished with an allocation (VC->HOST) */ |
| 212 | +struct vc_sm_released { |
| 213 | + /* pointer to the VC (ie physical) address of the allocated memory */ |
| 214 | + uint32_t addr; |
| 215 | + /* size of buffer */ |
| 216 | + uint32_t size; |
| 217 | + /* opaque handle returned in RELEASED messages */ |
| 218 | + int32_t kernel_id; |
| 219 | +}; |
| 220 | + |
| 221 | +/* Union of ALL messages */ |
| 222 | +union vc_sm_msg_union_t { |
| 223 | + struct vc_sm_alloc_t alloc; |
| 224 | + struct vc_sm_alloc_result_t alloc_result; |
| 225 | + struct vc_sm_free_t free; |
| 226 | + struct vc_sm_lock_unlock_t lock_unlock; |
| 227 | + struct vc_sm_action_clean_t action_clean; |
| 228 | + struct vc_sm_resize_t resize; |
| 229 | + struct vc_sm_lock_result_t lock_result; |
| 230 | + struct vc_sm_result_t result; |
| 231 | + struct vc_sm_free_all_t free_all; |
| 232 | + struct vc_sm_import import; |
| 233 | + struct vc_sm_import_result import_result; |
| 234 | + struct vc_sm_released released; |
| 235 | +}; |
| 236 | + |
| 237 | +#endif /* __VC_SM_DEFS_H__INCLUDED__ */ |
0 commit comments