Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1150 → Rev 1151

/demos/trunk/advtimer/initfile.c
0,0 → 1,120
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@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
*/
 
/*
------------
CVS : $Id: initfile.c,v 1.1 2003-04-23 09:15:48 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2003-04-23 09:15:48 $
------------
 
System initialization file
 
This file contains the 2 functions needed to initialize the system.
 
These functions register the following levels:
 
an EDF (Earliest Deadline First) level
a RR (Round Robin) level
a CBS (Costant Bandwidth Server) level
a Dummy level
 
It can accept these task models:
 
HARD_TASK_MODEL (wcet+mit) at level 0
SOFT_TASK_MODEL (met, period) at level 1
NRT_TASK_MODEL at level 2
 
This file is similar to the configuration of kernel/init/hartik3.c
 
TICK is set to 0 (one-shot timer is used)
*/
 
/*
* 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 1000
 
/*+ 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;
 
KEYB_PARMS kparms = BASE_KEYB;
 
HARTPORT_init();
 
keyb_def_ctrlC(kparms, NULL);
keyb_def_map(kparms,itaMap);
KEYB_init(&kparms);
 
__call_main__(mb);
 
return (void *)0;
}
 
/demos/trunk/advtimer/advtimer.c
0,0 → 1,147
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@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 "ll/i386/cons.h"
 
#include "ll/sys/ll/time.h"
 
#include "drivers/keyb.h"
 
#define UPDATE_PERIOD 10000
#define UPDATE_WCET 1000
 
extern signed long long clk_per_msec;
 
extern signed long last_delta_clk_per_msec;
extern signed long total_delta_clk_per_msec;
 
extern unsigned char use_tsc;
extern unsigned char use_cmos;
 
void program_key_end(KEY_EVT *k)
{
 
sys_end();
 
}
 
TASK Update(void *arg)
{
struct timespec actual_timer;
struct timespec s_test,e_test;
long nsec,sec,min,hrs,day;
 
sys_gettime(&s_test);
sys_gettime(&e_test);
SUBTIMESPEC(&e_test,&s_test,&s_test);
 
while (1) {
sys_gettime(&actual_timer);
nsec = actual_timer.tv_nsec;
sec = actual_timer.tv_sec;
min = sec / 60;
sec %= 60;
hrs = min / 60;
min %= 60;
day = hrs / 24;
hrs %= 24;
if (use_tsc)
if (use_cmos)
printf_xy(0,4,WHITE,"Timer Mode: TSC + CMOS");
else
printf_xy(0,4,WHITE,"Timer Mode: TSC");
else
printf_xy(0,4,WHITE,"Timer Mode: 8254");
 
printf_xy(0,5,WHITE,"Actual Clk/msec: %12ld",(long)clk_per_msec);
printf_xy(0,6,WHITE,"Actual Timer: %2ld d %2ld h %2ld m %2ld s %12ld ns",day,hrs,min,sec,(long)nsec);
 
printf_xy(0,8,WHITE,"CMOS Adjustment setting");
printf_xy(0,9,WHITE,"CMOS last delta Clk/msec: %12ld",(long)last_delta_clk_per_msec);
printf_xy(0,10,WHITE,"CMOS total delta Clk/msec: %12ld",(long)total_delta_clk_per_msec);
printf_xy(0,12,WHITE,"Timer Access Delay: %12ld ns",s_test.tv_nsec/2);
task_endcycle();
 
}
 
sys_end();
}
 
void set_screen()
{
 
printf_xy(20,0,WHITE," Advanced Timer Demo ");
printf_xy(20,1,WHITE,"Giacomo Guidi <giacomo@gandalf.sssup.it>");
printf_xy(20,2,WHITE," Press Alt + c to exit ");
}
int main(int argc, char **argv)
{
HARD_TASK_MODEL mp; //Show current setting
PID update;
KEY_EVT k;
 
k.flag = ALTL_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,program_key_end);
 
clear();
 
set_screen();
 
hard_task_default_model(mp);
hard_task_def_ctrl_jet(mp);
hard_task_def_group(mp, 1);
hard_task_def_wcet(mp,UPDATE_WCET);
hard_task_def_mit(mp,UPDATE_PERIOD);
hard_task_def_usemath(mp);
update = task_create("Update", Update, &mp, NULL);
if (update != NIL) task_activate(update);
 
return 0;
 
}
/demos/trunk/advtimer/makefile
0,0 → 1,18
#
#
#
 
ifndef BASE
BASE=../..
endif
include $(BASE)/config/config.mk
 
PROGS = advtimer
 
include $(BASE)/config/example.mk
 
# Text applications
advtimer:
make -f $(SUBMAKE) APP=advtimer INIT= OTHEROBJS="initfile.o" SHARKOPT="__OLDCHAR__"