drv_spi_sfs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. */
  3. #ifndef __SISSPI_SFS_H
  4. #define __SISSPI_SFS_H
  5. #ifndef __ASSEMBLY__ //force skip this (8051 & boot asm)
  6. #include "drv_spi_flashalloc_external.h"
  7. #endif
  8. #ifdef CONFIG_SPI_SFS
  9. #if (CONFIG_SPI_SIMFS_FLASHSIZE == 2048) //(2048*1024)
  10. #define SPI_SIMFS_FLASHSIZE (2048*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
  11. #define C8051_SFS_SIZE 20H //0xbc600000 for 8M
  12. #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 1024) //(1024*1024)
  13. #define SPI_SIMFS_FLASHSIZE (1024*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
  14. #define C8051_SFS_SIZE 10H //0xbc700000 for 8M
  15. #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 256) //(256*1024)
  16. #define SPI_SIMFS_FLASHSIZE (256*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
  17. #define C8051_SFS_SIZE 04H //0xbc3c0000 for 4M
  18. #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 128) //(128*1024)
  19. #define SPI_SIMFS_FLASHSIZE (128*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
  20. #define C8051_SFS_SIZE 02H //0xbc3e0000 for 4M
  21. #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 64) //(64*1024)
  22. #define SPI_SIMFS_FLASHSIZE (64*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
  23. #define C8051_SFS_SIZE 01H //0xbc1f0000 for 2M
  24. #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 32) //(32*1024)
  25. #define SPI_SIMFS_FLASHSIZE (32*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
  26. #define C8051_SFS_SIZE 01H
  27. #endif
  28. #define SPI_SIMFS_FLASHADDR (0xbc000000+(CONFIG_CODE_FLASH_SIZE*1024)-(CONFIG_SPI_SIMFS_FLASHSIZE*1024))
  29. #if (CONFIG_CODE_FLASH_SIZE == 16384)
  30. #define C8051_SFS_ADDR2_END 000H //0xbd000000
  31. #elif (CONFIG_CODE_FLASH_SIZE == 8192)
  32. #define C8051_SFS_ADDR2_END 80H //0xbc800000
  33. #elif (CONFIG_CODE_FLASH_SIZE == 4096)
  34. #define C8051_SFS_ADDR2_END 40H //0xbc400000
  35. #elif (CONFIG_CODE_FLASH_SIZE == 2048)
  36. #define C8051_SFS_ADDR2_END 20H //0xbc200000
  37. #endif
  38. /* keys fix address setting */
  39. #ifdef CONFIG_AUTO_WB
  40. #ifdef CONFIG_FLASH_KEYSTORAGE_ALIGNMENT_4K
  41. #define EDID_RELATEADDR (-0x7000)
  42. #define EDID_SIZE 0x1000-FLASH_HEAD_SIZE//-header
  43. #define WBDATA_SIZE 0x2000-FLASH_HEAD_SIZE //-header
  44. #define HDCPKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
  45. #define HDCP2XKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
  46. #define CIKEY_SIZE 0x2850
  47. #else
  48. #define EDID_RELATEADDR (-0x4000)
  49. #define EDID_SIZE 0x380
  50. #define WBDATA_SIZE 0xd2
  51. #define HDCPKEY_SIZE 0x280
  52. #define HDCP2XKEY_SIZE 0x1000
  53. #define CIKEY_SIZE 0x2850 //12032
  54. #endif
  55. #else
  56. #ifdef CONFIG_FLASH_KEYSTORAGE_ALIGNMENT_4K
  57. #define EDID_RELATEADDR (-0x5000)
  58. #define EDID_SIZE 0x1000-FLASH_HEAD_SIZE//-header
  59. #define HDCPKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
  60. #define HDCP2XKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
  61. #define CIKEY_SIZE 0x2850
  62. #else
  63. #define EDID_RELATEADDR (-0x3000)
  64. #define EDID_SIZE 0x380
  65. #define HDCPKEY_SIZE 0x280
  66. #define HDCP2XKEY_SIZE 0x1000
  67. #define CIKEY_SIZE 0x2850 //12032
  68. #endif
  69. #endif
  70. #define C_EDID_START (CONFIG_FLASH_KEYSTORAGE_END_OFFSET + EDID_RELATEADDR)
  71. #define C_EDID_END (CONFIG_FLASH_KEYSTORAGE_END_OFFSET + EDID_RELATEADDR + EDID_SIZE + FLASH_HEAD_SIZE)
  72. #ifdef CONFIG_AUTO_WB
  73. #define C_WBDATA_START (C_EDID_END)
  74. #define C_WBDATA_END (C_WBDATA_START + WBDATA_SIZE + FLASH_HEAD_SIZE)
  75. #define C_HDCP_START (C_WBDATA_END)
  76. #else
  77. #define C_HDCP_START (C_EDID_END)
  78. #endif
  79. #define C_HDCP_END (C_HDCP_START + HDCPKEY_SIZE + FLASH_HEAD_SIZE)
  80. #define C_CIKEY_START (C_HDCP_END)
  81. #define C_CIKEY_END (C_CIKEY_START + CIKEY_SIZE + FLASH_HEAD_SIZE)
  82. #define C_HDCP2X_START (C_CIKEY_END)
  83. #define C_HDCP2X_END (C_HDCP2X_START+ HDCP2XKEY_SIZE + FLASH_HEAD_SIZE)
  84. #ifndef __ASSEMBLY__ //force skip this (8051 & boot asm)
  85. typedef struct _oob_st {
  86. unsigned char id;
  87. unsigned char sn;
  88. unsigned char offset;
  89. unsigned char len;
  90. unsigned int Magic;
  91. }oob_st;
  92. #define SFS_StartOffset SPI_SIMFS_FLASHADDR
  93. #define SFS_Size SPI_SIMFS_FLASHSIZE
  94. #define SFS_block_size (4096)
  95. #define SFS_page_size 2048//4096
  96. #define SFS_data_size (SFS_page_size - sizeof(oob_st))
  97. #define SFS_pages_per_blk (SFS_block_size/SFS_page_size)
  98. #define SFS_Total_Blks (SFS_Size/SFS_block_size)
  99. #define SFS_PageBitMapSize (SFS_pages_per_blk/8+1) //4096/1024 = 4, 4/8 =0, hmm let us +1
  100. #define SFS_MagicNum 0x9a190000
  101. #define SFS_BackupMagicNum 0xda190000
  102. #define SFS_SecondNum 0xb8100000
  103. #define SFS_EncryptMark 0xdb0baaa5 //compute from decrypt
  104. #define SPI_DMA_MINSIZE 256
  105. typedef enum {
  106. _IS_NOUSE = 0,
  107. _IS_MAJOR = 1,
  108. _IS_BACKUP = 2,
  109. }page_status;
  110. extern bool sfs_fwrite(unsigned short objid, void* addr, int size, unsigned char compressed);
  111. extern bool sfs_fread(unsigned short objid, void *addr, int size, unsigned char compressed);
  112. extern int sfs_GetFileSize(unsigned short objid);
  113. #ifdef CONFIG_SFS_BACKUP_EN
  114. extern int sfs_GetObjFileSize(int id, page_status page_stat);
  115. #else
  116. extern int sfs_GetObjFileSize(int id);
  117. #endif
  118. extern int LzDecode(void *in, void *out, int size);
  119. extern int LzEncode(void *in, void *out, int size);
  120. //bool sfs_delete_file(unsigned short id);
  121. #endif
  122. #endif
  123. #endif //__SISSPI_SFS_H