Subversion Repositories Kolibri OS

Rev

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