fw/layer1: Add a 'flags' field to sched_items and the infra to use it
authorSylvain Munaut <tnt@246tNt.com>
Tue, 14 Sep 2010 19:08:19 +0000 (21:08 +0200)
committerSylvain Munaut <tnt@246tNt.com>
Fri, 17 Sep 2010 18:52:40 +0000 (20:52 +0200)
This is only preparation

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
src/target/firmware/include/layer1/tdma_sched.h
src/target/firmware/layer1/sync.c
src/target/firmware/layer1/tdma_sched.c

index 2c5873c..0c9f319 100644 (file)
@@ -22,6 +22,7 @@ struct tdma_sched_item {
        uint8_t p2;
        uint16_t p3;
        int16_t prio;
+       uint16_t flags;         /* TDMA_IFLG_xxx */
 };
 
 /* A bucket inside the TDMA scheduler */
@@ -43,6 +44,9 @@ int tdma_schedule(uint8_t frame_offset, tdma_sched_cb *cb,
 /* 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);
 
@@ -57,7 +61,7 @@ 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 }
+#define SCHED_ITEM(x, p, y, z)         { .cb = x, .p1 = y, .p2 = z, .prio = p, .flags = 0 }
 #define SCHED_END_FRAME()              { .cb = NULL, .p1 = 0, .p2 = 0 }
 #define SCHED_END_SET()                        { .cb = &tdma_end_set, .p1 = 0, .p2 = 0 }
 
index 7062fe6..233cf6e 100644 (file)
@@ -217,6 +217,8 @@ void l1s_compl_sched(enum l1_compl c)
  * generated by TPU once every TDMA frame */
 static void l1_sync(void)
 {
+       uint16_t sched_flags;
+
        putchart('+');
 
        check_lost_frame();
@@ -252,7 +254,9 @@ static void l1_sync(void)
        }
 
        /* execute the sched_items that have been scheduled for this
-        * TDMA frame */
+        * TDMA frame (including setup/cleanup steps) */
+       sched_flags = tdma_sched_flag_scan();
+
        tdma_sched_execute();
 
        if (dsp_api.r_page_used) {
index 889d9e4..013d305 100644 (file)
@@ -122,6 +122,26 @@ void tdma_sched_advance(void)
        sched->cur_bucket = next_bucket;
 }
 
+/* Scan current frame scheduled items for flags */
+uint16_t tdma_sched_flag_scan(void)
+{
+       struct tdma_scheduler *sched = &l1s.tdma_sched;
+       struct tdma_sched_bucket *bucket;
+       int i;
+       uint16_t flags = 0;
+
+       /* determine current bucket */
+       bucket = &sched->bucket[sched->cur_bucket];
+
+       /* iterate over items in this bucket and call callback function */
+       for (i=0; i<bucket->num_items; i++) {
+               struct tdma_sched_item *item = &bucket->item[i];
+               flags |= item->flags;
+       }
+
+       return flags;
+}
+
 /* Sort a bucket entries by priority */
 static void _tdma_sched_bucket_sort(struct tdma_sched_bucket *bucket, int *seq)
 {