aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/tidspbridge/include/dspbridge/proc.h
blob: 5e09fd165d9d4c9294aaf76333ca290cde8e6f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
/*
 * proc.h
 *
 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
 *
 * This is the DSP API RM module interface.
 *
 * Copyright (C) 2005-2006 Texas Instruments, Inc.
 *
 * This package is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef PROC_
#define PROC_

#include <dspbridge/cfgdefs.h>
#include <dspbridge/devdefs.h>
#include <dspbridge/drv.h>

extern char *iva_img;

/*
 *  ======== proc_attach ========
 *  Purpose:
 *      Prepare for communication with a particular DSP processor, and return
 *      a handle to the processor object. The PROC Object gets created
 *  Parameters:
 *      processor_id  :	   The processor index (zero-based).
 *      hmgr_obj  :	   Handle to the Manager Object
 *      attr_in     :	   Ptr to the dsp_processorattrin structure.
 *			      A NULL value means use default values.
 *      ph_processor :	   Ptr to location to store processor handle.
 *  Returns:
 *      0     :	   Success.
 *      -EPERM   :	   General failure.
 *      -EFAULT :	   Invalid processor handle.
 *      0:   Success; Processor already attached.
 *  Requires:
 *      ph_processor != NULL.
 *      PROC Initialized.
 *  Ensures:
 *      -EPERM, and *ph_processor == NULL, OR
 *      Success and *ph_processor is a Valid Processor handle OR
 *      0 and *ph_processor is a Valid Processor.
 *  Details:
 *      When attr_in is NULL, the default timeout value is 10 seconds.
 */
extern int proc_attach(u32 processor_id,
			      const struct dsp_processorattrin
			      *attr_in, void **ph_processor,
			      struct process_context *pr_ctxt);

/*
 *  ======== proc_auto_start =========
 *  Purpose:
 *      A Particular device gets loaded with the default image
 *      if the AutoStart flag is set.
 *  Parameters:
 *      hdev_obj  :   Handle to the Device
 *  Returns:
 *      0     :   On Successful Loading
 *      -ENOENT   :   No DSP exec file found.
 *      -EPERM   :   General Failure
 *  Requires:
 *      hdev_obj != NULL.
 *      dev_node_obj != NULL.
 *      PROC Initialized.
 *  Ensures:
 */
extern int proc_auto_start(struct cfg_devnode *dev_node_obj,
				  struct dev_object *hdev_obj);

/*
 *  ======== proc_ctrl ========
 *  Purpose:
 *      Pass control information to the GPP device driver managing the DSP
 *      processor. This will be an OEM-only function, and not part of the
 *      'Bridge application developer's API.
 *  Parameters:
 *      hprocessor  :       The processor handle.
 *      dw_cmd       :       Private driver IOCTL cmd ID.
 *      pargs       :       Ptr to an driver defined argument structure.
 *  Returns:
 *      0     :       SUCCESS
 *      -EFAULT :       Invalid processor handle.
 *      -ETIME:       A Timeout Occured before the Control information
 *			  could be sent.
 *      -EPERM   :       General Failure.
 *  Requires:
 *      PROC Initialized.
 *  Ensures
 *  Details:
 *      This function Calls bridge_dev_ctrl.
 */
extern int proc_ctrl(void *hprocessor,
			    u32 dw_cmd, struct dsp_cbdata *arg);

/*
 *  ======== proc_detach ========
 *  Purpose:
 *      Close a DSP processor and de-allocate all (GPP) resources reserved
 *      for it. The Processor Object is deleted.
 *  Parameters:
 *      pr_ctxt     :   The processor handle.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   InValid Handle.
 *      -EPERM   :   General failure.
 *  Requires:
 *      PROC Initialized.
 *  Ensures:
 *      PROC Object is destroyed.
 */
extern int proc_detach(struct process_context *pr_ctxt);

