Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1448 → Rev 1447

/demos/trunk/bca/makefile
12,5 → 12,5
include $(BASE)/config/example.mk
 
bca:
make -f $(SUBMAKE) APP=bca INIT= OTHEROBJS="initfile.o fab_lib.o bca_lib.o" SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__"
make -f $(SUBMAKE) APP=bca INIT= OTHEROBJS="initfile.o fab_lib.o bca_lib.o" SHARKOPT="__OLDCHAR__ __GRX__"
 
/demos/trunk/bca/fab_lib.c
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: fab_lib.c,v 1.4 2004-05-23 08:59:27 giacomo Exp $ */
/* CVS : $Id: fab_lib.c,v 1.3 2003-01-07 17:10:16 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
55,9 → 55,8
// *** Librerie di S.Ha.R.K. ***
#include<kernel/kern.h>
#include<kernel/mem.h>
 
#include<drivers/shark_fb26.h>
 
#include<drivers/gd.h>
#include<drivers/glib.h>
#include<ll/sys/types.h>
#include<ll/i386/x-dos.h>
// *** Librerie Standard C ***
198,6 → 197,27
 
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;
/demos/trunk/bca/bca.c
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: bca.c,v 1.5 2004-05-23 08:59:27 giacomo Exp $ */
/* CVS : $Id: bca.c,v 1.4 2003-01-07 17:10:16 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
71,11 → 71,9
 
// *** Librerie S.Ha.R.K ***
#include <kernel/kern.h>
#include <drivers/keyb.h>
#include <ll/i386/cons.h>
 
#include <drivers/shark_fb26.h>
#include <drivers/shark_keyb26.h>
 
#include <drivers/glib.h>
// *** Librerie Standard C ***
#include <stdlib.h>
// *** Librerie FAB ***
124,8 → 122,32
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)
{ sys_shutdown_message("Ending...\n");
{ cprintf("Ending...\n");
sys_end();
}
void incrementa_aerei_fun(KEY_EVT* k)
146,33 → 168,33
PID pid;
 
KEY_EVT k;
keyb_set_map(itaMap);
 
k.flag = 0;
k.scan = KEY_ENT;
k.ascii = 13;
k.status = KEY_PRESSED;
keyb_hook(k,end_fun,FALSE);
keyb_hook(k,end_fun);
k.flag = 0;
k.scan = KEY_1;
k.ascii = '1';
k.status = KEY_PRESSED;
keyb_hook(k,incrementa_aerei_fun,FALSE);
keyb_hook(k,incrementa_aerei_fun);
k.flag = 0;
k.scan = KEY_2;
k.ascii = '2';
k.status = KEY_PRESSED;
keyb_hook(k,decrementa_aerei_fun,FALSE);
keyb_hook(k,decrementa_aerei_fun);
k.flag = 0;
k.scan = KEY_3;
k.ascii = '3';
k.status = KEY_PRESSED;
keyb_hook(k,incrementa_cannoni_fun,FALSE);
keyb_hook(k,incrementa_cannoni_fun);
k.flag = 0;
k.scan = KEY_4;
k.ascii = '4';
k.status = KEY_PRESSED;
keyb_hook(k,decrementa_cannoni_fun,FALSE);
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);
 
195,9 → 217,6
pid=crea_soft_control();
task_activate(pid);
//----------
 
return 0;
 
}
 
 
/demos/trunk/bca/initfile.c
6,7 → 6,9
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* 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)
16,7 → 18,11
* 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
33,70 → 39,66
*
*/
 
#define PI_MUTEX
/****************************************************
* *
* 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/intdrive.h"
#include "modules/edf.h"
#include "modules/hardcbs.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"
 
#include "modules/pi.h"
#include "modules/nop.h"
/*+ system tick in us +*/
#define TICK 1000
 
#include "bca.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_fb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 2000
#define RRTICK 10000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
void call_shutdown_task(void *arg);
int device_drivers_init();
int device_drivers_close();
void set_shutdown_task();
TASK shutdown_task_body(void *arg);
 
PID shutdown_task_PID = -1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
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)
103,30 → 105,25
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
KEYB_PARMS kparms = BASE_KEYB;
 
HARTPORT_init();
 
/* Create the shutdown task. It will be activated at RUNLEVEL
SHUTDOWN */
set_shutdown_task();
keyb_def_ctrlC(kparms, NULL);
KEYB_init(&kparms);
 
/* Init the drivers */
device_drivers_init();
 
/* Set the shutdown task activation */
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
}
 
#ifdef PI_MUTEX
#ifdef PI
int app_mutex_init(mutex_t *m)
{
PI_mutexattr_t attr;
 
PI_mutexattr_default(attr);
 
return mutex_init(m, &attr);
}
#else
133,98 → 130,10
int app_mutex_init(mutex_t *m)
{
NOP_mutexattr_t attr;
 
NOP_mutexattr_default(attr);
 
return mutex_init(m, &attr);
}
#endif
 
