Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1123 → Rev 1377

/demos/trunk/base/cabs.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: cabs.c,v 1.3 2003-01-07 17:10:15 pj Exp $
* CVS : $Id: cabs.c,v 1.4 2004-04-17 11:36:13 giacomo Exp $
*/
 
/*--------------------------------------------------------------*/
43,10 → 43,16
 
#include <kernel/kern.h>
#include <modules/cabs.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
#define NCAB 4 /* max number of CABs */
#define NCAR 26 /* generated characters */
 
85,17 → 91,80
TIME w1[NCAB] = {10000, 10000, 10000, 10000};
TIME w2[NCAB] = {10000, 10000, 10000, 10000};
 
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
FB26_init();
FB26_open(FRAME_BUFFER_DEVICE);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
return 0;
}
 
int device_drivers_close() {
 
FB26_close(FRAME_BUFFER_DEVICE);
 
KEYB26_close();
 
INPUT26_close();
 
return 0;
 
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_end();
 
return NULL;
 
}
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
 
/****************************************************************/
 
/* This function is called when Alt-X is pressed.
It simply shutdown the system using sys_end.
Note that the byebye() function is called only if we exit from
the system using sys_end()!!!!
*/
void my_end(KEY_EVT* e)
{
sys_end();
task_activate(shutdown_task_PID);
}
 
/******************************************************************/
114,22 → 183,10
NOT called
*/
 
 
/*--------------------------------------------------------------*/
/* User exit function */
/*--------------------------------------------------------------*/
 
void byebye(void *arg)
{
grx_close();
cprintf("Bye Bye!\n");
}
 
/*--------------------------------------------------------------*/
/* Main task */
/*--------------------------------------------------------------*/
 
 
/****************************** MAIN ******************************/
 
int main(int argc, char **argv)
136,18 → 193,9
{
char c = 0; /* character from keyboard */
 
/* Set the closing function */
sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT);
set_shutdown_task();
 
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
if (grx_open(640, 480, 8) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
device_drivers_init();
 
grx_clear(BLACK);
 
161,7 → 209,7
create_channel(c-'1');
}
sys_end();
task_activate(shutdown_task_PID);
 
return 0;
}
267,9 → 315,9
hard_task_def_usemath (m);
p1[i] = task_create(pname1[i], producer, &m, NULL);
if (p1[i] == NIL) {
grx_close();
perror("Could not create task <producer>");
sys_abort(1);
sys_shutdown_message("Could not create task <producer>");
task_activate(shutdown_task_PID);
return;
}
task_activate(p1[i]);
 
281,9 → 329,9
hard_task_def_usemath (m);
p2[i] = task_create(pname2[i], consumer, &m, NULL);
if (p2[i] == NIL) {
grx_close();
perror("Could not create task <consumer>");
sys_abort(1);
sys_shutdown_message("Could not create task <consumer>");
task_activate(shutdown_task_PID);
return;
}
task_activate(p2[i]);
}
318,5 → 366,3
grx_text(buffer,X2+88,yc+R+16,14,0);
}
 
/*--------------------------------------------------------------*/