lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef __LIBCPNV_H
|
| 2 | #define __LIBCPNV_H
|
| 3 |
|
| 4 |
|
| 5 | enum FS_PARTITION_NO {
|
| 6 | FS_IMAGEFS,
|
| 7 | FS_RESOURCEFS,
|
| 8 | FS_NVROFS,
|
| 9 | FS_PARTITION_NO_MAX
|
| 10 | };
|
| 11 |
|
| 12 | #define SYSCALL_jffs2_quick_gc_wait_done 385
|
| 13 |
|
| 14 | #define CPNV_OK (0)
|
| 15 | #define CPNV_ERROR (0xFFFFFFFF)
|
| 16 |
|
| 17 | /** |
| 18 | * @brief 写CP侧NVRW区NV项 |
| 19 | * @param NvItemID 入参,NV项ID |
| 20 | * @param NvItemData 入参,写入NV项数据缓冲区 |
| 21 | * @param NvItemLen 入参,写入NV项数据缓冲区长度 |
| 22 | * @return CPNV_OK 成功,CPNV_ERROR 失败 |
| 23 | * @retval |
| 24 | * @note |
| 25 | * @warning 数据先写到内存,定时刷新到flash。如果要求及时刷新到flash需要再调用cpnv_NvramFlush刷新 |
| 26 | */ |
| 27 | extern unsigned int cpnv_NvItemWrite(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);
|
| 28 |
|
| 29 | /** |
| 30 | * @brief 读取CP侧NVRW区NV项 |
| 31 | * @param NvItemID 入参,NV项ID |
| 32 | * @param NvItemData 出参,读取NV项数据缓冲区 |
| 33 | * @param NvItemLen 入参,读取NV项数据缓冲区长度 |
| 34 | * @return CPNV_OK 成功,CPNV_ERROR 失败 |
| 35 | * @retval |
| 36 | * @note |
| 37 | * @warning |
| 38 | */ |
| 39 | extern unsigned int cpnv_NvItemRead(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);
|
| 40 |
|
| 41 | /** |
| 42 | * @brief 刷新NVRW区缓存数据到flash |
| 43 | * @param 无 |
| 44 | * @return CPNV_OK 成功,CPNV_ERROR 失败 |
| 45 | * @retval |
| 46 | * @note |
| 47 | * @warning |
| 48 | */ |
| 49 | extern unsigned int cpnv_NvramFlush(void);
|
| 50 |
|
| 51 | /** |
| 52 | * @brief 写CP侧NVFAC区NV项 |
| 53 | * @param NvItemID 入参,NV项ID |
| 54 | * @param NvItemData 入参,写入NV项数据缓冲区 |
| 55 | * @param NvItemLen 入参,写入NV项数据缓冲区长度 |
| 56 | * @return 无 |
| 57 | * @retval |
| 58 | * @note |
| 59 | * @warning |
| 60 | */ |
| 61 | void cpnv_NvItemWriteFactory(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen); |
| 62 |
|
| 63 | /** |
| 64 | * @brief 写CP侧NVRO区NV项 |
| 65 | * @param NvItemID 入参,NV项ID |
| 66 | * @param NvItemData 入参,写入NV项数据缓冲区 |
| 67 | * @param NvItemLen 入参,写入NV项数据缓冲区长度 |
| 68 | * @return CPNV_OK 成功,CPNV_ERROR 失败 |
| 69 | * @retval |
| 70 | * @note 调用之前要用cpnv_ChangeNvRoAttr设置为可写 |
| 71 | * @warning 调用后要用cpnv_ChangeNvRoAttr设置为只读,保护NVRO区数据 |
| 72 | */ |
| 73 | unsigned int cpnv_NvItemWriteNvro(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen); |
| 74 | |
| 75 | /** |
| 76 | * @brief NV恢复出厂数据 |
| 77 | * @param 无 |
| 78 | * @return CPNV_OK 成功,CPNV_ERROR 失败 |
| 79 | * @retval |
| 80 | * @note |
| 81 | * @warning |
| 82 | */ |
| 83 | unsigned int cpnv_ResetNVFactory(void); |
| 84 | |
| 85 | /** |
| 86 | * @brief 设置NVRO区读写属性
|
| 87 | * @param writable为0设置NVRO区为只读,其他值设置为可写
|
| 88 | * @return CPNV_OK 成功,CPNV_ERROR 失败
|
| 89 | * @retval
|
| 90 | * @note
|
| 91 | * @warning
|
| 92 | */
|
| 93 | unsigned int cpnv_ChangeNvRoAttr(int writable);
|
| 94 |
|
| 95 | /**
|
| 96 | * @brief 设置imagefs/resource/nvrofs分区可写属性 |
| 97 | * @param partition_no取值自enum FS_PARTITION_NO;writable为0设置为只读,其他值设置为可写 |
| 98 | * @return CPNV_OK 成功,CPNV_ERROR 失败 |
| 99 | * @retval |
| 100 | * @note |
| 101 | * @warning |
| 102 | */ |
| 103 | unsigned int cpnv_ChangeFsPartitionAttr(int partition_no, int writable); |
| 104 | |
| 105 | /**
|
| 106 | * @brief 等待imagefs/resource/nvrofs 文件系统垃圾回收,partition_no取值自enum FS_PARTITION_NO
|
| 107 | * @param partition_no取值自enum FS_PARTITION_NO
|
| 108 | * @return CPNV_OK 成功,CPNV_ERROR 失败
|
| 109 | * @retval
|
| 110 | * @note
|
| 111 | * @warning 只能在整个该分区文件系统都写完毕后调用才有意义
|
| 112 | */
|
| 113 | unsigned int cpnv_FsGcWait(int partition_no);
|
| 114 |
|
| 115 | #endif // __LIBCPNV_H
|