Some L1 status updates

Harald Welte laforge at gnumonks.org
Thu Jun 24 07:44:25 UTC 2010


Hi Sylvain,

On Wed, Jun 23, 2010 at 07:30:31PM +0200, Harald Welte wrote:
> > Some 'gotchas' you might encounter that are not fixed yet:
> > 
> >  - The L1 completion handler crashes.
> >    In target/firmware/layer1/prim_tx_nb.c ,
> > l1s.completion[L1_COMPL_TX_NB] is set in l1s_tx_test() but that's
> > never called. So you need to comment out
> > l1s_compl_sched(L1_COMPL_TX_NB) in the 'resp' handler temporarly until
> > a proper fix.
> 
> the proper fix is to either move all the l1s.completion[] assignments to
> l1s_init(), as they only need to be set once - or to have a initialization
> function for each primitive.  The first option requires making the completion
> functions non-static, which I would actually try to avoid.  But having an
> init callback function for each primitive that only assigns one pointer is
> probably a stupid idea, too.

I think the cleanest solution is to use __attribute__ ((constructor))
like this:

diff --git a/src/target/firmware/layer1/prim_fbsb.c b/src/target/firmware/layer1/prim_fbsb.c
index fe87996..2c58033 100644
--- a/src/target/firmware/layer1/prim_fbsb.c
+++ b/src/target/firmware/layer1/prim_fbsb.c
@@ -561,5 +561,9 @@ void l1s_fbsb_req(uint8_t base_fn, struct l1ctl_fbsb_req *req)
 	else if (fbs.req.flags & L1CTL_FBSB_F_SB)
 		tdma_schedule_set(base_fn, sb_sched_set, 0);
 
+}
+
+static __attribute__ ((constructor)) void l1s_prim_fbsb_init(void)
+{
 	l1s.completion[L1_COMPL_FB] = &l1a_fb_compl;
 }
diff --git a/src/target/firmware/layer1/prim_rach.c b/src/target/firmware/layer1/prim_rach.c
index b8fcaae..6781384 100644
--- a/src/target/firmware/layer1/prim_rach.c
+++ b/src/target/firmware/layer1/prim_rach.c
@@ -128,5 +128,9 @@ void l1a_rach_req(uint8_t fn51, uint8_t ra)
 	l1a_unlock_sync();
 
 	memset(&last_rach, 0, sizeof(last_rach));
+}
+
+static __attribute__ ((constructor)) void prim_rach_init(void)
+{
 	l1s.completion[L1_COMPL_RACH] = &l1a_rach_compl;
 }
diff --git a/src/target/firmware/layer1/prim_tx_nb.c b/src/target/firmware/layer1/prim_tx_nb.c
index 7a72ca3..b721a86 100644
--- a/src/target/firmware/layer1/prim_tx_nb.c
+++ b/src/target/firmware/layer1/prim_tx_nb.c
@@ -188,8 +188,6 @@ void l1s_tx_test(uint8_t base_fn, uint8_t type)
 		tdma_schedule(base_fn + 4, &l1s_tx_resp, 2, 2, 0);
 		tdma_schedule(base_fn + 5, &l1s_tx_resp, 2, 3, 0);
 	}
-
-	l1s.completion[L1_COMPL_TX_NB] = &l1a_tx_nb_compl;
 }
 
 /* sched sets for uplink */
@@ -203,3 +201,7 @@ const struct tdma_sched_item nb_sched_set_ul[] = {
 	SCHED_END_SET()
 };
 
+static __attribute__ ((constructor)) void prim_tx_nb_init(void)
+{
+	l1s.completion[L1_COMPL_TX_NB] = &l1a_tx_nb_compl;
+}


however, this means that our linker script and initialization code
actually supports the constructor construct.  I will take care
about this today.

-- 
- Harald Welte <laforge at gnumonks.org>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)




More information about the baseband-devel mailing list