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.

98 lines
2.9 KiB

  1. //================ Copyright (c) Valve Corporation. All Rights Reserved. ===========================
  2. //
  3. //
  4. //
  5. //==================================================================================================
  6. #ifndef INCLUDED_SPUMGR_DMA_H
  7. #define INCLUDED_SPUMGR_DMA_H
  8. //--------------------------------------------------------------------------------------------------
  9. // Headers
  10. //--------------------------------------------------------------------------------------------------
  11. #include <stdint.h>
  12. #ifdef SPU
  13. //#include <Stdshader_spu/Inc/debug_spu.h> // MH
  14. #else
  15. #include <debug/inc/debug.h>
  16. #endif
  17. //--------------------------------------------------------------------------------------------------
  18. // Defines
  19. //--------------------------------------------------------------------------------------------------
  20. #define SPUMGR_IS_ALIGNED(val, align) (((val) & ((align) - 1)) == 0)
  21. #define SPUMGR_ALIGN_UP(val, align) (((val) + ((align)-1)) & ~((align) - 1))
  22. #define SPUMGR_ALIGN_DOWN(val, align) ((val) & ~((align) - 1))
  23. #define SPUMGR_MSG_MEMCPY 0x000000ff
  24. #define Assert(val) // MH
  25. //--------------------------------------------------------------------------------------------------
  26. // Types
  27. //--------------------------------------------------------------------------------------------------
  28. struct MemCpyHeader
  29. {
  30. uint32_t src;
  31. uint32_t dst;
  32. uint32_t size;
  33. uint32_t blocking;
  34. uint8_t cacheLine[16];
  35. };
  36. //--------------------------------------------------------------------------------------------------
  37. // Classes
  38. //--------------------------------------------------------------------------------------------------
  39. struct DMAList
  40. {
  41. uint32_t stallAndNotify :1;
  42. uint32_t reserved :16;
  43. uint32_t size :15;
  44. uint32_t ea;
  45. };
  46. //--------------------------------------------------------------------------------------------------
  47. // DmaCheckAlignment
  48. // Checks restrictions specified in SpuMgr::DmaGet
  49. //--------------------------------------------------------------------------------------------------
  50. int DmaCheckAlignment(uint32_t src, uint32_t dest, uint32_t size);
  51. //--------------------------------------------------------------------------------------------------
  52. //SetupDmaListEntry
  53. //
  54. // Note that this function increments input ptr by number of entries added,
  55. // which will be > 1 if size > 16K
  56. //--------------------------------------------------------------------------------------------------
  57. inline void SetupDmaListEntry(uint32_t stall, uint32_t ea, uint32_t size, DMAList **pDmaList)
  58. {
  59. // check alignment; don't pass in NULL for dest
  60. if (!DmaCheckAlignment(ea, 0x10, size))
  61. {
  62. Assert(0);
  63. }
  64. Assert((size & 0xF) == 0); // for lists input sizes must be multiple of 16 bytes
  65. while (size)
  66. {
  67. uint32_t dmaSize = 0x4000;
  68. dmaSize = size < dmaSize? size: dmaSize;
  69. (*pDmaList)->stallAndNotify = stall;
  70. (*pDmaList)->size = dmaSize;
  71. (*pDmaList)->ea = ea;
  72. size -= dmaSize;
  73. ea += dmaSize;
  74. (*pDmaList)++;
  75. }
  76. }
  77. #endif // INCLUDED_SPUMGR_DMA_H