-
-
-/* *********************************************************************
- * kerSysImageTagGet()
- * Get the image tag
- * Input parameters:
- * none
- * Return value:
- * point to tag -- Found
- * NULL -- failed
- ********************************************************************* */
-PFILE_TAG kerSysImageTagGet(void)
-{
- int i;
- int totalBlks = flash_get_numsectors();
- UINT32 crc;
- unsigned char *sectAddr;
- PFILE_TAG pTag;
-
-#if defined(DEBUG_FLASH)
- printk("totalblks in tagGet=%d\n", totalBlks);
-#endif
-
- // start from 2nd blk, assume 1st one is always CFE
- for (i = 1; i < totalBlks; i++)
- {
- sectAddr = flash_get_memptr((byte) i);
- crc = CRC32_INIT_VALUE;
- crc = getCrc32(sectAddr, (UINT32)TAG_LEN-TOKEN_LEN, crc);
- pTag = (PFILE_TAG) sectAddr;
-
-#if defined(DEBUG_FLASH)
- printk("Check Tag crc on blk [%d]\n", i);
-#endif
-
- if (crc == (UINT32)(*(UINT32*)(pTag->tagValidationToken)))
- return pTag;
- }
-
- return (PFILE_TAG) NULL;
-}
-