hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
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
/*************************************************************************/ /*!
@File
@Title          Header for Services abstraction layer
@Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description    Declaration of an interface layer used to abstract code that
                can be compiled outside of the DDK, potentially in a
                completely different OS.
                All the headers included by this file must also be copied to
                the alternative source tree.
                All the functions declared here must have a DDK implementation
                inside the DDK source tree (e.g. rgxlayer_km_impl.h/.c) and
                another different implementation in case they are used outside
                of the DDK.
                All of the functions accept as a first parameter a
                "const void *hPrivate" argument. It should be used to pass
                around any implementation specific data required.
@License        Dual MIT/GPLv2
 
The contents of this file are subject to the MIT license as set out below.
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
 
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
 
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
 
This License is also included in this distribution in the file called
"MIT-COPYING".
 
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /**************************************************************************/
 
#if !defined (__RGXLAYER_KM_H__)
#define __RGXLAYER_KM_H__
 
#if defined (__cplusplus)
extern "C" {
#endif
 
 
#include "img_types.h"
#include "img_defs.h"
#include "pvrsrv_error.h" /* includes pvrsrv_errors.h */
#include "rgx_bvnc_defs_km.h"
 
#include "rgx_firmware_processor.h"
/* includes:
 * rgx_meta.h and rgx_mips.h,
 * rgxdefs_km.h,
 * rgx_cr_defs_km.h,
 * RGX_BVNC_CORE_KM_HEADER (rgxcore_km_B.V.N.C.h),
 * RGX_BNC_CONFIG_KM_HEADER (rgxconfig_km_B.V.N.C.h)
 */
 
 
/*!
*******************************************************************************
 
 @Function      RGXWriteReg32/64
 
 @Description   Write a value to a 32/64 bit RGX register
 
 @Input         hPrivate         : Implementation specific data
 @Input         ui32RegAddr      : Register offset inside the register bank
 @Input         ui32/64RegValue  : New register value
 
 @Return        void
 
******************************************************************************/
void RGXWriteReg32(const void *hPrivate,
                   IMG_UINT32 ui32RegAddr,
                   IMG_UINT32 ui32RegValue);
 
void RGXWriteReg64(const void *hPrivate,
                   IMG_UINT32 ui32RegAddr,
                   IMG_UINT64 ui64RegValue);
 
/*!
*******************************************************************************
 
 @Function       RGXReadReg32/64
 
 @Description    Read a 32/64 bit RGX register
 
 @Input          hPrivate     : Implementation specific data
 @Input          ui32RegAddr  : Register offset inside the register bank
 
 @Return         Register value
 
******************************************************************************/
IMG_UINT32 RGXReadReg32(const void *hPrivate,
                        IMG_UINT32 ui32RegAddr);
 
IMG_UINT64 RGXReadReg64(const void *hPrivate,
                        IMG_UINT32 ui32RegAddr);
 
/*!
*******************************************************************************
 
 @Function       RGXPollReg32/64
 
 @Description    Poll on a 32/64 bit RGX register until some bits are set/unset
 
 @Input          hPrivate         : Implementation specific data
 @Input          ui32RegAddr      : Register offset inside the register bank
 @Input          ui32/64RegValue  : Value expected from the register
 @Input          ui32/64RegMask   : Only the bits set in this mask will be
                                    checked against uiRegValue
 
 @Return         PVRSRV_OK if the poll succeeds,
                 PVRSRV_ERROR_TIMEOUT if the poll takes too long
 
******************************************************************************/
PVRSRV_ERROR RGXPollReg32(const void *hPrivate,
                          IMG_UINT32 ui32RegAddr,
                          IMG_UINT32 ui32RegValue,
                          IMG_UINT32 ui32RegMask);
 
PVRSRV_ERROR RGXPollReg64(const void *hPrivate,
                          IMG_UINT32 ui32RegAddr,
                          IMG_UINT64 ui64RegValue,
                          IMG_UINT64 ui64RegMask);
 
/*!
*******************************************************************************
 
 @Function       RGXWaitCycles
 
 @Description    Wait for a number of GPU cycles and/or microseconds
 
 @Input          hPrivate    : Implementation specific data
 @Input          ui32Cycles  : Number of GPU cycles to wait for in pdumps,
                               it can also be used when running driver-live
                               if desired (ignoring the next parameter)
 @Input          ui32WaitUs  : Number of microseconds to wait for when running
                               driver-live
 
 @Return         void
 
******************************************************************************/
void RGXWaitCycles(const void *hPrivate,
                   IMG_UINT32 ui32Cycles,
                   IMG_UINT32 ui32WaitUs);
 
/*!
*******************************************************************************
 
 @Function       RGXCommentLogPower
 
 @Description    This function is called with debug messages during
                 the RGX start/stop process
 
 @Input          hPrivate   : Implementation specific data
 @Input          pszString  : Message to be printed
 @Input          ...        : Variadic arguments
 
 @Return         void
 
******************************************************************************/
void RGXCommentLogPower(const void *hPrivate,
                        const IMG_CHAR *pszString,
                        ...) __printf(2, 3);
 
 
/*!
*******************************************************************************
 
 @Function        RGXAcquireKernelMMUPC
 
 @Description     Acquire the Kernel MMU Page Catalogue device physical address
 
 @Input           hPrivate  : Implementation specific data
 @Input           psPCAddr  : Returned page catalog address
 
 @Return          void
 
******************************************************************************/
void RGXAcquireKernelMMUPC(const void *hPrivate, IMG_DEV_PHYADDR *psPCAddr);
 
/*!
*******************************************************************************
 
 @Function        RGXWriteKernelMMUPC32/64
 
 @Description     Write the Kernel MMU Page Catalogue to the 32/64 bit
                  RGX register passed as argument.
                  In a driver-live scenario without PDump these functions
                  are the same as RGXWriteReg32/64 and they don't need
                  to be reimplemented.
 
 @Input           hPrivate        : Implementation specific data
 @Input           ui32PCReg       : Register offset inside the register bank
 @Input           ui32AlignShift  : PC register alignshift
 @Input           ui32Shift       : PC register shift
 @Input           ui32/64PCVal    : Page catalog value (aligned and shifted)
 
 @Return          void
 
******************************************************************************/
#if defined(PDUMP)
 
void RGXWriteKernelMMUPC64(const void *hPrivate,
                           IMG_UINT32 ui32PCReg,
                           IMG_UINT32 ui32PCRegAlignShift,
                           IMG_UINT32 ui32PCRegShift,
                           IMG_UINT64 ui64PCVal);
 
void RGXWriteKernelMMUPC32(const void *hPrivate,
                           IMG_UINT32 ui32PCReg,
                           IMG_UINT32 ui32PCRegAlignShift,
                           IMG_UINT32 ui32PCRegShift,
                           IMG_UINT32 ui32PCVal);
 
 
#else  /* defined(PDUMP) */
 
#define RGXWriteKernelMMUPC64(priv, pcreg, alignshift, shift, pcval) \
   RGXWriteReg64(priv, pcreg, pcval)
 
#define RGXWriteKernelMMUPC32(priv, pcreg, alignshift, shift, pcval) \
   RGXWriteReg32(priv, pcreg, pcval)
 
#endif /* defined(PDUMP) */
 
 
 
/*!
*******************************************************************************
 
 @Function        RGXAcquireGPURegsAddr
 
 @Description     Acquire the GPU registers base device physical address
 
 @Input           hPrivate       : Implementation specific data
 @Input           psGPURegsAddr  : Returned GPU registers base address
 
 @Return          void
 
******************************************************************************/
void RGXAcquireGPURegsAddr(const void *hPrivate, IMG_DEV_PHYADDR *psGPURegsAddr);
 
/*!
*******************************************************************************
 
 @Function        RGXMIPSWrapperConfig
 
 @Description     Write GPU register bank transaction ID and MIPS boot mode
                  to the MIPS wrapper config register (passed as argument).
                  In a driver-live scenario without PDump this is the same as
                  RGXWriteReg64 and it doesn't need to be reimplemented.
 
 @Input           hPrivate          : Implementation specific data
 @Input           ui32RegAddr       : Register offset inside the register bank
 @Input           ui64GPURegsAddr   : GPU registers base address
 @Input           ui32GPURegsAlign  : Register bank transactions alignment
 @Input           ui32BootMode      : Mips BOOT ISA mode
 
 @Return          void
 
******************************************************************************/
#if defined(PDUMP)
void RGXMIPSWrapperConfig(const void *hPrivate,
                          IMG_UINT32 ui32RegAddr,
                          IMG_UINT64 ui64GPURegsAddr,
                          IMG_UINT32 ui32GPURegsAlign,
                          IMG_UINT32 ui32BootMode);
#else
#define RGXMIPSWrapperConfig(priv, regaddr, gpuregsaddr, gpuregsalign, bootmode) \
   RGXWriteReg64(priv, regaddr, ((gpuregsaddr) >> (gpuregsalign)) | (bootmode))
#endif
 
/*!
*******************************************************************************
 
 @Function        RGXAcquireBootRemapAddr
 
 @Description     Acquire the device physical address of the MIPS bootloader
                  accessed through remap region
 
 @Input           hPrivate         : Implementation specific data
 @Output          psBootRemapAddr  : Base address of the remapped bootloader
 
 @Return          void
 
******************************************************************************/
void RGXAcquireBootRemapAddr(const void *hPrivate, IMG_DEV_PHYADDR *psBootRemapAddr);
 
/*!
*******************************************************************************
 
 @Function        RGXBootRemapConfig
 
 @Description     Configure the bootloader remap registers passed as arguments.
                  In a driver-live scenario without PDump this is the same as
                  two RGXWriteReg64 and it doesn't need to be reimplemented.
 
 @Input           hPrivate             : Implementation specific data
 @Input           ui32Config1RegAddr   : Remap config1 register offset
 @Input           ui64Config1RegValue  : Remap config1 register value
 @Input           ui32Config2RegAddr   : Remap config2 register offset
 @Input           ui64Config2PhyAddr   : Output remapped aligned physical address
 @Input           ui64Config2PhyMask   : Mask for the output physical address
 @Input           ui64Config2Settings  : Extra settings for this remap region
 
 @Return          void
 
******************************************************************************/
#if defined(PDUMP)
void RGXBootRemapConfig(const void *hPrivate,
                        IMG_UINT32 ui32Config1RegAddr,
                        IMG_UINT64 ui64Config1RegValue,
                        IMG_UINT32 ui32Config2RegAddr,
                        IMG_UINT64 ui64Config2PhyAddr,
                        IMG_UINT64 ui64Config2PhyMask,
                        IMG_UINT64 ui64Config2Settings);
#else
#define RGXBootRemapConfig(priv, c1reg, c1val, c2reg, c2phyaddr, c2phymask, c2settings) do { \
       RGXWriteReg64(priv, c1reg, (c1val)); \
       RGXWriteReg64(priv, c2reg, ((c2phyaddr) & (c2phymask)) | (c2settings)); \
   } while (0)
