blob: 171feb460dd8e059f1aa2e979984497abff549ae [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 *
30 * \brief GSM TS 05.03 parity
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
34 */
35
36/*! \file gsm0503_parity.c */
37
38/*! \brief GSM (SACCH) parity (FIRE code)
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070039 *
40 * g(x) = (x^23 + 1)(x^17 + x^3 + 1)
41 * = x^40 + x^26 + x^23 + x^17 + x^3 + a1
42 */
43const struct osmo_crc64gen_code gsm0503_fire_crc40 = {
44 .bits = 40,
45 .poly = 0x0004820009ULL,
46 .init = 0x0000000000ULL,
47 .remainder = 0xffffffffffULL,
48};
49
Harald Weltec6636782017-06-12 14:59:37 +020050/*! \brief GSM PDTCH CS-2, CS-3, CS-4 parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070051 *
52 * g(x) = x^16 + x^12 + x^5 + 1
53 */
54const struct osmo_crc16gen_code gsm0503_cs234_crc16 = {
55 .bits = 16,
56 .poly = 0x1021,
57 .init = 0x0000,
58 .remainder = 0xffff,
59};
60
Harald Weltec6636782017-06-12 14:59:37 +020061/*! \brief EDGE MCS header parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070062 *
63 */
64const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = {
65 .bits = 8,
66 .poly = 0x49,
67 .init = 0x00,
68 .remainder = 0xff,
69};
70
Harald Weltec6636782017-06-12 14:59:37 +020071/*! \brief EDGE MCS data parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070072 *
73 */
74const struct osmo_crc16gen_code gsm0503_mcs_crc12 = {
75 .bits = 12,
76 .poly = 0x0d31,
77 .init = 0x0000,
78 .remainder = 0x0fff,
79};
80
Harald Weltec6636782017-06-12 14:59:37 +020081/*! \brief GSM RACH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070082 *
83 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
84 */
85const struct osmo_crc8gen_code gsm0503_rach_crc6 = {
86 .bits = 6,
87 .poly = 0x2f,
88 .init = 0x00,
89 .remainder = 0x3f,
90};
91
Harald Weltec6636782017-06-12 14:59:37 +020092/*! \brief GSM SCH parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070093 *
94 * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1
95 */
96const struct osmo_crc16gen_code gsm0503_sch_crc10 = {
97 .bits = 10,
98 .poly = 0x175,
99 .init = 0x000,
100 .remainder = 0x3ff,
101};
102
Harald Weltec6636782017-06-12 14:59:37 +0200103/*! \brief GSM TCH FR/HR/EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700104 *
105 * g(x) = x^3 + x + 1
106 */
107const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = {
108 .bits = 3,
109 .poly = 0x3,
110 .init = 0x0,
111 .remainder = 0x7,
112};
113
Harald Weltec6636782017-06-12 14:59:37 +0200114/*! \brief GSM TCH EFR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700115 *
116 * g(x) = x^8 + x^4 + x^3 + x^2 + 1
117 */
118const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = {
119 .bits = 8,
120 .poly = 0x1d,
121 .init = 0x00,
122 .remainder = 0x00,
123};
124
Harald Weltec6636782017-06-12 14:59:37 +0200125/*! \brief GSM AMR parity
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700126 *
127 * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
128 */
129const struct osmo_crc8gen_code gsm0503_amr_crc6 = {
130 .bits = 6,
131 .poly = 0x2f,
132 .init = 0x00,
133 .remainder = 0x3f,
134};
Harald Weltec6636782017-06-12 14:59:37 +0200135
136/*! @} */