blob: ef71d3514feefa97665ed56f02e832756bf23048 [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.
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070018 */
19
20#include <stdint.h>
21
22#include <osmocom/core/crcgen.h>
23#include <osmocom/coding/gsm0503_parity.h>
24
Harald Weltec6636782017-06-12 14:59:37 +020025/*! \addtogroup parity
26 * @{
27 *
Neels Hofmeyr87e45502017-06-20 00:17:59 +020028 * GSM TS 05.03 parity
Harald Weltec6636782017-06-12 14:59:37 +020029 *
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 Hofmeyr17518fe2017-06-20 04:35:06 +020032 *
33 * \file gsm0503_parity.c */
Harald Weltec6636782017-06-12 14:59:37 +020034
Neels Hofmeyr87e45502017-06-20 00:17:59 +020035/*! GSM (SACCH) parity (FIRE code)
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070036 *
37 * g(x) = (x^23 + 1)(x^17 + x^3 + 1)
38 * = x^40 + x^26 + x^23 + x^17 + x^3 + a1
39 */
40const struct osmo_crc64gen_code gsm0503_fire_crc40 = {
41 .bits = 40,
42 .poly = 0x0004820009ULL,
43 .init = 0x0000000000ULL,
44 .remainder = 0xffffffffffULL,
45};
46
Neels Hofmeyr87e45502017-06-20 00:17:59 +020047/*! GSM PDTCH CS-2, CS-3, CS-4 parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070048 *
49 * g(x) = x^16 + x^12 + x^5 + 1
50 */
51const struct osmo_crc16gen_code gsm0503_cs234_crc16 = {
52 .bits = 16,
53 .poly = 0x1021,
54 .init = 0x0000,
55 .remainder = 0xffff,
56};
57
Neels Hofmeyr87e45502017-06-20 00:17:59 +020058/*! EDGE MCS header parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070059 *
60 */
61const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = {
62 .bits = 8,
63 .poly = 0x49,
64 .init = 0x00,
65 .remainder = 0xff,
66};
67
Neels Hofmeyr87e45502017-06-20 00:17:59 +020068/*! EDGE MCS data parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070069 *
70 */
71const struct osmo_crc16gen_code gsm0503_mcs_crc12 = {
72 .bits = 12,
73 .poly = 0x0d31,
74 .init = 0x0000,
75 .remainder = 0x0fff,
76};
77
Neels Hofmeyr87e45502017-06-20 00:17:59 +020078/*! GSM RACH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070079 *
80 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
81 */
82const struct osmo_crc8gen_code gsm0503_rach_crc6 = {
83 .bits = 6,
84 .poly = 0x2f,
85 .init = 0x00,
86 .remainder = 0x3f,
87};
88
Neels Hofmeyr87e45502017-06-20 00:17:59 +020089/*! GSM SCH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070090 *
91 * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1
92 */
93const struct osmo_crc16gen_code gsm0503_sch_crc10 = {
94 .bits = 10,
95 .poly = 0x175,
96 .init = 0x000,
97 .remainder = 0x3ff,
98};
99
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200100/*! GSM TCH FR/HR/EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700101 *
102 * g(x) = x^3 + x + 1
103 */
104const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = {
105 .bits = 3,
106 .poly = 0x3,
107 .init = 0x0,
108 .remainder = 0x7,
109};
110
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200111/*! GSM TCH EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700112 *
113 * g(x) = x^8 + x^4 + x^3 + x^2 + 1
114 */
115const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = {
116 .bits = 8,
117 .poly = 0x1d,
118 .init = 0x00,
119 .remainder = 0x00,
120};
121
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200122/*! GSM AMR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700123 *
124 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
125 */
126const struct osmo_crc8gen_code gsm0503_amr_crc6 = {
127 .bits = 6,
128 .poly = 0x2f,
129 .init = 0x00,
130 .remainder = 0x3f,
131};
Harald Weltec6636782017-06-12 14:59:37 +0200132
Philipp Maier1c46d192020-02-28 14:23:55 +0100133/*! GSM AMR parity (SID_UPDATE)
134 *
135 * g(x) = x^14 + x^13 + x^5 + x^3 + x^2 + 1
136 */
137const struct osmo_crc16gen_code gsm0503_amr_crc14 = {
138 .bits = 14,
139 .poly = 0x202d,
140 .init = 0x0000,
141 .remainder = 0x3fff,
142};
143
Harald Weltec6636782017-06-12 14:59:37 +0200144/*! @} */