Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1096 → Rev 1097

/demos/trunk/tracer/udp/initfile.c
0,0 → 1,115
/*
* 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
*/
 
/*
* 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
*
*/
 
/*
* CVS : $Id: initfile.c,v 1.1 2002-10-28 08:10:10 pj Exp $
*
* File: $File$
* Revision: $Revision: 1.1 $
* Last update: $Date: 2002-10-28 08:10:10 $
*/
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/rr.h"
#include "modules/cbs.h"
#include "modules/dummy.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
#include "modules/pi.h"
#include "modules/pc.h"
#include "modules/srp.h"
#include "modules/npp.h"
#include "modules/nop.h"
#include "modules/nopm.h"
 
#include "drivers/keyb.h"
 
/*+ sysyem tick in us +*/
#define TICK 1000
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
void mytracer_prologue(void);
void mytracer_epilogue(void);
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
mytracer_prologue();
 
EDF_register_level(EDF_ENABLE_ALL);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
CBS_register_level(CBS_ENABLE_ALL, 0);
dummy_register_level();
 
SEM_register_module();
 
CABS_register_module();
 
PI_register_module();
PC_register_module();
NPP_register_module();
SRP_register_module();
NOP_register_module();
NOPM_register_module();
 
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
KEYB_PARMS keyb = BASE_KEYB;
extern void ctrlc_exit(KEY_EVT *k);
HARTPORT_init();
keyb_def_ctrlC(keyb, ctrlc_exit);
KEYB_init(&keyb);
 
mytracer_epilogue();
__call_main__(mb);
 
return (void *)0;
}
 
/demos/trunk/tracer/udp/udptrace.c
0,0 → 1,160
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* Massimiliano Giorgi <massy@gandalf.sssup.it>
* Luca Abeni <luca@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
*/
 
/*
* Copyright (C) 2000 Massimiliano Giorgi
* Copyright (C) 2002 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
*
* CVS : $Id: udptrace.c,v 1.1 2002-10-28 08:10:11 pj Exp $
*/
 
/*
* Example of tracer initialization.
*/
 
#include <ll/i386/cons.h>
 
#include <kernel/func.h>
#include <kernel/trace.h>
 
#include <fs/bdevinit.h>
#include <fs/fsinit.h>
#include <fs/bdev.h>
 
#include <drivers/keyb.h>
#include <drivers/udpip.h>
 
#include <trace/trace.h>
#include <trace/queues.h>
 
#include <sys/mount.h>
#include <stddef.h>
#include <string.h>
 
char myipaddr[15], toipaddr[15];
 
void mytracer_prologue(void)
{
int myqueue;
TRC_PARMS p;
TRC_UDP_PARMS u;
UDP_ADDR local, remote;
 
/* these are the IP numbers of my home PCs ;-) */
strcpy(myipaddr, "192.168.1.2");
strcpy(toipaddr, "192.168.1.1");
 
clear();
 
ip_str2addr(toipaddr,&(remote.s_addr));
remote.s_port = 20000; // htons is done automatically;
ip_str2addr(myipaddr,&(local.s_addr));
local.s_port = 20000; // htons is done automatically;
 
trc_default_parms(p);
trc_def_path(p,"");
 
trc_udp_default_parms(u,local,remote);
/* Tracer Initialization */
/* the first functions to call... parameters can be passed */
TRC_init_phase1(&p);
 
/* all the tracer queue types must be registered */
trc_register_udp_queue();
 
/* then, we create all the queues we need */
myqueue = trc_create_queue(TRC_UDP_QUEUE,&u);
 
/* Then, we say that events must be sent to a particular queue */
trc_trace_class(TRC_CLASS_SYSTEM);
trc_assign_class_to_queue(TRC_CLASS_SYSTEM, myqueue);
}
 
void mytracer_epilogue(void)
{
struct net_model m = net_base;
/* We want a task for TX mutual exclusion */
net_setmode(m, TXTASK);
/* We use UDP/IP stack */
net_setudpip(m, myipaddr);
/* OK: let's start the NetLib! */
if (net_init(&m) == 1) {
cprintf("udptrace: Net Init OK...\n");
} else {
cprintf("udptrace: Net Init Failed...\n");
sys_abort(300);
}
TRC_init_phase2();
}
 
void ctrlc_exit(KEY_EVT *k)
{
sys_end();
}
 
void *mytask(void *arg)
{
int i;
 
for(i=0; i<10; i++) {
cprintf("%d\n", i);
task_endcycle();
}
 
return 0;
}
 
int main(int argc,char *argv[])
{
SOFT_TASK_MODEL mp;
 
PID pid;
 
soft_task_default_model(mp);
soft_task_def_met(mp, 10000);
soft_task_def_period(mp,50000);
soft_task_def_usemath(mp);
 
cprintf("\nHello, world!\n");
 
pid = task_create("mytask", mytask, &mp, NULL);
 
if (pid != NIL) task_activate(pid);
 
return 0;
}
/demos/trunk/tracer/udp/makefile
0,0 → 1,21
#
#
#
 
ifndef BASE
BASE=../../..
endif
 
include $(BASE)/config/config.mk
 
PROGS= udptrace
 
include $(BASE)/config/example.mk
 
udptrace:
make -f $(SUBMAKE) BASE=$(BASE) APP=udptrace INIT= OTHEROBJS=initfile.o
 
 
 
 
 
/demos/trunk/tracer/udp/readme
0,0 → 1,10
This is a simple test that uses the tracer.
 
The example assigns the IP address 192.168.1.2 to the machine, and
sends the tracer data to 192.168.1.1 using UDp, port 20000.
 
You can use demos/tracer/utils/udpdump to get the informations.
 
Enjoy,
 
PJ
/demos/trunk/tracer/readme
7,6 → 7,7
dfixed - a small applications that defines a tracer queue.
At the end a file is written (using DOSFS).
small - a set of small examples of tracer usage (using the Shark Filesystem)
udp - a small application that sends its trace data through the network
 
Enjoy