/demos/tags/rel_0_3/myapp/initfile.c |
---|
File deleted |
/demos/tags/rel_0_3/myapp/mymod.c |
---|
File deleted |
/demos/tags/rel_0_3/myapp/myapp.c |
---|
File deleted |
/demos/tags/rel_0_3/myapp/readme.txt |
---|
File deleted |
/demos/tags/rel_0_3/myapp/mymod.h |
---|
File deleted |
/demos/tags/rel_0_3/myapp/makefile |
---|
File deleted |
/demos/tags/rel_0_3/myapp2/myapp.c |
---|
File deleted |
/demos/tags/rel_0_3/myapp2/readme.txt |
---|
File deleted |
/demos/tags/rel_0_3/myapp2/makefile |
---|
File deleted |
/demos/tags/rel_0_3/orbit/orbit.c |
---|
18,11 → 18,11 |
/* |
------------ |
CVS : $Id: orbit.c,v 1.1.1.1 2002-09-02 09:37:45 pj Exp $ |
CVS : $Id: orbit.c,v 1.3 2003-01-07 17:10:17 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-09-02 09:37:45 $ |
Revision: $Revision: 1.3 $ |
Last update: $Date: 2003-01-07 17:10:17 $ |
------------ |
*/ |
185,12 → 185,11 |
/* MAIN */ |
/*--------------------------------------------------------------*/ |
TASK main() |
int main() |
{ |
HARD_TASK_MODEL m; |
char c; /* carattere letto da tastiera */ |
set_exchandler_grx(); |
sys_atrunlevel(my_fine, NULL, RUNLEVEL_BEFORE_EXIT); |
sem_init(&mutex,0,1); |
/demos/tags/rel_0_3/thdemo/demo.c |
---|
137,29 → 137,9 |
} |
void demo_exc_handler(int signo, siginfo_t *info, void *extra) |
{ |
struct timespec t; |
grx_close(); |
/* Default action for an kern exception is */ |
kern_cli(); |
ll_gettime(TIME_EXACT, &t), |
kern_printf("\nHartik Exception raised!!!" |
"\nTime (s:ns) :%ld:%ld" |
"\nException number:%d" |
"\nPID :%d\n", |
t.tv_sec, t.tv_nsec, info->si_value.sival_int, |
info->si_task); |
sys_end(); |
// ll_abort(5); |
} |
void my_close(void *arg) |
{ |
grx_close(); |
// sys_status(3); |
} |
199,8 → 179,6 |
KEY_EVT k; |
struct sigaction action; |
srand(4); |
version(); |
234,18 → 212,6 |
k.ascii = 13; |
keyb_hook(k,endfun); |
/* Init the standard Hartik exception handler */ |
/* Set the signal action */ |
action.sa_flags = SA_SIGINFO; |
action.sa_sigaction = demo_exc_handler; |
action.sa_handler = 0; |
sigfillset(&action.sa_mask); /* we block all the other signals... */ |
if (sigaction(SIGHEXC, &action, NULL) == -1) { |
perror("Error initializing signals..."); |
sys_end(); |
} |
sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
/demos/tags/rel_0_3/thdemo/fftplay.c |
---|
619,7 → 619,6 |
void my_close(void *arg) |
{ |
grx_close(); |
sys_status(3); |
} |
/demos/tags/rel_0_3/tracer/small/common.c |
---|
0,0 → 1,133 |
#include <kernel/func.h> |
#include <kernel/trace.h> |
#include <fs/bdevinit.h> |
#include <fs/fsinit.h> |
#include <fs/bdev.h> |
#include <drivers/keyb.h> |
#include <trace/trace.h> |
#include <trace/queues.h> |
#include <sys/mount.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <errno.h> |
int __register_sub_init(void) |
{ |
return 0; |
} |
/* -- */ |
__dev_t root_device; |
__dev_t temp_device; |
int choose_root_callback(__dev_t dev,__uint8_t fs) |
{ |
if (fs==FS_MSDOS) return dev; |
return -1; |
} |
int choose_temp_callback(__dev_t dev,__uint8_t fs) |
{ |
static int flag=0; |
if (fs==FS_MSDOS) { |
if (flag) return dev; |
flag=1; |
} |
return -1; |
} |
/* -- */ |
extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t)); |
int __bdev_sub_init(void) |
{ |
BDEV_PARMS bdev=BASE_BDEV; |
bdev_def_showinfo(bdev,FALSE); |
bdev_init(&bdev); |
root_device=bdev_scan_devices(choose_root_callback); |
if (root_device<0) { |
cprintf("can't find root device to mount on /!!!\n"); |
sys_end(); |
return -1; |
} |
temp_device=bdev_scan_devices(choose_temp_callback); |
if (temp_device<0) { |
cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
} |
return 0; |
} |
/* -- */ |
extern int libc_initialize(void); |
int __fs_sub_init(void) |
{ |
FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
struct mount_opts opts; |
int res; |
filesystem_def_rootdevice(fs,root_device); |
filesystem_def_fs(fs,FS_MSDOS); |
filesystem_def_showinfo(fs,FALSE); |
//filesystem_init_prologue(); |
filesystem_init(&fs); |
libc_initialize(); |
if (temp_device>=0) { |
memset(&opts,0,sizeof(struct mount_opts)); |
opts.flags=MOUNT_FLAG_RW; |
res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
if (res!=0) { |
cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
} |
} |
TRC_init_phase2(); |
return 0; |
} |
/* -- */ |
void ctrlc_exit(KEY_EVT *k) |
{ |
extern void dump_sem_table(void); |
extern void dump_nop_table(void); |
//dump_sem_table(); |
//dump_nop_table(); |
sys_end(); |
} |
/* -- */ |
void showmessage(char *s) |
{ |
cputs(s); |
cprintf("Press [x] to begin..."); |
while (keyb_getchar()!='x'); |
cprintf("\n"); |
} |
void waitend(void) |
{ |
int c; |
cprintf("Press [x] to exit..."); |
while ((c=keyb_getchar())!='x'); |
cprintf("\n"); |
} |
/demos/tags/rel_0_3/tracer/small/treec1.c |
---|
0,0 → 1,220 |
/* |
* |
* |
* |
*/ |
#include <kernel/func.h> |
#include <kernel/model.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/mount.h> |
#include <dirent.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <errno.h> |
#include <string.h> |
#include <stdlib.h> |
#include <semaphore.h> |
#include <stdio.h> |
#include <time.h> |
#include "common.h" |
#include <trace/trace.h> |
#include <trace/queues.h> |
int noscroll=0; |
SEM console; |
#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
TASK viewdir(void *prof); |
sem_t actmutex,actsync; |
char *globpathname; |
PID globpid; |
int counter=0,actcounter=0; |
void activate_task(int prof, char *pathname) |
{ |
char tname[32]; |
NRT_TASK_MODEL m; |
PID pid; |
REPEAT: |
sem_wait(&actmutex); |
if (actcounter>=MPROC) { |
struct timespec delay; |
delay.tv_sec = 0; |
delay.tv_nsec = 10000000; |
sem_signal(&actmutex); |
nanosleep(&delay, NULL); |
goto REPEAT; |
} |
globpathname=pathname; |
counter++; |
sprintf(tname,"tsk%i",counter); |
nrt_task_default_model(m); |
nrt_task_def_arg(m,(void*)counter); |
globpid=pid=task_create(tname,viewdir,&m,NULL); |
if (pid==-1) { |
sem_wait(&console); |
cprintf("can't create '%s'\n",tname); |
perror("can't create task"); |
sem_signal(&console); |
sys_end(); |
return; |
} |
task_activate(pid); |
sem_wait(&actsync); |
actcounter++; |
sem_signal(&actmutex); |
} |
/* |
* |
*/ |
int filecounter=0; |
TASK viewdir(void *pointer) |
{ |
struct dirent *den; |
struct stat st; |
char *str; |
DIR *d; |
int res; |
int x; |
char pathname[1024]; |
PID mypid; |
int prof=(int)pointer; |
strcpy(pathname,globpathname); |
mypid=globpid; |
sem_signal(&actsync); |
str=pathname+(x=strlen(pathname)); |
d=opendir(pathname); |
if (d==NULL) { |
sem_wait(&console); |
cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
sem_signal(&console); |
sys_end(); |
l1_exit(0); |
goto END; |
} |
while ((den=readdir(d))!=NULL) { |
if (x==1&&*pathname=='/') |
strcat(pathname,den->d_name); |
else |
strcat(strcat(pathname,"/"),den->d_name); |
sem_wait(&console); |
if (noscroll) { |
place(0,10); |
cprintf(" "); |
place(0,10); |
} |
cprintf("t%03i %s\n",prof,pathname); |
filecounter++; |
sem_signal(&console); |
if (!strcmp(den->d_name,".")) goto SKIP; |
if (!strcmp(den->d_name,"..")) goto SKIP; |
res=stat(pathname,&st); |
if (res!=0) { |
sem_wait(&console); |
cprintf("t%03i can't stat %s\n",prof,pathname); |
cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
sem_signal(&console); |
sys_end(); |
l1_exit(0); |
closedir(d); |
goto END; |
} else { |
if (S_ISDIR(st.st_mode)) { |
sem_wait(&console); |
sem_signal(&console); |
activate_task(prof,pathname); |
} |
} |
SKIP: |
*str='\0'; |
} |
closedir(d); |
END: |
sem_wait(&actmutex); |
actcounter--; |
sem_signal(&actmutex); |
return 0; |
} |
/* |
* |
*/ |
int __register_sub_init_prologue(void) |
{ |
TRC_init_phase1(NULL); |
trc_register_circular_queue(); |
trc_create_queue(TRC_CIRCULAR_QUEUE,NULL); |
return 0; |
} |
/* |
* |
*/ |
int main(int argc,char *argv[]) |
{ |
// int res; |
showmessage("This test show all filenames of a directory of an hardisk\n" |
"recursively using a soft task for every directory.\n" |
"The tracer with a circular queue is activated.\n"); |
sem_init(&console,0,1); |
sem_init(&actmutex,0,1); |
sem_init(&actsync,0,0); |
activate_task(-1,FROMDIR); |
{ |
struct timespec delay; |
delay.tv_sec = 0; |
delay.tv_nsec = 500000000; |
for(;;) { |
sem_wait(&actmutex); |
if (actcounter==0) break; |
sem_signal(&actmutex); |
nanosleep(&delay, NULL); |
} |
} |
cprintf("\nfiles: %i\n",filecounter); |
waitend(); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/treec2.c |
---|
0,0 → 1,233 |
/* |
* |
* |
* |
*/ |
#include <kernel/func.h> |
#include <kernel/model.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/mount.h> |
#include <dirent.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <errno.h> |
#include <string.h> |
#include <stdlib.h> |
#include <semaphore.h> |
#include <stdio.h> |
#include <time.h> |
#include "common.h" |
#include <trace/trace.h> |
#include <trace/queues.h> |
#define sem_signal sem_post |
int noscroll=0; |
SEM console; |
#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
TASK viewdir(void *prof); |
sem_t actmutex,actsync; |
char *globpathname; |
PID globpid; |
int counter=0,actcounter=0; |
void activate_task(int prof, char *pathname) |
{ |
char tname[32]; |
NRT_TASK_MODEL m; |
PID pid; |
REPEAT: |
sem_wait(&actmutex); |
if (actcounter>=MPROC) { |
struct timespec delay; |
delay.tv_sec = 0; |
delay.tv_nsec = 10000000; |
sem_signal(&actmutex); |
nanosleep(&delay, NULL); |
goto REPEAT; |
} |
globpathname=pathname; |
counter++; |
sprintf(tname,"tsk%i",counter); |
nrt_task_default_model(m); |
nrt_task_def_arg(m,(void*)counter); |
globpid=pid=task_create(tname,viewdir,&m,NULL); |
if (pid==-1) { |
sem_wait(&console); |
cprintf("can't create '%s'\n",tname); |
perror("can't create task"); |
sem_signal(&console); |
sys_end(); |
return; |
} |
task_activate(pid); |
sem_wait(&actsync); |
actcounter++; |
sem_signal(&actmutex); |
} |
/* |
* |
*/ |
int filecounter=0; |
TASK viewdir(void *pointer) |
{ |
struct dirent *den; |
struct stat st; |
char *str; |
DIR *d; |
int res; |
int x; |
char pathname[1024]; |
PID mypid; |
int prof=(int)pointer; |
strcpy(pathname,globpathname); |
mypid=globpid; |
sem_signal(&actsync); |
str=pathname+(x=strlen(pathname)); |
d=opendir(pathname); |
if (d==NULL) { |
sem_wait(&console); |
cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
sem_signal(&console); |
sys_end(); |
l1_exit(0); |
goto END; |
} |
while ((den=readdir(d))!=NULL) { |
if (x==1&&*pathname=='/') |
strcat(pathname,den->d_name); |
else |
strcat(strcat(pathname,"/"),den->d_name); |
sem_wait(&console); |
if (noscroll) { |
place(0,10); |
cprintf(" "); |
place(0,10); |
} |
cprintf("t%03i %s\n",prof,pathname); |
filecounter++; |
sem_signal(&console); |
if (!strcmp(den->d_name,".")) goto SKIP; |
if (!strcmp(den->d_name,"..")) goto SKIP; |
res=stat(pathname,&st); |
if (res!=0) { |
sem_wait(&console); |
cprintf("t%03i can't stat %s\n",prof,pathname); |
cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
sem_signal(&console); |
sys_end(); |
l1_exit(0); |
closedir(d); |
goto END; |
} else { |
if (S_ISDIR(st.st_mode)) { |
sem_wait(&console); |
sem_signal(&console); |
activate_task(prof,pathname); |
} |
} |
SKIP: |
*str='\0'; |
} |
closedir(d); |
END: |
sem_wait(&actmutex); |
actcounter--; |
sem_signal(&actmutex); |
return 0; |
} |
/* |
* |
*/ |
int __register_sub_init_prologue(void) |
{ |
TRC_CIRCULAR_PARMS args; |
int q; |
TRC_init_phase1(NULL); |
trc_register_circular_queue(); |
trc_circular_default_parms(args); |
trc_circular_def_onlinetask(args); |
q=trc_create_queue(TRC_CIRCULAR_QUEUE,&args); |
trc_assign_class_to_queue(TRC_CLASS_SYSTEM,q); |
trc_trace_class(TRC_CLASS_SYSTEM); |
return 0; |
} |
/* |
* |
*/ |
int main(int argc,char *argv[]) |
{ |
// int res; |
showmessage("This test show all filenames of a directory of an hardisk\n" |
"recursively using a soft task for every directory.\n" |
"The tracer with a circular queue is activated that write\n" |
"on hardisk online (while the system is running)\n"); |
sem_init(&console,0,1); |
sem_init(&actmutex,0,1); |
sem_init(&actsync,0,0); |
activate_task(-1,FROMDIR); |
//activate_task(-1,"/"); |
{ |
struct timespec delay; |
delay.tv_sec = 0; |
delay.tv_nsec = 500000000; |
for(;;) { |
sem_wait(&actmutex); |
if (actcounter==0) break; |
sem_signal(&actmutex); |
nanosleep(&delay, NULL); |
} |
} |
cprintf("\nfiles: %i\n",filecounter); |
waitend(); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/treef1.c |
---|
0,0 → 1,224 |
/* |
* |
* |
* |
*/ |
#include <kernel/func.h> |
#include <kernel/model.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/mount.h> |
#include <dirent.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <errno.h> |
#include <string.h> |
#include <stdlib.h> |
#include <semaphore.h> |
#include <stdio.h> |
#include <time.h> |
#include "common.h" |
#include <trace/trace.h> |
#include <trace/queues.h> |
#define sem_signal sem_post |
int noscroll=0; |
SEM console; |
#define MPROC ((50<(MAX_PROC-10))?50:MAX_PROC-10) |
TASK viewdir(void *prof); |
sem_t actmutex,actsync; |
char *globpathname; |
PID globpid; |
int counter=0,actcounter=0; |
void activate_task(int prof, char *pathname) |
{ |
char tname[32]; |
NRT_TASK_MODEL m; |
PID pid; |
REPEAT: |
sem_wait(&actmutex); |
if (actcounter>=MPROC) { |
struct timespec delay; |
delay.tv_sec = 0; |
delay.tv_nsec = 10000000; |
sem_signal(&actmutex); |
nanosleep(&delay, NULL); |
goto REPEAT; |
} |
globpathname=pathname; |
counter++; |
sprintf(tname,"tsk%i",counter); |
nrt_task_default_model(m); |
nrt_task_def_arg(m,(void*)counter); |
globpid=pid=task_create(tname,viewdir,&m,NULL); |
if (pid==-1) { |
sem_wait(&console); |
cprintf("can't create '%s'\n",tname); |
perror("can't create task"); |
sem_signal(&console); |
sys_end(); |
return; |
} |
task_activate(pid); |
sem_wait(&actsync); |
actcounter++; |
sem_signal(&actmutex); |
} |
/* |
* |
*/ |
int filecounter=0; |
TASK viewdir(void *pointer) |
{ |
struct dirent *den; |
struct stat st; |
char *str; |
DIR *d; |
int res; |
int x; |
char pathname[1024]; |
PID mypid; |
int prof=(int)pointer; |
strcpy(pathname,globpathname); |
mypid=globpid; |
sem_signal(&actsync); |
str=pathname+(x=strlen(pathname)); |
d=opendir(pathname); |
if (d==NULL) { |
sem_wait(&console); |
cprintf("%03i ERR: can't open dir %s\n",prof,pathname); |
cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
sem_signal(&console); |
sys_end(); |
l1_exit(0); |
goto END; |
} |
while ((den=readdir(d))!=NULL) { |
if (x==1&&*pathname=='/') |
strcat(pathname,den->d_name); |
else |
strcat(strcat(pathname,"/"),den->d_name); |
sem_wait(&console); |
if (noscroll) { |
place(0,10); |
cprintf(" "); |
place(0,10); |
} |
cprintf("t%03i %s\n",prof,pathname); |
filecounter++; |
sem_signal(&console); |
if (!strcmp(den->d_name,".")) goto SKIP; |
if (!strcmp(den->d_name,"..")) goto SKIP; |
res=stat(pathname,&st); |
if (res!=0) { |
sem_wait(&console); |
cprintf("t%03i can't stat %s\n",prof,pathname); |
cprintf("errno: %i '%s'\n",errno,strerror(errno)); |
sem_signal(&console); |
sys_end(); |
l1_exit(0); |
closedir(d); |
goto END; |
} else { |
if (S_ISDIR(st.st_mode)) { |
sem_wait(&console); |
sem_signal(&console); |
activate_task(prof,pathname); |
} |
} |
SKIP: |
*str='\0'; |
} |
closedir(d); |
END: |
sem_wait(&actmutex); |
actcounter--; |
sem_signal(&actmutex); |
return 0; |
} |
/* |
* |
*/ |
int __register_sub_init_prologue(void) |
{ |
int q; |
TRC_init_phase1(NULL); |
trc_register_fixed_queue(); |
q=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
trc_assign_class_to_queue(TRC_CLASS_SYSTEM,q); |
trc_trace_class(TRC_CLASS_SYSTEM); |
return 0; |
} |
/* |
* |
*/ |
int main(int argc,char *argv[]) |
{ |
// int res; |
showmessage("This test show all filenames of a directory of an hardisk\n" |
"recursively using a soft task for every directory.\n" |
"The tracer with a circular queue is activated.\n"); |
sem_init(&console,0,1); |
sem_init(&actmutex,0,1); |
sem_init(&actsync,0,0); |
activate_task(-1,FROMDIR); |
{ |
struct timespec delay; |
delay.tv_sec = 0; |
delay.tv_nsec = 500000000; |
for(;;) { |
sem_wait(&actmutex); |
if (actcounter==0) break; |
sem_signal(&actmutex); |
nanosleep(&delay, NULL); |
} |
} |
cprintf("\nfiles: %i\n",filecounter); |
waitend(); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/makefile |
---|
0,0 → 1,29 |
# |
# |
# |
ifndef BASE |
BASE=../../.. |
endif |
include $(BASE)/config/config.mk |
PROGS= simple hello hello1 hello2 test0 treef1 treec1 treec2 |
include $(BASE)/config/example.mk |
simple: |
make -f $(SUBMAKE) BASE=$(BASE) APP=simple OTHEROBJS=initfs.o |
hello: |
make -f $(SUBMAKE) BASE=$(BASE) APP=hello OTHEROBJS=initfs.o |
hello1: |
make -f $(SUBMAKE) BASE=$(BASE) APP=hello1 OTHEROBJS="initfs.o common.o" |
hello2: |
make -f $(SUBMAKE) BASE=$(BASE) APP=hello2 OTHEROBJS="initfs.o common.o" |
test0: |
make -f $(SUBMAKE) BASE=$(BASE) APP=test0 OTHEROBJS="initfs.o common.o" |
treef1: |
make -f $(SUBMAKE) BASE=$(BASE) APP=treef1 OTHEROBJS="initfs.o common.o" |
treec1: |
make -f $(SUBMAKE) BASE=$(BASE) APP=treec1 OTHEROBJS="initfs.o common.o" |
treec2: |
make -f $(SUBMAKE) BASE=$(BASE) APP=treec2 OTHEROBJS="initfs.o common.o" |
/demos/tags/rel_0_3/tracer/small/initfs.c |
---|
0,0 → 1,119 |
/* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: initfs.c,v 1.1 2002-11-11 07:45:05 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.1 $ |
* Last update: $Date: 2002-11-11 07:45:05 $ |
*/ |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/rr.h" |
#include "modules/cbs.h" |
#include "modules/dummy.h" |
#include "modules/sem.h" |
#include "modules/hartport.h" |
#include "modules/cabs.h" |
#include "modules/pi.h" |
#include "modules/pc.h" |
#include "modules/srp.h" |
#include "modules/npp.h" |
#include "modules/nop.h" |
#include "modules/nopm.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; |
extern int __register_sub_init_prologue(void); |
extern int __register_sub_init(void); |
__register_sub_init_prologue(); |
EDF_register_level(EDF_ENABLE_ALL); |
RR_register_level(RRTICK, RR_MAIN_YES, mb); |
CBS_register_level(CBS_ENABLE_ALL, 0); |
dummy_register_level(); |
SEM_register_module(); |
CABS_register_module(); |
PI_register_module(); |
PC_register_module(); |
NPP_register_module(); |
SRP_register_module(); |
NOP_register_module(); |
NOPM_register_module(); |
__register_sub_init(); |
return TICK; |
} |
TASK __init__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
KEYB_PARMS keyb = BASE_KEYB; |
extern int __bdev_sub_init(void); |
extern int __fs_sub_init(void); |
extern void ctrlc_exit(KEY_EVT *k); |
HARTPORT_init(); |
keyb_def_ctrlC(keyb, ctrlc_exit); |
KEYB_init(&keyb); |
__bdev_sub_init(); |
__fs_sub_init(); |
__call_main__(mb); |
return (void *)0; |
} |
/demos/tags/rel_0_3/tracer/small/test0.c |
---|
0,0 → 1,71 |
/* |
* |
* |
* |
*/ |
#include <kernel/func.h> |
#include <fs/bdevinit.h> |
#include <fs/fsinit.h> |
#include <fs/bdev.h> |
#include <drivers/keyb.h> |
#include <sys/mount.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <errno.h> |
#include <string.h> |
#include "common.h" |
#define FILENAME "/TEMP/ALFA1.TXT" |
#include <trace/trace.h> |
#include <trace/queues.h> |
int __register_sub_init_prologue(void) |
{ |
TRC_init_phase1(NULL); |
trc_register_fixed_queue(); |
trc_create_queue(TRC_FIXED_QUEUE,NULL); |
return 0; |
} |
int main(int argc,char *argv[]) |
{ |
int h; |
showmessage("A file is opened for reading while the tracer\n" |
"with a fixed queue is runnig\n"); |
cprintf("OPENING %s\n",FILENAME); |
h=open(FILENAME,O_RDONLY); |
if (h>=0) { |
char buffer[128]; |
int len; |
cprintf("OPENED!\n"); |
cprintf("READING...\n"); |
len=read(h,buffer,sizeof(buffer)); |
cprintf("READ %i bytes\n",len); |
memset(buffer,'\0',sizeof(buffer)); |
cprintf("buffer='%s'\n",buffer); |
cprintf("READING...\n"); |
len=read(h,buffer,sizeof(buffer)); |
cprintf("READ %i bytes\n",len); |
memset(buffer,'\0',sizeof(buffer)); |
cprintf("buffer='%s'\n",buffer); |
close(h); |
} else |
cprintf("FAILED!\n"); |
waitend(); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/hello.c |
---|
0,0 → 1,209 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Massimiliano Giorgi |
* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: hello.c,v 1.1 2002-10-21 09:12:35 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.1 $ |
* Last update: $Date: 2002-10-21 09:12:35 $ |
*/ |
/* |
* Example of tracer initialization. |
*/ |
#include <ll/i386/cons.h> |
#include <kernel/func.h> |
#include <kernel/trace.h> |
#include <fs/bdevinit.h> |
#include <fs/fsinit.h> |
#include <fs/bdev.h> |
#include <drivers/keyb.h> |
#include <trace/trace.h> |
#include <trace/queues.h> |
#include <sys/mount.h> |
#include <stddef.h> |
/* |
this example use initfs.c to initialize the system; this file define |
the following two function. |
__kernel_register_levels__(), must initialize all kernel modules, |
it has this structure: |
{ |
__register_sub_init_prologue(); |
... modules initialization.... |
__register_sub_init(); |
} |
__init__(void *arg) is called when the first task is created |
and must call the main(): |
{ |
... drivers initialization .... |
__bdev_sub_init(); |
__fs_sub_init(); |
call_main() |
} |
*/ |
/* |
* This function is called before all other modules initialization because |
* all modules that need the tracer must follow tracer initialization. |
*/ |
int __register_sub_init_prologue(void) |
{ |
/* the first functions to call... parameters can be passed */ |
TRC_init_phase1(NULL); |
/* all the tracer queues must be registrated (in this case only */ |
/* a dummy queue is initialized) */ |
trc_register_dummy_queue(); |
/* the queues must be created (only one in this example) */ |
trc_create_queue(TRC_DUMMY_QUEUE,NULL); |
/* events can be dispatch to a queue (nothing in this case) */ |
return 0; |
} |
/* |
* This function is called after all other modules initialization |
* functions... notjing to do. |
*/ |
int __register_sub_init(void) |
{ |
return 0; |
} |
__dev_t root_device; |
__dev_t temp_device; |
/* |
* Now the system is running... we have to initialize the block device |
* drivers |
*/ |
int __bdev_sub_init(void) |
{ |
BDEV_PARMS bdev=BASE_BDEV; |
/* This to initialize the block device drivers... a NULL can be passed */ |
/* to the bdev_init() functions */ |
bdev_def_showinfo(bdev,FALSE); |
bdev_init(&bdev); |
/* The following phase ca be made in several way: we must decide the */ |
/* device that we want mount as root... we use the bdev_find_byname() */ |
/* functions to find a specific device */ |
root_device=bdev_find_byname("ide/hda1"); |
if (root_device<0) { |
cprintf("can't find root device to mount on /!!!\n"); |
sys_end(); |
return -1; |
} |
/* Well, we want a device to mount into /TEMP */ |
temp_device=bdev_find_byname("ide/hdb3"); |
if (temp_device<0) { |
cprintf("can't find a filesystem to mount on /TEMP!!!\n"); |
sys_end(); |
return -1; |
} |
return 0; |
} |
/* |
* This is the real filesystem initialization! |
*/ |
int __fs_sub_init(void) |
{ |
FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
extern int libc_initialize(void); |
int res; |
struct mount_opts opts; |
/* We set the root device and call the filesystem_init() function */ |
filesystem_def_rootdevice(fs,root_device); |
filesystem_def_fs(fs,FS_MSDOS); |
filesystem_def_showinfo(fs,FALSE); |
filesystem_init(&fs); |
/* We must initialize the libC if we use it */ |
libc_initialize(); |
/* We have choose to mount the second partiotion into the /TEMP */ |
/* directory with read/write privilegies (this step is not required) */ |
if (temp_device>=0) { |
memset(&opts,0,sizeof(struct mount_opts)); |
opts.flags=MOUNT_FLAG_RW; |
res=mount(temp_device,FS_MSDOS,"/TEMP",&opts); |
if (res!=0) { |
cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno); |
} |
} |
/* NOW we call the tracer initialization phase 2!!! */ |
/* It must FOLLOW the filesystem initialization... (this function */ |
/* can be called after the call to filesystem_init() functions but */ |
/* we do it here because we want be able to write into the /TEMP */ |
/* directory! */ |
TRC_init_phase2(); |
return 0; |
} |
void ctrlc_exit(KEY_EVT *k) |
{ |
sys_end(); |
} |
int main(int argc,char *argv[]) |
{ |
cprintf("\nHello, world!\n"); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/hello1.c |
---|
0,0 → 1,27 |
/* |
* |
* |
* |
*/ |
#include <ll/i386/cons.h> |
#include <stddef.h> |
#include <trace/trace.h> |
#include <trace/queues.h> |
int __register_sub_init_prologue(void) |
{ |
TRC_init_phase1(NULL); |
trc_register_dummy_queue(); |
trc_create_queue(TRC_DUMMY_QUEUE,NULL); |
return 0; |
} |
int main(int argc,char *argv[]) |
{ |
cprintf("\nHello, world!\n"); |
cprintf("The tracer has been activated!\n"); |
cprintf("(No result are produced)\n\n"); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/hello2.c |
---|
0,0 → 1,30 |
/* |
* |
* |
* |
*/ |
#include <ll/i386/cons.h> |
#include <stddef.h> |
#include <trace/trace.h> |
#include <trace/queues.h> |
int __register_sub_init_prologue(void) |
{ |
int q; |
TRC_init_phase1(NULL); |
trc_register_fixed_queue(); |
q=trc_create_queue(TRC_FIXED_QUEUE,NULL); |
trc_assign_class_to_queue(TRC_CLASS_SYSTEM,q); |
trc_trace_class(TRC_CLASS_SYSTEM); |
return 0; |
} |
int main(int argc,char *argv[]) |
{ |
cprintf("\nHello, world!\n"); |
cprintf("The tracer has been activated! Look at the results.\n"); |
cprintf("(A fixed queue has been created)\n\n"); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/simple.c |
---|
0,0 → 1,132 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Massimiliano Giorgi |
* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: simple.c,v 1.1 2002-10-21 09:12:35 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.1 $ |
* Last update: $Date: 2002-10-21 09:12:35 $ |
*/ |
/* |
* Example of simple tracer initialization. |
*/ |
#include <ll/i386/cons.h> |
#include <kernel/func.h> |
#include <kernel/trace.h> |
#include <fs/bdevinit.h> |
#include <fs/fsinit.h> |
#include <fs/bdev.h> |
#include <drivers/keyb.h> |
#include <trace/trace.h> |
#include <sys/mount.h> |
#include <stddef.h> |
#define ROOTDEVICE "ide/hda2" |
int __register_sub_init_prologue(void) |
{ |
int res; |
/* tracer initialization phase 1 */ |
res=TRC_init_phase1_standard(); |
if (res!=0) { |
cprintf("tracer initialization error (%i)!!!\n",res); |
sys_end(); |
return -1; |
} |
return 0; |
} |
int __register_sub_init(void) |
{ |
return 0; |
} |
__dev_t root_device; |
int __bdev_sub_init(void) |
{ |
/* block device initialization */ |
bdev_init(NULL); |
/* choose root device */ |
root_device=bdev_find_byname(ROOTDEVICE); |
if (root_device<0) { |
cprintf("can't find root device to mount on /!!!\n"); |
sys_end(); |
return -1; |
} |
return 0; |
} |
int __fs_sub_init(void) |
{ |
FILESYSTEM_PARMS fs=BASE_FILESYSTEM; |
extern int libc_initialize(void); |
/* filesystems initialization */ |
filesystem_def_rootdevice(fs,root_device); |
filesystem_def_fs(fs,FS_MSDOS); |
filesystem_def_showinfo(fs,FALSE); |
filesystem_init(&fs); |
/* libC initialization */ |
libc_initialize(); |
/* tracer initialization phase 2 */ |
TRC_init_phase2_standard(); |
return 0; |
} |
void ctrlc_exit(KEY_EVT *k) |
{ |
sys_end(); |
} |
int main(int argc,char *argv[]) |
{ |
cprintf("\nSimple hello world (with tracer)!\n\n"); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/small/readme |
---|
0,0 → 1,27 |
This directory contains a set of tests that uses the Shark Filesystem and the tracer |
treef1 - the test shows all filenames of a directory of an hardisk |
recursively using a soft task for every directory. |
The tracer with a circular queue is activated. |
treec2 - the test shows all filenames of a directory of an hardisk |
recursively using a soft task for every directory. |
The tracer with a circular queue is activated that write |
on hardisk online (while the system is running). |
treec1 - This test show all filenames of a directory of an hardisk |
recursively using a soft task for every directory. |
The tracer with a circular queue is activated. |
test0 - A file is opened for reading while the tracerwith a fixed |
queue is runnig. |
simple - Simple hello world (with tracer)! |
hello - another hello world... |
hello1 - another hello world with a dummy queue... |
hello2 - another hello world with a fixed queue... |
PJ |
/demos/tags/rel_0_3/tracer/small/common.h |
---|
0,0 → 1,28 |
#ifndef _COMMON_H |
#define _COMMON_H |
#include <sys/types.h> |
/* |
#include <kernel/int_sem.h> |
#define SEM internal_sem_t |
#define sem_init internal_sem_init |
#define sem_signal internal_sem_post |
#define sem_wait internal_sem_wait |
*/ |
#define SEM sem_t |
#define sem_signal sem_post |
extern __dev_t root_device; |
extern __dev_t temp_device; |
int choose_temp_callback(__dev_t dev,__uint8_t fs); |
void showmessage(char *s); |
void waitend(void); |
#define FROMDIR "/TEMP" |
#endif |
/demos/tags/rel_0_3/tracer/makefile |
---|
0,0 → 1,11 |
.PHONY: all clean |
all: |
make -C dfixed |
make -C small |
make -C udp |
clean: |
make -C dfixed clean |
make -C small clean |
make -C udp clean |
/demos/tags/rel_0_3/tracer/utils/makefile |
---|
0,0 → 1,70 |
# |
# util -> compiles the tracer utilities under MSDOS/DJGPP |
# util_linux -> compiles the tracer utilities under Linux |
# |
ifndef BASE |
BASE=../../.. |
endif |
.PHONY: util_dos util_linux clean |
all: |
@echo Targets: util_dos util_linux clean |
@echo Note: udpdump is available only under linux |
util_dos: tdump.exe jdump.exe sa.exe road.exe wait.exe |
tdump.exe: tdump.c util.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace tdump.c util.c -o tdump.exe |
jdump.exe: jdump.c util.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace jdump.c util.c -o jdump.exe |
sa.exe: sa.c util.c distr.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace sa.c util.c -o sa.exe |
road.exe: road.c util.c distr.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace road.c util.c -o road.exe |
wait.exe: wait.c util.c distr.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace wait.c util.c -o wait.exe |
util_linux: jdump tdump sa road wait udpdump |
jdump: jdump.c util.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace jdump.c util.c -o jdump |
tdump: tdump.c util.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace tdump.c util.c -o tdump |
sa: sa.c util.c distr.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace sa.c util.c -o sa |
road: road.c util.c distr.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace road.c util.c -o road |
wait: wait.c util.c distr.c |
gcc -s -Wimplicit-function-declaration -Wall \ |
-I$(BASE)/include/trace wait.c util.c -o wait |
udpdump: udpdump.c util.c |
gcc -Wimplicit-function-declaration -Wall -ggdb\ |
-I$(BASE)/include/trace udpdump.c util.c -o udpdump |
clean: |
rm -rf *.o jdump tdump sa road wait tdump.exe jdump.exe sa.exe road.exe wait.exe |
/demos/tags/rel_0_3/tracer/utils/udpdump.c |
---|
0,0 → 1,216 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* Copyright (C) 2002 Paolo Gai |
* Copyright (C) 2002 Tomas Lenvall |
* |
* 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 |
* |
* CVS : $Id: udpdump.c,v 1.1 2002-10-28 08:07:32 pj Exp $ |
*/ |
/* this example simply prints a Shark trace file */ |
// INCLUDES |
#include <netinet/in.h> |
#include "types.h" |
#include "trace.h" |
#include "util.h" |
#include <sys/socket.h> |
#include <netinet/in.h> |
#include <arpa/inet.h> |
#include <netdb.h> |
#include <stdio.h> |
#include <unistd.h>/* close() */ |
#include <string.h> /* memset() */ |
#include <stdlib.h> |
// GLOBALS |
char server_ipaddr[20]; // Store the IP adress of the server |
// DEFINES |
#define LOCAL_SERVER_PORT 20000 |
#define MAX_MSG 10000 |
// FUNCTIONS |
/* */ |
int dumpsys(trc_system_event_t *sys) |
{ |
printf("%02i\n",sys->task); |
return 0; |
} |
/* */ |
int dumpusr(trc_user_event_t *usr) |
{ |
printf("%8li ",usr->n); |
printf("\n"); |
return 0; |
} |
/* */ |
int dumpsem(trc_sem_event_t *sem) |
{ |
printf("on [%i]\n",sem->id); |
return 0; |
} |
/* */ |
int dumpfunc(trc_event_t *ev) |
{ |
static int counter=0; |
printf("\t%4i ",counter); |
counter++; |
printf("%12s ",format_time(ev->time)); |
printf("%-10s ",event_name(ev->event)); |
//printf("%08x\n",(unsigned)ev->sys.event); |
//return 0; |
switch(event_class(ev->event)) { |
case TRC_CLASS_SYSTEM: return dumpsys(&ev->x.sys); |
case TRC_CLASS_USER: return dumpusr(&ev->x.usr); |
case TRC_CLASS_SEM: return dumpsem(&ev->x.sem); |
} |
printf("\nEVENT %i... CLASS %i UNKNOWN!\n",ev->event,event_class(ev->event)); |
return -1; |
} |
/* Use UDP/IP to receive the events from the client computer */ |
int main(int argc, char *argv[]) |
{ |
int sd, rc, n, cliLen; |
struct sockaddr_in cliAddr, servAddr; |
char msg[MAX_MSG]; |
// socket creation |
sd = socket(AF_INET, SOCK_DGRAM, 0); |
if(sd < 0) { |
printf("%s: cannot open socket \n",argv[0]); |
exit(1); |
} |
// bind local server port |
servAddr.sin_family = AF_INET; |
servAddr.sin_addr.s_addr = htonl(INADDR_ANY); |
servAddr.sin_port = htons(LOCAL_SERVER_PORT); |
rc = bind (sd, (struct sockaddr *)&servAddr,sizeof(servAddr)); |
if(rc < 0) { |
printf("%s: cannot bind port number %d \n", |
argv[0], LOCAL_SERVER_PORT); |
exit(1); |
} |
while(1){ |
// init buffer |
memset(msg, 0x0, MAX_MSG); |
// receive message |
cliLen = sizeof(cliAddr); |
n = recvfrom(sd, msg, MAX_MSG, 0,(struct sockaddr *)&cliAddr, &cliLen); |
printf("Packet received, length %d, %d tracer events.\n", n, |
*((short int *)msg)); |
if(n < 0) { |
printf("%s: cannot receive data \n",argv[0]); |
continue; |
} |
// Read the trace we got from the network |
read_udp_trace(msg, dumpfunc); |
} |
return 0; |
} |
// test main: testing this program from a file (simulating a network package) |
// ONLY USED FOR TESTING!!! |
/*int main(int argc, char *argv[]) |
{ |
FILE* fin; |
int nr_of_events = 0; |
trc_event_t buffer; |
char all_events[1000]; |
char tmpbuf[2]; |
if(argc != 2) { |
printf("Missing filename!\n"); |
return -1; |
} |
// open the file and send event by event |
fin = fopen(argv[1], "r"); |
if (fin == NULL) { |
printf("Cannot open file\n"); |
return -1; |
} |
// check how many events |
while (!feof(fin)) { |
fread(&buffer, sizeof(trc_event_t), 1, fin); |
nr_of_events++; |
} |
//printf("Nr of events: %d\n", nr_of_events); |
rewind(fin); // start from the beginning again... |
//strncpy(tmpbuf, itoa(nr_of_events), 2); |
sprintf(tmpbuf, "%d", nr_of_events); |
//printf("tmpbuf: %s\n", tmpbuf); |
memset(all_events, 0, 1000); |
memcpy(all_events, tmpbuf, 2); |
printf("all_events(1): %s\n", all_events); |
// read all tracer events and store them in an array |
fread(all_events + 2, sizeof(trc_event_t), nr_of_events, fin); |
fclose(fin); |
printf("all_events(2): %s\n", all_events); |
// send it to the event reader |
read_trace(all_events, dumpfunc); |
return 1; |
} |
*/ |
/demos/tags/rel_0_3/tracer/utils/util.h |
---|
0,0 → 1,58 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* Copyright (C) 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 |
* |
* CVS : $Id: util.h,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
#ifndef __UTIL_H |
#define __UTIL_H |
#include "types.h" |
char *event_name(int evt); |
char *event_hexdump(u_int8_t *ptr, int maxsize); |
char *event_strdump(u_int8_t *ptr, int maxsize); |
int event_class(int evt); |
int read_trace(char *filename,int (*func)(trc_event_t *)); |
int read_udp_trace(void *msg, int (*func)(trc_event_t *)); |
char *format_time(long time); |
#endif |
/demos/tags/rel_0_3/tracer/utils/sa.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> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* |
* 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 |
* |
* CVS : $Id: sa.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
#include <netinet/in.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include "types.h" |
#include <trace.h> |
#include "util.h" |
/* this file prints the distribution of (schedule_time - arrival_time) */ |
#define MAXX 50 |
#define PREC 100 |
#define DELTA ((double)MAXX/(double)PREC) |
#include "distr.c" |
int task; |
long a=-1; |
long s; |
int safunc(trc_event_t *ev) |
{ |
if (event_class(ev->event)!=TRC_CLASS_SYSTEM) return 0; |
if (ev->x.sys.task!=task) return 0; |
if (a==-1) { |
if (ev->event==TRC_ACTIVATE||ev->event==TRC_INTACTIVATION) |
a=ev->time; |
} else { |
if (ev->event==TRC_SCHEDULE) { |
s=ev->time; |
d_insert(s-a); |
a=-1; |
} |
} |
return 0; |
} |
/* -- */ |
int main(int argc, char *argv[]) |
{ |
int res; |
if (argc!=4) { |
fprintf(stderr,"usage: sa [tracefile] [pid] [outputfile]\n"); |
return -1; |
} |
d_init(); |
task=atoi(argv[2]); |
res=read_trace(argv[1],safunc); |
if (res==0) { |
FILE *fout; |
fout=fopen(argv[3],"wt"); |
if (fout==NULL) { |
fprintf(stderr,"error writing output file!\n"); |
return 0; |
} |
d_dump(fout); |
fclose(fout); |
} |
if (res!=0) { |
fprintf(stderr,"error=%i\n",res); |
perror("ERROR"); |
} |
return 0; |
} |
/demos/tags/rel_0_3/tracer/utils/wait.c |
---|
0,0 → 1,95 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* |
* 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 |
* |
* CVS : $Id: wait.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include "types.h" |
#include <trace.h> |
#include "util.h" |
/* This demo computes the distribution of the wait times on disk requests */ |
#define MAXX 37000 |
#define PREC 37000 |
#define DELTA ((double)MAXX/(double)PREC) |
#include "distr.c" |
int task; |
long a=-1; |
int waitfunc(trc_event_t *ev) |
{ |
if (event_class(ev->event)!=TRC_CLASS_USER) return 0; |
if (ev->x.usr.n!=task) return 0; |
if (ev->event==TRC_USER1) { |
a=ev->time; |
return 0; |
} |
if (ev->event==TRC_USER2) { |
if (a!=-1) d_insert(ev->time-a); |
a=-1; |
} |
return 0; |
} |
int main(int argc, char *argv[]) |
{ |
FILE *fout; |
int res; |
if (argc!=4) { |
fprintf(stderr,"missing filename!\n"); |
return -1; |
} |
d_init(); |
task=atoi(argv[2]); |
res=read_trace(argv[1],waitfunc); |
if (res==0) { |
fout=fopen(argv[3],"wt"); |
if (fout!=NULL) { |
d_dump(fout); |
fclose(fout); |
} else |
fprintf(stderr,"can't create output file!\n"); |
} else |
fprintf(stderr,"read_trace error\n"); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/utils/distr.c |
---|
0,0 → 1,83 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* |
* 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 |
* |
* CVS : $Id: distr.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
long t[PREC]; |
long counter; |
long hoops; |
long maxv=0; |
void d_init(void) |
{ |
int i; |
hoops=counter=0; |
for (i=0;i<PREC;i++) t[i]=0; |
} |
void d_insert(long d) |
{ |
if (d>=MAXX) { |
hoops++; |
if (d>maxv) maxv=d; |
return; |
} |
counter++; |
t[(int)(d/DELTA)]++; |
} |
void d_dump(FILE *fout) |
{ |
int i; |
if (counter==0) { |
fprintf(stderr,"nothing to write to the output file\n"); |
return; |
} |
if (hoops) { |
fprintf(stderr,"%li values to big (max=%li)\n",hoops,maxv); |
} |
for (i=0;i<PREC;i++) |
fprintf(fout,"%f %f\n", |
DELTA/2.0+DELTA*i, |
(double)t[i]/(double)counter |
); |
} |
/demos/tags/rel_0_3/tracer/utils/road.c |
---|
0,0 → 1,96 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* |
* 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 |
* |
* CVS : $Id: road.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include "types.h" |
#include <trace.h> |
#include "util.h" |
/* this test prints the distribution of the HD seeks */ |
#define MAXX 1000 |
#define PREC 1000 |
#define DELTA ((double)MAXX/(double)PREC) |
#include "distr.c" |
int dumpusr(int event, trc_user_event_t *usr) |
{ |
static long last=-1; |
long d; |
if (event!=TRC_USER0) return 0; |
if (last!=-1) { |
d=abs(last-usr->n); |
d_insert(d); |
} |
last=usr->n; |
return 0; |
} |
int dumpfunc(trc_event_t *ev) |
{ |
if (event_class(ev->event)==TRC_CLASS_USER) dumpusr(ev->event,&ev->x.usr); |
return 0; |
} |
int main(int argc, char *argv[]) |
{ |
FILE *fout; |
int res; |
if (argc!=3) { |
fprintf(stderr,"missing filename!\n"); |
return -1; |
} |
d_init(); |
res=read_trace(argv[1],dumpfunc); |
if (res==0) { |
fout=fopen(argv[2],"wt"); |
if (fout!=NULL) { |
d_dump(fout); |
fclose(fout); |
} else |
fprintf(stderr,"can't create output file!\n"); |
} else |
fprintf(stderr,"read_trace error\n"); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/utils/tdump.c |
---|
0,0 → 1,115 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* Copyright (C) 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 |
* |
* CVS : $Id: tdump.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
/* this example simply prints a Shark trace file */ |
#include <netinet/in.h> |
#include <stdio.h> |
#include "types.h" |
#include <trace.h> |
#include "util.h" |
int dumpsys(trc_system_event_t *sys) |
{ |
/* |
if (sys->event==TRC_SCHEDULE) { |
//if (sys->prev!=65535) |
// printf("%02i->%02i\n",sys->prev,sys->task); |
//else |
printf("??->%02i\n",sys->task); |
return 0; |
} |
*/ |
printf("%02i\n",sys->task); |
return 0; |
} |
int dumpusr(trc_user_event_t *usr) |
{ |
printf("%8li ",usr->n); |
printf("\n"); |
return 0; |
} |
int dumpsem(trc_sem_event_t *sem) |
{ |
printf("on [%i]\n",sem->id); |
return 0; |
} |
int dumpfunc(trc_event_t *ev) |
{ |
static int counter=0; |
printf("%4i ",counter); |
counter++; |
printf("%12s ",format_time(ev->time)); |
printf("%-10s ",event_name(ev->event)); |
//printf("%08x\n",(unsigned)ev->sys.event); |
//return 0; |
switch(event_class(ev->event)) { |
case TRC_CLASS_SYSTEM: return dumpsys(&ev->x.sys); |
case TRC_CLASS_USER: return dumpusr(&ev->x.usr); |
case TRC_CLASS_SEM: return dumpsem(&ev->x.sem); |
} |
printf("\nEVENT %i... CLASS %i UNKNOWN!\n",ev->event,event_class(ev->event)); |
return -1; |
} |
int main(int argc, char *argv[]) |
{ |
int res; |
if (argc!=2) { |
fprintf(stderr,"missing filename!\n"); |
return -1; |
} |
res=read_trace(argv[1],dumpfunc); |
//fprintf(stderr,"result=%i\n",res); |
//fprintf(stderr,"size=%li\n",sizeof(trc_event_t)); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/utils/types.h |
---|
0,0 → 1,55 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* Copyright (C) 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 |
* |
* CVS : $Id: types.h,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
#ifndef __TYPES_H__ |
#define __TYPES_H__ |
#include <sys/types.h> |
/* when compiling under MSDOS, uncomment this three typedefs!!! */ |
//typedef unsigned char u_int8_t; |
//typedef unsigned short u_int16_t; |
//typedef unsigned long u_int32_t; |
#include <types.h> |
#endif |
/demos/tags/rel_0_3/tracer/utils/util.c |
---|
0,0 → 1,202 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* Copyright (C) 2002 Paolo Gai |
* Copyright (C) 2002 Tomas Lenvall |
* |
* 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 |
* |
* CVS : $Id: util.c,v 1.2 2002-10-28 08:07:32 pj Exp $ |
*/ |
#include <stdio.h> |
#include <string.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <stdlib.h> |
#include "types.h" |
#include <trace.h> |
#include <types.h> |
static char *names[]={ |
"reserved", |
"hoops", |
/*--*/ |
"create", |
"activate", |
"schedule", |
"delay", |
"sleep", |
"endcycle", |
"destroy", |
"intactiv", |
/*--*/ |
"user0", |
"user1", |
"user2", |
"user3", |
"user4", |
"user5", |
"user6", |
"user7", |
/*--*/ |
"wait", |
"waitnb", |
"signal" |
}; |
int classtable[TRC_NUMCLASSES+1]={ |
TRC_F_TRACER, |
TRC_F_SYSTEM, |
TRC_F_USER, |
TRC_F_SEM, |
TRC_F_LAST |
}; |
int event_class(int ev) |
{ |
int i; |
if (ev < 0 || ev >= TRC_NUMEVENTS) |
return -1; |
for (i = 0; i < TRC_NUMCLASSES; i++) |
if (ev >= classtable[i] && ev < classtable[i+1]) |
return i; |
return -1; |
} |
char *event_name(int ev) |
{ |
if (ev<0||ev>=TRC_NUMEVENTS) return "unknown"; |
return names[ev]; |
} |
char *event_hexdump(u_int8_t *ptr,int maxsize) |
{ |
static char buffer[256]; |
int i; |
for (i=0;i<maxsize;i++) sprintf(buffer+i*2,"%02x",*(ptr+i)); |
buffer[maxsize*2]='\0'; |
return buffer; |
} |
char *event_strdump(u_int8_t *ptr, int maxsize) |
{ |
static char buffer[256]; |
memcpy(buffer,ptr,maxsize); |
buffer[maxsize]='\0'; |
return buffer; |
} |
char *format_time(long time) |
{ |
static char buffer[256]; |
if (time<1000l) { |
sprintf(buffer,"%li",time); |
return buffer; |
} |
if (time<1000000l) { |
sprintf(buffer,"%li,%03li",time/1000l,time%1000l); |
return buffer; |
} |
sprintf(buffer,"%li,%03li,%03li", |
(time/1000000l), |
(time%1000000l)/1000l, |
time%1000l); |
return buffer; |
} |
#ifndef O_BINARY |
#define O_BINARY 0 |
#endif |
int read_trace(char *filename,int (*func)(trc_event_t *)) |
{ |
trc_event_t buffer; |
int fin; |
int res; |
fin=open(filename,O_RDONLY|O_BINARY); |
if (fin==-1) return -1; |
for (;;) { |
res=read(fin,&buffer,sizeof(trc_event_t)); |
if (res!=sizeof(trc_event_t)) { |
close(fin); |
return res==0?0:-2; |
} |
res=(*func)(&buffer); |
if (res!=0) { |
close(fin); |
return res; |
} |
} |
close(fin); |
return 0; |
} |
/* reads trace events from a udp message */ |
int read_udp_trace(char *msg, int (*func)(trc_event_t *)) |
{ |
short int events; // temporary storage of nr of events |
int res; |
/* message: |
|2 bytes=nr of events|12 bytes=event 0|12 bytes=event 1|... |
Note: the size of an event depends on the extra informations that |
are put on the trc_event_t data structures. That size is |
currently 12 bytes, but it can change if additional fields are |
added to the trc_event_t structure. Including the |
include/trace/types.h header ensures that the size used in this |
application is coherent with the size of the compiled Shark |
applications... |
*/ |
events = *((short int *)msg); |
msg += 2; // skip the 2 first bytes |
for (; |
events > 0; |
events--, msg += sizeof(trc_event_t)) |
res = (*func)((trc_event_t *)msg); |
return 1; |
} |
/demos/tags/rel_0_3/tracer/utils/jdump.c |
---|
0,0 → 1,466 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/* |
* Copyright (C) 1999 Massimiliano Giorgi |
* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: jdump.c,v 1.2 2002-10-22 10:07:51 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.2 $ |
* Last update: $Date: 2002-10-22 10:07:51 $ |
*/ |
#include <netinet/in.h> |
#include <stdio.h> |
#include <string.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include "types.h" |
#include <trace.h> |
#include "util.h" |
/* |
* |
* This filter converts trace file formats from SHARK to JTRACER |
* |
*/ |
/* All times are dived by this costant. */ |
#define TIMESCALE 1 |
/* If defined dump on stdout the packets (in ascii) that will be written |
* on the output file (the file of the tracer). |
*/ |
#define DUMPOUT |
/* |
* |
* |
* |
*/ |
int pippo=0; |
int writeInt(int h, int x) |
{ |
int y,res; |
y=htonl(x); |
res=write(h,&y,sizeof(int)); |
return res!=sizeof(int); |
} |
int writeStr(int h, char *s) |
{ |
int res,size; |
size=strlen(s); |
writeInt(h,size); |
res=write(h,s,size); |
return res!=size; |
} |
/* |
* |
*/ |
#define TASK_ARRIVAL 0 |
#define TASK_SCHEDULE 1 |
#define TASK_DESCHEDULE 2 |
#define TASK_END 3 |
#define TASK_DLINEPOST 4 |
#define TASK_DLINESET 5 |
#define TASK_WAIT 6 |
#define TASK_SIGNAL 7 |
#define TASK_IDLE 8 |
#define TASK_NAME 9 |
#define EVT_NUMBER 10 |
char *eventsname[]={ |
"task_arrival", |
"task_schedule", |
"task_deschedule", |
"task_end", |
"task_dlinepost", |
"task_dlineset", |
"task_wait", |
"task_signal", |
"task_idle", |
"task_name" |
}; |
struct j_evt_prolog { |
int type; |
int time; |
}; |
struct j_evt_task { |
struct j_evt_prolog p; |
int task; |
}; |
struct j_evt_dlinepost { |
struct j_evt_task t; |
int taskD; |
int taskD2; |
}; |
struct j_evt_dlineset { |
struct j_evt_task t; |
int taskD; |
}; |
struct j_evt_semaph { |
struct j_evt_task t; |
int res; |
char *name; |
}; |
struct j_evt_name { |
struct j_evt_task t; |
char *name; |
}; |
/* |
* |
*/ |
int j_write_prolog(int h, void *ptr) |
{ |
#ifdef DUMPOUT |
printf("%10i ",((struct j_evt_prolog *)ptr)->time); |
printf("%-18s ",eventsname[((struct j_evt_prolog *)ptr)->type]); |
#endif |
if (writeInt(h,((struct j_evt_prolog *)ptr)->type)) return -2; |
if (writeInt(h,((struct j_evt_prolog *)ptr)->time)) return -3; |
return 0; |
} |
int j_write_task(int h, void *ptr) |
{ |
int res; |
res=j_write_prolog(h,ptr); |
#ifdef DUMPOUT |
printf("tsk=%i ",((struct j_evt_task *)ptr)->task); |
#endif |
if (res) return res; |
if (writeInt(h,((struct j_evt_task *)ptr)->task)) return -4; |
return 0; |
} |
int j_write_dlinepost(int h, void *ptr) |
{ |
int res; |
res=j_write_task(h,ptr); |
if (res) return res; |
if (writeInt(h,((struct j_evt_dlinepost *)ptr)->taskD)) return -5; |
if (writeInt(h,((struct j_evt_dlinepost *)ptr)->taskD2)) return -6; |
return 0; |
} |
int j_write_dlineset(int h, void *ptr) |
{ |
int res; |
res=j_write_task(h,ptr); |
if (res) return res; |
if (writeInt(h,((struct j_evt_dlineset *)ptr)->taskD)) return -7; |
return 0; |
} |
int j_write_semaph(int h, void *ptr) |
{ |
int res; |
res=j_write_task(h,ptr); |
if (res) return res; |
if (writeInt(h,((struct j_evt_semaph *)ptr)->res)) return -8; |
if (writeStr(h,((struct j_evt_semaph *)ptr)->name)) return -9; |
return 0; |
} |
int j_write_name(int h, void *ptr) |
{ |
int res; |
res=j_write_task(h,ptr); |
#ifdef DUMPOUT |
printf("name='%s' ",((struct j_evt_name *)ptr)->name); |
#endif |
if (res) return res; |
if (writeStr(h,((struct j_evt_name *)ptr)->name)) return -10; |
return 0; |
} |
int writeEvent(int h, void *ptr) |
{ |
int res; |
//printf("<%i>",((struct j_evt_prolog*)ptr)->type); |
((struct j_evt_prolog*)ptr)->time/=TIMESCALE; |
switch(((struct j_evt_prolog*)ptr)->type) { |
case TASK_ARRIVAL: |
case TASK_SCHEDULE: |
case TASK_DESCHEDULE: |
case TASK_END: |
case TASK_IDLE: |
res=j_write_task(h,ptr); |
break; |
case TASK_DLINEPOST: |
res=j_write_dlinepost(h,ptr); |
break; |
case TASK_DLINESET: |
res=j_write_dlineset(h,ptr); |
break; |
case TASK_WAIT: |
case TASK_SIGNAL: |
res=j_write_semaph(h,ptr); |
break; |
case TASK_NAME: |
res=j_write_name(h,ptr); |
break; |
default: |
return -1; |
} |
#ifdef DUMPOUT |
printf(" \n"); |
#endif |
return res; |
} |
/* |
* |
* |
* |
*/ |
#define MAX_PROC 150 |
//int activated[MAX_PROC]; |
int cxx=0; |
/* write MAXC-1 events */ |
#define MAXC 10000 |
long lasttime; |
int sys_event(int h, void *param) |
{ |
static int prevtask=-1; |
trc_event_t *ptr=(trc_event_t *)param; |
struct j_evt_task evt; |
evt.p.time=ptr->time; |
evt.task=ptr->x.sys.task; |
lasttime=ptr->time; |
switch(ptr->event) { |
case TRC_CREATE: |
return 0; |
case TRC_ACTIVATE: |
case TRC_INTACTIVATION: |
//activated[ptr->x.sys.task]=1; |
evt.p.type=TASK_ARRIVAL; |
break; |
case TRC_DESTROY: |
//activated[ptr->x.sys.task]=0; |
return 0; |
case TRC_DELAY: |
prevtask=-1; |
evt.p.type=TASK_DESCHEDULE; |
break; |
case TRC_SLEEP: |
prevtask=-1; |
evt.p.type=TASK_DESCHEDULE; |
break; |
case TRC_ENDCYCLE: |
prevtask=-1; |
evt.p.type=TASK_END; |
break; |
case TRC_SCHEDULE: |
if (prevtask!=-1) { |
struct j_evt_task evt2; |
int res; |
evt2.p.time=ptr->time; |
evt2.p.type=TASK_DESCHEDULE; |
evt2.task=prevtask; |
res=writeEvent(h,&evt2); |
if (res!=0) return -1; |
} |
/* |
if (!activated[ptr->x.sys.task]) { |
struct j_evt_task evt2; |
evt2.p.time=ptr->time-1; |
evt2.task=ptr->x.sys.task; |
evt2.p.type=TASK_ARRIVAL; |
writeEvent(h,&evt2); |
activated[ptr->x.sys.task]=1; |
} |
*/ |
evt.p.type=TASK_SCHEDULE; |
prevtask=ptr->x.sys.task; |
break; |
default: |
return 0; |
} |
cxx++; |
if (cxx==MAXC) return -1; |
return writeEvent(h,&evt); |
} |
int sem_event(int h,void *param) |
{ |
//trc_event_t *ptr=(trc_event_t *)param; |
//struct j_evt_semaph evt; |
return 0; |
/* |
evt.t.p.time=ptr->x.norm.when; |
evt.t.task=ptr->x.norm.who; |
switch(ptr->what) { |
case TRC_SEM_WAIT: evt.t.p.type=TASK_WAIT; break; |
case TRC_SEM_SIGNAL: evt.t.p.type=TASK_SIGNAL; break; |
case TRC_SEM_WAITNB: return 0; |
default: return 0; |
} |
evt.res=1; |
evt.name="NoName"; |
return j_write_semaph(h,&evt); |
*/ |
} |
/* -- */ |
#define MAX_PROC 150 |
int names[MAX_PROC]; |
int outfile; |
int dumpfunc(trc_event_t *ptr) |
{ |
//printf("{%i}",ptr->event); |
if (!names[ptr->x.sys.task]) { |
struct j_evt_name evtname; |
static char name[24]; |
cxx++; |
if (cxx==MAXC) return -1; |
evtname.t.p.time=lasttime; |
evtname.t.task=ptr->x.sys.task; |
evtname.t.p.type=TASK_NAME; |
sprintf(name,"task%03i",ptr->x.sys.task); |
evtname.name=name; |
writeEvent(outfile,&evtname); |
names[ptr->x.sys.task]=1; |
} |
switch(event_class(ptr->event)) { |
case TRC_CLASS_SYSTEM: |
return sys_event(outfile,ptr); |
case TRC_CLASS_SEM: |
return 0; |
return sem_event(outfile,ptr); |
case TRC_CLASS_USER: |
return 0; |
} |
return 0; |
} |
/* |
* |
*/ |
#ifndef O_BINARY |
#define O_BINARY 0 |
#endif |
int main(int argc, char *argv[]) |
{ |
int res; |
int i; |
if (argc!=3) { |
fprintf(stderr,"missing filenames\n"); |
fprintf(stderr,"usage: jdump SHARKtracefilename JTRACERtracefilename\n"); |
return -1; |
} |
for (i=0;i<MAX_PROC;i++) { |
names[i]=0; |
//activated[i]=0; |
} |
outfile=open(argv[2],O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,0777); |
if (outfile==-1) { |
perror("can't open outfile"); |
return -1; |
} |
res=read_trace(argv[1],dumpfunc); |
close(outfile); |
//fprintf(stderr,"result=%i",res); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/utils/readme |
---|
0,0 → 1,13 |
This directory contains a set of utilities that can be used to interpret |
the tracer output: |
- tdump this example simply prints a Shark trace file |
- jdump converts trace file formats from SHARK to JTRACER |
- sa prints the distribution of (schedule_time - arrival_time) |
- road prints the distribution of the HD seeks |
- wait computes the distribution of the wait times on disk requests |
Under Linux: to compile, type "make util_linux" |
Under MSDOS: uncomment the three lines into types.h, then type "make util_dos" |
PJ |
/demos/tags/rel_0_3/tracer/udp/initfile.c |
---|
0,0 → 1,115 |
/* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: initfile.c,v 1.1 2002-10-28 08:10:10 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.1 $ |
* Last update: $Date: 2002-10-28 08:10:10 $ |
*/ |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/rr.h" |
#include "modules/cbs.h" |
#include "modules/dummy.h" |
#include "modules/sem.h" |
#include "modules/hartport.h" |
#include "modules/cabs.h" |
#include "modules/pi.h" |
#include "modules/pc.h" |
#include "modules/srp.h" |
#include "modules/npp.h" |
#include "modules/nop.h" |
#include "modules/nopm.h" |
#include "drivers/keyb.h" |
/*+ sysyem tick in us +*/ |
#define TICK 1000 |
/*+ RR tick in us +*/ |
#define RRTICK 10000 |
void mytracer_prologue(void); |
void mytracer_epilogue(void); |
TIME __kernel_register_levels__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
mytracer_prologue(); |
EDF_register_level(EDF_ENABLE_ALL); |
RR_register_level(RRTICK, RR_MAIN_YES, mb); |
CBS_register_level(CBS_ENABLE_ALL, 0); |
dummy_register_level(); |
SEM_register_module(); |
CABS_register_module(); |
PI_register_module(); |
PC_register_module(); |
NPP_register_module(); |
SRP_register_module(); |
NOP_register_module(); |
NOPM_register_module(); |
return TICK; |
} |
TASK __init__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
KEYB_PARMS keyb = BASE_KEYB; |
extern void ctrlc_exit(KEY_EVT *k); |
HARTPORT_init(); |
keyb_def_ctrlC(keyb, ctrlc_exit); |
KEYB_init(&keyb); |
mytracer_epilogue(); |
__call_main__(mb); |
return (void *)0; |
} |
/demos/tags/rel_0_3/tracer/udp/udptrace.c |
---|
0,0 → 1,160 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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 Massimiliano Giorgi |
* Copyright (C) 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 |
* |
* CVS : $Id: udptrace.c,v 1.1 2002-10-28 08:10:11 pj Exp $ |
*/ |
/* |
* Example of tracer initialization. |
*/ |
#include <ll/i386/cons.h> |
#include <kernel/func.h> |
#include <kernel/trace.h> |
#include <fs/bdevinit.h> |
#include <fs/fsinit.h> |
#include <fs/bdev.h> |
#include <drivers/keyb.h> |
#include <drivers/udpip.h> |
#include <trace/trace.h> |
#include <trace/queues.h> |
#include <sys/mount.h> |
#include <stddef.h> |
#include <string.h> |
char myipaddr[15], toipaddr[15]; |
void mytracer_prologue(void) |
{ |
int myqueue; |
TRC_PARMS p; |
TRC_UDP_PARMS u; |
UDP_ADDR local, remote; |
/* these are the IP numbers of my home PCs ;-) */ |
strcpy(myipaddr, "192.168.1.2"); |
strcpy(toipaddr, "192.168.1.1"); |
clear(); |
ip_str2addr(toipaddr,&(remote.s_addr)); |
remote.s_port = 20000; // htons is done automatically; |
ip_str2addr(myipaddr,&(local.s_addr)); |
local.s_port = 20000; // htons is done automatically; |
trc_default_parms(p); |
trc_def_path(p,""); |
trc_udp_default_parms(u,local,remote); |
/* Tracer Initialization */ |
/* the first functions to call... parameters can be passed */ |
TRC_init_phase1(&p); |
/* all the tracer queue types must be registered */ |
trc_register_udp_queue(); |
/* then, we create all the queues we need */ |
myqueue = trc_create_queue(TRC_UDP_QUEUE,&u); |
/* Then, we say that events must be sent to a particular queue */ |
trc_trace_class(TRC_CLASS_SYSTEM); |
trc_assign_class_to_queue(TRC_CLASS_SYSTEM, myqueue); |
} |
void mytracer_epilogue(void) |
{ |
struct net_model m = net_base; |
/* We want a task for TX mutual exclusion */ |
net_setmode(m, TXTASK); |
/* We use UDP/IP stack */ |
net_setudpip(m, myipaddr); |
/* OK: let's start the NetLib! */ |
if (net_init(&m) == 1) { |
cprintf("udptrace: Net Init OK...\n"); |
} else { |
cprintf("udptrace: Net Init Failed...\n"); |
sys_abort(300); |
} |
TRC_init_phase2(); |
} |
void ctrlc_exit(KEY_EVT *k) |
{ |
sys_end(); |
} |
void *mytask(void *arg) |
{ |
int i; |
for(i=0; i<10; i++) { |
cprintf("%d\n", i); |
task_endcycle(); |
} |
return 0; |
} |
int main(int argc,char *argv[]) |
{ |
SOFT_TASK_MODEL mp; |
PID pid; |
soft_task_default_model(mp); |
soft_task_def_met(mp, 10000); |
soft_task_def_period(mp,50000); |
soft_task_def_usemath(mp); |
cprintf("\nHello, world!\n"); |
pid = task_create("mytask", mytask, &mp, NULL); |
if (pid != NIL) task_activate(pid); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/udp/makefile |
---|
0,0 → 1,21 |
# |
# |
# |
ifndef BASE |
BASE=../../.. |
endif |
include $(BASE)/config/config.mk |
PROGS= udptrace |
include $(BASE)/config/example.mk |
udptrace: |
make -f $(SUBMAKE) BASE=$(BASE) APP=udptrace INIT= OTHEROBJS=initfile.o |
/demos/tags/rel_0_3/tracer/udp/readme |
---|
0,0 → 1,10 |
This is a simple test that uses the tracer. |
The example assigns the IP address 192.168.1.2 to the machine, and |
sends the tracer data to 192.168.1.1 using UDp, port 20000. |
You can use demos/tracer/utils/udpdump to get the informations. |
Enjoy, |
PJ |
/demos/tags/rel_0_3/tracer/readme |
---|
0,0 → 1,14 |
This directory contains a set of sub directories containing all the tracer |
examples and utilities. |
Here a short description of the contents |
utils - some small utilities that can read tracer files |
dfixed - a small applications that defines a tracer queue. |
At the end a file is written (using DOSFS). |
small - a set of small examples of tracer usage (using the Shark Filesystem) |
udp - a small application that sends its trace data through the network |
Enjoy |
PJ |
/demos/tags/rel_0_3/tracer/dfixed/initfile.c |
---|
0,0 → 1,115 |
/* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: initfile.c,v 1.1 2002-10-21 09:12:35 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.1 $ |
* Last update: $Date: 2002-10-21 09:12:35 $ |
*/ |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/rr.h" |
#include "modules/cbs.h" |
#include "modules/dummy.h" |
#include "modules/sem.h" |
#include "modules/hartport.h" |
#include "modules/cabs.h" |
#include "modules/pi.h" |
#include "modules/pc.h" |
#include "modules/srp.h" |
#include "modules/npp.h" |
#include "modules/nop.h" |
#include "modules/nopm.h" |
#include "drivers/keyb.h" |
/*+ sysyem tick in us +*/ |
#define TICK 1000 |
/*+ RR tick in us +*/ |
#define RRTICK 10000 |
void mytracer_prologue(void); |
void mytracer_epilogue(void); |
TIME __kernel_register_levels__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
mytracer_prologue(); |
EDF_register_level(EDF_ENABLE_ALL); |
RR_register_level(RRTICK, RR_MAIN_YES, mb); |
CBS_register_level(CBS_ENABLE_ALL, 0); |
dummy_register_level(); |
SEM_register_module(); |
CABS_register_module(); |
PI_register_module(); |
PC_register_module(); |
NPP_register_module(); |
SRP_register_module(); |
NOP_register_module(); |
NOPM_register_module(); |
return TICK; |
} |
TASK __init__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
KEYB_PARMS keyb = BASE_KEYB; |
extern void ctrlc_exit(KEY_EVT *k); |
HARTPORT_init(); |
keyb_def_ctrlC(keyb, ctrlc_exit); |
KEYB_init(&keyb); |
mytracer_epilogue(); |
__call_main__(mb); |
return (void *)0; |
} |
/demos/tags/rel_0_3/tracer/dfixed/dfixed.c |
---|
0,0 → 1,133 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Massimiliano Giorgi |
* |
* 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 |
* |
*/ |
/* |
* CVS : $Id: dfixed.c,v 1.1 2002-10-21 09:12:35 pj Exp $ |
* |
* File: $File$ |
* Revision: $Revision: 1.1 $ |
* Last update: $Date: 2002-10-21 09:12:35 $ |
*/ |
/* |
* Example of tracer initialization. |
*/ |
#include <ll/i386/cons.h> |
#include <kernel/func.h> |
#include <kernel/trace.h> |
#include <fs/bdevinit.h> |
#include <fs/fsinit.h> |
#include <fs/bdev.h> |
#include <drivers/keyb.h> |
#include <trace/trace.h> |
#include <trace/queues.h> |
#include <sys/mount.h> |
#include <stddef.h> |
void mytracer_prologue(void) |
{ |
int myqueue; |
TRC_PARMS p; |
TRC_FIXED_PARMS f; |
trc_default_parms(p); |
trc_def_path(p,""); |
trc_fixed_default_parms(f); |
trc_fixed_def_filename(f,"fixed"); |
/* Tracer Initialization */ |
/* the first functions to call... parameters can be passed */ |
TRC_init_phase1(&p); |
/* all the tracer queue types must be registered */ |
trc_register_dosfs_fixed_queue(); |
/* then, we create all the queues we need */ |
myqueue = trc_create_queue(TRC_DOSFS_FIXED_QUEUE,&f); |
/* Then, we say that events must be sent to a particular queue */ |
trc_trace_class(TRC_CLASS_SYSTEM); |
trc_assign_class_to_queue(TRC_CLASS_SYSTEM, myqueue); |
} |
void mytracer_epilogue(void) |
{ |
TRC_init_phase2(); |
} |
void ctrlc_exit(KEY_EVT *k) |
{ |
sys_end(); |
} |
void *mytask(void *arg) |
{ |
int i; |
for(i=0; i<10; i++) { |
cprintf("%d ", i); |
task_endcycle(); |
} |
return 0; |
} |
int main(int argc,char *argv[]) |
{ |
SOFT_TASK_MODEL mp; |
PID pid; |
soft_task_default_model(mp); |
soft_task_def_met(mp, 10000); |
soft_task_def_period(mp,50000); |
soft_task_def_usemath(mp); |
cprintf("\nHello, world!\n"); |
pid = task_create("mytask", mytask, &mp, NULL); |
if (pid != NIL) task_activate(pid); |
return 0; |
} |
/demos/tags/rel_0_3/tracer/dfixed/makefile |
---|
0,0 → 1,21 |
# |
# |
# |
ifndef BASE |
BASE=../../.. |
endif |
include $(BASE)/config/config.mk |
PROGS= dfixed |
include $(BASE)/config/example.mk |
dfixed: |
make -f $(SUBMAKE) BASE=$(BASE) APP=dfixed INIT= OTHEROBJS=initfile.o |
/demos/tags/rel_0_3/tracer/dfixed/readme |
---|
0,0 → 1,8 |
This is a simple test that uses the tracer. |
The example simply creates a soft task that does 10 instances and then dies. |
It uses a DOSFS Fixed queue to write the output on a file. |
Enjoy, |
PJ |
/demos/tags/rel_0_3/simcity/keyboard.c |
---|
46,4 → 46,4 |
k.scan = KEY_D; |
k.ascii = 'd'; |
keyb_hook(k, sensor_switch); |
} |
} |
/demos/tags/rel_0_3/simcity/include/simcity.h |
---|
2,7 → 2,7 |
// global variables and tasks bodies declaration |
#include <kernel/func.h> |
#include <semaphor.h> |
#include <semaphore.h> |
#ifndef CST |
#include "constant.h" |
#endif |
/demos/tags/rel_0_3/simcity/include/keyfunct.h |
---|
7,4 → 7,4 |
void h_car_kill(KEY_EVT *); |
void endfun(KEY_EVT *); |
void refresh(KEY_EVT *); |
void sensor_switch(KEY_EVT *); |
void sensor_switch(KEY_EVT *); |
/demos/tags/rel_0_3/simcity/initfile.c |
---|
77,10 → 77,7 |
HARTPORT_init(); |
kern_printf("TIME=%d\n",sys_gettime(NULL)); |
KEYB_init(NULL); |
kern_printf("TIME=%d\n",sys_gettime(NULL)); |
KEYB_init(NULL); |
__call_main__(mb); |
/demos/tags/rel_0_3/simcity/car.c |
---|
172,4 → 172,4 |
set_spd=MAX_SPEED; |
} |
cd->speed=set_spd; |
} |
} |
/demos/tags/rel_0_3/simcity/simcity.c |
---|
6,7 → 6,7 |
#include <drivers/keyb.h> |
#include <drivers/glib.h> |
#include <kernel/kern.h> |
#include <semaphor.h> |
#include <semaphore.h> |
#include <math.h> |
#include "include/constant.h" |
#include "include/misc.h" |
76,23 → 76,6 |
cprintf("Ferrari Fabio\n"); |
} |
void demo_exc_handler(int signo, siginfo_t *info, void *extra) |
{ |
struct timespec t; |
grx_close(); |
/* Default action for an kern exception is */ |
kern_cli(); |
ll_gettime(TIME_EXACT, &t), |
kern_printf("\nS.Ha.R.K. Exception raised!!!" |
"\nTime (s:ns) :%d:%d" |
"\nException number:%d" |
"\nPID :%d\n", |
t.tv_sec, t.tv_nsec, info->si_value.sival_int, |
info->si_task); |
sys_end(); |
} |
void my_close(void *arg) |
{ |
grx_close(); |
103,20 → 86,9 |
{ |
int i; |
char tl_name[4]; |
struct sigaction action; |
version(); |
/* Init the standard Hartik exception handler */ |
/* Set the signal action */ |
action.sa_flags = SA_SIGINFO; |
action.sa_sigaction = demo_exc_handler; |
action.sa_handler = 0; |
sigfillset(&action.sa_mask); /* we block all the other signals... */ |
if (sigaction(SIGHEXC, &action, NULL) == -1) { |
perror("Error initializing signals..."); |
sys_end(); |
} |
sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
//resetting kill flags |
/demos/tags/rel_0_3/simcity/tasks.c |
---|
5,7 → 5,7 |
#include <string.h> |
#include <kernel/func.h> |
#include <drivers/glib.h> |
#include <semaphor.h> |
#include <semaphore.h> |
#include <math.h> |
#include "include/simcity.h" |
#include "include/states.h" |
406,4 → 406,4 |
cd->xp=my_rint(cd->xpos); |
cd->yp=my_rint(cd->ypos); |
} |
} |
} |
/demos/tags/rel_0_3/simcity/keyfunct.c |
---|
82,4 → 82,4 |
void sensor_switch(KEY_EVT *k) { |
if(sens==0) sens=1; |
else sens=0; |
} |
} |
/demos/tags/rel_0_3/simcity/misc.c |
---|
212,4 → 212,4 |
break; |
} |
return min_tl; |
} |
} |
/demos/tags/rel_0_3/bca/fab_lib.c |
---|
0,0 → 1,444 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: fab_lib.c,v 1.3 2003-01-07 17:10:16 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: FAB_lib.c * |
* libreria: FAB_LIB * |
* version: 1.0 25/08/2002 * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************/ |
#ifndef __FAB_LIB_c__ |
#define __FAB_LIB_c__ |
//-------------------BEGIN--------------------------- |
// *** Librerie di S.Ha.R.K. *** |
#include<kernel/kern.h> |
#include<kernel/mem.h> |
#include<drivers/gd.h> |
#include<drivers/glib.h> |
#include<ll/sys/types.h> |
#include<ll/i386/x-dos.h> |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
#include"fab_lib/fab_msg.h" |
#include"fab_lib/fab_tool.h" |
#include"fab_lib/fab_grx.h" |
// *** Corpo delle funzioni in FAB_msg.h *** // |
void FAB_print(char * InitMsg, char * msg) |
{ if (InitMsg!=NULL) {kern_printf("\n[%s]",(InitMsg));} |
if (msg!=NULL) {kern_printf("\n %s.",msg);} |
} |
void __FAB_go(int test, char * OkMsg, char * ErrorMsg,int EXITflag) |
{ |
if (OkMsg==NULL) OkMsg=FAB_EMPTY_MSG; |
if (ErrorMsg==NULL) ErrorMsg=FAB_EMPTY_MSG; |
if (!test) {kern_printf("\n OK: %s.",OkMsg);} |
else {kern_printf("\n ERROR: %s!",ErrorMsg); |
if (EXITflag==FAB_EXIT_YES) sys_end(); |
} |
} |
// *** Corpo delle funzioni in FAB_tool.h *** // |
// nessun corpo! |
// *** Corpo delle funzioni in FAB_show.h *** // |
void FAB_show_sched_modules() |
{ //int i; |
FAB_print("MODULI DI SCHEDULAZIONE",NULL); |
kern_printf("\n (livello) (nome)"); |
kern_printf("Names non more available!"); |
//for (i=0; i<sched_levels; i++) |
// {kern_printf("\n %-9d %s",i,(level_table[i])->level_name); |
// } |
FAB_newline(); |
} |
// *** Corpo delle funzioni in FAB_grx.h *** |
FAB_BALLFRAME* FAB_ballframe_alloc() |
{ FAB_BALLFRAME* frame; |
frame=(FAB_BALLFRAME*)kern_alloc(sizeof(FAB_BALLFRAME)); |
if (frame==NULL) { |
FAB_print(NULL,"BALLFRAME CREATING... ERROR #1"); |
return NULL; |
} |
return frame; |
} |
void FAB_ballframe_free(FAB_BALLFRAME * frame) |
{ if (frame!=NULL) |
{ kern_free(frame,sizeof(FAB_BALLFRAME)); |
} |
} |
FAB_FRAME* FAB_frame_alloc() |
{ FAB_FRAME* frame; |
frame=(FAB_FRAME*)kern_alloc(sizeof(FAB_FRAME)); |
if (frame==NULL) { |
FAB_print(NULL,"FRAME CREATING... ERROR #1"); |
return NULL; |
} |
return frame; |
} |
void FAB_frame_free(FAB_FRAME * frame) |
{ if (frame!=NULL) |
{ kern_free(frame,sizeof(FAB_FRAME)); |
} |
} |
void FAB_ballborder_put(FAB_BORDER* border, WORD cx, WORD cy, WORD r_int) |
{ int i; |
for (i=0; i<border->dim; i++) |
grx_circle(cx, cy, r_int+i, border->buf[i]); |
} |
void FAB_border_put(FAB_BORDER* border, WORD x0, WORD y0, WORD x1, WORD y1) |
{ int i; |
for (i=0; i<border->dim; i++) |
grx_rect(x0-i, y0-i, x1+i, y1+i, border->buf[i]); |
} |
FAB_BORDER* FAB_border_alloc(WORD dim) |
{ FAB_BORDER* border; |
border=(FAB_BORDER*)kern_alloc(sizeof(FAB_BORDER)); |
if (border==NULL) { |
FAB_print(NULL,"BORDER CREATING... ERROR #1"); |
return NULL; |
} |
border->buf=(COLOR*)kern_alloc(dim*sizeof(COLOR)); |
if (border->buf==NULL) { |
FAB_print(NULL,"BORDER CREATING... ERROR #2"); |
return NULL; |
} |
border->dim = dim; |
return border; |
} |
void FAB_border_free(FAB_BORDER * border) |
{ if (border!=NULL) |
{ kern_free(border->buf,border->dim*sizeof(COLOR)); |
kern_free(border,sizeof(FAB_BORDER)); |
} |
} |
void FAB_image_free(FAB_IMAGE* image) |
{ if (image!=NULL) |
{ kern_free(image->buf,image->lx*image->ly*sizeof(COLOR)); |
kern_free(image,sizeof(FAB_IMAGE)); |
} |
} |
FAB_IMAGE* FAB_image_alloc(WORD lx, WORD ly) |
{ FAB_IMAGE* image; |
image=(FAB_IMAGE*)kern_alloc(sizeof(FAB_IMAGE)); |
if (image==NULL) { |
FAB_print(NULL,"IMAGE CREATING... ERROR #1"); |
return NULL; |
} |
image->buf=(COLOR*)kern_alloc(lx*ly*sizeof(COLOR)); |
if (image->buf==NULL) { |
FAB_print(NULL,"IMAGE CREATING... ERROR #2"); |
return NULL; |
} |
FAB_image_no_trasparent_set(image); |
image->lx = lx; |
image->ly = ly; |
return image; |
} |
int FAB_grx_open(WORD lx, WORD ly) |
{ int modenum; |
FAB_print("VIDEO",NULL); |
if (grx_init()==-1) { |
FAB_print(NULL,"ERRORE nell'inizializzazione!"); |
return -1; |
} |
if((modenum = grx_getmode(lx, ly, FAB_BPP))==-1) { |
FAB_print(NULL,"Modalita' NON supportata!"); |
return -1; |
} |
if(grx_setmode(modenum)==-1) { |
FAB_print(NULL,"ERRORE nell'apertura della modalita'video"); |
return -1; |
} |
return 0; |
} |
void FAB_grx_close() |
{ grx_close(); |
} |
int FAB_image_load(FAB_IMAGE* image, char* file_name) |
{ |
DOS_FILE* file; |
BYTE rgb[3]; |
COLOR * buf; |
int i; |
file=DOS_fopen(file_name,"r"); |
if (file==NULL) return -1; |
buf = image->buf; |
for (i=0; i<image->lx*image->ly; i++) |
{ DOS_fread(&rgb[0],sizeof(BYTE),3,file); |
*buf = FAB_rgb(rgb[0],rgb[1],rgb[2]); |
buf++; |
} |
DOS_fclose(file); |
return(0); |
} |
void FAB_image_get(FAB_IMAGE* image, WORD x0, WORD y0, WORD lx, WORD ly) |
{ WORD x, y; |
COLOR* buf; |
buf = image->buf; |
for (y=0; y<image->ly; y++) |
for (x=0; x<image->lx; x++) { |
*buf = (COLOR) grx_getpixel(x0+x,y0+y); |
buf++; |
} |
FAB_image_no_trasparent_set(image); |
} |
void FAB_image_put(FAB_IMAGE* image, WORD x0, WORD y0) |
{ WORD x, y; |
COLOR* buf; |
buf = image->buf; |
if (!image->trasparent) { |
for (y=0; y<image->ly; y++) |
for (x=0; x<image->lx; x++) |
grx_plot(x0+x,y0+y,*buf++); |
} |
else { |
for (y=0; y<image->ly; y++) |
for (x=0; x<image->lx; x++) { |
if (*buf!=image->trasparent_col) |
grx_plot(x0+x,y0+y,*buf); |
buf++; |
} |
} |
} |
void FAB_image_put_within(FAB_IMAGE* image, WORD x0, WORD y0, |
WORD xx0, WORD yy0, WORD xx1, WORD yy1) |
{ int step_x0_xx0; |
int step_y0_yy0; |
int step_xx1_x1; |
int step_yy1_y1; |
WORD xx, yy; |
COLOR* buf; |
step_x0_xx0 = xx0 - x0; |
step_y0_yy0 = yy0 - y0; |
step_xx1_x1 = (x0 + image->lx - 1) - xx1; |
step_yy1_y1 = (y0 + image->ly - 1) - yy1; |
if (step_x0_xx0 < 0) step_x0_xx0 = 0; |
if (step_y0_yy0 < 0) step_y0_yy0 = 0; |
if (step_xx1_x1 < 0) step_xx1_x1 = 0; |
if (step_yy1_y1 < 0) step_yy1_y1 = 0; |
buf = image->buf + step_y0_yy0*image->lx; |
if (!image->trasparent) { |
for(yy=step_y0_yy0; yy<image->ly-step_yy1_y1; yy++) { |
buf += step_x0_xx0; |
for(xx=step_x0_xx0; xx<image->lx-step_xx1_x1; xx++) |
grx_plot(x0+xx,y0+yy,*buf++); |
buf += step_xx1_x1; |
} |
} |
else { |
for(yy=step_y0_yy0; yy<image->ly-step_yy1_y1; yy++) { |
buf += step_x0_xx0; |
for(xx=step_x0_xx0; xx<image->lx-step_xx1_x1; xx++) { |
if (*buf!=image->trasparent_col) |
grx_plot(x0+xx,y0+yy,*buf); |
buf++; |
} |
buf += step_xx1_x1; |
} |
} |
} |
//...funzione usata da FAB_image_fill()... |
void __FAB_image_put_into(FAB_IMAGE* image, WORD x0, WORD y0, WORD lx, WORD ly) |
{ WORD x, y; |
WORD skipped_pixels; |
COLOR* buf; |
if (lx < image->lx) skipped_pixels = image->lx - lx; |
else skipped_pixels = 0; |
buf = image->buf; |
if (!image->trasparent) { |
for (y=0; y<ly; y++, buf+=skipped_pixels) { |
if (y > image->ly -1) break; |
for (x=0; x<lx; x++, buf++) { |
if (x < image->lx) grx_plot(x0+x,y0+y,*buf); |
else break; |
} |
} |
} |
else { |
for (y=0; y<ly; y++, buf+=skipped_pixels) { |
if (y > image->ly -1) break; |
for (x=0; x<lx; x++, buf++) { |
if (x < image->lx) { |
if (*buf!=image->trasparent_col) |
grx_plot(x0+x,y0+y,*buf); |
} |
else break; |
} |
} |
} |
} |
void FAB_image_fill(FAB_IMAGE* image, WORD x0, WORD y0, WORD lx, WORD ly) |
{ WORD x, y; |
WORD sub_lx, sub_ly; |
for (y=0; y<ly; y+=image->ly) { |
sub_ly = ly - y; // spazio verticale disponibile |
if (sub_ly > image->ly) sub_ly = image->ly; |
for (x=0; x<lx; x+=image->lx) { |
sub_lx = lx - x; // spazio orizzontale disponibile |
if (sub_lx > image->lx) sub_lx = image->lx; |
__FAB_image_put_into(image,x0+x,y0+y,sub_lx,sub_ly); |
} |
} |
} |
void FAB_frame_put(FAB_FRAME* frame, WORD x0, WORD y0, WORD lx, WORD ly) |
{ |
WORD eff_dim; |
int j; |
//BORDO DEL FRAME |
if (frame->border!=NULL) eff_dim = frame->border->dim; |
else eff_dim = frame->border_dim; |
frame->x0 = x0 + eff_dim; |
frame->y0 = y0 + eff_dim; |
frame->x1 = x0 + lx - eff_dim - 1; |
frame->y1 = y0 + ly - eff_dim - 1; |
if (frame->border!=NULL) { |
FAB_border_put(frame->border, frame->x0-1, frame->y0-1, |
frame->x1+1, frame->y1+1); |
} |
else { |
for (j=0; j<eff_dim; j++) |
grx_rect(frame->x0-1-j, frame->y0-1-j, |
frame->x1+1+j, frame->y1+1+j, frame->border_col); |
} |
//PANNELLO DEL FRAME |
if (!frame->trasparent) { |
if (frame->image==NULL) grx_box(frame->x0, frame->y0, |
frame->x1, frame->y1, frame->color); |
else FAB_image_fill(frame->image, |
frame->x0, frame->y0, |
lx-eff_dim*2, ly-eff_dim*2); |
} |
} |
void FAB_ballframe_put(FAB_BALLFRAME* frame, WORD cx, WORD cy, WORD r) |
{ |
int j; |
WORD eff_dim; |
//BORDO DEL FRAME |
if (frame->border!=NULL) eff_dim = frame->border->dim; |
else eff_dim = frame->border_dim; |
frame->cx = cx; |
frame->cy = cy; |
frame->r = r - eff_dim; |
if (frame->border!=NULL) { |
FAB_ballborder_put(frame->border,frame->cx,frame->cy,frame->r+1); |
} |
else { |
for (j=0; j<eff_dim; j++) |
grx_circle(frame->cx,frame->cy,frame->r+1+j,frame->border_col); |
} |
//PANNELLO DEL FRAME |
if (!frame->trasparent) { |
grx_disc(frame->cx,frame->cy,frame->r,frame->color); |
} |
} |
void FAB_image_copy(FAB_IMAGE* orig_image, FAB_IMAGE* dest_image) |
{ |
COLOR* orig_buf; |
COLOR* dest_buf; |
int j,n; |
n = orig_image->lx * orig_image->ly; |
if (n==(dest_image->lx * dest_image->ly)) { |
orig_buf = orig_image->buf; |
dest_buf = dest_image->buf; |
for(j=0; j<n; j++) { |
*dest_buf = *orig_buf; |
orig_buf++; |
dest_buf++; |
} |
} |
} |
void FAB_image_color_change(FAB_IMAGE* image, COLOR old_col, COLOR new_col) |
{ COLOR* buf; |
int j,n; |
buf = image->buf; |
n = image->lx * image->ly; |
for(j=0; j<n; j++, buf++) |
if (*buf==old_col) |
*buf=new_col; |
} |
//----------------------END-------------------------- |
#endif |
/demos/tags/rel_0_3/bca/esplo.c |
---|
0,0 → 1,98 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: esplo.c,v 1.3 2003-01-07 17:10:16 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
//************************ |
//* file: esplo.c * |
//* included by: bca.c * |
//************************ |
#include <time.h> |
PID crea_soft_esplo(int index) |
{ |
SOFT_TASK_MODEL m; |
PID pid; |
soft_task_default_model(m); |
soft_task_def_arg(m,(void*)index); |
soft_task_def_period(m,ESPLO_PERIOD*5); |
soft_task_def_wcet(m,ESPLO_WCET*5); |
soft_task_def_met(m,ESPLO_MET*5); |
pid = task_create("esplo", esplo, &m, NULL); |
return pid; |
} |
TASK esplo(void *argv) |
{ |
int i; |
int index; |
WORD xx0, yy0, xx1, yy1; |
struct timespec delay; |
delay.tv_sec = (ESPLO_PERIOD-ESPLO_MET)/1000000; |
delay.tv_nsec = ((ESPLO_PERIOD-ESPLO_MET)%1000000)*1000; |
i=0; |
index = (int)argv; |
xx0 = aereo_table[index].x - ESPLO_LX/2; |
yy0 = aereo_table[index].y - ESPLO_LY/2; |
xx1 = xx0 + ESPLO_LX-1; |
yy1 = yy0 + ESPLO_LY-1; |
while(1){ |
for(i=0;i<5;i++) { |
mutex_lock(&grx_mutex); |
FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
FAB_image_put_within(image_esplo[i],xx0,yy0,X0,Y0,X1,Y1); |
mutex_unlock(&grx_mutex); |
nanosleep(&delay, NULL); |
} |
mutex_lock(&grx_mutex); |
FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
mutex_unlock(&grx_mutex); |
return NULL; |
task_endcycle(); |
} |
} |
/demos/tags/rel_0_3/bca/bca.c |
---|
0,0 → 1,222 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: bca.c,v 1.4 2003-01-07 17:10:16 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: bca.c * |
* header file: bca.h * |
* data: 15/09/2002 * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************** |
* * |
* descrizione: e' il file in cui è descritto il task* |
* main del programma S.Ha.R.K. * |
* "(B)ase(C)ontr(A)rea". * |
* Il codice del programma comprende * |
* anche l'implementazione di altri task* |
* distribuiti nei seguenti file che * |
* quindi sono inclusi: * |
* dummy.c * |
* control.c * |
* aereo.c * |
* cannone.c * |
* missile.c * |
* esplo.c * |
* Inoltre è incluso anche il file: * |
* scenario.c * |
* che descrive come disegnare lo * |
* scenario grafico iniziale * |
* * |
******************************************************/ |
// *** Librerie S.Ha.R.K *** |
#include <kernel/kern.h> |
#include <drivers/keyb.h> |
#include <ll/i386/cons.h> |
#include <drivers/glib.h> |
// *** Librerie Standard C *** |
#include <stdlib.h> |
// *** Librerie FAB *** |
#include "fab_lib/fab_msg.h" |
#include "fab_lib/fab_show.h" |
#include "fab_lib/fab_tool.h" |
#include "fab_lib/fab_grx.h" |
// *** Librerie BCA *** |
#include "bca.h" |
char * titolo[10]; |
void scenario(); |
void info(); |
#include"scenario.c" |
PID crea_soft_dummy_radar (); |
TASK dummy_radar(void *); |
#include"dummy.c" |
PID crea_soft_control(); |
TASK control(void *); |
#include"control.c" |
PID crea_soft_aereo_creator(); |
TASK aereo_creator(); |
PID crea_hard_aereo(int index); |
PID crea_soft_aereo(int index); |
TASK aereo(void * index); |
#include"aereo.c" |
PID crea_soft_cannone_creator(); |
TASK cannone_creator(); |
PID crea_hard_cannone(int index); |
PID crea_soft_cannone(int index); |
TASK cannone(void * index); |
#include"cannone.c" |
PID crea_hard_missile(); |
PID crea_soft_missile(); |
TASK missile(); |
#include"missile.c" |
PID crea_soft_esplo(); |
TASK esplo(void *); |
#include"esplo.c" |
void demo_exc_handler(int signo, siginfo_t *info, void *extra) |
{ |
struct timespec t; |
grx_close(); |
/* Default action for an kern exception is */ |
kern_cli(); |
kern_gettime(&t), |
kern_printf("\nS.Ha.R.K. Exception raised!!!" |
"\nTime (s:ns) :%ld:%ld" |
"\nException number:%d" |
"\nPID :%d\n", |
t.tv_sec, t.tv_nsec, info->si_value.sival_int, |
info->si_task); |
sys_end(); |
} |
void my_close(void *arg) |
{ FAB_grx_close(); |
place(0,0); |
info(); |
} |
void end_fun(KEY_EVT* k) |
{ cprintf("Ending...\n"); |
sys_end(); |
} |
void incrementa_aerei_fun(KEY_EVT* k) |
{ if (aereo_count<AEREO_N_MAX) aereo_count++; |
} |
void decrementa_aerei_fun(KEY_EVT* k) |
{ if (aereo_count>AEREO_N_MIN) aereo_count--; |
} |
void incrementa_cannoni_fun(KEY_EVT* k) |
{ if (cannone_count<CANNONE_N_MAX) cannone_count++; |
} |
void decrementa_cannoni_fun(KEY_EVT* k) |
{ if (cannone_count>CANNONE_N_MIN) cannone_count--; |
} |
int main(int argc, char **argv) |
{ |
PID pid; |
KEY_EVT k; |
keyb_set_map(itaMap); |
k.flag = 0; |
k.scan = KEY_ENT; |
k.ascii = 13; |
keyb_hook(k,end_fun); |
k.flag = 0; |
k.scan = KEY_1; |
k.ascii = '1'; |
keyb_hook(k,incrementa_aerei_fun); |
k.flag = 0; |
k.scan = KEY_2; |
k.ascii = '2'; |
keyb_hook(k,decrementa_aerei_fun); |
k.flag = 0; |
k.scan = KEY_3; |
k.ascii = '3'; |
keyb_hook(k,incrementa_cannoni_fun); |
k.flag = 0; |
k.scan = KEY_4; |
k.ascii = '4'; |
keyb_hook(k,decrementa_cannoni_fun); |
sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
FAB_grx_open(800,600); |
/* inizializza il mutex grafico */ |
app_mutex_init(&grx_mutex); |
scenario(); |
//---init--- |
srand(sys_gettime(NULL)); |
aereo_count = AEREO_N_MIN; |
cannone_count = CANNONE_N_MIN; |
pid=crea_soft_dummy_radar(); |
task_activate(pid); |
pid=crea_soft_aereo_creator(); |
task_activate(pid); |
pid=crea_soft_cannone_creator(); |
task_activate(pid); |
pid=crea_soft_control(); |
task_activate(pid); |
//---------- |
} |
/demos/tags/rel_0_3/bca/initfile.c |
---|
0,0 → 1,139 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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.3 2002-11-11 08:15:13 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: initfile.h * |
* data: 15/09/2002 * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************** |
* * |
* descrizione: inizializza i moduli di scheduling e * |
* di risorse per il programma SHaRK * |
* "(B)ase(C)ontr(A)rea", il cui task * |
* main e' nel file bca.c. * |
* * |
******************************************************/ |
#define PI |
// *** Librerie S.Ha.R.K *** |
#include "kernel/kern.h" |
#include "modules/edf.h" |
#include "modules/cbs.h" |
#include "modules/rr.h" |
#include "modules/dummy.h" |
#include "modules/pi.h" |
#include "modules/nop.h" |
#include "modules/sem.h" |
#include "modules/hartport.h" |
#include "modules/cabs.h" |
#include "drivers/keyb.h" |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
// *** Librerie BCA *** |
#include"bca.h" |
/*+ system 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(); |
PI_register_module(); |
NOP_register_module(); |
kern_init_bca(); |
// periodic timer |
return TICK; |
// one-shot timer |
// return 0 |
} |
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_init(&kparms); |
__call_main__(mb); |
return (void *)0; |
} |
#ifdef PI |
int app_mutex_init(mutex_t *m) |
{ |
PI_mutexattr_t attr; |
PI_mutexattr_default(attr); |
return mutex_init(m, &attr); |
} |
#else |
int app_mutex_init(mutex_t *m) |
{ |
NOP_mutexattr_t attr; |
NOP_mutexattr_default(attr); |
return mutex_init(m, &attr); |
} |
#endif |
/demos/tags/rel_0_3/bca/bca_lib.c |
---|
0,0 → 1,413 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: bca_lib.c,v 1.3 2002-11-11 08:15:13 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: BCA_LIB.c * |
* libreria: BCA_LIB * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************/ |
#ifndef __BCA_LIB_c__ |
#define __BCA_LIB_c__ |
//-------------------BEGIN--------------------------- |
// *** Librerie S.Ha.R.K *** |
#include<kernel/kern.h> |
#include<drivers/glib.h> |
#include<drivers/gd.h> |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
#include"fab_lib/fab_msg.h" |
// *** Librerie BCA *** |
#include"bca.h" |
char * titolo[10]={" UNIVERSITA' DEGLI \0", |
" STUDI DI \0", |
" PAVIA \0", |
"Progetto S.Ha.R.K.\0", |
" 'BaseContrAerea' \0", |
"-------------------\0", |
" PAVIA 2002 \0", |
"by Fabio CALABRESE \0", |
"<fabiocalabrese77 \0", |
" @yahoo.it>\0"}; |
void kern_alloc_images(); // richiede DISABLED_INTERUPTS |
void kern_free_images(); // richiede DISABLED_INTERUPTS |
void kern_load_images(); // solo in __kernel_register_levels__() |
void kern_alloc_borders(); // richiede DISABLED_INTERUPTS |
void kern_free_borders(); // richiede DISABLED_INTERUPTS |
void kern_set_border(); // consigliato in __kernel_register-levels__() |
void kern_alloc_frames(); // richiede DISABLED_INTERUPTS |
void kern_free_frames(); // richiede DISABLED_INTERUPTS |
void kern_set_frames(); // consigliato in __kernel_register-levels__() |
void kern_alloc_ballframes(); // richiede DISABLED_INTERUPTS |
void kern_free_ballframes(); // richiede DISABLED_INTERUPTS |
void kern_set_ballframes(); // consigliato in __kernel_register-levels__() |
void kern_alloc_task_tables(); // richiede DISABLED_INTERUPTS |
void kern_free_task_tables(); // richiede DISABLED_INTERUPTS |
void kern_set_task_tables(); // consigliato in __kernel_register-levels__() |
// *** Corpo delle funzioni in CA.h *** // |
void kern_init_bca() |
{ |
FAB_clr(); |
FAB_show_sched_modules(); |
kern_alloc_task_tables(); |
kern_set_task_tables(); |
kern_alloc_borders(); |
kern_set_borders(); |
kern_alloc_images(); |
kern_load_images(); |
kern_alloc_frames(); |
kern_set_frames(); |
kern_alloc_ballframes(); |
kern_set_ballframes(); |
} |
void kern_alloc_task_tables() |
{ |
int test=0,j; |
FAB_print("TASKS'TABLES","allocazione..."); |
for (j=0; j<AEREO_N_MAX; j++) { |
aereo_table[j].image=FAB_image_alloc(AEREO_LX,AEREO_LY); |
if(aereo_table[j].image==NULL) test=1; |
} |
FAB_msg(test,NULL,"fatto","almeno un elemento della tabella non allocato"); |
} |
void kern_free_task_tables() |
{ int j; |
for (j=0; j<AEREO_N_MAX; j++) { |
FAB_image_free(aereo_table[j].image); |
} |
} |
void kern_set_task_tables() |
{ int j; |
FAB_print(NULL,"settaggio..."); |
for (j=0; j<AEREO_N_MAX; j++) { |
aereo_table[j].status = 0; |
aereo_table[j].killing = 0; |
aereo_table[j].image->trasparent = 1; |
aereo_table[j].image->trasparent_col = AEREO_TRASPARENT_COL; |
} |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_ballframes() |
{ |
int test=0,j; |
FAB_print("FAB_BALLFRAMEs","allocazione..."); |
ballframe_radar = FAB_ballframe_alloc(); |
if (ballframe_radar==NULL) test=1; |
for (j=0; j<3; j++) { |
ballframe_lucerossa[j] = FAB_ballframe_alloc(); |
if (ballframe_lucerossa[j]==NULL) test=1; |
} |
FAB_msg(test,NULL,"fatto","almeno un ballframe non allocato"); |
} |
void kern_free_ballframes() |
{ int j; |
FAB_ballframe_free(ballframe_radar); |
for (j=0; j<3; j++) |
FAB_ballframe_free(ballframe_lucerossa[j]); |
} |
void kern_set_ballframes() |
{ int j; |
FAB_print(NULL,"settaggio..."); |
FAB_ballframe_border_set(ballframe_radar,border_verde7,7, |
FRAME_MISURE_LINE_COLOR); |
FAB_ballframe_color_set(ballframe_radar,0,FAB_blue); |
for(j=0; j<3; j++) { |
FAB_ballframe_border_set(ballframe_lucerossa[j],border_verde7,7, |
FRAME_MISURE_LINE_COLOR); |
FAB_ballframe_color_set(ballframe_lucerossa[j],0,FAB_red); |
} |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_frames() |
{ |
int test=0; |
FAB_print("FAB_FRAMEs","allocazione..."); |
frame_bca = FAB_frame_alloc(); |
if (frame_bca==NULL) test=1; |
frame_misure_oriz = FAB_frame_alloc(); |
if (frame_misure_oriz==NULL) test=1; |
frame_misure_vert = FAB_frame_alloc(); |
if (frame_misure_vert==NULL) test=1; |
frame_titolo = FAB_frame_alloc(); |
if (frame_titolo==NULL) test=1; |
frame_comandi = FAB_frame_alloc(); |
if (frame_comandi==NULL) test=1; |
frame_control = FAB_frame_alloc(); |
if (frame_control==NULL) test=1; |
FAB_msg(test,NULL,"fatto","almeno un frame non allocato"); |
} |
void kern_free_frames() |
{ |
FAB_frame_free(frame_bca); |
FAB_frame_free(frame_misure_oriz); |
FAB_frame_free(frame_misure_vert); |
FAB_frame_free(frame_titolo); |
FAB_frame_free(frame_comandi); |
FAB_frame_free(frame_control); |
} |
void kern_set_frames() |
{ |
FAB_print(NULL,"settaggio..."); |
FAB_frame_border_set(frame_bca,border_blu7,7,FAB_rgb(255,0,0)); |
FAB_frame_color_set(frame_bca,0,image_bca,FAB_green); |
FAB_frame_border_set(frame_misure_oriz,border_verde7,7,FRAME_MISURE_LINE_COLOR); |
FAB_frame_color_set(frame_misure_oriz,0,NULL,FRAME_MISURE_BACK_COLOR); |
FAB_frame_border_set(frame_misure_vert,border_verde7,7,FRAME_MISURE_LINE_COLOR); |
FAB_frame_color_set(frame_misure_vert,0,NULL,FRAME_MISURE_BACK_COLOR); |
FAB_frame_border_set(frame_titolo,border_bianco7,7,FAB_white); |
FAB_frame_color_set(frame_titolo,0,NULL,FRAME_TITOLO_BACK_COLOR1); |
FAB_frame_border_set(frame_comandi,border_giallo7,7,FAB_yellow); |
FAB_frame_color_set(frame_comandi,0,NULL,FRAME_COMANDI_BACK_COLOR1); |
FAB_frame_border_set(frame_control,border_verde7,7,FAB_green); |
FAB_frame_color_set(frame_control,0,NULL,FRAME_CONTROL_BACK_COLOR); |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_borders() |
{ |
int test=0; |
FAB_print("FAB_BORDERs","allocazione..."); |
border_blu7 = FAB_border_alloc(7); |
if (border_blu7==NULL) test=1; |
border_verde7 = FAB_border_alloc(7); |
if (border_verde7==NULL) test=1; |
border_rosso7 = FAB_border_alloc(7); |
if (border_rosso7==NULL) test=1; |
border_bianco7 = FAB_border_alloc(7); |
if (border_bianco7==NULL) test=1; |
border_giallo7 = FAB_border_alloc(7); |
if (border_giallo7==NULL) test=1; |
FAB_msg(test,NULL,"fatto","almeno un bordo non allocato"); |
} |
void kern_free_borders() |
{ |
FAB_border_free(border_blu7); |
FAB_border_free(border_verde7); |
FAB_border_free(border_rosso7); |
FAB_border_free(border_bianco7); |
FAB_border_free(border_giallo7); |
} |
void kern_set_borders() |
{ |
FAB_print(NULL,"settaggio..."); |
border_blu7->buf[0]=FAB_rgb( 0, 0, 50); |
border_blu7->buf[1]=FAB_rgb( 0, 50,200); |
border_blu7->buf[2]=FAB_rgb( 50,100,255); |
border_blu7->buf[3]=FAB_rgb(100,150,255); |
border_blu7->buf[4]=FAB_rgb( 50,100,255); |
border_blu7->buf[5]=FAB_rgb( 0, 50,200); |
border_blu7->buf[6]=FAB_rgb( 0, 0, 50); |
border_verde7->buf[0]=FAB_rgb( 0, 50, 0); |
border_verde7->buf[1]=FAB_rgb( 0,100, 50); |
border_verde7->buf[2]=FAB_rgb( 50,255,100); |
border_verde7->buf[3]=FAB_rgb(100,255,150); |
border_verde7->buf[4]=FAB_rgb( 50,255,100); |
border_verde7->buf[5]=FAB_rgb( 0,100, 50); |
border_verde7->buf[6]=FAB_rgb( 0, 50, 0); |
border_rosso7->buf[0]=FAB_rgb( 50, 0, 0); |
border_rosso7->buf[1]=FAB_rgb(200, 25, 25); |
border_rosso7->buf[2]=FAB_rgb(255, 75, 75); |
border_rosso7->buf[3]=FAB_rgb(255,125,125); |
border_rosso7->buf[4]=FAB_rgb(255, 75, 75); |
border_rosso7->buf[5]=FAB_rgb(200, 25, 25); |
border_rosso7->buf[6]=FAB_rgb( 50, 0, 0); |
border_bianco7->buf[0]=FAB_rgb( 25, 25, 25); |
border_bianco7->buf[1]=FAB_rgb( 75, 75, 75); |
border_bianco7->buf[2]=FAB_rgb(125,125,125); |
border_bianco7->buf[3]=FAB_rgb(255,255,255); |
border_bianco7->buf[4]=FAB_rgb(125,125,125); |
border_bianco7->buf[5]=FAB_rgb( 75, 75, 75); |
border_bianco7->buf[6]=FAB_rgb( 25, 25, 25); |
border_giallo7->buf[0]=FAB_rgb( 25, 25, 0); |
border_giallo7->buf[1]=FAB_rgb(115,115, 25); |
border_giallo7->buf[2]=FAB_rgb(170,170, 75); |
border_giallo7->buf[3]=FAB_rgb(255,255,100); |
border_giallo7->buf[4]=FAB_rgb(170,170, 75); |
border_giallo7->buf[5]=FAB_rgb(115,115, 25); |
border_giallo7->buf[6]=FAB_rgb( 25, 25, 0); |
FAB_print(NULL,"fatto"); |
} |
void kern_alloc_images() |
{ |
int j,test=0; |
FAB_print("FAB_IMAGEs","allocazione..."); |
image_missile[0] = FAB_image_alloc(MISSILE_LX,MISSILE_LY); |
if (image_missile[0]==NULL) test=1; |
image_missile[1] = FAB_image_alloc(MISSILE_LX,MISSILE_LY); |
if (image_missile[1]==NULL) test=1; |
for (j=0; j<2; j++) { |
image_cannone[j] = FAB_image_alloc(CANNONE_LX,CANNONE_LY); |
if (image_cannone[j]==NULL) test=1; |
} |
for (j=0; j<4; j++) { |
image_aereo[j] = FAB_image_alloc(AEREO_LX,AEREO_LY); |
if (image_aereo[j]==NULL) test=1; |
} |
for (j=0; j<5; j++) { |
image_esplo[j] = FAB_image_alloc(ESPLO_LX,ESPLO_LY); |
if (image_esplo[j]==NULL) test=1; |
} |
image_sfondo = FAB_image_alloc(96,96); |
if (image_sfondo==NULL) test=1; |
image_bca = FAB_image_alloc(500,500); |
if (image_bca==NULL) test=1; |
FAB_msg(test,NULL,"fatto","almeno un'immagine non allocata"); |
} |
void kern_free_images() |
{ |
int j; |
FAB_image_free(image_missile[0]); |
FAB_image_free(image_missile[1]); |
for (j=0; j<2; j++) FAB_image_free(image_cannone[j]); |
for (j=0; j<4; j++) FAB_image_free(image_aereo[j]); |
for (j=0; j<5; j++) FAB_image_free(image_esplo[j]); |
FAB_image_free(image_sfondo); |
FAB_image_free(image_bca); |
} |
void kern_load_images() |
{ int test=0; |
FAB_print(NULL,"caricamento dai file..."); |
FAB_print(NULL," [missile1.raw]..."); |
if(FAB_image_load(image_missile[0],"BCA_raw/missile1.raw")==-1) test=1; |
FAB_image_trasparent_set(image_missile[0],MISSILE_TRASPARENT_COL); |
FAB_print(NULL," [missile2.raw]..."); |
if(FAB_image_load(image_missile[1],"BCA_raw/missile2.raw")==-1) test=1; |
FAB_image_trasparent_set(image_missile[1],MISSILE_TRASPARENT_COL); |
FAB_print(NULL," [aereo1.raw]..."); |
if(FAB_image_load(image_aereo[0],"BCA_raw/aereo1.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[0],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [aereo2.raw]..."); |
if(FAB_image_load(image_aereo[1],"BCA_raw/aereo2.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[1],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [aereo1_h.raw]..."); |
if(FAB_image_load(image_aereo[2],"BCA_raw/aereo1_h.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[2],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [aereo2_h.raw]..."); |
if(FAB_image_load(image_aereo[3],"BCA_raw/aereo2_h.raw")==-1) test=1; |
FAB_image_trasparent_set(image_aereo[3],AEREO_TRASPARENT_COL); |
FAB_print(NULL," [cannon.raw]..."); |
if(FAB_image_load(image_cannone[0],"BCA_raw/cannon.raw")==-1) test=1; |
FAB_image_trasparent_set(image_cannone[0],CANNONE_TRASPARENT_COL); |
FAB_print(NULL," [cannon_h.raw]..."); |
if(FAB_image_load(image_cannone[1],"BCA_raw/cannon_h.raw")==-1) test=1; |
FAB_image_trasparent_set(image_cannone[1],CANNONE_TRASPARENT_COL); |
FAB_print(NULL," [esplo1.raw]..."); |
if(FAB_image_load(image_esplo[0],"BCA_raw/esplo1.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[0],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo2.raw]..."); |
if(FAB_image_load(image_esplo[1],"BCA_raw/esplo2.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[1],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo3.raw]..."); |
if(FAB_image_load(image_esplo[2],"BCA_raw/esplo3.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[2],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo4.raw]..."); |
if(FAB_image_load(image_esplo[3],"BCA_raw/esplo4.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[3],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [esplo5.raw]..."); |
if(FAB_image_load(image_esplo[4],"BCA_raw/esplo5.raw")==-1) test=1; |
FAB_image_trasparent_set(image_esplo[4],ESPLO_TRASPARENT_COL); |
FAB_print(NULL," [sfondo.raw]..."); |
if(FAB_image_load(image_sfondo,"BCA_raw/sfondo.raw")==-1) test=1; |
FAB_image_no_trasparent_set(image_sfondo); |
FAB_print(NULL," [bca.raw]..."); |
if(FAB_image_load(image_bca,"BCA_raw/bca.raw")==-1) test=1; |
FAB_image_no_trasparent_set(image_bca); |
FAB_msg(test,NULL,"fatto","almeno un file non esiste oppure ha un formato incompatibile"); |
} |
//----------------------END-------------------------- |
#endif |
/demos/tags/rel_0_3/bca/bca.h |
---|
0,0 → 1,288 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: bca.h,v 1.2 2002-10-01 10:33:51 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: bca.h * |
* included by: bca.c & bca_lib di cui fa da header* |
* data: 15/09/2002 * |
* creato da: Fabio CALABRESE * |
* * |
****************************************************** |
* * |
* descrizione: contiene la definizione di variabili * |
* e strutture globali, con un corredo * |
* di macro e funzioni per la loro * |
* gestione, usate nel programma SHaRK * |
* "(B)ase(C)ontr(A)rea", il cui codice * |
* e' scritto nel file bca.c; * |
* il file bca_lib.c contiene il corpo * |
* di tutte le funzioni qui dichiarate. * |
* * |
******************************************************/ |
#ifndef __BCA_H__ |
#define __BCA_H__ |
//----------------BEGIN------------------ |
// *** Librerie S.Ha.R.K *** |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
#include"fab_lib/fab_grx.h" |
#include"fab_lib/fab_tool.h" |
// *** Librerie BCA *** |
// --------------------------------- |
// *** Elementi Grafici Generici *** |
// --------------------------------- |
// IMMAGINI: |
FAB_IMAGE* image_sfondo; |
FAB_IMAGE* image_bca; |
FAB_IMAGE* image_aereo[4]; // 1 aereo per ogni direzione(soft e hard) |
FAB_IMAGE* image_esplo[5]; // 5 immagini in sequenza simulanti |
FAB_IMAGE* image_cannone[2]; // un esplosione |
FAB_IMAGE* image_missile[2]; |
// BORDI: |
FAB_BORDER* border_blu7; |
FAB_BORDER* border_verde7; |
FAB_BORDER* border_rosso7; |
FAB_BORDER* border_bianco7; |
FAB_BORDER* border_giallo7; |
// FRAME: |
FAB_FRAME* frame_bca; |
FAB_FRAME* frame_misure_oriz; |
FAB_FRAME* frame_misure_vert; |
FAB_FRAME* frame_misure_vert; |
FAB_FRAME* frame_titolo; |
FAB_FRAME* frame_comandi; |
FAB_FRAME* frame_control; |
// BALLFRAME: |
FAB_BALLFRAME* ballframe_radar; |
FAB_BALLFRAME* ballframe_lucerossa[3]; |
// Base ContrAerea |
#define BASE_L 1.0 // [Km]: lunghezza |
#define BASE_H 2100 // [m]: altezza max di visibilita' |
// Finestra Virtuale sullo schermo |
#define FIN_X_MIN 20 // [pixel] |
#define FIN_X_MAX 520-1 // [pixel] |
#define FIN_Y_MIN 20 // [pixel] |
#define FIN_Y_MAX 520-1 // [pixel] |
// Inoltre si possono usare le seguenti + comode define |
// con gli stessi valori: |
#define X0 FIN_X_MIN |
#define X1 FIN_X_MAX |
#define Y0 FIN_Y_MIN |
#define Y1 FIN_Y_MAX |
// NB: non e' necessaria la proporzionalita' tra finestra |
// reale(BASE_L*BASE_H) e virtuale((X1-X0)*(Y1-Y0))! |
// Finestra Misure |
#define FRAME_MISURE_LINE_COLOR FAB_green |
#define FRAME_MISURE_BACK_COLOR FAB_black |
#define FRAME_MISURE_ORIZ_LY 30 |
#define FRAME_MISURE_VERT_LX 52 |
// Finestra Titolo |
#define FRAME_TITOLO_TEXT_COLOR1 FAB_yellow |
#define FRAME_TITOLO_TEXT_COLOR2 FAB_white |
#define FRAME_TITOLO_BACK_COLOR1 FAB_gray |
#define FRAME_TITOLO_BACK_COLOR2 FAB_blue |
// Finestra Comandi |
#define FRAME_COMANDI_TEXT_COLOR1 FAB_yellow |
#define FRAME_COMANDI_TEXT_COLOR2 FAB_white |
#define FRAME_COMANDI_TEXT_COLOR3 FAB_red |
#define FRAME_COMANDI_BACK_COLOR1 FAB_gray |
#define FRAME_COMANDI_BACK_COLOR2 FAB_yellow |
// Finestra Control |
#define FRAME_CONTROL_TEXT_COLOR1 FAB_rgb( 50,255, 50) |
#define FRAME_CONTROL_TEXT_COLOR2 FAB_rgb(150,255,150) |
#define FRAME_CONTROL_BACK_COLOR FAB_black |
// --------------------------------- |
// *** Elementi Task Dummy_radar *** |
// --------------------------------- |
#define DUMMY_RADAR_GROUP 3 |
#define DUMMY_RADAR_PERIOD 50000 |
#define DUMMY_RADAR_WCET 400 |
#define DUMMY_RADAR_MET 200 |
// --------------------------------- |
// *** Elementi Task Control *** |
// --------------------------------- |
#define CONTROL_PERIOD 50000 |
#define CONTROL_WCET 400 |
#define CONTROL_MET 300 |
// --------------------------- |
// *** Elementi Task Esplo *** |
// --------------------------- |
#define ESPLO_TRASPARENT_COL FAB_white |
#define ESPLO_LX 40 |
#define ESPLO_LY 40 |
#define ESPLO_PERIOD 80000 |
#define ESPLO_WCET 300 |
#define ESPLO_MET 100 |
// ----------------------------------- |
// *** Elementi Task Aereo_Creator *** |
// ----------------------------------- |
#define AEREO_CREATOR_PERIOD 200000 |
#define AEREO_CREATOR_WCET 300 |
#define AEREO_CREATOR_MET 100 |
// ----------------------------------- |
// *** Elementi Task Cannone_Creator *** |
// ----------------------------------- |
#define CANNONE_CREATOR_PERIOD 1000000 |
#define CANNONE_CREATOR_WCET 150 |
#define CANNONE_CREATOR_MET 50 |
// --------------------------- |
// *** Elementi Task Aereo *** |
// --------------------------- |
#define AEREO_N_MAX 10 |
#define AEREO_N_MIN 1 |
#define AEREO_TRASPARENT_COL FAB_white |
#define AEREO_BASE_COL FAB_green |
#define AEREO_LX 32 |
#define AEREO_LY 19 |
#define AEREO_H_MIN 500 // [m]: altezza min di volo |
#define AEREO_H_MAX 2000 // [m]: altezza max di volo (<BASE_H) |
#define AEREO_L_MIN 0 // [km]: posizione 0 nella base |
#define AEREO_L_MAX BASE_L // [km] posizione max nella base |
#define AEREO_V_MIN 300.0 // [Km/h]: velocit min di volo |
#define AEREO_V_MAX 500.0 // [Km/h]: velocit max di volo |
#define AEREO_X_MIN X0 - AEREO_LX/2 |
#define AEREO_X_MAX X1 + AEREO_LX/2 |
#define AEREO_PERIOD 30000 |
#define AEREO_WCET 1250 //Verificato! |
#define AEREO_MET 800 |
struct { BYTE status; //[0=free/1=occupato] |
BYTE killing; //richiesta uscita se 1 altrimenti 0 |
PID pid; |
COLOR color; |
FAB_IMAGE* image; |
double vel; //[km/h] |
int dir; //[+1/-1] |
WORD h; //[m] |
double l; //[km] |
WORD x, y; //[pixel] |
} aereo_table[AEREO_N_MAX]; |
int aereo_count; |
// ----------------------------- |
// *** Elementi Task Cannone *** |
// ----------------------------- |
#define CANNONE_N_MAX 9 |
#define CANNONE_N_MIN 1 |
#define CANNONE_SENSIBILITA 200 //[m] |
#define CANNONE_TRASPARENT_COL FAB_white |
#define CANNONE_LX 33 |
#define CANNONE_LY 15 |
#define CANNONE_PERIOD 100000 |
#define CANNONE_WCET 1000 |
#define CANNONE_MET 100 |
struct { BYTE status; //[0=free/1=occupato] |
BYTE killing; //richiesta uscita se 1 altrimenti 0 |
PID pid; |
BYTE fire; |
WORD x; |
double missile_vel; |
} cannone_table[CANNONE_N_MAX]; |
int cannone_count; |
// ----------------------------- |
// *** Elementi Task Missile *** |
// ----------------------------- |
#define MISSILE_V_MIN 300.0 //[km/h] |
#define MISSILE_V_MAX 5000.0 //[km/h] |
#define MISSILE_ACC_MIN 100000.0 //[km/(h*h)] |
#define MISSILE_ACC_MAX 10000000.0 //[km/(h*h)] |
#define MISSILE_X_MAX X1 + MISSILE_LX/2 //[pixel] |
#define MISSILE_X_MIN X0 - MISSILE_LX/2 //[pixel] |
#define MISSILE_Y_MAX Y1 + MISSILE_LY/2 //[pixel] |
#define MISSILE_Y_MIN Y0 - MISSILE_LY/2 //[pixel] |
#define MISSILE_TRASPARENT_COL FAB_white |
#define MISSILE_LX 7 //[pixel] |
#define MISSILE_LY 15 //[pixel] |
#define MISSILE_PERIOD 10000 |
#define MISSILE_WCET 500 |
#define MISSILE_MET 100 |
// MUTEX: |
mutex_t grx_mutex; //per l'accesso alla grafica |
int app_mutex_init(mutex_t *m); |
// FUNZIONI GESTIONE RISORSE DI MEMORIA: |
void kern_init_bca(); |
//------------------END------------------ |
#endif |
/demos/tags/rel_0_3/bca/makefile |
---|
0,0 → 1,16 |
# |
# |
# |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
PROGS= bca |
include $(BASE)/config/example.mk |
bca: |
make -f $(SUBMAKE) APP=bca INIT= OTHEROBJS="initfile.o fab_lib.o bca_lib.o" |
/demos/tags/rel_0_3/bca/fab_lib/fab_grx.h |
---|
0,0 → 1,201 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: fab_grx.h,v 1.2 2002-10-01 10:33:52 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: FAB_grx.h * |
* libreria: FAB_LIB * |
* version: 1.0 25/08/2002 * |
* creato da: Fabio CALABRESE * |
* * |
**************************************************** |
* * |
* descrizione: libreria di funzioni grafiche: * |
* permette di gestire con facilita' * |
* immagini, cornici, e veri e propri * |
* pannelli colorati. * |
* Il contesto di grafica va avviato * |
* con FAB_grx_open() e alla fine * |
* chiuso correttamente con la funz. * |
* FAB_grx_close(). L'ambiente di * |
* grafica e'impostato a 16bit per * |
* default, comunque e' sempre * |
* possibile scegliere la profondita' * |
* di colori preferita tra 15/16/24/32* |
* definendo semplicemente solo una * |
* delle seguenti costanti all'inizio * |
* del proprio programma che include * |
* questa libreria grafica: * |
* FAB_GRX_15 * |
* FAB_GRX_16 (default) * |
* FAB_GRX_24 * |
* FAB_GRX_32 * |
* * |
****************************************************/ |
#ifndef __FAB_LIB_fab_grx_h__ |
#define __FAB_LIB_fab_grx_h__ |
//-------------------BEGIN--------------------------- |
// *** Librerie di S.Ha.R.K. *** |
#include<kernel/kern.h> |
#include<drivers/gd.h> |
#include<ll/sys/types.h> |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
#include"fab_grx.sys" |
//#define FAB_GRX_15 |
//#define FAB_GRX_16 |
//#define FAB_GRX_24 |
//#define FAB_GRX_32 |
typedef __FAB_COLOR COLOR; |
typedef struct { |
WORD lx,ly; |
COLOR * buf; |
int trasparent; |
COLOR trasparent_col; |
} FAB_IMAGE; |
typedef struct { |
WORD dim; |
COLOR * buf; |
} FAB_BORDER; |
typedef struct { |
FAB_BORDER * border; //default = NULL |
WORD border_dim; //default = 0 |
COLOR border_col; |
BYTE trasparent; //default = 0 |
FAB_IMAGE * image; //default = NULL |
COLOR color; |
WORD x0,y0,x1,y1; //spigoli pannello interno |
//cornice esclusa: vengono settati |
//automaticamente con FAB_frame_put(). |
} FAB_FRAME; |
typedef struct { |
FAB_BORDER * border; //default = NULL |
WORD border_dim; //default = 0 |
COLOR border_col; |
BYTE trasparent; //default = 0 |
COLOR color; |
WORD cx,cy,r; //centro e raggio del pannello |
//circolare: vengono settati |
//automaticamente con FAB_ballframe_put(). |
} FAB_BALLFRAME; |
// ----------- |
// Definizioni |
//---------------------- |
#define FAB_BPP __FAB_BPP |
#define FAB_rgb(R24,G24,B24) __FAB_rgb((R24),(G24),(B24)) |
// Colori base |
#define FAB_white FAB_rgb(255,255,255) |
#define FAB_black FAB_rgb( 0, 0, 0) |
#define FAB_red FAB_rgb(255, 0, 0) |
#define FAB_green FAB_rgb( 0,255, 0) |
#define FAB_blue FAB_rgb( 0, 0,255) |
#define FAB_yellow FAB_rgb(255,255, 0) |
#define FAB_gray FAB_rgb(100,100,100) |
//---------------------- |
// ---------------- |
// Funzioni & Macro |
//-------------------------------------------------- |
int FAB_grx_open(WORD lx, WORD ly); |
void FAB_grx_close(); |
FAB_IMAGE* FAB_image_alloc(WORD lx, WORD ly); //richiede DISABLED INTERRUPTS |
void FAB_image_free(FAB_IMAGE* image); //richiede DISABLED INTERRUPTS |
FAB_BORDER* FAB_border_alloc(WORD dim); //richiede DISABLED INTERRUPTS |
void FAB_border_free(FAB_BORDER * border);//richiede DISABLED INTERRUPTS |
FAB_FRAME* FAB_frame_alloc(); //richiede DISABLED INTERRUPTS |
void FAB_frame_free(FAB_FRAME * frame); //richiede DISABLED INTERRUPTS |
FAB_BALLFRAME* FAB_ballframe_alloc(); //richiede DISABLED INTERRUPTS |
void FAB_ballframe_free(FAB_BALLFRAME * frame);//richiede DISABLED INTERRUPTS |
// Permette di riempire lo spazio allocato ad un FAB_IMAGE |
// leggendo le sequenze rgb a 24bit da un file immagine binario. |
// Un formato perfettamente compatibile quello |
// "RAW"(con header=0 e sequenza ad ordinamento RGB-RGB-RGB...): |
int FAB_image_load(FAB_IMAGE* image, char* file_name); // solo in __kernel_register_levels__() |
// Per default un FAB_IMAGE non ha il colore di trasparenza: |
#define FAB_image_no_trasparent_set(IMAGE) (IMAGE)->trasparent=0 |
#define FAB_image_trasparent_set(IMAGE,TRASPARENT_COL) (IMAGE)->trasparent=1;(IMAGE)->trasparent_col=(TRASPARENT_COL) |
// Settaggio FAB_BORDER deve essere fatto manualmente! |
// esempio: |
// mio_border->buf[i] = FAB_rgb(0,100,0); |
// ... |
// mio_border->buf[N] = FAB_rgb(0,100,255); |
// (non esiste una funzione FAB_border_set) |
#define FAB_frame_border_set(FRAME,BORDER,BORDER_DIM,BORDER_COL) (FRAME)->border=(BORDER);(FRAME)->border_dim=(BORDER_DIM);(FRAME)->border_col=(BORDER_COL); |
#define FAB_frame_color_set(FRAME,TRASPARENT_FLAG,IMAGE,COLOR) (FRAME)->trasparent=(TRASPARENT_FLAG);(FRAME)->image=(IMAGE);(FRAME)->color=(COLOR); |
#define FAB_ballframe_border_set(FRAME,BORDER,BORDER_DIM,BORDER_COL) (FRAME)->border=(BORDER);(FRAME)->border_dim=(BORDER_DIM);(FRAME)->border_col=(BORDER_COL); |
#define FAB_ballframe_color_set(FRAME,TRASPARENT_FLAG,COLOR) (FRAME)->trasparent=(TRASPARENT_FLAG);(FRAME)->color=(COLOR); |
void FAB_ball_put(WORD cx, WORD cy, WORD r, COLOR c); |
void FAB_image_get(FAB_IMAGE* image, WORD x, WORD y, WORD lx, WORD ly); |
void FAB_image_put(FAB_IMAGE* image, WORD x, WORD y); |
void FAB_image_put_within(FAB_IMAGE* image, WORD x0, WORD y0, |
WORD xx0, WORD yy0, WORD xx1, WORD yy1); |
void FAB_image_copy(FAB_IMAGE* orig_image, FAB_IMAGE* dest_image); |
void FAB_image_color_change(FAB_IMAGE* image, COLOR old_col, COLOR new_col); |
void FAB_image_fill(FAB_IMAGE* image, WORD x0, WORD y0, WORD lx, WORD ly); |
void FAB_border_put(FAB_BORDER* border, WORD x0, WORD y0, WORD x1, WORD y1); |
void FAB_ballborder_put(FAB_BORDER* border, WORD cx, WORD cy, WORD r_int); |
void FAB_frame_put(FAB_FRAME* frame, WORD x0, WORD y0, WORD lx, WORD ly); |
void FAB_ballframe_put(FAB_BALLFRAME* frame, WORD cx, WORD cy, WORD r); |
//-------------------------------------------------- |
// Altro... |
//---------------------END--------------------------- |
#endif |
/demos/tags/rel_0_3/bca/fab_lib/fab_show.h |
---|
0,0 → 1,83 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: fab_show.h,v 1.2 2002-10-01 10:33:52 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: FAB_show.h * |
* libreria: FAB_LIB * |
* version: 1.0 25/08/2002 * |
* creato da: Fabio CALABRESE * |
* * |
**************************************************** |
* * |
* descrizione: libreria di funzioni per stampare * |
* specifiche informazioni utili * |
* riguardo lo stato del sistema. * |
* * |
****************************************************/ |
#ifndef __FAB_LIB__FAB_show_h__ |
#define __FAB_LIB__FAB_show_h__ |
//-------------------BEGIN--------------------------- |
// *** Librerie S.Ha.R.K *** |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
#include "fab_msg.h" |
// ----------- |
// Definizioni |
//---------------------- |
//---------------------- |
// ---------------- |
// Funzioni & Macro |
//------------------------------------------------- |
void FAB_show_sched_modules(); |
//-------------------------------------------------- |
// Altro... |
//----------------------END-------------------------- |
#endif |
/demos/tags/rel_0_3/bca/fab_lib/fab_msg.h |
---|
0,0 → 1,96 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: fab_msg.h,v 1.1 2002-10-01 10:25:02 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: FAB_msg.h * |
* libreria: FAB_LIB * |
* version: 1.0 25/08/2002 * |
* creato da: Fabio CALABRESE * |
* * |
**************************************************** |
* * |
* descrizione: libreria di funzioni per stampare * |
* messaggi circa il corretto esito * |
* dell'esecuzione delle istruzioni; * |
* stampa semplici stringhe colorate; * |
* aiuta a fare il debbuging. * |
* * |
****************************************************/ |
#ifndef __FAB_LIB__FAB_msg_h__ |
#define __FAB_LIB__FAB_msg_h__ |
//-------------------BEGIN--------------------------- |
// *** Librerie di S.Ha.R.K. *** |
#include <ll/i386/cons.h> |
// *** Librerie Standard C *** |
// *** Librerie FAB *** |
// ----------- |
// Definizioni |
//---------------------- |
#define FAB_EXIT_YES 1 |
#define FAB_EXIT_NO 0 |
#define FAB_EMPTY_MSG "" |
//---------------------- |
// ---------------- |
// Funzioni & Macro |
//------------------------------------------------- |
#define FAB_newline() NL() |
#define FAB_home() HOME() |
#define FAB_clr() clear() |
void FAB_print(char * InitMsg, char * msg); |
#define FAB_msg(TEST,INITMSG,OKMSG,ERRORMSG) __FAB_go2((TEST),(INITMSG),(OKMSG),(ERRORMSG),FAB_EXIT_NO) |
#define FAB_go(TEST,INITMSG,OKMSG,ERRORMSG,EXITFLAG) __FAB_go2((TEST),(INITMSG),(OKMSG),(ERRORMSG),(EXITFLAG)) |
//-------------------------------------------------- |
// Altro... |
void __FAB_go(int test, char * OkMsg, char * ErrorMsg,int EXITflag); |
#define __FAB_go2(TEST,INITMSG,OKMSG,ERRORMSG,EXITFLAG) {if ((INITMSG)!=NULL) cprintf("\n[%s]",(INITMSG)); __FAB_go((TEST),(OKMSG),(ERRORMSG),(EXITFLAG));} |
//----------------------END-------------------------- |
#endif |
/demos/tags/rel_0_3/bca/fab_lib/fab_grx.sys |
---|
0,0 → 1,71 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: fab_grx.sys,v 1.1 2002-10-01 10:25:02 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
// file incluso da FAB_grx.h |
// ------------------------- |
typedef BYTE COLOR8; |
typedef WORD COLOR15; |
typedef WORD COLOR16; |
typedef DWORD COLOR24; |
typedef DWORD COLOR32; |
#if defined FAB_GRX_15 |
#define __FAB_BPP 15 |
#define __FAB_rgb(R24,G24,B24) rgb15((R24),(G24),(B24)) |
typedef COLOR15 __FAB_COLOR; |
#elif defined FAB_GRX_16 |
#define __FAB_BPP 16 |
#define __FAB_rgb(R24,G24,B24) rgb16((R24),(G24),(B24)) |
typedef COLOR16 __FAB_COLOR; |
#elif defined FAB_GRX_24 |
#define __FAB_BPP 24 |
#define __FAB_rgb(R24,G24,B24) rgb24((R24),(G24),(B24)) |
typedef COLOR24 __FAB_COLOR; |
#elif defined FAB_GRX_32 |
#define __FAB_BPP 32 |
#define __FAB_rgb(R24,G24,B24) rgb32((R24),(G24),(B24)) |
typedef COLOR32 __FAB_COLOR; |
#else |
#define __FAB_BPP 16 |
#define __FAB_rgb(R24,G24,B24) rgb16((R24),(G24),(B24)) |
typedef COLOR16 __FAB_COLOR; |
#endif |
/demos/tags/rel_0_3/bca/fab_lib/fab_tool.h |
---|
0,0 → 1,90 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: fab_tool.h,v 1.1 2002-10-01 10:25:03 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
/**************************************************** |
* * |
* file: FAB_tool.h * |
* libreria: FAB_LIB * |
* version: 1.0 25/08/2002 * |
* creato da: Fabio CALABRESE * |
* * |
**************************************************** |
* * |
* descrizione: tool di funzioni d'utilita' * |
* * |
****************************************************/ |
#ifndef __FAB_LIB__FAB_tool_h__ |
#define __FAB_LIB__FAB_tool_h__ |
//-------------------BEGIN--------------------------- |
// *** Librerie S.Ha.R.K *** |
// *** Librerie Standard C *** |
#include <stdlib.h> |
#include <math.h> |
// *** Librerie FAB *** |
// ----------- |
// Definizioni |
//---------------------- |
//---------------------- |
// ---------------- |
// Funzioni & Macro |
//------------------------------------------------- |
#define FAB_PI 3.141592654 |
#define FAB_grad(RADIANTI) RADIANTI/FAB_PI*180 |
#define FAB_rad(GRADI) GRADI/180.0*FAB_PI |
#define FAB_set_ang360(ANGOLO,X,Y) if ((X)>0) {if((Y)>0) (ANGOLO)=atan((Y)/(double)(X));else if((Y)<0) (ANGOLO)=atan((Y)/(double)(X))+2*FAB_PI;else (ANGOLO)=0;}else if ((X)<0) (ANGOLO)=atan((Y)/(double)(X))+FAB_PI;else /* X==0 */if ((Y)>0) (ANGOLO)=FAB_PI/2;else if ((Y)<0) (ANGOLO)=FAB_PI/2+FAB_PI;else /* Y==0 */ (ANGOLO)=-1; /* X=Y=0 */ |
#define FAB_set_xy360(X,Y,MODULO,ANGOLO) (X)=(MODULO)*cos(ANGOLO);(Y)=(MODULO)*sin(ANGOLO); |
#define FAB_ABS(X) ((X) > 0 ? (X) : (X)*-1) |
#define FAB_sign_rand() (rand()%2 ? -1 : +1) |
#define FAB_int_rand(MIN,MAX ) ((MIN) + rand()%((MAX)-(MIN)+1)) |
#define FAB_double_rand(MIN,MAX) ((MIN) + ((MAX)-(MIN))*((double)rand()/RAND_MAX)) |
//-------------------------------------------------- |
// Altro... |
//----------------------END-------------------------- |
#endif |
/demos/tags/rel_0_3/bca/scenario.c |
---|
0,0 → 1,168 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: scenario.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
//*************************** |
//* file: scenario.c * |
//* included by: bca.c * |
//*************************** |
void scenario_ca() |
{ //SFONDO |
FAB_image_fill(image_sfondo,0,0,800,600); |
//FRAME_BCA |
FAB_frame_put(frame_bca,X0-7,Y0-7,500+7*2,500+7*2); |
} |
void scenario_misure() |
{ int x, y, cx, cy; |
char* str_km ="X.Xkm"; |
char* str_m ="XXXXm"; |
int h; |
//FRAME_MISURE orizzontale |
FAB_frame_put(frame_misure_oriz, X0-7, Y1+7+20-7, |
500+7*2, FRAME_MISURE_ORIZ_LY+7*2); |
cy = frame_misure_oriz->y0 + 10; |
cx = frame_misure_oriz->x0 + |
(frame_misure_oriz->x1 - frame_misure_oriz->x0) / 2; |
for(x=frame_misure_oriz->x0 ;x<frame_misure_oriz->x1+1 ;x+=5) |
grx_line(x,cy,x+2,cy,FRAME_MISURE_LINE_COLOR); |
for(y=frame_misure_oriz->y0; y<cy-1; y+=5) { |
grx_line(frame_misure_oriz->x0,y,frame_misure_oriz->x0,y+2,FRAME_MISURE_LINE_COLOR); |
grx_line(cx,y,cx,y+2,FRAME_MISURE_LINE_COLOR); |
grx_line(frame_misure_oriz->x1,y,frame_misure_oriz->x1,y+2,FRAME_MISURE_LINE_COLOR); |
} |
sprintf(str_km,"%02.1fkm",0.0); |
grx_text(str_km,frame_misure_oriz->x0+10,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
sprintf(str_km,"%02.1fkm",BASE_L/2.0); |
grx_text(str_km,cx-10,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
sprintf(str_km,"%02.1fkm",BASE_L); |
grx_text(str_km,frame_misure_oriz->x1-FRAME_MISURE_ORIZ_LY,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
//FRAME_MISURE verticale |
FAB_frame_put(frame_misure_vert, X1+7+20-7, Y0-7, |
FRAME_MISURE_VERT_LX+7*2, 500+7*2); |
cy = frame_misure_vert->y0 + |
(frame_misure_vert->y1 - frame_misure_vert->y0) / 2; |
cx = frame_misure_vert->x0 + 10; |
for(y=frame_misure_vert->y1; y>frame_misure_vert->y0-1; y-=5) |
grx_line(cx,y,cx,y-2,FRAME_MISURE_LINE_COLOR); |
h=0; |
for(y=frame_misure_vert->y1; y>frame_misure_vert->y0-1; |
y-=500.0*(X1-X0)/BASE_H, h+=500) { |
for(x=frame_misure_vert->x0; x<cx-1; x+=5) |
grx_line(x,y,x+2,y,FRAME_MISURE_LINE_COLOR); |
sprintf(str_m,"%dm",h); |
grx_text(str_m, cx+2, y-6, |
FRAME_MISURE_LINE_COLOR, frame_misure_vert->color); |
} |
} |
void scenario_radar() |
{ FAB_ballframe_put(ballframe_radar, |
frame_bca->x1+7+30, frame_bca->y1+7+30, 30); |
FAB_ballframe_put(ballframe_lucerossa[2],605,546,20); |
FAB_ballframe_put(ballframe_lucerossa[1],594,578,15); |
FAB_ballframe_put(ballframe_lucerossa[0],574,591,10); |
} |
void scenario_titolo() |
{ int x0,y0; |
x0 = frame_misure_vert->x1+7+20-7; |
y0 = frame_bca->y0-7; |
FAB_frame_put(frame_titolo,x0,y0,800-x0-20+7,170); |
x0 = frame_titolo->x0; |
y0 = frame_titolo->y0; |
grx_text(titolo[0],x0+2,y0+10,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[1],x0+2,y0+20,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[2],x0+2,y0+30,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[3],x0+2,y0+46,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[4],x0+2,y0+66,FRAME_TITOLO_TEXT_COLOR1,FRAME_TITOLO_BACK_COLOR2); |
grx_text(titolo[5],x0+2,y0+81,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[6],x0+2,y0+96,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[7],x0+2,y0+116,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[8],x0+2,y0+133,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
grx_text(titolo[9],x0+2,y0+141,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
} |
void scenario_comandi() |
{ int x0, y0; |
x0 = frame_misure_vert->x1+7+20-7; |
y0 = frame_titolo->y1+7+20-7; |
FAB_frame_put(frame_comandi,x0,y0,800-x0-20+7,100+7*2); |
x0 = frame_comandi->x0; |
y0 = frame_comandi->y0; |
grx_text(" COMANDI \0",x0+2,y0+10,FRAME_COMANDI_TEXT_COLOR1,FRAME_COMANDI_BACK_COLOR1); |
grx_text("-------------------\0",x0+2,y0+20,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text(" esci \0",x0+2,y0+40,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text("[INVIO]",x0+2,y0+40,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
grx_text(" +/- aerei \0",x0+2,y0+60,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text("[1/2]",x0+2,y0+60,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
grx_text(" +/- cannoni\0",x0+2,y0+80,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
grx_text("[3/4]",x0+2,y0+80,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
} |
void scenario_control() |
{ int x0,y0; |
x0 = frame_misure_vert->x1+7+20-7; |
y0 = frame_comandi->y1+7+20-7; |
FAB_frame_put(frame_control,x0,y0,800-x0-20+7,frame_misure_vert->y1+7-y0); |
x0 = frame_control->x0; |
y0 = frame_control->y0; |
grx_text(" CONTROL \0",x0+2, y0+5,FRAME_CONTROL_TEXT_COLOR2,FRAME_CONTROL_BACK_COLOR); |
grx_line(x0-3, y0+15, |
frame_control->x1+3, y0+15, |
FRAME_CONTROL_TEXT_COLOR1); |
grx_line(x0-3, frame_control->y1-81, |
frame_control->x1+3, frame_control->y1-81, |
FRAME_CONTROL_TEXT_COLOR1); |
} |
void scenario() |
{ scenario_ca(); |
scenario_misure(); |
scenario_radar(); |
scenario_titolo(); |
scenario_comandi(); |
scenario_control(); |
} |
void info() |
{ int i; |
for(i=0; i<10; i++) kern_printf("%s\n",titolo[i]); |
} |
/demos/tags/rel_0_3/bca/missile.c |
---|
0,0 → 1,198 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: |
* Giorgio Buttazzo <giorgio@sssup.it> |
* Paolo Gai <pj@gandalf.sssup.it> |
* |
* Authors : |
* Paolo Gai <pj@gandalf.sssup.it> |
* Massimiliano Giorgi <massy@gandalf.sssup.it> |
* Luca Abeni <luca@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: missile.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */ |
/* |
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
* |
* 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 |
* |
*/ |
//************************** |
//* file: missile.c * |
//* included by: bca.c * |
//************************** |
TASK missile(void *arg) |
{ |
PID esplo_pid; |
int img; |
int i, index; // indice nella cannone_table |
int distx, disty; |
int xx0,yy0,xx1,yy1; |
double vel, acc; |
double a; |
double y; |
double x; |
double old_x; // [pixel]: conserva valore x prima di aggiornare |
double old_y; |
double dx; // [pixel/us]: spostamento periodico |
double dy; |
int first_time; |
int killing; |
index = (int)arg; |
img=0; |
y = MISSILE_Y_MAX; |
x = cannone_table[index].x; |
a = FAB_rad(270); |
vel = MISSILE_V_MIN; |
acc = MISSILE_ACC_MIN; |
dx = 0; |
dy = 0; |
first_time = 1; |
killing = 0; |
while(1){ |
old_x = x; |
old_y = y; |
if (vel<MISSILE_V_MAX) { |
vel += acc*MISSILE_PERIOD/(60*60*1000000.0); |
if (vel>MISSILE_V_MAX) vel = MISSILE_V_MAX; |
} |
if (acc<MISSILE_ACC_MAX) { |
acc += MISSILE_ACC_MIN; |
if (acc>MISSILE_ACC_MAX) acc = MISSILE_ACC_MAX; |
} |
cannone_table[index].missile_vel=vel; |
dx = cos(a)*vel * (X1-X0) / (double)BASE_L |
* (MISSILE_PERIOD / (60*60*1000000.0)); |
dy = sin(a)*vel * (Y1-Y0) / ((double)BASE_H/1000) |
* (MISSILE_PERIOD / (60*60*1000000.0)); |
x += dx; |
y += dy; |
xx0 = old_x - MISSILE_LX/2; |
yy0 = old_y - MISSILE_LY/2; |
xx1 = xx0 + MISSILE_LX-1; |
yy1 = yy0 + MISSILE_LY-1; |
if (x<MISSILE_X_MIN || x>MISSILE_X_MAX |
|| y<MISSILE_Y_MIN || y>MISSILE_Y_MAX) { |
killing = 1; |
} |
if (killing) { |
if (!first_time) { |
mutex_lock(&grx_mutex); |
FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
mutex_unlock(&grx_mutex); |
} |
cannone_table[index].fire = 0; |
//il task cannone si accorge che il suo missile ha finito |
// quindi ne ricreer uno nuovo in caso di bersaglio!!! |
return NULL; |
} |
if ( (int)x != (int)old_x |
||(int)y != (int)old_y ) {//...se c' lo spostamento reale |
// di almeno un pixel... |
mutex_lock(&grx_mutex); //...aggiorna disegno... |
if (first_time) { |
first_time=0; |
} |
else { |
if (yy1<Y1-CANNONE_LY) FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
else FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,Y1-CANNONE_LY); |
} |
FAB_image_put_within(image_missile[img++], x - MISSILE_LX/2, y - MISSILE_LY/2, |
X0, Y0, |
X1, Y1-CANNONE_LY); |
mutex_unlock(&grx_mutex); |
if (img==2) img = 0; |
} |
//Ha colpito un aereo? |
for (i=0; i<AEREO_N_MAX; i++) |
if (aereo_table[i].status){ |
distx = aereo_table[i].x-x; |
disty = aereo_table[i].y-y; |
if (distx<0) distx *= -1; |
if (disty<0) disty *= -1; |
if ( distx<(AEREO_LX+MISSILE_LX)/2-1 |
&&disty<(AEREO_LY+MISSILE_LY)/2-1 ) { // BERSAGLIO COLPITO! |
esplo_pid = crea_soft_esplo(i); |
task_activate(esplo_pid); |
killing=1; |
aereo_table[i].killing=1; |
break; |
} |
} |
task_endcycle(); |
} |
return NULL; |
} |
PID crea_hard_missile(int index) |
{ |
HARD_TASK_MODEL m; |
PID pid; |
hard_task_default_model(m); |
hard_task_def_level(m,0); |
hard_task_def_arg(m,(void*)index); |
hard_task_def_periodic(m); |
hard_task_def_wcet(m, MISSILE_WCET); |
hard_task_def_mit(m,MISSILE_PERIOD); |
pid = task_create("hard_missile", missile, &m, NULL); |
return pid; |
} |
PID crea_soft_missile(int index) |
{ |
SOFT_TASK_MODEL m; |
PID pid; |
soft_task_default_model(m); |
soft_task_def_level(m,0); |
soft_task_def_arg(m,(void*)index); |
soft_task_def_periodic(m); |
soft_task_def_period(m,MISSILE_PERIOD); |
soft_task_def_wcet(m, MISSILE_WCET); |
soft_task_def_met(m,MISSILE_MET); |
pid = task_create("soft_missile", missile, &m, NULL); |
return pid; |
} |
/demos/tags/rel_0_3/bca/readme |
---|
0,0 → 1,11 |
Hi, |
This is a nice simulation made by Fabio Calabrese |
(fabiocalabrese77@yahoo.it). |
Documentation is also available in PDF form on the shark website (only |
in italian, sorry). |
Enjoy |
PJ |
/demos/tags/rel_0_3/bca/bca_raw/esplo5.raw |
---|
0,0 → 1,65 |
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ)&ÿÿÿÿÿÿÿÿÿ |
ÿÿÿÿÿÿ +*#! |
.*% ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ):'+) :-65/1&&ÿÿÿÿÿÿ *-"&* %!&$)"%+-&% &!+%)&ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ |
+.(B= 7342)& |
+ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ $ )&.(:/G7'H7/@3-) 62& +* EE HJ MRNSHNOS2JN7Y\K<=/0/@@('& |
+/,")#+#?4 i]GcU:i[6}nEmEuDzo-xr(^ZDB :6'%30//3627 9=BE`a7**! *'1-KH7*'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ |
+ &QC(eW2o`9E4]M,QE[Uzv9eb/63#!+*#% 47 |
+$& |