Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1388 → Rev 1387

/demos/trunk/base/initfile.c
20,12 → 20,6
#include "modules/sem.h"
#include "modules/hartport.h"
 
#include "modules/pi.h"
#include "modules/pc.h"
#include "modules/srp.h"
#include "modules/npp.h"
#include "modules/nop.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
63,12 → 57,6
 
SEM_register_module();
 
PI_register_module();
PC_register_module();
NPP_register_module();
SRP_register_module();
NOP_register_module();
 
return TICK;
}
 
/demos/trunk/base/ego.c
18,11 → 18,11
 
/**
------------
CVS : $Id: ego.c,v 1.6 2004-04-19 14:48:05 giacomo Exp $
CVS : $Id: ego.c,v 1.5 2004-04-18 19:46:29 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.6 $
Last update: $Date: 2004-04-19 14:48:05 $
Revision: $Revision: 1.5 $
Last update: $Date: 2004-04-18 19:46:29 $
------------
**/
 
88,7 → 88,7
 
while (1) {
s[0] = talk[i][j];
grx_text(s,x,y[i],rgb16(255,255,255),0);
grx_text(s,x,y[i],12+i,0);
x += 8;
if (++j == leng) {
j = 0;
142,8 → 142,8
keyb_hook(emerg,my_end,FALSE);
 
/* a small banner */
grx_text("EGO Test",8,8,rgb16(255,255,255),0);
grx_text("Press Alt-X to exit",8,16,rgb16(255,255,255),0);
grx_text("EGO Test",8,8,WHITE,0);
grx_text("Press Alt-X to exit",8,16,WHITE,0);
 
/* ego1 creation */
hard_task_default_model(m1);
/demos/trunk/base/makefile
59,7 → 59,7
make -f $(SUBMAKE) APP=aster4 INIT= OTHEROBJS="iaster4.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
 
aster5:
make -f $(SUBMAKE) APP=aster5 INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster5 INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
 
aster6:
make -f $(SUBMAKE) APP=aster6 INIT= OTHEROBJS="iaster6.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
/demos/trunk/base/aster2.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster2.c,v 1.4 2004-04-19 14:48:04 giacomo Exp $
* CVS : $Id: aster2.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
 
this is a part of the classic Hartik demo Aster.
 
141,7 → 141,7
 
while(1) {
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1));
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
 
if (++s > 59) {
149,7 → 149,7
m++;
}
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1));
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
}
}
/demos/trunk/base/aster3.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster3.c,v 1.5 2004-04-19 14:48:04 giacomo Exp $
* CVS : $Id: aster3.c,v 1.4 2004-04-17 11:36:12 giacomo Exp $
 
Test Number 10 (A):
 
182,7 → 182,7
 
while(1) {
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1));
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
 
if (++s > 59) {
190,7 → 190,7
m++;
}
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1));
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
}
}
267,7 → 267,7
soft_task_def_ctrl_jet(m_aper);
soft_task_def_aperiodic(m_aper);
 
soft_task_def_level(m_aper, 3);
soft_task_def_level(m_aper, 2);
aper_table[0] = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (aper_table[0] == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
275,7 → 275,7
}
 
for (i=1; i<APER_MAX; i++) {
soft_task_def_level(m_aper, i/4 + 3);
soft_task_def_level(m_aper, i/4 + 2);
soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±'));
aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL);
if (aper_table[i] == -1) {
/demos/trunk/base/aster4.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster4.c,v 1.3 2004-04-19 14:48:04 giacomo Exp $
* CVS : $Id: aster4.c,v 1.2 2004-04-17 11:36:12 giacomo Exp $
 
Test Number 13 (D):
 
105,6 → 105,60
 
PID aper_table[APER_MAX];
 
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
return 0;
}
 
int device_drivers_close() {
 
KEYB26_close();
 
INPUT26_close();
 
return 0;
 
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_end();
 
return NULL;
 
}
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
TASK asteroide(void)
{
int i;
256,8 → 310,8
 
while(1) {
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1));
printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(5));
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0));
printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(4));
task_endcycle();
 
if (++s > 59) {
265,8 → 319,8
m++;
}
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1));
printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(5));
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0));
printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(4));
task_endcycle();
}
}
294,7 → 348,7
for (j=0; j<5; j++) last[j] = 0;
jet_gettable(p, &last[0], 5);
kern_cli();
if (proc_table[p].task_level == 5)
if (proc_table[p].task_level == 4)
printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d",
p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(4,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]);
else
308,7 → 362,7
 
void endfun(KEY_EVT *k)
{
sys_end();
task_activate(shutdown_task_PID);
}
 
int main(int argc, char **argv)
321,6 → 375,10
SOFT_TASK_MODEL m_soft;
int i;
 
set_shutdown_task();
 
device_drivers_init();
 
