diff options
Diffstat (limited to 'include/osmocom')
-rw-r--r-- | include/osmocom/coding/gsm0503_coding.h | 63 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_interleaving.h | 51 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_mapping.h | 33 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_parity.h | 13 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_tables.h | 50 |
5 files changed, 210 insertions, 0 deletions
diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h new file mode 100644 index 00000000..b8eb2052 --- /dev/null +++ b/include/osmocom/coding/gsm0503_coding.h @@ -0,0 +1,63 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/bits.h> + +#define GSM0503_GPRS_BURSTS_NBITS (116 * 4) +#define GSM0503_EGPRS_BURSTS_NBITS (348 * 4) +#define NUM_BYTES(N) ((N + 8 - 1) / 8) + +enum gsm0503_egprs_mcs { + EGPRS_MCS0, + EGPRS_MCS1, + EGPRS_MCS2, + EGPRS_MCS3, + EGPRS_MCS4, + EGPRS_MCS5, + EGPRS_MCS6, + EGPRS_MCS7, + EGPRS_MCS8, + EGPRS_MCS9, + EGPRS_NUM_MCS, +}; + +int gsm0503_xcch_encode(ubit_t *bursts, uint8_t *l2_data); +int gsm0503_xcch_decode(uint8_t *l2_data, sbit_t *bursts, + int *n_errors, int *n_bits_total); + +int gsm0503_pdtch_encode(ubit_t *bursts, uint8_t *l2_data, uint8_t l2_len); +int gsm0503_pdtch_decode(uint8_t *l2_data, sbit_t *bursts, uint8_t *usf_p, + int *n_errors, int *n_bits_total); + +int gsm0503_pdtch_egprs_encode(ubit_t *bursts, uint8_t *l2_data, + uint8_t l2_len); +int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts, + uint16_t nbits, uint8_t *usf_p, int *n_errors, int *n_bits_total); + +int gsm0503_tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, + int net_order); +int gsm0503_tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int net_order, + int efr, int *n_errors, int *n_bits_total); + +int gsm0503_tch_hr_encode(ubit_t *bursts, uint8_t *tch_data, int len); +int gsm0503_tch_hr_decode(uint8_t *tch_data, sbit_t *bursts, int odd, + int *n_errors, int *n_bits_total); + +int gsm0503_tch_afs_encode(ubit_t *bursts, uint8_t *tch_data, int len, + int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft, + uint8_t cmr); +int gsm0503_tch_afs_decode(uint8_t *tch_data, sbit_t *bursts, + int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, + uint8_t *cmr, int *n_errors, int *n_bits_total); + +int gsm0503_tch_ahs_encode(ubit_t *bursts, uint8_t *tch_data, int len, + int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft, uint8_t cmr); +int gsm0503_tch_ahs_decode(uint8_t *tch_data, sbit_t *bursts, int odd, + int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, + uint8_t *cmr, int *n_errors, int *n_bits_total); + +int gsm0503_rach_encode(ubit_t *burst, uint8_t *ra, uint8_t bsic); +int gsm0503_rach_decode(uint8_t *ra, sbit_t *burst, uint8_t bsic); + +int gsm0503_sch_encode(ubit_t *burst, uint8_t *sb_info); +int gsm0503_sch_decode(uint8_t *sb_info, sbit_t *burst); diff --git a/include/osmocom/coding/gsm0503_interleaving.h b/include/osmocom/coding/gsm0503_interleaving.h new file mode 100644 index 00000000..f97dff4f --- /dev/null +++ b/include/osmocom/coding/gsm0503_interleaving.h @@ -0,0 +1,51 @@ +#pragma once + +#include <osmocom/core/bits.h> + +void gsm0503_xcch_deinterleave(sbit_t *cB, const sbit_t *iB); +void gsm0503_xcch_interleave(ubit_t *cB, ubit_t *iB); + +void gsm0503_tch_fr_deinterleave(sbit_t *cB, sbit_t *iB); +void gsm0503_tch_fr_interleave(ubit_t *cB, ubit_t *iB); + +void gsm0503_tch_hr_deinterleave(sbit_t *cB, sbit_t *iB); +void gsm0503_tch_hr_interleave(ubit_t *cB, ubit_t *iB); + +void gsm0503_mcs1_ul_deinterleave(sbit_t *hc, sbit_t *dc, const sbit_t *iB); +void gsm0503_mcs1_ul_interleave(const ubit_t *hc, + const ubit_t *dc, ubit_t *iB); + +void gsm0503_mcs1_dl_deinterleave(sbit_t *u, sbit_t *hc, + sbit_t *dc, const sbit_t *iB); +void gsm0503_mcs1_dl_interleave(const ubit_t *up, const ubit_t *hc, + const ubit_t *dc, ubit_t *iB); + +void gsm0503_mcs5_ul_deinterleave(sbit_t *hc, sbit_t *dc, + const sbit_t *hi, const sbit_t *di); +void gsm0503_mcs5_ul_interleave(const ubit_t *hc, const ubit_t *dc, + ubit_t *hi, ubit_t *di); + +void gsm0503_mcs5_dl_deinterleave(sbit_t *hc, sbit_t *dc, + const sbit_t *hi, const sbit_t *di); +void gsm0503_mcs5_dl_interleave(const ubit_t *hc, const ubit_t *dc, + ubit_t *hi, ubit_t *di); + +void gsm0503_mcs7_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2, + const sbit_t *hi, const sbit_t *di); +void gsm0503_mcs7_ul_interleave(const ubit_t *hc, const ubit_t *c1, + const ubit_t *c2, ubit_t *hi, ubit_t *di); + +void gsm0503_mcs7_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2, + const sbit_t *hi, const sbit_t *di); +void gsm0503_mcs7_dl_interleave(const ubit_t *hc, const ubit_t *c1, + const ubit_t *c2, ubit_t *hi, ubit_t *di); + +void gsm0503_mcs8_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2, + const sbit_t *hi, const sbit_t *di); +void gsm0503_mcs8_ul_interleave(const ubit_t *hc, const ubit_t *c1, + const ubit_t *c2, ubit_t *hi, ubit_t *di); + +void gsm0503_mcs8_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2, + const sbit_t *hi, const sbit_t *di); +void gsm0503_mcs8_dl_interleave(const ubit_t *hc, const ubit_t *c1, + const ubit_t *c2, ubit_t *hi, ubit_t *di); diff --git a/include/osmocom/coding/gsm0503_mapping.h b/include/osmocom/coding/gsm0503_mapping.h new file mode 100644 index 00000000..4c6550a4 --- /dev/null +++ b/include/osmocom/coding/gsm0503_mapping.h @@ -0,0 +1,33 @@ +#pragma once + +#include <osmocom/core/bits.h> + +void gsm0503_xcch_burst_unmap(sbit_t *iB, const sbit_t *eB, + sbit_t *hl, sbit_t *hn); +void gsm0503_xcch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *hl, + const ubit_t *hn); + +void gsm0503_tch_burst_unmap(sbit_t *iB, sbit_t *eB, sbit_t *h, int odd); +void gsm0503_tch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *h, int odd); + +void gsm0503_mcs5_ul_burst_map(const ubit_t *di, ubit_t *eB, + const ubit_t *hi, int B); +void gsm0503_mcs5_ul_burst_unmap(sbit_t *di, const sbit_t *eB, + sbit_t *hi, int B); + +void gsm0503_mcs7_ul_burst_map(const ubit_t *di, ubit_t *eB, + const ubit_t *hi, int B); +void gsm0503_mcs7_ul_burst_unmap(sbit_t *di, const sbit_t *eB, + sbit_t *hi, int B); + +void gsm0503_mcs5_dl_burst_map(const ubit_t *di, ubit_t *eB, + const ubit_t *hi, const ubit_t *up, int B); +void gsm0503_mcs5_dl_burst_unmap(sbit_t *di, const sbit_t *eB, + sbit_t *hi, sbit_t *up, int B); + +void gsm0503_mcs7_dl_burst_map(const ubit_t *di, ubit_t *eB, + const ubit_t *hi, const ubit_t *up, int B); +void gsm0503_mcs7_dl_burst_unmap(sbit_t *di, const sbit_t *eB, + sbit_t *hi, sbit_t *up, int B); + +void gsm0503_mcs5_burst_swap(sbit_t *eB); diff --git a/include/osmocom/coding/gsm0503_parity.h b/include/osmocom/coding/gsm0503_parity.h new file mode 100644 index 00000000..540124a7 --- /dev/null +++ b/include/osmocom/coding/gsm0503_parity.h @@ -0,0 +1,13 @@ +#pragma once + +#include <osmocom/core/crcgen.h> + +const struct osmo_crc64gen_code gsm0503_fire_crc40; +const struct osmo_crc16gen_code gsm0503_cs234_crc16; +const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr; +const struct osmo_crc16gen_code gsm0503_mcs_crc12; +const struct osmo_crc8gen_code gsm0503_rach_crc6; +const struct osmo_crc16gen_code gsm0503_sch_crc10; +const struct osmo_crc8gen_code gsm0503_tch_fr_crc3; +const struct osmo_crc8gen_code gsm0503_tch_efr_crc8; +const struct osmo_crc8gen_code gsm0503_amr_crc6; diff --git a/include/osmocom/coding/gsm0503_tables.h b/include/osmocom/coding/gsm0503_tables.h new file mode 100644 index 00000000..e6761ca4 --- /dev/null +++ b/include/osmocom/coding/gsm0503_tables.h @@ -0,0 +1,50 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/bits.h> + +extern const ubit_t gsm0503_pdtch_hl_hn_ubit[4][8]; +extern const ubit_t gsm0503_pdtch_edge_hl_hn_ubit[3][8]; +extern const sbit_t gsm0503_pdtch_hl_hn_sbit[4][8]; +extern const sbit_t gsm0503_pdtch_edge_hl_hn_sbit[3][8]; +extern const ubit_t gsm0503_usf2six[8][6]; +extern const ubit_t gsm0503_usf2twelve_ubit[8][12]; +extern const sbit_t gsm0503_usf2twelve_sbit[8][12]; +extern const uint8_t gsm0503_puncture_cs2[588]; +extern const uint8_t gsm0503_puncture_cs3[676]; +extern const uint8_t gsm0503_puncture_mcs1_dl_hdr[108]; +extern const uint8_t gsm0503_puncture_mcs1_ul_hdr[117]; +extern const uint8_t gsm0503_puncture_mcs1_p1[588]; +extern const uint8_t gsm0503_puncture_mcs1_p2[588]; +extern const uint8_t gsm0503_puncture_mcs2_p1[732]; +extern const uint8_t gsm0503_puncture_mcs2_p2[732]; +extern const uint8_t gsm0503_puncture_mcs3_p1[948]; +extern const uint8_t gsm0503_puncture_mcs3_p2[948]; +extern const uint8_t gsm0503_puncture_mcs3_p3[948]; +extern const uint8_t gsm0503_puncture_mcs4_p1[1116]; +extern const uint8_t gsm0503_puncture_mcs4_p2[1116]; +extern const uint8_t gsm0503_puncture_mcs4_p3[1116]; +extern const uint8_t gsm0503_puncture_mcs5_p1[1404]; +extern const uint8_t gsm0503_puncture_mcs5_p2[1404]; +extern const uint8_t gsm0503_puncture_mcs6_p1[1836]; +extern const uint8_t gsm0503_puncture_mcs6_p2[1836]; +extern const uint8_t gsm0503_puncture_mcs7_dl_hdr[135]; +extern const uint8_t gsm0503_puncture_mcs7_ul_hdr[162]; +extern const uint8_t gsm0503_puncture_mcs7_p1[1404]; +extern const uint8_t gsm0503_puncture_mcs7_p2[1404]; +extern const uint8_t gsm0503_puncture_mcs7_p3[1404]; +extern const uint8_t gsm0503_puncture_mcs8_p1[1692]; +extern const uint8_t gsm0503_puncture_mcs8_p2[1692]; +extern const uint8_t gsm0503_puncture_mcs8_p3[1692]; +extern const uint8_t gsm0503_puncture_mcs9_p1[1836]; +extern const uint8_t gsm0503_puncture_mcs9_p2[1836]; +extern const uint8_t gsm0503_puncture_mcs9_p3[1836]; +extern const uint16_t gsm0503_interleave_mcs5[1248]; +extern const uint8_t gsm0503_gsm_fr_map[76]; +extern const uint8_t gsm0503_gsm_efr_protected_bits[65]; +extern const ubit_t gsm0503_afs_ic_ubit[4][8]; +extern const sbit_t gsm0503_afs_ic_sbit[4][8]; +extern const ubit_t gsm0503_ahs_ic_ubit[4][4]; +extern const sbit_t gsm0503_ahs_ic_sbit[4][4]; +extern const uint8_t gsm0503_tch_hr_interleaving[228][2]; +extern const ubit_t gsm0503_mcs5_usf_precode_table[8][36]; |