• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2001-2008 Texas Instruments - http://www.ti.com/
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16 
17 /*
18  *  ======== drv.h ========
19  *  DSP-BIOS Bridge driver support functions for TI OMAP processors.
20  *  Purpose:
21  *      DRV Resource allocation module. Driver Object gets Created
22  *      at the time of Loading. It holds the List of Device Objects
23  *      in the Syste,
24  *
25  *  Public Functions:
26  *      DRV_Create
27  *      DRV_Destroy
28  *      DRV_Exit
29  *      DRV_GetDevObject
30  *      DRV_GetDevExtension
31  *      DRV_GetFirstDevObject
32  *      DRV_GetNextDevObject
33  *      DRV_GetNextDevExtension
34  *      DRV_Init
35  *      DRV_InsertDevObject
36  *      DRV_RemoveDevObject
37  *      DRV_RequestResources
38  *      DRV_ReleaseResources
39  *
40  *! Revision History
41  *! ================
42  *! 10-Feb-2004 vp:  Added OMAP24xx specific definitions.
43  *! 14-Aug-2000 rr:  Cleaned up.
44  *! 27-Jul-2000 rr:  DRV_RequestResources split into two(Request and Release)
45  *!                  Device extension created to hold the DevNodeString.
46  *! 17-Jul-2000 rr:  Driver Object holds the list of Device Objects.
47  *!                  Added DRV_Create, DRV_Destroy, DRV_GetDevObject,
48  *!                  DRV_GetFirst/NextDevObject, DRV_Insert/RemoveDevObject.
49  *! 12-Nov-1999 rr:  New Flag defines for DRV_ASSIGN and DRV_RELEASE
50  *! 25-Oct-1999 rr:  Resource Structure removed.
51  *! 15-Oct-1999 rr:  New Resource structure created.
52  *! 05-Oct-1999 rr:  Added DRV_RequestResources
53  *!                  Removed fxn'sDRV_RegisterMiniDriver(), DRV_UnRegisterMiniDriver()
54  *!                  Removed Structures DSP_DRIVER & DRV_EXTENSION.
55  *!
56  *! 24-Sep-1999 rr:  Added DRV_EXTENSION and DSP_DRIVER structures.
57  *!
58  */
59 
60 #ifndef DRV_
61 #define DRV_
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 #include <devdefs.h>
68 
69 #include <drvdefs.h>
70 
71 #define DRV_ASSIGN     1
72 #define DRV_RELEASE    0
73 
74 #ifdef OMAP_2430
75 
76 #if 0
77 #warning "For tests only remove !!!"
78 /* #define OMAP_DSP_BASE   0x5CE00000 */
79 #define OMAP_DSP_BASE   0x5C000000
80 /* #define OMAP_DSP_SIZE   0x00810000 */
81 #define OMAP_DSP_SIZE   0x00F18000
82 /* #define OMAP_DSP_SIZE   0x00008000 */
83 #endif
84 
85 /* currently we support DSP images with internal L2 and L1 using
86  * the adress space 0x1000:0000 to 0x10ff:ffff
87  * And since the first 8MB is reserved, start mapping from
88  * 0x1080:0000
89  */
90 
91 #define OMAP_DSP_BASE   0x5C800000
92 #define OMAP_DSP_SIZE   0x00718000
93 
94 #define OMAP_GEM_BASE   0x10800000
95 
96 /*#define OMAP_PRCM_BASE 0x47806000
97 #define OMAP_PRCM_SIZE 0x1000*/
98 
99 #define OMAP_PRCM_BASE 0x49006000
100 #define OMAP_PRCM_SIZE 0x1000
101 
102 #define OMAP_MBOX_BASE 0x48094000
103 #define OMAP_MBOX_SIZE 0x2000
104 
105 #define OMAP_WDTIMER_DSP_BASE 0x48026000
106 #define OMAP_WDTIMER_DSP_SIZE 0x2000
107 
108 #define OMAP_DMMU_BASE 0x5D000000
109 #define OMAP_DMMU_SIZE 0x4000
110 
111 /*#define OMAP_SYSC_BASE 0x47802000
112 #define OMAP_SYSC_SIZE 0x1000*/
113 
114 /*#define OMAP_SYSC_BASE 0x01C20000
115 #define OMAP_SYSC_SIZE 0x1000*/
116 #define OMAP_SYSC_BASE 0x49002000
117 #define OMAP_SYSC_SIZE 0x1000
118 #endif
119 
120 
121 #ifdef OMAP_3430
122 
123 
124 /* Provide the DSP Internal memory windows that can be accessed from L3 address
125  * space
126  */
127 
128 #define OMAP_GEM_BASE   0x107F8000
129 #define OMAP_DSP_SIZE   0x00720000
130 
131 /* MEM1 is L2 RAM + L2 Cache space */
132 #define OMAP_DSP_MEM1_BASE 0x5C7F8000
133 #define OMAP_DSP_MEM1_SIZE 0x18000
134 #define OMAP_DSP_GEM1_BASE 0x107F8000
135 
136 
137 /* MEM2 is L1P RAM/CACHE space */
138 #define OMAP_DSP_MEM2_BASE 0x5CE00000
139 #define OMAP_DSP_MEM2_SIZE 0x8000
140 #define OMAP_DSP_GEM2_BASE 0x10E00000
141 
142 /* MEM3 is L1D RAM/CACHE space */
143 #define OMAP_DSP_MEM3_BASE 0x5CF04000
144 #define OMAP_DSP_MEM3_SIZE 0x14000
145 #define OMAP_DSP_GEM3_BASE 0x10F04000
146 
147 
148 #define OMAP_IVA2_PRM_BASE 0x48306000
149 #define OMAP_IVA2_PRM_SIZE 0x1000
150 
151 #define OMAP_IVA2_CM_BASE 0x48004000
152 #define OMAP_IVA2_CM_SIZE 0x1000
153 
154 #define OMAP_PER_CM_BASE 0x48005000
155 #define OMAP_PER_CM_SIZE 0x1000
156 
157 #define OMAP_SYSC_BASE 0x48002000
158 #define OMAP_SYSC_SIZE 0x1000
159 
160 #define OMAP_MBOX_BASE 0x48094000
161 #define OMAP_MBOX_SIZE 0x1000
162 
163 // Do we have a WDT for DSP?
164 // #define OMAP_WDTIMER_DSP_BASE 0x48026000
165 // #define OMAP_WDTIMER_DSP_SIZE 0x2000
166 
167 #define OMAP_DMMU_BASE 0x5D000000
168 #define OMAP_DMMU_SIZE 0x1000
169 
170 #define OMAP_PRCM_VDD1_DOMAIN 1
171 #define OMAP_PRCM_VDD2_DOMAIN 2
172 
173 #endif
174 
175 #ifndef RES_CLEANUP_DISABLE
176 /**************************************************************************/
177 /******************** GPP PROCESS CLEANUP Data structures *****************/
178 /**************************************************************************/
179 //#ifndef RES_CLEANUP_DISABLE
180 /* New structure (member of process context) abstracts NODE resource info */
181 struct NODE_RES_OBJECT {
182          DSP_HNODE       hNode;
183          bool            nodeAllocated; //Node status
184          bool            heapAllocated; //Heap status
185          bool            streamsAllocated; //Streams status
186          struct NODE_RES_OBJECT         *next;
187 } ;
188 
189 /* New structure (member of process context) abstracts DMM resource info */
190 struct DMM_RES_OBJECT {
191          bool            dmmAllocated; //DMM status
192          ULONG           ulMpuAddr;
193          ULONG           ulDSPAddr;
194          ULONG           ulDSPResAddr;
195          ULONG           dmmSize;
196          HANDLE          hProcessor;
197          struct DMM_RES_OBJECT  *next;
198 } ;
199 
200 /* New structure (member of process context) abstracts DMM resource info */
201 struct DSPHEAP_RES_OBJECT {
202          bool            heapAllocated; //DMM status
203          ULONG           ulMpuAddr;
204          ULONG           ulDSPAddr;
205          ULONG           ulDSPResAddr;
206          ULONG           heapSize;
207          HANDLE          hProcessor;
208          struct DSPHEAP_RES_OBJECT  *next;
209 } ;
210 
211 /* New structure (member of process context) abstracts stream resource info */
212 struct STRM_RES_OBJECT {
213          bool                    streamAllocated; //Stream status
214          DSP_HSTREAM             hStream;
215          UINT                    uNumBufs;
216          UINT                    uDir;
217          struct STRM_RES_OBJECT         *next;
218 } ;
219 /* Overall Bridge process resource usage state */
220 typedef enum {
221          PROC_RES_ALLOCATED ,
222          PROC_RES_FREED
223 } GPP_PROC_RES_STATE;
224 
225 /* Process Context */
226 struct PROCESS_CONTEXT{
227          /* Process State */
228          GPP_PROC_RES_STATE       resState;
229 
230          /* Process ID (Same as UNIX process ID) */
231          UINT                     pid;
232 
233         /* Pointer to next process context
234 		 * (To maintain a linked list of process contexts) */
235          struct PROCESS_CONTEXT         *next;
236 
237          /* Processor info to which the process is related */
238          DSP_HPROCESSOR           hProcessor;
239 
240          /* DSP Node resources */
241          struct NODE_RES_OBJECT          *pNodeList;
242 
243          /* DMM resources */
244          struct DMM_RES_OBJECT          *pDMMList;
245 
246          /* DSP Heap resources */
247          struct DSPHEAP_RES_OBJECT          *pDSPHEAPList;
248 
249          /* Stream resources */
250          struct STRM_RES_OBJECT         *pSTRMList;
251 } ;
252 #endif
253 
254 /*
255  *  ======== DRV_Create ========
256  *  Purpose:
257  *      Creates the Driver Object. This is done during the driver loading.
258  *      There is only one Driver Object in the DSP/BIOS Bridge.
259  *  Parameters:
260  *      phDrvObject:    Location to store created DRV Object handle.
261  *  Returns:
262  *      DSP_SOK:        Sucess
263  *      DSP_EMEMORY:    Failed in Memory allocation
264  *      DSP_EFAIL:      General Failure
265  *  Requires:
266  *      DRV Initialized (cRefs > 0 )
267  *      phDrvObject != NULL.
268  *  Ensures:
269  *      DSP_SOK:        - *phDrvObject is a valid DRV interface to the device.
270  *                      - List of DevObject Created and Initialized.
271  *                      - List of DevNode String created and intialized.
272  *                      - Registry is updated with the DRV Object.
273  *      !DSP_SOK:       DRV Object not created
274  *  Details:
275  *      There is one Driver Object for the Driver representing
276  *      the driver itself. It contains the list of device
277  *      Objects and the list of Device Extensions in the system.
278  *      Also it can hold other neccessary
279  *      information in its storage area.
280  */
281 	extern DSP_STATUS DRV_Create(struct DRV_OBJECT* * phDrvObject);
282 
283 /*
284  *  ======== DRV_Destroy ========
285  *  Purpose:
286  *      destroys the Dev Object list, DrvExt list
287  *      and destroy the DRV object
288  *      Called upon driver unLoading.or unsuccesful loading of the driver.
289  *  Parameters:
290  *      hDrvObject:     Handle to Driver object .
291  *  Returns:
292  *      DSP_SOK:        Success.
293  *      DSP_EFAIL:      Failed to destroy DRV Object
294  *  Requires:
295  *      DRV Initialized (cRegs > 0 )
296  *      hDrvObject is not NULL and a valid DRV handle .
297  *      List of DevObject is Empty.
298  *      List of DrvExt is Empty
299  *  Ensures:
300  *      DSP_SOK:        - DRV Object destroyed and hDrvObject is not a valid
301  *                        DRV handle.
302  *                      - Registry is updated with "0" as the DRV Object.
303  */
304 	extern DSP_STATUS DRV_Destroy(struct DRV_OBJECT* hDrvObject);
305 
306 /*
307  *  ======== DRV_Exit ========
308  *  Purpose:
309  *      Exit the DRV module, freeing any modules initialized in DRV_Init.
310  *  Parameters:
311  *  Returns:
312  *  Requires:
313  *  Ensures:
314  */
315 	extern VOID DRV_Exit();
316 
317 /*
318  *  ======== DRV_GetFirstDevObject ========
319  *  Purpose:
320  *      Returns the Ptr to the FirstDev Object in the List
321  *  Parameters:
322  *  Requires:
323  *      DRV Initialized
324  *  Returns:
325  *      dwDevObject:  Ptr to the First Dev Object as a DWORD
326  *      0 if it fails to retrieve the First Dev Object
327  *  Ensures:
328  */
329 	extern DWORD DRV_GetFirstDevObject();
330 
331 /*
332  *  ======== DRV_GetFirstDevExtension ========
333  *  Purpose:
334  *      Returns the Ptr to the First Device Extension in the List
335  *  Parameters:
336  *  Requires:
337  *      DRV Initialized
338  *  Returns:
339  *      dwDevExtension:     Ptr to the First Device Extension as a DWORD
340  *      0:                  Failed to Get the Device Extension
341  *  Ensures:
342  */
343 	extern DWORD DRV_GetFirstDevExtension();
344 
345 /*
346  *  ======== DRV_GetDevObject ========
347  *  Purpose:
348  *      Given a index, returns a handle to DevObject from the list
349  *  Parameters:
350  *      hDrvObject:     Handle to the Manager
351  *      phDevObject:    Location to store the Dev Handle
352  *  Requires:
353  *      DRV Initialized
354  *      uIndex >= 0
355  *      hDrvObject is not NULL and Valid DRV Object
356  *      phDevObject is not NULL
357  *      Device Object List not Empty
358  *  Returns:
359  *      DSP_SOK:        Success
360  *      DSP_EFAIL:      Failed to Get the Dev Object
361  *  Ensures:
362  *      DSP_SOK:        *phDevObject != NULL
363  *      DSP_EFAIL:      *phDevObject = NULL
364  */
365 	extern DSP_STATUS DRV_GetDevObject(UINT uIndex, struct DRV_OBJECT* hDrvObject,
366 					   struct DEV_OBJECT* * phDevObject);
367 
368 /*
369  *  ======== DRV_GetNextDevObject ========
370  *  Purpose:
371  *      Returns the Ptr to the Next Device Object from the the List
372  *  Parameters:
373  *      hDevObject:     Handle to the Device Object
374  *  Requires:
375  *      DRV Initialized
376  *      hDevObject != 0
377  *  Returns:
378  *      dwDevObject:    Ptr to the Next Dev Object as a DWORD
379  *      0:              If it fail to get the next Dev Object.
380  *  Ensures:
381  */
382 	extern DWORD DRV_GetNextDevObject(DWORD hDevObject);
383 
384 /*
385  *  ======== DRV_GetNextDevExtension ========
386  *  Purpose:
387  *      Returns the Ptr to the Next Device Extension from the the List
388  *  Parameters:
389  *      hDevExtension:      Handle to the Device Extension
390  *  Requires:
391  *      DRV Initialized
392  *      hDevExtension != 0.
393  *  Returns:
394  *      dwDevExtension:     Ptr to the Next Dev Extension
395  *      0:                  If it fail to Get the next Dev Extension
396  *  Ensures:
397  */
398 	extern DWORD DRV_GetNextDevExtension(DWORD hDevExtension);
399 
400 /*
401  *  ======== DRV_Init ========
402  *  Purpose:
403  *      Initialize the DRV module.
404  *  Parameters:
405  *  Returns:
406  *      TRUE if success; FALSE otherwise.
407  *  Requires:
408  *  Ensures:
409  */
410 	extern DSP_STATUS DRV_Init();
411 
412 /*
413  *  ======== DRV_InsertDevObject ========
414  *  Purpose:
415  *      Insert a DeviceObject into the list of Driver object.
416  *  Parameters:
417  *      hDrvObject:     Handle to DrvObject
418  *      hDevObject:     Handle to DeviceObject to insert.
419  *  Returns:
420  *      DSP_SOK:        If successful.
421  *      DSP_EFAIL:      General Failure:
422  *  Requires:
423  *      hDrvObject != NULL and Valid DRV Handle.
424  *      hDevObject != NULL.
425  *  Ensures:
426  *      DSP_SOK:        Device Object is inserted and the List is not empty.
427  */
428 	extern DSP_STATUS DRV_InsertDevObject(struct DRV_OBJECT* hDrvObject,
429 					      struct DEV_OBJECT* hDevObject);
430 
431 /*
432  *  ======== DRV_RemoveDevObject ========
433  *  Purpose:
434  *      Search for and remove a Device object from the given list of Device Obj
435  *      objects.
436  *  Parameters:
437  *      hDrvObject:     Handle to DrvObject
438  *      hDevObject:     Handle to DevObject to Remove
439  *  Returns:
440  *      DSP_SOK:        Success.
441  *      DSP_EFAIL:      Unable to find pDevObject.
442  *  Requires:
443  *      hDrvObject != NULL and a Valid DRV Handle.
444  *      hDevObject != NULL.
445  *      List exists and is not empty.
446  *  Ensures:
447  *      List either does not exist (NULL), or is not empty if it does exist.
448 */
449 	extern DSP_STATUS DRV_RemoveDevObject(struct DRV_OBJECT* hDrvObject,
450 					      struct DEV_OBJECT* hDevObject);
451 
452 /*
453  *  ======== DRV_RequestResources ========
454  *  Purpose:
455  *      Assigns the Resources or Releases them.
456  *  Parameters:
457  *      dwContext:          Path to the driver Registry Key.
458  *      pDevNodeString:     Ptr to DevNode String stored in the Device Ext.
459  *  Returns:
460  *      TRUE if success; FALSE otherwise.
461  *  Requires:
462  *  Ensures:
463  *      The Resources are assigned based on Bus type.
464  *      The hardware is initialized. Resource information is
465  *      gathered from the Registry(ISA, PCMCIA)or scanned(PCI)
466  *      Resource structure is stored in the registry which will be
467  *      later used by the CFG module.
468  */
469 	extern DSP_STATUS DRV_RequestResources(IN DWORD dwContext,
470 					       OUT DWORD * pDevNodeString);
471 
472 /*
473  *  ======== DRV_ReleaseResources ========
474  *  Purpose:
475  *      Assigns the Resources or Releases them.
476  *  Parameters:
477  *      dwContext:      Path to the driver Registry Key.
478  *      hDrvObject:     Handle to the Driver Object.
479  *  Returns:
480  *      TRUE if success; FALSE otherwise.
481  *  Requires:
482  *  Ensures:
483  *      The Resources are released based on Bus type.
484  *      Resource structure is deleted from the registry
485  */
486 	extern DSP_STATUS DRV_ReleaseResources(IN DWORD dwContext,
487 					       struct DRV_OBJECT* hDrvObject);
488 
489 #ifdef __cplusplus
490 }
491 #endif
492 #endif				/* DRV_ */
493