Subversion Repositories shark

Rev

Rev 1655 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/*
22
 * Copyright (C) 2000 Massimiliano Giorgi
23
 * Copyright (C) 2002 Paolo Gai
24
 *
25
 * This program is free software; you can redistribute it and/or modify
26
 * it under the terms of the GNU General Public License as published by
27
 * the Free Software Foundation; either version 2 of the License, or
28
 * (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
38
 *
39
 * CVS :        $Id: udptrace.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $
40
 */
41
 
42
/*
43
 * Example of tracer initialization.
44
 */
45
 
46
#include <ll/i386/cons.h>
47
 
48
#include <kernel/func.h>
49
 
50
#include <fs/bdevinit.h>
51
#include <fs/fsinit.h>
52
#include <fs/bdev.h>
53
 
54
#include <drivers/keyb.h>
55
#include <drivers/udpip.h>
56
 
57
#include <tracer.h>
58
#include <queues.h>
59
 
60
#include <sys/mount.h>
61
#include <stddef.h>
62
#include <string.h>
63
 
64
char myipaddr[15], toipaddr[15];
65
 
66
void mytracer_prologue(void)
67
{
68
  int myqueue;
69
  TRC_PARMS p;
70
  TRC_UDP_PARMS u;
71
  UDP_ADDR local, remote;
72
 
73
  /* these are the IP numbers of my home PCs ;-) */
74
  strcpy(myipaddr, "192.168.82.120");
75
  strcpy(toipaddr, "192.168.82.20");
76
 
77
  clear();
78
 
79
  ip_str2addr(toipaddr,&(remote.s_addr));
80
  remote.s_port = 20000; // htons is done automatically;
81
  ip_str2addr(myipaddr,&(local.s_addr));
82
  local.s_port = 20000;  // htons is done automatically;
83
 
84
  trc_default_parms(p);
85
  trc_def_path(p,"");
86
 
87
  trc_udp_default_parms(u,local,remote);
88
 
89
  /* Tracer Initialization */
90
  /* the first functions to call... parameters can be passed */
91
  TRC_init_phase1(&p);
92
 
93
  /* all the tracer queue types must be registered */
94
  trc_register_udp_queue();
95
 
96
  /* then, we create all the queues we need */
97
  myqueue = trc_create_queue(TRC_UDP_QUEUE,&u);
98
 
99
  /* Then, we say that events must be sent to a particular queue */
100
  trc_trace_class(TRC_CLASS_SYSTEM);
101
  trc_assign_class_to_queue(TRC_CLASS_SYSTEM, myqueue);
102
}
103
 
104
void mytracer_epilogue(void)
105
{
106
  struct net_model m = net_base;
107
 
108
 
109
  /* We want a task for TX mutual exclusion */
110
  net_setmode(m, TXTASK);
111
  /* We use UDP/IP stack */
112
  net_setudpip(m, myipaddr, "255.255.255.255");
113
  /* OK: let's start the NetLib! */
114
  if (net_init(&m) == 1) {
115
    cprintf("udptrace: Net Init OK...\n");
116
  } else {
117
    cprintf("udptrace: Net Init Failed...\n");
118
    sys_abort(300);
119
  }
120
 
121
  TRC_init_phase2();
122
}
123
 
124
void ctrlc_exit(KEY_EVT *k)
125
{
126
  sys_end();
127
}
128
 
129
void *mytask(void *arg)
130
{
131
  int i;
132
 
133
  for(i=0; i<10; i++) {
134
    cprintf("%d\n", i);
135
    task_endcycle();
136
  }
137
 
138
  return 0;
139
}
140
 
141
int main(int argc,char *argv[])
142
{
143
  SOFT_TASK_MODEL mp;
144
 
145
  PID pid;
146
 
147
  soft_task_default_model(mp);
148
  soft_task_def_met(mp, 10000);
149
  soft_task_def_period(mp,50000);
150
  soft_task_def_usemath(mp);
151
 
152
  cprintf("\nHello, world!\n");
153
 
154
  pid = task_create("mytask", mytask, &mp, NULL);
155
 
156
  if (pid != NIL) task_activate(pid);
157
 
158
  return 0;
159
}