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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [vapi/] [vapi.c] - Blame information for rev 1646

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 1557 nogj
  socklen_t len;
225 293 markom
  char myname[256];
226
  int flags;
227
  char sTemp[256];
228
 
229
  /* First, get the protocol number of TCP */
230
  if(!(protocol = getprotobyname(proto))) {
231
    sprintf(sTemp,"Unable to load protocol \"%s\"",proto);
232
    perror(sTemp);
233
    return 0;
234
  }
235
  tcp_level = protocol->p_proto; /* Save for later */
236
 
237
  /* If we weren't passed a non standard port, get the port
238
     from the services directory. */
239
  if(!port) {
240 1308 phoenix
    if((service = getservbyname(name,protocol->p_name)))
241 293 markom
      port = ntohs(service->s_port);
242
  }
243 336 markom
 
244 293 markom
  /* Create the socket using the TCP protocol */
245
  if((sockfd = socket(PF_INET,SOCK_STREAM,protocol->p_proto)) < 0) {
246
    perror("Unable to create socket");
247
    return 0;
248
  }
249 336 markom
 
250 293 markom
  flags = 1;
251
  if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,(const char*)&flags,sizeof(int)) < 0) {
252
    sprintf(sTemp,"Can not set SO_REUSEADDR option on socket %d",sockfd);
253
    perror(sTemp);
254
    close(sockfd);
255
    return 0;
256
  }
257
 
258
  /* The server should also be non blocking. Get the current flags. */
259
  if(fcntl(sockfd,F_GETFL,&flags) < 0) {
260
    sprintf(sTemp,"Unable to get flags for socket %d",sockfd);
261
    perror(sTemp);
262
    close(sockfd);
263
    return 0;
264
  }
265
 
266
  /* Set the nonblocking flag */
267
  if(fcntl(sockfd,F_SETFL, flags | O_NONBLOCK) < 0) {
268
    sprintf(sTemp,"Unable to set flags for socket %d to value 0x%08x",
269
            sockfd,flags | O_NONBLOCK);
270
    perror(sTemp);
271
    close(sockfd);
272
    return 0;
273
  }
274
 
275
  /* Find out what our address is */
276
  memset(&sa,0,sizeof(struct sockaddr_in));
277
  gethostname(myname,sizeof(myname));
278
  if(!(hp = gethostbyname(myname))) {
279
    perror("Unable to read hostname");
280
    close(sockfd);
281
    return 0;
282
  }
283
 
284
  /* Bind our socket to the appropriate address */
285
  sa.sin_family = hp->h_addrtype;
286
  sa.sin_port = htons(port);
287
  if(bind(sockfd,(struct sockaddr*)&sa,sizeof(struct sockaddr_in)) < 0) {
288
    sprintf(sTemp,"Unable to bind socket %d to port %d",sockfd,port);
289
    perror(sTemp);
290
    close(sockfd);
291
    return 0;
292
  }
293
  serverIP = sa.sin_addr.s_addr;
294 1557 nogj
  len = sizeof(struct sockaddr_in);
295
  if(getsockname(sockfd,(struct sockaddr*)&sa,&len) < 0) {
296 293 markom
    sprintf(sTemp,"Unable to get socket information for socket %d",sockfd);
297
    perror(sTemp);
298
    close(sockfd);
299
    return 0;
300
  }
301 551 markom
  runtime.vapi.server_port = ntohs(sa.sin_port);
302 293 markom
 
303
  /* Set the backlog to 1 connections */
304
  if(listen(sockfd,1) < 0) {
305
    sprintf(sTemp,"Unable to set backlog on socket %d to %d",sockfd,1);
306
    perror(sTemp);
307
    close(sockfd);
308
    return 0;
309
  }
310
 
311
  return sockfd;
312
}
313
 