/*
 *  ======== proc_enum_nodes ========
 *  Purpose:
 *      Enumerate the nodes currently allocated on a processor.
 *  Parameters:
 *      hprocessor  :   The processor handle.
 *      node_tab    :   The first Location of an array allocated for node
 *		      handles.
 *      node_tab_size:   The number of (DSP_HNODE) handles that can be held
 *		      to the memory the client has allocated for node_tab
 *      pu_num_nodes  :   Location where DSPProcessor_EnumNodes will return
 *		      the number of valid handles written to node_tab
 *      pu_allocated :   Location where DSPProcessor_EnumNodes will return
 *		      the number of nodes that are allocated on the DSP.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle.
 *      -EINVAL   :   The amount of memory allocated for node_tab is
 *		      insufficent. That is the number of nodes actually
 *		      allocated on the DSP is greater than the value
 *		      specified for node_tab_size.
 *      -EPERM   :   Unable to get Resource Information.
 *  Details:
 *  Requires
 *      pu_num_nodes is not NULL.
 *      pu_allocated is not NULL.
 *      node_tab is not NULL.
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_enum_nodes(void *hprocessor,
				  void **node_tab,
				  u32 node_tab_size,
				  u32 *pu_num_nodes,
				  u32 *pu_allocated);

/*
 *  ======== proc_get_resource_info ========
 *  Purpose:
 *      Enumerate the resources currently available on a processor.
 *  Parameters:
 *      hprocessor  :       The processor handle.
 *      resource_type:      Type of resource .
 *      resource_info:      Ptr to the dsp_resourceinfo structure.
 *      resource_info_size:  Size of the structure.
 *  Returns:
 *      0     :       Success.
 *      -EFAULT :       Invalid processor handle.
 *      -EBADR:    The processor is not in the PROC_RUNNING state.
 *      -ETIME:       A timeout occured before the DSP responded to the
 *			  querry.
 *      -EPERM   :       Unable to get Resource Information
 *  Requires:
 *      resource_info is not NULL.
 *      Parameter resource_type is Valid.[TBD]
 *      resource_info_size is >= sizeof dsp_resourceinfo struct.
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 *      This function currently returns
 *      -ENOSYS, and does not write any data to the resource_info struct.
 */
extern int proc_get_resource_info(void *hprocessor,
					 u32 resource_type,
					 struct dsp_resourceinfo
					 *resource_info,
					 u32 resource_info_size);

/*
 *  ======== proc_exit ========
 *  Purpose:
 *      Decrement reference count, and free resources when reference count is
 *      0.
 *  Parameters:
 *  Returns:
 *  Requires:
 *      PROC is initialized.
 *  Ensures:
 *      When reference count == 0, PROC's private resources are freed.
 */
extern void proc_exit(void);

/*
 * ======== proc_get_dev_object =========
 *  Purpose:
 *      Returns the DEV Hanlde for a given Processor handle
 *  Parameters:
 *      hprocessor  :   Processor Handle
 *      device_obj :    Location to store the DEV Handle.
 *  Returns:
 *      0     :   Success; *device_obj has Dev handle
 *      -EPERM   :   Failure; *device_obj is zero.
 *  Requires:
 *      device_obj is not NULL
 *      PROC Initialized.
 *  Ensures:
 *      0     :   *device_obj is not NULL
 *      -EPERM   :   *device_obj is NULL.
 */
extern int proc_get_dev_object(void *hprocessor,
				      struct dev_object **device_obj);

/*
 *  ======== proc_init ========
 *  Purpose:
 *      Initialize PROC's private state, keeping a reference count on each
 *      call.
 *  Parameters:
 *  Returns:
 *      TRUE if initialized; FALSE if error occured.
 *  Requires:
 *  Ensures:
 *      TRUE: A requirement for the other public PROC functions.
 */
extern bool proc_init(void);

/*
 *  ======== proc_get_state ========
 *  Purpose:
 *      Report the state of the specified DSP processor.
 *  Parameters:
 *      hprocessor  :   The processor handle.
 *      proc_state_obj :   Ptr to location to store the dsp_processorstate
 *		      structure.
 *      state_info_size: Size of dsp_processorstate.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle.
 *      -EPERM   :   General failure while querying processor state.
 *  Requires:
 *      proc_state_obj is not NULL
 *      state_info_size is >= than the size of dsp_processorstate structure.
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_get_state(void *hprocessor, struct dsp_processorstate
				 *proc_state_obj, u32 state_info_size);

/*
 *  ======== PROC_GetProcessorID ========
 *  Purpose:
 *      Report the state of the specified DSP processor.
 *  Parameters:
 *      hprocessor  :   The processor handle.
 *      proc_id      :   Processor ID
 *
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle.
 *      -EPERM   :   General failure while querying processor state.
 *  Requires:
 *      proc_state_obj is not NULL
 *      state_info_size is >= than the size of dsp_processorstate structure.
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_get_processor_id(void *proc, u32 * proc_id);

/*
 *  ======== proc_get_trace ========
 *  Purpose:
 *      Retrieve the trace buffer from the specified DSP processor.
 *  Parameters:
 *      hprocessor  :   The processor handle.
 *      pbuf	:   Ptr to buffer to hold trace output.
 *      max_size    :   Maximum size of the output buffer.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle.
 *      -EPERM   :   General failure while retireving processor trace
 *		      Buffer.
 *  Requires:
 *      pbuf is not NULL
 *      max_size is > 0.
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_get_trace(void *hprocessor, u8 * pbuf, u32 max_size);

/*
 *  ======== proc_load ========
 *  Purpose:
 *      Reset a processor and load a new base program image.
 *      This will be an OEM-only function.
 *  Parameters:
 *      hprocessor:       The processor handle.
 *      argc_index:       The number of Arguments(strings)in the aArgV[]
 *      user_args:       An Array of Arguments(Unicode Strings)
 *      user_envp:       An Array of Environment settings(Unicode Strings)
 *  Returns:
 *      0:       Success.
 *      -ENOENT:       The DSP Execuetable was not found.
 *      -EFAULT:       Invalid processor handle.
 *      -EPERM   :       Unable to Load the Processor
 *  Requires:
 *      user_args is not NULL
 *      argc_index is > 0
 *      PROC Initialized.
 *  Ensures:
 *      Success and ProcState == PROC_LOADED
 *      or DSP_FAILED status.
 *  Details:
 *      Does not implement access rights to control which GPP application
 *      can load the processor.
 */