#endif
 
/*!
*******************************************************************************
 
 @Function        RGXAcquireCodeRemapAddr
 
 @Description     Acquire the device physical address of the MIPS code
                  accessed through remap region
 
 @Input           hPrivate         : Implementation specific data
 @Output          psCodeRemapAddr  : Base address of the remapped code
 
 @Return          void
 
******************************************************************************/
void RGXAcquireCodeRemapAddr(const void *hPrivate, IMG_DEV_PHYADDR *psCodeRemapAddr);
 
/*!
*******************************************************************************
 
 @Function        RGXCodeRemapConfig
 
 @Description     Configure the code remap registers passed as arguments.
                  In a driver-live scenario without PDump this is the same as
                  two RGXWriteReg64 and it doesn't need to be reimplemented.
 
 @Input           hPrivate             : Implementation specific data
 @Input           ui32Config1RegAddr   : Remap config1 register offset
 @Input           ui64Config1RegValue  : Remap config1 register value
 @Input           ui32Config2RegAddr   : Remap config2 register offset
 @Input           ui64Config2PhyAddr   : Output remapped aligned physical address
 @Input           ui64Config2PhyMask   : Mask for the output physical address
 @Input           ui64Config2Settings  : Extra settings for this remap region
 
 @Return          void
 
******************************************************************************/
#if defined(PDUMP)
void RGXCodeRemapConfig(const void *hPrivate,
                        IMG_UINT32 ui32Config1RegAddr,
                        IMG_UINT64 ui64Config1RegValue,
                        IMG_UINT32 ui32Config2RegAddr,
                        IMG_UINT64 ui64Config2PhyAddr,
                        IMG_UINT64 ui64Config2PhyMask,
                        IMG_UINT64 ui64Config2Settings);
