src/occBootLoader/bootMain.c
// Function Specification
//
//  Name: calChecksum
//
//  Description: Calculate checksum starting at given address and given size
//               bytes. Skip checksum field in the imageHdr_t while calculating
//               checksum
//
// End Function Specification
Function Specification
Name: calChecksum

Calculate checksum starting at given address and given size
bytes. Skip checksum field in the imageHdr_t while calculating
checksum

End Function Specification
Function Specification Name : calChecksum Calculate checksum starting at given address and given size bytes . Skip checksum field in the imageHdr_t while calculating checksum End Function Specification
uint32_t calChecksum(const uint32_t i_startAddr, const uint32_t i_sz, bool i_gpeFile)
{
    uint32_t l_checksum = 0;
    uint32_t l_counter = 0;
    uint8_t *l_srcPtr = (uint8_t *)(i_startAddr);
    while(l_counter < i_sz)
    {
        if( (l_counter == (uint32_t)(offsetof(imageHdr_t,checksum))) &&
            !i_gpeFile )
        {
            l_counter = ((uint32_t)(offsetof(imageHdr_t,checksum)) +
                        sizeof(G_bootImageHdr.checksum));
        }
        else if ( (l_counter == (uint32_t)(offsetof(imageHdr_t,gpe0_checksum))) &&
                  !i_gpeFile )
        {
            l_counter = ((uint32_t)(offsetof(imageHdr_t,gpe0_checksum)) +
                        sizeof(G_bootImageHdr.gpe0_checksum));
        }
        else if ( (l_counter == (uint32_t)(offsetof(imageHdr_t,gpe1_checksum))) &&
                  !i_gpeFile )
        {
            l_counter = ((uint32_t)(offsetof(imageHdr_t,gpe1_checksum)) +
                        sizeof(G_bootImageHdr.gpe1_checksum));
        }
        else
        {
            l_checksum += (*(l_srcPtr + l_counter));
            l_counter = l_counter + 1;
        }
    }
    return l_checksum;
}
uint32_t calChecksum ( const uint32_t i_startAddr , const uint32_t i_sz , bool i_gpeFile ) { uint32_t l_checksum = 0 ; uint32_t l_counter = 0 ; uint8_t * l_srcPtr = ( uint8_t * ) ( i_startAddr ) ; while ( l_counter < i_sz ) { if ( ( l_counter == ( uint32_t ) ( offsetof ( imageHdr_t , checksum ) ) ) && ! i_gpeFile ) { l_counter = ( ( uint32_t ) ( offsetof ( imageHdr_t , checksum ) ) + sizeof ( G_bootImageHdr . checksum ) ) ; } else if ( ( l_counter == ( uint32_t ) ( offsetof ( imageHdr_t , gpe0_checksum ) ) ) && ! i_gpeFile ) { l_counter = ( ( uint32_t ) ( offsetof ( imageHdr_t , gpe0_checksum ) ) + sizeof ( G_bootImageHdr . gpe0_checksum ) ) ; } else if ( ( l_counter == ( uint32_t ) ( offsetof ( imageHdr_t , gpe1_checksum ) ) ) && ! i_gpeFile ) { l_counter = ( ( uint32_t ) ( offsetof ( imageHdr_t , gpe1_checksum ) ) + sizeof ( G_bootImageHdr . gpe1_checksum ) ) ; } else { l_checksum += ( * ( l_srcPtr + l_counter ) ) ; l_counter = l_counter + 1 ; } } return l_checksum ; }
Function Specification
Name: calChecksum
Function Specification Name : calChecksum