OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [vapi/] [vapi.c] - Blame information for rev 1492

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 293 markom
/* vapi.c -- Verification API Interface
2
   Copyright (C) 2001, Marko Mlinar, markom@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20 336 markom
#include "config.h"
21 293 markom
 
22
#include <stdio.h>
23
#include <ctype.h>
24
#include <string.h>
25
#include <stdlib.h>
26
#include <unistd.h>
27
#include <stdarg.h>
28
#include <signal.h>
29
#include <errno.h>
30
 
31
/* Added by CZ 24/05/01 */
32
#include <sys/stat.h>
33
#include <sys/types.h>
34
#include <sys/socket.h>
35
#include <netinet/in.h>
36
#include <sys/select.h>
37
#include <sys/poll.h>
38
#include <fcntl.h>
39
#include <netdb.h>
40
#include <netinet/tcp.h>
41
 
42 1358 nogj
#include "config.h"
43
 
44
#ifdef HAVE_INTTYPES_H
45
#include <inttypes.h>
46
#endif
47
 
48
#include "port.h"
49
#include "arch.h"
50 336 markom
#include "sim-config.h"
51 439 erez
#include "vapi.h"
52 1308 phoenix
#include "debug.h"
53 293 markom
 
54 1492 nogj
DEFAULT_DEBUG_CHANNEL(vapi);
55
 
56 304 markom
static unsigned int serverIP = 0;
57 293 markom
 
58 304 markom
static unsigned int server_fd = 0;
59
static unsigned int nhandlers = 0;
60
 
61 293 markom
static int tcp_level = 0;
62
 
63 304 markom
static struct vapi_handler {
64
  int fd;
65 477 erez
  unsigned long base_id, num_ids;
66 1366 nogj
  void (*read_func)(unsigned long, unsigned long, void *);
67
  void *priv_dat;
68 293 markom
  struct vapi_handler *next;
69 304 markom
  int temp;
70 442 erez
} *vapi_handler = NULL;
71 293 markom
 
72 304 markom
/* Structure for polling, it is cached, that it doesn't have to be rebuilt each time */
73
static struct pollfd *fds = NULL;
74
static int nfds = 0;
75
 
76
/* Rebuilds the fds structures; see fds.  */
77
void rebuild_fds () {
78
  struct vapi_handler *t;
79
  if (fds)
80
    free (fds);
81
  fds = (struct pollfd *) malloc (sizeof (struct pollfd) * (nhandlers + 1));
82
  if (!fds) {
83
    fprintf (stderr, "FATAL: Out of memory.\n");
84
    exit (1);
85
  }
86
 
87
  nfds = 0;
88
  fds[nfds].fd = server_fd;
89
  fds[nfds].events = POLLIN;
90
  fds[nfds++].revents = 0;
91
 
92
  for (t = vapi_handler; t; t = t->next) {
93
    if (t->fd) {
94
      t->temp = nfds;
95
      fds[nfds].fd = t->fd;
96
      fds[nfds].events = POLLIN;
97
      fds[nfds++].revents = 0;
98
    } else
99
      t->temp = -1;
100
  }
101
}
102
 
103 477 erez
/* Determines whether a certain handler handles an ID */
104
static inline int handler_fits_id( const struct vapi_handler *t, unsigned long id ) {
105
  return ((id >= t->base_id) && (id < t->base_id + t->num_ids));
106
}
107
 
108 304 markom
/* Finds a handler with given ID, return it, NULL if not found.  */
109
static struct vapi_handler *find_handler (unsigned long id) {
110
  struct vapi_handler *t = vapi_handler;
111 477 erez
  while (t && !handler_fits_id (t, id))
112 304 markom
    t = t->next;
113
  return t;
114
}
115
 
116
/* Adds a handler with given id and returns it.  */
117 477 erez
static struct vapi_handler *add_handler (unsigned long base_id, unsigned long num_ids) {
118 304 markom
  struct vapi_handler **t = &vapi_handler;
119
  struct vapi_handler *tt;
120
  while ((*t))
121
    t = &(*t)->next;
122
  tt = (struct vapi_handler *)malloc (sizeof (struct vapi_handler));
123
  tt->next = NULL;
124 477 erez
  tt->base_id = base_id;
125
  tt->num_ids = num_ids;
126 304 markom
  tt->read_func = NULL;
127 1366 nogj
  tt->priv_dat = NULL;
128 304 markom
  tt->fd = 0;
129
  (*t) = tt;
130
  free (fds);
131
  fds = NULL;
132
  nhandlers++;
133
  rebuild_fds ();
134
  return tt;
135
}
136
 
