From e32f79e69ec75c6164bdc13358079c7b5a53007d Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Wed, 16 Jan 2013 23:06:59 +0100 Subject: fw/l1/l23_api: Wire the L1CTL to the internal TRX interface & prim_bts Signed-off-by: Sylvain Munaut --- src/target/firmware/layer1/l23_api.c | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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 #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include @@ -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: -- cgit v1.2.3