ubi_uboot.h 5.1 KB

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