6 #include <dspbridge/devdefs.h>
8 #include <dspbridge/cmmdefs.h>
9 #include <dspbridge/host_os.h>
12 * ======== cmm_calloc_buf ========
14 * Allocate memory buffers that can be used for data streaming or
17 * hcmm_mgr: Cmm Mgr handle.
18 * usize: Number of bytes to allocate.
19 * pattr: Attributes of memory to allocate.
20 * pp_buf_va: Address of where to place VA.
22 * Pointer to a zero'd block of SM memory;
23 * NULL if memory couldn't be allocated,
24 * or if byte_size == 0,
29 * The returned pointer, if not NULL, points to a valid memory block of
33 extern void *cmm_calloc_buf(struct cmm_object
*hcmm_mgr
,
34 u32 usize
, struct cmm_attrs
*pattrs
,
38 * ======== cmm_create ========
40 * Create a communication memory manager object.
42 * ph_cmm_mgr: Location to store a communication manager handle on
44 * hdev_obj: Handle to a device object.
45 * mgr_attrts: Comm mem manager attributes.
48 * -ENOMEM: Insufficient memory for requested resources.
49 * -EPERM: Failed to initialize critical sect sync object.
52 * cmm_init(void) called.
54 * mgr_attrts->ul_min_block_size >= 4 bytes.
58 extern int cmm_create(struct cmm_object
**ph_cmm_mgr
,
59 struct dev_object
*hdev_obj
,
60 const struct cmm_mgrattrs
*mgr_attrts
);
63 * ======== cmm_destroy ========
65 * Destroy the communication memory manager object.
67 * hcmm_mgr: Cmm Mgr handle.
68 * force: Force deallocation of all cmm memory immediately if set TRUE.
69 * If FALSE, and outstanding allocations will return -EPERM
72 * 0: CMM object & resources deleted.
73 * -EPERM: Unable to free CMM object due to outstanding allocation.
74 * -EFAULT: Unable to free CMM due to bad handle.
79 * Memory resources used by Cmm Mgr are freed.
81 extern int cmm_destroy(struct cmm_object
*hcmm_mgr
, bool force
);
84 * ======== cmm_exit ========
86 * Discontinue usage of module. Cleanup CMM module if CMM cRef reaches zero.
95 extern void cmm_exit(void);
98 * ======== cmm_free_buf ========
100 * Free the given buffer.
102 * hcmm_mgr: Cmm Mgr handle.
103 * pbuf: Pointer to memory allocated by cmm_calloc_buf().
104 * ul_seg_id: SM segment Id used in CMM_Calloc() attrs.
105 * Set to 0 to use default segment.
115 extern int cmm_free_buf(struct cmm_object
*hcmm_mgr
,
116 void *buf_pa
, u32 ul_seg_id
);
119 * ======== cmm_get_handle ========
121 * Return the handle to the cmm mgr for the given device obj.
123 * hprocessor: Handle to a Processor.
124 * ph_cmm_mgr: Location to store the shared memory mgr handle on
128 * 0: Cmm Mgr opaque handle returned.
129 * -EFAULT: Invalid handle.
135 extern int cmm_get_handle(void *hprocessor
,
136 struct cmm_object
**ph_cmm_mgr
);
139 * ======== cmm_get_info ========
141 * Return the current SM and VM utilization information.
143 * hcmm_mgr: Handle to a Cmm Mgr.
144 * cmm_info_obj: Location to store the Cmm information on output.
148 * -EFAULT: Invalid handle.
149 * -EINVAL Invalid input argument.
154 extern int cmm_get_info(struct cmm_object
*hcmm_mgr
,
155 struct cmm_info
*cmm_info_obj
);
158 * ======== cmm_init ========
160 * Initializes private state of CMM module.
163 * TRUE if initialized; FALSE if error occured.
168 extern bool cmm_init(void);
171 * ======== cmm_register_gppsm_seg ========
173 * Register a block of SM with the CMM.
175 * hcmm_mgr: Handle to a Cmm Mgr.
176 * lpGPPBasePA: GPP Base Physical address.
177 * ul_size: Size in GPP bytes.
178 * dsp_addr_offset GPP PA to DSP PA Offset.
179 * c_factor: Add offset if CMM_ADDTODSPPA, sub if CMM_SUBFROMDSPPA.
180 * dw_dsp_base: DSP virtual base byte address.
181 * ul_dsp_size: Size of DSP segment in bytes.
182 * sgmt_id: Address to store segment Id.
186 * -EFAULT: Invalid hcmm_mgr handle.
187 * -EINVAL: Invalid input argument.
188 * -EPERM: Unable to register.
189 * - On success *sgmt_id is a valid SM segment ID.
193 * dw_gpp_base_pa != 0
194 * c_factor = CMM_ADDTODSPPA || c_factor = CMM_SUBFROMDSPPA
198 extern int cmm_register_gppsm_seg(struct cmm_object
*hcmm_mgr
,
199 unsigned int dw_gpp_base_pa
,
203 unsigned int dw_dsp_base
,
205 u32
*sgmt_id
, u32 gpp_base_va
);
208 * ======== cmm_un_register_gppsm_seg ========
210 * Unregister the given memory segment that was previously registered
211 * by cmm_register_gppsm_seg.
213 * hcmm_mgr: Handle to a Cmm Mgr.
214 * ul_seg_id Segment identifier returned by cmm_register_gppsm_seg.
217 * -EFAULT: Invalid handle.
218 * -EINVAL: Invalid ul_seg_id.
219 * -EPERM: Unable to unregister for unknown reason.
224 extern int cmm_un_register_gppsm_seg(struct cmm_object
*hcmm_mgr
,
228 * ======== cmm_xlator_alloc_buf ========
230 * Allocate the specified SM buffer and create a local memory descriptor.
231 * Place on the descriptor on the translator's HaQ (Host Alloc'd Queue).
233 * xlator: Handle to a Xlator object.
234 * va_buf: Virtual address ptr(client context)
235 * pa_size: Size of SM memory to allocate.
237 * Ptr to valid physical address(Pa) of pa_size bytes, NULL if failed.
244 extern void *cmm_xlator_alloc_buf(struct cmm_xlatorobject
*xlator
,
245 void *va_buf
, u32 pa_size
);
248 * ======== cmm_xlator_create ========
250 * Create a translator(xlator) object used for process specific Va<->Pa
251 * address translation. Node messaging and streams use this to perform
252 * inter-processor(GPP<->DSP) zero-copy data transfer.
254 * xlator: Address to place handle to a new Xlator handle.
255 * hcmm_mgr: Handle to Cmm Mgr associated with this translator.
256 * xlator_attrs: Translator attributes used for the client NODE or STREAM.
259 * -EINVAL: Bad input Attrs.
260 * -ENOMEM: Insufficient memory(local) for requested resources.
264 * xlator_attrs != NULL
268 extern int cmm_xlator_create(struct cmm_xlatorobject
**xlator
,
269 struct cmm_object
*hcmm_mgr
,
270 struct cmm_xlatorattrs
*xlator_attrs
);
273 * ======== cmm_xlator_delete ========
275 * Delete translator resources
277 * xlator: handle to translator.
278 * force: force = TRUE will free XLators SM buffers/dscriptrs.
281 * -EFAULT: Bad translator handle.
282 * -EPERM: Unable to free translator resources.
288 extern int cmm_xlator_delete(struct cmm_xlatorobject
*xlator
,
292 * ======== cmm_xlator_free_buf ========
294 * Free SM buffer and descriptor.
295 * Does not free client process VM.
297 * xlator: handle to translator.
298 * buf_va Virtual address of PA to free.
301 * -EFAULT: Bad translator handle.
306 extern int cmm_xlator_free_buf(struct cmm_xlatorobject
*xlator
,
310 * ======== cmm_xlator_info ========
312 * Set/Get process specific "translator" address info.
313 * This is used to perform fast virtaul address translation
314 * for shared memory buffers between the GPP and DSP.
316 * xlator: handle to translator.
317 * paddr: Virtual base address of segment.
318 * ul_size: Size in bytes.
319 * segm_id: Segment identifier of SM segment(s)
320 * set_info Set xlator fields if TRUE, else return base addr
323 * -EFAULT: Bad translator handle.
331 extern int cmm_xlator_info(struct cmm_xlatorobject
*xlator
,
333 u32 ul_size
, u32 segm_id
, bool set_info
);
336 * ======== cmm_xlator_translate ========
338 * Perform address translation VA<->PA for the specified stream or
339 * message shared memory buffer.
341 * xlator: handle to translator.
342 * paddr address of buffer to translate.
343 * xtype Type of address xlation. CMM_PA2VA or CMM_VA2PA.
345 * Valid address on success, else NULL.
349 * xtype >= CMM_VA2PA) && (xtype <= CMM_DSPPA2PA)
353 extern void *cmm_xlator_translate(struct cmm_xlatorobject
*xlator
,
354 void *paddr
, enum cmm_xlatetype xtype
);