#else
#define RGXCodeRemapConfig(priv, c1reg, c1val, c2reg, c2phyaddr, c2phymask, c2settings) do { \
       RGXWriteReg64(priv, c1reg, (c1val)); \
       RGXWriteReg64(priv, c2reg, ((c2phyaddr) & (c2phymask)) | (c2settings)); \
   } while (0)
#endif
 
/*!
*******************************************************************************
 
 @Function        RGXAcquireDataRemapAddr
 
 @Description     Acquire the device physical address of the MIPS data
                  accessed through remap region
 
 @Input           hPrivate         : Implementation specific data
 @Output          psDataRemapAddr  : Base address of the remapped data
 
 @Return          void
 
******************************************************************************/
void RGXAcquireDataRemapAddr(const void *hPrivate, IMG_DEV_PHYADDR *psDataRemapAddr);
 
/*!
*******************************************************************************
 
 @Function        RGXDataRemapConfig
 
 @Description     Configure the data remap registers passed as arguments.
                  In a driver-live scenario without PDump this is the same as
                  two RGXWriteReg64 and it doesn't need to be reimplemented.
 
 @Input           hPrivate             : Implementation specific data
 @Input           ui32Config1RegAddr   : Remap config1 register offset
 @Input           ui64Config1RegValue  : Remap config1 register value
 @Input           ui32Config2RegAddr   : Remap config2 register offset
 @Input           ui64Config2PhyAddr   : Output remapped aligned physical address
 @Input           ui64Config2PhyMask   : Mask for the output physical address
 @Input           ui64Config2Settings  : Extra settings for this remap region
 
 @Return          void
 
******************************************************************************/
#if defined(PDUMP)
void RGXDataRemapConfig(const void *hPrivate,
                        IMG_UINT32 ui32Config1RegAddr,
                        IMG_UINT64 ui64Config1RegValue,
                        IMG_UINT32 ui32Config2RegAddr,
                        IMG_UINT64 ui64Config2PhyAddr,
                        IMG_UINT64 ui64Config2PhyMask,
                        IMG_UINT64 ui64Config2Settings);
