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