4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * This is the DSP API RM module interface.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 #include <dspbridge/cfgdefs.h>
23 #include <dspbridge/devdefs.h>
24 #include <dspbridge/drv.h>
27 * ======== proc_attach ========
29 * Prepare for communication with a particular DSP processor, and return
30 * a handle to the processor object. The PROC Object gets created
32 * processor_id : The processor index (zero-based).
33 * hmgr_obj : Handle to the Manager Object
34 * attr_in : Ptr to the dsp_processorattrin structure.
35 * A NULL value means use default values.
36 * ph_processor : Ptr to location to store processor handle.
39 * -EPERM : General failure.
40 * -EFAULT : Invalid processor handle.
41 * 0: Success; Processor already attached.
43 * ph_processor != NULL.
46 * -EPERM, and *ph_processor == NULL, OR
47 * Success and *ph_processor is a Valid Processor handle OR
48 * 0 and *ph_processor is a Valid Processor.
50 * When attr_in is NULL, the default timeout value is 10 seconds.
52 extern int proc_attach(u32 processor_id,
53 const struct dsp_processorattrin
54 *attr_in, void **ph_processor,
55 struct process_context *pr_ctxt);
58 * ======== proc_auto_start =========
60 * A Particular device gets loaded with the default image
61 * if the AutoStart flag is set.
63 * hdev_obj : Handle to the Device
65 * 0 : On Successful Loading
66 * -ENOENT : No DSP exec file found.
67 * -EPERM : General Failure
70 * dev_node_obj != NULL.
74 extern int proc_auto_start(struct cfg_devnode *dev_node_obj,
75 struct dev_object *hdev_obj);
78 * ======== proc_ctrl ========
80 * Pass control information to the GPP device driver managing the DSP
81 * processor. This will be an OEM-only function, and not part of the
82 * 'Bridge application developer's API.
84 * hprocessor : The processor handle.
85 * dw_cmd : Private driver IOCTL cmd ID.
86 * pargs : Ptr to an driver defined argument structure.
89 * -EFAULT : Invalid processor handle.
90 * -ETIME: A Timeout Occurred before the Control information
92 * -EPERM : General Failure.
97 * This function Calls bridge_dev_ctrl.
99 extern int proc_ctrl(void *hprocessor,
100 u32 dw_cmd, struct dsp_cbdata *arg);
103 * ======== proc_detach ========
105 * Close a DSP processor and de-allocate all (GPP) resources reserved
106 * for it. The Processor Object is deleted.
108 * pr_ctxt : The processor handle.
111 * -EFAULT : InValid Handle.
112 * -EPERM : General failure.
116 * PROC Object is destroyed.
118 extern int proc_detach(struct process_context *pr_ctxt);
121 * ======== proc_enum_nodes ========
123 * Enumerate the nodes currently allocated on a processor.
125 * hprocessor : The processor handle.
126 * node_tab : The first Location of an array allocated for node
128 * node_tab_size: The number of (DSP_HNODE) handles that can be held
129 * to the memory the client has allocated for node_tab
130 * pu_num_nodes : Location where DSPProcessor_EnumNodes will return
131 * the number of valid handles written to node_tab
132 * pu_allocated : Location where DSPProcessor_EnumNodes will return
133 * the number of nodes that are allocated on the DSP.
136 * -EFAULT : Invalid processor handle.
137 * -EINVAL : The amount of memory allocated for node_tab is
138 * insufficent. That is the number of nodes actually
139 * allocated on the DSP is greater than the value
140 * specified for node_tab_size.
141 * -EPERM : Unable to get Resource Information.
144 * pu_num_nodes is not NULL.
145 * pu_allocated is not NULL.
146 * node_tab is not NULL.
151 extern int proc_enum_nodes(void *hprocessor,
158 * ======== proc_get_resource_info ========
160 * Enumerate the resources currently available on a processor.
162 * hprocessor : The processor handle.
163 * resource_type: Type of resource .
164 * resource_info: Ptr to the dsp_resourceinfo structure.
165 * resource_info_size: Size of the structure.
168 * -EFAULT : Invalid processor handle.
169 * -EBADR: The processor is not in the PROC_RUNNING state.
170 * -ETIME: A timeout occurred before the DSP responded to the
172 * -EPERM : Unable to get Resource Information
174 * resource_info is not NULL.
175 * Parameter resource_type is Valid.[TBD]
176 * resource_info_size is >= sizeof dsp_resourceinfo struct.
180 * This function currently returns
181 * -ENOSYS, and does not write any data to the resource_info struct.
183 extern int proc_get_resource_info(void *hprocessor,
185 struct dsp_resourceinfo
187 u32 resource_info_size);
190 * ======== proc_get_dev_object =========
192 * Returns the DEV Hanlde for a given Processor handle
194 * hprocessor : Processor Handle
195 * device_obj : Location to store the DEV Handle.
197 * 0 : Success; *device_obj has Dev handle
198 * -EPERM : Failure; *device_obj is zero.
200 * device_obj is not NULL
203 * 0 : *device_obj is not NULL
204 * -EPERM : *device_obj is NULL.
206 extern int proc_get_dev_object(void *hprocessor,
207 struct dev_object **device_obj);
210 * ======== proc_get_state ========
212 * Report the state of the specified DSP processor.
214 * hprocessor : The processor handle.
215 * proc_state_obj : Ptr to location to store the dsp_processorstate
217 * state_info_size: Size of dsp_processorstate.
220 * -EFAULT : Invalid processor handle.
221 * -EPERM : General failure while querying processor state.
223 * proc_state_obj is not NULL
224 * state_info_size is >= than the size of dsp_processorstate structure.
229 extern int proc_get_state(void *hprocessor, struct dsp_processorstate
230 *proc_state_obj, u32 state_info_size);
233 * ======== PROC_GetProcessorID ========
235 * Report the state of the specified DSP processor.
237 * hprocessor : The processor handle.
238 * proc_id : Processor ID
242 * -EFAULT : Invalid processor handle.
243 * -EPERM : General failure while querying processor state.
245 * proc_state_obj is not NULL
246 * state_info_size is >= than the size of dsp_processorstate structure.
251 extern int proc_get_processor_id(void *proc, u32 * proc_id);
254 * ======== proc_get_trace ========
256 * Retrieve the trace buffer from the specified DSP processor.
258 * hprocessor : The processor handle.
259 * pbuf : Ptr to buffer to hold trace output.
260 * max_size : Maximum size of the output buffer.
263 * -EFAULT : Invalid processor handle.
264 * -EPERM : General failure while retrieving processor trace
273 extern int proc_get_trace(void *hprocessor, u8 * pbuf, u32 max_size);
276 * ======== proc_load ========
278 * Reset a processor and load a new base program image.
279 * This will be an OEM-only function.
281 * hprocessor: The processor handle.
282 * argc_index: The number of Arguments(strings)in the aArgV[]
283 * user_args: An Array of Arguments(Unicode Strings)
284 * user_envp: An Array of Environment settings(Unicode Strings)
287 * -ENOENT: The DSP Executable was not found.
288 * -EFAULT: Invalid processor handle.
289 * -EPERM : Unable to Load the Processor
291 * user_args is not NULL
295 * Success and ProcState == PROC_LOADED
296 * or DSP_FAILED status.
298 * Does not implement access rights to control which GPP application
299 * can load the processor.
301 extern int proc_load(void *hprocessor,
302 const s32 argc_index, const char **user_args,
303 const char **user_envp);
306 * ======== proc_register_notify ========
308 * Register to be notified of specific processor events
310 * hprocessor : The processor handle.
311 * event_mask : Mask of types of events to be notified about.
312 * notify_type : Type of notification to be sent.
313 * hnotification: Handle to be used for notification.
316 * -EFAULT : Invalid processor handle or hnotification.
317 * -EINVAL : Parameter event_mask is Invalid
318 * DSP_ENOTIMP : The notification type specified in uNotifyMask
320 * -EPERM : Unable to register for notification.
322 * hnotification is not NULL
327 extern int proc_register_notify(void *hprocessor,
328 u32 event_mask, u32 notify_type,
329 struct dsp_notification
333 * ======== proc_notify_clients ========
335 * Notify the Processor Clients
337 * proc : The processor handle.
338 * events : Event to be notified about.
341 * -EFAULT : Invalid processor handle.
342 * -EPERM : Failure to Set or Reset the Event
344 * events is Supported or Valid type of Event
345 * proc is a valid handle
349 extern int proc_notify_clients(void *proc, u32 events);
352 * ======== proc_notify_all_clients ========
354 * Notify the Processor Clients
356 * proc : The processor handle.
357 * events : Event to be notified about.
360 * -EFAULT : Invalid processor handle.
361 * -EPERM : Failure to Set or Reset the Event
363 * events is Supported or Valid type of Event
364 * proc is a valid handle
368 * NODE And STRM would use this function to notify their clients
369 * about the state changes in NODE or STRM.
371 extern int proc_notify_all_clients(void *proc, u32 events);
374 * ======== proc_start ========
376 * Start a processor running.
377 * Processor must be in PROC_LOADED state.
378 * This will be an OEM-only function, and not part of the 'Bridge
379 * application developer's API.
381 * hprocessor : The processor handle.
384 * -EFAULT : Invalid processor handle.
385 * -EBADR: Processor is not in PROC_LOADED state.
386 * -EPERM : Unable to start the processor.
390 * Success and ProcState == PROC_RUNNING or DSP_FAILED status.
393 extern int proc_start(void *hprocessor);
396 * ======== proc_stop ========
398 * Start a processor running.
399 * Processor must be in PROC_LOADED state.
400 * This will be an OEM-only function, and not part of the 'Bridge
401 * application developer's API.
403 * hprocessor : The processor handle.
406 * -EFAULT : Invalid processor handle.
407 * -EBADR: Processor is not in PROC_LOADED state.
408 * -EPERM : Unable to start the processor.
412 * Success and ProcState == PROC_RUNNING or DSP_FAILED status.
415 extern int proc_stop(void *hprocessor);
418 * ======== proc_end_dma ========
420 * Begin a DMA transfer
422 * hprocessor : The processor handle.
423 * pmpu_addr : Buffer start address
424 * ul_size : Buffer size
425 * dir : The direction of the transfer
427 * Memory was previously mapped.
429 extern int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
430 enum dma_data_direction dir);
432 * ======== proc_begin_dma ========
434 * Begin a DMA transfer
436 * hprocessor : The processor handle.
437 * pmpu_addr : Buffer start address
438 * ul_size : Buffer size
439 * dir : The direction of the transfer
441 * Memory was previously mapped.
443 extern int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
444 enum dma_data_direction dir);
447 * ======== proc_flush_memory ========
449 * Flushes a buffer from the MPU data cache.
451 * hprocessor : The processor handle.
452 * pmpu_addr : Buffer start address
453 * ul_size : Buffer size
454 * ul_flags : Reserved.
457 * -EFAULT : Invalid processor handle.
458 * -EPERM : General failure.
463 * All the arguments are currently ignored.
465 extern int proc_flush_memory(void *hprocessor,
466 void *pmpu_addr, u32 ul_size, u32 ul_flags);
469 * ======== proc_invalidate_memory ========
471 * Invalidates a buffer from the MPU data cache.
473 * hprocessor : The processor handle.
474 * pmpu_addr : Buffer start address
475 * ul_size : Buffer size
478 * -EFAULT : Invalid processor handle.
479 * -EPERM : General failure.
484 * All the arguments are currently ignored.
486 extern int proc_invalidate_memory(void *hprocessor,
487 void *pmpu_addr, u32 ul_size);
490 * ======== proc_map ========
492 * Maps a MPU buffer to DSP address space.
494 * hprocessor : The processor handle.
495 * pmpu_addr : Starting address of the memory region to map.
496 * ul_size : Size of the memory region to map.
497 * req_addr : Requested DSP start address. Offset-adjusted actual
498 * mapped address is in the last argument.
499 * pp_map_addr : Ptr to DSP side mapped u8 address.
500 * ul_map_attr : Optional endianness attributes, virt to phys flag.
503 * -EFAULT : Invalid processor handle.
504 * -EPERM : General failure.
505 * -ENOMEM : MPU side memory allocation error.
506 * -ENOENT : Cannot find a reserved region starting with this
509 * pmpu_addr is not NULL
510 * ul_size is not zero
511 * pp_map_addr is not NULL
516 extern int proc_map(void *hprocessor,
520 void **pp_map_addr, u32 ul_map_attr,
521 struct process_context *pr_ctxt);
524 * ======== proc_reserve_memory ========
526 * Reserve a virtually contiguous region of DSP address space.
528 * hprocessor : The processor handle.
529 * ul_size : Size of the address space to reserve.
530 * pp_rsv_addr : Ptr to DSP side reserved u8 address.
533 * -EFAULT : Invalid processor handle.
534 * -EPERM : General failure.
535 * -ENOMEM : Cannot reserve chunk of this size.
537 * pp_rsv_addr is not NULL
542 extern int proc_reserve_memory(void *hprocessor,
543 u32 ul_size, void **pp_rsv_addr,
544 struct process_context *pr_ctxt);
547 * ======== proc_un_map ========
549 * Removes a MPU buffer mapping from the DSP address space.
551 * hprocessor : The processor handle.
552 * map_addr : Starting address of the mapped memory region.
555 * -EFAULT : Invalid processor handle.
556 * -EPERM : General failure.
557 * -ENOENT : Cannot find a mapped region starting with this
560 * map_addr is not NULL
565 extern int proc_un_map(void *hprocessor, void *map_addr,
566 struct process_context *pr_ctxt);
569 * ======== proc_un_reserve_memory ========
571 * Frees a previously reserved region of DSP address space.
573 * hprocessor : The processor handle.
574 * prsv_addr : Ptr to DSP side reservedBYTE address.
577 * -EFAULT : Invalid processor handle.
578 * -EPERM : General failure.
579 * -ENOENT : Cannot find a reserved region starting with this
582 * prsv_addr is not NULL
587 extern int proc_un_reserve_memory(void *hprocessor,
589 struct process_context *pr_ctxt);