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>
This commit is contained in:
Sylvain Munaut 2010-09-14 21:08:19 +02:00
parent f06d54ed6f
commit 1ba04eb47b
3 changed files with 30 additions and 2 deletions

View 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 }

View 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) {

View 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)
{