Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.4 KiB

  1. //========= Copyright � 1996-2004, Valve LLC, All rights reserved. ============
  2. //
  3. // This common file serves as redirection to make minimal SPU-only preparation
  4. // of a job and call into its Main function. The Main function is hidden behind
  5. // the unique namespace, just like all global symbols, so that multiple similar
  6. // jobs can easily compile into and link with the vjobs.prx module that can call
  7. // them on PPU either for debugging, for fallback case, or for main processing
  8. // on Xbox360
  9. //
  10. //#include <cell/spurs/job_chain.h>
  11. #include <cell/spurs/job_queue.h>
  12. #include <cell/spurs/job_context.h>
  13. #include <spu_printf.h>
  14. #ifdef USE_LSGUARD
  15. #include <cell/lsguard.h>
  16. #endif
  17. #ifndef VJOB
  18. #error "Please define VJOB to the project name in SPU job project. This will isolate it from other jobs when they compile into the common elf, prx or dll"
  19. #endif
  20. namespace VJOB
  21. {
  22. extern void Main( CellSpursJobContext2* stInfo, CellSpursJob256 *job );
  23. }
  24. CellSpursJobContext2* g_stInfo = 0;
  25. uint32_t g_InterlockedBuffer[32] __attribute__((aligned(128)));
  26. #ifdef VJOB_JOBCHAIN_JOB
  27. // JobChain job: the symbol is "job"
  28. extern "C"
  29. void cellSpursJobMain2(CellSpursJobContext2* stInfo, CellSpursJob256 *job)
  30. {
  31. extern CellSpursJobContext2* g_stInfo;
  32. g_stInfo = stInfo;
  33. VJOB::Main( stInfo, job );
  34. }
  35. #else
  36. // JobQueue job: the symbol is "jqjob"
  37. void cellSpursJobQueueMain(
  38. CellSpursJobContext2 *pContext,
  39. CellSpursJob256 *pJob
  40. )
  41. {
  42. extern CellSpursJobContext2* g_stInfo;
  43. g_stInfo = pContext;
  44. VJOB::Main( pContext, pJob );
  45. }
  46. #endif
  47. void CheckBufferOverflow_Impl()
  48. {
  49. uint16_t nCause;
  50. int nResult;
  51. nResult = cellSpursJobMemoryCheckTest( &nCause );
  52. if ( nResult != CELL_OK )
  53. {
  54. spu_printf( "cellSpursJobMemoryCheckTest() failed = %08X\n", nResult );
  55. __asm volatile ("stopd $0,$0,$0");
  56. }
  57. #ifdef USE_LSGUARD
  58. nResult = cellLsGuardCheckCorruption();
  59. if ( nResult != CELL_OK )
  60. {
  61. spu_printf( "cellLsGuardCheckCorruption() failed = %08X\n", nResult );
  62. __asm volatile ("stopd $0,$0,$0");
  63. cellLsGuardRehash(); // We rehash to detect the next corruption
  64. }
  65. #endif
  66. }
  67. void CheckDmaGet_Impl( const void * pBuffer, size_t nSize )
  68. {
  69. #ifdef USE_LSGUARD
  70. int nResult;
  71. nResult = cellLsGuardCheckWriteAccess( pBuffer, nSize );
  72. if ( nResult != CELL_OK )
  73. {
  74. spu_printf( "cellLsGuardCheckWriteAccess() failed = %08X\n", nResult );
  75. spu_printf( "Address: %08X - Size: %d\n", (int)pBuffer, (int)nSize );
  76. __asm volatile ("stopd $0,$0,$0");
  77. }
  78. #endif
  79. }