1,3 → 1,4 |
#include <kernel/kern.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdio.h> |
10,7 → 11,6 |
#define PAR_EXEC_TYPE 5 |
#define PAR_TASK_TYPE 6 |
#define PAR_NOTHING 8 |
#define PAR_END 9 |
#define PAR_ERROR 10 |
#define PAR_FOUND 11 |
|
41,13 → 41,14 |
while (((char *)(*buf))[i] == ' ' || ((char *)(*buf))[i] == ':') i++; |
*buf += i; |
|
if (((char *)(*buf))[0] == '#') return PAR_NOTHING; |
|
switch (find_type) { |
|
case PAR_END: |
if (((char *)(*buf))[0] == ';' || ((char *)(*buf))[0] == '\n') return PAR_FOUND; |
break; |
|
case PAR_NOTHING: |
if (((char *)(*buf))[0] == '#' || |
((char *)(*buf))[0] == ';' || |
((char *)(*buf))[0] == 0 || |
((char *)(*buf))[0] == '\n') return PAR_FOUND; |
break; |
|
case PAR_TOTAL_EXEC_TIME: |
if (!strncmp(*buf, "TOTAL_EXEC_TIME:",16)) { |
179,30 → 180,36 |
{ |
|
cprintf("\nParser error: line [%d]\n",line_num); |
sys_end(); |
|
} |
|
int line_parser(void) |
/* result: |
* 0 -> nothing |
* 1 -> total |
* 2 -> new task-loader |
*/ |
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task *last) |
{ |
char buf[1000]; |
char *pbuf = buf; |
struct timespec time,total_exec_time; |
struct loader_task ld; |
struct timespec time; |
struct loader_task *ld = NULL; |
int val, res; |
|
sprintf(buf,"NRT:[1]:[1]:ACT_PERIODIC([13][123],[45][456]):[0][1000]:EXEC_CONST([0][10]);\n"); |
|
res = find_break(&pbuf, PAR_NOTHING, &time, &val); |
if (res == PAR_FOUND) return 0; |
|
res = find_break(&pbuf,PAR_TOTAL_EXEC_TIME, &time, &val); |
if (res == PAR_FOUND) { |
NULL_TIMESPEC(&total_exec_time); |
NULL_TIMESPEC(total); |
res = find_break(&pbuf, PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
TIMESPEC_ASSIGN(&total_exec_time,&time); |
TIMESPEC_ASSIGN(total,&time); |
#ifdef PARSER_DEBUG |
cprintf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total_exec_time.tv_sec,total_exec_time.tv_nsec); |
cprintf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total->tv_sec,total->tv_nsec); |
#endif |
return 0; |
} else par_error(1); |
return 1; |
} else par_error(line_num); |
} |
|
res = find_break(&pbuf,PAR_TASK_TYPE, &time, &val); |
210,31 → 217,44 |
#ifdef PARSER_DEBUG |
cprintf("TASK TYPE = %d\n",val); |
#endif |
ld.task_type = val; |
} else par_error(1); |
|
ld = malloc(sizeof(struct loader_task)); |
if (ld == NULL) par_error(line_num); |
|
ld->next = NULL; |
last = ld; |
|
ld->task_type = val; |
|
} else par_error(line_num); |
|
res = find_break(&pbuf,PAR_TASK_NUMBER, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf("TASK LEVEL = %d\n",val); |
#endif |
ld.task_level = val; |
} else par_error(1); |
|
ld->task_level = val; |
|
} else par_error(line_num); |
|
res = find_break(&pbuf,PAR_TASK_NUMBER, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf("TASK NUMBER = %d\n",val); |
#endif |
ld.number = val; |
} else par_error(1); |
|
ld->number = val; |
|
} else par_error(line_num); |
|
res = find_break(&pbuf,PAR_ACT_TYPE, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf("ACTIVATION TYPE: %d (",val); |
#endif |
ld.act_type = val; |
|
ld->act_type = val; |
|
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
241,38 → 261,38 |
#ifdef PARSER_DEBUG |
cprintf("[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.act_par_1,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->act_par_1,&time); |
} else par_error(line_num); |
|
if (ld.act_type != PAR_ACT_SINGLE) { |
if (ld->act_type != PAR_ACT_SINGLE) { |
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.act_par_2,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->act_par_2,&time); |
} else par_error(line_num); |
} |
|
if (ld.act_type != PAR_ACT_SINGLE && ld.act_type != PAR_ACT_PERIODIC) { |
if (ld->act_type != PAR_ACT_SINGLE && ld->act_type != PAR_ACT_PERIODIC) { |
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.act_par_3,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->act_par_3,&time); |
} else par_error(line_num); |
} |
|
if (ld.act_type != PAR_ACT_SINGLE && ld.act_type != PAR_ACT_PERIODIC && |
ld.act_type != PAR_ACT_MEAN && ld.act_type != PAR_ACT_EXP) { |
if (ld->act_type != PAR_ACT_SINGLE && ld->act_type != PAR_ACT_PERIODIC && |
ld->act_type != PAR_ACT_MEAN && ld->act_type != PAR_ACT_EXP) { |
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.act_par_4,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->act_par_4,&time); |
} else par_error(line_num); |
} |
|
#ifdef PARSER_DEBUG |
279,7 → 299,7 |
cprintf(")\n"); |
#endif |
|
} else par_error(1); |
} else par_error(line_num); |
|
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
286,8 → 306,8 |
#ifdef PARSER_DEBUG |
cprintf("WCET: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.wcet,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->wcet,&time); |
} else par_error(line_num); |
|
res = find_break(&pbuf,PAR_EXEC_TYPE, &time, &val); |
if (res == PAR_FOUND) { |
294,34 → 314,34 |
#ifdef PARSER_DEBUG |
cprintf("EXEC TYPE: %d (",val); |
#endif |
ld.exec_type = val; |
ld->exec_type = val; |
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf("[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.exec_par_1,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->exec_par_1,&time); |
} else par_error(line_num); |
|
if (ld.exec_type != PAR_EXEC_CONST) { |
if (ld->exec_type != PAR_EXEC_CONST) { |
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.exec_par_2,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->exec_par_2,&time); |
} else par_error(line_num); |
} |
|
if (ld.exec_type != PAR_EXEC_CONST && ld.exec_type != PAR_EXEC_MEAN && |
ld.exec_type != PAR_EXEC_EXP) { |
if (ld->exec_type != PAR_EXEC_CONST && ld->exec_type != PAR_EXEC_MEAN && |
ld->exec_type != PAR_EXEC_EXP) { |
res = find_break(&pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
cprintf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld.exec_par_3,&time); |
} else par_error(1); |
TIMESPEC_ASSIGN(&ld->exec_par_3,&time); |
} else par_error(line_num); |
} |
|
#ifdef PARSER_DEBUG |
328,8 → 348,9 |
cprintf(")\n"); |
#endif |
|
} else par_error(1); |
} else par_error(line_num); |
|
return 0; |
return 2; |
|
} |
|