ubi_uboot.h 5.3 KB

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