1 /* 2 * Header file for UBI support for U-Boot 3 * 4 * Adaptation from kernel to U-Boot 5 * 6 * Copyright (C) 2005-2007 Samsung Electronics 7 * Kyungmin Park <kyungmin.park@samsung.com> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ 13 14 #ifndef __UBOOT_UBI_H 15 #define __UBOOT_UBI_H 16 17 #include <common.h> 18 #include <compiler.h> 19 #include <malloc.h> 20 #include <div64.h> 21 #include <linux/crc32.h> 22 #include <linux/types.h> 23 #include <linux/list.h> 24 #include <linux/rbtree.h> 25 #include <linux/string.h> 26 #include <linux/mtd/mtd.h> 27 #include <linux/mtd/ubi.h> 28 29 #ifdef CONFIG_CMD_ONENAND 30 #include <onenand_uboot.h> 31 #endif 32 33 #include <asm/errno.h> 34 35 #define DPRINTK(format, args...) \ 36 do { \ 37 printf("%s[%d]: " format "\n", __func__, __LINE__, ##args); \ 38 } while (0) 39 40 /* configurable */ 41 #define CONFIG_MTD_UBI_WL_THRESHOLD 4096 42 #define CONFIG_MTD_UBI_BEB_RESERVE 1 43 #define UBI_IO_DEBUG 0 44 45 /* debug options (Linux: drivers/mtd/ubi/Kconfig.debug) */ 46 #undef CONFIG_MTD_UBI_DEBUG 47 #undef CONFIG_MTD_UBI_DEBUG_PARANOID 48 #undef CONFIG_MTD_UBI_DEBUG_MSG 49 #undef CONFIG_MTD_UBI_DEBUG_MSG_EBA 50 #undef CONFIG_MTD_UBI_DEBUG_MSG_WL 51 #undef CONFIG_MTD_UBI_DEBUG_MSG_IO 52 #undef CONFIG_MTD_UBI_DEBUG_MSG_BLD 53 #define CONFIG_MTD_UBI_DEBUG_DISABLE_BGT 54 55 /* build.c */ 56 #define get_device(...) 57 #define put_device(...) 58 #define ubi_sysfs_init(...) 0 59 #define ubi_sysfs_close(...) do { } while (0) 60 static inline int is_power_of_2(unsigned long n) 61 { 62 return (n != 0 && ((n & (n - 1)) == 0)); 63 } 64 65 /* FIXME */ 66 #define MKDEV(...) 0 67 #define MAJOR(dev) 0 68 #define MINOR(dev) 0 69 70 #define alloc_chrdev_region(...) 0 71 #define unregister_chrdev_region(...) 72 73 #define class_create(...) __builtin_return_address(0) 74 #define class_create_file(...) 0 75 #define class_remove_file(...) 76 #define class_destroy(...) 77 #define misc_register(...) 0 78 #define misc_deregister(...) 79 80 /* vmt.c */ 81 #define device_register(...) 0 82 #define volume_sysfs_init(...) 0 83 #define volume_sysfs_close(...) do { } while (0) 84 85 /* kapi.c */ 86 87 /* eba.c */ 88 89 /* io.c */ 90 #define init_waitqueue_head(...) do { } while (0) 91 #define wait_event_interruptible(...) 0 92 #define wake_up_interruptible(...) do { } while (0) 93 #define print_hex_dump(...) do { } while (0) 94 #define dump_stack(...) do { } while (0) 95 96 /* wl.c */ 97 #define task_pid_nr(x) 0 98 #define set_freezable(...) do { } while (0) 99 #define try_to_freeze(...) 0 100 #define set_current_state(...) do { } while (0) 101 #define kthread_should_stop(...) 0 102 #define schedule() do { } while (0) 103 104 /* upd.c */ 105 static inline unsigned long copy_from_user(void *dest, const void *src, 106 unsigned long count) 107 { 108 memcpy((void *)dest, (void *)src, count); 109 return 0; 110 } 111 112 /* common */ 113 typedef int spinlock_t; 114 typedef int wait_queue_head_t; 115 #define spin_lock_init(...) 116 #define spin_lock(...) 117 #define spin_unlock(...) 118 119 #define mutex_init(...) 120 #define mutex_lock(...) 121 #define mutex_unlock(...) 122 123 #define init_rwsem(...) do { } while (0) 124 #define down_read(...) do { } while (0) 125 #define down_write(...) do { } while (0) 126 #define down_write_trylock(...) 1 127 #define up_read(...) do { } while (0) 128 #define up_write(...) do { } while (0) 129 130 struct kmem_cache { int i; }; 131 #define kmem_cache_create(...) 1 132 #define kmem_cache_alloc(obj, gfp) malloc(sizeof(struct ubi_wl_entry)) 133 #define kmem_cache_free(obj, size) free(size) 134 #define kmem_cache_destroy(...) 135 136 #define cond_resched() do { } while (0) 137 #define yield() do { } while (0) 138 139 #define KERN_WARNING 140 #define KERN_ERR 141 #define KERN_NOTICE 142 #define KERN_DEBUG 143 144 #define GFP_KERNEL 0 145 #define GFP_NOFS 1 146 147 #define __user 148 #define __init 149 #define __exit 150 151 #define kthread_create(...) __builtin_return_address(0) 152 #define kthread_stop(...) do { } while (0) 153 #define wake_up_process(...) do { } while (0) 154 155 #define BUS_ID_SIZE 20 156 157 struct rw_semaphore { int i; }; 158 struct device { 159 struct device *parent; 160 struct class *class; 161 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 162 dev_t devt; /* dev_t, creates the sysfs "dev" */ 163 void (*release)(struct device *dev); 164 }; 165 struct mutex { int i; }; 166 struct kernel_param { int i; }; 167 168 struct cdev { 169 int owner; 170 dev_t dev; 171 }; 172 #define cdev_init(...) do { } while (0) 173 #define cdev_add(...) 0 174 #define cdev_del(...) do { } while (0) 175 176 #define MAX_ERRNO 4095 177 #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) 178 179 static inline void *ERR_PTR(long error) 180 { 181 return (void *) error; 182 } 183 184 static inline long PTR_ERR(const void *ptr) 185 { 186 return (long) ptr; 187 } 188 189 static inline long IS_ERR(const void *ptr) 190 { 191 return IS_ERR_VALUE((unsigned long)ptr); 192 } 193 194 /* module */ 195 #define THIS_MODULE 0 196 #define try_module_get(...) 1 197 #define module_put(...) do { } while (0) 198 #define module_init(...) 199 #define module_exit(...) 200 #define EXPORT_SYMBOL(...) 201 #define EXPORT_SYMBOL_GPL(...) 202 #define module_param_call(...) 203 #define MODULE_PARM_DESC(...) 204 #define MODULE_VERSION(...) 205 #define MODULE_DESCRIPTION(...) 206 #define MODULE_AUTHOR(...) 207 #define MODULE_LICENSE(...) 208 209 #ifndef __UBIFS_H__ 210 #include "../drivers/mtd/ubi/ubi.h" 211 #endif 212 213 /* functions */ 214 extern int ubi_mtd_param_parse(const char *val, struct kernel_param *kp); 215 extern int ubi_init(void); 216 extern void ubi_exit(void); 217 218 extern struct ubi_device *ubi_devices[]; 219 220 #endif 221