linux: Add compatibility headers for ext4l
Add stub headers to support ext4l filesystem compilation: New headers: - bit_spinlock.h: bit-based spinlock stubs - blkdev.h: block device structures and operations - buffer_head.h: buffer head management with state functions - crc32c.h: CRC32C checksum stub - fs.h: filesystem structures (super_block, inode operations) - journal-head.h: journal buffer head structure - mutex.h: mutex stubs Updates to existing headers: - compat.h: add rcu_head callback structure - jbd2.h: add wait.h and init.h includes for types - sched.h: add current task stub - workqueue.h: fix flush_work macro warning These provide the minimal Linux kernel interfaces needed for ext4 code to compile in U-Boot's single-threaded environment. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
44
include/linux/bit_spinlock.h
Normal file
44
include/linux/bit_spinlock.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* bit-based spin_lock()
|
||||
*
|
||||
* Minimal version for U-Boot ext4l - based on Linux 6.18
|
||||
* U-Boot is single-threaded so these are simplified.
|
||||
*/
|
||||
#ifndef __LINUX_BIT_SPINLOCK_H
|
||||
#define __LINUX_BIT_SPINLOCK_H
|
||||
|
||||
#include <linux/bitops.h>
|
||||
|
||||
/*
|
||||
* bit-based spin_lock() - U-Boot single-threaded version
|
||||
*/
|
||||
static inline void bit_spin_lock(int bitnum, unsigned long *addr)
|
||||
{
|
||||
set_bit(bitnum, addr);
|
||||
}
|
||||
|
||||
static inline int bit_spin_trylock(int bitnum, unsigned long *addr)
|
||||
{
|
||||
if (test_bit(bitnum, addr))
|
||||
return 0;
|
||||
set_bit(bitnum, addr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void bit_spin_unlock(int bitnum, unsigned long *addr)
|
||||
{
|
||||
clear_bit(bitnum, addr);
|
||||
}
|
||||
|
||||
static inline void __bit_spin_unlock(int bitnum, unsigned long *addr)
|
||||
{
|
||||
clear_bit(bitnum, addr);
|
||||
}
|
||||
|
||||
static inline int bit_spin_is_locked(int bitnum, unsigned long *addr)
|
||||
{
|
||||
return test_bit(bitnum, addr);
|
||||
}
|
||||
|
||||
#endif /* __LINUX_BIT_SPINLOCK_H */
|
||||
18
include/linux/blkdev.h
Normal file
18
include/linux/blkdev.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Block device definitions
|
||||
*
|
||||
* Minimal version for U-Boot ext4l - based on Linux 6.18
|
||||
*/
|
||||
#ifndef _LINUX_BLKDEV_H
|
||||
#define _LINUX_BLKDEV_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
struct block_device;
|
||||
struct gendisk;
|
||||
|
||||
/* Block size helpers */
|
||||
#define bdev_logical_block_size(bdev) 512
|
||||
|
||||
#endif /* _LINUX_BLKDEV_H */
|
||||
21
include/linux/crc32c.h
Normal file
21
include/linux/crc32c.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* CRC32C definitions
|
||||
*
|
||||
* Minimal version for U-Boot ext4l - based on Linux 6.18
|
||||
*/
|
||||
#ifndef _LINUX_CRC32C_H
|
||||
#define _LINUX_CRC32C_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <u-boot/crc.h>
|
||||
|
||||
/* Use U-Boot's CRC32 implementation */
|
||||
static inline u32 crc32c(u32 crc, const void *address, unsigned int length)
|
||||
{
|
||||
return crc32(crc, address, length);
|
||||
}
|
||||
|
||||
#define crc32c_le(crc, p, len) crc32c(crc, p, len)
|
||||
|
||||
#endif /* _LINUX_CRC32C_H */
|
||||
83
include/linux/fs.h
Normal file
83
include/linux/fs.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Filesystem definitions
|
||||
*
|
||||
* Minimal version for U-Boot ext4l - based on Linux 6.18
|
||||
*/
|
||||
#ifndef _LINUX_FS_H
|
||||
#define _LINUX_FS_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
/* Forward declarations */
|
||||
struct inode;
|
||||
struct super_block;
|
||||
struct buffer_head;
|
||||
|
||||
/* errseq_t - error sequence type */
|
||||
typedef u32 errseq_t;
|
||||
|
||||
/* fmode_t - file mode type */
|
||||
typedef unsigned int fmode_t;
|
||||
|
||||
/* File mode flags */
|
||||
#define FMODE_READ ((__force fmode_t)(1 << 0))
|
||||
#define FMODE_WRITE ((__force fmode_t)(1 << 1))
|
||||
#define FMODE_LSEEK ((__force fmode_t)(1 << 2))
|
||||
|
||||
/* Buffer operations are in buffer_head.h */
|
||||
|
||||
/* address_space - minimal stub */
|
||||
struct address_space {
|
||||
struct inode *host;
|
||||
errseq_t wb_err; /* For jbd2 error tracking */
|
||||
};
|
||||
|
||||
/* block_device - minimal stub */
|
||||
struct block_device {
|
||||
struct address_space *bd_mapping;
|
||||
void *bd_disk;
|
||||
};
|
||||
|
||||
/* errseq functions - stubs */
|
||||
static inline int errseq_check(errseq_t *eseq, errseq_t since)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int errseq_check_and_advance(errseq_t *eseq, errseq_t *since)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* file - minimal stub */
|
||||
struct file {
|
||||
fmode_t f_mode;
|
||||
struct inode *f_inode;
|
||||
};
|
||||
|
||||
/* iattr - inode attributes for setattr */
|
||||
struct iattr {
|
||||
unsigned int ia_valid;
|
||||
umode_t ia_mode;
|
||||
uid_t ia_uid;
|
||||
gid_t ia_gid;
|
||||
loff_t ia_size;
|
||||
};
|
||||
|
||||
/* writeback_control - defined in linux/compat.h */
|
||||
|
||||
/* fsnotify - stub */
|
||||
#define fsnotify_change(d, m) do { } while (0)
|
||||
|
||||
/* inode_init_once - stub */
|
||||
static inline void inode_init_once(struct inode *inode)
|
||||
{
|
||||
}
|
||||
|
||||
/* S_ISDIR, etc. - already in linux/stat.h */
|
||||
#include <linux/stat.h>
|
||||
|
||||
#endif /* _LINUX_FS_H */
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <linux/bit_spinlock.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/crc32c.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/init.h>
|
||||
#endif
|
||||
|
||||
#define journal_oom_retry 1
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
struct task_struct {
|
||||
int pid;
|
||||
char comm[16];
|
||||
void *journal_info; /* For jbd2 */
|
||||
};
|
||||
|
||||
extern struct task_struct *current;
|
||||
|
||||
@@ -23,7 +23,7 @@ struct delayed_work {
|
||||
#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_work(work) ({ (void)(work); 0; })
|
||||
#define flush_delayed_work(work) 0
|
||||
#define queue_work(wq, work) 0
|
||||
#define queue_delayed_work(wq, work, delay) 0
|
||||
|
||||
Reference in New Issue
Block a user