gc_hal_vg.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. /****************************************************************************
  2. *
  3. * Copyright (c) 2005 - 2014 by Vivante Corp. All rights reserved.
  4. *
  5. * The material in this file is confidential and contains trade secrets
  6. * of Vivante Corporation. This is proprietary information owned by
  7. * Vivante Corporation. No part of this work may be disclosed,
  8. * reproduced, copied, transmitted, or used in any way for any purpose,
  9. * without the express written permission of Vivante Corporation.
  10. *
  11. *****************************************************************************/
  12. #ifndef __gc_hal_vg_h_
  13. #define __gc_hal_vg_h_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include "gc_hal_rename.h"
  18. #include "gc_hal_types.h"
  19. #include "gc_hal_enum.h"
  20. #include "gc_hal_base.h"
  21. #if gcdENABLE_VG
  22. /* Thread routine type. */
  23. #if defined(LINUX)
  24. typedef gctINT gctTHREADFUNCRESULT;
  25. typedef gctPOINTER gctTHREADFUNCPARAMETER;
  26. # define gctTHREADFUNCTYPE
  27. #elif defined(WIN32)
  28. typedef gctUINT gctTHREADFUNCRESULT;
  29. typedef gctPOINTER gctTHREADFUNCPARAMETER;
  30. # define gctTHREADFUNCTYPE __stdcall
  31. #elif defined(__QNXNTO__)
  32. typedef void * gctTHREADFUNCRESULT;
  33. typedef gctPOINTER gctTHREADFUNCPARAMETER;
  34. # define gctTHREADFUNCTYPE
  35. #endif
  36. typedef gctTHREADFUNCRESULT (gctTHREADFUNCTYPE * gctTHREADFUNC) (
  37. gctTHREADFUNCPARAMETER ThreadParameter
  38. );
  39. #if defined(gcvDEBUG)
  40. # undef gcvDEBUG
  41. #endif
  42. #define gcdFORCE_DEBUG 0
  43. #define gcdFORCE_MESSAGES 0
  44. #if DBG || defined(DEBUG) || defined(_DEBUG) || gcdFORCE_DEBUG
  45. # define gcvDEBUG 1
  46. #else
  47. # define gcvDEBUG 0
  48. #endif
  49. #define _gcmERROR_RETURN(prefix, func) \
  50. status = func; \
  51. if (gcmIS_ERROR(status)) \
  52. { \
  53. prefix##PRINT_VERSION(); \
  54. prefix##TRACE(gcvLEVEL_ERROR, \
  55. #prefix "ERR_RETURN: status=%d(%s) @ %s(%d)", \
  56. status, gcoOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
  57. return status; \
  58. } \
  59. do { } while (gcvFALSE)
  60. #define gcmERROR_RETURN(func) _gcmERROR_RETURN(gcm, func)
  61. #define gcmLOG_LOCATION()
  62. #define gcmkIS_ERROR(status) (status < 0)
  63. #define gcmALIGNDOWN(n, align) \
  64. ( \
  65. (n) & ~((align) - 1) \
  66. )
  67. #define gcmIS_VALID_INDEX(Index, Array) \
  68. (((gctUINT) (Index)) < gcmCOUNTOF(Array))
  69. #define gcmIS_NAN(x) \
  70. ( \
  71. ((* (gctUINT32_PTR) &(x)) & 0x7FFFFFFF) == 0x7FFFFFFF \
  72. )
  73. #define gcmLERP(v1, v2, w) \
  74. ((v1) * (w) + (v2) * (1.0f - (w)))
  75. #define gcmINTERSECT(Start1, Start2, Length) \
  76. (gcmABS((Start1) - (Start2)) < (Length))
  77. /*******************************************************************************
  78. **
  79. ** gcmERR_GOTO
  80. **
  81. ** Prints a message and terminates the current loop on error.
  82. **
  83. ** ASSUMPTIONS:
  84. **
  85. ** 'status' variable of gceSTATUS type must be defined.
  86. **
  87. ** ARGUMENTS:
  88. **
  89. ** Function
  90. ** Function to evaluate.
  91. */
  92. #define gcmERR_GOTO(Function) \
  93. status = Function; \
  94. if (gcmIS_ERROR(status)) \
  95. { \
  96. gcmTRACE( \
  97. gcvLEVEL_ERROR, \
  98. "gcmERR_GOTO: status=%d @ line=%d in function %s.\n", \
  99. status, __LINE__, __FUNCTION__ \
  100. ); \
  101. goto ErrorHandler; \
  102. }
  103. #if gcvDEBUG || gcdFORCE_MESSAGES
  104. # define gcmVERIFY_BOOLEAN(Expression) \
  105. gcmASSERT( \
  106. ( (Expression) == gcvFALSE ) || \
  107. ( (Expression) == gcvTRUE ) \
  108. )
  109. #else
  110. # define gcmVERIFY_BOOLEAN(Expression)
  111. #endif
  112. /*******************************************************************************
  113. **
  114. ** gcmVERIFYFIELDFIT
  115. **
  116. ** Verify whether the value fits in the field.
  117. **
  118. ** ARGUMENTS:
  119. **
  120. ** data Data value.
  121. ** reg Name of register.
  122. ** field Name of field within register.
  123. ** value Value for field.
  124. */
  125. #define gcmVERIFYFIELDFIT(reg, field, value) \
  126. gcmASSERT( \
  127. (value) <= gcmFIELDMAX(reg, field) \
  128. )
  129. /*******************************************************************************
  130. **
  131. ** gcmFIELDMAX
  132. **
  133. ** Get field maximum value.
  134. **
  135. ** ARGUMENTS:
  136. **
  137. ** reg Name of register.
  138. ** field Name of field within register.
  139. */
  140. #define gcmFIELDMAX(reg, field) \
  141. ( \
  142. (gctUINT32) \
  143. ( \
  144. (__gcmGETSIZE(reg##_##field) == 32) \
  145. ? ~0 \
  146. : (~(~0 << __gcmGETSIZE(reg##_##field))) \
  147. ) \
  148. )
  149. /* ANSI C does not have the 'f' functions, define replacements here. */
  150. #define gcmSINF(x) ((gctFLOAT) sin(x))
  151. #define gcmCOSF(x) ((gctFLOAT) cos(x))
  152. #define gcmASINF(x) ((gctFLOAT) asin(x))
  153. #define gcmACOSF(x) ((gctFLOAT) acos(x))
  154. #define gcmSQRTF(x) ((gctFLOAT) sqrt(x))
  155. #define gcmFABSF(x) ((gctFLOAT) fabs(x))
  156. #define gcmFMODF(x, y) ((gctFLOAT) fmod((x), (y)))
  157. #define gcmCEILF(x) ((gctFLOAT) ceil(x))
  158. #define gcmFLOORF(x) ((gctFLOAT) floor(x))
  159. /* Fixed point constants. */
  160. #define gcvZERO_X ((gctFIXED_POINT) 0x00000000)
  161. #define gcvHALF_X ((gctFIXED_POINT) 0x00008000)
  162. #define gcvONE_X ((gctFIXED_POINT) 0x00010000)
  163. #define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000)
  164. #define gcvTWO_X ((gctFIXED_POINT) 0x00020000)
  165. /* Integer constants. */
  166. #define gcvMAX_POS_INT ((gctINT) 0x7FFFFFFF)
  167. #define gcvMAX_NEG_INT ((gctINT) 0x80000000)
  168. /* Float constants. */
  169. #define gcvMAX_POS_FLOAT ((gctFLOAT) 3.4028235e+038)
  170. #define gcvMAX_NEG_FLOAT ((gctFLOAT) -3.4028235e+038)
  171. /******************************************************************************\
  172. ***************************** Miscellaneous Macro ******************************
  173. \******************************************************************************/
  174. #define gcmKB2BYTES(Kilobyte) \
  175. ( \
  176. (Kilobyte) << 10 \
  177. )
  178. #define gcmMB2BYTES(Megabyte) \
  179. ( \
  180. (Megabyte) << 20 \
  181. )
  182. #define gcmMAT(Matrix, Row, Column) \
  183. ( \
  184. (Matrix) [(Row) * 3 + (Column)] \
  185. )
  186. #define gcmMAKE2CHAR(Char1, Char2) \
  187. ( \
  188. ((gctUINT16) (gctUINT8) (Char1) << 0) | \
  189. ((gctUINT16) (gctUINT8) (Char2) << 8) \
  190. )
  191. #define gcmMAKE4CHAR(Char1, Char2, Char3, Char4) \
  192. ( \
  193. ((gctUINT32)(gctUINT8) (Char1) << 0) | \
  194. ((gctUINT32)(gctUINT8) (Char2) << 8) | \
  195. ((gctUINT32)(gctUINT8) (Char3) << 16) | \
  196. ((gctUINT32)(gctUINT8) (Char4) << 24) \
  197. )
  198. /* some platforms need to fix the physical address for HW to access*/
  199. #define gcmFIXADDRESS(address) \
  200. (\
  201. (address)\
  202. )
  203. #define gcmkFIXADDRESS(address) \
  204. (\
  205. (address)\
  206. )
  207. /******************************************************************************\
  208. ****************************** Kernel Debug Macro ******************************
  209. \******************************************************************************/
  210. /* Set signal to signaled state for specified process. */
  211. gceSTATUS
  212. gckOS_SetSignal(
  213. IN gckOS Os,
  214. IN gctHANDLE Process,
  215. IN gctSIGNAL Signal
  216. );
  217. /* Return the kernel logical pointer for the given physical one. */
  218. gceSTATUS
  219. gckOS_GetKernelLogical(
  220. IN gckOS Os,
  221. IN gctUINT32 Address,
  222. OUT gctPOINTER * KernelPointer
  223. );
  224. /* Return the kernel logical pointer for the given physical one. */
  225. gceSTATUS
  226. gckOS_GetKernelLogicalEx(
  227. IN gckOS Os,
  228. IN gceCORE Core,
  229. IN gctUINT32 Address,
  230. OUT gctPOINTER * KernelPointer
  231. );
  232. /*----------------------------------------------------------------------------*/
  233. /*----------------------------- Semaphore Object -----------------------------*/
  234. /* Increment the value of a semaphore. */
  235. gceSTATUS
  236. gckOS_IncrementSemaphore(
  237. IN gckOS Os,
  238. IN gctSEMAPHORE Semaphore
  239. );
  240. /* Decrement the value of a semaphore (waiting might occur). */
  241. gceSTATUS
  242. gckOS_DecrementSemaphore(
  243. IN gckOS Os,
  244. IN gctSEMAPHORE Semaphore
  245. );
  246. /*----------------------------------------------------------------------------*/
  247. /*------------------------------- Thread Object ------------------------------*/
  248. /* Start a thread. */
  249. gceSTATUS
  250. gckOS_StartThread(
  251. IN gckOS Os,
  252. IN gctTHREADFUNC ThreadFunction,
  253. IN gctPOINTER ThreadParameter,
  254. OUT gctTHREAD * Thread
  255. );
  256. /* Stop a thread. */
  257. gceSTATUS
  258. gckOS_StopThread(
  259. IN gckOS Os,
  260. IN gctTHREAD Thread
  261. );
  262. /* Verify whether the thread is still running. */
  263. gceSTATUS
  264. gckOS_VerifyThread(
  265. IN gckOS Os,
  266. IN gctTHREAD Thread
  267. );
  268. /* Construct a new gckVGKERNEL object. */
  269. gceSTATUS
  270. gckVGKERNEL_Construct(
  271. IN gckOS Os,
  272. IN gctPOINTER Context,
  273. IN gckKERNEL inKernel,
  274. OUT gckVGKERNEL * Kernel
  275. );
  276. /* Destroy an gckVGKERNEL object. */
  277. gceSTATUS
  278. gckVGKERNEL_Destroy(
  279. IN gckVGKERNEL Kernel
  280. );
  281. /* Allocate linear video memory. */
  282. gceSTATUS
  283. gckVGKERNEL_AllocateLinearMemory(
  284. IN gckKERNEL Kernel,
  285. IN OUT gcePOOL * Pool,
  286. IN gctSIZE_T Bytes,
  287. IN gctUINT32 Alignment,
  288. IN gceSURF_TYPE Type,
  289. OUT gcuVIDMEM_NODE_PTR * Node
  290. );
  291. /* Unmap memory. */
  292. gceSTATUS
  293. gckKERNEL_UnmapMemory(
  294. IN gckKERNEL Kernel,
  295. IN gctPHYS_ADDR Physical,
  296. IN gctSIZE_T Bytes,
  297. IN gctPOINTER Logical
  298. );
  299. /* Dispatch a user-level command. */
  300. gceSTATUS
  301. gckVGKERNEL_Dispatch(
  302. IN gckKERNEL Kernel,
  303. IN gctBOOL FromUser,
  304. IN OUT struct _gcsHAL_INTERFACE * Interface
  305. );
  306. /* Query command buffer requirements. */
  307. gceSTATUS
  308. gckKERNEL_QueryCommandBuffer(
  309. IN gckKERNEL Kernel,
  310. OUT gcsCOMMAND_BUFFER_INFO_PTR Information
  311. );
  312. /******************************************************************************\
  313. ******************************* gckVGHARDWARE Object ******************************
  314. \******************************************************************************/
  315. /* Construct a new gckVGHARDWARE object. */
  316. gceSTATUS
  317. gckVGHARDWARE_Construct(
  318. IN gckOS Os,
  319. OUT gckVGHARDWARE * Hardware
  320. );
  321. /* Destroy an gckVGHARDWARE object. */
  322. gceSTATUS
  323. gckVGHARDWARE_Destroy(
  324. IN gckVGHARDWARE Hardware
  325. );
  326. /* Query system memory requirements. */
  327. gceSTATUS
  328. gckVGHARDWARE_QuerySystemMemory(
  329. IN gckVGHARDWARE Hardware,
  330. OUT gctSIZE_T * SystemSize,
  331. OUT gctUINT32 * SystemBaseAddress
  332. );
  333. /* Build virtual address. */
  334. gceSTATUS
  335. gckVGHARDWARE_BuildVirtualAddress(
  336. IN gckVGHARDWARE Hardware,
  337. IN gctUINT32 Index,
  338. IN gctUINT32 Offset,
  339. OUT gctUINT32 * Address
  340. );
  341. /* Kickstart the command processor. */
  342. gceSTATUS
  343. gckVGHARDWARE_Execute(
  344. IN gckVGHARDWARE Hardware,
  345. IN gctUINT32 Address,
  346. IN gctUINT32 Count
  347. );
  348. /* Query the available memory. */
  349. gceSTATUS
  350. gckVGHARDWARE_QueryMemory(
  351. IN gckVGHARDWARE Hardware,
  352. OUT gctSIZE_T * InternalSize,
  353. OUT gctUINT32 * InternalBaseAddress,
  354. OUT gctUINT32 * InternalAlignment,
  355. OUT gctSIZE_T * ExternalSize,
  356. OUT gctUINT32 * ExternalBaseAddress,
  357. OUT gctUINT32 * ExternalAlignment,
  358. OUT gctUINT32 * HorizontalTileSize,
  359. OUT gctUINT32 * VerticalTileSize
  360. );
  361. /* Query the identity of the hardware. */
  362. gceSTATUS
  363. gckVGHARDWARE_QueryChipIdentity(
  364. IN gckVGHARDWARE Hardware,
  365. OUT gceCHIPMODEL* ChipModel,
  366. OUT gctUINT32* ChipRevision,
  367. OUT gctUINT32* ChipFeatures,
  368. OUT gctUINT32* ChipMinorFeatures,
  369. OUT gctUINT32* ChipMinorFeatures1
  370. );
  371. /* Convert an API format. */
  372. gceSTATUS
  373. gckVGHARDWARE_ConvertFormat(
  374. IN gckVGHARDWARE Hardware,
  375. IN gceSURF_FORMAT Format,
  376. OUT gctUINT32 * BitsPerPixel,
  377. OUT gctUINT32 * BytesPerTile
  378. );
  379. /* Split a harwdare specific address into API stuff. */
  380. gceSTATUS
  381. gckVGHARDWARE_SplitMemory(
  382. IN gckVGHARDWARE Hardware,
  383. IN gctUINT32 Address,
  384. OUT gcePOOL * Pool,
  385. OUT gctUINT32 * Offset
  386. );
  387. /* Align size to tile boundary. */
  388. gceSTATUS
  389. gckVGHARDWARE_AlignToTile(
  390. IN gckVGHARDWARE Hardware,
  391. IN gceSURF_TYPE Type,
  392. IN OUT gctUINT32_PTR Width,
  393. IN OUT gctUINT32_PTR Height
  394. );
  395. /* Convert logical address to hardware specific address. */
  396. gceSTATUS
  397. gckVGHARDWARE_ConvertLogical(
  398. IN gckVGHARDWARE Hardware,
  399. IN gctPOINTER Logical,
  400. IN gctBOOL InUserSpace,
  401. OUT gctUINT32 * Address
  402. );
  403. /* Program MMU. */
  404. gceSTATUS
  405. gckVGHARDWARE_SetMMU(
  406. IN gckVGHARDWARE Hardware,
  407. IN gctPOINTER Logical
  408. );
  409. /* Flush the MMU. */
  410. gceSTATUS
  411. gckVGHARDWARE_FlushMMU(
  412. IN gckVGHARDWARE Hardware
  413. );
  414. /* Get idle register. */
  415. gceSTATUS
  416. gckVGHARDWARE_GetIdle(
  417. IN gckVGHARDWARE Hardware,
  418. OUT gctUINT32 * Data
  419. );
  420. /* Flush the caches. */
  421. gceSTATUS
  422. gckVGHARDWARE_Flush(
  423. IN gckVGHARDWARE Hardware,
  424. IN gceKERNEL_FLUSH Flush,
  425. IN gctPOINTER Logical,
  426. IN OUT gctSIZE_T * Bytes
  427. );
  428. /* Enable/disable fast clear. */
  429. gceSTATUS
  430. gckVGHARDWARE_SetFastClear(
  431. IN gckVGHARDWARE Hardware,
  432. IN gctINT Enable
  433. );
  434. gceSTATUS
  435. gckVGHARDWARE_ReadInterrupt(
  436. IN gckVGHARDWARE Hardware,
  437. OUT gctUINT32_PTR IDs
  438. );
  439. /* Power management. */
  440. gceSTATUS
  441. gckVGHARDWARE_SetPowerManagementState(
  442. IN gckVGHARDWARE Hardware,
  443. IN gceCHIPPOWERSTATE State
  444. );
  445. gceSTATUS
  446. gckVGHARDWARE_QueryPowerManagementState(
  447. IN gckVGHARDWARE Hardware,
  448. OUT gceCHIPPOWERSTATE* State
  449. );
  450. gceSTATUS
  451. gckVGHARDWARE_SetPowerManagement(
  452. IN gckVGHARDWARE Hardware,
  453. IN gctBOOL PowerManagement
  454. );
  455. gceSTATUS
  456. gckVGHARDWARE_SetPowerOffTimeout(
  457. IN gckVGHARDWARE Hardware,
  458. IN gctUINT32 Timeout
  459. );
  460. gceSTATUS
  461. gckVGHARDWARE_QueryPowerOffTimeout(
  462. IN gckVGHARDWARE Hardware,
  463. OUT gctUINT32* Timeout
  464. );
  465. gceSTATUS
  466. gckVGHARDWARE_QueryIdle(
  467. IN gckVGHARDWARE Hardware,
  468. OUT gctBOOL_PTR IsIdle
  469. );
  470. /******************************************************************************\
  471. *************************** Command Buffer Structures **************************
  472. \******************************************************************************/
  473. /* Vacant command buffer marker. */
  474. #define gcvVACANT_BUFFER ((gcsCOMPLETION_SIGNAL_PTR) ((gctSIZE_T)1))
  475. /* Command buffer header. */
  476. typedef struct _gcsCMDBUFFER * gcsCMDBUFFER_PTR;
  477. typedef struct _gcsCMDBUFFER
  478. {
  479. /* Pointer to the completion signal. */
  480. gcsCOMPLETION_SIGNAL_PTR completion;
  481. /* The user sets this to the node of the container buffer whitin which
  482. this particular command buffer resides. The kernel sets this to the
  483. node of the internally allocated buffer. */
  484. gcuVIDMEM_NODE_PTR node;
  485. /* Command buffer hardware address. */
  486. gctUINT32 address;
  487. /* The offset of the buffer from the beginning of the header. */
  488. gctUINT32 bufferOffset;
  489. /* Size of the area allocated for the data portion of this particular
  490. command buffer (headers and tail reserves are excluded). */
  491. gctUINT32 size;
  492. /* Offset into the buffer [0..size]; reflects exactly how much data has
  493. been put into the command buffer. */
  494. gctUINT offset;
  495. /* The number of command units in the buffer for the hardware to
  496. execute. */
  497. gctUINT32 dataCount;
  498. /* MANAGED BY : user HAL (gcoBUFFER object).
  499. USED BY : user HAL (gcoBUFFER object).
  500. Points to the immediate next allocated command buffer. */
  501. gcsCMDBUFFER_PTR nextAllocated;
  502. /* MANAGED BY : user layers (HAL and drivers).
  503. USED BY : kernel HAL (gcoBUFFER object).
  504. Points to the next subbuffer if any. A family of subbuffers are chained
  505. together and are meant to be executed inseparably as a unit. Meaning
  506. that context switching cannot occur while a chain of subbuffers is being
  507. executed. */
  508. gcsCMDBUFFER_PTR nextSubBuffer;
  509. }
  510. gcsCMDBUFFER;
  511. /* Command queue element. */
  512. typedef struct _gcsVGCMDQUEUE
  513. {
  514. /* Pointer to the command buffer header. */
  515. gcsCMDBUFFER_PTR commandBuffer;
  516. /* Dynamic vs. static command buffer state. */
  517. gctBOOL dynamic;
  518. }
  519. gcsVGCMDQUEUE;
  520. /* Context map entry. */
  521. typedef struct _gcsVGCONTEXT_MAP
  522. {
  523. /* State index. */
  524. gctUINT32 index;
  525. /* New state value. */
  526. gctUINT32 data;
  527. /* Points to the next entry in the mod list. */
  528. gcsVGCONTEXT_MAP_PTR next;
  529. }
  530. gcsVGCONTEXT_MAP;
  531. /* gcsVGCONTEXT structure that holds the current context. */
  532. typedef struct _gcsVGCONTEXT
  533. {
  534. /* Context ID. */
  535. gctUINT64 id;
  536. /* State caching ebable flag. */
  537. gctBOOL stateCachingEnabled;
  538. /* Current pipe. */
  539. gctUINT32 currentPipe;
  540. /* State map/mod buffer. */
  541. gctUINT32 mapFirst;
  542. gctUINT32 mapLast;
  543. gcsVGCONTEXT_MAP_PTR mapContainer;
  544. gcsVGCONTEXT_MAP_PTR mapPrev;
  545. gcsVGCONTEXT_MAP_PTR mapCurr;
  546. gcsVGCONTEXT_MAP_PTR firstPrevMap;
  547. gcsVGCONTEXT_MAP_PTR firstCurrMap;
  548. /* Main context buffer. */
  549. gcsCMDBUFFER_PTR header;
  550. gctUINT32_PTR buffer;
  551. /* Completion signal. */
  552. gctHANDLE process;
  553. gctSIGNAL signal;
  554. #if defined(__QNXNTO__)
  555. gctSIGNAL userSignal;
  556. gctINT32 coid;
  557. gctINT32 rcvid;
  558. #endif
  559. }
  560. gcsVGCONTEXT;
  561. /* User space task header. */
  562. typedef struct _gcsTASK * gcsTASK_PTR;
  563. typedef struct _gcsTASK
  564. {
  565. /* Pointer to the next task for the same interrupt in user space. */
  566. gcsTASK_PTR next;
  567. /* Size of the task data that immediately follows the structure. */
  568. gctUINT size;
  569. /* Task data starts here. */
  570. /* ... */
  571. }
  572. gcsTASK;
  573. /* User space task master table entry. */
  574. typedef struct _gcsTASK_MASTER_ENTRY * gcsTASK_MASTER_ENTRY_PTR;
  575. typedef struct _gcsTASK_MASTER_ENTRY
  576. {
  577. /* Pointers to the head and to the tail of the task chain. */
  578. gcsTASK_PTR head;
  579. gcsTASK_PTR tail;
  580. }
  581. gcsTASK_MASTER_ENTRY;
  582. /* User space task master table entry. */
  583. typedef struct _gcsTASK_MASTER_TABLE
  584. {
  585. /* Table with one entry per block. */
  586. gcsTASK_MASTER_ENTRY table[gcvBLOCK_COUNT];
  587. /* The total number of tasks sckeduled. */
  588. gctUINT count;
  589. /* The total size of event data in bytes. */
  590. gctUINT size;
  591. #if defined(__QNXNTO__)
  592. gctINT32 coid;
  593. gctINT32 rcvid;
  594. #endif
  595. }
  596. gcsTASK_MASTER_TABLE;
  597. /******************************************************************************\
  598. ***************************** gckVGINTERRUPT Object ******************************
  599. \******************************************************************************/
  600. typedef struct _gckVGINTERRUPT * gckVGINTERRUPT;
  601. typedef gceSTATUS (* gctINTERRUPT_HANDLER)(
  602. IN gckVGKERNEL Kernel
  603. );
  604. gceSTATUS
  605. gckVGINTERRUPT_Construct(
  606. IN gckVGKERNEL Kernel,
  607. OUT gckVGINTERRUPT * Interrupt
  608. );
  609. gceSTATUS
  610. gckVGINTERRUPT_Destroy(
  611. IN gckVGINTERRUPT Interrupt
  612. );
  613. gceSTATUS
  614. gckVGINTERRUPT_Enable(
  615. IN gckVGINTERRUPT Interrupt,
  616. IN OUT gctINT32_PTR Id,
  617. IN gctINTERRUPT_HANDLER Handler
  618. );
  619. gceSTATUS
  620. gckVGINTERRUPT_Disable(
  621. IN gckVGINTERRUPT Interrupt,
  622. IN gctINT32 Id
  623. );
  624. #ifndef __QNXNTO__
  625. gceSTATUS
  626. gckVGINTERRUPT_Enque(
  627. IN gckVGINTERRUPT Interrupt
  628. );
  629. #else
  630. gceSTATUS
  631. gckVGINTERRUPT_Enque(
  632. IN gckVGINTERRUPT Interrupt,
  633. OUT gckOS *Os,
  634. OUT gctSEMAPHORE *Semaphore
  635. );
  636. #endif
  637. gceSTATUS
  638. gckVGINTERRUPT_DumpState(
  639. IN gckVGINTERRUPT Interrupt
  640. );
  641. /******************************************************************************\
  642. ******************************* gckVGCOMMAND Object *******************************
  643. \******************************************************************************/
  644. typedef struct _gckVGCOMMAND * gckVGCOMMAND;
  645. /* Construct a new gckVGCOMMAND object. */
  646. gceSTATUS
  647. gckVGCOMMAND_Construct(
  648. IN gckVGKERNEL Kernel,
  649. IN gctUINT TaskGranularity,
  650. IN gctUINT QueueSize,
  651. OUT gckVGCOMMAND * Command
  652. );
  653. /* Destroy an gckVGCOMMAND object. */
  654. gceSTATUS
  655. gckVGCOMMAND_Destroy(
  656. IN gckVGCOMMAND Command
  657. );
  658. /* Query command buffer attributes. */
  659. gceSTATUS
  660. gckVGCOMMAND_QueryCommandBuffer(
  661. IN gckVGCOMMAND Command,
  662. OUT gcsCOMMAND_BUFFER_INFO_PTR Information
  663. );
  664. /* Allocate a command queue. */
  665. gceSTATUS
  666. gckVGCOMMAND_Allocate(
  667. IN gckVGCOMMAND Command,
  668. IN gctSIZE_T Size,
  669. OUT gcsCMDBUFFER_PTR * CommandBuffer,
  670. OUT gctPOINTER * Data
  671. );
  672. /* Release memory held by the command queue. */
  673. gceSTATUS
  674. gckVGCOMMAND_Free(
  675. IN gckVGCOMMAND Command,
  676. IN gcsCMDBUFFER_PTR CommandBuffer
  677. );
  678. /* Schedule the command queue for execution. */
  679. gceSTATUS
  680. gckVGCOMMAND_Execute(
  681. IN gckVGCOMMAND Command,
  682. IN gcsCMDBUFFER_PTR CommandBuffer
  683. );
  684. /* Commit a buffer to the command queue. */
  685. gceSTATUS
  686. gckVGCOMMAND_Commit(
  687. IN gckVGCOMMAND Command,
  688. IN gcsVGCONTEXT_PTR Context,
  689. IN gcsVGCMDQUEUE_PTR Queue,
  690. IN gctUINT EntryCount,
  691. IN gcsTASK_MASTER_TABLE_PTR TaskTable
  692. );
  693. /******************************************************************************\
  694. ********************************* gckVGMMU Object ********************************
  695. \******************************************************************************/
  696. typedef struct _gckVGMMU * gckVGMMU;
  697. /* Construct a new gckVGMMU object. */
  698. gceSTATUS
  699. gckVGMMU_Construct(
  700. IN gckVGKERNEL Kernel,
  701. IN gctUINT32 MmuSize,
  702. OUT gckVGMMU * Mmu
  703. );
  704. /* Destroy an gckVGMMU object. */
  705. gceSTATUS
  706. gckVGMMU_Destroy(
  707. IN gckVGMMU Mmu
  708. );
  709. /* Allocate pages inside the MMU. */
  710. gceSTATUS
  711. gckVGMMU_AllocatePages(
  712. IN gckVGMMU Mmu,
  713. IN gctSIZE_T PageCount,
  714. OUT gctPOINTER * PageTable,
  715. OUT gctUINT32 * Address
  716. );
  717. /* Remove a page table from the MMU. */
  718. gceSTATUS
  719. gckVGMMU_FreePages(
  720. IN gckVGMMU Mmu,
  721. IN gctPOINTER PageTable,
  722. IN gctSIZE_T PageCount
  723. );
  724. /* Set the MMU page with info. */
  725. gceSTATUS
  726. gckVGMMU_SetPage(
  727. IN gckVGMMU Mmu,
  728. IN gctUINT32 PageAddress,
  729. IN gctUINT32 *PageEntry
  730. );
  731. /* Flush MMU */
  732. gceSTATUS
  733. gckVGMMU_Flush(
  734. IN gckVGMMU Mmu
  735. );
  736. #endif /* gcdENABLE_VG */
  737. #ifdef __cplusplus
  738. } /* extern "C" */
  739. #endif
  740. #endif /* __gc_hal_h_ */