[PATCH 00/11] ext4l: Add Linux compatibility headers
From: Simon Glass <simon.glass@canonical.com> 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. Simon Glass (11): ext4l: Extract export.h declarations into their own file ext4l: Provide sizeof_field() in linux/stddef.h ext4l: Extract uaccess.h declarations into their own file ext4l: Add some stub headers for Linux code ext4l: Extract freezer.h declarations into their own file ext4l: Extract alloc declarations into their own file ext4l: Extract module declarations into their own file ext4l: Extract initcall declarations into their own file ext4l: Extract kthread declarations into their own file ext4l: Extract timer declarations into their own file ext4l: Add stub versions various other linux headers include/linux/capability.h | 27 +++++++ include/linux/compat.h | 143 ++++----------------------------- include/linux/cred.h | 53 ++++++++++++ include/linux/export.h | 14 ++++ include/linux/file.h | 29 +++++++ include/linux/freezer.h | 17 ++++ include/linux/init.h | 49 +++++++++++ include/linux/kthread.h | 28 +++++++ include/linux/module.h | 37 +++++++++ include/linux/part_stat.h | 16 ++++ include/linux/path.h | 13 +++ include/linux/percpu_counter.h | 80 ++++++++++++++++++ include/linux/prefetch.h | 17 ++++ include/linux/quotaops.h | 38 +++++++++ include/linux/random.h | 15 ++++ include/linux/rwsem.h | 28 +++++++ include/linux/sched.h | 36 +++++++++ include/linux/security.h | 39 +++++++++ include/linux/seq_file.h | 18 +++++ include/linux/slab.h | 79 ++++++++++++++++++ include/linux/sort.h | 19 +++++ include/linux/stddef.h | 8 ++ include/linux/swap.h | 18 +++++ include/linux/timer.h | 30 +++++++ include/linux/uaccess.h | 32 ++++++++ include/linux/vmalloc.h | 24 ++++++ include/linux/wait.h | 31 +++++++ include/linux/workqueue.h | 37 +++++++++ 28 files changed, 849 insertions(+), 126 deletions(-) create mode 100644 include/linux/capability.h create mode 100644 include/linux/cred.h create mode 100644 include/linux/export.h create mode 100644 include/linux/file.h create mode 100644 include/linux/freezer.h create mode 100644 include/linux/init.h create mode 100644 include/linux/kthread.h create mode 100644 include/linux/module.h create mode 100644 include/linux/part_stat.h create mode 100644 include/linux/path.h create mode 100644 include/linux/percpu_counter.h create mode 100644 include/linux/prefetch.h create mode 100644 include/linux/quotaops.h create mode 100644 include/linux/random.h create mode 100644 include/linux/rwsem.h create mode 100644 include/linux/sched.h create mode 100644 include/linux/security.h create mode 100644 include/linux/seq_file.h create mode 100644 include/linux/slab.h create mode 100644 include/linux/sort.h create mode 100644 include/linux/swap.h create mode 100644 include/linux/timer.h create mode 100644 include/linux/uaccess.h create mode 100644 include/linux/vmalloc.h create mode 100644 include/linux/wait.h create mode 100644 include/linux/workqueue.h -- 2.43.0 base-commit: e7f94bcbcb083a5c2f667193069c0bf89dbbd22f branch: extb
From: Simon Glass <simon.glass@canonical.com> Create include/linux/export.h with stub definitions for EXPORT_SYMBOL and EXPORT_SYMBOL_GPL macros. This matches the Linux kernel's header organization where export.h is a separate file. Update compat.h to include export.h and remove the duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 3 +-- include/linux/export.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 include/linux/export.h diff --git a/include/linux/compat.h b/include/linux/compat.h index 62381451617..12b4cfccdc5 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -11,6 +11,7 @@ #include <linux/types.h> #include <linux/err.h> +#include <linux/export.h> #include <linux/kernel.h> #ifdef CONFIG_XEN @@ -182,8 +183,6 @@ typedef unsigned long blkcnt_t; #define module_put(...) do { } while (0) #define module_init(...) #define module_exit(...) -#define EXPORT_SYMBOL(...) -#define EXPORT_SYMBOL_GPL(...) #define module_param(...) #define module_param_call(...) #define MODULE_PARM_DESC(...) diff --git a/include/linux/export.h b/include/linux/export.h new file mode 100644 index 00000000000..2585bd40d25 --- /dev/null +++ b/include/linux/export.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_EXPORT_H +#define _LINUX_EXPORT_H + +/* + * Stub definitions for Linux kernel module exports. + * U-Boot doesn't use modules, so these are no-ops. + */ +#define EXPORT_SYMBOL(sym) +#define EXPORT_SYMBOL_GPL(sym) +#define EXPORT_SYMBOL_NS(sym, ns) +#define EXPORT_SYMBOL_NS_GPL(sym, ns) + +#endif /* _LINUX_EXPORT_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add the sizeof_field() macro which returns the size of a struct field. This is used by Linux kernel code including ext4. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/stddef.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/stddef.h b/include/linux/stddef.h index c732eef65ac..deeffc96360 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -17,4 +17,12 @@ #undef offsetof #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) +/** + * sizeof_field() - Report the size of a struct field in bytes + * + * @TYPE: The structure containing the field of interest + * @MEMBER: The field to return the size of + */ +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) + #endif -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/uaccess.h with stub implementations for user-space access functions. In U-Boot there's no user/kernel separation, so these are simple memory copies. Includes: - copy_from_user() - copy_to_user() - get_user() / put_user() - access_ok() Update compat.h to include uaccess.h and remove the duplicate declaration. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 3 +-- include/linux/uaccess.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 include/linux/uaccess.h diff --git a/include/linux/compat.h b/include/linux/compat.h index 12b4cfccdc5..d66ca200602 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -13,6 +13,7 @@ #include <linux/err.h> #include <linux/export.h> #include <linux/kernel.h> +#include <linux/uaccess.h> #ifdef CONFIG_XEN #include <xen/events.h> @@ -239,8 +240,6 @@ typedef unsigned long blkcnt_t; struct work_struct {}; -unsigned long copy_from_user(void *dest, const void *src, - unsigned long count); typedef unused_t spinlock_t; typedef int wait_queue_head_t; diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h new file mode 100644 index 00000000000..96311e2c6f1 --- /dev/null +++ b/include/linux/uaccess.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_UACCESS_H +#define _LINUX_UACCESS_H + +#include <linux/types.h> +#include <string.h> + +/* + * Stub definitions for Linux kernel user-space access functions. + * In U-Boot there's no user/kernel separation, so these are simple copies. + */ + +static inline unsigned long copy_from_user(void *to, const void *from, + unsigned long n) +{ + memcpy(to, from, n); + return 0; +} + +static inline unsigned long copy_to_user(void *to, const void *from, + unsigned long n) +{ + memcpy(to, from, n); + return 0; +} + +#define get_user(x, ptr) ({ x = *(ptr); 0; }) +#define put_user(x, ptr) ({ *(ptr) = x; 0; }) + +#define access_ok(addr, size) 1 + +#endif /* _LINUX_UACCESS_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add stub headers for Linux kernel interfaces that ext4 code expects: - capability.h: stub capability checks (always return true) - cred.h: stub credential types and macros - file.h: stub file descriptor helpers - path.h: basic path structure definition - security.h: stub LSM hooks (no-ops) - seq_file.h: stub seq_file interface These provide minimal definitions to allow ext4 code to compile. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/capability.h | 27 +++++++++++++++++++ include/linux/cred.h | 53 ++++++++++++++++++++++++++++++++++++++ include/linux/file.h | 29 +++++++++++++++++++++ include/linux/path.h | 13 ++++++++++ include/linux/security.h | 39 ++++++++++++++++++++++++++++ include/linux/seq_file.h | 18 +++++++++++++ 6 files changed, 179 insertions(+) create mode 100644 include/linux/capability.h create mode 100644 include/linux/cred.h create mode 100644 include/linux/file.h create mode 100644 include/linux/path.h create mode 100644 include/linux/security.h create mode 100644 include/linux/seq_file.h diff --git a/include/linux/capability.h b/include/linux/capability.h new file mode 100644 index 00000000000..1192c8a4033 --- /dev/null +++ b/include/linux/capability.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * This is <linux/capability.h> + * + * Andrew G. Morgan <morgan@kernel.org> + * Alexander Kjeldaas <astor@guardian.no> + * with help from Aleph1, Roland Buresund and Andrew Main. + * + * Stub definitions for Linux kernel capabilities. + * U-Boot doesn't implement capability checks. + */ +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H + +#define CAP_SYS_RESOURCE 24 + +static inline bool capable(int cap) +{ + return true; +} + +static inline bool ns_capable(void *ns, int cap) +{ + return true; +} + +#endif /* _LINUX_CAPABILITY_H */ diff --git a/include/linux/cred.h b/include/linux/cred.h new file mode 100644 index 00000000000..a5afc267ba0 --- /dev/null +++ b/include/linux/cred.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Credentials management - see Documentation/security/credentials.rst + * + * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + */ +#ifndef _LINUX_CRED_H +#define _LINUX_CRED_H + +#include <linux/types.h> + +/* + * Stub definitions for Linux kernel credentials. + * U-Boot doesn't implement user credentials. + */ + +typedef struct { + uid_t val; +} kuid_t; + +typedef struct { + gid_t val; +} kgid_t; + +struct cred { + kuid_t uid; + kgid_t gid; + kuid_t fsuid; + kgid_t fsgid; +}; + +#define current_cred() NULL +#define current_uid() ((kuid_t){0}) +#define current_gid() ((kgid_t){0}) +#define current_fsuid() ((kuid_t){0}) +#define current_fsgid() ((kgid_t){0}) + +#define from_kuid(ns, uid) ((uid).val) +#define from_kgid(ns, gid) ((gid).val) +#define make_kuid(ns, uid) ((kuid_t){uid}) +#define make_kgid(ns, gid) ((kgid_t){gid}) + +#define uid_eq(a, b) ((a).val == (b).val) +#define gid_eq(a, b) ((a).val == (b).val) +#define uid_valid(uid) ((uid).val != (uid_t)-1) +#define gid_valid(gid) ((gid).val != (gid_t)-1) + +#define GLOBAL_ROOT_UID ((kuid_t){0}) +#define GLOBAL_ROOT_GID ((kgid_t){0}) +#define INVALID_UID ((kuid_t){-1}) +#define INVALID_GID ((kgid_t){-1}) + +#endif /* _LINUX_CRED_H */ diff --git a/include/linux/file.h b/include/linux/file.h new file mode 100644 index 00000000000..74859204979 --- /dev/null +++ b/include/linux/file.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Wrapper functions for accessing the file_struct fd array. + */ +#ifndef _LINUX_FILE_H +#define _LINUX_FILE_H + +/* + * Stub definitions for Linux kernel file handling. + */ + +struct file; +struct fd { + struct file *file; + unsigned int flags; +}; + +#define EMPTY_FD ((struct fd){ NULL, 0 }) + +static inline struct fd fdget(unsigned int fd) +{ + return EMPTY_FD; +} + +static inline void fdput(struct fd fd) +{ +} + +#endif /* _LINUX_FILE_H */ diff --git a/include/linux/path.h b/include/linux/path.h new file mode 100644 index 00000000000..27cc071026a --- /dev/null +++ b/include/linux/path.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_PATH_H +#define _LINUX_PATH_H + +struct dentry; +struct vfsmount; + +struct path { + struct vfsmount *mnt; + struct dentry *dentry; +}; + +#endif /* _LINUX_PATH_H */ diff --git a/include/linux/security.h b/include/linux/security.h new file mode 100644 index 00000000000..876b70bc1c8 --- /dev/null +++ b/include/linux/security.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Linux Security plug + * + * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com> + * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com> + * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com> + * Copyright (C) 2001 James Morris <jmorris@intercode.com.au> + * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group) + * Copyright (C) 2016 Mellanox Techonologies + * + * Stub definitions for Linux Security Module (LSM) hooks. + * U-Boot doesn't implement security modules. + */ +#ifndef _LINUX_SECURITY_H +#define _LINUX_SECURITY_H + +struct inode; +struct dentry; + +static inline int security_inode_init_security(struct inode *inode, + struct inode *dir, + void *name, void *value, + void *len) +{ + return -EOPNOTSUPP; +} + +#define security_inode_create(dir, dentry, mode) 0 +#define security_inode_link(old, dir, new) 0 +#define security_inode_unlink(dir, dentry) 0 +#define security_inode_symlink(dir, dentry, name) 0 +#define security_inode_mkdir(dir, dentry, mode) 0 +#define security_inode_rmdir(dir, dentry) 0 +#define security_inode_mknod(dir, dentry, mode, dev) 0 +#define security_inode_rename(od, odent, nd, ndent, f) 0 +#define security_inode_setattr(dentry, attr) 0 + +#endif /* _LINUX_SECURITY_H */ diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h new file mode 100644 index 00000000000..fb5dbf97708 --- /dev/null +++ b/include/linux/seq_file.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_SEQ_FILE_H +#define _LINUX_SEQ_FILE_H + +/* + * Stub definitions for seq_file interface. + * U-Boot doesn't use /proc filesystem. + */ + +struct seq_file { + void *private; +}; + +#define seq_printf(m, fmt, ...) do { } while (0) +#define seq_puts(m, s) do { } while (0) +#define seq_putc(m, c) do { } while (0) + +#endif /* _LINUX_SEQ_FILE_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/freezer.h with stub definitions for process freezer functions used during suspend/hibernate. U-Boot doesn't support process freezing, so these are no-ops. Update compat.h to include freezer.h and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 3 +-- include/linux/freezer.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 include/linux/freezer.h diff --git a/include/linux/compat.h b/include/linux/compat.h index d66ca200602..190c3820a14 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -12,6 +12,7 @@ #include <linux/types.h> #include <linux/err.h> #include <linux/export.h> +#include <linux/freezer.h> #include <linux/kernel.h> #include <linux/uaccess.h> @@ -228,8 +229,6 @@ typedef unsigned long blkcnt_t; #define dump_stack(...) do { } while (0) #define task_pid_nr(x) 0 -#define set_freezable(...) do { } while (0) -#define try_to_freeze(...) 0 #define set_current_state(...) do { } while (0) #define kthread_should_stop(...) 0 diff --git a/include/linux/freezer.h b/include/linux/freezer.h new file mode 100644 index 00000000000..be38266beeb --- /dev/null +++ b/include/linux/freezer.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Freezer declarations + * + * Stub definitions for Linux kernel freezer (suspend/hibernate). + * U-Boot doesn't support process freezing. + */ +#ifndef _LINUX_FREEZER_H +#define _LINUX_FREEZER_H + +#define set_freezable() do { } while (0) +#define try_to_freeze() 0 +#define freezing(task) 0 +#define frozen(task) 0 +#define freezable_schedule() do { } while (0) +#define freezable_schedule_timeout(t) 0 + +#endif /* _LINUX_FREEZER_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/slab.h and include/linux/vmalloc.h with memory allocation functions: slab.h: - GFP flags (GFP_KERNEL, GFP_ATOMIC, etc.) - kmalloc(), kzalloc(), kcalloc(), kmalloc_array() - kfree(), krealloc(), kmemdup() - kmem_cache_* functions vmalloc.h: - vmalloc(), vzalloc(), vfree() - __vmalloc() Update compat.h to include these headers and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 58 ++---------------------------- include/linux/slab.h | 79 +++++++++++++++++++++++++++++++++++++++++ include/linux/vmalloc.h | 24 +++++++++++++ 3 files changed, 105 insertions(+), 56 deletions(-) create mode 100644 include/linux/slab.h create mode 100644 include/linux/vmalloc.h diff --git a/include/linux/compat.h b/include/linux/compat.h index 190c3820a14..28207fb96b8 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -14,7 +14,9 @@ #include <linux/export.h> #include <linux/freezer.h> #include <linux/kernel.h> +#include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/vmalloc.h> #ifdef CONFIG_XEN #include <xen/events.h> @@ -29,61 +31,6 @@ struct p_current{ extern struct p_current *current; -#define GFP_ATOMIC ((gfp_t) 0) -#define GFP_KERNEL ((gfp_t) 0) -#define GFP_NOFS ((gfp_t) 0) -#define GFP_USER ((gfp_t) 0) -#define __GFP_NOWARN ((gfp_t) 0) -#define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */ - -void *kmalloc(size_t size, int flags); - -static inline void *kzalloc(size_t size, gfp_t flags) -{ - return kmalloc(size, flags | __GFP_ZERO); -} - -static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) -{ - if (size != 0 && n > SIZE_MAX / size) - return NULL; - return kmalloc(n * size, flags | __GFP_ZERO); -} - -static inline void *kcalloc(size_t n, size_t size, gfp_t flags) -{ - return kmalloc_array(n, size, flags | __GFP_ZERO); -} - -#define vmalloc(size) kmalloc(size, 0) -#define __vmalloc(size, flags, pgsz) kmalloc(size, flags) -static inline void *vzalloc(unsigned long size) -{ - return kzalloc(size, 0); -} -static inline void kfree(const void *block) -{ - free((void *)block); -} -static inline void vfree(const void *addr) -{ - free((void *)addr); -} - -struct kmem_cache { int sz; }; - -struct kmem_cache *get_mem(int element_sz); -#define kmem_cache_create(a, sz, c, d, e) get_mem(sz) -void *kmem_cache_alloc(struct kmem_cache *obj, int flag); -static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj) -{ - free(obj); -} -static inline void kmem_cache_destroy(struct kmem_cache *cachep) -{ - free(cachep); -} - #define DECLARE_WAITQUEUE(...) do { } while (0) #define add_wait_queue(...) do { } while (0) #define remove_wait_queue(...) do { } while (0) @@ -357,7 +304,6 @@ struct writeback_control { unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */ }; -void *kmemdup(const void *src, size_t len, gfp_t gfp); typedef int irqreturn_t; diff --git a/include/linux/slab.h b/include/linux/slab.h new file mode 100644 index 00000000000..2ea124a420d --- /dev/null +++ b/include/linux/slab.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Written by Mark Hemment, 1996 (markhe@nextd.demon.co.uk). + * + * (C) SGI 2006, Christoph Lameter + * Cleaned up and restructured to ease the addition of alternative + * implementations of SLAB allocators. + * (C) Linux Foundation 2008-2013 + * Unified interface for all slab allocators + * + * Memory allocation functions for Linux kernel compatibility. + * These map to U-Boot's malloc/free infrastructure. + */ +#ifndef _LINUX_SLAB_H +#define _LINUX_SLAB_H + +#include <malloc.h> +#include <linux/types.h> + +#define GFP_ATOMIC ((gfp_t)0) +#define GFP_KERNEL ((gfp_t)0) +#define GFP_NOFS ((gfp_t)0) +#define GFP_USER ((gfp_t)0) +#define GFP_NOWAIT ((gfp_t)0) +#define __GFP_NOWARN ((gfp_t)0) +#define __GFP_ZERO ((__force gfp_t)0x8000u) +#define __GFP_NOFAIL ((gfp_t)0) + +void *kmalloc(size_t size, gfp_t flags); + +static inline void *kzalloc(size_t size, gfp_t flags) +{ + return kmalloc(size, flags | __GFP_ZERO); +} + +static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) +{ + if (size != 0 && n > SIZE_MAX / size) + return NULL; + return kmalloc(n * size, flags | __GFP_ZERO); +} + +static inline void *kcalloc(size_t n, size_t size, gfp_t flags) +{ + return kmalloc_array(n, size, flags | __GFP_ZERO); +} + +static inline void kfree(const void *block) +{ + free((void *)block); +} + +static inline void *krealloc(const void *p, size_t new_size, gfp_t flags) +{ + return realloc((void *)p, new_size); +} + +void *kmemdup(const void *src, size_t len, gfp_t gfp); + +/* kmem_cache stubs */ +struct kmem_cache { + int sz; +}; + +struct kmem_cache *get_mem(int element_sz); +#define kmem_cache_create(a, sz, c, d, e) get_mem(sz) +void *kmem_cache_alloc(struct kmem_cache *obj, gfp_t flag); + +static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj) +{ + free(obj); +} + +static inline void kmem_cache_destroy(struct kmem_cache *cachep) +{ + free(cachep); +} + +#endif /* _LINUX_SLAB_H */ diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h new file mode 100644 index 00000000000..b8b5e5e63a2 --- /dev/null +++ b/include/linux/vmalloc.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * vmalloc functions for Linux kernel compatibility. + * In U-Boot, these just map to regular malloc. + */ +#ifndef _LINUX_VMALLOC_H +#define _LINUX_VMALLOC_H + +#include <linux/slab.h> + +#define vmalloc(size) kmalloc(size, 0) +#define __vmalloc(size, flags, pgsz) kmalloc(size, flags) + +static inline void *vzalloc(unsigned long size) +{ + return kzalloc(size, 0); +} + +static inline void vfree(const void *addr) +{ + free((void *)addr); +} + +#endif /* _LINUX_VMALLOC_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/module.h with stub definitions for kernel module support. U-Boot doesn't use loadable modules, so these are no-ops. Includes: - THIS_MODULE, try_module_get(), module_put() - module_init(), module_exit() - module_param() and variants - MODULE_* macros (LICENSE, AUTHOR, DESCRIPTION, etc.) Update compat.h to include module.h and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 16 +--------------- include/linux/module.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 include/linux/module.h diff --git a/include/linux/compat.h b/include/linux/compat.h index 28207fb96b8..3bba18d637d 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -14,6 +14,7 @@ #include <linux/export.h> #include <linux/freezer.h> #include <linux/kernel.h> +#include <linux/module.h> #include <linux/slab.h> #include <linux/uaccess.h> #include <linux/vmalloc.h> @@ -126,21 +127,6 @@ typedef unsigned long sector_t; typedef unsigned long blkcnt_t; #endif -/* module */ -#define THIS_MODULE 0 -#define try_module_get(...) 1 -#define module_put(...) do { } while (0) -#define module_init(...) -#define module_exit(...) -#define module_param(...) -#define module_param_call(...) -#define MODULE_PARM_DESC(...) -#define MODULE_VERSION(...) -#define MODULE_DESCRIPTION(...) -#define MODULE_AUTHOR(...) -#define MODULE_LICENSE(...) -#define MODULE_ALIAS(...) -#define __module_get(...) /* character device */ #define MKDEV(...) 0 diff --git a/include/linux/module.h b/include/linux/module.h new file mode 100644 index 00000000000..ba226652144 --- /dev/null +++ b/include/linux/module.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Dynamic loading of modules into the kernel. + * + * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 + * Rewritten again by Rusty Russell, 2002 + * + * Stub definitions for Linux kernel module support. + * U-Boot doesn't use loadable modules. + */ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +struct module; + +#define THIS_MODULE ((struct module *)0) +#define try_module_get(...) 1 +#define module_put(...) do { } while (0) +#define __module_get(...) do { } while (0) + +#define module_init(fn) +#define module_exit(fn) + +#define module_param(name, type, perm) +#define module_param_call(name, set, get, arg, perm) +#define module_param_named(name, var, type, perm) + +#define MODULE_PARM_DESC(name, desc) +#define MODULE_VERSION(ver) +#define MODULE_DESCRIPTION(desc) +#define MODULE_AUTHOR(author) +#define MODULE_LICENSE(license) +#define MODULE_ALIAS(alias) +#define MODULE_SOFTDEP(dep) +#define MODULE_INFO(tag, info) + +#endif /* _LINUX_MODULE_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/init.h with stub definitions for kernel initialization macros. U-Boot has its own initialization mechanism. Includes: - Section markers: __init, __exit, __initdata, __devinit, etc. - Initcall levels: core_initcall(), late_initcall(), etc. Update compat.h to include init.h and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 10 +-------- include/linux/init.h | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 include/linux/init.h diff --git a/include/linux/compat.h b/include/linux/compat.h index 3bba18d637d..fc0bfc31e5f 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -13,6 +13,7 @@ #include <linux/err.h> #include <linux/export.h> #include <linux/freezer.h> +#include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> @@ -147,8 +148,6 @@ typedef unsigned long blkcnt_t; #define blocking_notifier_call_chain(...) 0 -#define __initdata -#define late_initcall(...) #define dev_set_name(...) do { } while (0) #define device_register(...) 0 @@ -197,13 +196,6 @@ typedef int wait_queue_head_t; #define cond_resched() do { } while (0) #define yield() do { } while (0) -#define __init -#define __exit -#define __devinit -#define __devinitdata -#define __devinitconst -#define __initconst -#define __initdata #define kthread_create(...) __builtin_return_address(0) #define kthread_stop(...) do { } while (0) diff --git a/include/linux/init.h b/include/linux/init.h new file mode 100644 index 00000000000..ea74422c337 --- /dev/null +++ b/include/linux/init.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * These macros are used to mark some functions or initialized data + * as 'initialization' functions. The kernel can take this as hint + * that the function is used only during the initialization phase + * and free up used memory resources after. + * + * Stub definitions for Linux kernel initialization macros. + * U-Boot has its own initialization mechanism. + */ +#ifndef _LINUX_INIT_H +#define _LINUX_INIT_H + +/* Section markers - these are no-ops in U-Boot */ +#define __init +#define __exit +#define __initdata +#define __exitdata +#define __initconst +#define __exitconst +#define __devinit +#define __devexit +#define __devinitdata +#define __devexitdata +#define __devinitconst +#define __devexitconst + +/* Initcall levels - no-ops in U-Boot */ +#define pure_initcall(fn) +#define core_initcall(fn) +#define core_initcall_sync(fn) +#define postcore_initcall(fn) +#define postcore_initcall_sync(fn) +#define arch_initcall(fn) +#define arch_initcall_sync(fn) +#define subsys_initcall(fn) +#define subsys_initcall_sync(fn) +#define fs_initcall(fn) +#define fs_initcall_sync(fn) +#define rootfs_initcall(fn) +#define device_initcall(fn) +#define device_initcall_sync(fn) +#define late_initcall(fn) +#define late_initcall_sync(fn) + +#define __initcall(fn) +#define __exitcall(fn) + +#endif /* _LINUX_INIT_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/kthread.h with stub definitions for kernel thread support. U-Boot doesn't have multi-threading. Includes: - kthread_create(), kthread_run(), kthread_stop() - kthread_should_stop(), kthread_should_park() - wake_up_process(), set_current_state() - task_pid_nr() Update compat.h to include kthread.h and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 7 +------ include/linux/kthread.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 include/linux/kthread.h diff --git a/include/linux/compat.h b/include/linux/compat.h index fc0bfc31e5f..e9db2120de6 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -15,6 +15,7 @@ #include <linux/freezer.h> #include <linux/init.h> #include <linux/kernel.h> +#include <linux/kthread.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/uaccess.h> @@ -160,9 +161,6 @@ typedef unsigned long blkcnt_t; #define wake_up_interruptible(...) do { } while (0) #define dump_stack(...) do { } while (0) -#define task_pid_nr(x) 0 -#define set_current_state(...) do { } while (0) -#define kthread_should_stop(...) 0 #define setup_timer(timer, func, data) do {} while (0) #define del_timer_sync(timer) do {} while (0) @@ -197,9 +195,6 @@ typedef int wait_queue_head_t; #define yield() do { } while (0) -#define kthread_create(...) __builtin_return_address(0) -#define kthread_stop(...) do { } while (0) -#define wake_up_process(...) do { } while (0) struct rw_semaphore { int i; }; #define down_write(...) do { } while (0) diff --git a/include/linux/kthread.h b/include/linux/kthread.h new file mode 100644 index 00000000000..ba35274e9a4 --- /dev/null +++ b/include/linux/kthread.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Simple interface for creating and stopping kernel threads without mess. + * + * Stub definitions for Linux kernel thread support. + * U-Boot doesn't have multi-threading. + */ +#ifndef _LINUX_KTHREAD_H +#define _LINUX_KTHREAD_H + +struct task_struct; + +#define kthread_create(fn, data, fmt, ...) \ + ((struct task_struct *)__builtin_return_address(0)) +#define kthread_run(fn, data, fmt, ...) \ + ((struct task_struct *)__builtin_return_address(0)) +#define kthread_stop(task) do { } while (0) +#define kthread_should_stop() 0 +#define kthread_should_park() 0 +#define kthread_park(task) 0 +#define kthread_unpark(task) do { } while (0) +#define kthread_parkme() do { } while (0) + +#define wake_up_process(task) do { } while (0) +#define set_current_state(state) do { } while (0) + +#define task_pid_nr(task) 0 + +#endif /* _LINUX_KTHREAD_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/timer.h and include/linux/workqueue.h with stub definitions for kernel timer and workqueue support. U-Boot doesn't use these subsystems. timer.h: - struct timer_list - setup_timer(), del_timer(), del_timer_sync() - timer_setup(), mod_timer(), timer_pending() workqueue.h: - struct work_struct, struct delayed_work - INIT_WORK(), schedule_work() - queue_work(), cancel_work_sync() - alloc_workqueue(), destroy_workqueue() Update compat.h to include these headers and remove duplicate definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/linux/compat.h | 9 ++------- include/linux/timer.h | 30 ++++++++++++++++++++++++++++++ include/linux/workqueue.h | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 include/linux/timer.h create mode 100644 include/linux/workqueue.h diff --git a/include/linux/compat.h b/include/linux/compat.h index e9db2120de6..6892decf3ec 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -18,8 +18,10 @@ #include <linux/kthread.h> #include <linux/module.h> #include <linux/slab.h> +#include <linux/timer.h> #include <linux/uaccess.h> #include <linux/vmalloc.h> +#include <linux/workqueue.h> #ifdef CONFIG_XEN #include <xen/events.h> @@ -162,12 +164,6 @@ typedef unsigned long blkcnt_t; #define dump_stack(...) do { } while (0) -#define setup_timer(timer, func, data) do {} while (0) -#define del_timer_sync(timer) do {} while (0) -#define schedule_work(work) do {} while (0) -#define INIT_WORK(work, fun) do {} while (0) - -struct work_struct {}; typedef unused_t spinlock_t; @@ -280,7 +276,6 @@ struct writeback_control { typedef int irqreturn_t; -struct timer_list {}; struct notifier_block {}; typedef unsigned long dmaaddr_t; diff --git a/include/linux/timer.h b/include/linux/timer.h new file mode 100644 index 00000000000..71274df1125 --- /dev/null +++ b/include/linux/timer.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Stub definitions for Linux kernel timer support. + * U-Boot doesn't use kernel timers. + */ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +struct timer_list { + unsigned long expires; + void (*function)(struct timer_list *); + unsigned long data; +}; + +#define DEFINE_TIMER(name, func) \ + struct timer_list name = { .function = func } + +#define setup_timer(timer, func, data) do { } while (0) +#define timer_setup(timer, func, flags) do { } while (0) +#define init_timer(timer) do { } while (0) +#define add_timer(timer) do { } while (0) +#define del_timer(timer) 0 +#define del_timer_sync(timer) 0 +#define mod_timer(timer, expires) 0 +#define timer_pending(timer) 0 + +#define from_timer(var, callback_timer, timer_fieldname) \ + container_of(callback_timer, typeof(*var), timer_fieldname) + +#endif /* _LINUX_TIMER_H */ diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h new file mode 100644 index 00000000000..8f0cc25a2ea --- /dev/null +++ b/include/linux/workqueue.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * workqueue.h --- work queue handling for Linux. + * + * Stub definitions for Linux kernel workqueue support. + * U-Boot doesn't use workqueues. + */ +#ifndef _LINUX_WORKQUEUE_H +#define _LINUX_WORKQUEUE_H + +struct work_struct { + void (*func)(struct work_struct *); +}; + +struct delayed_work { + struct work_struct work; +}; + +#define INIT_WORK(work, func) do { } while (0) +#define INIT_DELAYED_WORK(work, func) do { } while (0) +#define schedule_work(work) 0 +#define schedule_delayed_work(work, delay) 0 +#define cancel_work_sync(work) 0 +#define cancel_delayed_work(work) 0 +#define cancel_delayed_work_sync(work) 0 +#define flush_work(work) 0 +#define flush_delayed_work(work) 0 +#define queue_work(wq, work) 0 +#define queue_delayed_work(wq, work, delay) 0 + +#define alloc_workqueue(fmt, flags, max, ...) ((struct workqueue_struct *)1) +#define create_singlethread_workqueue(name) ((struct workqueue_struct *)1) +#define destroy_workqueue(wq) do { } while (0) + +struct workqueue_struct; + +#endif /* _LINUX_WORKQUEUE_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> 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> --- include/linux/compat.h | 28 ++---------- include/linux/part_stat.h | 16 +++++++ include/linux/percpu_counter.h | 80 ++++++++++++++++++++++++++++++++++ include/linux/prefetch.h | 17 ++++++++ include/linux/quotaops.h | 38 ++++++++++++++++ include/linux/random.h | 15 +++++++ include/linux/rwsem.h | 28 ++++++++++++ include/linux/sched.h | 36 +++++++++++++++ include/linux/sort.h | 19 ++++++++ include/linux/swap.h | 18 ++++++++ include/linux/wait.h | 31 +++++++++++++ 11 files changed, 302 insertions(+), 24 deletions(-) create mode 100644 include/linux/part_stat.h create mode 100644 include/linux/percpu_counter.h create mode 100644 include/linux/prefetch.h create mode 100644 include/linux/quotaops.h create mode 100644 include/linux/random.h create mode 100644 include/linux/rwsem.h create mode 100644 include/linux/sched.h create mode 100644 include/linux/sort.h create mode 100644 include/linux/swap.h create mode 100644 include/linux/wait.h diff --git a/include/linux/compat.h b/include/linux/compat.h index 6892decf3ec..d5e4c3b4530 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -11,12 +11,16 @@ #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> @@ -93,8 +97,6 @@ extern struct p_current *current; #define PAGE_SIZE 4096 #endif -/* drivers/char/random.c */ -#define get_random_bytes(...) /* include/linux/leds.h */ struct led_trigger {}; @@ -180,23 +182,9 @@ typedef int wait_queue_head_t; #define mutex_lock(...) #define mutex_unlock(...) -#define init_rwsem(...) do { } while (0) -#define down_read(...) do { } while (0) -#define down_write(...) do { } while (0) -#define down_write_trylock(...) 1 -#define up_read(...) do { } while (0) -#define up_write(...) do { } while (0) -#define cond_resched() do { } while (0) -#define yield() do { } while (0) - -struct rw_semaphore { int i; }; -#define down_write(...) do { } while (0) -#define up_write(...) do { } while (0) -#define down_read(...) do { } while (0) -#define up_read(...) do { } while (0) struct device { struct device *parent; struct class *class; @@ -217,15 +205,7 @@ struct cdev { #define cdev_add(...) 0 #define cdev_del(...) do { } while (0) -#define prandom_u32(...) 0 - -typedef struct { - uid_t val; -} kuid_t; -typedef struct { - gid_t val; -} kgid_t; /* from include/linux/types.h */ diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h new file mode 100644 index 00000000000..8c998b99786 --- /dev/null +++ b/include/linux/part_stat.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Stub definitions for partition statistics. + * U-Boot doesn't track I/O statistics. + */ +#ifndef _LINUX_PART_STAT_H +#define _LINUX_PART_STAT_H + +#define STAT_READ 0 +#define STAT_WRITE 1 + +#define part_stat_read(bdev, field) 0 +#define part_stat_inc(bdev, field) do { } while (0) +#define part_stat_add(bdev, field, val) do { } while (0) + +#endif /* _LINUX_PART_STAT_H */ diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h new file mode 100644 index 00000000000..425648e6377 --- /dev/null +++ b/include/linux/percpu_counter.h @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * A simple "approximate counter" for use in ext2 and ext3 superblocks. + * + * WARNING: these things are HUGE. 4 kbytes per counter on 32-way P4. + * + * Stub definitions for percpu counters. + * U-Boot is single-threaded, use simple counters. + */ +#ifndef _LINUX_PERCPU_COUNTER_H +#define _LINUX_PERCPU_COUNTER_H + +#include <linux/types.h> + +struct percpu_counter { + s64 count; +}; + +static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount, + gfp_t gfp) +{ + fbc->count = amount; + return 0; +} + +static inline void percpu_counter_destroy(struct percpu_counter *fbc) +{ +} + +static inline void percpu_counter_set(struct percpu_counter *fbc, s64 amount) +{ + fbc->count = amount; +} + +static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) +{ + fbc->count += amount; +} + +static inline void percpu_counter_sub(struct percpu_counter *fbc, s64 amount) +{ + fbc->count -= amount; +} + +static inline void percpu_counter_inc(struct percpu_counter *fbc) +{ + fbc->count++; +} + +static inline void percpu_counter_dec(struct percpu_counter *fbc) +{ + fbc->count--; +} + +static inline s64 percpu_counter_read(struct percpu_counter *fbc) +{ + return fbc->count; +} + +static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc) +{ + return fbc->count > 0 ? fbc->count : 0; +} + +static inline s64 percpu_counter_sum(struct percpu_counter *fbc) +{ + return fbc->count; +} + +static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc) +{ + return fbc->count > 0 ? fbc->count : 0; +} + +static inline bool percpu_counter_initialized(struct percpu_counter *fbc) +{ + return true; +} + +#endif /* _LINUX_PERCPU_COUNTER_H */ diff --git a/include/linux/prefetch.h b/include/linux/prefetch.h new file mode 100644 index 00000000000..4b9bbfbe7e9 --- /dev/null +++ b/include/linux/prefetch.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Generic cache management functions. Everything is arch-specific, + * but this header exists to make sure the defines/functions can be + * used in a generic way. + * + * 2000-11-13 Arjan van de Ven <arjan@fenrus.demon.nl> + * + * Stub definitions for prefetch operations. + */ +#ifndef _LINUX_PREFETCH_H +#define _LINUX_PREFETCH_H + +#define prefetch(x) do { } while (0) +#define prefetchw(x) do { } while (0) + +#endif /* _LINUX_PREFETCH_H */ diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h new file mode 100644 index 00000000000..04988ace843 --- /dev/null +++ b/include/linux/quotaops.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Definitions for diskquota-operations. When diskquota is configured these + * macros expand to the right source-code. + * + * Author: Marco van Wieringen <mvw@planets.elm.net> + * + * Stub definitions for quota operations. + * U-Boot doesn't support disk quotas. + */ +#ifndef _LINUX_QUOTAOPS_H +#define _LINUX_QUOTAOPS_H + +struct inode; +struct dentry; +struct kqid; + +#define dquot_initialize(inode) 0 +#define dquot_drop(inode) do { } while (0) +#define dquot_alloc_inode(inode) 0 +#define dquot_free_inode(inode) do { } while (0) +#define dquot_transfer(inode, attr) 0 +#define dquot_claim_space_nodirty(inode, nr) 0 +#define dquot_reclaim_space_nodirty(inode, nr) do { } while (0) +#define dquot_disable(sb, type, flags) 0 +#define dquot_suspend(sb, type) 0 +#define dquot_resume(sb, type) 0 +#define dquot_file_open(inode, file) 0 + +#define sb_has_quota_usage_enabled(sb, type) 0 +#define sb_has_quota_limits_enabled(sb, type) 0 +#define sb_has_quota_suspended(sb, type) 0 +#define sb_has_quota_loaded(sb, type) 0 +#define sb_has_quota_active(sb, type) 0 +#define sb_any_quota_loaded(sb) 0 +#define sb_any_quota_active(sb) 0 + +#endif /* _LINUX_QUOTAOPS_H */ diff --git a/include/linux/random.h b/include/linux/random.h new file mode 100644 index 00000000000..cb09c6c6b05 --- /dev/null +++ b/include/linux/random.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Stub definitions for random number generation. + */ +#ifndef _LINUX_RANDOM_H +#define _LINUX_RANDOM_H + +#include <linux/types.h> + +#define get_random_bytes(buf, len) do { } while (0) +#define prandom_u32() 0 +#define get_random_u32() 0 +#define get_random_u64() 0ULL + +#endif /* _LINUX_RANDOM_H */ diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h new file mode 100644 index 00000000000..ea70829d135 --- /dev/null +++ b/include/linux/rwsem.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* rwsem.h: R/W semaphores, public interface + * + * Written by David Howells (dhowells@redhat.com). + * Derived from asm-i386/semaphore.h + * + * Stub definitions for Linux kernel read-write semaphores. + * U-Boot is single-threaded, no locking needed. + */ +#ifndef _LINUX_RWSEM_H +#define _LINUX_RWSEM_H + +struct rw_semaphore { + int count; +}; + +#define DECLARE_RWSEM(name) struct rw_semaphore name = { 0 } + +#define init_rwsem(sem) do { } while (0) +#define down_read(sem) do { } while (0) +#define down_read_trylock(sem) 1 +#define up_read(sem) do { } while (0) +#define down_write(sem) do { } while (0) +#define down_write_trylock(sem) 1 +#define up_write(sem) do { } while (0) +#define downgrade_write(sem) do { } while (0) + +#endif /* _LINUX_RWSEM_H */ diff --git a/include/linux/sched.h b/include/linux/sched.h new file mode 100644 index 00000000000..e62a2a40c77 --- /dev/null +++ b/include/linux/sched.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Define 'struct task_struct' and provide the main scheduler + * APIs (schedule(), wakeup variants, etc.) + * + * Stub definitions for Linux kernel scheduler. + * U-Boot is single-threaded. + */ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +#include <linux/types.h> + +struct task_struct { + int pid; + char comm[16]; +}; + +extern struct task_struct *current; + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 + +#define cond_resched() do { } while (0) +#define yield() do { } while (0) +#define schedule() do { } while (0) + +#define in_interrupt() 0 +#define in_atomic() 0 +#define in_task() 1 + +#define signal_pending(task) 0 +#define fatal_signal_pending(task) 0 + +#endif /* _LINUX_SCHED_H */ diff --git a/include/linux/sort.h b/include/linux/sort.h new file mode 100644 index 00000000000..dc222d8dc89 --- /dev/null +++ b/include/linux/sort.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Sorting functions - use stdlib qsort. + */ +#ifndef _LINUX_SORT_H +#define _LINUX_SORT_H + +#include <linux/types.h> +#include <stdlib.h> + +typedef int (*cmp_func_t)(const void *, const void *); + +static inline void sort(void *base, size_t num, size_t size, + cmp_func_t cmp, void *swap) +{ + qsort(base, num, size, cmp); +} + +#endif /* _LINUX_SORT_H */ diff --git a/include/linux/swap.h b/include/linux/swap.h new file mode 100644 index 00000000000..1c714db6ae2 --- /dev/null +++ b/include/linux/swap.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Stub definitions for swap/memory management. + * U-Boot doesn't use swap. + */ +#ifndef _LINUX_SWAP_H +#define _LINUX_SWAP_H + +#define mark_page_accessed(page) do { } while (0) + +struct address_space; +struct folio; + +static inline void folio_mark_accessed(struct folio *folio) +{ +} + +#endif /* _LINUX_SWAP_H */ diff --git a/include/linux/wait.h b/include/linux/wait.h new file mode 100644 index 00000000000..1eb1263639e --- /dev/null +++ b/include/linux/wait.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Linux wait queue related types and methods + * + * Stub definitions for Linux kernel wait queues. + * U-Boot doesn't use wait queues. + */ +#ifndef _LINUX_WAIT_H +#define _LINUX_WAIT_H + +typedef int wait_queue_head_t; + +struct wait_queue_entry { + int dummy; +}; + +#define DECLARE_WAITQUEUE(name, task) struct wait_queue_entry name = { 0 } +#define DECLARE_WAIT_QUEUE_HEAD(name) wait_queue_head_t name = 0 + +#define init_waitqueue_head(wq) do { } while (0) +#define add_wait_queue(wq, entry) do { } while (0) +#define remove_wait_queue(wq, entry) do { } while (0) +#define wake_up(wq) do { } while (0) +#define wake_up_all(wq) do { } while (0) +#define wake_up_interruptible(wq) do { } while (0) +#define wake_up_interruptible_all(wq) do { } while (0) + +#define wait_event(wq, condition) do { } while (0) +#define wait_event_interruptible(wq, condition) 0 + +#endif /* _LINUX_WAIT_H */ -- 2.43.0
participants (1)
-
Simon Glass