/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* valid_srecord.c: to get and check an S-record string from a file
* (firmware image to be downloaded to the service processor)
*/
#include <stdio.h>
#include <string.h>
#include "adm.h"
static unsigned long
{
unsigned long val = 0;
while (chars--) {
if ((*s >= '0') && (*s <= '9'))
val += *s - '0';
else if ((*s >= 'a') && (*s <= 'f'))
else if ((*s >= 'A') && (*s <= 'F'))
s++;
}
return (val);
}
int
{
char *CurrentChar;
int SrecordLength;
int Sum;
return (SREC_ERR_LINE_TOO_BIG);
return (SREC_ERR_LINE_TOO_SMALL);
/* Check first two characters for validity */
return (SREC_ERR_BAD_HEADER);
/* Next check the length for validity */
return (SREC_ERR_WRONG_LENGTH);
/* Check the checksum. */
Sum = 0;
while (SrecordLength--) {
CurrentChar += 2;
}
return (SREC_ERR_BAD_CRC); /* checksum failed */
else
return (SREC_OK); /* checksum passed */
}