314 442 erez
static void server_request()
315 293 markom
{
316
  struct sockaddr_in sa;
317
  struct sockaddr* addr = (struct sockaddr*)&sa;
318 1557 nogj
  socklen_t len = sizeof(struct sockaddr_in);
319
  int fd = accept(server_fd, addr, &len);
320 293 markom
  int on_off = 0; /* Turn off Nagel's algorithm on the socket */
321
  int flags;
322
  char sTemp[256];
323
 
324
  if(fd < 0) {
325
    /* This is valid, because a connection could have started,
326
       and then terminated due to a protocol error or user
327
       initiation before the accept could take place. */
328
    if(errno != EWOULDBLOCK && errno != EAGAIN) {
329
      perror("accept");
330
      close(server_fd);
331
      server_fd = 0;
332 551 markom
      runtime.vapi.enabled = 0;
333 293 markom
      serverIP = 0;
334 336 markom
    }
335 293 markom
    return;
336
  }
337
 
338
  if(fcntl(fd,F_GETFL,&flags) < 0) {
339
    sprintf(sTemp,"Unable to get flags for vapi socket %d",fd);
340
    perror(sTemp);
341
    close(fd);
342
    return;
343
  }
344
 
345
  if(fcntl(fd,F_SETFL, flags | O_NONBLOCK) < 0) {
346
    sprintf(sTemp,"Unable to set flags for vapi socket %d to value 0x%08x",
347
            fd,flags | O_NONBLOCK);
348
    perror(sTemp);
349
    close(fd);
350
    return;
351
  }
352
 
353
  if(setsockopt(fd,tcp_level,TCP_NODELAY,&on_off,sizeof(int)) < 0) {
354
    sprintf(sTemp,"Unable to disable Nagel's algorithm for socket %d.\nsetsockopt",fd);
355
    perror(sTemp);
356
    close(fd);
357
    return;
358
  }
359 304 markom
 
360
  /* Install new handler */
361
  {
362
    unsigned long id;
363
    struct vapi_handler *t;
364
    if (vapi_read_stream (fd, &id, sizeof (id))) {
365
      perror ("Cannot get id");
366
      close (fd);
367
      return;
368 293 markom
    }
369 304 markom
    t = find_handler (id);
370 355 markom
    if (t) {
371 304 markom
      if (t->fd) {
372 1308 phoenix
        fprintf (stderr, "WARNING: Test with id %lx already connected. Ignoring.\n", id);
373 304 markom
        close (fd);
374
        return;
375 355 markom
      } else {
376
        t->fd = fd;
377
        rebuild_fds ();
378
      }
379
    } else {
380 1308 phoenix
      fprintf (stderr, "WARNING: Test with id %lx not registered. Ignoring.\n", id);
381 355 markom
      close(fd); /* kill the connection */
382
      return;
383 293 markom
    }
384 304 markom
    if(config.sim.verbose)
385 1308 phoenix
      PRINTF ("\nConnection with test (id %lx) established.\n", id);
386 293 markom
  }
387
}
388
 
389
static int write_packet (unsigned long id, unsigned long data) {
390 304 markom
  struct vapi_handler *t = find_handler (id);
391
  if (!t || !t->fd)
392
    return 1;
393 293 markom
  id = htonl (id);
394 304 markom
  if (vapi_write_stream(t->fd, &id, sizeof (id)) < 0)
395 293 markom
    return 1;
396
  data = htonl (data);
397 304 markom
  if (vapi_write_stream(t->fd, &data, sizeof (data)) < 0)
398 293 markom
    return 1;
399
  return 0;
400 442 erez
}
401 293 markom
 
402 442 erez
static int read_packet (int fd, unsigned long *id, unsigned long *data)
403
{
404 477 erez
  if (fd <= 0)
405 293 markom
    return 1;
406 477 erez
  if (vapi_read_stream(fd, id, sizeof(unsigned long)) < 0)
407 293 markom
    return 1;
408 442 erez
  *id = ntohl (*id);
409 477 erez
  if (vapi_read_stream(fd, data, sizeof(unsigned long)) < 0)
410 304 markom
    return 1;
411 442 erez
  *data = ntohl (*data);
412 293 markom
  return 0;
413 304 markom
}
414 293 markom
 
415 442 erez
static void vapi_request (struct vapi_handler *t)
416
{
417
  unsigned long id, data;
418
 
419
  if (read_packet(t->fd, &id, &data)) {
420 477 erez
    if (t->fd > 0) {
421 293 markom
      perror("vapi read");
422 304 markom
      close(t->fd);
423
      t->fd = 0;
424 361 markom
      rebuild_fds ();
425 293 markom
    }
426
    return;
427
  }
428
 
429 442 erez
  vapi_write_log_file (VAPI_COMMAND_REQUEST, id, data);
430 1492 nogj
  TRACE ("[%08lx, %08lx]\n", id, data);
431 442 erez
 
432
  /* This packet may be for another handler */
433 477 erez
  if (!handler_fits_id (t, id))
434 442 erez
    t = find_handler (id);
435
  if (!t || !t->read_func)
436 1308 phoenix
    fprintf (stderr, "WARNING: Received packet for undefined id %08lx, data %08lx\n", id, data);
437 293 markom
  else
438 1366 nogj
    t->read_func(id, data, t->priv_dat);
439 293 markom
}
440
 
