Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1346 → Rev 1347

/demos/trunk/input/input.c
0,0 → 1,78
 
/*
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.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://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
*
*/
 
#include <kernel/kern.h>
#include <kernel/func.h>
#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>
 
void my_sysclose(KEY_EVT *e)
{
//EVBUG26_close();
KEYB26_close();
MOUSE26_close();
SPEAK26_close();
//JOY26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
sys_end();
}
 
int main(int argc, char **argv)
{
KEY_EVT ev;
 
ev.ascii = 'c';
ev.scan = KEY_C;
ev.status = KEY_PRESSED;
ev.flag = CNTL_BIT;
keyb_hook(ev, my_sysclose, FALSE);
ev.flag = CNTR_BIT;
keyb_hook(ev, my_sysclose, FALSE);
 
while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);
//while(1);
 
return 0;
}
/demos/trunk/input/initspk.c
0,0 → 1,103
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.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 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
*
*/
 
#include <kernel/kern.h>
 
#include "modules/edf.h"
#include "modules/cbs.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 <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
KEYB26_close();
SPEAK26_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;
 
INTDRIVE_register_level(1000, 10000, 0);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
 
return TICK;
}
 
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);
LINUXC26_register_module();
INPUT26_init();
KEYB26_init(&kparms);
SPEAK26_init();
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
 
__call_main__(mb);
 
return (void *)0;
}
/demos/trunk/input/speak.c
0,0 → 1,220
 
/*
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.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://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
*
*/
 
#include <kernel/kern.h>
#include <kernel/func.h>
#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>
 
void my_sysclose(KEY_EVT *e)
{
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();
}
 
void no_note(KEY_EVT *e){
speaker_sound(0, 0);
}
 
void my_note(KEY_EVT *e){
 
switch (e->scan) {
case KEY_Q:
speaker_sound(262, 0);
break;
case KEY_W:
speaker_sound(277, 0);
break;
case KEY_E:
speaker_sound(294, 0);
break;
case KEY_R:
speaker_sound(311, 0);
break;
case KEY_T:
speaker_sound(330, 0);
break;
case KEY_Y:
speaker_sound(349, 0);
break;
case KEY_U:
speaker_sound(370, 0);
break;
case KEY_I:
speaker_sound(392, 0);
break;
case KEY_O:
speaker_sound(415, 0);
break;
case KEY_P:
speaker_sound(440, 0);
break;
case KEY_BRL:
speaker_sound(466, 0);
break;
case KEY_BRR:
speaker_sound(494, 0);
break;
}
}
 
int main(int argc, char **argv)
{
KEY_EVT ev;
 
ev.ascii = 'c';
ev.scan = KEY_C;
ev.status = KEY_PRESSED;
ev.flag = CNTL_BIT;
keyb_hook(ev, my_sysclose, FALSE);
ev.flag = CNTR_BIT;
keyb_hook(ev, my_sysclose, FALSE);
 
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);
/*while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);*/
while(1);
return 0;
}
/demos/trunk/input/initfile.c
0,0 → 1,111
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.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 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
*
*/
 
#include <kernel/kern.h>
 
#include "modules/edf.h"
#include "modules/cbs.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 <drivers/shark_linuxc26.h>
#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
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
//EVBUG26_close();
KEYB26_close();
MOUSE26_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;
 
INTDRIVE_register_level(1000, 10000, 0);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
 
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
KEYB_PARMS kparms = BASE_KEYB;
MOUSE_PARMS mparms = BASE_MOUSE;
 
HARTPORT_init();
 
/*keyb_def_map(kparms, KEYMAP_IT);*/
keyb_def_ctrlC(kparms, NULL);
LINUXC26_register_module();
INPUT26_init();
KEYB26_init(&kparms);
MOUSE26_init(&mparms);
SPEAK26_init();
//JOY26_init();
//EVBUG26_init();
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
 
__call_main__(mb);
 
return (void *)0;
}
/demos/trunk/input/key.c
0,0 → 1,120
 
/*
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.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://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
*
*/
 
#include <kernel/kern.h>
#include <kernel/func.h>
#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();
}
 
TASK my_getch(void *arg) {
 
BYTE ch;
while (1) {
ch = keyb_getch(NON_BLOCK);
if (ch)
printk ("%c", ch);
task_endcycle();
}
}
 
void my_pause(KEY_EVT *e){
 
TIME t;
printk("Start Pause.\n");
keyb_disable();
printk("Keyboard Disabled.\n");
t = sys_gettime(NULL);
while ( ( (sys_gettime(NULL) -t) / 1000) < 5000);
keyb_enable();
printk("Keyboard Enabled.\n");
}
 
int main(int argc, char **argv)
{
SOFT_TASK_MODEL mp;
PID pid;
 
KEY_EVT ev;
ev.ascii = 'p';
ev.scan = KEY_P;
ev.status = KEY_PRESSED;
ev.flag = CNTR_BIT;
keyb_hook(ev, my_pause, FALSE);
ev.ascii = 'c';
ev.scan = KEY_C;
ev.status = KEY_PRESSED;
ev.flag = CNTR_BIT;
keyb_hook(ev, my_sysclose, FALSE);
ev.flag = CNTL_BIT;
keyb_hook(ev, my_sysclose, FALSE);
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,1000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Keyb_Print", my_getch, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Keyb_Print>");
sys_end();
} else
task_activate(pid);
/*while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);*/
//while(1);
 
return 0;
}
/demos/trunk/input/initkey.c
0,0 → 1,100
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Mauro Marinoni <mauro.marinoni@unipv.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 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
*
*/
 
#include <kernel/kern.h>
 
#include "modules/edf.h"
#include "modules/cbs.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 <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
void my_close(void *arg)
{
KEYB26_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;
 
INTDRIVE_register_level(1000, 10000, 0);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
 
return TICK;
}
 
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);
LINUXC26_register_module();
INPUT26_init();
KEYB26_init(&kparms);
//sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT);
 
__call_main__(mb);
 
return (void *)0;
}
/demos/trunk/input/makefile
0,0 → 1,21
#
#
#
 
ifndef BASE
BASE=../..
endif
include $(BASE)/config/config.mk
 
PROGS= speak key input
 
include $(BASE)/config/example.mk
 
input:
make -f $(SUBMAKE) APP=input INIT= OTHEROBJS="initfile.o" SHARKOPT="__INPUT__ __LINUXC26__ __NEWPCI__"
 
speak:
make -f $(SUBMAKE) APP=speak INIT= OTHEROBJS="initspk.o" SHARKOPT="__INPUT__ __LINUXC26__ __NEWPCI__"
 
key:
make -f $(SUBMAKE) APP=key INIT= OTHEROBJS="initkey.o" SHARKOPT="__INPUT__ __LINUXC26__ __NEWPCI__"