Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1388 → Rev 1389

/demos/trunk/input/input.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
38,18 → 35,13
#include <stdlib.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
 
#include <drivers/shark_fb26.h>
 
#include <drivers/shark_input26.h>
#include <drivers/shark_mouse26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
#include <drivers/shark_joy26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
#define RGB_BLACK rgb16( 0, 0, 0)
#define RGB_GRAY rgb16(127,127,127)
#define RGB_WHITE rgb16(255,255,255)
66,24 → 58,60
#define RGB_D_MAGENTA rgb16(127, 0,127)
#define RGB_D_CYAN rgb16( 0,127,127)
 
void my_sysclose(KEY_EVT *e)
void my_sysend(KEY_EVT *e)
{
mouse_grxcursor(DISABLE, 0);
sys_end();
}
 
FB26_close(FRAME_BUFFER_DEVICE);
void no_note(KEY_EVT *e)
{
speaker_sound(0, 0);
}
 
MOUSE26_close();
KEYB26_close();
SPEAK26_close();
JOY26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
void my_note(KEY_EVT *e)
{
switch (e->scan) {
case KEY_Q:
speaker_sound(262, 0); /* DO */
break;
case KEY_W:
speaker_sound(277, 0); /* DO# */
break;
case KEY_E:
speaker_sound(294, 0); /* RE */
break;
case KEY_R:
speaker_sound(311, 0); /* RE# */
break;
case KEY_T:
speaker_sound(330, 0); /* MI */
break;
case KEY_Y:
speaker_sound(349, 0); /* FA */
break;
case KEY_U:
speaker_sound(370, 0); /* FA# */
break;
case KEY_I:
speaker_sound(392, 0); /* SOL */
break;
case KEY_O:
speaker_sound(415, 0); /* SOL# */
break;
case KEY_P:
speaker_sound(440, 0); /* LA */
break;
case KEY_BRL:
speaker_sound(466, 0); /* LA# */
break;
case KEY_BRR:
speaker_sound(494, 0); /* SI */
break;
}
}
 
TASK my_getjoy(void *arg) {
 
TASK my_getjoy(void *arg)
{
int a0, a1, a2, a3, btn;
char st[20];
 
99,11 → 127,13
 
task_endcycle();
if (btn == 0xF)
my_sysclose(NULL);
my_sysend(NULL);
}
}
 