441
void vapi_check ()
442
{
443 304 markom
  struct vapi_handler *t;
444 293 markom
 
445 304 markom
  if (!server_fd || !fds) {
446
    fprintf (stderr, "FATAL: Unable to maintain VAPI server.\n");
447
    exit (1);
448 293 markom
  }
449
 
450 1492 nogj
  TRACE(".");
451 355 markom
 
452 304 markom
  /* Handle everything in queue. */
453 293 markom
  while(1) {
454 304 markom
    switch(poll(fds, nfds, 0)) {
455 293 markom
    case -1:
456
      if(errno == EINTR)
457
        continue;
458
      perror("poll");
459 304 markom
      if (server_fd)
460
        close(server_fd);
461 551 markom
      runtime.vapi.enabled = 0;
462 304 markom
      serverIP = 0;
463
      return;
464 293 markom
    case 0: /* Nothing interesting going on */
465
      return;
466
    default:
467 304 markom
      /* Handle the vapi ports first. */
468
      for (t = vapi_handler; t; t = t->next)
469
        if (t->temp >= 0 && fds[t->temp].revents)
470
          vapi_request (t);
471 293 markom
 
472 304 markom
      if(fds[0].revents) {
473 293 markom
        if(fds[0].revents & POLLIN)
474
          server_request();
475
        else { /* Error Occurred */
476 304 markom
          fprintf(stderr,"Received flags 0x%08x on server. Shutting down.\n", fds[0].revents);
477
          if (server_fd)
478
            close(server_fd);
479 293 markom
          server_fd = 0;
480 551 markom
          runtime.vapi.enabled = 0;
481 293 markom
          serverIP = 0;
482
        }
483
      }
484
      break;
485
    } /* End of switch statement */
486
  } /* End of while statement */
487
}
488
 
489 304 markom
/* Inits the VAPI, according to sim-config */
490
int vapi_init ()
491 293 markom
{
492 304 markom
  nhandlers = 0;
493
  vapi_handler = NULL;
494 551 markom
  if (!runtime.vapi.enabled)
495 304 markom
    return 0; /* Nothing to do */
496
 
497 551 markom
  runtime.vapi.server_port = config.vapi.server_port;
498
  if (!runtime.vapi.server_port) {
499 304 markom
    fprintf (stderr, "WARNING: server_port = 0, shutting down VAPI\n");
500 551 markom
    runtime.vapi.enabled = 0;
501 304 markom
    return 1;
502
  }
503 1308 phoenix
  if ((server_fd = get_server_socket("or1ksim", "tcp", runtime.vapi.server_port)))
504 997 markom
    PRINTF("VAPI Server started on port %d\n", runtime.vapi.server_port);
505 304 markom
  else {
506 293 markom
    perror ("Connection");
507 304 markom
    return 1;
508
  }
509
 
510
  rebuild_fds ();
511 355 markom
 
512 361 markom
  if ((runtime.vapi.vapi_file = fopen (config.vapi.vapi_fn, "wt+")) == NULL)
513 355 markom
    fprintf (stderr, "WARNING: cannot open VAPI log file\n");
514
 
515 304 markom
  return 0;
516
}
517
 
518
/* Closes the VAPI */
519
void vapi_done ()
520
{
521
  int i;
522
  struct vapi_handler *t = vapi_handler;
523 293 markom
 
524 304 markom
  for (i = 0; i < nfds; i++)
525
    if (fds[i].fd)
526 306 markom
      close (fds[i].fd);
527 304 markom
  server_fd = 0;
528 551 markom
  runtime.vapi.enabled = 0;
529 304 markom
  serverIP = 0;
530
  free (fds);
531
  fds = 0;
532 361 markom
  if (runtime.vapi.vapi_file) {
533
    /* Mark end of simulation */
534 442 erez
    vapi_write_log_file (VAPI_COMMAND_END, 0, 0);
535 361 markom
    fclose (runtime.vapi.vapi_file);
536
  }
537 355 markom
 
538 304 markom
  while (vapi_handler) {
539
    t = vapi_handler;
540
    vapi_handler = vapi_handler->next;
541
    free (t);
542
  }
543 293 markom
}
544
 
545 477 erez
/* Installs a vapi handler for one VAPI id */
546 1366 nogj
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long, void *), void *dat)
547 304 markom
{
548 1366 nogj
  vapi_install_multi_handler (id, 1, read_func, dat);
549 477 erez
}
550
 
