nftl.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. *
  18. */
  19. #ifndef __MTD_NFTL_H__
  20. #define __MTD_NFTL_H__
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/blktrans.h>
  23. #include <mtd/nftl-user.h>
  24. /* these info are used in ReplUnitTable */
  25. #define BLOCK_NIL 0xffff /* last block of a chain */
  26. #define BLOCK_FREE 0xfffe /* free block */
  27. #define BLOCK_NOTEXPLORED 0xfffd /* non explored block, only used during mounting */
  28. #define BLOCK_RESERVED 0xfffc /* bios block or bad block */
  29. struct NFTLrecord {
  30. struct mtd_blktrans_dev mbd;
  31. __u16 MediaUnit, SpareMediaUnit;
  32. __u32 EraseSize;
  33. struct NFTLMediaHeader MediaHdr;
  34. int usecount;
  35. unsigned char heads;
  36. unsigned char sectors;
  37. unsigned short cylinders;
  38. __u16 numvunits;
  39. __u16 lastEUN; /* should be suppressed */
  40. __u16 numfreeEUNs;
  41. __u16 LastFreeEUN; /* To speed up finding a free EUN */
  42. int head,sect,cyl;
  43. __u16 *EUNtable; /* [numvunits]: First EUN for each virtual unit */
  44. __u16 *ReplUnitTable; /* [numEUNs]: ReplUnitNumber for each */
  45. unsigned int nb_blocks; /* number of physical blocks */
  46. unsigned int nb_boot_blocks; /* number of blocks used by the bios */
  47. struct erase_info instr;
  48. };
  49. int NFTL_mount(struct NFTLrecord *s);
  50. int NFTL_formatblock(struct NFTLrecord *s, int block);
  51. int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
  52. size_t *retlen, uint8_t *buf);
  53. int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
  54. size_t *retlen, uint8_t *buf);
  55. #ifndef NFTL_MAJOR
  56. #define NFTL_MAJOR 93
  57. #endif
  58. #define MAX_NFTLS 16
  59. #define MAX_SECTORS_PER_UNIT 64
  60. #define NFTL_PARTN_BITS 4
  61. #endif /* __MTD_NFTL_H__ */