TASK my_getch(void *arg) {
TASK my_getch(void *arg)
{
#define MYNCHAR 25
 
BYTE ch;
int i = 0;
112,24 → 142,261
while (1) {
ch = keyb_getch(NON_BLOCK);
if (ch) {
if (ch == BACKSPACE) { //backspace
i--;
//ch = 0x20;
}
if (ch == ENTER) { //enter
i = ((i / MYNCHAR) + 1) * MYNCHAR - 1;
ch = 0x20;
}
sprintf(st, "%c", ch);
grx_text(st, 340 + 10 * (i%25), 30 + 20 * (i/25), RGB_BLUE, RGB_BLACK);
grx_text(st, 340 + 10 * (i%MYNCHAR), 25 + 20 * (i/MYNCHAR), RGB_BLUE, RGB_BLACK);
 
if (++i >= 200)
if (ch == BACKSPACE) //backspace
i--;
if (++i >= MYNCHAR * 9) {
i = 0;
grx_box(315, 15, 623, 223, RGB_BLACK);
}
}
 
task_endcycle();
}
}
 
void my_mouse(MOUSE_EVT *e)
{
char st[20];
char pressed = 0;
 
sprintf(st, "X Axis : %3d (%4d)", e->x, e->dx);
grx_text(st, 100, 280, RGB_YELLOW, RGB_BLACK);
sprintf(st, "Y Axis : %3d (%4d)", e->y, e->dy);
grx_text(st, 100, 320, RGB_YELLOW, RGB_BLACK);
sprintf(st, "Z Axis : %3d (%4d)", e->z, e->dz);
grx_text(st, 100, 360, RGB_YELLOW, RGB_BLACK);
sprintf(st, "Buttons: %6x ", (int)e->buttons);
grx_text(st, 100, 400, RGB_YELLOW, RGB_BLACK);
 
if ((e->x > 377) && (e->x < 401) && (e->y > 300) && (e->y < 360) && (e->buttons == MOUSE_LBUTTON)){
if (!pressed) {
speaker_sound(277, 0); /* DO# */
pressed = 1;
}
return;
}
if ((e->x > 407) && (e->x < 431) && (e->y > 300) && (e->y < 360) && (e->buttons == MOUSE_LBUTTON)){
if (!pressed) {
speaker_sound(311, 0); /* RE# */
pressed = 1;
}
return;
}
if ((e->x > 467) && (e->x < 491) && (e->y > 300) && (e->y < 360) && (e->buttons == MOUSE_LBUTTON)){
if (!pressed) {
speaker_sound(370, 0); /* FA# */
pressed = 1;
}
return;
}
if ((e->x > 497) && (e->x < 521) && (e->y > 300) && (e->y < 360) && (e->buttons == MOUSE_LBUTTON)){
if (!pressed) {
speaker_sound(415, 0); /* SOL# */
pressed = 1;
}
return;
}
if ((e->x > 527) && (e->x < 551) && (e->y > 300) && (e->y < 360) && (e->buttons == MOUSE_LBUTTON)){
if (!pressed) {
speaker_sound(466, 0); /* LA# */
pressed = 1;
}
return;
}
 
if ((e->x > 360) && (e->x < 388) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)){
if (!pressed) {
speaker_sound(262, 0); /* DO */
pressed = 1;
}
return;
}
if ((e->x > 390) && (e->x < 418) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)) {
if (!pressed) {
speaker_sound(294, 0); /* RE */
pressed = 1;
}
return;
}
if ((e->x > 420) && (e->x < 448) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)) {
if (!pressed) {
speaker_sound(330, 0); /* MI */
pressed = 1;
}
return;
}
if ((e->x > 450) && (e->x < 478) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)) {
if (!pressed) {
speaker_sound(349, 0); /* FA */
pressed = 1;
}
return;
}
if ((e->x > 480) && (e->x < 508) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)) {
if (!pressed) {
speaker_sound(392, 0); /* SOL */
pressed = 1;
}
return;
}
if ((e->x > 510) && (e->x < 538) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)) {
if (!pressed) {
speaker_sound(440, 0); /* LA */
pressed = 1;
}
return;
}
if ((e->x > 540) && (e->x < 568) && (e->y > 300) && (e->y < 400) && (e->buttons == MOUSE_LBUTTON)) {
if (!pressed) {
speaker_sound(494, 0); /* SI */
pressed = 1;
}
return;
}
speaker_sound(0, 0);
pressed = 0;
}
 
void graph_init(void)
{
grx_rect( 4, 4, 634, 474, RGB_WHITE);
grx_rect( 14, 14, 304, 214, RGB_YELLOW);
grx_rect(314, 14, 624, 214, RGB_RED);
grx_rect( 14, 14, 304, 224, RGB_YELLOW);
grx_rect(314, 14, 624, 224, RGB_RED);
grx_rect( 14, 234, 304, 464, RGB_GREEN);
grx_rect(314, 234, 624, 464, RGB_BLUE);
 
/* Draw Teyboard */
grx_box(360, 300, 388, 400, RGB_WHITE); /* DO */
grx_box(390, 300, 418, 400, RGB_WHITE); /* RE */
grx_box(420, 300, 448, 400, RGB_WHITE); /* MI */
grx_box(450, 300, 478, 400, RGB_WHITE); /* FA */
grx_box(480, 300, 508, 400, RGB_WHITE); /* SOL */
grx_box(510, 300, 538, 400, RGB_WHITE); /* LA */
grx_box(540, 300, 568, 400, RGB_WHITE); /* SI */
 
grx_box(377, 301, 401, 360, RGB_BLACK); /* DO# */
grx_box(407, 301, 431, 360, RGB_BLACK); /* RE# */
grx_box(467, 301, 491, 360, RGB_BLACK); /* FA# */
grx_box(497, 301, 521, 360, RGB_BLACK); /* SOL# */
grx_box(527, 301, 551, 360, RGB_BLACK); /* LA# */
}
 
void start_sound(void)
{
KEY_EVT ev;
 
speaker_sound(440, 400);
while ( (sys_gettime(NULL)/1000) < 1000);
 
ev.ascii = 'q';
ev.scan = KEY_Q;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'w';
ev.scan = KEY_W;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'e';
ev.scan = KEY_E;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'r';
ev.scan = KEY_R;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 't';
ev.scan = KEY_T;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'y';
ev.scan = KEY_Y;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'u';
ev.scan = KEY_U;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'i';
ev.scan = KEY_I;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'o';
ev.scan = KEY_O;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = 'p';
ev.scan = KEY_P;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = '[';
ev.scan = KEY_BRL;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
 
ev.ascii = ']';
ev.scan = KEY_BRR;
ev.flag = 0;
ev.status = KEY_PRESSED;
keyb_hook(ev, my_note, FALSE);
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
}
 
