yportenv.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #if defined CONFIG_YAFFS_WINCE
  18. #include "ywinceenv.h"
  19. #elif defined __KERNEL__
  20. #include "moduleconfig.h"
  21. /* Linux kernel */
  22. #include <linux/version.h>
  23. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
  24. #include <linux/config.h>
  25. #endif
  26. #include <linux/kernel.h>
  27. #include <linux/mm.h>
  28. #include <linux/string.h>
  29. #include <linux/slab.h>
  30. #include <linux/vmalloc.h>
  31. #define YCHAR char
  32. #define YUCHAR unsigned char
  33. #define _Y(x) x
  34. #define yaffs_strcpy(a,b) strcpy(a,b)
  35. #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
  36. #define yaffs_strncmp(a,b,c) strncmp(a,b,c)
  37. #define yaffs_strlen(s) strlen(s)
  38. #define yaffs_sprintf sprintf
  39. #define yaffs_toupper(a) toupper(a)
  40. #define Y_INLINE inline
  41. #define YAFFS_LOSTNFOUND_NAME "lost+found"
  42. #define YAFFS_LOSTNFOUND_PREFIX "obj"
  43. /* #define YPRINTF(x) printk x */
  44. #define YMALLOC(x) kmalloc(x,GFP_KERNEL)
  45. #define YFREE(x) kfree(x)
  46. #define YMALLOC_ALT(x) vmalloc(x)
  47. #define YFREE_ALT(x) vfree(x)
  48. #define YMALLOC_DMA(x) YMALLOC(x)
  49. // KR - added for use in scan so processes aren't blocked indefinitely.
  50. #define YYIELD() schedule()
  51. #define YAFFS_ROOT_MODE 0666
  52. #define YAFFS_LOSTNFOUND_MODE 0666
  53. #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
  54. #define Y_CURRENT_TIME CURRENT_TIME.tv_sec
  55. #define Y_TIME_CONVERT(x) (x).tv_sec
  56. #else
  57. #define Y_CURRENT_TIME CURRENT_TIME
  58. #define Y_TIME_CONVERT(x) (x)
  59. #endif
  60. #define yaffs_SumCompare(x,y) ((x) == (y))
  61. #define yaffs_strcmp(a,b) strcmp(a,b)
  62. #define TENDSTR "\n"
  63. #define TSTR(x) KERN_WARNING x
  64. #define TOUT(p) printk p
  65. #elif defined CONFIG_YAFFS_DIRECT
  66. /* Direct interface */
  67. #include "ydirectenv.h"
  68. #elif defined CONFIG_YAFFS_UTIL
  69. /* Stuff for YAFFS utilities */
  70. #include "stdlib.h"
  71. #include "stdio.h"
  72. #include "string.h"
  73. #include "devextras.h"
  74. #define YMALLOC(x) malloc(x)
  75. #define YFREE(x) free(x)
  76. #define YMALLOC_ALT(x) malloc(x)
  77. #define YFREE_ALT(x) free(x)
  78. #define YCHAR char
  79. #define YUCHAR unsigned char
  80. #define _Y(x) x
  81. #define yaffs_strcpy(a,b) strcpy(a,b)
  82. #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
  83. #define yaffs_strlen(s) strlen(s)
  84. #define yaffs_sprintf sprintf
  85. #define yaffs_toupper(a) toupper(a)
  86. #define Y_INLINE inline
  87. /* #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) */
  88. /* #define YALERT(s) YINFO(s) */
  89. #define TENDSTR "\n"
  90. #define TSTR(x) x
  91. #define TOUT(p) printf p
  92. #define YAFFS_LOSTNFOUND_NAME "lost+found"
  93. #define YAFFS_LOSTNFOUND_PREFIX "obj"
  94. /* #define YPRINTF(x) printf x */
  95. #define YAFFS_ROOT_MODE 0666
  96. #define YAFFS_LOSTNFOUND_MODE 0666
  97. #define yaffs_SumCompare(x,y) ((x) == (y))
  98. #define yaffs_strcmp(a,b) strcmp(a,b)
  99. #else
  100. /* Should have specified a configuration type */
  101. #error Unknown configuration
  102. #endif
  103. extern unsigned yaffs_traceMask;
  104. /*
  105. * Tracing flags.
  106. * The flags masked in YAFFS_TRACE_ALWAYS are always traced.
  107. */
  108. #define YAFFS_TRACE_OS 0x00000002
  109. #define YAFFS_TRACE_ALLOCATE 0x00000004
  110. #define YAFFS_TRACE_SCAN 0x00000008
  111. #define YAFFS_TRACE_BAD_BLOCKS 0x00000010
  112. #define YAFFS_TRACE_ERASE 0x00000020
  113. #define YAFFS_TRACE_GC 0x00000040
  114. #define YAFFS_TRACE_WRITE 0x00000080
  115. #define YAFFS_TRACE_TRACING 0x00000100
  116. #define YAFFS_TRACE_DELETION 0x00000200
  117. #define YAFFS_TRACE_BUFFERS 0x00000400
  118. #define YAFFS_TRACE_NANDACCESS 0x00000800
  119. #define YAFFS_TRACE_GC_DETAIL 0x00001000
  120. #define YAFFS_TRACE_SCAN_DEBUG 0x00002000
  121. #define YAFFS_TRACE_MTD 0x00004000
  122. #define YAFFS_TRACE_CHECKPOINT 0x00008000
  123. #define YAFFS_TRACE_VERIFY 0x00010000
  124. #define YAFFS_TRACE_VERIFY_NAND 0x00020000
  125. #define YAFFS_TRACE_VERIFY_FULL 0x00040000
  126. #define YAFFS_TRACE_VERIFY_ALL 0x000F0000
  127. #define YAFFS_TRACE_ERROR 0x40000000
  128. #define YAFFS_TRACE_BUG 0x80000000
  129. #define YAFFS_TRACE_ALWAYS 0xF0000000
  130. #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ALWAYS)) TOUT(p);} while(0)
  131. #ifndef CONFIG_YAFFS_WINCE
  132. #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
  133. #endif
  134. #endif