Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu> |
| 3 | * (C) 2016 by Tom Tsou <tom.tsou@ettus.com> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | */ |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | |
| 24 | #include <osmocom/core/crcgen.h> |
| 25 | #include <osmocom/coding/gsm0503_parity.h> |
| 26 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 27 | /*! \addtogroup parity |
| 28 | * @{ |
| 29 | * |
| 30 | * \brief GSM TS 05.03 parity |
| 31 | * |
| 32 | * This module contains parity/crc code definitions for the various |
| 33 | * parity/crc schemes as defined in 3GPP TS 05.03 / 45.003 |
| 34 | */ |
| 35 | |
| 36 | /*! \file gsm0503_parity.c */ |
| 37 | |
| 38 | /*! \brief GSM (SACCH) parity (FIRE code) |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 39 | * |
| 40 | * g(x) = (x^23 + 1)(x^17 + x^3 + 1) |
| 41 | * = x^40 + x^26 + x^23 + x^17 + x^3 + a1 |
| 42 | */ |
| 43 | const struct osmo_crc64gen_code gsm0503_fire_crc40 = { |
| 44 | .bits = 40, |
| 45 | .poly = 0x0004820009ULL, |
| 46 | .init = 0x0000000000ULL, |
| 47 | .remainder = 0xffffffffffULL, |
| 48 | }; |
| 49 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 50 | /*! \brief GSM PDTCH CS-2, CS-3, CS-4 parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 51 | * |
| 52 | * g(x) = x^16 + x^12 + x^5 + 1 |
| 53 | */ |
| 54 | const struct osmo_crc16gen_code gsm0503_cs234_crc16 = { |
| 55 | .bits = 16, |
| 56 | .poly = 0x1021, |
| 57 | .init = 0x0000, |
| 58 | .remainder = 0xffff, |
| 59 | }; |
| 60 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 61 | /*! \brief EDGE MCS header parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 62 | * |
| 63 | */ |
| 64 | const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = { |
| 65 | .bits = 8, |
| 66 | .poly = 0x49, |
| 67 | .init = 0x00, |
| 68 | .remainder = 0xff, |
| 69 | }; |
| 70 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 71 | /*! \brief EDGE MCS data parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 72 | * |
| 73 | */ |
| 74 | const struct osmo_crc16gen_code gsm0503_mcs_crc12 = { |
| 75 | .bits = 12, |
| 76 | .poly = 0x0d31, |
| 77 | .init = 0x0000, |
| 78 | .remainder = 0x0fff, |
| 79 | }; |
| 80 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 81 | /*! \brief GSM RACH parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 82 | * |
| 83 | * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1 |
| 84 | */ |
| 85 | const struct osmo_crc8gen_code gsm0503_rach_crc6 = { |
| 86 | .bits = 6, |
| 87 | .poly = 0x2f, |
| 88 | .init = 0x00, |
| 89 | .remainder = 0x3f, |
| 90 | }; |
| 91 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 92 | /*! \brief GSM SCH parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 93 | * |
| 94 | * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1 |
| 95 | */ |
| 96 | const struct osmo_crc16gen_code gsm0503_sch_crc10 = { |
| 97 | .bits = 10, |
| 98 | .poly = 0x175, |
| 99 | .init = 0x000, |
| 100 | .remainder = 0x3ff, |
| 101 | }; |
| 102 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 103 | /*! \brief GSM TCH FR/HR/EFR parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 104 | * |
| 105 | * g(x) = x^3 + x + 1 |
| 106 | */ |
| 107 | const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = { |
| 108 | .bits = 3, |
| 109 | .poly = 0x3, |
| 110 | .init = 0x0, |
| 111 | .remainder = 0x7, |
| 112 | }; |
| 113 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 114 | /*! \brief GSM TCH EFR parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 115 | * |
| 116 | * g(x) = x^8 + x^4 + x^3 + x^2 + 1 |
| 117 | */ |
| 118 | const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = { |
| 119 | .bits = 8, |
| 120 | .poly = 0x1d, |
| 121 | .init = 0x00, |
| 122 | .remainder = 0x00, |
| 123 | }; |
| 124 | |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 125 | /*! \brief GSM AMR parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 126 | * |
| 127 | * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1 |
| 128 | */ |
| 129 | const struct osmo_crc8gen_code gsm0503_amr_crc6 = { |
| 130 | .bits = 6, |
| 131 | .poly = 0x2f, |
| 132 | .init = 0x00, |
| 133 | .remainder = 0x3f, |
| 134 | }; |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 135 | |
| 136 | /*! @} */ |