4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Bridge Bridge driver device operations.
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 /* ----------------------------------- Module Dependent Headers */
23 #include <dspbridge/chnldefs.h>
24 #include <dspbridge/cmm.h>
25 #include <dspbridge/cod.h>
26 #include <dspbridge/dehdefs.h>
27 #include <dspbridge/nodedefs.h>
28 #include <dspbridge/dispdefs.h>
29 #include <dspbridge/dspdefs.h>
30 #include <dspbridge/host_os.h>
32 /* ----------------------------------- This */
33 #include <dspbridge/devdefs.h>
36 * ======== dev_brd_write_fxn ========
38 * Exported function to be used as the COD write function. This function
39 * is passed a handle to a DEV_hObject by ZL in arb, then calls the
40 * device's bridge_brd_write() function.
42 * arb: Handle to a Device Object.
43 * dev_ctxt: Handle to Bridge driver defined device info.
44 * dsp_addr: Address on DSP board (Destination).
45 * host_buf: Pointer to host buffer (Source).
46 * ul_num_bytes: Number of bytes to transfer.
47 * mem_type: Memory space on DSP to which to transfer.
49 * Number of bytes written. Returns 0 if the DEV_hObject passed in via
56 extern u32 dev_brd_write_fxn(void *arb,
58 void *host_buf, u32 ul_num_bytes, u32 mem_space);
61 * ======== dev_create_device ========
63 * Called by the operating system to load the Bridge Driver for a
66 * device_obj: Ptr to location to receive the device object handle.
67 * driver_file_name: Name of Bridge driver PE DLL file to load. If the
68 * absolute path is not provided, the file is loaded
69 * through 'Bridge's module search path.
70 * host_config: Host configuration information, to be passed down
71 * to the Bridge driver when bridge_dev_create() is called.
72 * pDspConfig: DSP resources, to be passed down to the Bridge driver
73 * when bridge_dev_create() is called.
74 * dev_node_obj: Platform specific device node.
76 * 0: Module is loaded, device object has been created
77 * -ENOMEM: Insufficient memory to create needed resources.
78 * -EPERM: Unable to find Bridge driver entry point function.
79 * -ESPIPE: Unable to load ZL DLL.
83 * driver_file_name != NULL.
84 * host_config != NULL.
87 * 0: *device_obj will contain handle to the new device object.
88 * Otherwise, does not create the device object, ensures the Bridge driver
89 * module is unloaded, and sets *device_obj to NULL.
91 extern int dev_create_device(struct dev_object
93 const char *driver_file_name,
94 struct cfg_devnode *dev_node_obj);
97 * ======== dev_create_iva_device ========
99 * Called by the operating system to load the Bridge Driver for IVA.
101 * device_obj: Ptr to location to receive the device object handle.
102 * driver_file_name: Name of Bridge driver PE DLL file to load. If the
103 * absolute path is not provided, the file is loaded
104 * through 'Bridge's module search path.
105 * host_config: Host configuration information, to be passed down
106 * to the Bridge driver when bridge_dev_create() is called.
107 * pDspConfig: DSP resources, to be passed down to the Bridge driver
108 * when bridge_dev_create() is called.
109 * dev_node_obj: Platform specific device node.
111 * 0: Module is loaded, device object has been created
112 * -ENOMEM: Insufficient memory to create needed resources.
113 * -EPERM: Unable to find Bridge driver entry point function.
114 * -ESPIPE: Unable to load ZL DLL.
117 * device_obj != NULL.
118 * driver_file_name != NULL.
119 * host_config != NULL.
120 * pDspConfig != NULL.
122 * 0: *device_obj will contain handle to the new device object.
123 * Otherwise, does not create the device object, ensures the Bridge driver
124 * module is unloaded, and sets *device_obj to NULL.
126 extern int dev_create_iva_device(struct dev_object
128 const char *driver_file_name,
129 const struct cfg_hostres
131 struct cfg_devnode *dev_node_obj);
134 * ======== dev_create2 ========
136 * After successful loading of the image from api_init_complete2
137 * (PROC Auto_Start) or proc_load this fxn is called. This creates
138 * the Node Manager and updates the DEV Object.
140 * hdev_obj: Handle to device object created with dev_create_device().
142 * 0: Successful Creation of Node Manager
143 * -EPERM: Some Error Occurred.
148 * 0 and hdev_obj->hnode_mgr != NULL
149 * else hdev_obj->hnode_mgr == NULL
151 extern int dev_create2(struct dev_object *hdev_obj);
154 * ======== dev_destroy2 ========
156 * Destroys the Node manager for this device.
158 * hdev_obj: Handle to device object created with dev_create_device().
160 * 0: Successful Creation of Node Manager
161 * -EPERM: Some Error Occurred.
166 * 0 and hdev_obj->hnode_mgr == NULL
169 extern int dev_destroy2(struct dev_object *hdev_obj);
172 * ======== dev_destroy_device ========
174 * Destroys the channel manager for this device, if any, calls
175 * bridge_dev_destroy(), and then attempts to unload the Bridge module.
177 * hdev_obj: Handle to device object created with
178 * dev_create_device().
181 * -EFAULT: Invalid hdev_obj.
182 * -EPERM: The Bridge driver failed it's bridge_dev_destroy() function.
187 extern int dev_destroy_device(struct dev_object
191 * ======== dev_get_chnl_mgr ========
193 * Retrieve the handle to the channel manager created for this device.
195 * hdev_obj: Handle to device object created with
196 * dev_create_device().
197 * *mgr: Ptr to location to store handle.
200 * -EFAULT: Invalid hdev_obj.
205 * 0: *mgr contains a handle to a channel manager object,
207 * else: *mgr is NULL.
209 extern int dev_get_chnl_mgr(struct dev_object *hdev_obj,
210 struct chnl_mgr **mgr);
213 * ======== dev_get_cmm_mgr ========
215 * Retrieve the handle to the shared memory manager created for this
218 * hdev_obj: Handle to device object created with
219 * dev_create_device().
220 * *mgr: Ptr to location to store handle.
223 * -EFAULT: Invalid hdev_obj.
228 * 0: *mgr contains a handle to a channel manager object,
230 * else: *mgr is NULL.
232 extern int dev_get_cmm_mgr(struct dev_object *hdev_obj,
233 struct cmm_object **mgr);
236 * ======== dev_get_cod_mgr ========
238 * Retrieve the COD manager create for this device.
240 * hdev_obj: Handle to device object created with
241 * dev_create_device().
242 * *cod_mgr: Ptr to location to store handle.
245 * -EFAULT: Invalid hdev_obj.
250 * 0: *cod_mgr contains a handle to a COD manager object.
251 * else: *cod_mgr is NULL.
253 extern int dev_get_cod_mgr(struct dev_object *hdev_obj,
254 struct cod_manager **cod_mgr);
257 * ======== dev_get_deh_mgr ========
259 * Retrieve the DEH manager created for this device.
261 * hdev_obj: Handle to device object created with dev_create_device().
262 * *deh_manager: Ptr to location to store handle.
265 * -EFAULT: Invalid hdev_obj.
267 * deh_manager != NULL.
270 * 0: *deh_manager contains a handle to a DEH manager object.
271 * else: *deh_manager is NULL.
273 extern int dev_get_deh_mgr(struct dev_object *hdev_obj,
274 struct deh_mgr **deh_manager);
277 * ======== dev_get_dev_node ========
279 * Retrieve the platform specific device ID for this device.
281 * hdev_obj: Handle to device object created with
282 * dev_create_device().
283 * dev_nde: Ptr to location to get the device node handle.
285 * 0: Returns a DEVNODE in *dev_node_obj.
286 * -EFAULT: Invalid hdev_obj.
291 * 0: *dev_nde contains a platform specific device ID;
292 * else: *dev_nde is NULL.
294 extern int dev_get_dev_node(struct dev_object *hdev_obj,
295 struct cfg_devnode **dev_nde);
298 * ======== dev_get_dev_type ========
300 * Retrieve the platform specific device ID for this device.
302 * hdev_obj: Handle to device object created with
303 * dev_create_device().
304 * dev_nde: Ptr to location to get the device node handle.
307 * -EFAULT: Invalid hdev_obj.
312 * 0: *dev_nde contains a platform specific device ID;
313 * else: *dev_nde is NULL.
315 extern int dev_get_dev_type(struct dev_object *device_obj,
319 * ======== dev_get_first ========
321 * Retrieve the first Device Object handle from an internal linked list of
322 * of DEV_OBJECTs maintained by DEV.
325 * NULL if there are no device objects stored; else
326 * a valid DEV_HOBJECT.
328 * No calls to dev_create_device or dev_destroy_device (which my modify the
329 * internal device object list) may occur between calls to dev_get_first
332 * The DEV_HOBJECT returned is valid.
333 * A subsequent call to dev_get_next will return the next device object in
336 extern struct dev_object *dev_get_first(void);
339 * ======== dev_get_intf_fxns ========
341 * Retrieve the Bridge driver interface function structure for the
342 * loaded Bridge driver.
344 * hdev_obj: Handle to device object created with
345 * dev_create_device().
346 * *if_fxns: Ptr to location to store fxn interface.
349 * -EFAULT: Invalid hdev_obj.
354 * 0: *if_fxns contains a pointer to the Bridge
356 * else: *if_fxns is NULL.
358 extern int dev_get_intf_fxns(struct dev_object *hdev_obj,
359 struct bridge_drv_interface **if_fxns);
362 * ======== dev_get_io_mgr ========
364 * Retrieve the handle to the IO manager created for this device.
366 * hdev_obj: Handle to device object created with
367 * dev_create_device().
368 * *mgr: Ptr to location to store handle.
371 * -EFAULT: Invalid hdev_obj.
376 * 0: *mgr contains a handle to an IO manager object.
377 * else: *mgr is NULL.
379 extern int dev_get_io_mgr(struct dev_object *hdev_obj,
380 struct io_mgr **mgr);
383 * ======== dev_get_next ========
385 * Retrieve the next Device Object handle from an internal linked list of
386 * of DEV_OBJECTs maintained by DEV, after having previously called
387 * dev_get_first() and zero or more dev_get_next
389 * hdev_obj: Handle to the device object returned from a previous
390 * call to dev_get_first() or dev_get_next().
392 * NULL if there are no further device objects on the list or hdev_obj
394 * else the next valid DEV_HOBJECT in the list.
396 * No calls to dev_create_device or dev_destroy_device (which my modify the
397 * internal device object list) may occur between calls to dev_get_first
400 * The DEV_HOBJECT returned is valid.
401 * A subsequent call to dev_get_next will return the next device object in
404 extern struct dev_object *dev_get_next(struct dev_object
408 * ========= dev_get_msg_mgr ========
410 * Retrieve the msg_ctrl Manager Handle from the DevObject.
412 * hdev_obj: Handle to the Dev Object
413 * msg_man: Location where msg_ctrl Manager handle will be returned.
421 extern void dev_get_msg_mgr(struct dev_object *hdev_obj,
422 struct msg_mgr **msg_man);
425 * ========= dev_get_node_manager ========
427 * Retrieve the Node Manager Handle from the DevObject. It is an
430 * hdev_obj: Handle to the Dev Object
431 * node_man: Location where Handle to the Node Manager will be
435 * -EFAULT: Invalid Dev Object handle.
438 * node_man is not null
440 * 0: *node_man contains a handle to a Node manager object.
441 * else: *node_man is NULL.
443 extern int dev_get_node_manager(struct dev_object
445 struct node_mgr **node_man);
448 * ======== dev_get_symbol ========
450 * Get the value of a symbol in the currently loaded program.
452 * hdev_obj: Handle to device object created with
453 * dev_create_device().
454 * str_sym: Name of symbol to look up.
455 * pul_value: Ptr to symbol value.
458 * -EFAULT: Invalid hdev_obj.
459 * -ESPIPE: Symbols couldn not be found or have not been loaded onto
466 * 0: *pul_value contains the symbol value;
468 extern int dev_get_symbol(struct dev_object *hdev_obj,
469 const char *str_sym, u32 * pul_value);
472 * ======== dev_get_bridge_context ========
474 * Retrieve the Bridge Context handle, as returned by the
475 * bridge_dev_create fxn.
477 * hdev_obj: Handle to device object created with dev_create_device()
478 * *phbridge_context: Ptr to location to store context handle.
481 * -EFAULT: Invalid hdev_obj.
483 * phbridge_context != NULL.
486 * 0: *phbridge_context contains context handle;
487 * else: *phbridge_context is NULL;
489 extern int dev_get_bridge_context(struct dev_object *hdev_obj,
490 struct bridge_dev_context
494 * ======== dev_exit ========
496 * Decrement reference count, and free resources when reference count is
501 * DEV is initialized.
503 * When reference count == 0, DEV's private resources are freed.
505 extern void dev_exit(void);
508 * ======== dev_init ========
510 * Initialize DEV's private state, keeping a reference count on each call.
513 * TRUE if initialized; FALSE if error occured.
516 * TRUE: A requirement for the other public DEV functions.
518 extern bool dev_init(void);
521 * ======== dev_is_locked ========
523 * Predicate function to determine if the device has been
524 * locked by a client for exclusive access.
526 * hdev_obj: Handle to device object created with
527 * dev_create_device().
529 * 0: TRUE: device has been locked.
530 * 0: FALSE: device not locked.
531 * -EFAULT: hdev_obj was invalid.
536 extern int dev_is_locked(struct dev_object *hdev_obj);
539 * ======== dev_insert_proc_object ========
541 * Inserts the Processor Object into the List of PROC Objects
542 * kept in the DEV Object
544 * proc_obj: Handle to the Proc Object
545 * hdev_obj Handle to the Dev Object
546 * bAttachedNew Specifies if there are already processors attached
548 * 0: Successfully inserted into the list
550 * proc_obj is not NULL
551 * hdev_obj is a valid handle to the DEV.
553 * List(of Proc object in Dev) Exists.
555 * 0 & the PROC Object is inserted and the list is not empty
557 * If the List of Proc Object is empty bAttachedNew is TRUE, it indicated
558 * this is the first Processor attaching.
559 * If it is False, there are already processors attached.
561 extern int dev_insert_proc_object(struct dev_object
564 bool *already_attached);
567 * ======== dev_remove_proc_object ========
569 * Search for and remove a Proc object from the given list maintained
572 * p_proc_object: Ptr to ProcObject to insert.
573 * dev_obj: Ptr to Dev Object where the list is.
574 * already_attached: Ptr to return the bool
577 * -EPERM Failure to Remove the PROC Object from the list
581 * dev_obj->proc_list != NULL
582 * !LST_IS_EMPTY(dev_obj->proc_list)
583 * already_attached !=NULL
586 * List will be deleted when the DEV is destroyed.
589 extern int dev_remove_proc_object(struct dev_object
590 *hdev_obj, u32 proc_obj);
593 * ======== dev_notify_clients ========
595 * Notify all clients of this device of a change in device status.
596 * Clients may include multiple users of BRD, as well as CHNL.
597 * This function is asychronous, and may be called by a timer event
598 * set up by a watchdog timer.
600 * hdev_obj: Handle to device object created with dev_create_device().
601 * ret: A status word, most likely a BRD_STATUS.
603 * 0: All registered clients were asynchronously notified.
604 * -EINVAL: Invalid hdev_obj.
608 * 0: Notifications are queued by the operating system to be
609 * delivered to clients. This function does not ensure that
610 * the notifications will ever be delivered.
612 extern int dev_notify_clients(struct dev_object *hdev_obj, u32 ret);
615 * ======== dev_remove_device ========
617 * Destroys the Device Object created by dev_start_device.
619 * dev_node_obj: Device node as it is know to OS.
622 * <error code> Otherwise.
626 extern int dev_remove_device(struct cfg_devnode *dev_node_obj);
629 * ======== dev_set_chnl_mgr ========
631 * Set the channel manager for this device.
633 * hdev_obj: Handle to device object created with
634 * dev_create_device().
635 * hmgr: Handle to a channel manager, or NULL.
638 * -EFAULT: Invalid hdev_obj.
643 extern int dev_set_chnl_mgr(struct dev_object *hdev_obj,
644 struct chnl_mgr *hmgr);
647 * ======== dev_set_msg_mgr ========
649 * Set the Message manager for this device.
651 * hdev_obj: Handle to device object created with dev_create_device().
652 * hmgr: Handle to a message manager, or NULL.
658 extern void dev_set_msg_mgr(struct dev_object *hdev_obj, struct msg_mgr *hmgr);
661 * ======== dev_start_device ========
663 * Initializes the new device with bridge environment. This involves
664 * querying CM for allocated resources, querying the registry for
665 * necessary dsp resources (requested in the INF file), and using this
666 * information to create a bridge device object.
668 * dev_node_obj: Device node as it is know to OS.
671 * <error code> Otherwise.
676 extern int dev_start_device(struct cfg_devnode *dev_node_obj);