137 439 erez
void vapi_write_log_file(VAPI_COMMAND command, unsigned long devid, unsigned long data)
138 419 erez
{
139 439 erez
  if (!runtime.vapi.vapi_file)
140
    return;
141 477 erez
  if (!config.vapi.hide_device_id && devid <= VAPI_MAX_DEVID)
142 1308 phoenix
    fprintf (runtime.vapi.vapi_file, "%04lx", devid);
143
  fprintf (runtime.vapi.vapi_file, "%1x%08lx\n", command, data);
144 419 erez
}
145
 
146 304 markom
static int vapi_write_stream(int fd, void* buf, int len)
147
{
148
  int n;
149
  char* w_buf = (char*)buf;
150
  struct pollfd block;
151
 
152
  while(len) {
153
    if((n = write(fd, w_buf, len)) < 0) {
154
      switch(errno) {
155
      case EWOULDBLOCK: /* or EAGAIN */
156
        /* We've been called on a descriptor marked
157
           for nonblocking I/O. We better simulate
158
           blocking behavior. */
159
        block.fd = fd;
160
        block.events = POLLOUT;
161
        block.revents = 0;
162
        poll(&block,1,-1);
163
        continue;
164
      case EINTR:
165
        continue;
166
      case EPIPE:
167
        close(fd);
168
        fd = 0;
169
        return -1;
170
      default:
171
        return -1;
172
      }
173
    } else {
174
      len -= n;
175
      w_buf += n;
176
    }
177
  }
178
  return 0;
179
}
180
 
181
static int vapi_read_stream(int fd, void* buf, int len)
182
{
183
  int n;
184
  char* r_buf = (char*)buf;
185
  struct pollfd block;
186
 
187
  while(len) {
188
    if((n = read(fd,r_buf,len)) < 0) {
189
      switch(errno) {
190
      case EWOULDBLOCK: /* or EAGAIN */
191
        /* We've been called on a descriptor marked
192
           for nonblocking I/O. We better simulate
193
           blocking behavior. */
194
        block.fd = fd;
195
        block.events = POLLIN;
196
        block.revents = 0;
197
        poll(&block,1,-1);
198
        continue;
199
      case EINTR:
200
        continue;
201
      default:
202
        return -1;
203
      }
204
    } else if(n == 0) {
205
      close(fd);
206
      fd = 0;
207
      return -1;
208
    } else {
209
      len -= n;
210
      r_buf += n;
211
    }
212
  }
213
  return 0;
214
}
215
 
216 293 markom
/* Added by CZ 24/05/01 */
217
int get_server_socket(const char* name,const char* proto,int port)
218
{
219
  struct servent *service;
220
  struct protoent *protocol;
221
  struct sockaddr_in sa;
222
  struct hostent *hp;
223
  int sockfd;
224
  char myname[256];
225
  int flags;
226
  char sTemp[256];
227
 
228
  /* First, get the protocol number of TCP */
229
  if(!(protocol = getprotobyname(proto))) {
230
    sprintf(sTemp,"Unable to load protocol \"%s\"",proto);
231
    perror(sTemp);
232
    return 0;
233
  }
234
  tcp_level = protocol->p_proto; /* Save for later */
235
 
236
  /* If we weren't passed a non standard port, get the port
237
     from the services directory. */
238
  if(!port) {
239 1308 phoenix
    if((service = getservbyname(name,protocol->p_name)))
240 293 markom
      port = ntohs(service->s_port);
241
  }
242 336 markom
 
243 293 markom
  /* Create the socket using the TCP protocol */
244
  if((sockfd = socket(PF_INET,SOCK_STREAM,protocol->p_proto)) < 0) {
245
    perror("Unable to create socket");
246
    return 0;
247
  }
248 336 markom
 
249 293 markom
  flags = 1;
250
  if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,(const char*)&flags,sizeof(int)) < 0) {
251
    sprintf(sTemp,"Can not set SO_REUSEADDR option on socket %d",sockfd);
252
    perror(sTemp);
253
    close(sockfd);
254
    return 0;
255
  }
