L1: don't hexdump every packet we receive from L1CTL to console
[osmocom-bb.git] / src / target / firmware / layer1 / async.c
1 /* Asynchronous part of GSM Layer 1 */
2
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
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
23 #include <stdint.h>
24
25 #include <debug.h>
26 #include <arm.h>
27 #include <asm/system.h>
28
29 #include <osmocore/msgb.h>
30
31 #include <layer1/sync.h>
32 #include <layer1/async.h>
33 #include <layer1/mframe_sched.h>
34 #include <layer1/sched_gsmtime.h>
35 #include <layer1/l23_api.h>
36
37 extern const struct tdma_sched_item rach_sched_set_ul[];
38
39 /* safely enable a message into the L1S TX queue */
40 void l1a_txq_msgb_enq(struct llist_head *queue, struct msgb *msg)
41 {
42         l1a_lock_sync();
43         msgb_enqueue(queue, msg);
44         l1a_unlock_sync();
45 }
46
47 /* Enable a repeating multiframe task */
48 void l1a_mftask_enable(enum mframe_task task)
49 {
50         /* we don't need locking here as L1S only reads mframe.tasks */
51         mframe_enable(task);
52 }
53
54 /* Disable a repeating multiframe task */
55 void l1a_mftask_disable(enum mframe_task task)
56 {
57         /* we don't need locking here as L1S only reads mframe.tasks */
58         mframe_disable(task);
59 }
60
61 /* Set the mask for repeating multiframe tasks */
62 void l1a_mftask_set(uint32_t tasks)
63 {
64         /* we don't need locking here as L1S only reads mframe.tasks */
65         mframe_set(tasks);
66 }
67
68 /* Initialize asynchronous part of Layer1 */
69 void l1a_init(void)
70 {
71         l1a_l23api_init();
72 }
73
74 /* Execute pending L1A completions */
75 void l1a_compl_execute(void)
76 {
77         unsigned long flags;
78         unsigned int scheduled;
79         unsigned int i;
80
81         /* get and reset the currently scheduled tasks */
82         local_firq_save(flags);
83         scheduled = l1s.scheduled_compl;
84         l1s.scheduled_compl = 0;
85         local_irq_restore(flags);
86
87         /* Iterate over list of scheduled completions, call their
88          * respective completion handler */
89         for (i = 0; i < 32; i++) {
90                 if (!(scheduled & (1 << i)))
91                         continue;
92                 /* call completion function */
93                 l1s.completion[i](i);
94         }
95 }