summaryrefslogtreecommitdiffstats
path: root/src/target
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-09-14 21:08:19 +0200
committerSylvain Munaut <tnt@246tNt.com>2010-09-17 20:52:40 +0200
commit1ba04eb47bb1ea0706ae553150550d5a2846dc60 (patch)
tree5cfb6524503eb8032039d0e52c325121fd740a60 /src/target
parentf06d54ed6fec78ec9c6dd106e5634b3a8c6a5220 (diff)
fw/layer1: Add a 'flags' field to sched_items and the infra to use it
This is only preparation Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/target')
-rw-r--r--src/target/firmware/include/layer1/tdma_sched.h6
-rw-r--r--src/target/firmware/layer1/sync.c6
-rw-r--r--src/target/firmware/layer1/tdma_sched.c20
3 files changed, 30 insertions, 2 deletions
diff --git a/src/target/firmware/include/layer1/tdma_sched.h b/src/target/firmware/include/layer1/tdma_sched.h
index 2c5873c0..0c9f3196 100644
--- a/src/target/firmware/include/layer1/tdma_sched.h
+++ b/src/target/firmware/include/layer1/tdma_sched.h
@@ -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 }
diff --git a/src/target/firmware/layer1/sync.c b/src/target/firmware/layer1/sync.c
index 7062fe63..233cf6ee 100644
--- a/src/target/firmware/layer1/sync.c
+++ b/src/target/firmware/layer1/sync.c
@@ -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) {
diff --git a/src/target/firmware/layer1/tdma_sched.c b/src/target/firmware/layer1/tdma_sched.c
index 889d9e44..013d305a 100644
--- a/src/target/firmware/layer1/tdma_sched.c
+++ b/src/target/firmware/layer1/tdma_sched.c
@@ -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)
{