551
/* Installs a vapi handler for many VAPI id */
552 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)
553 477 erez
{
554 293 markom
  struct vapi_handler *tt;
555 355 markom
 
556 1492 nogj
  TRACE("vapi_install_handler %08lx, %lu, %p\n", base_id, num_ids, read_func);
557 304 markom
  if (read_func == NULL) {
558
    struct vapi_handler **t = &vapi_handler;
559 477 erez
    while ((*t) && !handler_fits_id (*t, base_id))
560 293 markom
      t = &(*t)->next;
561
    if (!t) {
562 1308 phoenix
      fprintf (stderr, "Cannot uninstall VAPI read handler from id %lx\n",
563
               base_id);
564 293 markom
      exit (1);
565
    }
566
    tt = *t;
567
    (*t) = (*t)->next;
568
    free (tt);
569 304 markom
    nhandlers--;
570 293 markom
  } else {
571 477 erez
    tt = find_handler (base_id);
572 355 markom
    if (!tt) {
573 477 erez
      tt = add_handler (base_id, num_ids);
574 355 markom
      tt->read_func = read_func;
575 1366 nogj
      tt->priv_dat = dat;
576 355 markom
    } else {
577
      tt->read_func = read_func;
578 1366 nogj
      tt->priv_dat = dat;
579 355 markom
      rebuild_fds ();
580
    }
581 293 markom
  }
582
}
583
 
584 304 markom
/* Returns number of unconnected handles.  */
585 336 markom
int vapi_num_unconnected (int printout)
586 304 markom
{
587
  struct vapi_handler *t = vapi_handler;
588
  int numu = 0;
589 336 markom
  for (; t; t = t->next) {
590
    if (!t->fd) {
591
      numu++;
592 477 erez
      if (printout) {
593
        if ( t->num_ids == 1 )
594 1308 phoenix
          PRINTF (" 0x%lx", t->base_id);
595 477 erez
        else
596 1308 phoenix
          PRINTF (" 0x%lx..0x%lx", t->base_id, t->base_id + t->num_ids - 1);
597 477 erez
      }
598 336 markom
    }
599
  }
600 304 markom
  return numu;
601
}
602
 
603 305 markom
/* Sends a packet to specified test */
604 1557 nogj
void vapi_send (unsigned long id, unsigned long data)
605 305 markom
{
606 1492 nogj
  TRACE ("vapi_send [%08lx %08lx]\n", id, data);
607 442 erez
  vapi_write_log_file (VAPI_COMMAND_SEND, id, data);
608 305 markom
  write_packet (id, data);
609
}
610
 
611
/*
612 304 markom
int main ()
613
{
614 551 markom
  runtime.vapi.enabled = 1;
615 304 markom
  config.vapi.server_port = 9999;
616 293 markom
  vapi_init ();
617
  while (1) {
618
    vapi_check();
619 304 markom
    usleep(1);
620 293 markom
  }
621
  vapi_done ();
622 335 markom
}*/
623 1358 nogj
 
624
/*---------------------------------------------------[ VAPI configuration ]---*/
625
void vapi_enabled(union param_val val, void *dat)
626
{
627
  config.vapi.enabled = val.int_val;
628
}
629
 
630
void vapi_server_port(union param_val val, void *dat)
631
{
632
  config.vapi.server_port = val.int_val;
633
}
634
 
635
void vapi_log_enabled(union param_val val, void *dat)
636
{
637
  config.vapi.log_enabled = val.int_val;
638
}
639
 
640
void vapi_hide_device_id(union param_val val, void *dat)
641
{
642
  config.vapi.hide_device_id = val.int_val;
643
}
644
 
645
void vapi_log_fn(union param_val val, void *dat)
646
{
647
  strcpy(config.vapi.vapi_fn, val.str_val);
648
}
649
 
650
void reg_vapi_sec(void)
651
{
652
  struct config_section *sec = reg_config_sec("VAPI", NULL, NULL);
653
 
654
  reg_config_param(sec, "enabled", paramt_int, vapi_enabled);
655
  reg_config_param(sec, "server_port", paramt_int, vapi_server_port);
656
  reg_config_param(sec, "log_enabled", paramt_int, vapi_log_enabled);
657
  reg_config_param(sec, "hide_device_id", paramt_int, vapi_hide_device_id);
658
  reg_config_param(sec, "vapi_log_fn", paramt_str, vapi_log_fn);
659
}

powered by: WebSVN 2.1.0

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