// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: BL_HammingEcc.cc
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
// The above named program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License version 2 as published by the Free Software Foundation.
// The above named program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public
// License along with this work; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
// ========== Copyright Header End ============================================
/************************************************************************
** Copyright (C) 2006, Sun Microsystems, Inc.
** Sun considers its source code as an unpublished, proprietary
** trade secret and it is available only under strict license provisions.
** This copyright notice is placed here only to protect Sun in the event
** the source is deemed a published work. Disassembly, decompilation,
** or other means of reducing the object code to human readable form
** is prohibited by the license agreement under which this code is
** provided to the user or company in possession of this copy."
*************************************************************************/
#include "BL_HammingEcc.h"
#include "BL_Hamming_22_6_Synd.h"
#include "BL_Hamming_32_7_Synd.h"
#include "BL_Hamming_64_8_Synd.h"
uint64_t BL_HammingEcc::hamming_22_6_ecc_masks
[] =
uint64_t BL_HammingEcc::hamming_32_7_ecc_masks
[] =
0x2da65cb7, // check bit 6
0xfc000000, // check bit 5
0x03fff800, // check bit 4
0x03fc07f0, // check bit 3
0xe3c3c78e, // check bit 2
0x9b33366d, // check bit 1
0x56aaad5b, // check bit 0
uint64_t BL_HammingEcc::hamming_64_8_ecc_masks
[] =
0x972cd2d32da65cb7, // c7
0xfe00000000000000, // c6
0x01fffffffc000000, // c5
0x01fffe0003fff800, // c4
0x01fe01fe03fc07f0, // c3
0xf1e1e1e1e3c3c78e, // c2
0xcd9999999b33366d, // c1
0xab55555556aaad5b, // c0
#define HAMMING_22_6_ECC_MASKS (sizeof(hamming_22_6_ecc_masks)/sizeof(hamming_22_6_ecc_masks[0]))
#define HAMMING_32_7_ECC_MASKS (sizeof(hamming_32_7_ecc_masks)/sizeof(hamming_32_7_ecc_masks[0]))
#define HAMMING_64_8_ECC_MASKS (sizeof(hamming_64_8_ecc_masks)/sizeof(hamming_64_8_ecc_masks[0]))
BL_EccBits
BL_HammingEcc::calc_check_bits(BL_HammingEccTypes type
, uint64_t data
)
if (type
== BL_Hamming_22_6
)
return calc_checks(HAMMING_22_6_ECC_MASKS
,hamming_22_6_ecc_masks
,data
);
else if (type
== BL_Hamming_32_7
)
return calc_checks(HAMMING_32_7_ECC_MASKS
,hamming_32_7_ecc_masks
,data
);
else if (type
== BL_Hamming_64_8
)
return calc_checks(HAMMING_64_8_ECC_MASKS
,hamming_64_8_ecc_masks
,data
);
// This method generates an 22/6 hamming syndrome and returns the
// value Syndrome is the result of XOR'ing the calculated ecc value
BL_Hamming_22_6_Synd
BL_HammingEcc::get_hamming_22_6_synd(uint32_t data
,
BL_HammingEcc::calc_check_bits(BL_Hamming_22_6
, data
).get();
uint32_t syndrome
= calc_ecc_val
^ stored_ecc_val
;
syndrome
= BL_BaseSynd::maskedSyndrome(syndrome
, data
, stored_ecc_val
, 5);
return BL_Hamming_22_6_Synd(syndrome
);
// This method generates a 32/7 syndrome and returns the value
// Syndrome is the result of XOR'ing the calculated ecc value and
BL_Hamming_32_7_Synd
BL_HammingEcc::get_hamming_32_7_synd(uint32_t data
,
BL_HammingEcc::calc_check_bits(BL_Hamming_32_7
, data
).get();
uint32_t syndrome
= calc_ecc_val
^ stored_ecc_val
;
syndrome
= BL_BaseSynd::maskedSyndrome(syndrome
, data
, stored_ecc_val
, 6);
return BL_Hamming_32_7_Synd(syndrome
);
// This method generates an 64/8 syndrome and returns the value
// Syndrome is the result of XOR'ing the calculated ecc value and
BL_Hamming_64_8_Synd
BL_HammingEcc::get_hamming_64_8_synd(uint64_t data
,
BL_HammingEcc::calc_check_bits(BL_Hamming_64_8
, data
).get();
uint64_t syndrome
= calc_ecc_val
^ stored_ecc_val
;
syndrome
= BL_BaseSynd::maskedSyndrome(syndrome
, data
, stored_ecc_val
, 7);
return BL_Hamming_64_8_Synd(syndrome
);