#else
#define RGXDataRemapConfig(priv, c1reg, c1val, c2reg, c2phyaddr, c2phymask, c2settings) do { \
       RGXWriteReg64(priv, c1reg, (c1val)); \
       RGXWriteReg64(priv, c2reg, ((c2phyaddr) & (c2phymask)) | (c2settings)); \
   } while (0)
#endif
 
/*!
*******************************************************************************
 
 @Function        RGXAcquireTrampolineRemapAddr
 
 @Description     Acquire the device physical address of the MIPS data
                  accessed through remap region
 
 @Input           hPrivate             : Implementation specific data
 @Output          psTrampolineRemapAddr: Base address of the remapped data
 
 @Return          void
 
******************************************************************************/
void RGXAcquireTrampolineRemapAddr(const void *hPrivate, IMG_DEV_PHYADDR *psTrampolineRemapAddr);
 
/*!
*******************************************************************************
 
 @Function        RGXTrampolineRemapConfig
 
 @Description     Configure the trampoline remap registers passed as arguments.
                  In a driver-live scenario without PDump this is the same as
                  two RGXWriteReg64 and it doesn't need to be reimplemented.
 
 @Input           hPrivate             : Implementation specific data
 @Input           ui32Config1RegAddr   : Remap config1 register offset
 @Input           ui64Config1RegValue  : Remap config1 register value
 @Input           ui32Config2RegAddr   : Remap config2 register offset
 @Input           ui64Config2PhyAddr   : Output remapped aligned physical address
 @Input           ui64Config2PhyMask   : Mask for the output physical address
 @Input           ui64Config2Settings  : Extra settings for this remap region
 
 @Return          void
 
******************************************************************************/
#define RGXTrampolineRemapConfig(priv, c1reg, c1val, c2reg, c2phyaddr, c2phymask, c2settings) do { \
       RGXWriteReg64(priv, c1reg, (c1val)); \
       RGXWriteReg64(priv, c2reg, ((c2phyaddr) & (c2phymask)) | (c2settings)); \
   } while (0)
 
