Add stub headers for various Linux kernel interfaces that ext4 code expects: - sched.h: scheduler stubs (task_struct, cond_resched, yield) - wait.h: wait queue stubs - rwsem.h: read-write semaphore stubs - percpu_counter.h: percpu counter implementation (single-threaded) - random.h: random number stubs - quotaops.h: disk quota operation stubs - part_stat.h: partition statistics stubs - prefetch.h: prefetch operation stubs - sort.h: sort wrapper using stdlib qsort - swap.h: swap/memory management stubs Update compat.h to include new headers and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> Series-to: concept Cover-letter: ext4l: Add Linux compatibility headers This series extracts Linux kernel compatibility declarations from include/linux/compat.h into their own header files, matching the Linux kernel's organization. This makes it easier to port Linux filesystem code to U-Boot and keeps the compatibility layer maintainable. The headers come from Linux v6.18 Headers added: - export.h: EXPORT_SYMBOL macros - stddef.h: sizeof_field() macro - uaccess.h: copy_to/from_user stubs - capability.h, cred.h, file.h, path.h, security.h, seq_file.h - freezer.h: process freezer stubs - slab.h, vmalloc.h: memory allocation - module.h: kernel module stubs - init.h: initcall macros - kthread.h: kernel thread stubs - timer.h, workqueue.h: timer and workqueue stubs - sched.h, wait.h, rwsem.h: scheduler and synchronization - percpu_counter.h, random.h, quotaops.h, part_stat.h, prefetch.h, sort.h, swap.h All headers include appropriate copyright/author information from the original Linux sources. END Series-links: 1:77 Series-version: 2 Signed-off-by: Simon Glass <simon.glass@canonical.com>
271 lines
6.8 KiB
C
271 lines
6.8 KiB
C
#ifndef _LINUX_COMPAT_H_
|
|
#define _LINUX_COMPAT_H_
|
|
|
|
#include <console.h>
|
|
#include <cyclic.h>
|
|
#include <log.h>
|
|
#include <malloc.h>
|
|
#include <time.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/err.h>
|
|
#include <linux/cred.h>
|
|
#include <linux/export.h>
|
|
#include <linux/freezer.h>
|
|
#include <linux/init.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/module.h>
|
|
#include <linux/random.h>
|
|
#include <linux/rwsem.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/workqueue.h>
|
|
|
|
#ifdef CONFIG_XEN
|
|
#include <xen/events.h>
|
|
#endif
|
|
|
|
struct unused {};
|
|
typedef struct unused unused_t;
|
|
|
|
#ifndef CONFIG_XEN
|
|
#define eventchn_poll()
|
|
#endif
|
|
|
|
#define __wait_event_timeout(condition, timeout, ret) \
|
|
({ \
|
|
ulong __ret = ret; /* explicit shadow */ \
|
|
ulong start = get_timer(0); \
|
|
for (;;) { \
|
|
eventchn_poll(); \
|
|
if (condition) { \
|
|
__ret = 1; \
|
|
break; \
|
|
} \
|
|
if ((get_timer(start) > timeout) || ctrlc()) { \
|
|
__ret = 0; \
|
|
break; \
|
|
} \
|
|
cpu_relax(); \
|
|
} \
|
|
__ret; \
|
|
})
|
|
|
|
/**
|
|
* wait_event_timeout() - Wait until the event occurs before the timeout.
|
|
* @wr_head: The wait queue to wait on.
|
|
* @condition: Expression for the event to wait for.
|
|
* @timeout: Maximum waiting time.
|
|
*
|
|
* We wait until the @condition evaluates to %true (succeed) or
|
|
* %false (@timeout elapsed).
|
|
*
|
|
* Return:
|
|
* 0 - if the @condition evaluated to %false after the @timeout elapsed
|
|
* 1 - if the @condition evaluated to %true
|
|
*/
|
|
#define wait_event_timeout(wq_head, condition, timeout) \
|
|
({ \
|
|
ulong __ret; \
|
|
if (condition) \
|
|
__ret = 1; \
|
|
else \
|
|
__ret = __wait_event_timeout(condition, timeout, __ret);\
|
|
__ret; \
|
|
})
|
|
|
|
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
|
|
|
/* This is also defined in ARMv8's mmu.h */
|
|
#ifndef PAGE_SIZE
|
|
#define PAGE_SIZE 4096
|
|
#endif
|
|
|
|
|
|
/* include/linux/leds.h */
|
|
struct led_trigger {};
|
|
|
|
#define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
|
|
enum led_brightness {
|
|
LED_OFF = 0,
|
|
LED_HALF = 127,
|
|
LED_FULL = 255,
|
|
};
|
|
|
|
static inline void led_trigger_register_simple(const char *name,
|
|
struct led_trigger **trigger) {}
|
|
static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {}
|
|
static inline void led_trigger_event(struct led_trigger *trigger,
|
|
enum led_brightness event) {}
|
|
|
|
/* uapi/linux/limits.h */
|
|
#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
|
|
|
|
/**
|
|
* The type used for indexing onto a disc or disc partition.
|
|
*
|
|
* Linux always considers sectors to be 512 bytes long independently
|
|
* of the devices real block size.
|
|
*
|
|
* blkcnt_t is the type of the inode's block count.
|
|
*/
|
|
#ifdef CONFIG_LBDAF
|
|
typedef u64 sector_t;
|
|
typedef u64 blkcnt_t;
|
|
#else
|
|
typedef unsigned long sector_t;
|
|
typedef unsigned long blkcnt_t;
|
|
#endif
|
|
|
|
|
|
/* character device */
|
|
#define MKDEV(...) 0
|
|
#define MAJOR(dev) 0
|
|
#define MINOR(dev) 0
|
|
|
|
#define alloc_chrdev_region(...) 0
|
|
#define unregister_chrdev_region(...)
|
|
|
|
#define class_create(...) __builtin_return_address(0)
|
|
#define class_create_file(...) 0
|
|
#define class_register(...) 0
|
|
#define class_unregister(...)
|
|
#define class_remove_file(...)
|
|
#define class_destroy(...)
|
|
#define misc_register(...) 0
|
|
#define misc_deregister(...)
|
|
|
|
#define blocking_notifier_call_chain(...) 0
|
|
|
|
|
|
#define dev_set_name(...) do { } while (0)
|
|
#define device_register(...) 0
|
|
#define device_unregister(...)
|
|
#define volume_sysfs_init(...) 0
|
|
#define volume_sysfs_close(...) do { } while (0)
|
|
|
|
#define dump_stack(...) do { } while (0)
|
|
|
|
|
|
|
|
|
|
typedef unused_t spinlock_t;
|
|
|
|
#define spin_lock_init(lock) do {} while (0)
|
|
#define spin_lock(lock) do {} while (0)
|
|
#define spin_unlock(lock) do {} while (0)
|
|
#define spin_lock_irqsave(lock, flags) do {} while (0)
|
|
#define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0)
|
|
|
|
#define DEFINE_MUTEX(...)
|
|
#define mutex_init(...)
|
|
#define mutex_lock(...)
|
|
#define mutex_unlock(...)
|
|
|
|
|
|
|
|
|
|
struct device {
|
|
struct device *parent;
|
|
struct class *class;
|
|
dev_t devt; /* dev_t, creates the sysfs "dev" */
|
|
void (*release)(struct device *dev);
|
|
/* This is used from drivers/usb/musb-new subsystem only */
|
|
void *driver_data; /* data private to the driver */
|
|
void *device_data; /* data private to the device */
|
|
};
|
|
struct mutex { int i; };
|
|
struct kernel_param { int i; };
|
|
|
|
struct cdev {
|
|
int owner;
|
|
dev_t dev;
|
|
};
|
|
#define cdev_init(...) do { } while (0)
|
|
#define cdev_add(...) 0
|
|
#define cdev_del(...) do { } while (0)
|
|
|
|
|
|
|
|
/* from include/linux/types.h */
|
|
|
|
/**
|
|
* struct callback_head - callback structure for use with RCU and task_work
|
|
* @next: next update requests in a list
|
|
* @func: actual update function to call after the grace period.
|
|
*/
|
|
struct callback_head {
|
|
struct callback_head *next;
|
|
void (*func)(struct callback_head *head);
|
|
};
|
|
#define rcu_head callback_head
|
|
enum writeback_sync_modes {
|
|
WB_SYNC_NONE, /* Don't wait on anything */
|
|
WB_SYNC_ALL, /* Wait on every mapping */
|
|
};
|
|
|
|
/* from include/linux/writeback.h */
|
|
/*
|
|
* A control structure which tells the writeback code what to do. These are
|
|
* always on the stack, and hence need no locking. They are always initialised
|
|
* in a manner such that unspecified fields are set to zero.
|
|
*/
|
|
struct writeback_control {
|
|
long nr_to_write; /* Write this many pages, and decrement
|
|
this for each page written */
|
|
long pages_skipped; /* Pages which were not written */
|
|
|
|
/*
|
|
* For a_ops->writepages(): if start or end are non-zero then this is
|
|
* a hint that the filesystem need only write out the pages inside that
|
|
* byterange. The byte at `end' is included in the writeout request.
|
|
*/
|
|
loff_t range_start;
|
|
loff_t range_end;
|
|
|
|
enum writeback_sync_modes sync_mode;
|
|
|
|
unsigned for_kupdate:1; /* A kupdate writeback */
|
|
unsigned for_background:1; /* A background writeback */
|
|
unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
|
|
unsigned for_reclaim:1; /* Invoked from the page allocator */
|
|
unsigned range_cyclic:1; /* range_start is cyclic */
|
|
unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
|
|
};
|
|
|
|
|
|
typedef int irqreturn_t;
|
|
|
|
struct notifier_block {};
|
|
|
|
typedef unsigned long dmaaddr_t;
|
|
|
|
#define pm_runtime_get_sync(dev) do {} while (0)
|
|
#define pm_runtime_put(dev) do {} while (0)
|
|
#define pm_runtime_put_sync(dev) do {} while (0)
|
|
#define pm_runtime_use_autosuspend(dev) do {} while (0)
|
|
#define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
|
|
#define pm_runtime_enable(dev) do {} while (0)
|
|
|
|
#define IRQ_NONE 0
|
|
#define IRQ_HANDLED 1
|
|
#define IRQ_WAKE_THREAD 2
|
|
|
|
#define dev_set_drvdata(dev, data) do {} while (0)
|
|
|
|
#define enable_irq(...)
|
|
#define disable_irq(...)
|
|
#define disable_irq_wake(irq) do {} while (0)
|
|
#define enable_irq_wake(irq) -EINVAL
|
|
#define free_irq(irq, data) do {} while (0)
|
|
#define request_irq(nr, f, flags, nm, data) 0
|
|
|
|
#endif
|