extern int proc_load(void *hprocessor,
			    const s32 argc_index, const char **user_args,
			    const char **user_envp);

/*
 *  ======== proc_register_notify ========
 *  Purpose:
 *      Register to be notified of specific processor events
 *  Parameters:
 *      hprocessor  :   The processor handle.
 *      event_mask  :   Mask of types of events to be notified about.
 *      notify_type :   Type of notification to be sent.
 *      hnotification:  Handle to be used for notification.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle or hnotification.
 *      -EINVAL  :   Parameter event_mask is Invalid
 *      DSP_ENOTIMP :   The notification type specified in uNotifyMask
 *		      is not supported.
 *      -EPERM   :   Unable to register for notification.
 *  Requires:
 *      hnotification is not NULL
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_register_notify(void *hprocessor,
				       u32 event_mask, u32 notify_type,
				       struct dsp_notification
				       *hnotification);

/*
 *  ======== proc_notify_clients ========
 *  Purpose:
 *      Notify the Processor Clients
 *  Parameters:
 *      proc       :   The processor handle.
 *      events     :   Event to be notified about.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle.
 *      -EPERM   :   Failure to Set or Reset the Event
 *  Requires:
 *      events is Supported or Valid type of Event
 *      proc is a valid handle
 *      PROC Initialized.
 *  Ensures:
 */
extern int proc_notify_clients(void *proc, u32 events);

/*
 *  ======== proc_notify_all_clients ========
 *  Purpose:
 *      Notify the Processor Clients
 *  Parameters:
 *      proc       :   The processor handle.
 *      events     :   Event to be notified about.
 *  Returns:
 *      0     :   Success.
 *      -EFAULT :   Invalid processor handle.
 *      -EPERM   :   Failure to Set or Reset the Event
 *  Requires:
 *      events is Supported or Valid type of Event
 *      proc is a valid handle
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 *      NODE And STRM would use this function to notify their clients
 *      about the state changes in NODE or STRM.
 */
extern int proc_notify_all_clients(void *proc, u32 events);

/*
 *  ======== proc_start ========
 *  Purpose:
 *      Start a processor running.
 *      Processor must be in PROC_LOADED state.
 *      This will be an OEM-only function, and not part of the 'Bridge
 *      application developer's API.
 *  Parameters:
 *      hprocessor  :       The processor handle.
 *  Returns:
 *      0     :       Success.
 *      -EFAULT :       Invalid processor handle.
 *      -EBADR:    Processor is not in PROC_LOADED state.
 *      -EPERM   :       Unable to start the processor.
 *  Requires:
 *      PROC Initialized.
 *  Ensures:
 *      Success and ProcState == PROC_RUNNING or DSP_FAILED status.
 *  Details:
 */
extern int proc_start(void *hprocessor);

/*
 *  ======== proc_stop ========
 *  Purpose:
 *      Start a processor running.
 *      Processor must be in PROC_LOADED state.
 *      This will be an OEM-only function, and not part of the 'Bridge
 *      application developer's API.
 *  Parameters:
 *      hprocessor  :       The processor handle.
 *  Returns:
 *      0     :       Success.
 *      -EFAULT :       Invalid processor handle.
 *      -EBADR:    Processor is not in PROC_LOADED state.
 *      -EPERM   :       Unable to start the processor.
 *  Requires:
 *      PROC Initialized.
 *  Ensures:
 *      Success and ProcState == PROC_RUNNING or DSP_FAILED status.
 *  Details:
 */
extern int proc_stop(void *hprocessor);

/*
 *  ======== proc_end_dma ========
 *  Purpose:
 *      Begin a DMA transfer
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      pmpu_addr	:   Buffer start address
 *      ul_size		:   Buffer size
 *      dir		:   The direction of the transfer
 *  Requires:
 *      Memory was previously mapped.
 */
extern int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
						enum dma_data_direction dir);
