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