int main(int argc, char **argv)
{
SOFT_TASK_MODEL mp;
141,22 → 408,15
ev.scan = KEY_C;
ev.status = KEY_PRESSED;
ev.flag = CNTL_BIT;
keyb_hook(ev, my_sysclose, FALSE);
keyb_hook(ev, my_sysend, FALSE);
ev.flag = CNTR_BIT;
keyb_hook(ev, my_sysclose, FALSE);
keyb_hook(ev, my_sysend, FALSE);
 
FB26_init();
 
FB26_open(FRAME_BUFFER_DEVICE);
 
FB26_use_grx(FRAME_BUFFER_DEVICE);
 
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
graph_init();
 
mouse_grxlimits(639, 479);
mouse_setposition(319, 239, 0);
mouse_hook(my_mouse);
mouse_grxcursor(ENABLE, 2);
 
soft_task_default_model(mp);
164,28 → 424,29
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Joy_Print", my_getjoy, &mp, NULL);
pid = task_create("Key_Print", my_getch, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Joy_Print>");
perror("Could not create task <Key_Print>");
sys_end();
} else
task_activate(pid);
 
if (JOY26_installed()) {
soft_task_default_model(mp);
soft_task_def_level(mp,2);
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Key_Print", my_getch, &mp, NULL);
pid = task_create("Joy_Print", my_getjoy, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Key_Print>");
perror("Could not create task <Joy_Print>");
sys_end();
} else
task_activate(pid);
}
 
start_sound();
return 0;
}
/demos/trunk/input/initspk.c
15,8 → 15,6
*/
 
/*
* 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
30,9 → 28,9
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
 
#include <kernel/kern.h>
 
#include "modules/edf.h"
41,7 → 39,6
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
 
56,20 → 53,18
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
KEYB26_close();
SPEAK26_close();
INPUT26_close();
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
kern_printf("S.Ha.R.K. closed.\n\n");
}
PID shutdown_task_PID = 1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(1000, 10000, 0);
INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
80,23 → 75,71
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
KEYB_PARMS kparms = BASE_KEYB;
int device_drivers_close() {
 
HARTPORT_init();
KEYB26_close();
SPEAK26_close();
INPUT26_close();
 
//keyb_def_map(kparms, KEYMAP_IT);
keyb_def_ctrlC(kparms, NULL);
return 0;
}
int device_drivers_init() {
 
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
INPUT26_init();
 
/*keyb_def_map(kparms, KEYMAP_IT);*/
keyb_def_ctrlC(kparms, NULL);
KEYB26_init(&kparms);
 
SPEAK26_init();
return 0;
}
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
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);
nrt_task_def_system(nrt);
nrt_task_def_nokill(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();
}
 
}
 
void call_shutdown_task(void *arg) {
task_activate(shutdown_task_PID);
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
set_shutdown_task();
 
device_drivers_init();
 
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
/demos/trunk/input/joy.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
38,20 → 35,8
#include <stdlib.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_joy26.h>
 
//void my_sysclose(KEY_EVT *e)
void my_sysclose(void)
{
JOY26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
}
 
TASK my_getjoy(void *arg) {
 
int a0, a1, a2, a3, btn;
61,7 → 46,7
printk ("(%6d %6d) %2x\n", a0, a1, btn);
task_endcycle();
if (btn == 0xF)
my_sysclose();
sys_end();
}
}
 
70,12 → 55,15
SOFT_TASK_MODEL mp;
PID pid;
 
if (!JOY26_installed()) {
printk("No Joystick found.");
sys_end();
}
soft_task_default_model(mp);
soft_task_def_level(mp,2);
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Joy_Print", my_getjoy, &mp, NULL);
if (pid == NIL) {
83,10 → 71,6
sys_end();
} else
task_activate(pid);
/*while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose();*/
//while(1);
 
return 0;
}
/demos/trunk/input/initfile.c
33,55 → 33,51
*
*/
 
#include <kernel/kern.h>
 
#include "kernel/kern.h"
 
#include "modules/intdrive.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/hardcbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
 
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_mouse26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
#include <drivers/shark_joy26.h>
 
