1 #ifndef _LINUX_COMPAT_H_
2 #define _LINUX_COMPAT_H_
8 #include <asm/processor.h>
10 #include <linux/types.h>
11 #include <linux/err.h>
12 #include <linux/kernel.h>
15 #include <xen/events.h>
19 typedef struct unused unused_t;
25 extern struct p_current *current;
27 /* avoid conflict with <dm/device.h> */
44 #define dev_dbg(dev, fmt, args...) \
46 #define dev_vdbg(dev, fmt, args...) \
48 #define dev_info(dev, fmt, args...) \
50 #define dev_err(dev, fmt, args...) \
52 #define dev_warn(dev, fmt, args...) \
55 #define GFP_ATOMIC ((gfp_t) 0)
56 #define GFP_KERNEL ((gfp_t) 0)
57 #define GFP_NOFS ((gfp_t) 0)
58 #define GFP_USER ((gfp_t) 0)
59 #define __GFP_NOWARN ((gfp_t) 0)
60 #define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */
62 void *kmalloc(size_t size, int flags);
64 static inline void *kzalloc(size_t size, gfp_t flags)
66 return kmalloc(size, flags | __GFP_ZERO);
69 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71 if (size != 0 && n > SIZE_MAX / size)
73 return kmalloc(n * size, flags | __GFP_ZERO);
76 static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
78 return kmalloc_array(n, size, flags | __GFP_ZERO);
81 #define vmalloc(size) kmalloc(size, 0)
82 #define __vmalloc(size, flags, pgsz) kmalloc(size, flags)
83 static inline void *vzalloc(unsigned long size)
85 return kzalloc(size, 0);
87 static inline void kfree(const void *block)
91 static inline void vfree(const void *addr)
96 struct kmem_cache { int sz; };
98 struct kmem_cache *get_mem(int element_sz);
99 #define kmem_cache_create(a, sz, c, d, e) get_mem(sz)
100 void *kmem_cache_alloc(struct kmem_cache *obj, int flag);
101 static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj)
105 static inline void kmem_cache_destroy(struct kmem_cache *cachep)
110 #define DECLARE_WAITQUEUE(...) do { } while (0)
111 #define add_wait_queue(...) do { } while (0)
112 #define remove_wait_queue(...) do { } while (0)
115 #define eventchn_poll()
118 #define __wait_event_timeout(condition, timeout, ret) \
120 ulong __ret = ret; /* explicit shadow */ \
121 ulong start = get_timer(0); \
128 if ((get_timer(start) > timeout) || ctrlc()) { \
138 * wait_event_timeout() - Wait until the event occurs before the timeout.
139 * @wr_head: The wait queue to wait on.
140 * @condition: Expression for the event to wait for.
141 * @timeout: Maximum waiting time.
143 * We wait until the @condition evaluates to %true (succeed) or
144 * %false (@timeout elapsed).
147 * 0 - if the @condition evaluated to %false after the @timeout elapsed
148 * 1 - if the @condition evaluated to %true
150 #define wait_event_timeout(wq_head, condition, timeout) \
156 __ret = __wait_event_timeout(condition, timeout, __ret);\
160 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
162 /* This is also defined in ARMv8's mmu.h */
164 #define PAGE_SIZE 4096
167 /* drivers/char/random.c */
168 #define get_random_bytes(...)
170 /* include/linux/leds.h */
171 struct led_trigger {};
173 #define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
174 enum led_brightness {
180 static inline void led_trigger_register_simple(const char *name,
181 struct led_trigger **trigger) {}
182 static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {}
183 static inline void led_trigger_event(struct led_trigger *trigger,
184 enum led_brightness event) {}
186 /* uapi/linux/limits.h */
187 #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
190 * The type used for indexing onto a disc or disc partition.
192 * Linux always considers sectors to be 512 bytes long independently
193 * of the devices real block size.
195 * blkcnt_t is the type of the inode's block count.
198 typedef u64 sector_t;
199 typedef u64 blkcnt_t;
201 typedef unsigned long sector_t;
202 typedef unsigned long blkcnt_t;
206 #define THIS_MODULE 0
207 #define try_module_get(...) 1
208 #define module_put(...) do { } while (0)
209 #define module_init(...)
210 #define module_exit(...)
211 #define EXPORT_SYMBOL(...)
212 #define EXPORT_SYMBOL_GPL(...)
213 #define module_param(...)
214 #define module_param_call(...)
215 #define MODULE_PARM_DESC(...)
216 #define MODULE_VERSION(...)
217 #define MODULE_DESCRIPTION(...)
218 #define MODULE_AUTHOR(...)
219 #define MODULE_LICENSE(...)
220 #define MODULE_ALIAS(...)
221 #define __module_get(...)
223 /* character device */
228 #define alloc_chrdev_region(...) 0
229 #define unregister_chrdev_region(...)
231 #define class_create(...) __builtin_return_address(0)
232 #define class_create_file(...) 0
233 #define class_register(...) 0
234 #define class_unregister(...)
235 #define class_remove_file(...)
236 #define class_destroy(...)
237 #define misc_register(...) 0
238 #define misc_deregister(...)
240 #define blocking_notifier_call_chain(...) 0
243 #define late_initcall(...)
245 #define dev_set_name(...) do { } while (0)
246 #define device_register(...) 0
247 #define device_unregister(...)
248 #define volume_sysfs_init(...) 0
249 #define volume_sysfs_close(...) do { } while (0)
251 #define init_waitqueue_head(...) do { } while (0)
252 #define wait_event_interruptible(...) 0
253 #define wake_up_interruptible(...) do { } while (0)
254 #define dump_stack(...) do { } while (0)
256 #define task_pid_nr(x) 0
257 #define set_freezable(...) do { } while (0)
258 #define try_to_freeze(...) 0
259 #define set_current_state(...) do { } while (0)
260 #define kthread_should_stop(...) 0
261 #define schedule() do { } while (0)
263 #define setup_timer(timer, func, data) do {} while (0)
264 #define del_timer_sync(timer) do {} while (0)
265 #define schedule_work(work) do {} while (0)
266 #define INIT_WORK(work, fun) do {} while (0)
268 struct work_struct {};
270 unsigned long copy_from_user(void *dest, const void *src,
271 unsigned long count);
273 typedef unused_t spinlock_t;
274 typedef int wait_queue_head_t;
276 #define spin_lock_init(lock) do {} while (0)
277 #define spin_lock(lock) do {} while (0)
278 #define spin_unlock(lock) do {} while (0)
279 #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
280 #define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0)
282 #define DEFINE_MUTEX(...)
283 #define mutex_init(...)
284 #define mutex_lock(...)
285 #define mutex_unlock(...)
287 #define init_rwsem(...) do { } while (0)
288 #define down_read(...) do { } while (0)
289 #define down_write(...) do { } while (0)
290 #define down_write_trylock(...) 1
291 #define up_read(...) do { } while (0)
292 #define up_write(...) do { } while (0)
294 #define cond_resched() do { } while (0)
295 #define yield() do { } while (0)
300 #define __devinitdata
301 #define __devinitconst
303 #define kthread_create(...) __builtin_return_address(0)
304 #define kthread_stop(...) do { } while (0)
305 #define wake_up_process(...) do { } while (0)
307 struct rw_semaphore { int i; };
308 #define down_write(...) do { } while (0)
309 #define up_write(...) do { } while (0)
310 #define down_read(...) do { } while (0)
311 #define up_read(...) do { } while (0)
313 struct device *parent;
315 dev_t devt; /* dev_t, creates the sysfs "dev" */
316 void (*release)(struct device *dev);
317 /* This is used from drivers/usb/musb-new subsystem only */
318 void *driver_data; /* data private to the driver */
319 void *device_data; /* data private to the device */
321 struct mutex { int i; };
322 struct kernel_param { int i; };
328 #define cdev_init(...) do { } while (0)
329 #define cdev_add(...) 0
330 #define cdev_del(...) do { } while (0)
332 #define prandom_u32(...) 0
342 /* from include/linux/types.h */
345 * struct callback_head - callback structure for use with RCU and task_work
346 * @next: next update requests in a list
347 * @func: actual update function to call after the grace period.
349 struct callback_head {
350 struct callback_head *next;
351 void (*func)(struct callback_head *head);
353 #define rcu_head callback_head
354 enum writeback_sync_modes {
355 WB_SYNC_NONE, /* Don't wait on anything */
356 WB_SYNC_ALL, /* Wait on every mapping */
359 /* from include/linux/writeback.h */
361 * A control structure which tells the writeback code what to do. These are
362 * always on the stack, and hence need no locking. They are always initialised
363 * in a manner such that unspecified fields are set to zero.
365 struct writeback_control {
366 long nr_to_write; /* Write this many pages, and decrement
367 this for each page written */
368 long pages_skipped; /* Pages which were not written */
371 * For a_ops->writepages(): if start or end are non-zero then this is
372 * a hint that the filesystem need only write out the pages inside that
373 * byterange. The byte at `end' is included in the writeout request.
378 enum writeback_sync_modes sync_mode;
380 unsigned for_kupdate:1; /* A kupdate writeback */
381 unsigned for_background:1; /* A background writeback */
382 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
383 unsigned for_reclaim:1; /* Invoked from the page allocator */
384 unsigned range_cyclic:1; /* range_start is cyclic */
385 unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
388 void *kmemdup(const void *src, size_t len, gfp_t gfp);
390 typedef int irqreturn_t;
392 struct timer_list {};
393 struct notifier_block {};
395 typedef unsigned long dmaaddr_t;
397 #define pm_runtime_get_sync(dev) do {} while (0)
398 #define pm_runtime_put(dev) do {} while (0)
399 #define pm_runtime_put_sync(dev) do {} while (0)
400 #define pm_runtime_use_autosuspend(dev) do {} while (0)
401 #define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
402 #define pm_runtime_enable(dev) do {} while (0)
405 #define IRQ_HANDLED 1
406 #define IRQ_WAKE_THREAD 2
408 #define dev_set_drvdata(dev, data) do {} while (0)
410 #define enable_irq(...)
411 #define disable_irq(...)
412 #define disable_irq_wake(irq) do {} while (0)
413 #define enable_irq_wake(irq) -EINVAL
414 #define free_irq(irq, data) do {} while (0)
415 #define request_irq(nr, f, flags, nm, data) 0