void set_shutdown_task() {
 
/* WARNING: the shutdown task is a background thread. It cannot execute
if the system is overloaded */
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
nrt_task_def_system(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
int device_drivers_init() {
 
int res;
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
INPUT26_init();
 
keyb_def_ctrlC(kparms, NULL);
 
KEYB26_init(&kparms);
 
FB26_init();
res = FB26_open(FRAME_BUFFER_DEVICE);
if (res) {
cprintf("Error: Cannot open graphical mode\n");
KEYB26_close();
INPUT26_close();
sys_end();
}
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"800x600-16");
return 0;
 
}
 
int device_drivers_close() {
FB26_close(FRAME_BUFFER_DEVICE);
KEYB26_close();
INPUT26_close();
return 0;
}
 
#define SHUTDOWN_TIMEOUT_SEC 3
 
void call_shutdown_task(void *arg)
{
struct timespec t;
 
sys_gettime(&t);
t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
 
/* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
 
task_activate(shutdown_task_PID);
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_abort_shutdown(0);
 
return NULL;
 
}
/demos/trunk/bca/bca_lib.c
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: bca_lib.c,v 1.4 2004-05-23 08:59:27 giacomo Exp $ */
/* CVS : $Id: bca_lib.c,v 1.3 2002-11-11 08:15:13 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
53,9 → 53,8
 
// *** Librerie S.Ha.R.K ***
#include<kernel/kern.h>
 
#include<drivers/shark_fb26.h>
 
#include<drivers/glib.h>
#include<drivers/gd.h>
// *** Librerie Standard C ***
// *** Librerie FAB ***
#include"fab_lib/fab_msg.h"
93,6 → 92,25
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;
102,7 → 120,7
aereo_table[j].image=FAB_image_alloc(AEREO_LX,AEREO_LY);
if(aereo_table[j].image==NULL) test=1;
}
FAB_msg(test,"fatto","almeno un elemento della tabella non allocato");
FAB_msg(test,NULL,"fatto","almeno un elemento della tabella non allocato");
}
void kern_free_task_tables()
{ int j;
137,7 → 155,7
ballframe_lucerossa[j] = FAB_ballframe_alloc();
if (ballframe_lucerossa[j]==NULL) test=1;
}
FAB_msg(test,"fatto","almeno un ballframe non allocato");
FAB_msg(test,NULL,"fatto","almeno un ballframe non allocato");
}
void kern_free_ballframes()
{ int j;
179,7 → 197,7
frame_control = FAB_frame_alloc();
if (frame_control==NULL) test=1;
 
FAB_msg(test,"fatto","almeno un frame non allocato");
FAB_msg(test,NULL,"fatto","almeno un frame non allocato");
}
void kern_free_frames()
{
227,7 → 245,7
border_giallo7 = FAB_border_alloc(7);
if (border_giallo7==NULL) test=1;
 
FAB_msg(test,"fatto","almeno un bordo non allocato");
FAB_msg(test,NULL,"fatto","almeno un bordo non allocato");
}
void kern_free_borders()
{
316,7 → 334,7
image_bca = FAB_image_alloc(500,500);
if (image_bca==NULL) test=1;
 
FAB_msg(test,"fatto","almeno un'immagine non allocata");
FAB_msg(test,NULL,"fatto","almeno un'immagine non allocata");
}
void kern_free_images()
{
387,26 → 405,9
if(FAB_image_load(image_bca,"BCA_raw/bca.raw")==-1) test=1;
FAB_image_no_trasparent_set(image_bca);
 
FAB_msg(test,"fatto","almeno un file non esiste oppure ha un formato incompatibile");
FAB_msg(test,NULL,"fatto","almeno un file non esiste oppure ha un formato incompatibile");
}
 
// *** Corpo delle funzioni in CA.h *** //
void kern_init_bca()
{
FAB_clr();
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();
}
 
//----------------------END--------------------------
#endif
/demos/trunk/bca/fab_lib/fab_grx.h
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: fab_grx.h,v 1.3 2004-05-23 08:59:28 giacomo Exp $ */
/* CVS : $Id: fab_grx.h,v 1.2 2002-10-01 10:33:52 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
76,11 → 76,9
//-------------------BEGIN---------------------------
 
// *** Librerie di S.Ha.R.K. ***
#include <kernel/kern.h>
#include <ll/sys/types.h>
 
#include <drivers/shark_fb26.h>
 
#include<kernel/kern.h>
#include<drivers/gd.h>
#include<ll/sys/types.h>
// *** Librerie Standard C ***
// *** Librerie FAB ***
#include"fab_grx.sys"
/demos/trunk/bca/fab_lib/fab_msg.h
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: fab_msg.h,v 1.2 2004-05-23 08:59:28 giacomo Exp $ */
/* CVS : $Id: fab_msg.h,v 1.1 2002-10-01 10:25:02 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
81,8 → 81,8
#define FAB_clr() clear()
 
void FAB_print(char * InitMsg, char * msg);
#define FAB_msg(TEST,OKMSG,ERRORMSG) __FAB_go((TEST),(OKMSG),(ERRORMSG),FAB_EXIT_NO)
#define FAB_go(TEST,OKMSG,ERRORMSG,EXITFLAG) __FAB_go((TEST),(OKMSG),(ERRORMSG),(EXITFLAG))
#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))
//--------------------------------------------------
 
 
89,6 → 89,8
// 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/trunk/bca/missile.c
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: missile.c,v 1.2 2004-05-23 08:59:28 giacomo Exp $ */
/* CVS : $Id: missile.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
44,10 → 44,6
//* included by: bca.c *
//**************************
 
PID crea_hard_missile(int index);
PID crea_soft_missile(int index);
PID crea_soft_esplo(int index);
 
TASK missile(void *arg)
{
PID esplo_pid;
/demos/trunk/bca/cannone.c
18,7 → 18,7
* http://shark.sssup.it
*/
 
/* CVS : $Id: cannone.c,v 1.2 2004-05-23 08:59:27 giacomo Exp $ */
/* CVS : $Id: cannone.c,v 1.1 2002-10-01 10:25:00 pj Exp $ */
 
/*
* Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it>
86,13 → 86,6
return NULL;
}
 
PID crea_soft_cannone_creator();
PID crea_hard_cannone(int index);
PID crea_hard_cannone(int index);
 
PID crea_hard_missile(int index);
PID crea_soft_missile(int index);
 
TASK cannone(void *arg)
{
PID missile_pid=-2;