/*!
*******************************************************************************
 
 @Function        RGXDoFWSlaveBoot
 
 @Description     Returns whether or not a FW Slave Boot is required
                  while powering on
 
 @Input           hPrivate       : Implementation specific data
 
 @Return          IMG_BOOL
 
******************************************************************************/
IMG_BOOL RGXDoFWSlaveBoot(const void *hPrivate);
 
/*!
*******************************************************************************
 
 @Function       RGXIOCoherencyTest
 
 @Description    Performs a coherency test
 
 @Input          hPrivate         : Implementation specific data
 
 @Return         PVRSRV_OK if the test succeeds,
                 PVRSRV_ERROR_INIT_FAILURE if the test fails at some point
 
******************************************************************************/
PVRSRV_ERROR RGXIOCoherencyTest(const void *hPrivate);
 
/*!
*******************************************************************************
 
 @Function       RGXDeviceHasFeaturePower
 
 @Description    Checks if a device has a particular feature
 
 @Input          hPrivate     : Implementation specific data
 @Input          ui64Feature  : Feature to check
 
 @Return         IMG_TRUE if the given feature is available, IMG_FALSE otherwise
 
******************************************************************************/
IMG_BOOL RGXDeviceHasFeaturePower(const void *hPrivate, IMG_UINT64 ui64Feature);
 
/*!
*******************************************************************************
 
 @Function       RGXDeviceHasErnBrnPower
 
 @Description    Checks if a device has a particular errata
 
 @Input          hPrivate     : Implementation specific data
 @Input          ui64ErnsBrns : Flags to check
 
 @Return         IMG_TRUE if the given errata is available, IMG_FALSE otherwise
 
******************************************************************************/
IMG_BOOL RGXDeviceHasErnBrnPower(const void *hPrivate, IMG_UINT64 ui64ErnsBrns);
 
/*!
*******************************************************************************
 
 @Function       RGXGetDeviceSLCBanks
 
 @Description    Returns the number of SLC banks used by the device
 
 @Input          hPrivate    : Implementation specific data
 
 @Return         Number of SLC banks
 
******************************************************************************/
IMG_UINT32 RGXGetDeviceSLCBanks(const void *hPrivate);
 
/*!
*******************************************************************************
 
 @Function       RGXGetDeviceSLCSize
 
 @Description    Returns the device SLC size
 
 @Input          hPrivate    : Implementation specific data
 
 @Return         SLC size
 
******************************************************************************/
IMG_UINT32 RGXGetDeviceSLCSize(const void *hPrivate);
 
/*!
*******************************************************************************
 
 @Function       RGXGetDeviceCacheLineSize
 
 @Description    Returns the device cache line size
 
 @Input          hPrivate    : Implementation specific data
 
 @Return         Cache line size
 
******************************************************************************/
IMG_UINT32 RGXGetDeviceCacheLineSize(const void *hPrivate);
 
#if defined (__cplusplus)
}
#endif
 
#endif /* !defined (__RGXLAYER_KM_H__) */