256
 
257
  /* The server should also be non blocking. Get the current flags. */
258
  if(fcntl(sockfd,F_GETFL,&flags) < 0) {
259
    sprintf(sTemp,"Unable to get flags for socket %d",sockfd);
260
    perror(sTemp);
261
    close(sockfd);
262
    return 0;
263
  }
264
 
265
  /* Set the nonblocking flag */
266
  if(fcntl(sockfd,F_SETFL, flags | O_NONBLOCK) < 0) {
267
    sprintf(sTemp,"Unable to set flags for socket %d to value 0x%08x",
268
            sockfd,flags | O_NONBLOCK);
269
    perror(sTemp);
270
    close(sockfd);
271
    return 0;
272
  }
273
 
274
  /* Find out what our address is */
275
  memset(&sa,0,sizeof(struct sockaddr_in));
276
  gethostname(myname,sizeof(myname));
277
  if(!(hp = gethostbyname(myname))) {
278
    perror("Unable to read hostname");
279
    close(sockfd);
280
    return 0;
281
  }
282
 
283
  /* Bind our socket to the appropriate address */
284
  sa.sin_family = hp->h_addrtype;
285
  sa.sin_port = htons(port);
286
  if(bind(sockfd,(struct sockaddr*)&sa,sizeof(struct sockaddr_in)) < 0) {
287
    sprintf(sTemp,"Unable to bind socket %d to port %d",sockfd,port);
288
    perror(sTemp);
289
    close(sockfd);
290
    return 0;
291
  }
292
  serverIP = sa.sin_addr.s_addr;
293
  flags = sizeof(struct sockaddr_in);
294
  if(getsockname(sockfd,(struct sockaddr*)&sa,&flags) < 0) {
295
    sprintf(sTemp,"Unable to get socket information for socket %d",sockfd);
296
    perror(sTemp);
297
    close(sockfd);
298
    return 0;
299
  }
300 551 markom
  runtime.vapi.server_port = ntohs(sa.sin_port);
301 293 markom
 
302
  /* Set the backlog to 1 connections */
303
  if(listen(sockfd,1) < 0) {
304
    sprintf(sTemp,"Unable to set backlog on socket %d to %d",sockfd,1);
305
    perror(sTemp);
306
    close(sockfd);
307
    return 0;
308
  }
309
 
310
  return sockfd;
311
}
312
 
313 442 erez
static void server_request()
314 293 markom
{
315
  struct sockaddr_in sa;
316
  struct sockaddr* addr = (struct sockaddr*)&sa;
317
  int n = sizeof(struct sockaddr_in);
318 336 markom
  int fd = accept(server_fd, addr, &n);
319 293 markom
  int on_off = 0; /* Turn off Nagel's algorithm on the socket */
320
  int flags;
321
  char sTemp[256];
322
 
323
  if(fd < 0) {
324
    /* This is valid, because a connection could have started,
325
       and then terminated due to a protocol error or user
326
       initiation before the accept could take place. */
327
    if(errno != EWOULDBLOCK && errno != EAGAIN) {
328
      perror("accept");
329
      close(server_fd);
330
      server_fd = 0;
331 551 markom
      runtime.vapi.enabled = 0;
332 293 markom
      serverIP = 0;
333 336 markom
    }
334 293 markom
    return;
335
  }
336
 
337
  if(fcntl(fd,F_GETFL,&flags) < 0) {
338
    sprintf(sTemp,"Unable to get flags for vapi socket %d",fd);
339
    perror(sTemp);
340
    close(fd);
341
    return;
342
  }
343
 
344
  if(fcntl(fd,F_SETFL, flags | O_NONBLOCK) < 0) {
345
    sprintf(sTemp,"Unable to set flags for vapi socket %d to value 0x%08x",
346
            fd,flags | O_NONBLOCK);
347
    perror(sTemp);
348
    close(fd);
349
    return;
350
  }
351
 
352
  if(setsockopt(fd,tcp_level,TCP_NODELAY,&on_off,sizeof(int)) < 0) {
353
    sprintf(sTemp,"Unable to disable Nagel's algorithm for socket %d.\nsetsockopt",fd);
354
    perror(sTemp);
355
    close(fd);
356
    return;
357
  }
358 304 markom
 
359
  /* Install new handler */
360
  {
361
    unsigned long id;
362
    struct vapi_handler *t;
363
    if (vapi_read_stream (fd, &id, sizeof (id))) {
364
      perror ("Cannot get id");
365
      close (fd);
366
      return;
367 293 markom
    }
368 304 markom
    t = find_handler (id);
369 355 markom
    if (t) {
370 304 markom
      if (t->fd) {
371 1308 phoenix
        fprintf (stderr, "WARNING: Test with id %lx already connected. Ignoring.\n", id);
372 304 markom
        close (fd);
373
        return;
374 355 markom
      } else {
375
        t->fd = fd;
376
        rebuild_fds ();
377
      }
378
    } else {
379 1308 phoenix
      fprintf (stderr, "WARNING: Test with id %lx not registered. Ignoring.\n", id);
380 355 markom
      close(fd); /* kill the connection */
381
      return;
382 293 markom
    }
383 304 markom
    if(config.sim.verbose)
384 1308 phoenix
      PRINTF ("\nConnection with test (id %lx) established.\n", id);
385 293 markom
  }
386
}
387
 
