summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2013-01-16 23:06:59 +0100
committerSylvain Munaut <tnt@246tNt.com>2013-01-16 23:08:01 +0100
commit19d9f11c086de9ac551ec378a4a1c7b36978a5fe (patch)
tree015219f8ef9c459fa90fb63be08c1ca5f06c8092
parent14c070c9f40405f9102798fe5c400a968443cb84 (diff)
fw/l1/l23_api: Wire the L1CTL to the internal TRX interface & prim_bts
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--src/target/firmware/layer1/l23_api.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/target/firmware/layer1/l23_api.c b/src/target/firmware/layer1/l23_api.c
index 49aeb455..342196f8 100644
--- a/src/target/firmware/layer1/l23_api.c
+++ b/src/target/firmware/layer1/l23_api.c
@@ -22,6 +22,7 @@
#define DEBUG
+#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -41,6 +42,7 @@
#include <layer1/prim.h>
#include <layer1/tpu_window.h>
#include <layer1/sched_gsmtime.h>
+#include <layer1/trx.h>
#include <abb/twl3025.h>
#include <rf/trf6151.h>
@@ -586,6 +588,45 @@ static void l1ctl_sim_req(struct msgb *msg)
sim_apdu(len, data);
}
+static int l1ctl_bts_mode(struct msgb *msg)
+{
+ struct l1ctl_hdr *l1h = (struct l1ctl_hdr *) msg->data;
+ struct l1ctl_bts_mode *bm = (struct l1ctl_bts_mode *) l1h->data;
+
+ if (msg->len < (sizeof(*l1h) + sizeof(*bm))) {
+ printf("l1ctl_bts_mode: Short message. %u\n", msg->len);
+ return -EINVAL;
+ }
+
+ l1s.bts.bsic = bm->bsic;
+ l1s.bts.arfcn = ntohs(bm->band_arfcn);
+
+ l1s.tx_power = ms_pwr_ctl_lvl(gsm_arfcn2band(l1s.bts.arfcn), 15);
+
+ printf("BTS MODE: %u %u\n", l1s.bts.bsic, l1s.bts.arfcn);
+
+ if (bm->enabled) {
+ mframe_enable(MF_TASK_BTS);
+ } else {
+ mframe_disable(MF_TASK_BTS);
+ }
+
+ return 0;
+}
+
+static int l1ctl_bts_burst_req(struct msgb *msg)
+{
+ struct l1ctl_hdr *l1h = (struct l1ctl_hdr *) msg->data;
+ struct l1ctl_bts_burst_req *br = (struct l1ctl_bts_burst_req *) l1h->data;
+
+ if (msg->len < sizeof(*l1h) + sizeof(*br)) {
+ printf("l1ctl_bts_burst_req: Short message. %u\n", msg->len);
+ return -EINVAL;
+ }
+
+ return trx_put_burst(ntohl(br->fn), br->tn, br->type, br->data);
+}
+
static struct llist_head l23_rx_queue = LLIST_HEAD_INIT(l23_rx_queue);
/* callback from SERCOMM when L2 sends a message to L1 */
@@ -677,6 +718,12 @@ void l1a_l23_handler(void)
case L1CTL_SIM_REQ:
l1ctl_sim_req(msg);
break;
+ case L1CTL_BTS_MODE:
+ l1ctl_bts_mode(msg);
+ break;
+ case L1CTL_BTS_BURST_REQ:
+ l1ctl_bts_burst_req(msg);
+ break;
}
exit_msgbfree: