Blame |
Last modification |
View Log
| RSS feed
/*
* 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.1.1 2004-05-24 18:03:44 giacomo Exp $
*/
/*
* Example of tracer initialization.
*/
#include <ll/i386/cons.h>
#include <kernel/func.h>
#include <fs/bdevinit.h>
#include <fs/fsinit.h>
#include <fs/bdev.h>
#include <drivers/keyb.h>
#include <drivers/udpip.h>
#include <tracer.h>
#include <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.82.120");
strcpy(toipaddr
, "192.168.82.20");
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
, "255.255.255.255");
/* 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;
}