Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1200 → Rev 1199

/demos/trunk/loader/dosread.c
File deleted
/demos/trunk/loader/dosread.h
File deleted
/demos/trunk/loader/parser.h
20,7 → 20,7
struct loader_task *next;
};
 
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task *last);
int line_parser(void);
 
#endif
 
/demos/trunk/loader/initfile.c
47,8 → 47,6
 
#include "drivers/keyb.h"
 
#include "dosread.h"
 
/*+ sysyem tick in us +*/
#define TICK 0
 
55,9 → 53,6
/*+ RR tick in us +*/
#define RRTICK 10000
 
void *start;
void *end;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
71,12 → 66,6
 
CABS_register_module();
 
dos_preload("loadfile.txt",100000,&start,&end);
 
cprintf("Start file ptr = %08lx\n",(long)(start));
cprintf("End file ptr = %08lx\n",(long)(end));
cprintf("Size = %8ld\n",(long)(end - start));
 
return TICK;
}
 
/demos/trunk/loader/loader.c
1,18 → 1,11
#include <kernel/kern.h>
#include "parser.h"
#include "dosread.h"
 
extern void *start;
extern void *end;
 
int main()
{
 
struct loader_task *start_loader_task = NULL;
struct timespec total;
line_parser();
 
line_reader(start, end, &total, start_loader_task);
 
return 0;
 
}
/demos/trunk/loader/parser.c
1,4 → 1,3
#include <kernel/kern.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
11,6 → 10,7
#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,14 → 41,13
while (((char *)(*buf))[i] == ' ' || ((char *)(*buf))[i] == ':') i++;
*buf += i;
if (((char *)(*buf))[0] == '#') return PAR_NOTHING;
 
switch (find_type) {
case PAR_NOTHING:
if (((char *)(*buf))[0] == '#' ||
((char *)(*buf))[0] == ';' ||
((char *)(*buf))[0] == 0 ||
((char *)(*buf))[0] == '\n') return PAR_FOUND;
break;
case PAR_END:
if (((char *)(*buf))[0] == ';' || ((char *)(*buf))[0] == '\n') return PAR_FOUND;
break;
 
case PAR_TOTAL_EXEC_TIME:
if (!strncmp(*buf, "TOTAL_EXEC_TIME:",16)) {
180,36 → 179,30
{
 
cprintf("\nParser error: line [%d]\n",line_num);
sys_end();
 
}
 
/* result:
* 0 -> nothing
* 1 -> total
* 2 -> new task-loader
*/
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task *last)
int line_parser(void)
{
char buf[1000];
char *pbuf = buf;
struct timespec time;
struct loader_task *ld = NULL;
struct timespec time,total_exec_time;
struct loader_task ld;
int val, res;
 
res = find_break(&pbuf, PAR_NOTHING, &time, &val);
if (res == PAR_FOUND) return 0;
 
sprintf(buf,"NRT:[1]:[1]:ACT_PERIODIC([13][123],[45][456]):[0][1000]:EXEC_CONST([0][10]);\n");
res = find_break(&pbuf,PAR_TOTAL_EXEC_TIME, &time, &val);
if (res == PAR_FOUND) {
NULL_TIMESPEC(total);
NULL_TIMESPEC(&total_exec_time);
res = find_break(&pbuf, PAR_TIME, &time, &val);
if (res == PAR_FOUND) {
TIMESPEC_ASSIGN(total,&time);
TIMESPEC_ASSIGN(&total_exec_time,&time);
#ifdef PARSER_DEBUG
cprintf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total->tv_sec,total->tv_nsec);
cprintf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total_exec_time.tv_sec,total_exec_time.tv_nsec);
#endif
return 1;
} else par_error(line_num);
return 0;
} else par_error(1);
}
 
res = find_break(&pbuf,PAR_TASK_TYPE, &time, &val);
217,44 → 210,31
#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) {
261,38 → 241,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(line_num);
TIMESPEC_ASSIGN(&ld.act_par_1,&time);
} else par_error(1);
 
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(line_num);
TIMESPEC_ASSIGN(&ld.act_par_2,&time);
} else par_error(1);
}
 
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(line_num);
TIMESPEC_ASSIGN(&ld.act_par_3,&time);
} else par_error(1);
}
 
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(line_num);
TIMESPEC_ASSIGN(&ld.act_par_4,&time);
} else par_error(1);
}
 
#ifdef PARSER_DEBUG
299,7 → 279,7
cprintf(")\n");
#endif
 
} else par_error(line_num);
} else par_error(1);
 
res = find_break(&pbuf,PAR_TIME, &time, &val);
if (res == PAR_FOUND) {
306,8 → 286,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(line_num);
TIMESPEC_ASSIGN(&ld.wcet,&time);
} else par_error(1);
 
res = find_break(&pbuf,PAR_EXEC_TYPE, &time, &val);
if (res == PAR_FOUND) {
314,34 → 294,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(line_num);
TIMESPEC_ASSIGN(&ld.exec_par_1,&time);
} else par_error(1);
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(line_num);
TIMESPEC_ASSIGN(&ld.exec_par_2,&time);
} else par_error(1);
}
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(line_num);
TIMESPEC_ASSIGN(&ld.exec_par_3,&time);
} else par_error(1);
}
#ifdef PARSER_DEBUG
348,9 → 328,8
cprintf(")\n");
#endif
 
} else par_error(line_num);
} else par_error(1);
 
return 2;
return 0;
 
}
 
/demos/trunk/loader/makefile
12,5 → 12,5
include $(BASE)/config/example.mk
 
loader:
make -f $(SUBMAKE) APP=loader INIT= OTHEROBJS="initfile.o parser.o dosread.o" OTHERINCL= SHARKOPT="__OLDCHAR__"
make -f $(SUBMAKE) APP=loader INIT= OTHEROBJS="initfile.o parser.o" OTHERINCL= SHARKOPT="__OLDCHAR__"
 
/demos/trunk/loader/loadfile.txt
19,5 → 19,4
# ACT_EXP_MAX(START_TIME, MEAN, SIGMA, MAX)
 
TOTAL_EXEC_TIME:[10][0];
HARD:[1]:[1]:ACT_PERIODIC([0][0],[1][0]):[0][10000]:EXEC_CONST([0][1000]);
 
HARD:1:1:ACT_PERIODIC([0][0],[1][0]):[0][10000]:EXEC_CONST([0][1000]);