123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- /*
- */
- #ifndef __SISSPI_SFS_H
- #define __SISSPI_SFS_H
- #ifndef __ASSEMBLY__ //force skip this (8051 & boot asm)
- #include "drv_spi_flashalloc_external.h"
- #endif
- #ifdef CONFIG_SPI_SFS
- #if (CONFIG_SPI_SIMFS_FLASHSIZE == 2048) //(2048*1024)
- #define SPI_SIMFS_FLASHSIZE (2048*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
- #define C8051_SFS_SIZE 20H //0xbc600000 for 8M
- #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 1024) //(1024*1024)
- #define SPI_SIMFS_FLASHSIZE (1024*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
- #define C8051_SFS_SIZE 10H //0xbc700000 for 8M
- #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 256) //(256*1024)
- #define SPI_SIMFS_FLASHSIZE (256*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
- #define C8051_SFS_SIZE 04H //0xbc3c0000 for 4M
- #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 128) //(128*1024)
- #define SPI_SIMFS_FLASHSIZE (128*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
- #define C8051_SFS_SIZE 02H //0xbc3e0000 for 4M
- #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 64) //(64*1024)
- #define SPI_SIMFS_FLASHSIZE (64*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
- #define C8051_SFS_SIZE 01H //0xbc1f0000 for 2M
- #elif (CONFIG_SPI_SIMFS_FLASHSIZE == 32) //(32*1024)
- #define SPI_SIMFS_FLASHSIZE (32*1024)//(576*1024) /* use Logo(part2) + Backup RRT */
- #define C8051_SFS_SIZE 01H
- #endif
- #define SPI_SIMFS_FLASHADDR (0xbc000000+(CONFIG_CODE_FLASH_SIZE*1024)-(CONFIG_SPI_SIMFS_FLASHSIZE*1024))
- #if (CONFIG_CODE_FLASH_SIZE == 16384)
- #define C8051_SFS_ADDR2_END 000H //0xbd000000
- #elif (CONFIG_CODE_FLASH_SIZE == 8192)
- #define C8051_SFS_ADDR2_END 80H //0xbc800000
- #elif (CONFIG_CODE_FLASH_SIZE == 4096)
- #define C8051_SFS_ADDR2_END 40H //0xbc400000
- #elif (CONFIG_CODE_FLASH_SIZE == 2048)
- #define C8051_SFS_ADDR2_END 20H //0xbc200000
- #endif
- /* keys fix address setting */
- #ifdef CONFIG_AUTO_WB
- #ifdef CONFIG_FLASH_KEYSTORAGE_ALIGNMENT_4K
- #define EDID_RELATEADDR (-0x7000)
- #define EDID_SIZE 0x1000-FLASH_HEAD_SIZE//-header
- #define WBDATA_SIZE 0x2000-FLASH_HEAD_SIZE //-header
- #define HDCPKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
- #define HDCP2XKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
- #define CIKEY_SIZE 0x2850
- #else
- #define EDID_RELATEADDR (-0x4000)
- #define EDID_SIZE 0x380
- #define WBDATA_SIZE 0xd2
- #define HDCPKEY_SIZE 0x280
- #define HDCP2XKEY_SIZE 0x1000
- #define CIKEY_SIZE 0x2850 //12032
- #endif
- #else
- #ifdef CONFIG_FLASH_KEYSTORAGE_ALIGNMENT_4K
- #define EDID_RELATEADDR (-0x5000)
- #define EDID_SIZE 0x1000-FLASH_HEAD_SIZE//-header
- #define HDCPKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
- #define HDCP2XKEY_SIZE 0x1000-FLASH_HEAD_SIZE //-header
- #define CIKEY_SIZE 0x2850
- #else
- #define EDID_RELATEADDR (-0x3000)
- #define EDID_SIZE 0x380
- #define HDCPKEY_SIZE 0x280
- #define HDCP2XKEY_SIZE 0x1000
- #define CIKEY_SIZE 0x2850 //12032
- #endif
- #endif
- #define C_EDID_START (CONFIG_FLASH_KEYSTORAGE_END_OFFSET + EDID_RELATEADDR)
- #define C_EDID_END (CONFIG_FLASH_KEYSTORAGE_END_OFFSET + EDID_RELATEADDR + EDID_SIZE + FLASH_HEAD_SIZE)
- #ifdef CONFIG_AUTO_WB
- #define C_WBDATA_START (C_EDID_END)
- #define C_WBDATA_END (C_WBDATA_START + WBDATA_SIZE + FLASH_HEAD_SIZE)
- #define C_HDCP_START (C_WBDATA_END)
- #else
- #define C_HDCP_START (C_EDID_END)
- #endif
- #define C_HDCP_END (C_HDCP_START + HDCPKEY_SIZE + FLASH_HEAD_SIZE)
- #define C_CIKEY_START (C_HDCP_END)
- #define C_CIKEY_END (C_CIKEY_START + CIKEY_SIZE + FLASH_HEAD_SIZE)
- #define C_HDCP2X_START (C_CIKEY_END)
- #define C_HDCP2X_END (C_HDCP2X_START+ HDCP2XKEY_SIZE + FLASH_HEAD_SIZE)
- #ifndef __ASSEMBLY__ //force skip this (8051 & boot asm)
- typedef struct _oob_st {
- unsigned char id;
- unsigned char sn;
- unsigned char offset;
- unsigned char len;
- unsigned int Magic;
- }oob_st;
- #define SFS_StartOffset SPI_SIMFS_FLASHADDR
- #define SFS_Size SPI_SIMFS_FLASHSIZE
- #define SFS_block_size (4096)
- #define SFS_page_size 2048//4096
- #define SFS_data_size (SFS_page_size - sizeof(oob_st))
- #define SFS_pages_per_blk (SFS_block_size/SFS_page_size)
- #define SFS_Total_Blks (SFS_Size/SFS_block_size)
- #define SFS_PageBitMapSize (SFS_pages_per_blk/8+1) //4096/1024 = 4, 4/8 =0, hmm let us +1
- #define SFS_MagicNum 0x9a190000
- #define SFS_BackupMagicNum 0xda190000
- #define SFS_SecondNum 0xb8100000
- #define SFS_EncryptMark 0xdb0baaa5 //compute from decrypt
- #define SPI_DMA_MINSIZE 256
- typedef enum {
- _IS_NOUSE = 0,
- _IS_MAJOR = 1,
- _IS_BACKUP = 2,
- }page_status;
- extern bool sfs_fwrite(unsigned short objid, void* addr, int size, unsigned char compressed);
- extern bool sfs_fread(unsigned short objid, void *addr, int size, unsigned char compressed);
- extern int sfs_GetFileSize(unsigned short objid);
- #ifdef CONFIG_SFS_BACKUP_EN
- extern int sfs_GetObjFileSize(int id, page_status page_stat);
- #else
- extern int sfs_GetObjFileSize(int id);
- #endif
- extern int LzDecode(void *in, void *out, int size);
- extern int LzEncode(void *in, void *out, int size);
- //bool sfs_delete_file(unsigned short id);
- #endif
- #endif
- #endif //__SISSPI_SFS_H
|