388
static int write_packet (unsigned long id, unsigned long data) {
389 304 markom
  struct vapi_handler *t = find_handler (id);
390
  if (!t || !t->fd)
391
    return 1;
392 293 markom
  id = htonl (id);
393 304 markom
  if (vapi_write_stream(t->fd, &id, sizeof (id)) < 0)
394 293 markom
    return 1;
395
  data = htonl (data);
396 304 markom
  if (vapi_write_stream(t->fd, &data, sizeof (data)) < 0)
397 293 markom
    return 1;
398
  return 0;
399 442 erez
}
400 293 markom
 
401 442 erez
static int read_packet (int fd, unsigned long *id, unsigned long *data)
402
{
403 477 erez
  if (fd <= 0)
404 293 markom
    return 1;
405 477 erez
  if (vapi_read_stream(fd, id, sizeof(unsigned long)) < 0)
406 293 markom
    return 1;
407 442 erez
  *id = ntohl (*id);
408 477 erez
  if (vapi_read_stream(fd, data, sizeof(unsigned long)) < 0)
409 304 markom
    return 1;
410 442 erez
  *data = ntohl (*data);
411 293 markom
  return 0;
412 304 markom
}
413 293 markom
 
414 442 erez
static void vapi_request (struct vapi_handler *t)
415
{
416
  unsigned long id, data;
417
 
418
  if (read_packet(t->fd, &id, &data)) {
419 477 erez
    if (t->fd > 0) {
420 293 markom
      perror("vapi read");
421 304 markom
      close(t->fd);
422
      t->fd = 0;
423 361 markom
      rebuild_fds ();
424 293 markom
    }
425
    return;
426
  }
427
 
428 442 erez
  vapi_write_log_file (VAPI_COMMAND_REQUEST, id, data);
429 1492 nogj
  TRACE ("[%08lx, %08lx]\n", id, data);
430 442 erez
 
431
  /* This packet may be for another handler */
432 477 erez
  if (!handler_fits_id (t, id))
433 442 erez
    t = find_handler (id);
434
  if (!t || !t->read_func)
435 1308 phoenix
    fprintf (stderr, "WARNING: Received packet for undefined id %08lx, data %08lx\n", id, data);
436 293 markom
  else
437 1366 nogj
    t->read_func(id, data, t->priv_dat);
438 293 markom
}
439
 
