blob: b57caa3090563837db398872f5fb3dc15e148f84 [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 *
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 Weltec6636782017-06-12 14:59:37 +020027/*! \addtogroup parity
28 * @{
29 *
Neels Hofmeyr87e45502017-06-20 00:17:59 +020030 * GSM TS 05.03 parity
Harald Weltec6636782017-06-12 14:59:37 +020031 *
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 Hofmeyr17518fe2017-06-20 04:35:06 +020034 *
35 * \file gsm0503_parity.c */
Harald Weltec6636782017-06-12 14:59:37 +020036
Neels Hofmeyr87e45502017-06-20 00:17:59 +020037/*! GSM (SACCH) parity (FIRE code)
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070038 *
39 * g(x) = (x^23 + 1)(x^17 + x^3 + 1)
40 * = x^40 + x^26 + x^23 + x^17 + x^3 + a1
41 */
42const struct osmo_crc64gen_code gsm0503_fire_crc40 = {
43 .bits = 40,
44 .poly = 0x0004820009ULL,
45 .init = 0x0000000000ULL,
46 .remainder = 0xffffffffffULL,
47};
48
Neels Hofmeyr87e45502017-06-20 00:17:59 +020049/*! GSM PDTCH CS-2, CS-3, CS-4 parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070050 *
51 * g(x) = x^16 + x^12 + x^5 + 1
52 */
53const struct osmo_crc16gen_code gsm0503_cs234_crc16 = {
54 .bits = 16,
55 .poly = 0x1021,
56 .init = 0x0000,
57 .remainder = 0xffff,
58};
59
Neels Hofmeyr87e45502017-06-20 00:17:59 +020060/*! EDGE MCS header parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070061 *
62 */
63const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = {
64 .bits = 8,
65 .poly = 0x49,
66 .init = 0x00,
67 .remainder = 0xff,
68};
69
Neels Hofmeyr87e45502017-06-20 00:17:59 +020070/*! EDGE MCS data parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070071 *
72 */
73const struct osmo_crc16gen_code gsm0503_mcs_crc12 = {
74 .bits = 12,
75 .poly = 0x0d31,
76 .init = 0x0000,
77 .remainder = 0x0fff,
78};
79
Neels Hofmeyr87e45502017-06-20 00:17:59 +020080/*! GSM RACH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070081 *
82 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
83 */
84const struct osmo_crc8gen_code gsm0503_rach_crc6 = {
85 .bits = 6,
86 .poly = 0x2f,
87 .init = 0x00,
88 .remainder = 0x3f,
89};
90
Neels Hofmeyr87e45502017-06-20 00:17:59 +020091/*! GSM SCH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070092 *
93 * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1
94 */
95const struct osmo_crc16gen_code gsm0503_sch_crc10 = {
96 .bits = 10,
97 .poly = 0x175,
98 .init = 0x000,
99 .remainder = 0x3ff,
100};
101
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200102/*! GSM TCH FR/HR/EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700103 *
104 * g(x) = x^3 + x + 1
105 */
106const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = {
107 .bits = 3,
108 .poly = 0x3,
109 .init = 0x0,
110 .remainder = 0x7,
111};
112
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200113/*! GSM TCH EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700114 *
115 * g(x) = x^8 + x^4 + x^3 + x^2 + 1
116 */
117const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = {
118 .bits = 8,
119 .poly = 0x1d,
120 .init = 0x00,
121 .remainder = 0x00,
122};
123
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200124/*! GSM AMR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700125 *
126 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
127 */
128const struct osmo_crc8gen_code gsm0503_amr_crc6 = {
129 .bits = 6,
130 .poly = 0x2f,
131 .init = 0x00,
132 .remainder = 0x3f,
133};
Harald Weltec6636782017-06-12 14:59:37 +0200134
135/*! @} */