Signed-off-by: lzeng14
Reviewed-by: rsun3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11674
6f19259b-4bc3-4df7-8a09-
765794883524
/** @file\r
FFS file access utilities.\r
\r
/** @file\r
FFS file access utilities.\r
\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
)\r
{\r
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
)\r
{\r
- UINT32 Index;\r
- UINT32 HeaderLength;\r
- HeaderLength = FvHeader->HeaderLength;\r
- Ptr = (UINT16 *)FvHeader;\r
- Checksum = 0;\r
-\r
- for (Index = 0; Index < HeaderLength / sizeof (UINT16); Index++) {\r
- Checksum = (UINT16)(Checksum + Ptr[Index]);\r
- }\r
+ Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength);\r
\r
if (Checksum == 0) {\r
return TRUE;\r
\r
if (Checksum == 0) {\r
return TRUE;\r
IN EFI_FFS_FILE_HEADER *FfsHeader\r
)\r
{\r
IN EFI_FFS_FILE_HEADER *FfsHeader\r
)\r
{\r
- UINT32 Index;\r
- UINT8 *Ptr;\r
- UINT8 HeaderChecksum;\r
-\r
- Ptr = (UINT8 *)FfsHeader;\r
- HeaderChecksum = 0;\r
- for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {\r
- HeaderChecksum = (UINT8)(HeaderChecksum + Ptr[Index]);\r
- }\r
+ UINT8 HeaderChecksum;\r
+ HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));\r
HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);\r
\r
if (HeaderChecksum == 0) {\r
HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);\r
\r
if (HeaderChecksum == 0) {\r