Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1198 → Rev 1199

/demos/trunk/loader/parser.h
0,0 → 1,26
#ifndef __PARSER_H__
#define __PARSER_H__
 
#include <kernel/kern.h>
 
struct loader_task {
int number;
int task_level;
int task_type;
struct timespec wcet;
int exec_type;
struct timespec exec_par_1;
struct timespec exec_par_2;
struct timespec exec_par_3;
int act_type;
struct timespec act_par_1;
struct timespec act_par_2;
struct timespec act_par_3;
struct timespec act_par_4;
struct loader_task *next;
};
 
int line_parser(void);
 
#endif
 
/demos/trunk/loader/initfile.c
0,0 → 1,82
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include "drivers/keyb.h"
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
 
CABS_register_module();
 
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
__call_main__(mb);
 
return (void *)0;
}
 
/demos/trunk/loader/loader.c
0,0 → 1,11
#include <kernel/kern.h>
#include "parser.h"
 
int main()
{
 
line_parser();
 
return 0;
 
}
/demos/trunk/loader/parser.c
0,0 → 1,335
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "parser.h"
 
#define PAR_TOTAL_EXEC_TIME 0
#define PAR_TIME 2
#define PAR_ACT_TYPE 3
#define PAR_TASK_NUMBER 4
#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
 
#define PAR_EXEC_CONST 12
#define PAR_EXEC_MEAN 13
#define PAR_EXEC_EXP 14
#define PAR_EXEC_EXP_MAX 15
 
#define PAR_ACT_SINGLE 16
#define PAR_ACT_PERIODIC 17
#define PAR_ACT_MEAN 18
#define PAR_ACT_EXP 19
#define PAR_ACT_EXP_MAX 20
 
#define PAR_TASK_NRT 21
#define PAR_TASK_HARD 22
#define PAR_TASK_SOFT 23
 
#define PARSER_DEBUG
 
static int find_break(char **buf, int find_type, struct timespec *time, int *val)
{
 
int i;
char str[20];
 
i = 0;
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_TOTAL_EXEC_TIME:
if (!strncmp(*buf, "TOTAL_EXEC_TIME:",16)) {
*buf += 16;
return PAR_FOUND;
}
break;
case PAR_TIME:
if (((char *)(*buf))[0] != '[') return PAR_ERROR;
*buf += 1;
i = 0;
while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') {
str[i] = ((char *)(*buf))[i];
i++;
}
if (((char *)(*buf))[i] != ']') return PAR_ERROR;
str[i] = 0;
time->tv_sec = atoi(str);
i += 2;
*buf += i;
i = 0;
while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') {
str[i] = ((char *)(*buf))[i];
i++;
}
if (((char *)(*buf))[i] != ']') return PAR_ERROR;
str[i] = 0;
time->tv_nsec = atoi(str) * 1000;
i += 2;
*buf += i;
return PAR_FOUND;
break;
 
case PAR_TASK_TYPE:
if (!strncmp(*buf, "NRT:",4)) {
*val = PAR_TASK_NRT;
*buf += 4;
return PAR_FOUND;
}
if (!strncmp(*buf, "HARD:",5)) {
*val = PAR_TASK_HARD;
*buf += 5;
return PAR_FOUND;
}
if (!strncmp(*buf, "SOFT:",5)) {
*val = PAR_TASK_SOFT;
*buf += 5;
return PAR_FOUND;
}
break;
 
case PAR_TASK_NUMBER:
if (((char *)(*buf))[0] != '[') return PAR_ERROR;
*buf += 1;
i = 0;
while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') {
str[i] = ((char *)(*buf))[i];
i++;
}
if (((char *)(*buf))[i] != ']') return PAR_ERROR;
str[i] = 0;
*val = atoi(str);
i += 2;
*buf += i;
return PAR_FOUND;
break;
case PAR_ACT_TYPE:
if (!strncmp(*buf,"ACT_SINGLE(",11)) {
*buf += 11;
*val = PAR_ACT_SINGLE;
return PAR_FOUND;
}
if (!strncmp(*buf,"ACT_PERIODIC(",13)) {
*buf += 13;
*val = PAR_ACT_PERIODIC;
return PAR_FOUND;
}
if (!strncmp(*buf,"ACT_MEAN(",9)) {
*buf += 9;
*val = PAR_ACT_MEAN;
return PAR_FOUND;
}
if (!strncmp(*buf,"ACT_EXP(",8)) {
*buf += 8;
*val = PAR_ACT_EXP;
return PAR_FOUND;;
}
if (!strncmp(*buf,"ACT_EXP_MAX(",12)) {
*buf += 12;
*val = PAR_ACT_EXP_MAX;
return PAR_FOUND;
}
return PAR_ERROR;
break;
 
