ubi_uboot.h 5.3 KB

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