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 | * |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 30 | * GSM TS 05.03 parity |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 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 |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 34 | * |
| 35 | * \file gsm0503_parity.c */ |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 36 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 37 | /*! GSM (SACCH) parity (FIRE code) |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 38 | * |
| 39 | * g(x) = (x^23 + 1)(x^17 + x^3 + 1) |
| 40 | * = x^40 + x^26 + x^23 + x^17 + x^3 + a1 |
| 41 | */ |
| 42 | const struct osmo_crc64gen_code gsm0503_fire_crc40 = { |
| 43 | .bits = 40, |
| 44 | .poly = 0x0004820009ULL, |
| 45 | .init = 0x0000000000ULL, |
| 46 | .remainder = 0xffffffffffULL, |
| 47 | }; |
| 48 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 49 | /*! GSM PDTCH CS-2, CS-3, CS-4 parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 50 | * |
| 51 | * g(x) = x^16 + x^12 + x^5 + 1 |
| 52 | */ |
| 53 | const struct osmo_crc16gen_code gsm0503_cs234_crc16 = { |
| 54 | .bits = 16, |
| 55 | .poly = 0x1021, |
| 56 | .init = 0x0000, |
| 57 | .remainder = 0xffff, |
| 58 | }; |
| 59 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 60 | /*! EDGE MCS header parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 61 | * |
| 62 | */ |
| 63 | const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = { |
| 64 | .bits = 8, |
| 65 | .poly = 0x49, |
| 66 | .init = 0x00, |
| 67 | .remainder = 0xff, |
| 68 | }; |
| 69 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 70 | /*! EDGE MCS data parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 71 | * |
| 72 | */ |
| 73 | const struct osmo_crc16gen_code gsm0503_mcs_crc12 = { |
| 74 | .bits = 12, |
| 75 | .poly = 0x0d31, |
| 76 | .init = 0x0000, |
| 77 | .remainder = 0x0fff, |
| 78 | }; |
| 79 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 80 | /*! GSM RACH parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 81 | * |
| 82 | * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1 |
| 83 | */ |
| 84 | const struct osmo_crc8gen_code gsm0503_rach_crc6 = { |
| 85 | .bits = 6, |
| 86 | .poly = 0x2f, |
| 87 | .init = 0x00, |
| 88 | .remainder = 0x3f, |
| 89 | }; |
| 90 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 91 | /*! GSM SCH parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 92 | * |
| 93 | * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1 |
| 94 | */ |
| 95 | const struct osmo_crc16gen_code gsm0503_sch_crc10 = { |
| 96 | .bits = 10, |
| 97 | .poly = 0x175, |
| 98 | .init = 0x000, |
| 99 | .remainder = 0x3ff, |
| 100 | }; |
| 101 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 102 | /*! GSM TCH FR/HR/EFR parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 103 | * |
| 104 | * g(x) = x^3 + x + 1 |
| 105 | */ |
| 106 | const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = { |
| 107 | .bits = 3, |
| 108 | .poly = 0x3, |
| 109 | .init = 0x0, |
| 110 | .remainder = 0x7, |
| 111 | }; |
| 112 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 113 | /*! GSM TCH EFR parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 114 | * |
| 115 | * g(x) = x^8 + x^4 + x^3 + x^2 + 1 |
| 116 | */ |
| 117 | const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = { |
| 118 | .bits = 8, |
| 119 | .poly = 0x1d, |
| 120 | .init = 0x00, |
| 121 | .remainder = 0x00, |
| 122 | }; |
| 123 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 124 | /*! GSM AMR parity |
Vadim Yanitskiy | 3262f82 | 2016-09-23 01:48:59 +0700 | [diff] [blame] | 125 | * |
| 126 | * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1 |
| 127 | */ |
| 128 | const struct osmo_crc8gen_code gsm0503_amr_crc6 = { |
| 129 | .bits = 6, |
| 130 | .poly = 0x2f, |
| 131 | .init = 0x00, |
| 132 | .remainder = 0x3f, |
| 133 | }; |
Harald Welte | c663678 | 2017-06-12 14:59:37 +0200 | [diff] [blame] | 134 | |
| 135 | /*! @} */ |