1 #ifndef _LINUX_COMPAT_H_ 2 #define _LINUX_COMPAT_H_ 3 4 #include <malloc.h> 5 #include <linux/types.h> 6 #include <linux/err.h> 7 #include <linux/kernel.h> 8 9 struct unused {}; 10 typedef struct unused unused_t; 11 12 struct p_current{ 13 int pid; 14 }; 15 16 extern struct p_current *current; 17 18 #define dev_dbg(dev, fmt, args...) \ 19 debug(fmt, ##args) 20 #define dev_vdbg(dev, fmt, args...) \ 21 debug(fmt, ##args) 22 #define dev_info(dev, fmt, args...) \ 23 printf(fmt, ##args) 24 #define dev_err(dev, fmt, args...) \ 25 printf(fmt, ##args) 26 #define dev_warn(dev, fmt, args...) \ 27 printf(fmt, ##args) 28 #define printk printf 29 #define printk_once printf 30 31 #define KERN_EMERG 32 #define KERN_ALERT 33 #define KERN_CRIT 34 #define KERN_ERR 35 #define KERN_WARNING 36 #define KERN_NOTICE 37 #define KERN_INFO 38 #define KERN_DEBUG 39 40 #define GFP_ATOMIC ((gfp_t) 0) 41 #define GFP_KERNEL ((gfp_t) 0) 42 #define GFP_NOFS ((gfp_t) 0) 43 #define GFP_USER ((gfp_t) 0) 44 #define __GFP_NOWARN ((gfp_t) 0) 45 #define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */ 46 47 void *kmalloc(size_t size, int flags); 48 49 static inline void *kzalloc(size_t size, gfp_t flags) 50 { 51 return kmalloc(size, flags | __GFP_ZERO); 52 } 53 54 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) 55 { 56 if (size != 0 && n > SIZE_MAX / size) 57 return NULL; 58 return kmalloc(n * size, flags | __GFP_ZERO); 59 } 60 61 static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 62 { 63 return kmalloc_array(n, size, flags | __GFP_ZERO); 64 } 65 66 #define vmalloc(size) kmalloc(size, 0) 67 #define __vmalloc(size, flags, pgsz) kmalloc(size, flags) 68 static inline void *vzalloc(unsigned long size) 69 { 70 return kzalloc(size, 0); 71 } 72 static inline void kfree(const void *block) 73 { 74 free((void *)block); 75 } 76 static inline void vfree(const void *addr) 77 { 78 free((void *)addr); 79 } 80 81 struct kmem_cache { int sz; }; 82 83 struct kmem_cache *get_mem(int element_sz); 84 #define kmem_cache_create(a, sz, c, d, e) get_mem(sz) 85 void *kmem_cache_alloc(struct kmem_cache *obj, int flag); 86 static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj) 87 { 88 free(obj); 89 } 90 static inline void kmem_cache_destroy(struct kmem_cache *cachep) 91 { 92 free(cachep); 93 } 94 95 #define DECLARE_WAITQUEUE(...) do { } while (0) 96 #define add_wait_queue(...) do { } while (0) 97 #define remove_wait_queue(...) do { } while (0) 98 99 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 100 101 #ifndef BUG 102 #define BUG() do { \ 103 printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \ 104 } while (0) 105 106 #define BUG_ON(condition) do { if (condition) BUG(); } while(0) 107 #endif /* BUG */ 108 109 #define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \ 110 , __FILE__, __LINE__); } 111 112 #define PAGE_SIZE 4096 113 114 /* drivers/char/random.c */ 115 #define get_random_bytes(...) 116 117 /* include/linux/leds.h */ 118 struct led_trigger {}; 119 120 #define DEFINE_LED_TRIGGER(x) static struct led_trigger *x; 121 enum led_brightness { 122 LED_OFF = 0, 123 LED_HALF = 127, 124 LED_FULL = 255, 125 }; 126 127 static inline void led_trigger_register_simple(const char *name, 128 struct led_trigger **trigger) {} 129 static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {} 130 static inline void led_trigger_event(struct led_trigger *trigger, 131 enum led_brightness event) {} 132 133 /* uapi/linux/limits.h */ 134 #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ 135 136 /** 137 * The type used for indexing onto a disc or disc partition. 138 * 139 * Linux always considers sectors to be 512 bytes long independently 140 * of the devices real block size. 141 * 142 * blkcnt_t is the type of the inode's block count. 143 */ 144 #ifdef CONFIG_LBDAF 145 typedef u64 sector_t; 146 typedef u64 blkcnt_t; 147 #else 148 typedef unsigned long sector_t; 149 typedef unsigned long blkcnt_t; 150 #endif 151 152 /* module */ 153 #define THIS_MODULE 0 154 #define try_module_get(...) 1 155 #define module_put(...) do { } while (0) 156 #define module_init(...) 157 #define module_exit(...) 158 #define EXPORT_SYMBOL(...) 159 #define EXPORT_SYMBOL_GPL(...) 160 #define module_param(...) 161 #define module_param_call(...) 162 #define MODULE_PARM_DESC(...) 163 #define MODULE_VERSION(...) 164 #define MODULE_DESCRIPTION(...) 165 #define MODULE_AUTHOR(...) 166 #define MODULE_LICENSE(...) 167 #define MODULE_ALIAS(...) 168 #define __module_get(...) 169 170 /* character device */ 171 #define MKDEV(...) 0 172 #define MAJOR(dev) 0 173 #define MINOR(dev) 0 174 175 #define alloc_chrdev_region(...) 0 176 #define unregister_chrdev_region(...) 177 178 #define class_create(...) __builtin_return_address(0) 179 #define class_create_file(...) 0 180 #define class_register(...) 0 181 #define class_unregister(...) 182 #define class_remove_file(...) 183 #define class_destroy(...) 184 #define misc_register(...) 0 185 #define misc_deregister(...) 186 187 #define blocking_notifier_call_chain(...) 0 188 189 #define __initdata 190 #define late_initcall(...) 191 192 #define dev_set_name(...) do { } while (0) 193 #define device_register(...) 0 194 #define device_unregister(...) 195 #define volume_sysfs_init(...) 0 196 #define volume_sysfs_close(...) do { } while (0) 197 198 #define init_waitqueue_head(...) do { } while (0) 199 #define wait_event_interruptible(...) 0 200 #define wake_up_interruptible(...) do { } while (0) 201 #define print_hex_dump(...) do { } while (0) 202 #define dump_stack(...) do { } while (0) 203 204 #define task_pid_nr(x) 0 205 #define set_freezable(...) do { } while (0) 206 #define try_to_freeze(...) 0 207 #define set_current_state(...) do { } while (0) 208 #define kthread_should_stop(...) 0 209 #define schedule() do { } while (0) 210 211 #define setup_timer(timer, func, data) do {} while (0) 212 #define del_timer_sync(timer) do {} while (0) 213 #define schedule_work(work) do {} while (0) 214 #define INIT_WORK(work, fun) do {} while (0) 215 216 struct work_struct {}; 217 218 unsigned long copy_from_user(void *dest, const void *src, 219 unsigned long count); 220 221 typedef unused_t spinlock_t; 222 typedef int wait_queue_head_t; 223 224 #define spin_lock_init(lock) do {} while (0) 225 #define spin_lock(lock) do {} while (0) 226 #define spin_unlock(lock) do {} while (0) 227 #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0) 228 #define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0) 229 230 #define DEFINE_MUTEX(...) 231 #define mutex_init(...) 232 #define mutex_lock(...) 233 #define mutex_unlock(...) 234 235 #define init_rwsem(...) do { } while (0) 236 #define down_read(...) do { } while (0) 237 #define down_write(...) do { } while (0) 238 #define down_write_trylock(...) 1 239 #define up_read(...) do { } while (0) 240 #define up_write(...) do { } while (0) 241 242 #define cond_resched() do { } while (0) 243 #define yield() do { } while (0) 244 245 #define __init 246 #define __exit 247 #define __devinit 248 #define __devinitdata 249 #define __devinitconst 250 251 #define kthread_create(...) __builtin_return_address(0) 252 #define kthread_stop(...) do { } while (0) 253 #define wake_up_process(...) do { } while (0) 254 255 struct rw_semaphore { int i; }; 256 #define down_write(...) do { } while (0) 257 #define up_write(...) do { } while (0) 258 #define down_read(...) do { } while (0) 259 #define up_read(...) do { } while (0) 260 struct device { 261 struct device *parent; 262 struct class *class; 263 dev_t devt; /* dev_t, creates the sysfs "dev" */ 264 void (*release)(struct device *dev); 265 /* This is used from drivers/usb/musb-new subsystem only */ 266 void *driver_data; /* data private to the driver */ 267 void *device_data; /* data private to the device */ 268 }; 269 struct mutex { int i; }; 270 struct kernel_param { int i; }; 271 272 struct cdev { 273 int owner; 274 dev_t dev; 275 }; 276 #define cdev_init(...) do { } while (0) 277 #define cdev_add(...) 0 278 #define cdev_del(...) do { } while (0) 279 280 #define prandom_u32(...) 0 281 282 typedef struct { 283 uid_t val; 284 } kuid_t; 285 286 typedef struct { 287 gid_t val; 288 } kgid_t; 289 290 /* from include/linux/types.h */ 291 292 /** 293 * struct callback_head - callback structure for use with RCU and task_work 294 * @next: next update requests in a list 295 * @func: actual update function to call after the grace period. 296 */ 297 struct callback_head { 298 struct callback_head *next; 299 void (*func)(struct callback_head *head); 300 }; 301 #define rcu_head callback_head 302 enum writeback_sync_modes { 303 WB_SYNC_NONE, /* Don't wait on anything */ 304 WB_SYNC_ALL, /* Wait on every mapping */ 305 }; 306 307 /* from include/linux/writeback.h */ 308 /* 309 * A control structure which tells the writeback code what to do. These are 310 * always on the stack, and hence need no locking. They are always initialised 311 * in a manner such that unspecified fields are set to zero. 312 */ 313 struct writeback_control { 314 long nr_to_write; /* Write this many pages, and decrement 315 this for each page written */ 316 long pages_skipped; /* Pages which were not written */ 317 318 /* 319 * For a_ops->writepages(): if start or end are non-zero then this is 320 * a hint that the filesystem need only write out the pages inside that 321 * byterange. The byte at `end' is included in the writeout request. 322 */ 323 loff_t range_start; 324 loff_t range_end; 325 326 enum writeback_sync_modes sync_mode; 327 328 unsigned for_kupdate:1; /* A kupdate writeback */ 329 unsigned for_background:1; /* A background writeback */ 330 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ 331 unsigned for_reclaim:1; /* Invoked from the page allocator */ 332 unsigned range_cyclic:1; /* range_start is cyclic */ 333 unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */ 334 }; 335 336 void *kmemdup(const void *src, size_t len, gfp_t gfp); 337 338 typedef int irqreturn_t; 339 340 struct timer_list {}; 341 struct notifier_block {}; 342 343 typedef unsigned long dmaaddr_t; 344 345 #define pm_runtime_get_sync(dev) do {} while (0) 346 #define pm_runtime_put(dev) do {} while (0) 347 #define pm_runtime_put_sync(dev) do {} while (0) 348 #define pm_runtime_use_autosuspend(dev) do {} while (0) 349 #define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0) 350 #define pm_runtime_enable(dev) do {} while (0) 351 352 #define IRQ_NONE 0 353 #define IRQ_HANDLED 1 354 #define IRQ_WAKE_THREAD 2 355 356 #define dev_set_drvdata(dev, data) do {} while (0) 357 358 #define enable_irq(...) 359 #define disable_irq(...) 360 #define disable_irq_wake(irq) do {} while (0) 361 #define enable_irq_wake(irq) -EINVAL 362 #define free_irq(irq, data) do {} while (0) 363 #define request_irq(nr, f, flags, nm, data) 0 364 365 #endif 366