/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* Start of crcmodel.c
*
*
* Author : Ross Williams (ross@guest.adelaide.edu.au.).
* Date : 3 June 1993.
* Status : Public domain.
*
* Description : This is the implementation (.c) file for the reference
* implementation of the Rocksoft^tm Model CRC Algorithm. For more
* information on the Rocksoft^tm Model CRC Algorithm, see the document
* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross
* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in
*
* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia.
*
*
*
* Implementation Notes
* --------------------
* To avoid inconsistencies, the specification of each function is not echoed
* here. See the header file for a description of these functions.
* This package is light on checking because I want to keep it short and
* simple and portable (i.e. it would be too messy to distribute my entire
* C culture (e.g. assertions package) with this package.
*
*
*/
#include "crcmodel.h"
/* The following definitions make the code more readable. */
#define LOCAL static
reflect(v, b)
/* Returns the value v with the bottom b [0,32] bits reflected. */
/* Example: reflect(0x3e23L,3) == 0x3e26 */
uint32_t v;
int b;
{
int i;
uint32_t t = v;
for (i = 0; i < b; i++) {
if (t & 1L)
v |= BITMASK((b-1)-i);
else
v &= ~BITMASK((b-1)-i);
t >>= 1;
}
return (v);
}
/* Returns a longword whose value is (2^p_cm->cm_width)-1. */
/* The trick is to do this portably (e.g. without doing <<32). */
{
}
void
{
}
void
int ch;
{
int i;
for (i = 0; i < 8; i++) {
else
}
}
void
{
while (blk_len--)
}
{
else
}
int index;
{
int i;
uint32_t r;
for (i = 0; i < 8; i++)
if (r & topbit)
else
r <<= 1;
}