blob: a8daacc7286b233aed256b8538eee4cd117c2788 [file] [log] [blame]
Vadim Yanitskiy3262f822016-09-23 01:48:59 +07001/*
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 Weltee08da972017-11-13 01:00:26 +09007 * SPDX-License-Identifier: GPL-2.0+
8 *
Vadim Yanitskiy3262f822016-09-23 01:48:59 +07009 * 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.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#include <stdint.h>
25
26#include <osmocom/core/crcgen.h>
27#include <osmocom/coding/gsm0503_parity.h>
28
Harald Weltec6636782017-06-12 14:59:37 +020029/*! \addtogroup parity
30 * @{
31 *
Neels Hofmeyr87e45502017-06-20 00:17:59 +020032 * GSM TS 05.03 parity
Harald Weltec6636782017-06-12 14:59:37 +020033 *
34 * This module contains parity/crc code definitions for the various
35 * parity/crc schemes as defined in 3GPP TS 05.03 / 45.003
Neels Hofmeyr17518fe2017-06-20 04:35:06 +020036 *
37 * \file gsm0503_parity.c */
Harald Weltec6636782017-06-12 14:59:37 +020038
Neels Hofmeyr87e45502017-06-20 00:17:59 +020039/*! GSM (SACCH) parity (FIRE code)
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070040 *
41 * g(x) = (x^23 + 1)(x^17 + x^3 + 1)
42 * = x^40 + x^26 + x^23 + x^17 + x^3 + a1
43 */
44const struct osmo_crc64gen_code gsm0503_fire_crc40 = {
45 .bits = 40,
46 .poly = 0x0004820009ULL,
47 .init = 0x0000000000ULL,
48 .remainder = 0xffffffffffULL,
49};
50
Neels Hofmeyr87e45502017-06-20 00:17:59 +020051/*! GSM PDTCH CS-2, CS-3, CS-4 parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070052 *
53 * g(x) = x^16 + x^12 + x^5 + 1
54 */
55const struct osmo_crc16gen_code gsm0503_cs234_crc16 = {
56 .bits = 16,
57 .poly = 0x1021,
58 .init = 0x0000,
59 .remainder = 0xffff,
60};
61
Neels Hofmeyr87e45502017-06-20 00:17:59 +020062/*! EDGE MCS header parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070063 *
64 */
65const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = {
66 .bits = 8,
67 .poly = 0x49,
68 .init = 0x00,
69 .remainder = 0xff,
70};
71
Neels Hofmeyr87e45502017-06-20 00:17:59 +020072/*! EDGE MCS data parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070073 *
74 */
75const struct osmo_crc16gen_code gsm0503_mcs_crc12 = {
76 .bits = 12,
77 .poly = 0x0d31,
78 .init = 0x0000,
79 .remainder = 0x0fff,
80};
81
Neels Hofmeyr87e45502017-06-20 00:17:59 +020082/*! GSM RACH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070083 *
84 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
85 */
86const struct osmo_crc8gen_code gsm0503_rach_crc6 = {
87 .bits = 6,
88 .poly = 0x2f,
89 .init = 0x00,
90 .remainder = 0x3f,
91};
92
Neels Hofmeyr87e45502017-06-20 00:17:59 +020093/*! GSM SCH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070094 *
95 * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1
96 */
97const struct osmo_crc16gen_code gsm0503_sch_crc10 = {
98 .bits = 10,
99 .poly = 0x175,
100 .init = 0x000,
101 .remainder = 0x3ff,
102};
103
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200104/*! GSM TCH FR/HR/EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700105 *
106 * g(x) = x^3 + x + 1
107 */
108const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = {
109 .bits = 3,
110 .poly = 0x3,
111 .init = 0x0,
112 .remainder = 0x7,
113};
114
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200115/*! GSM TCH EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700116 *
117 * g(x) = x^8 + x^4 + x^3 + x^2 + 1
118 */
119const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = {
120 .bits = 8,
121 .poly = 0x1d,
122 .init = 0x00,
123 .remainder = 0x00,
124};
125
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200126/*! GSM AMR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700127 *
128 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
129 */
130const struct osmo_crc8gen_code gsm0503_amr_crc6 = {
131 .bits = 6,
132 .poly = 0x2f,
133 .init = 0x00,
134 .remainder = 0x3f,
135};
Harald Weltec6636782017-06-12 14:59:37 +0200136
Philipp Maier1c46d192020-02-28 14:23:55 +0100137/*! GSM AMR parity (SID_UPDATE)
138 *
139 * g(x) = x^14 + x^13 + x^5 + x^3 + x^2 + 1
140 */
141const struct osmo_crc16gen_code gsm0503_amr_crc14 = {
142 .bits = 14,
143 .poly = 0x202d,
144 .init = 0x0000,
145 .remainder = 0x3fff,
146};
147
Harald Weltec6636782017-06-12 14:59:37 +0200148/*! @} */