/*
 *  ======== proc_begin_dma ========
 *  Purpose:
 *      Begin a DMA transfer
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      pmpu_addr	:   Buffer start address
 *      ul_size		:   Buffer size
 *      dir		:   The direction of the transfer
 *  Requires:
 *      Memory was previously mapped.
 */
extern int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
						enum dma_data_direction dir);

/*
 *  ======== proc_flush_memory ========
 *  Purpose:
 *      Flushes a buffer from the MPU data cache.
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      pmpu_addr	:   Buffer start address
 *      ul_size	  :   Buffer size
 *      ul_flags	 :   Reserved.
 *  Returns:
 *      0	 :   Success.
 *      -EFAULT     :   Invalid processor handle.
 *      -EPERM       :   General failure.
 *  Requires:
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 *      All the arguments are currently ignored.
 */
extern int proc_flush_memory(void *hprocessor,
				    void *pmpu_addr, u32 ul_size, u32 ul_flags);

/*
 *  ======== proc_invalidate_memory ========
 *  Purpose:
 *      Invalidates a buffer from the MPU data cache.
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      pmpu_addr	:   Buffer start address
 *      ul_size	  :   Buffer size
 *  Returns:
 *      0	 :   Success.
 *      -EFAULT     :   Invalid processor handle.
 *      -EPERM       :   General failure.
 *  Requires:
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 *      All the arguments are currently ignored.
 */
extern int proc_invalidate_memory(void *hprocessor,
					 void *pmpu_addr, u32 ul_size);

/*
 *  ======== proc_map ========
 *  Purpose:
 *      Maps a MPU buffer to DSP address space.
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      pmpu_addr	:   Starting address of the memory region to map.
 *      ul_size	  :   Size of the memory region to map.
 *      req_addr	:   Requested DSP start address. Offset-adjusted actual
 *			  mapped address is in the last argument.
 *      pp_map_addr       :   Ptr to DSP side mapped u8 address.
 *      ul_map_attr       :   Optional endianness attributes, virt to phys flag.
 *  Returns:
 *      0	 :   Success.
 *      -EFAULT     :   Invalid processor handle.
 *      -EPERM       :   General failure.
 *      -ENOMEM     :   MPU side memory allocation error.
 *      -ENOENT   :   Cannot find a reserved region starting with this
 *		      :   address.
 *  Requires:
 *      pmpu_addr is not NULL
 *      ul_size is not zero
 *      pp_map_addr is not NULL
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_map(void *hprocessor,
			   void *pmpu_addr,
			   u32 ul_size,
			   void *req_addr,
			   void **pp_map_addr, u32 ul_map_attr,
			   struct process_context *pr_ctxt);

/*
 *  ======== proc_reserve_memory ========
 *  Purpose:
 *      Reserve a virtually contiguous region of DSP address space.
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      ul_size	  :   Size of the address space to reserve.
 *      pp_rsv_addr       :   Ptr to DSP side reserved u8 address.
 *  Returns:
 *      0	 :   Success.
 *      -EFAULT     :   Invalid processor handle.
 *      -EPERM       :   General failure.
 *      -ENOMEM     :   Cannot reserve chunk of this size.
 *  Requires:
 *      pp_rsv_addr is not NULL
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_reserve_memory(void *hprocessor,
				      u32 ul_size, void **pp_rsv_addr,
				      struct process_context *pr_ctxt);

/*
 *  ======== proc_un_map ========
 *  Purpose:
 *      Removes a MPU buffer mapping from the DSP address space.
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      map_addr	:   Starting address of the mapped memory region.
 *  Returns:
 *      0	 :   Success.
 *      -EFAULT     :   Invalid processor handle.
 *      -EPERM       :   General failure.
 *      -ENOENT   :   Cannot find a mapped region starting with this
 *		      :   address.
 *  Requires:
 *      map_addr is not NULL
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_un_map(void *hprocessor, void *map_addr,
			      struct process_context *pr_ctxt);

/*
 *  ======== proc_un_reserve_memory ========
 *  Purpose:
 *      Frees a previously reserved region of DSP address space.
 *  Parameters:
 *      hprocessor      :   The processor handle.
 *      prsv_addr	:   Ptr to DSP side reservedBYTE address.
 *  Returns:
 *      0	 :   Success.
 *      -EFAULT     :   Invalid processor handle.
 *      -EPERM       :   General failure.
 *      -ENOENT   :   Cannot find a reserved region starting with this
 *		      :   address.
 *  Requires:
 *      prsv_addr is not NULL
 *      PROC Initialized.
 *  Ensures:
 *  Details:
 */
extern int proc_un_reserve_memory(void *hprocessor,
					 void *prsv_addr,
					 struct process_context *pr_ctxt);

#endif /* PROC_ */