Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1199 → Rev 1200

/demos/trunk/loader/parser.h
20,7 → 20,7
struct loader_task *next;
};
 
int line_parser(void);
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task *last);
 
#endif
 
/demos/trunk/loader/dosread.c
0,0 → 1,63
#include <kernel/kern.h>
#include <stdlib.h>
#include "parser.h"
 
int dos_preload(char *file_name, long max_size, void **start, void **end)
{
DOS_FILE* file;
void *buf;
long rd;
file = DOS_fopen(file_name,"r");
if (file == NULL) return -1;
buf = malloc(max_size);
*start = buf;
while(((rd = DOS_fread(buf, sizeof(BYTE), 2048, file)) == 2048) &&
((buf - *start + rd) < (max_size-2048))) {
buf += rd;
}
*end = buf + rd;
DOS_fclose(file);
return(0);
}
 
int line_reader(void *start, void *end, struct timespec *total, struct loader_task *start_loader_task)
{
char line_buf[1000];
char *pbuf = start;
int i,res,line_num,total_loader_task;
 
NULL_TIMESPEC(total);
 
line_num = 0;
total_loader_task = 0;
while ((void *)(pbuf) < end) {
i = 0;
line_num++;
while ((char)(pbuf[i]) != '\n') {
line_buf[i] = pbuf[i];
i++;
}
pbuf += i+1;
line_buf[i] = 0;
res = line_parser(line_buf, line_num, total, start_loader_task);
if (res == 2) {
total_loader_task++;
start_loader_task = start_loader_task->next;
}
}
 
cprintf("Total decoded lines %d\n",line_num);
cprintf("Total loader task %d\n",total_loader_task);
cprintf("Simulation time sec = %ld usec = %ld\n",total->tv_sec,total->tv_nsec/1000);
 
return 0;
 
}
/demos/trunk/loader/initfile.c
47,6 → 47,8
 
#include "drivers/keyb.h"
 
#include "dosread.h"
 
/*+ sysyem tick in us +*/
#define TICK 0
 
53,6 → 55,9
/*+ 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;
66,6 → 71,12
 
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,11 → 1,18
#include <kernel/kern.h>
#include "parser.h"
#include "dosread.h"
 
extern void *start;
extern void *end;
 
int main()
{
 
line_parser();
struct loader_task *start_loader_task = NULL;
struct timespec total;
 
line_reader(start, end, &total, start_loader_task);
 
return 0;
 
}
/demos/trunk/loader/dosread.h
0,0 → 1,10
#ifndef __DOSREAD_H__
#define __DOSREAD_H__
 
#include "parser.h"
 
int dos_preload(char *file_name, long max_size, void **start, void **end);
 
int line_reader(void *start, void *end, struct timespec *total, struct loader_task *start_loader_task);
 
#endif
/demos/trunk/loader/loadfile.txt
19,4 → 19,5
# 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]);
 
/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" OTHERINCL= SHARKOPT="__OLDCHAR__"
make -f $(SUBMAKE) APP=loader INIT= OTHEROBJS="initfile.o parser.o dosread.o" OTHERINCL= SHARKOPT="__OLDCHAR__"
 
/demos/trunk/loader/parser.c
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;
 
}