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