Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. #ifndef __TYPES_H__
  3. #define __TYPES_H__
  4.  
  5. # define __iomem
  6. # define __force
  7. # define __user
  8.  
  9. # define WARN(condition, format...)
  10.  
  11. typedef int                  bool;
  12.  
  13. #define false                0
  14. #define true                 1
  15.  
  16. typedef int                  ssize_t;
  17. typedef long long            loff_t;
  18.  
  19. typedef unsigned int         size_t;
  20. typedef unsigned int         count_t;
  21. typedef unsigned int         addr_t;
  22.  
  23. typedef unsigned char        u8;
  24. typedef unsigned short       u16;
  25. typedef unsigned int         u32;
  26. typedef unsigned long long   u64;
  27.  
  28. typedef unsigned char        __u8;
  29. typedef unsigned short       __u16;
  30. typedef unsigned int         __u32;
  31. typedef unsigned long long   __u64;
  32.  
  33. typedef signed char         __s8;
  34. typedef signed short        __s16;
  35. typedef signed int          __s32;
  36. typedef signed long long    __s64;
  37.  
  38.  
  39. typedef unsigned char        uint8_t;
  40. typedef unsigned short       uint16_t;
  41. typedef unsigned int         uint32_t;
  42. typedef unsigned long long   uint64_t;
  43.  
  44. typedef unsigned char        u8_t;
  45. typedef unsigned short       u16_t;
  46. typedef unsigned int         u32_t;
  47. typedef unsigned long long   u64_t;
  48.  
  49. typedef signed char          int8_t;
  50. typedef signed int           int32_t;
  51. typedef signed long long     int64_t;
  52.  
  53. #define  NULL     (void*)0
  54.  
  55. typedef uint32_t             dma_addr_t;
  56. typedef uint32_t             resource_size_t;
  57.  
  58.  
  59. #define cpu_to_le16(v16) (v16)
  60. #define cpu_to_le32(v32) (v32)
  61. #define cpu_to_le64(v64) (v64)
  62. #define le16_to_cpu(v16) (v16)
  63. #define le32_to_cpu(v32) (v32)
  64. #define le64_to_cpu(v64) (v64)
  65.  
  66. #define likely(x)       __builtin_expect(!!(x), 1)
  67. #define unlikely(x)     __builtin_expect(!!(x), 0)
  68.  
  69. #define BITS_PER_LONG 32
  70.  
  71. #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
  72.  
  73. #define BITS_TO_LONGS(nr)   DIV_ROUND_UP(nr, BITS_PER_LONG)
  74.  
  75. #define DECLARE_BITMAP(name,bits) \
  76.         unsigned long name[BITS_TO_LONGS(bits)]
  77.  
  78.  
  79. #define KERN_EMERG      "<0>"   /* system is unusable                   */
  80. #define KERN_ALERT      "<1>"   /* action must be taken immediately     */
  81. #define KERN_CRIT       "<2>"   /* critical conditions                  */
  82. #define KERN_ERR        "<3>"   /* error conditions                     */
  83. #define KERN_WARNING    "<4>"   /* warning conditions                   */
  84. #define KERN_NOTICE     "<5>"   /* normal but significant condition     */
  85. #define KERN_INFO       "<6>"   /* informational                        */
  86. #define KERN_DEBUG      "<7>"   /* debug-level messages                 */
  87.  
  88. //int printk(const char *fmt, ...);
  89.  
  90. #define printk(fmt, arg...)    dbgprintf(fmt , ##arg)
  91.  
  92.  
  93. #define DRM_NAME    "drm"     /**< Name in kernel, /dev, and /proc */
  94.  
  95. #define DRM_INFO(fmt, arg...)  dbgprintf("DRM: "fmt , ##arg)
  96.  
  97. #define DRM_ERROR(fmt, arg...) \
  98.     printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg)
  99.  
  100. #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
  101.  
  102. #define __must_be_array(a) \
  103.     BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
  104.  
  105. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
  106.  
  107.  
  108.  
  109.  
  110. #ifndef HAVE_ARCH_BUG
  111. #define BUG() do { \
  112.          printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
  113.        /*  panic("BUG!"); */ \
  114.  } while (0)
  115. #endif
  116.  
  117. #ifndef HAVE_ARCH_BUG_ON
  118. #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
  119. #endif
  120.  
  121.  
  122.  
  123. #define MTRR_TYPE_UNCACHABLE 0
  124. #define MTRR_TYPE_WRCOMB     1
  125. #define MTRR_TYPE_WRTHROUGH  4
  126. #define MTRR_TYPE_WRPROT     5
  127. #define MTRR_TYPE_WRBACK     6
  128. #define MTRR_NUM_TYPES       7
  129.  
  130. int dbgprintf(const char* format, ...);
  131.  
  132. #define GFP_KERNEL           0
  133.  
  134. //#include <stdio.h>
  135.  
  136. int snprintf(char *str, size_t size, const char *format, ...);
  137.  
  138.  
  139. //#include <string.h>
  140.  
  141. void*   memcpy(void *s1, const void *s2, size_t n);
  142. void*   memset(void *s, int c, size_t n);
  143. size_t  strlen(const char *s);
  144. char *strcpy(char *s1, const char *s2);
  145. char *strncpy (char *dst, const char *src, size_t len);
  146.  
  147. void *malloc(size_t size);
  148.  
  149. #define kmalloc(s,f) malloc((s))
  150. #define kfree free
  151.  
  152. static inline void *kzalloc(size_t size, u32_t flags)
  153. {
  154.     void *ret = malloc(size);
  155.     memset(ret, 0, size);
  156.     return ret;
  157. }
  158.  
  159. struct drm_file;
  160.  
  161. #define offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER)
  162.  
  163. #define container_of(ptr, type, member) ({                      \
  164.         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
  165.         (type *)( (char *)__mptr - offsetof(type,member) );})
  166.  
  167.  
  168.  
  169. #define DRM_MEMORYBARRIER() __asm__ __volatile__("lock; addl $0,0(%esp)")
  170. #define mb() __asm__ __volatile__("lock; addl $0,0(%esp)")
  171.  
  172.  
  173. #define PAGE_SHIFT      12
  174. #define PAGE_SIZE       (1UL << PAGE_SHIFT)
  175. #define PAGE_MASK       (~(PAGE_SIZE-1))
  176.  
  177. #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
  178.  
  179. static inline void bitmap_zero(unsigned long *dst, int nbits)
  180. {
  181.         if (nbits <= BITS_PER_LONG)
  182.                 *dst = 0UL;
  183.         else {
  184.                 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
  185.                 memset(dst, 0, len);
  186.         }
  187. }
  188.  
  189. #define EXPORT_SYMBOL(x)
  190.  
  191. #define min(x,y) ({ \
  192.         typeof(x) _x = (x);     \
  193.         typeof(y) _y = (y);     \
  194.         (void) (&_x == &_y);            \
  195.         _x < _y ? _x : _y; })
  196.  
  197. #define max(x,y) ({ \
  198.         typeof(x) _x = (x);     \
  199.         typeof(y) _y = (y);     \
  200.         (void) (&_x == &_y);            \
  201.         _x > _y ? _x : _y; })
  202.  
  203.  
  204. extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
  205.  
  206. # define do_div(n,base) ({                             \
  207.        uint32_t __base = (base);                       \
  208.        uint32_t __rem;                                 \
  209.        (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
  210.        if (likely(((n) >> 32) == 0)) {                 \
  211.                __rem = (uint32_t)(n) % __base;         \
  212.                (n) = (uint32_t)(n) / __base;           \
  213.        } else                                          \
  214.                __rem = __div64_32(&(n), __base);       \
  215.        __rem;                                          \
  216. })
  217.  
  218. #define lower_32_bits(n) ((u32)(n))
  219.  
  220. #define INT_MAX         ((int)(~0U>>1))
  221. #define INT_MIN         (-INT_MAX - 1)
  222. #define UINT_MAX        (~0U)
  223. #define LONG_MAX        ((long)(~0UL>>1))
  224. #define LONG_MIN        (-LONG_MAX - 1)
  225. #define ULONG_MAX       (~0UL)
  226. #define LLONG_MAX       ((long long)(~0ULL>>1))
  227. #define LLONG_MIN       (-LLONG_MAX - 1)
  228. #define ULLONG_MAX      (~0ULL)
  229.  
  230.  
  231. static inline void *kcalloc(size_t n, size_t size, u32_t flags)
  232. {
  233.         if (n != 0 && size > ULONG_MAX / n)
  234.                 return NULL;
  235.         return kzalloc(n * size, 0);
  236. }
  237.  
  238. #define ENTER()   dbgprintf("enter %s\n",__FUNCTION__)
  239. #define LEAVE()   dbgprintf("leave %s\n",__FUNCTION__)
  240.  
  241. #define ALIGN(x,a)              __ALIGN_MASK(x,(typeof(x))(a)-1)
  242. #define __ALIGN_MASK(x,mask)    (((x)+(mask))&~(mask))
  243.  
  244. #define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159
  245.  
  246.  
  247. #endif  //__TYPES_H__
  248.