Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1003 → Rev 1004

/shark/trunk/modules/intdrive/intdrive/inttask.h
0,0 → 1,51
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* (see the web pages for full authors list)
* Giacomo Guidi <giacomo@gandalf.sssup.it>
*
* 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
*
*/
 
 
#ifndef __INTTASK_H__
#define __INTTASK_H__
 
__BEGIN_DECLS
 
int add_interrupt_job(int no);
int intdrive_taskinit(int wcet);
void set_noint_handler(void * new_handler);
 
__END_DECLS
 
#endif
/shark/trunk/modules/intdrive/intdrive/intdrive.h
49,7 → 49,7
 
#define INTDRIVE_CHECK_WCET 1
 
LEVEL INTDRIVE_register_level(TIME capacity, TIME replenish_period, int flag);
LEVEL INTDRIVE_register_level(TIME capacity, TIME q_theta, int U, int flags);
 
/*+ Returns the used bandwidth of a level +*/
bandwidth_t INTDRIVE_usedbandwidth(LEVEL l);
/shark/trunk/modules/intdrive/intdrive.c
262,7 → 262,7
kern_gettime(&acttime);
SUBTIMESPEC(&acttime, &(lev->act_time), &time);
delta_time = TIMESPEC2USEC(&time);
mul32div32to32(delta_time, (1-lev->U), MAX_BANDWIDTH, delta_capacity);
mul32div32to32(delta_time, (MAX_BANDWIDTH-lev->U), MAX_BANDWIDTH, delta_capacity);
lev->avail -= delta_capacity;
//lev->avail -= TIMESPEC2USEC(&time);
337,7 → 337,7
/* Registration functions */
 
/*+ Registration function: +*/
LEVEL INTDRIVE_register_level(TIME capacity, TIME replenish_period, int flags)
LEVEL INTDRIVE_register_level(TIME capacity, TIME q_theta, int U, int flags)
{
LEVEL l; /* the level that we register */
INTDRIVE_level_des *lev;
363,15 → 363,16
NULL_TIMESPEC(&(lev->act_time));
 
lev->capacity = capacity;
//lev->replenish_period = replenish_period;
lev->replenish_timer = NIL;
//lev->wcet_timer = NIL;
lev->flags = flags;
lev->act_number = 0;
lev->avail = 0;
lev->q_theta = capacity;
mul32div32to32(MAX_BANDWIDTH,lev->capacity,replenish_period,lev->U);
lev->q_theta = q_theta;
mul32div32to32(MAX_BANDWIDTH,U,10000,lev->U);
 
//!!!calcolare parametro
intdrive_taskinit(10000);
 
return l;
}
 
/shark/trunk/modules/intdrive/subdir.mk
1,0 → 0,0
OBJS += intdrive/intdrive.o
OBJS += intdrive/intdrive.o intdrive/inttask.o
/shark/trunk/modules/intdrive/inttask.c
0,0 → 1,151
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* ... <......>
* (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,2002 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
*
*/
 
/* Interrupt Driver Module */
 
#include <kernel/int_sem.h>
#include <stdlib.h>
#include <kernel/func.h>
#include <ll/sys/ll/event.h>
#include <ll/i386/pic.h>
#include <tracer.h>
 
#include <intdrive/intdrive/inttask.h>
 
//#define DEBUG_SHARK_GLUE
 
PID intr_server = NIL;
void (*noint_handler)(int n);
 
#define MAX_INT_LIST 50
 
int int_list[MAX_INT_LIST];
 
int next_free_int = 0;
int next_execute_int = 0;
int n_intact = 0, n_lost = 0;
 
/* FIFO add job */
int add_interrupt_job(int no)
{
int old_free_int = next_free_int;
 
if (no<16)
irq_mask(no);
 
TRACER_LOGEVENT(FTrace_EVT_user_event_1, no, 0);
 
int_list[next_free_int] = no;
next_free_int++;
 
if (next_free_int == MAX_INT_LIST) next_free_int = 0;
if (next_free_int == next_execute_int) {
next_free_int = old_free_int;
n_lost++;
//Raise an exception?!?
return -1;
}
 
if (intr_server!=NIL)
task_activate(intr_server);
 
return 0;
}
 
/* FIFO get job */
int get_interrupt_job()
{
int res = -1;
 
if (next_free_int != next_execute_int) {
res = int_list[next_execute_int];
next_execute_int++;
if (next_execute_int == MAX_INT_LIST) next_execute_int = 0;
}
 
TRACER_LOGEVENT(FTrace_EVT_user_event_2, res, 0);
 
return res;
}
 
/* The Interrupt TASK is an aperiodic task designed for
the INTDRIVE module. */
 
TASK Interrupt_Server(void *arg)
{
void (*tmp_fast)(int n);
int no;
 
while(1) {
n_intact++;
 
no = get_interrupt_job();
 
if (no != -1 && no < 16) {
tmp_fast = handler_get_intdrive(no);
(tmp_fast)(no);
irq_unmask(no);
}
 
if (no != -1 && no >= 16) {
(noint_handler)(no);
}
 
task_endcycle();
}
 
}
 
int intdrive_taskinit(int wcet)
{
HARD_TASK_MODEL ht;
 
hard_task_default_model(ht);
hard_task_def_wcet(ht, wcet);
hard_task_def_interrupt(ht);
hard_task_def_system(ht);
hard_task_def_nokill(ht);
 
intr_server = task_create("Interrupt Server",Interrupt_Server,&ht,NULL);
if (intr_server == NIL)
return -1;
}
 
void set_noint_handler(void * new_handler)
{
noint_handler = new_handler;
}