Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1321 → Rev 1464

/demos/trunk/mesatex/initfile.c
6,7 → 6,7
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
17,38 → 17,6
*/
 
/*
------------
CVS : $Id: initfile.c,v 1.2 2003-04-28 11:14:08 giacomo Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2003-04-28 11:14:08 $
------------
 
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
67,8 → 35,9
*/
 
#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"
 
76,21 → 45,40
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include "drivers/keyb.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 1000
#define TICK 0
 
/*+ RR tick in us +*/
#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);
CBS_register_level(CBS_ENABLE_ALL, 0);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
105,15 → 93,110
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
KEYB_PARMS kparms = BASE_KEYB;
 
HARTPORT_init();
 
keyb_def_ctrlC(kparms, NULL);
KEYB_init(&kparms);
/* 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;
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,"640x480-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/mesatex/mesatex.c
16,9 → 16,6
* http://shark.sssup.it
*/
 
#include <drivers/glib.h>
#include <drivers/keyb.h>
 
#include <GL/osmesa.h>
#include <GL/glut.h>
 
28,6 → 25,9
#include <kernel/log.h>
#include <kernel/kern.h>
 
#include <drivers/shark_fb26.h>
#include <drivers/shark_keyb26.h>
 
#ifndef M_PI
#define M_PI 3.14159265
#endif
42,6 → 42,8
static GLfloat Angle = 0.0f;
static GLboolean UseObj = GL_FALSE;
 
extern void *video_memory;
 
#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2)
# define TEXTURE_OBJECT 1
#elif defined(GL_EXT_texture_object)
54,7 → 56,6
unsigned char *rgb_565_buf = NULL; //RGB 16 bpp Buffer
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 = 30000;
117,7 → 118,6
 
}
 
 
static void gl_init()
{
 
250,27 → 250,6
 
}
 
static int screen()
{
 
extern DWORD flbaddr;
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
if (grx_open(640, 480, 16) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
video_buf = (unsigned char *)flbaddr;
 
return 0;
}
 
void program_end(void *arg)
{
277,8 → 256,6
OSMesaDestroyContext(ctx);
free(rgb_565_buf);
 
grx_close();
 
sys_end();
 
}
338,8 → 315,6
HARD_TASK_MODEL ht_refresh, ht_disegna;
 
sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT);
 
clear();
WCET_REFRESH =((long int) PERIOD_REFRESH * (0.45));
377,7 → 352,8
k.flag = ALTL_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,program_key_end);
k.status = KEY_PRESSED;
keyb_hook(k,program_key_end,FALSE);
}
 
rgb_565_buf = malloc(RGB565MEM);
384,10 → 360,8
gl_init();
if (screen()) {
printk(KERN_INFO "Graphical initialization failed !!\n");
sys_end();
}
video_buf = (unsigned char *)video_memory;
//video_buf = (unsigned char *)malloc(640*480*2);
 
memset(rgb_565_buf, 0, RGB565MEM);
 
/demos/trunk/mesatex/makefile
12,5 → 12,5
include $(BASE)/config/example.mk
 
mesatex:
make -f $(SUBMAKE) APP=mesatex INIT= OTHEROBJS="initfile.o" SHARKOPT="__OSMESA__ __OLDCHAR__ __GRX__"
make -f $(SUBMAKE) APP=mesatex INIT= OTHEROBJS="initfile.o" SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__ __OSMESA__"