440
void vapi_check ()
441
{
442 304 markom
  struct vapi_handler *t;
443 293 markom
 
444 304 markom
  if (!server_fd || !fds) {
445
    fprintf (stderr, "FATAL: Unable to maintain VAPI server.\n");
446
    exit (1);
447 293 markom
  }
448
 
449 1492 nogj
  TRACE(".");
450 355 markom
 
451 304 markom
  /* Handle everything in queue. */
452 293 markom
  while(1) {
453 304 markom
    switch(poll(fds, nfds, 0)) {
454 293 markom
    case -1:
455
      if(errno == EINTR)
456
        continue;
457
      perror("poll");
458 304 markom
      if (server_fd)
459
        close(server_fd);
460 551 markom
      runtime.vapi.enabled = 0;
461 304 markom
      serverIP = 0;
462
      return;
463 293 markom
    case 0: /* Nothing interesting going on */
464
      return;
465
    default:
466 304 markom
      /* Handle the vapi ports first. */
467
      for (t = vapi_handler; t; t = t->next)
468
        if (t->temp >= 0 && fds[t->temp].revents)
469
          vapi_request (t);
470 293 markom
 
471 304 markom
      if(fds[0].revents) {
472 293 markom
        if(fds[0].revents & POLLIN)
473
          server_request();
474
        else { /* Error Occurred */
475 304 markom
          fprintf(stderr,"Received flags 0x%08x on server. Shutting down.\n", fds[0].revents);
476
          if (server_fd)
477
            close(server_fd);
478 293 markom
          server_fd = 0;
479 551 markom
          runtime.vapi.enabled = 0;
480 293 markom
          serverIP = 0;
481
        }
482
      }
483
      break;
484
    } /* End of switch statement */
485
  } /* End of while statement */
486
}
487
 
488 304 markom
/* Inits the VAPI, according to sim-config */
489
int vapi_init ()
490 293 markom
{
491 304 markom
  nhandlers = 0;
492
  vapi_handler = NULL;
493 551 markom
  if (!runtime.vapi.enabled)
494 304 markom
    return 0; /* Nothing to do */
495
 
496 551 markom
  runtime.vapi.server_port = config.vapi.server_port;
497
  if (!runtime.vapi.server_port) {
498 304 markom
    fprintf (stderr, "WARNING: server_port = 0, shutting down VAPI\n");
499 551 markom
    runtime.vapi.enabled = 0;
500 304 markom
    return 1;
501
  }
502 1308 phoenix
  if ((server_fd = get_server_socket("or1ksim", "tcp", runtime.vapi.server_port)))
503 997 markom
    PRINTF("VAPI Server started on port %d\n", runtime.vapi.server_port);
504 304 markom
  else {
505 293 markom
    perror ("Connection");
506 304 markom
    return 1;
507
  }
508
 
509
  rebuild_fds ();
510 355 markom
 
511 361 markom
  if ((runtime.vapi.vapi_file = fopen (config.vapi.vapi_fn, "wt+")) == NULL)
512 355 markom
    fprintf (stderr, "WARNING: cannot open VAPI log file\n");
513
 
514 304 markom
  return 0;
515
}
516
 
517
/* Closes the VAPI */
518
void vapi_done ()
519
{
520
  int i;
521
  struct vapi_handler *t = vapi_handler;
522 293 markom
 
523 304 markom
  for (i = 0; i < nfds; i++)
524
    if (fds[i].fd)
525 306 markom
      close (fds[i].fd);
526 304 markom
  server_fd = 0;
527 551 markom
  runtime.vapi.enabled = 0;
528 304 markom
  serverIP = 0;
529
  free (fds);
530
  fds = 0;
531 361 markom
  if (runtime.vapi.vapi_file) {
532
    /* Mark end of simulation */
533 442 erez
    vapi_write_log_file (VAPI_COMMAND_END, 0, 0);
534 361 markom
    fclose (runtime.vapi.vapi_file);
535
  }
536 355 markom
 
537 304 markom
  while (vapi_handler) {
538
    t = vapi_handler;
539
    vapi_handler = vapi_handler->next;
540
    free (t);
541
  }
542 293 markom
}
543
 
544 477 erez
/* Installs a vapi handler for one VAPI id */
545 1366 nogj
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long, void *), void *dat)
546 304 markom
{
547 1366 nogj
  vapi_install_multi_handler (id, 1, read_func, dat);
548 477 erez
}
549
 
