@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */
new file mode 100644
@@ -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 */