summaryrefslogtreecommitdiffstats
path: root/apps/osmocomBB/osmocomBB/include/layer1
diff options
context:
space:
mode:
Diffstat (limited to 'apps/osmocomBB/osmocomBB/include/layer1')
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/afc.h18
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/agc.h7
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/apc.h10
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/async.h62
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/avg.h23
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/l23_api.h18
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/mframe_sched.h68
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/prim.h34
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/rfch.h9
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/sched_gsmtime.h24
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/sync.h204
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/tdma_sched.h73
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/toa.h10
-rw-r--r--apps/osmocomBB/osmocomBB/include/layer1/tpu_window.h24
14 files changed, 584 insertions, 0 deletions
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/afc.h b/apps/osmocomBB/osmocomBB/include/layer1/afc.h
new file mode 100644
index 0000000000..8b43f8aa85
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/afc.h
@@ -0,0 +1,18 @@
+#ifndef _L1_AFC_H
+#define _L1_AFC_H
+
+#define AFC_SNR_THRESHOLD 2560 /* 2.5 dB in fx6.10 */
+
+/* Input a frequency error sample into the AFC averaging */
+void afc_input(int32_t freq_error, uint16_t arfcn, int valid);
+
+/* Update the AFC with a frequency error, bypassing averaging */
+void afc_correct(int16_t freq_error, uint16_t arfcn);
+
+/* Update DSP with new AFC DAC value to be used for next TDMA frame */
+void afc_load_dsp(void);
+
+/* Reset the AFC to its initial DAC value */
+void afc_reset(void);
+
+#endif
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/agc.h b/apps/osmocomBB/osmocomBB/include/layer1/agc.h
new file mode 100644
index 0000000000..2b7e46e927
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/agc.h
@@ -0,0 +1,7 @@
+#ifndef _L1_AGC_H
+#define _L1_AGC_H
+
+#define to_dbm8(x) ((x)*8)
+int16_t agc_inp_dbm8_by_pm(int16_t pm);
+
+#endif /* _L1_AGC_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/apc.h b/apps/osmocomBB/osmocomBB/include/layer1/apc.h
new file mode 100644
index 0000000000..3d73c23e52
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/apc.h
@@ -0,0 +1,10 @@
+#ifndef _L1_APC_H
+#define _L1_APC_H
+
+/* determine the AUXAPC value by the Tx Power Level */
+int16_t apc_tx_dbm2auxapc(enum gsm_band band, int8_t dbm);
+
+/* determine the AUXAPC value by the Tx Power Level */
+int16_t apc_tx_pwrlvl2auxapc(enum gsm_band band, uint8_t lvl);
+
+#endif
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/async.h b/apps/osmocomBB/osmocomBB/include/layer1/async.h
new file mode 100644
index 0000000000..de996a674a
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/async.h
@@ -0,0 +1,62 @@
+#ifndef _L1_ASYNC_H
+#define _L1_ASYNC_H
+
+#include <osmocom/core/msgb.h>
+
+#include <layer1/mframe_sched.h>
+
+#if 0
+NOTE: Re-enabling interrupts causes an IRQ while processing the same IRQ.
+ Use local_firq_save and local_irq_restore instead!
+
+/* When altering data structures used by L1 Sync part, we need to
+ * make sure to temporarily disable IRQ/FIQ to keep data consistent */
+static inline void l1a_lock_sync(void)
+{
+ arm_disable_interrupts();
+}
+
+static inline void l1a_unlock_sync(void)
+{
+ arm_enable_interrupts();
+}
+#endif
+
+/* safely enable a message into the L1S TX queue */
+void l1a_txq_msgb_enq(struct llist_head *queue, struct msgb *msg);
+void l1a_meas_msgb_set(struct msgb *msg);
+
+/* safely count messages in the L1S TX queue */
+int l1a_txq_msgb_count(struct llist_head *queue);
+
+/* flush all pending msgb */
+void l1a_txq_msgb_flush(struct llist_head *queue);
+
+/* request a RACH */
+void l1a_rach_req(uint16_t offset, uint8_t combined, uint8_t ra);
+
+/* schedule frequency change */
+void l1a_freq_req(uint32_t fn_sched);
+
+/* Enable a repeating multiframe task */
+void l1a_mftask_enable(enum mframe_task task);
+
+/* Disable a repeating multiframe task */
+void l1a_mftask_disable(enum mframe_task task);
+
+/* Set the mask for repeating multiframe tasks */
+void l1a_mftask_set(uint32_t tasks);
+
+/* Set TCH mode */
+uint8_t l1a_tch_mode_set(uint8_t mode);
+
+/* Set Audio routing mode */
+uint8_t l1a_audio_mode_set(uint8_t mode);
+
+/* Execute pending L1A completions */
+void l1a_compl_execute(void);
+
+/* Initialize asynchronous part of Layer1 */
+void l1a_init(void);
+
+#endif
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/avg.h b/apps/osmocomBB/osmocomBB/include/layer1/avg.h
new file mode 100644
index 0000000000..6c5de172d4
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/avg.h
@@ -0,0 +1,23 @@
+#ifndef _L1_AVG_H
+#define _L1_AVG_H
+
+struct running_avg {
+ /* configuration */
+ uint16_t period; /* over how many samples to average */
+ uint16_t min_valid;
+
+ int32_t acc_val;
+ uint16_t num_samples; /* how often did we try to sample? */
+ uint16_t num_samples_valid; /* how often did we receive valid samples? */
+
+ void (*outfn)(struct running_avg *, int32_t avg);
+ void *priv;
+};
+
+/* input a new sample into the averaging process */
+void runavg_input(struct running_avg *ravg, int32_t val, int valid);
+
+/* check if sufficient samples have been obtained, and call outfn() */
+int runavg_check_output(struct running_avg *ravg);
+
+#endif /* _AVG_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/l23_api.h b/apps/osmocomBB/osmocomBB/include/layer1/l23_api.h
new file mode 100644
index 0000000000..e4a3fd0a68
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/l23_api.h
@@ -0,0 +1,18 @@
+#ifndef _L1_L23_API_H
+#define _L1_L23_API_H
+
+#include <stdint.h>
+#include <osmocom/core/msgb.h>
+#include <l1ctl_proto.h>
+
+void l1a_l23api_init(void);
+void l1a_l23_handler(void);
+void l1_queue_for_l2(struct msgb *msg);
+struct msgb *l1ctl_msgb_alloc(uint8_t msg_type);
+struct msgb *l1_create_l2_msg(int msg_type, uint32_t fn, uint16_t snr, uint16_t arfcn);
+extern void (*l1a_l23_tx_cb)(struct msgb *msg);
+void l1a_l23_rx(uint8_t dlci, struct msgb *msg);
+
+void l1ctl_tx_reset(uint8_t msg_type, uint8_t reset_type);
+
+#endif /* _L1_L23_API_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/mframe_sched.h b/apps/osmocomBB/osmocomBB/include/layer1/mframe_sched.h
new file mode 100644
index 0000000000..ecdb1ec8fe
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/mframe_sched.h
@@ -0,0 +1,68 @@
+#ifndef _L1_MFRAME_SCHED_H
+#define _L1_MFRAME_SCHED_H
+
+#include <stdint.h>
+
+enum mframe_task {
+ MF_TASK_BCCH_NORM,
+ MF_TASK_BCCH_EXT,
+ MF_TASK_CCCH,
+ MF_TASK_CCCH_COMB,
+
+ MF_TASK_SDCCH4_0,
+ MF_TASK_SDCCH4_1,
+ MF_TASK_SDCCH4_2,
+ MF_TASK_SDCCH4_3,
+
+ MF_TASK_SDCCH8_0,
+ MF_TASK_SDCCH8_1,
+ MF_TASK_SDCCH8_2,
+ MF_TASK_SDCCH8_3,
+ MF_TASK_SDCCH8_4,
+ MF_TASK_SDCCH8_5,
+ MF_TASK_SDCCH8_6,
+ MF_TASK_SDCCH8_7,
+
+ MF_TASK_TCH_F_EVEN,
+ MF_TASK_TCH_F_ODD,
+ MF_TASK_TCH_H_0,
+ MF_TASK_TCH_H_1,
+
+ MF_TASK_NEIGH_PM51_C0T0,
+ MF_TASK_NEIGH_PM51,
+ MF_TASK_NEIGH_PM26E,
+ MF_TASK_NEIGH_PM26O,
+
+ /* Test task: send Normal Burst in all timeslots */
+ MF_TASK_UL_ALL_NB,
+};
+
+enum mf_sched_item_flag {
+ MF_F_SACCH = (1 << 0),
+};
+
+/* The scheduler itself */
+struct mframe_scheduler {
+ uint32_t tasks;
+ uint32_t tasks_tgt;
+ uint32_t safe_fn;
+};
+
+uint8_t mframe_task2chan_nr(enum mframe_task mft, uint8_t ts);
+
+/* Enable a specific task */
+void mframe_enable(enum mframe_task task_id);
+
+/* Disable a specific task */
+void mframe_disable(enum mframe_task task_id);
+
+/* Replace the current active set by the new one */
+void mframe_set(uint32_t tasks);
+
+/* Schedule mframe_sched_items according to current MF TASK list */
+void mframe_schedule(void);
+
+/* reset the scheduler, disabling all tasks */
+void mframe_reset(void);
+
+#endif /* _MFRAME_SCHED_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/prim.h b/apps/osmocomBB/osmocomBB/include/layer1/prim.h
new file mode 100644
index 0000000000..30c51ae6cb
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/prim.h
@@ -0,0 +1,34 @@
+#ifndef _L1_PRIM_H
+#define _L1_PRIM_H
+
+#include <stdint.h>
+
+#include <layer1/tdma_sched.h>
+
+struct l1ctl_fbsb_req;
+
+/* Utils */
+const uint8_t *pu_get_idle_frame(void);
+void pu_update_rx_level(uint8_t rx_level);
+const uint8_t *pu_get_meas_frame(void);
+
+/* Primitives tests/requests */
+void l1s_fb_test(uint8_t base_fn, uint8_t fb_mode);
+void l1s_sb_test(uint8_t base_fn);
+void l1s_pm_test(uint8_t base_fn, uint16_t arfcn);
+void l1s_nb_test(uint8_t base_fn);
+
+void l1s_fbsb_req(uint8_t base_fn, struct l1ctl_fbsb_req *req);
+void l1a_freq_req(uint32_t fn_sched);
+void l1a_rach_req(uint16_t offset, uint8_t combined, uint8_t ra);
+
+/* Primitives raw scheduling sets */
+extern const struct tdma_sched_item nb_sched_set[];
+extern const struct tdma_sched_item nb_sched_set_ul[];
+
+extern const struct tdma_sched_item tch_sched_set[];
+extern const struct tdma_sched_item tch_a_sched_set[];
+extern const struct tdma_sched_item tch_d_sched_set[];
+extern const struct tdma_sched_item neigh_pm_sched_set[];
+
+#endif /* _L1_PRIM_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/rfch.h b/apps/osmocomBB/osmocomBB/include/layer1/rfch.h
new file mode 100644
index 0000000000..344523c353
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/rfch.h
@@ -0,0 +1,9 @@
+#ifndef _L1_RFCH_H
+#define _L1_RFCH_H
+
+struct gsm_time;
+
+void rfch_get_params(struct gsm_time *t,
+ uint16_t *arfcn_p, uint8_t *tsc_p, uint8_t *tn_p);
+
+#endif /* _L1_RFCH_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/sched_gsmtime.h b/apps/osmocomBB/osmocomBB/include/layer1/sched_gsmtime.h
new file mode 100644
index 0000000000..c40359eaff
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/sched_gsmtime.h
@@ -0,0 +1,24 @@
+#ifndef _L1_SCHED_GSMTIME_H
+#define _L1_SCHED_GSMTIME_H
+
+#include <stdint.h>
+#include <osmocom/core/linuxlist.h>
+
+struct sched_gsmtime_event {
+ struct llist_head list;
+ const struct tdma_sched_item *si;
+ uint32_t fn;
+ uint16_t p3; /* parameter for TDMA scheduler */
+};
+
+/* initialize the GSMTIME scheduler */
+void sched_gsmtime_init(void);
+
+/* Scheduling of a single event at a givnen GSM time */
+int sched_gsmtime(const struct tdma_sched_item *si, uint32_t fn, uint16_t p3);
+
+/* execute all GSMTIME one-shot events pending for 'current_fn' */
+int sched_gsmtime_execute(uint32_t current_fn);
+
+void sched_gsmtime_reset(void);
+#endif
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/sync.h b/apps/osmocomBB/osmocomBB/include/layer1/sync.h
new file mode 100644
index 0000000000..dae85a1a9c
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/sync.h
@@ -0,0 +1,204 @@
+#ifndef _L1_SYNC_H
+#define _L1_SYNC_H
+
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <layer1/tdma_sched.h>
+#include <layer1/mframe_sched.h>
+#include <l1ctl_proto.h>
+
+/* structure representing L1 sync information about a cell */
+struct l1_cell_info {
+ /* on which ARFCN (+band) is the cell? */
+ uint16_t arfcn;
+ /* what's the BSIC of the cell (from SCH burst decoding) */
+ uint8_t bsic;
+ /* Combined or non-combined CCCH */
+ uint8_t ccch_mode; /* enum ccch_mode */
+ /* whats the delta of the cells current GSM frame number
+ * compared to our current local frame number */
+ int32_t fn_offset;
+ /* how much does the TPU need adjustment (delta) to synchronize
+ * with the cells burst */
+ uint32_t time_alignment;
+ /* FIXME: should we also store the AFC value? */
+};
+
+enum l1s_chan {
+ L1S_CHAN_MAIN,
+ L1S_CHAN_SACCH,
+ L1S_CHAN_TRAFFIC,
+ _NUM_L1S_CHAN
+};
+
+enum l1_compl {
+ L1_COMPL_FB,
+ L1_COMPL_RACH,
+ L1_COMPL_TX_NB,
+ L1_COMPL_TX_TCH,
+};
+
+typedef void l1_compl_cb(enum l1_compl c);
+
+#define L1S_NUM_COMPL 32
+#define L1S_NUM_NEIGH_CELL 6
+
+struct l1s_h0 {
+ uint16_t arfcn;
+};
+
+struct l1s_h1 {
+ uint8_t hsn;
+ uint8_t maio;
+ uint8_t n;
+ uint16_t ma[64];
+};
+
+struct l1s_state {
+ struct gsm_time current_time; /* current GSM time */
+ struct gsm_time next_time; /* GSM time at next TMDMA irq */
+
+ /* the cell on which we are camping right now */
+ struct l1_cell_info serving_cell;
+
+ /* neighbor cell sync info */
+ struct l1_cell_info neigh_cell[L1S_NUM_NEIGH_CELL];
+
+ /* TDMA scheduler */
+ struct tdma_scheduler tdma_sched;
+
+ /* Multiframe scheduler */
+ struct mframe_scheduler mframe_sched;
+
+ /* The current TPU offset register */
+ uint32_t tpu_offset;
+ int32_t tpu_offset_correction;
+
+ /* TX parameters */
+ int8_t ta;
+ uint8_t tx_power;
+
+ /* TCH */
+ uint8_t tch_mode;
+ uint8_t tch_sync;
+ uint8_t audio_mode;
+
+ /* Transmit queues of pending packets for main DCCH and ACCH */
+ struct llist_head tx_queue[_NUM_L1S_CHAN];
+ struct msgb *tx_meas;
+
+ /* Which L1A completions are scheduled right now */
+ uint32_t scheduled_compl;
+ /* callbacks for each of the completions */
+ l1_compl_cb *completion[L1S_NUM_COMPL];
+
+ /* Structures below are for L1-task specific parameters, used
+ * to communicate between l1-sync and l1-async (l23_api) */
+ struct {
+ uint8_t mode; /* FB_MODE 0/1 */
+ } fb;
+
+ struct {
+ /* power measurement l1 task */
+ unsigned int mode;
+ union {
+ struct {
+ uint16_t arfcn_start;
+ uint16_t arfcn_next;
+ uint16_t arfcn_end;
+ } range;
+ };
+ struct msgb *msg;
+ } pm;
+
+ struct {
+ uint8_t ra;
+ } rach;
+
+ struct {
+ enum {
+ GSM_DCHAN_NONE = 0,
+ GSM_DCHAN_SDCCH_4,
+ GSM_DCHAN_SDCCH_8,
+ GSM_DCHAN_TCH_H,
+ GSM_DCHAN_TCH_F,
+ GSM_DCHAN_UNKNOWN,
+ } type;
+
+ uint8_t scn;
+ uint8_t tsc;
+ uint8_t tn;
+ uint8_t h;
+
+ union {
+ struct l1s_h0 h0;
+ struct l1s_h1 h1;
+ };
+
+ uint8_t st_tsc;
+ uint8_t st_tn;
+ uint8_t st_h;
+
+ union {
+ struct l1s_h0 st_h0;
+ struct l1s_h1 st_h1;
+ };
+ } dedicated;
+
+ /* neighbour cell power measurement process */
+ struct {
+ uint8_t n, second;
+ uint8_t pos;
+ uint8_t running;
+ uint16_t band_arfcn[64];
+ uint8_t tn[64];
+ uint8_t level[64];
+ } neigh_pm;
+};
+
+extern struct l1s_state l1s;
+
+struct l1s_meas_hdr {
+ uint16_t snr; /* signal/noise ratio */
+ int16_t toa_qbit; /* time of arrival (qbits) */
+ int16_t pm_dbm8; /* power level in dbm/8 */
+ int16_t freq_err; /* Frequency error in Hz */
+};
+
+int16_t l1s_snr_int(uint16_t snr);
+uint16_t l1s_snr_fract(uint16_t snr);
+
+void l1s_dsp_abort(void);
+
+void l1s_tx_apc_helper(uint16_t arfcn);
+
+/* schedule a completion */
+void l1s_compl_sched(enum l1_compl c);
+
+void l1s_init(void);
+
+/* reset the layer1 as part of synchronizing to a new cell */
+void l1s_reset(void);
+
+/* init.c */
+void layer1_init(void);
+
+/* A debug macro to print every TDMA frame */
+#ifdef DEBUG_EVERY_TDMA
+#define putchart(x) putchar(x)
+#else
+#define putchart(x)
+#endif
+
+/* Convert an angle in fx1.15 notatinon into Hz */
+#define BITFREQ_DIV_2PI 43104 /* 270kHz / 2 * pi */
+#define BITFREQ_DIV_PI 86208 /* 270kHz / pi */
+#define ANG2FREQ_SCALING (2<<15) /* 2^15 scaling factor for fx1.15 */
+#define ANGLE_TO_FREQ(angle) ((int16_t)angle * BITFREQ_DIV_PI / ANG2FREQ_SCALING)
+
+void l1s_reset_hw(void);
+void synchronize_tdma(struct l1_cell_info *cinfo);
+void l1s_time_inc(struct gsm_time *time, uint32_t delta_fn);
+void l1s_time_dump(const struct gsm_time *time);
+
+#endif /* _L1_SYNC_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/tdma_sched.h b/apps/osmocomBB/osmocomBB/include/layer1/tdma_sched.h
new file mode 100644
index 0000000000..f58d59bb9e
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/tdma_sched.h
@@ -0,0 +1,73 @@
+#ifndef _L1_TDMA_SCHED_H
+#define _L1_TDMA_SCHED_H
+
+#include <stdint.h>
+
+/* TDMA scheduler */
+
+/* The idea of this scheduler is that we have a circular buffer of buckets,
+ * where each bucket corresponds to one future TDMA frame [interrupt]. Each
+ * bucket contains of a list of callbacks which are executed when the bucket
+ * index reaches that particular bucket. */
+
+#define TDMASCHED_NUM_FRAMES 25
+#define TDMASCHED_NUM_CB 8
+
+#define TDMA_IFLG_TPU (1<<0)
+#define TDMA_IFLG_DSP (1<<1)
+
+typedef int tdma_sched_cb(uint8_t p1, uint8_t p2, uint16_t p3);
+
+/* A single item in a TDMA scheduler bucket */
+struct tdma_sched_item {
+ tdma_sched_cb *cb;
+ uint8_t p1;
+ uint8_t p2;
+ uint16_t p3;
+ int16_t prio;
+ uint16_t flags; /* TDMA_IFLG_xxx */
+};
+
+/* A bucket inside the TDMA scheduler */
+struct tdma_sched_bucket {
+ struct tdma_sched_item item[TDMASCHED_NUM_CB];
+ uint8_t num_items;
+};
+
+/* The scheduler itself, consisting of buckets and a current index */
+struct tdma_scheduler {
+ struct tdma_sched_bucket bucket[TDMASCHED_NUM_FRAMES];
+ uint8_t cur_bucket;
+};
+
+/* Schedule an item at 'frame_offset' TDMA frames in the future */
+int tdma_schedule(uint8_t frame_offset, tdma_sched_cb *cb,
+ uint8_t p1, uint8_t p2, uint16_t p3, int16_t prio);
+
+/* Schedule a set of items starting from 'frame_offset' TDMA frames in the future */
+int tdma_schedule_set(uint8_t frame_offset, const struct tdma_sched_item *item_set, uint16_t p3);
+
+/* Scan current frame scheduled items for flags */
+uint16_t tdma_sched_flag_scan(void);
+
+/* Execute pre-scheduled events for current frame */
+int tdma_sched_execute(void);
+
+/* Advance TDMA scheduler to the next bucket */
+void tdma_sched_advance(void);
+
+/* reset the scheduler; erase all scheduled items */
+void tdma_sched_reset(void);
+
+/* debug function: print number of entries of all TDMA buckets */
+void tdma_sched_dump(void);
+
+
+extern int tdma_end_set(uint8_t p1, uint8_t p2, uint16_t p3);
+#define SCHED_ITEM(x, p, y, z) { .cb = x, .p1 = y, .p2 = z, .prio = p, .flags = 0 }
+#define SCHED_ITEM_DT(x, p, y, z) { .cb = x, .p1 = y, .p2 = z, .prio = p, \
+ .flags = TDMA_IFLG_TPU | TDMA_IFLG_DSP }
+#define SCHED_END_FRAME() { .cb = NULL, .p1 = 0, .p2 = 0 }
+#define SCHED_END_SET() { .cb = &tdma_end_set, .p1 = 0, .p2 = 0 }
+
+#endif /* _L1_TDMA_SCHED_H */
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/toa.h b/apps/osmocomBB/osmocomBB/include/layer1/toa.h
new file mode 100644
index 0000000000..dea9dd9657
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/toa.h
@@ -0,0 +1,10 @@
+#ifndef _L1_TOA_H
+#define _L1_TOA_H
+
+/* Input a qbits error sample into the TOA averaging */
+void toa_input(int32_t offset, uint32_t snr);
+
+/* Reset the TOA counters */
+void toa_reset(void);
+
+#endif
diff --git a/apps/osmocomBB/osmocomBB/include/layer1/tpu_window.h b/apps/osmocomBB/osmocomBB/include/layer1/tpu_window.h
new file mode 100644
index 0000000000..7b146f128b
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/layer1/tpu_window.h
@@ -0,0 +1,24 @@
+#ifndef _L1_TPU_CTRL_H
+#define _L1_TPU_CTRL_H
+
+enum l1_rxwin_type {
+ L1_RXWIN_PW, /* power measurement */
+ L1_RXWIN_FB, /* FCCH burst detection */
+ L1_RXWIN_SB, /* SCH burst detection */
+ L1_RXWIN_NB, /* Normal burst decoding */
+ _NUM_L1_RXWIN
+};
+
+enum l1_txwin_type {
+ L1_TXWIN_NB, /* Normal burst sending */
+ L1_TXWIN_AB, /* RACH burst sending */
+ _NUM_L1_TXWIN
+};
+
+void l1s_win_init(void);
+void l1s_rx_win_ctrl(uint16_t arfcn, enum l1_rxwin_type wtype, uint8_t tn_ofs);
+void l1s_tx_win_ctrl(uint16_t arfcn, enum l1_txwin_type wtype, uint8_t pwr, uint8_t tn_ofs);
+
+void tpu_end_scenario(void);
+
+#endif /* _L1_TPU_CTRL_H */