k.flag = 0;
k.scan = KEY_ENT;
k.ascii = 13;
346,7 → 404,7
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <aster> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
 
355,7 → 413,7
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <Clock> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
 
362,7 → 420,7
p3 = task_create("JetControl",jetcontrol,&m_soft,NULL);
if (p3 == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <JetControl> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
 
373,12 → 431,12
soft_task_def_aperiodic(m_aper);
 
for (i=0; i<APER_MAX; i++) {
soft_task_def_level(m_aper, i/4 + 3);
soft_task_def_level(m_aper, i/4 + 2);
soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±'));
aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL);
if (aper_table[i] == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <aper> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
}
/demos/trunk/base/aster5.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster5.c,v 1.4 2004-04-19 14:48:04 giacomo Exp $
* CVS : $Id: aster5.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
 
this is a part of the classic Hartik demo Aster.
 
55,6 → 55,8
#include "modules/edf.h"
#include "modules/cbs.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
int num_aster = 0;
94,6 → 96,60
#define ASTER_WCET 2000 /* 200*/
#endif
 
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
return 0;
}
 
int device_drivers_close() {
 
KEYB26_close();
 
INPUT26_close();
 
return 0;
 
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_end();
 
return NULL;
 
}
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
TASK asteroide(void)
{
int i;
294,7 → 350,7
while(1) {
mutex_lock(&m1);
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1));
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0));
printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2));
 
mutex_unlock(&m1);
306,7 → 362,7
}
mutex_lock(&m1);
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1));
printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(0));
printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2));
mutex_unlock(&m1);
task_endcycle();
355,7 → 411,7
 
void fine(KEY_EVT *e)
{
sys_end();
task_activate(shutdown_task_PID);
}
 
int main(int argc, char **argv)
368,6 → 424,10
// int i;
struct timespec fineprg;
 
set_shutdown_task();
 
device_drivers_init();
 
#ifdef PIMUTEX
PI_mutexattr_t a;
#endif
417,7 → 477,7
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
 
426,7 → 486,7
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
 
434,7 → 494,7
p3 = task_create("JetControl",jetcontrol,&m_soft,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
sys_end();
task_activate(shutdown_task_PID);
return 0;
}
/*
/demos/trunk/base/imdemo.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: imdemo.c,v 1.3 2004-04-19 14:48:05 giacomo Exp $
* CVS : $Id: imdemo.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $
**/
 
#include "kernel/kern.h"
41,7 → 41,7
 
#include "modules/intdrive.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/hardcbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
 
72,7 → 72,7
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
CBS_register_level(CBS_ENABLE_ALL, 1);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
dummy_register_level();
 
SEM_register_module();
/demos/trunk/base/iaster4.c
58,20 → 58,7
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
void call_shutdown_task(void *arg);
int device_drivers_init();
int device_drivers_close();
void set_shutdown_task();
TASK shutdown_task_body(void *arg);
 
PID shutdown_task_PID = 1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
96,87 → 83,8
 
HARTPORT_init();
 
/* Create the shutdown task. It will be activated at RUNLEVEL
SHUTDOWN */
set_shutdown_task();
 
/* Init the drivers */
device_drivers_init();
 
/* Set the shutdown task activation */
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
}
 
void set_shutdown_task() {
 
/* WARNING: the shutdown task is a background thread. It cannot execute
if the system is overloaded */
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
nrt_task_def_system(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
int device_drivers_init() {
 
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
INPUT26_init();
 
keyb_def_ctrlC(kparms, NULL);
 
KEYB26_init(&kparms);
 
return 0;
 
}
 
int device_drivers_close() {
KEYB26_close();
INPUT26_close();
return 0;
}
 
#define SHUTDOWN_TIMEOUT_SEC 3
 
void call_shutdown_task(void *arg)
{
struct timespec t;
 
sys_gettime(&t);
t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
 
/* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
 
task_activate(shutdown_task_PID);
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_abort_shutdown(0);
 
return NULL;
 
}
/demos/trunk/base/preempt.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: preempt.c,v 1.3 2004-04-19 14:48:05 giacomo Exp $
* CVS : $Id: preempt.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
CBS test with preemption disabling
 
108,7 → 108,7
p = task_create("save", periodic, &m_aper, NULL);
if (p == NIL)
{
sys_shutdown_message("Can't create save task...\n");
perror("Can't create save task...\n");
sys_end();
}
 
118,7 → 118,7
p = task_create("skip", periodic, &m_aper, NULL);
if (p == NIL)
{
sys_shutdown_message("Can't create skip task...\n");
perror("Can't create skip task...\n");
sys_end();
}
 
125,7 → 125,7
p = task_create("blocker", blocker, &m, NULL);
if (p == NIL)
{
sys_shutdown_message("Can't create blocker task...\n");
perror("Can't create blocker task...\n");
sys_end();
}