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.  
  6. typedef int                  bool;
  7.  
  8. #define false                0
  9. #define true                 1
  10.  
  11. typedef unsigned int         size_t;
  12. typedef unsigned int         count_t;
  13. typedef unsigned int         addr_t;
  14.  
  15. typedef unsigned char        u8;
  16. typedef unsigned short       u16;
  17. typedef unsigned int         u32;
  18. typedef unsigned long long   u64;
  19.  
  20. typedef unsigned char        __u8;
  21. typedef unsigned short       __u16;
  22. typedef unsigned int         __u32;
  23. typedef unsigned long long   __u64;
  24.  
  25. typedef signed char         __s8;
  26. typedef signed short        __s16;
  27. typedef signed int          __s32;
  28. typedef signed long long    __s64;
  29.  
  30.  
  31. typedef unsigned char        uint8_t;
  32. typedef unsigned short       uint16_t;
  33. typedef unsigned int         uint32_t;
  34. typedef unsigned long long   uint64_t;
  35.  
  36. typedef unsigned char        u8_t;
  37. typedef unsigned short       u16_t;
  38. typedef unsigned int         u32_t;
  39. typedef unsigned long long   u64_t;
  40.  
  41. #define  NULL     (void*)0
  42.  
  43. typedef uint32_t             dma_addr_t;
  44. typedef uint32_t             resource_size_t;
  45.  
  46. #define __user
  47.  
  48. #define cpu_to_le16(v16) (v16)
  49. #define cpu_to_le32(v32) (v32)
  50. #define cpu_to_le64(v64) (v64)
  51. #define le16_to_cpu(v16) (v16)
  52. #define le32_to_cpu(v32) (v32)
  53. #define le64_to_cpu(v64) (v64)
  54.  
  55. #define likely(x)       __builtin_expect(!!(x), 1)
  56. #define unlikely(x)     __builtin_expect(!!(x), 0)
  57.  
  58.  
  59.  
  60. #define KERN_EMERG      "<0>"   /* system is unusable                   */
  61. #define KERN_ALERT      "<1>"   /* action must be taken immediately     */
  62. #define KERN_CRIT       "<2>"   /* critical conditions                  */
  63. #define KERN_ERR        "<3>"   /* error conditions                     */
  64. #define KERN_WARNING    "<4>"   /* warning conditions                   */
  65. #define KERN_NOTICE     "<5>"   /* normal but significant condition     */
  66. #define KERN_INFO       "<6>"   /* informational                        */
  67. #define KERN_DEBUG      "<7>"   /* debug-level messages                 */
  68.  
  69. //int printk(const char *fmt, ...);
  70.  
  71. #define printk(fmt, arg...)    dbgprintf(fmt , ##arg)
  72.  
  73.  
  74. #define DRM_NAME    "drm"     /**< Name in kernel, /dev, and /proc */
  75.  
  76. #define DRM_INFO(fmt, arg...)  dbgprintf("DRM: "fmt , ##arg)
  77.  
  78. #define DRM_DEBUG(fmt, arg...)     \
  79.     printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg)
  80.  
  81. #define DRM_ERROR(fmt, arg...) \
  82.     printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg)
  83.  
  84. #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
  85.  
  86. #define __must_be_array(a) \
  87.     BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
  88.  
  89. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
  90.  
  91.  
  92.  
  93.  
  94. #ifndef HAVE_ARCH_BUG
  95. #define BUG() do { \
  96.          printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
  97.        /*  panic("BUG!"); */ \
  98.  } while (0)
  99. #endif
  100.  
  101. #ifndef HAVE_ARCH_BUG_ON
  102. #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
  103. #endif
  104.  
  105.  
  106.  
  107. #define MTRR_TYPE_UNCACHABLE 0
  108. #define MTRR_TYPE_WRCOMB     1
  109. #define MTRR_TYPE_WRTHROUGH  4
  110. #define MTRR_TYPE_WRPROT     5
  111. #define MTRR_TYPE_WRBACK     6
  112. #define MTRR_NUM_TYPES       7
  113.  
  114. int dbgprintf(const char* format, ...);
  115.  
  116. #define GFP_KERNEL           0
  117.  
  118. //#include <string.h>
  119.  
  120. void*   memcpy(void *s1, const void *s2, size_t n);
  121. void*   memset(void *s, int c, size_t n);
  122. size_t  strlen(const char *s);
  123.  
  124. void *malloc(size_t size);
  125.  
  126. #define kfree free
  127.  
  128. static inline void *kzalloc(size_t size, u32_t flags)
  129. {
  130.     void *ret = malloc(size);
  131.     memset(ret, 0, size);
  132.     return ret;
  133. }
  134.  
  135. struct drm_gem_object {
  136.  
  137.     /** Reference count of this object */
  138. //    struct kref refcount;
  139.  
  140.     /** Handle count of this object. Each handle also holds a reference */
  141. //    struct kref handlecount;
  142.  
  143.     /** Related drm device */
  144. //    struct drm_device *dev;
  145.  
  146.     /** File representing the shmem storage */
  147. //    struct file *filp;
  148.  
  149.     /* Mapping info for this object */
  150. //    struct drm_map_list map_list;
  151.  
  152.     /**
  153.      * Size of the object, in bytes.  Immutable over the object's
  154.      * lifetime.
  155.      */
  156.     size_t size;
  157.  
  158.     /**
  159.      * Global name for this object, starts at 1. 0 means unnamed.
  160.      * Access is covered by the object_name_lock in the related drm_device
  161.      */
  162.     int name;
  163.  
  164.     /**
  165.      * Memory domains. These monitor which caches contain read/write data
  166.      * related to the object. When transitioning from one set of domains
  167.      * to another, the driver is called to ensure that caches are suitably
  168.      * flushed and invalidated
  169.      */
  170.     uint32_t read_domains;
  171.     uint32_t write_domain;
  172.  
  173.     /**
  174.      * While validating an exec operation, the
  175.      * new read/write domain values are computed here.
  176.      * They will be transferred to the above values
  177.      * at the point that any cache flushing occurs
  178.      */
  179.     uint32_t pending_read_domains;
  180.     uint32_t pending_write_domain;
  181.  
  182.     void *driver_private;
  183. };
  184.  
  185. struct drm_file;
  186.  
  187. #define offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER)
  188.  
  189. #define container_of(ptr, type, member) ({                      \
  190.         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
  191.         (type *)( (char *)__mptr - offsetof(type,member) );})
  192.  
  193.  
  194.  
  195. #define DRM_MEMORYBARRIER() __asm__ __volatile__("lock; addl $0,0(%esp)")
  196.  
  197.  
  198.  
  199. #endif  //__TYPES_H__
  200.