| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 1 | /* |
| 2 | * YAFFS: Yet another Flash File System . A NAND-flash specific file system. |
| 3 | * |
| 4 | * Copyright (C) 2002-2018 Aleph One Ltd. |
| 5 | * |
| 6 | * Created by Charles Manning <charles@aleph1.co.uk> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Lesser General Public License version 2.1 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. |
| 13 | */ |
| 14 | |
| 15 | #ifndef __YPORTENV_H__ |
| 16 | #define __YPORTENV_H__ |
| 17 | |
| 18 | /* |
| 19 | * Define the MTD version in terms of Linux Kernel versions |
| 20 | * This allows yaffs to be used independantly of the kernel |
| 21 | * as well as with it. |
| 22 | */ |
| 23 | |
| 24 | #define MTD_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) |
| 25 | |
| 26 | #ifdef YAFFS_OUT_OF_TREE |
| 27 | #include "moduleconfig.h" |
| 28 | #endif |
| 29 | |
| 30 | #include <linux/version.h> |
| 31 | #define MTD_VERSION_CODE LINUX_VERSION_CODE |
| 32 | |
| 33 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) |
| 34 | #include <linux/config.h> |
| 35 | #endif |
| 36 | #include <linux/version.h> |
| 37 | #include <linux/kernel.h> |
| 38 | #include <linux/mm.h> |
| 39 | #include <linux/sched.h> |
| 40 | #include <linux/string.h> |
| 41 | #include <linux/slab.h> |
| 42 | #include <linux/vmalloc.h> |
| 43 | #include <linux/xattr.h> |
| 44 | #include <linux/list.h> |
| 45 | #include <linux/types.h> |
| 46 | #include <linux/fs.h> |
| 47 | #include <linux/stat.h> |
| 48 | #include <linux/sort.h> |
| 49 | #include <linux/bitops.h> |
| 50 | |
| 51 | /* These type wrappings are used to support Unicode names in WinCE. */ |
| 52 | #define YCHAR char |
| 53 | #define YUCHAR unsigned char |
| 54 | #define _Y(x) x |
| 55 | |
| 56 | #define YAFFS_LOSTNFOUND_NAME "lost+found" |
| 57 | #define YAFFS_LOSTNFOUND_PREFIX "obj" |
| 58 | |
| 59 | |
| 60 | #define YAFFS_ROOT_MODE 0755 |
| 61 | #define YAFFS_LOSTNFOUND_MODE 0700 |
| 62 | |
| 63 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 64 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0)) |
| 65 | #define Y_CURRENT_TIME CURRENT_TIME.tv_sec |
| 66 | #else |
| 67 | #define Y_CURRENT_TIME current_kernel_time().tv_sec |
| 68 | #endif |
| 69 | #define Y_TIME_CONVERT(x) (x).tv_sec |
| 70 | #else |
| 71 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0)) |
| 72 | #define Y_CURRENT_TIME CURRENT_TIME |
| 73 | #else |
| 74 | #define Y_CURRENT_TIME current_kernel_time() |
| 75 | #endif |
| 76 | #define Y_TIME_CONVERT(x) (x) |
| 77 | #endif |
| 78 | |
| 79 | #define compile_time_assertion(assertion) \ |
| 80 | ({ int x = __builtin_choose_expr(assertion, 0, (void)0); (void) x; }) |
| 81 | |
| 82 | |
| 83 | #define yaffs_printf(msk, fmt, ...) \ |
| 84 | printk(KERN_DEBUG "yaffs: " fmt "\n", ##__VA_ARGS__) |
| 85 | |
| 86 | #define yaffs_trace(msk, fmt, ...) do { \ |
| 87 | if (yaffs_trace_mask & (msk)) \ |
| 88 | printk(KERN_DEBUG "yaffs: " fmt "\n", ##__VA_ARGS__); \ |
| 89 | } while (0) |
| 90 | |
| 91 | |
| 92 | #endif |