case PAR_EXEC_TYPE:
if (!strncmp(*buf,"EXEC_CONST(",11)) {
*buf += 11;
*val = PAR_EXEC_CONST;
return PAR_FOUND;
}
if (!strncmp(*buf,"EXEC_MEAN(",10)) {
*buf += 10;
*val = PAR_EXEC_MEAN;
return PAR_FOUND;
}
if (!strncmp(*buf,"EXEC_EXP(",9)) {
*buf += 9;
*val = PAR_EXEC_EXP;
return PAR_FOUND;
}
if (!strncmp(*buf,"EXEC_EXP_MAX(",13)) {
*buf += 13;
*val = PAR_EXEC_EXP_MAX;
return PAR_FOUND;
}
return PAR_ERROR;
break;
 
}
 
return PAR_ERROR;
 
}
 
void par_error(int line_num)
{
 
cprintf("\nParser error: line [%d]\n",line_num);
 
}
 
int line_parser(void)
{
char buf[1000];
char *pbuf = buf;
struct timespec time,total_exec_time;
struct loader_task ld;
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_TOTAL_EXEC_TIME, &time, &val);
if (res == PAR_FOUND) {
NULL_TIMESPEC(&total_exec_time);
res = find_break(&pbuf, PAR_TIME, &time, &val);
if (res == PAR_FOUND) {
TIMESPEC_ASSIGN(&total_exec_time,&time);
#ifdef PARSER_DEBUG
cprintf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total_exec_time.tv_sec,total_exec_time.tv_nsec);
#endif
return 0;
} else par_error(1);
}
 
res = find_break(&pbuf,PAR_TASK_TYPE, &time, &val);
if (res == PAR_FOUND) {
#ifdef PARSER_DEBUG
cprintf("TASK TYPE = %d\n",val);
#endif
ld.task_type = val;
} else par_error(1);
 
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);
 
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);
 
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;
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_1,&time);
} else par_error(1);
 
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);
}
 
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);
}
 
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);
}
 
#ifdef PARSER_DEBUG
cprintf(")\n");
#endif
 
} else par_error(1);
 
res = find_break(&pbuf,PAR_TIME, &time, &val);
if (res == PAR_FOUND) {
#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);
 
res = find_break(&pbuf,PAR_EXEC_TYPE, &time, &val);
if (res == PAR_FOUND) {
#ifdef PARSER_DEBUG
cprintf("EXEC TYPE: %d (",val);
#endif
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);
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);
}
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);
}
#ifdef PARSER_DEBUG
cprintf(")\n");
#endif
 
} else par_error(1);
 
return 0;
 
}
/demos/trunk/loader/makefile
0,0 → 1,16
#
#
#
 
ifndef BASE
BASE=../..
endif
include $(BASE)/config/config.mk
 
PROGS = loader
 
include $(BASE)/config/example.mk
 
loader:
make -f $(SUBMAKE) APP=loader INIT= OTHEROBJS="initfile.o parser.o" OTHERINCL= SHARKOPT="__OLDCHAR__"
 
/demos/trunk/loader/loadfile.txt
0,0 → 1,22
# TASK TYPE:TASK LEVEL:NUMBER OF:TASK ACTIVATION TYPE (PAR0,PAR1,...):WCET:TASK EXEC TYPE;
#
# TASK TYPE
# NRT - NON REAL TIME
# HARD - HARD REAL TIME
# SOFT - SOFT REAL TIME
#
# TASK EXEC TYPE
# EXEC_CONST(TIME) - CONSTANT EXEC TIME
# EXEC_MEAN(MEAN, DELTA) - VARIABLE EXEC TIME WITH CONSTANT DISTRIBUTION
# EXEC_EXP(MEAN, SIGMA) - VARIABLE EXEC TIME WITH EXP DISTRIBUTION
# EXEC_EXP_MAX(MEAN, SIGMA, MAX) - VARIABLE EXEC TIME WITH EXP DISTRIBUTION MAXIMIZED
#
# TASK ACTIVATION TIME
# ACT_SINGLE(START_TIME)
# ACT_PERIODIC(START_TIME, PERIOD)
# ACT_MEAN(START_TIME, MEAN, DELTA)
# ACT_EXP(START_TIME, MEAN, SIGMA)
# 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]);