/*static char *SCCSID = "@(#)rsc.c	6.1 90/11/17";*/
/*static char *SCCSID = "@(#)rsc.c      13.3 90/01/25";*/
#include <os2.h>

#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "volume.h"
#include "storage.h"
#include "tables.h"
#include "superb.h"
#include "pb_ifs.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "pr_DEBUG.h"
#include "pr_MISC.h"


#ifdef DEBUG

/*
 ***	RSC - Recompute Sector Checksums
 *
 *	We keep a 16-bit checksum for each sector in a cache block,
 *	if we're debugging.  This allows us to check later to
 *	make sure that all modified sectors got set dirty.
 *
 *	ENTRY	pbuf = pointer to buffer header 
 *
 *	EXIT	none
 *
 *      HISTORY
 *          23-Sep-1988 10:16:54 by Bill McJohn [t-billm] 
 *				brought up to date with 9/23/88 assembly code
 */

void far
RSC (pbuf)
PBUFNODE pbuf;	    /* pointer to buffer header */
{

    CHECKSUM cks;
    USHORT i;

/*    #if SPB != 4
 *	#error RSC:  SPB is not four;  RSC will not behave properly. ??????????
 *   #endif
 */

    /*  If checksumming is not enabled, return without doing anything.  */
    if ((flFastFile & FF_CHKSUM) == 0) {
	return;
    }

    for ( i = 0; i < SPB; i++) {
	    
	/*  Compute the checksum, fold it into a 16-bit quantity,
	 *  using xor, and store it in the appropriate checksum 
	 *  field.
	 */
	cks = CASfar ((PCHAR)((PSECTOR)(pbuf->pblkData) + i), SECSIZE);
	pbuf->ausCheckSum[i] = HIUSHORT(cks) ^ LOUSHORT(cks);
    }
}

#endif
