blob: 74312abf0394fbbe2f7c0d151080a1aef8933acf [file] [log] [blame]
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +01001/*
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 <malloc.h>
19#include <div64.h>
20#include <linux/crc32.h>
Stefan Roese9eefe2a2009-03-19 15:35:05 +010021#include <linux/types.h>
22#include <linux/list.h>
23#include <linux/rbtree.h>
24#include <linux/string.h>
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +010025#include <linux/mtd/mtd.h>
Stefan Roese9eefe2a2009-03-19 15:35:05 +010026#include <linux/mtd/ubi.h>
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +010027
28#ifdef CONFIG_CMD_ONENAND
29#include <onenand_uboot.h>
30#endif
31
32#include <asm/errno.h>
33
34#define DPRINTK(format, args...) \
35do { \
36 printf("%s[%d]: " format "\n", __func__, __LINE__, ##args); \
37} while (0)
38
39/* configurable */
40#define CONFIG_MTD_UBI_WL_THRESHOLD 4096
41#define CONFIG_MTD_UBI_BEB_RESERVE 1
42#define UBI_IO_DEBUG 0
43
44/* debug options (Linux: drivers/mtd/ubi/Kconfig.debug) */
45#undef CONFIG_MTD_UBI_DEBUG
46#undef CONFIG_MTD_UBI_DEBUG_PARANOID
47#undef CONFIG_MTD_UBI_DEBUG_MSG
48#undef CONFIG_MTD_UBI_DEBUG_MSG_EBA
49#undef CONFIG_MTD_UBI_DEBUG_MSG_WL
50#undef CONFIG_MTD_UBI_DEBUG_MSG_IO
51#undef CONFIG_MTD_UBI_DEBUG_MSG_BLD
52#define CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
53
54/* compiler options */
55#define uninitialized_var(x) x = x
56
57/* build.c */
58#define get_device(...)
59#define put_device(...)
60#define ubi_sysfs_init(...) 0
61#define ubi_sysfs_close(...) do { } while (0)
62static inline int is_power_of_2(unsigned long n)
63{
Wolfgang Denk455ae7e2008-12-16 01:02:17 +010064 return (n != 0 && ((n & (n - 1)) == 0));
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +010065}
66
67/* FIXME */
68#define MKDEV(...) 0
69#define MAJOR(dev) 0
70#define MINOR(dev) 0
71
72#define alloc_chrdev_region(...) 0
73#define unregister_chrdev_region(...)
74
75#define class_create(...) __builtin_return_address(0)
76#define class_create_file(...) 0
77#define class_remove_file(...)
78#define class_destroy(...)
79#define misc_register(...) 0
80#define misc_deregister(...)
81
82/* vmt.c */
83#define device_register(...) 0
84#define volume_sysfs_init(...) 0
85#define volume_sysfs_close(...) do { } while (0)
86
87/* kapi.c */
88
89/* eba.c */
90
91/* io.c */
92#define init_waitqueue_head(...) do { } while (0)
93#define wait_event_interruptible(...) 0
94#define wake_up_interruptible(...) do { } while (0)
95#define print_hex_dump(...) do { } while (0)
96#define dump_stack(...) do { } while (0)
97
98/* wl.c */
99#define task_pid_nr(x) 0
100#define set_freezable(...) do { } while (0)
101#define try_to_freeze(...) 0
102#define set_current_state(...) do { } while (0)
103#define kthread_should_stop(...) 0
104#define schedule() do { } while (0)
105
106/* upd.c */
107static inline unsigned long copy_from_user(void *dest, const void *src,
108 unsigned long count)
109{
110 memcpy((void *)dest, (void *)src, count);
111 return 0;
112}
113
114/* common */
115typedef int spinlock_t;
116typedef int wait_queue_head_t;
117#define spin_lock_init(...)
118#define spin_lock(...)
119#define spin_unlock(...)
120
121#define mutex_init(...)
122#define mutex_lock(...)
123#define mutex_unlock(...)
124
125#define init_rwsem(...) do { } while (0)
126#define down_read(...) do { } while (0)
127#define down_write(...) do { } while (0)
128#define down_write_trylock(...) 0
129#define up_read(...) do { } while (0)
130#define up_write(...) do { } while (0)
131
132struct kmem_cache { int i; };
133#define kmem_cache_create(...) 1
134#define kmem_cache_alloc(obj, gfp) malloc(sizeof(struct ubi_wl_entry))
135#define kmem_cache_free(obj, size) free(size)
136#define kmem_cache_destroy(...)
137
138#define cond_resched() do { } while (0)
139#define yield() do { } while (0)
140
141#define KERN_WARNING
142#define KERN_ERR
143#define KERN_NOTICE
144#define KERN_DEBUG
145
146#define GFP_KERNEL 0
147#define GFP_NOFS 1
148
149#define __user
150#define __init
151#define __exit
152
153#define kthread_create(...) __builtin_return_address(0)
154#define kthread_stop(...) do { } while (0)
155#define wake_up_process(...) do { } while (0)
156
157#define BUS_ID_SIZE 20
158
159struct rw_semaphore { int i; };
160struct device {
161 struct device *parent;
162 struct class *class;
163 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
164 dev_t devt; /* dev_t, creates the sysfs "dev" */
165 void (*release)(struct device *dev);
166};
167struct mutex { int i; };
168struct kernel_param { int i; };
169
170struct cdev {
171 int owner;
172 dev_t dev;
173};
174#define cdev_init(...) do { } while (0)
175#define cdev_add(...) 0
176#define cdev_del(...) do { } while (0)
177
178#define MAX_ERRNO 4095
179#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
180
181static inline void *ERR_PTR(long error)
182{
183 return (void *) error;
184}
185
186static inline long PTR_ERR(const void *ptr)
187{
188 return (long) ptr;
189}
190
191static inline long IS_ERR(const void *ptr)
192{
193 return IS_ERR_VALUE((unsigned long)ptr);
194}
195
196/* Force a compilation error if condition is true */
197#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
198
199/* module */
200#define THIS_MODULE 0
Stefan Roese9eefe2a2009-03-19 15:35:05 +0100201#define try_module_get(...) 1
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +0100202#define module_put(...) do { } while (0)
203#define module_init(...)
204#define module_exit(...)
205#define EXPORT_SYMBOL(...)
206#define EXPORT_SYMBOL_GPL(...)
207#define module_param_call(...)
208#define MODULE_PARM_DESC(...)
209#define MODULE_VERSION(...)
210#define MODULE_DESCRIPTION(...)
211#define MODULE_AUTHOR(...)
212#define MODULE_LICENSE(...)
213
Stefan Roese9eefe2a2009-03-19 15:35:05 +0100214#ifndef __UBIFS_H__
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +0100215#include "../drivers/mtd/ubi/ubi.h"
Stefan Roese9eefe2a2009-03-19 15:35:05 +0100216#endif
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +0100217
218/* functions */
219extern int ubi_mtd_param_parse(const char *val, struct kernel_param *kp);
220extern int ubi_init(void);
Stefan Roese2ee951b2008-11-27 14:07:09 +0100221extern void ubi_exit(void);
Kyungmin Park7e6ee7a2008-11-19 16:32:36 +0100222
223extern struct ubi_device *ubi_devices[];
224
225#endif