#include <drivers/shark_fb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
#define RRTICK 2000
 
/*+ Interrup Server */
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
#define FRAME_BUFFER_DEVICE 0
void call_shutdown_task(void *arg);
int device_drivers_init();
int device_drivers_close();
void set_shutdown_task();
TASK shutdown_task_body(void *arg);
 
void my_close(void *arg)
{
mouse_grxcursor(DISABLE, 0);
PID shutdown_task_PID = -1;
 
FB26_close(FRAME_BUFFER_DEVICE);
 
MOUSE26_close();
KEYB26_close();
SPEAK26_close();
JOY26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
}
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
88,11 → 84,12
 
INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
CABS_register_module();
 
return TICK;
}
100,13 → 97,53
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
/* Create the shutdown task. It will be activated at RUNLEVEL SHUTDOWN */
set_shutdown_task();
 
/* Init the drivers */
device_drivers_init();
 
/* Set the shutdown task activation */
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
}
 
void set_shutdown_task()
{
/* WARNING: the shutdown task is a background thread. It cannot execute if the system is overloaded */
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
nrt_task_def_system(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
}
 
int device_drivers_init()
{
int res;
KEYB_PARMS kparms = BASE_KEYB;
MOUSE_PARMS mparms = BASE_MOUSE;
 
HARTPORT_init();
LINUXC26_register_module();
 
PCI26_init();
 
INPUT26_init();
 
/* keyb_def_map(kparms, KEYMAP_IT);*/
keyb_def_ctrlC(kparms, NULL);
KEYB26_init(&kparms);
 
mouse_def_threshold(mparms, 5);
mouse_def_xmin(mparms, 0);
113,17 → 150,67
mouse_def_ymin(mparms, 0);
mouse_def_xmax(mparms, 639);
mouse_def_ymax(mparms, 479);
MOUSE26_init(&mparms);
 
LINUXC26_register_module();
INPUT26_init();
MOUSE26_init(&mparms);
KEYB26_init(&kparms);
SPEAK26_init();
 
JOY26_init();
 
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
FB26_init();
res = FB26_open(FRAME_BUFFER_DEVICE);
if (res) {
cprintf("Error: Cannot open graphical mode\n");
MOUSE26_close();
SPEAK26_close();
JOY26_close();
KEYB26_close();
INPUT26_close();
sys_end();
}
 
__call_main__(mb);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
return (void *)0;
return 0;
}
 
int device_drivers_close() {
 
mouse_grxcursor(DISABLE, 0);
 
FB26_close(FRAME_BUFFER_DEVICE);
 
MOUSE26_close();
SPEAK26_close();
JOY26_close();
KEYB26_close();
INPUT26_close();
return 0;
}
 
#define SHUTDOWN_TIMEOUT_SEC 3
 
void call_shutdown_task(void *arg)
{
struct timespec t;
 
sys_gettime(&t);
t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
 
/* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
 
task_activate(shutdown_task_PID);
}
 
TASK shutdown_task_body(void *arg)
{
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_abort_shutdown(0);
 
return NULL;
}
/demos/trunk/input/speak.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
38,8 → 35,6
#include <stdlib.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
 
47,10 → 42,6
{
speaker_sound(0, 0);
cprintf("Keyboard Close : %d\n", KEYB26_close());
cprintf("Speaker Close : %d\n", SPEAK26_close());
cprintf("Input Close : %d\n", INPUT26_close());
 
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
}
212,9 → 203,6
ev.status = KEY_RELEASED;
keyb_hook(ev, no_note, FALSE);
/*while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);*/
while(1);
return 0;
}
/demos/trunk/input/initjoy.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
41,7 → 38,6
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
 
55,19 → 51,18
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
JOY26_close();
INPUT26_close();
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
kern_printf("S.Ha.R.K. closed.\n\n");
}
PID shutdown_task_PID = 1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(1000, 10000, 0);
INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
78,16 → 73,66
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
int device_drivers_close() {
JOY26_close();
INPUT26_close();
return 0;
}
 
int device_drivers_init() {
 
LINUXC26_register_module();
INPUT26_init();
 
JOY26_init();
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
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);
nrt_task_def_system(nrt);
nrt_task_def_nokill(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();
}
 
}
 
