Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1162 → Rev 1163

/demos/trunk/bttvdemo/bttv.c
0,0 → 1,173
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/*
* Copyright (C) 2003 Giacomo Guidi
*
* 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 <drivers/fg.h>
#include <drivers/vga.h>
#include <drivers/keyb.h>
#include <unistd.h>
#include <stdlib.h>
 
#define WIDTH 640
#define HEIGHT 480
#define BYTES_PP 2
#define INITSTR G640x480x64K //SVGAlib standard mode definitions
#define CARD VESA //Video driver
 
unsigned char *video_buf = NULL; //Video Buffer
unsigned long int VMEMLONG = WIDTH * HEIGHT * BYTES_PP / 4; // Used by copy_videomem_16to16
unsigned long int RGB565MEM = WIDTH * HEIGHT * BYTES_PP; // Total video mem
 
unsigned long int PERIOD_REFRESH = 50000;
unsigned long int WCET_REFRESH = 20000;
 
void * fg_buffer;
 
int fg_p = 40000;
int fp_c = 15000;
int fg_w = 320;
int fg_h = 200;
 
static int screen(int mode)
{
 
vga_modeinfo *minf;
 
vga_setmode(mode,CARD);
minf = vga_getmodeinfo(mode);
if(! (minf->flags & CAPABLE_LINEAR)){
vga_setmode(TEXT,CARD);
printk(KERN_INFO "The mode %d is not capable of linear\n",mode);
return 1;
}
vga_setpage(0);
if(vga_setlinearaddressing() == -1) {
vga_setmode(TEXT,CARD);
printk(KERN_INFO "Could not set linear addressing for mode %d\n",mode);
return 1;
}
video_buf = vga_getgraphmem();
memset(video_buf, 0, RGB565MEM);
grx_setbuffer(video_buf, WIDTH, HEIGHT); //Init of RGBA version of grx functions
//created to work with Mesa buffer
return 0;
}
 
void program_end(void *arg)
{
vga_setmode(TEXT,CARD);
FG_close();
sys_end();
 
}
 
void program_key_end(KEY_EVT *k)
{
 
sys_end();
 
}
TASK ref(void)
{
 
WORD col,x,y;
 
while(1) {
 
fg_buffer = FG_getbuffer();
for(y = 0; y < fg_h; y++)
for(x = 0; x < fg_w; x++) {
 
col = *(BYTE *)(fg_buffer + y*fg_w + x);
*(WORD *)(video_buf + y*(WIDTH*2) + x*2) = (WORD)rgb16(col,col,col);
 
}
task_endcycle();
 
}
 
sys_end();
 
}
 
int main(int argc, char **argv)
{
 
HARD_TASK_MODEL ht_ref;
PID ref_PID;
 
sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT);
hard_task_default_model(ht_ref);
hard_task_def_wcet(ht_ref,WCET_REFRESH);
hard_task_def_mit(ht_ref,PERIOD_REFRESH);
hard_task_def_usemath(ht_ref);
hard_task_def_group(ht_ref,1);
hard_task_def_ctrl_jet(ht_ref);
 
ref_PID = task_create("HT_ref", ref, &ht_ref, NULL);
if (ref_PID == -1) {
sys_end();
}
 
{
KEY_EVT k;
k.flag = ALTL_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,program_key_end);
}
 
screen(INITSTR);
 
sleep(5);
FG_init(fg_p, fp_c, fg_w, fg_h);
 
task_activate(ref_PID);
return 0;
 
}
/demos/trunk/bttvdemo/initfile.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>
* (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.1 2003-05-22 14:12:29 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2003-05-22 14:12:29 $
------------
 
System initialization file
 
This file contains the 2 functions needed to initialize the system.
 
These functions register the following levels:
 
an EDF (Earliest Deadline First) level
a RR (Round Robin) level
a CBS (Costant Bandwidth Server) level
a Dummy level
 
It can accept these task models:
 
HARD_TASK_MODEL (wcet+mit) at level 0
SOFT_TASK_MODEL (met, period) at level 1
NRT_TASK_MODEL at level 2
 
This file is similar to the configuration of kernel/init/hartik3.c
 
TICK is set to 0 (one-shot timer is used)
*/
 
/*
* 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/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.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;
 
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();
 
return TICK;
}
 
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_def_map(kparms,itaMap);
KEYB_init(&kparms);
 
__call_main__(mb);
 
return (void *)0;
}
 
/demos/trunk/bttvdemo/makefile
0,0 → 1,16
#
#
#
 
ifndef BASE
BASE=../..
endif
include $(BASE)/config/config.mk
 
PROGS = bttv
 
include $(BASE)/config/example.mk
 
bttv:
make -f $(SUBMAKE) APP=bttv INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __SVGA__ __BTTV__"