mali_osk_specific.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2008-2010, 2012-2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. /**
  11. * @file mali_osk_specific.h
  12. * Defines per-OS Kernel level specifics, such as unusual workarounds for
  13. * certain OSs.
  14. */
  15. #ifndef __MALI_OSK_SPECIFIC_H__
  16. #define __MALI_OSK_SPECIFIC_H__
  17. #include <asm/uaccess.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/dmapool.h>
  20. #include <linux/gfp.h>
  21. #include <linux/hardirq.h>
  22. #include <linux/uaccess.h>
  23. #include "mali_osk_types.h"
  24. #include "mali_kernel_linux.h"
  25. #define MALI_STATIC_INLINE static inline
  26. #define MALI_NON_STATIC_INLINE inline
  27. typedef struct dma_pool * mali_dma_pool;
  28. MALI_STATIC_INLINE mali_dma_pool mali_dma_pool_create(u32 size, u32 alignment, u32 boundary)
  29. {
  30. return dma_pool_create("mali-dma", &mali_platform_device->dev, size, alignment, boundary);
  31. }
  32. MALI_STATIC_INLINE void mali_dma_pool_destroy(mali_dma_pool pool)
  33. {
  34. dma_pool_destroy(pool);
  35. }
  36. MALI_STATIC_INLINE mali_io_address mali_dma_pool_alloc(mali_dma_pool pool, u32 *phys_addr)
  37. {
  38. return dma_pool_alloc(pool, GFP_KERNEL, phys_addr);
  39. }
  40. MALI_STATIC_INLINE void mali_dma_pool_free(mali_dma_pool pool, void* virt_addr, u32 phys_addr)
  41. {
  42. dma_pool_free(pool, virt_addr, phys_addr);
  43. }
  44. #if MALI_ENABLE_CPU_CYCLES
  45. /* Reads out the clock cycle performance counter of the current cpu.
  46. It is useful for cost-free (2 cycle) measuring of the time spent
  47. in a code path. Sample before and after, the diff number of cycles.
  48. When the CPU is idle it will not increase this clock counter.
  49. It means that the counter is accurate if only spin-locks are used,
  50. but mutexes may lead to too low values since the cpu might "idle"
  51. waiting for the mutex to become available.
  52. The clock source is configured on the CPU during mali module load,
  53. but will not give useful output after a CPU has been power cycled.
  54. It is therefore important to configure the system to not turn of
  55. the cpu cores when using this functionallity.*/
  56. static inline unsigned int mali_get_cpu_cyclecount(void)
  57. {
  58. unsigned int value;
  59. /* Reading the CCNT Register - CPU clock counter */
  60. asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(value));
  61. return value;
  62. }
  63. void mali_init_cpu_time_counters(int reset, int enable_divide_by_64);
  64. #endif
  65. MALI_STATIC_INLINE u32 _mali_osk_copy_from_user(void *to, void *from, u32 n)
  66. {
  67. return (u32)copy_from_user(to, from, (unsigned long)n);
  68. }
  69. MALI_STATIC_INLINE mali_bool _mali_osk_in_atomic(void)
  70. {
  71. return in_atomic();
  72. }
  73. #define _mali_osk_put_user(x, ptr) put_user(x, ptr)
  74. #endif /* __MALI_OSK_SPECIFIC_H__ */