void call_shutdown_task(void *arg) {
task_activate(shutdown_task_PID);
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
set_shutdown_task();
 
device_drivers_init();
 
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
/demos/trunk/input/key.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
38,15 → 35,10
#include <stdlib.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
void my_sysclose(KEY_EVT *e)
{
KEYB26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
}
102,7 → 94,6
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,1000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Keyb_Print", my_getch, &mp, NULL);
if (pid == NIL) {
111,10 → 102,5
} else
task_activate(pid);
/*while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);*/
//while(1);
 
return 0;
}
/demos/trunk/input/mouse.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
38,8 → 35,6
#include <stdlib.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_mouse26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
48,10 → 43,6
{
mouse_txtcursor(DISABLE);
 
MOUSE26_close();
KEYB26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
}
64,7 → 55,7
clear();
 
while (1) {
mouse_getpos(&x, &y, &z, &btn);
mouse_getposition(&x, &y, &z, &btn);
place(10, 10);
printk("X: %2d - Y: %2d - Z: %3d - Btn: %4d\n", x, y, z, (int)btn);
 
93,7 → 84,6
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,1000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Mouse_Print", my_putxy, &mp, NULL);
if (pid == NIL) {
102,10 → 92,5
} else
task_activate(pid);
 
while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);
//while(1);
 
return 0;
}
/demos/trunk/input/initkey.c
15,8 → 15,6
*/
 
/*
* 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
30,9 → 28,9
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
 
#include "modules/edf.h"
41,7 → 39,6
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
 
55,19 → 52,18
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
KEYB26_close();
INPUT26_close();
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
kern_printf("S.Ha.R.K. closed.\n\n");
}
PID shutdown_task_PID = 1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(1000, 10000, 0);
INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
78,21 → 74,68
return TICK;
}
 
int device_drivers_close() {
KEYB26_close();
INPUT26_close();
return 0;
}
 
int device_drivers_init() {
 
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
INPUT26_init();
 
/*keyb_def_map(kparms, KEYMAP_IT);*/
keyb_def_ctrlC(kparms, NULL);
KEYB26_init(&kparms);
 
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);
nrt_task_def_system(nrt);
nrt_task_def_nokill(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();
}
 
}
 
void call_shutdown_task(void *arg) {
task_activate(shutdown_task_PID);
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
KEYB_PARMS kparms = BASE_KEYB;
 
HARTPORT_init();
 
//keyb_def_map(kparms, KEYMAP_IT);
keyb_def_ctrlC(kparms, NULL);
set_shutdown_task();
LINUXC26_register_module();
INPUT26_init();
KEYB26_init(&kparms);
device_drivers_init();
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
/demos/trunk/input/makefile
23,6 → 23,6
mouse:
make -f $(SUBMAKE) APP=mouse INIT= OTHEROBJS="initcur.o" SHARKOPT="__INPUT__ __LINUXC26__ __NEWPCI__"
 
mouse:
joy:
make -f $(SUBMAKE) APP=joy INIT= OTHEROBJS="initjoy.o" SHARKOPT="__INPUT__ __LINUXC26__ __NEWPCI__"
 
/demos/trunk/input/initcur.c
15,8 → 15,6
*/
 
/*
* 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
30,7 → 28,6
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#include <kernel/kern.h>
41,7 → 38,6
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
 
49,7 → 45,6
#include <drivers/shark_input26.h>
#include <drivers/shark_mouse26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
 
/*+ sysyem tick in us +*/
#define TICK 0
57,20 → 52,18
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
MOUSE26_close();
KEYB26_close();
INPUT26_close();
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
kern_printf("S.Ha.R.K. closed.\n\n");
}
PID shutdown_task_PID = 1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(1000, 10000, 0);
INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
81,24 → 74,74
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
int device_drivers_close() {
MOUSE26_close();
KEYB26_close();
INPUT26_close();
return 0;
}
 
int device_drivers_init() {
 
KEYB_PARMS kparms = BASE_KEYB;
MOUSE_PARMS mparms = BASE_MOUSE;
 
HARTPORT_init();
LINUXC26_register_module();
INPUT26_init();
 
/*keyb_def_map(kparms, KEYMAP_IT);*/
keyb_def_ctrlC(kparms, NULL);
KEYB26_init(&kparms);
LINUXC26_register_module();
INPUT26_init();
MOUSE26_init(&mparms);
KEYB26_init(&kparms);
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
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);
nrt_task_def_system(nrt);
nrt_task_def_nokill(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();
}
 
}
 
void call_shutdown_task(void *arg) {
task_activate(shutdown_task_PID);
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
set_shutdown_task();
 
device_drivers_init();
 
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;