yportenv.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
  3. *
  4. * Copyright (C) 2002-2007 Aleph One Ltd.
  5. * for Toby Churchill Ltd and Brightstar Engineering
  6. *
  7. * Created by Charles Manning <charles@aleph1.co.uk>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License version 2.1 as
  11. * published by the Free Software Foundation.
  12. *
  13. * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  14. */
  15. #ifndef __YPORTENV_H__
  16. #define __YPORTENV_H__
  17. /* XXX U-BOOT XXX */
  18. #ifndef CONFIG_YAFFS_DIRECT
  19. #define CONFIG_YAFFS_DIRECT
  20. #endif
  21. #if defined CONFIG_YAFFS_WINCE
  22. #include "ywinceenv.h"
  23. /* XXX U-BOOT XXX */
  24. #elif 0 /* defined __KERNEL__ */
  25. #include "moduleconfig.h"
  26. /* Linux kernel */
  27. #include <linux/version.h>
  28. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
  29. #include <linux/config.h>
  30. #endif
  31. #include <linux/kernel.h>
  32. #include <linux/mm.h>
  33. #include <linux/sched.h>
  34. #include <linux/string.h>
  35. #include <linux/slab.h>
  36. #include <linux/vmalloc.h>
  37. #define YCHAR char
  38. #define YUCHAR unsigned char
  39. #define _Y(x) x
  40. #define yaffs_strcpy(a,b) strcpy(a,b)
  41. #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
  42. #define yaffs_strncmp(a,b,c) strncmp(a,b,c)
  43. #define yaffs_strlen(s) strlen(s)
  44. #define yaffs_sprintf sprintf
  45. #define yaffs_toupper(a) toupper(a)
  46. #define Y_INLINE inline
  47. #define YAFFS_LOSTNFOUND_NAME "lost+found"
  48. #define YAFFS_LOSTNFOUND_PREFIX "obj"
  49. /* #define YPRINTF(x) printk x */
  50. #define YMALLOC(x) kmalloc(x,GFP_KERNEL)
  51. #define YFREE(x) kfree(x)
  52. #define YMALLOC_ALT(x) vmalloc(x)
  53. #define YFREE_ALT(x) vfree(x)
  54. #define YMALLOC_DMA(x) YMALLOC(x)
  55. // KR - added for use in scan so processes aren't blocked indefinitely.
  56. #define YYIELD() schedule()
  57. #define YAFFS_ROOT_MODE 0666
  58. #define YAFFS_LOSTNFOUND_MODE 0666
  59. #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
  60. #define Y_CURRENT_TIME CURRENT_TIME.tv_sec
  61. #define Y_TIME_CONVERT(x) (x).tv_sec
  62. #else
  63. #define Y_CURRENT_TIME CURRENT_TIME
  64. #define Y_TIME_CONVERT(x) (x)
  65. #endif
  66. #define yaffs_SumCompare(x,y) ((x) == (y))
  67. #define yaffs_strcmp(a,b) strcmp(a,b)
  68. #define TENDSTR "\n"
  69. #define TSTR(x) KERN_WARNING x
  70. #define TOUT(p) printk p
  71. #define yaffs_trace(mask, fmt, args...) \
  72. do { if ((mask) & (yaffs_traceMask|YAFFS_TRACE_ERROR)) \
  73. printk(KERN_WARNING "yaffs: " fmt, ## args); \
  74. } while (0)
  75. #define compile_time_assertion(assertion) \
  76. ({ int x = __builtin_choose_expr(assertion, 0, (void)0); (void) x; })
  77. #elif defined CONFIG_YAFFS_DIRECT
  78. /* Direct interface */
  79. #include "ydirectenv.h"
  80. #elif defined CONFIG_YAFFS_UTIL
  81. /* Stuff for YAFFS utilities */
  82. #include "stdlib.h"
  83. #include "stdio.h"
  84. #include "string.h"
  85. #include "devextras.h"
  86. #define YMALLOC(x) malloc(x)
  87. #define YFREE(x) free(x)
  88. #define YMALLOC_ALT(x) malloc(x)
  89. #define YFREE_ALT(x) free(x)
  90. #define YCHAR char
  91. #define YUCHAR unsigned char
  92. #define _Y(x) x
  93. #define yaffs_strcpy(a,b) strcpy(a,b)
  94. #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
  95. #define yaffs_strlen(s) strlen(s)
  96. #define yaffs_sprintf sprintf
  97. #define yaffs_toupper(a) toupper(a)
  98. #define Y_INLINE inline
  99. /* #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) */
  100. /* #define YALERT(s) YINFO(s) */
  101. #define TENDSTR "\n"
  102. #define TSTR(x) x
  103. #define TOUT(p) printf p
  104. #define YAFFS_LOSTNFOUND_NAME "lost+found"
  105. #define YAFFS_LOSTNFOUND_PREFIX "obj"
  106. /* #define YPRINTF(x) printf x */
  107. #define YAFFS_ROOT_MODE 0666
  108. #define YAFFS_LOSTNFOUND_MODE 0666
  109. #define yaffs_SumCompare(x,y) ((x) == (y))
  110. #define yaffs_strcmp(a,b) strcmp(a,b)
  111. #else
  112. /* Should have specified a configuration type */
  113. #error Unknown configuration
  114. #endif
  115. /* see yaffs_fs.c */
  116. extern unsigned int yaffs_traceMask;
  117. extern unsigned int yaffs_wr_attempts;
  118. /*
  119. * Tracing flags.
  120. * The flags masked in YAFFS_TRACE_ALWAYS are always traced.
  121. */
  122. #define YAFFS_TRACE_OS 0x00000002
  123. #define YAFFS_TRACE_ALLOCATE 0x00000004
  124. #define YAFFS_TRACE_SCAN 0x00000008
  125. #define YAFFS_TRACE_BAD_BLOCKS 0x00000010
  126. #define YAFFS_TRACE_ERASE 0x00000020
  127. #define YAFFS_TRACE_GC 0x00000040
  128. #define YAFFS_TRACE_WRITE 0x00000080
  129. #define YAFFS_TRACE_TRACING 0x00000100
  130. #define YAFFS_TRACE_DELETION 0x00000200
  131. #define YAFFS_TRACE_BUFFERS 0x00000400
  132. #define YAFFS_TRACE_NANDACCESS 0x00000800
  133. #define YAFFS_TRACE_GC_DETAIL 0x00001000
  134. #define YAFFS_TRACE_SCAN_DEBUG 0x00002000
  135. #define YAFFS_TRACE_MTD 0x00004000
  136. #define YAFFS_TRACE_CHECKPOINT 0x00008000
  137. #define YAFFS_TRACE_VERIFY 0x00010000
  138. #define YAFFS_TRACE_VERIFY_NAND 0x00020000
  139. #define YAFFS_TRACE_VERIFY_FULL 0x00040000
  140. #define YAFFS_TRACE_VERIFY_ALL 0x000F0000
  141. #define YAFFS_TRACE_ERROR 0x40000000
  142. #define YAFFS_TRACE_BUG 0x80000000
  143. #define YAFFS_TRACE_ALWAYS 0xF0000000
  144. #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ALWAYS)) TOUT(p);} while(0)
  145. #ifndef CONFIG_YAFFS_WINCE
  146. #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
  147. #endif
  148. #endif