550
/* Installs a vapi handler for many VAPI id */
551 1366 nogj
void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long, void *), void *dat)
552 477 erez
{
553 293 markom
  struct vapi_handler *tt;
554 355 markom
 
555 1492 nogj
  TRACE("vapi_install_handler %08lx, %lu, %p\n", base_id, num_ids, read_func);
556 304 markom
  if (read_func == NULL) {
557
    struct vapi_handler **t = &vapi_handler;
558 477 erez
    while ((*t) && !handler_fits_id (*t, base_id))
559 293 markom
      t = &(*t)->next;
560
    if (!t) {
561 1308 phoenix
      fprintf (stderr, "Cannot uninstall VAPI read handler from id %lx\n",
562
               base_id);
563 293 markom
      exit (1);
564
    }
565
    tt = *t;
566
    (*t) = (*t)->next;
567
    free (tt);
568 304 markom
    nhandlers--;
569 293 markom
  } else {
570 477 erez
    tt = find_handler (base_id);
571 355 markom
    if (!tt) {
572 477 erez
      tt = add_handler (base_id, num_ids);
573 355 markom
      tt->read_func = read_func;
574 1366 nogj
      tt->priv_dat = dat;
575 355 markom
    } else {
576
      tt->read_func = read_func;
577 1366 nogj
      tt->priv_dat = dat;
578 355 markom
      rebuild_fds ();
579
    }
580 293 markom
  }
581
}
582
 
583 304 markom
/* Returns number of unconnected handles.  */
584 336 markom
int vapi_num_unconnected (int printout)
585 304 markom
{
586
  struct vapi_handler *t = vapi_handler;
587
  int numu = 0;
588 336 markom
  for (; t; t = t->next) {
589
    if (!t->fd) {
590
      numu++;
591 477 erez
      if (printout) {
592
        if ( t->num_ids == 1 )
593 1308 phoenix
          PRINTF (" 0x%lx", t->base_id);
594 477 erez
        else
595 1308 phoenix
          PRINTF (" 0x%lx..0x%lx", t->base_id, t->base_id + t->num_ids - 1);
596 477 erez
      }
597 336 markom
    }
598
  }
599 304 markom
  return numu;
600
}
601
 
602 305 markom
/* Sends a packet to specified test */
603
int vapi_send (unsigned long id, unsigned long data)
604
{
605 1492 nogj
  TRACE ("vapi_send [%08lx %08lx]\n", id, data);
606 442 erez
  vapi_write_log_file (VAPI_COMMAND_SEND, id, data);
607 305 markom
  write_packet (id, data);
608
}
609
 
610
/*
611 304 markom
int main ()
612
{
613 551 markom
  runtime.vapi.enabled = 1;
614 304 markom
  config.vapi.server_port = 9999;
615 293 markom
  vapi_init ();
616
  while (1) {
617
    vapi_check();
618 304 markom
    usleep(1);
619 293 markom
  }
620
  vapi_done ();
621 335 markom
}*/
622 1358 nogj
 
623
/*---------------------------------------------------[ VAPI configuration ]---*/
624
void vapi_enabled(union param_val val, void *dat)
625
{
626
  config.vapi.enabled = val.int_val;
627
}
628
 
629
void vapi_server_port(union param_val val, void *dat)
630
{
631
  config.vapi.server_port = val.int_val;
632
}
633
 
634
void vapi_log_enabled(union param_val val, void *dat)
635
{
636
  config.vapi.log_enabled = val.int_val;
637
}
638
 
639
void vapi_hide_device_id(union param_val val, void *dat)
640
{
641
  config.vapi.hide_device_id = val.int_val;
642
}
643
 
644
void vapi_log_fn(union param_val val, void *dat)
645
{
646
  strcpy(config.vapi.vapi_fn, val.str_val);
647
}
648
 
649
void reg_vapi_sec(void)
650
{
651
  struct config_section *sec = reg_config_sec("VAPI", NULL, NULL);
652
 
653
  reg_config_param(sec, "enabled", paramt_int, vapi_enabled);
654
  reg_config_param(sec, "server_port", paramt_int, vapi_server_port);
655
  reg_config_param(sec, "log_enabled", paramt_int, vapi_log_enabled);
656
  reg_config_param(sec, "hide_device_id", paramt_int, vapi_hide_device_id);
657
  reg_config_param(sec, "vapi_log_fn", paramt_str, vapi_log_fn);
658
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.