Thu Apr 16 06:07:53 2009 UTC ()
Fix WARNS=4 issues (-Wcast-qual -Wshadow)


(lukem)
diff -r1.10 -r1.11 src/usr.sbin/lmcconfig/lmcconfig.c

cvs diff -r1.10 -r1.11 src/usr.sbin/lmcconfig/Attic/lmcconfig.c (expand / switch to unified diff)

--- src/usr.sbin/lmcconfig/Attic/lmcconfig.c 2006/05/25 00:16:48 1.10
+++ src/usr.sbin/lmcconfig/Attic/lmcconfig.c 2009/04/16 06:07:53 1.11
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1/*- 1/*-
2 * $NetBSD: lmcconfig.c,v 1.10 2006/05/25 00:16:48 christos Exp $ 2 * $NetBSD: lmcconfig.c,v 1.11 2009/04/16 06:07:53 lukem Exp $
3 * 3 *
4 * First author: Michael Graff. 4 * First author: Michael Graff.
5 * Copyright (c) 1997-2000 Lan Media Corp. 5 * Copyright (c) 1997-2000 Lan Media Corp.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Second author: Andrew Stanley-Jones. 8 * Second author: Andrew Stanley-Jones.
9 * Copyright (c) 2000-2002 SBE Corp. 9 * Copyright (c) 2000-2002 SBE Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Third author: David Boggs. 12 * Third author: David Boggs.
13 * Copyright (c) 2002-2006 David Boggs. 13 * Copyright (c) 2002-2006 David Boggs.
14 * All rights reserved. 14 * All rights reserved.
15 * 15 *
@@ -134,51 +134,51 @@ void synth_freq(unsigned long); @@ -134,51 +134,51 @@ void synth_freq(unsigned long);
134void print_cable_len(void); 134void print_cable_len(void);
135void print_cable_type(void); 135void print_cable_type(void);
136void print_time_slots(void); 136void print_time_slots(void);
137void print_scrambler(void); 137void print_scrambler(void);
138double vga_dbs(u_int8_t); 138double vga_dbs(u_int8_t);
139void print_rx_gain_max(void); 139void print_rx_gain_max(void);
140void print_tx_lbo(void); 140void print_tx_lbo(void);
141void print_tx_pulse(int); 141void print_tx_pulse(int);
142void print_ssi_sigs(void); 142void print_ssi_sigs(void);
143void print_hssi_sigs(void); 143void print_hssi_sigs(void);
144void print_events(void); 144void print_events(void);
145void print_summary(void); 145void print_summary(void);
146 146
147char *print_t3_bop(int); 147const char *print_t3_bop(int);
148void print_t3_snmp(void); 148void print_t3_snmp(void);
149void print_t3_dsu(void); 149void print_t3_dsu(void);
150void t3_cmd(int, char **); 150void t3_cmd(int, char **);
151 151
152char *print_t1_bop(int); 152const char *print_t1_bop(int);
153void print_t1_test_pattern(int); 153void print_t1_test_pattern(int);
154void print_t1_far_report(int); 154void print_t1_far_report(int);
155void print_t1_snmp(void); 155void print_t1_snmp(void);
156void print_t1_dsu(void); 156void print_t1_dsu(void);
157void t1_cmd(int, char **); 157void t1_cmd(int, char **);
158 158
159unsigned char read_hex(FILE *); 159unsigned char read_hex(FILE *);
160void load_xilinx(char *); 160void load_xilinx(char *);
161 161
162u_int32_t crc32(u_int8_t *, int); 162u_int32_t crc32(u_int8_t *, int);
163u_int8_t crc8(u_int16_t *, int); 163u_int8_t crc8(u_int16_t *, int);
164 164
165void main_cmd(int, char **); 165void main_cmd(int, char **);
166/* int main(int, char **); */ 166/* int main(int, char **); */
167 167
168/* program global variables */ 168/* program global variables */
169 169
170char * progname; /* name of this program */ 170char * progname; /* name of this program */
171char * ifname; /* interface name */ 171const char * ifname; /* interface name */
172int fdcs; /* ifnet File Desc or ng Ctl Socket */ 172int fdcs; /* ifnet File Desc or ng Ctl Socket */
173struct status status; /* card status (read only) */ 173struct status status; /* card status (read only) */
174struct config config; /* card configuration (read/write) */ 174struct config config; /* card configuration (read/write) */
175int netgraph = 0; /* non-zero if netgraph present */ 175int netgraph = 0; /* non-zero if netgraph present */
176int summary = 0; /* print summary at end */ 176int summary = 0; /* print summary at end */
177int update = 0; /* update driver config */ 177int update = 0; /* update driver config */
178int verbose = 0; /* verbose output */ 178int verbose = 0; /* verbose output */
179unsigned int waittime = 0; /* time in seconds between status prints */ 179unsigned int waittime = 0; /* time in seconds between status prints */
180u_int8_t checksum; /* gate array ucode file checksum */ 180u_int8_t checksum; /* gate array ucode file checksum */
181 181
182void usage() 182void usage()
183 { 183 {
184 fprintf(stderr, "Usage: %s interface [-abBcCdDeEfgGhiLmMpPsStTuUvVwxXyY?]\n", progname); 184 fprintf(stderr, "Usage: %s interface [-abBcCdDeEfgGhiLmMpPsStTuUvVwxXyY?]\n", progname);
@@ -333,278 +333,278 @@ void call_driver(unsigned long cmd, stru @@ -333,278 +333,278 @@ void call_driver(unsigned long cmd, stru
333 } 333 }
334 334
335 if (iohdr->cookie != NGM_LMC_COOKIE) 335 if (iohdr->cookie != NGM_LMC_COOKIE)
336 { 336 {
337 fprintf(stderr, "%s: cookie is 0x%08X; expected 0x%08X\n", 337 fprintf(stderr, "%s: cookie is 0x%08X; expected 0x%08X\n",
338 progname, iohdr->cookie, NGM_LMC_COOKIE); 338 progname, iohdr->cookie, NGM_LMC_COOKIE);
339 fprintf(stderr, "%s: recompile this program!\n", progname); 339 fprintf(stderr, "%s: recompile this program!\n", progname);
340 exit(1); 340 exit(1);
341 } 341 }
342 } 342 }
343 343
344u_int32_t read_pci_config(u_int8_t addr) 344u_int32_t read_pci_config(u_int8_t addr)
345 { 345 {
346 struct ioctl ioctl; 346 struct ioctl ioc;
347 347
348 ioctl.iohdr.direction = DIR_IOWR; 348 ioc.iohdr.direction = DIR_IOWR;
349 ioctl.iohdr.length = sizeof(struct ioctl); 349 ioc.iohdr.length = sizeof(struct ioctl);
350 ioctl.cmd = IOCTL_RW_PCI; 350 ioc.cmd = IOCTL_RW_PCI;
351 ioctl.address = addr; 351 ioc.address = addr;
352 352
353 call_driver(LMCIOCREAD, &ioctl.iohdr); 353 call_driver(LMCIOCREAD, &ioc.iohdr);
354 354
355 return ioctl.data; 355 return ioc.data;
356 } 356 }
357 357
358void write_pci_config(u_int8_t addr, u_int32_t data) 358void write_pci_config(u_int8_t addr, u_int32_t data)
359 { 359 {
360 struct ioctl ioctl; 360 struct ioctl ioc;
361 361
362 ioctl.iohdr.direction = DIR_IOW; 362 ioc.iohdr.direction = DIR_IOW;
363 ioctl.iohdr.length = sizeof(struct ioctl); 363 ioc.iohdr.length = sizeof(struct ioctl);
364 ioctl.cmd = IOCTL_RW_PCI; 364 ioc.cmd = IOCTL_RW_PCI;
365 ioctl.address = addr; 365 ioc.address = addr;
366 ioctl.data = data; 366 ioc.data = data;
367 367
368 call_driver(LMCIOCWRITE, &ioctl.iohdr); 368 call_driver(LMCIOCWRITE, &ioc.iohdr);
369 } 369 }
370 370
371u_int32_t read_csr(u_int8_t addr) 371u_int32_t read_csr(u_int8_t addr)
372 { 372 {
373 struct ioctl ioctl; 373 struct ioctl ioc;
374 374
375 ioctl.iohdr.direction = DIR_IOWR; 375 ioc.iohdr.direction = DIR_IOWR;
376 ioctl.iohdr.length = sizeof(struct ioctl); 376 ioc.iohdr.length = sizeof(struct ioctl);
377 ioctl.cmd = IOCTL_RW_CSR; 377 ioc.cmd = IOCTL_RW_CSR;
378 ioctl.address = addr; 378 ioc.address = addr;
379 379
380 call_driver(LMCIOCREAD, &ioctl.iohdr); 380 call_driver(LMCIOCREAD, &ioc.iohdr);
381 381
382 return ioctl.data; 382 return ioc.data;
383 } 383 }
384 384
385void write_csr(u_int8_t addr, u_int32_t data) 385void write_csr(u_int8_t addr, u_int32_t data)
386 { 386 {
387 struct ioctl ioctl; 387 struct ioctl ioc;
388 388
389 ioctl.iohdr.direction = DIR_IOW; 389 ioc.iohdr.direction = DIR_IOW;
390 ioctl.iohdr.length = sizeof(struct ioctl); 390 ioc.iohdr.length = sizeof(struct ioctl);
391 ioctl.cmd = IOCTL_RW_CSR; 391 ioc.cmd = IOCTL_RW_CSR;
392 ioctl.address = addr; 392 ioc.address = addr;
393 ioctl.data = data; 393 ioc.data = data;
394 394
395 call_driver(LMCIOCWRITE, &ioctl.iohdr); 395 call_driver(LMCIOCWRITE, &ioc.iohdr);
396 } 396 }
397 397
398u_int16_t read_srom(u_int8_t addr) 398u_int16_t read_srom(u_int8_t addr)
399 { 399 {
400 struct ioctl ioctl; 400 struct ioctl ioc;
401 401
402 ioctl.iohdr.direction = DIR_IOWR; 402 ioc.iohdr.direction = DIR_IOWR;
403 ioctl.iohdr.length = sizeof(struct ioctl); 403 ioc.iohdr.length = sizeof(struct ioctl);
404 ioctl.cmd = IOCTL_RW_SROM; 404 ioc.cmd = IOCTL_RW_SROM;
405 ioctl.address = addr; 405 ioc.address = addr;
406 406
407 call_driver(LMCIOCREAD, &ioctl.iohdr); 407 call_driver(LMCIOCREAD, &ioc.iohdr);
408 408
409 return ioctl.data; 409 return ioc.data;
410 } 410 }
411 411
412void write_srom(u_int8_t addr, u_int16_t data) 412void write_srom(u_int8_t addr, u_int16_t data)
413 { 413 {
414 struct ioctl ioctl; 414 struct ioctl ioc;
415 415
416 ioctl.iohdr.direction = DIR_IOW; 416 ioc.iohdr.direction = DIR_IOW;
417 ioctl.iohdr.length = sizeof(struct ioctl); 417 ioc.iohdr.length = sizeof(struct ioctl);
418 ioctl.cmd = IOCTL_RW_SROM; 418 ioc.cmd = IOCTL_RW_SROM;
419 ioctl.address = addr; 419 ioc.address = addr;
420 ioctl.data = data; 420 ioc.data = data;
421 421
422 call_driver(LMCIOCWRITE, &ioctl.iohdr); 422 call_driver(LMCIOCWRITE, &ioc.iohdr);
423 } 423 }
424 424
425u_int8_t read_bios_rom(u_int32_t addr) 425u_int8_t read_bios_rom(u_int32_t addr)
426 { 426 {
427 struct ioctl ioctl; 427 struct ioctl ioc;
428 428
429 ioctl.iohdr.direction = DIR_IOWR; 429 ioc.iohdr.direction = DIR_IOWR;
430 ioctl.iohdr.length = sizeof(struct ioctl); 430 ioc.iohdr.length = sizeof(struct ioctl);
431 ioctl.cmd = IOCTL_RW_BIOS; 431 ioc.cmd = IOCTL_RW_BIOS;
432 ioctl.address = addr; 432 ioc.address = addr;
433 433
434 call_driver(LMCIOCREAD, &ioctl.iohdr); 434 call_driver(LMCIOCREAD, &ioc.iohdr);
435 435
436 return ioctl.data; 436 return ioc.data;
437 } 437 }
438 438
439void write_bios_rom(u_int32_t addr, u_int8_t data) 439void write_bios_rom(u_int32_t addr, u_int8_t data)
440 { 440 {
441 struct ioctl ioctl; 441 struct ioctl ioc;
442 442
443 ioctl.iohdr.direction = DIR_IOW; 443 ioc.iohdr.direction = DIR_IOW;
444 ioctl.iohdr.length = sizeof(struct ioctl); 444 ioc.iohdr.length = sizeof(struct ioctl);
445 ioctl.cmd = IOCTL_RW_BIOS; 445 ioc.cmd = IOCTL_RW_BIOS;
446 ioctl.address = addr; 446 ioc.address = addr;
447 ioctl.data = data; 447 ioc.data = data;
448 448
449 call_driver(LMCIOCWRITE, &ioctl.iohdr); 449 call_driver(LMCIOCWRITE, &ioc.iohdr);
450 } 450 }
451 451
452u_int16_t read_mii(u_int8_t addr) 452u_int16_t read_mii(u_int8_t addr)
453 { 453 {
454 struct ioctl ioctl; 454 struct ioctl ioc;
455 455
456 ioctl.iohdr.direction = DIR_IOWR; 456 ioc.iohdr.direction = DIR_IOWR;
457 ioctl.iohdr.length = sizeof(struct ioctl); 457 ioc.iohdr.length = sizeof(struct ioctl);
458 ioctl.cmd = IOCTL_RW_MII; 458 ioc.cmd = IOCTL_RW_MII;
459 ioctl.address = addr; 459 ioc.address = addr;
460 460
461 call_driver(LMCIOCREAD, &ioctl.iohdr); 461 call_driver(LMCIOCREAD, &ioc.iohdr);
462 462
463 return ioctl.data; 463 return ioc.data;
464 } 464 }
465 465
466void write_mii(u_int8_t addr, u_int16_t data) 466void write_mii(u_int8_t addr, u_int16_t data)
467 { 467 {
468 struct ioctl ioctl; 468 struct ioctl ioc;
469 469
470 ioctl.iohdr.direction = DIR_IOW; 470 ioc.iohdr.direction = DIR_IOW;
471 ioctl.iohdr.length = sizeof(struct ioctl); 471 ioc.iohdr.length = sizeof(struct ioctl);
472 ioctl.cmd = IOCTL_RW_MII; 472 ioc.cmd = IOCTL_RW_MII;
473 ioctl.address = addr; 473 ioc.address = addr;
474 ioctl.data = data; 474 ioc.data = data;
475 475
476 call_driver(LMCIOCWRITE, &ioctl.iohdr); 476 call_driver(LMCIOCWRITE, &ioc.iohdr);
477 } 477 }
478 478
479u_int8_t read_framer(u_int16_t addr) 479u_int8_t read_framer(u_int16_t addr)
480 { 480 {
481 struct ioctl ioctl; 481 struct ioctl ioc;
482 482
483 ioctl.iohdr.direction = DIR_IOWR; 483 ioc.iohdr.direction = DIR_IOWR;
484 ioctl.iohdr.length = sizeof(struct ioctl); 484 ioc.iohdr.length = sizeof(struct ioctl);
485 ioctl.cmd = IOCTL_RW_FRAME; 485 ioc.cmd = IOCTL_RW_FRAME;
486 ioctl.address = addr; 486 ioc.address = addr;
487 487
488 call_driver(LMCIOCREAD, &ioctl.iohdr); 488 call_driver(LMCIOCREAD, &ioc.iohdr);
489 489
490 return ioctl.data; 490 return ioc.data;
491 } 491 }
492 492
493void write_framer(u_int16_t addr, u_int8_t data) 493void write_framer(u_int16_t addr, u_int8_t data)
494 { 494 {
495 struct ioctl ioctl; 495 struct ioctl ioc;
496 496
497 ioctl.iohdr.direction = DIR_IOW; 497 ioc.iohdr.direction = DIR_IOW;
498 ioctl.iohdr.length = sizeof(struct ioctl); 498 ioc.iohdr.length = sizeof(struct ioctl);
499 ioctl.cmd = IOCTL_RW_FRAME; 499 ioc.cmd = IOCTL_RW_FRAME;
500 ioctl.address = addr; 500 ioc.address = addr;
501 ioctl.data = data; 501 ioc.data = data;
502 502
503 call_driver(LMCIOCWRITE, &ioctl.iohdr); 503 call_driver(LMCIOCWRITE, &ioc.iohdr);
504 } 504 }
505 505
506void write_synth(struct synth synth) 506void write_synth(struct synth synth)
507 { 507 {
508 struct ioctl ioctl; 508 struct ioctl ioc;
509 509
510 ioctl.iohdr.direction = DIR_IOW; 510 ioc.iohdr.direction = DIR_IOW;
511 ioctl.iohdr.length = sizeof(struct ioctl); 511 ioc.iohdr.length = sizeof(struct ioctl);
512 ioctl.cmd = IOCTL_WO_SYNTH; 512 ioc.cmd = IOCTL_WO_SYNTH;
513 bcopy(&synth, &ioctl.data, sizeof(synth)); 513 bcopy(&synth, &ioc.data, sizeof(synth));
514 514
515 call_driver(LMCIOCWRITE, &ioctl.iohdr); 515 call_driver(LMCIOCWRITE, &ioc.iohdr);
516 } 516 }
517 517
518void write_dac(u_int16_t data) 518void write_dac(u_int16_t data)
519 { 519 {
520 struct ioctl ioctl; 520 struct ioctl ioc;
521 521
522 ioctl.iohdr.direction = DIR_IOW; 522 ioc.iohdr.direction = DIR_IOW;
523 ioctl.iohdr.length = sizeof(struct ioctl); 523 ioc.iohdr.length = sizeof(struct ioctl);
524 ioctl.cmd = IOCTL_WO_DAC; 524 ioc.cmd = IOCTL_WO_DAC;
525 ioctl.data = data; 525 ioc.data = data;
526 526
527 call_driver(LMCIOCWRITE, &ioctl.iohdr); 527 call_driver(LMCIOCWRITE, &ioc.iohdr);
528 } 528 }
529 529
530void reset_xilinx() 530void reset_xilinx()
531 { 531 {
532 struct ioctl ioctl; 532 struct ioctl ioc;
533 533
534 ioctl.iohdr.direction = DIR_IOWR; 534 ioc.iohdr.direction = DIR_IOWR;
535 ioctl.iohdr.length = sizeof(struct ioctl); 535 ioc.iohdr.length = sizeof(struct ioctl);
536 ioctl.cmd = IOCTL_XILINX_RESET; 536 ioc.cmd = IOCTL_XILINX_RESET;
537 537
538 call_driver(LMCIOCTL, &ioctl.iohdr); 538 call_driver(LMCIOCTL, &ioc.iohdr);
539 } 539 }
540 540
541void load_xilinx_from_rom() 541void load_xilinx_from_rom()
542 { 542 {
543 struct ioctl ioctl; 543 struct ioctl ioc;
544 544
545 ioctl.iohdr.direction = DIR_IOWR; 545 ioc.iohdr.direction = DIR_IOWR;
546 ioctl.iohdr.length = sizeof(struct ioctl); 546 ioc.iohdr.length = sizeof(struct ioctl);
547 ioctl.cmd = IOCTL_XILINX_ROM; 547 ioc.cmd = IOCTL_XILINX_ROM;
548 548
549 call_driver(LMCIOCTL, &ioctl.iohdr); 549 call_driver(LMCIOCTL, &ioc.iohdr);
550 } 550 }
551 551
552void load_xilinx_from_file(char *ucode, int len) 552void load_xilinx_from_file(char *ucode, int len)
553 { 553 {
554 struct ioctl ioctl; 554 struct ioctl ioc;
555 555
556 ioctl.iohdr.direction = DIR_IOWR; 556 ioc.iohdr.direction = DIR_IOWR;
557 ioctl.iohdr.length = sizeof(struct ioctl); 557 ioc.iohdr.length = sizeof(struct ioctl);
558 ioctl.cmd = IOCTL_XILINX_FILE; 558 ioc.cmd = IOCTL_XILINX_FILE;
559 ioctl.data = len; 559 ioc.data = len;
560 ioctl.ucode = ucode; 560 ioc.ucode = ucode;
561 561
562 call_driver(LMCIOCTL, &ioctl.iohdr); 562 call_driver(LMCIOCTL, &ioc.iohdr);
563 } 563 }
564 564
565void ioctl_snmp_send(u_int32_t send) 565void ioctl_snmp_send(u_int32_t sendval)
566 { 566 {
567 struct ioctl ioctl; 567 struct ioctl ioc;
568 568
569 ioctl.iohdr.direction = DIR_IOWR; 569 ioc.iohdr.direction = DIR_IOWR;
570 ioctl.iohdr.length = sizeof(struct ioctl); 570 ioc.iohdr.length = sizeof(struct ioctl);
571 ioctl.cmd = IOCTL_SNMP_SEND; 571 ioc.cmd = IOCTL_SNMP_SEND;
572 ioctl.data = send; 572 ioc.data = sendval;
573 573
574 call_driver(LMCIOCTL, &ioctl.iohdr); 574 call_driver(LMCIOCTL, &ioc.iohdr);
575 } 575 }
576 576
577void ioctl_snmp_loop(u_int32_t loop) 577void ioctl_snmp_loop(u_int32_t loop)
578 { 578 {
579 struct ioctl ioctl; 579 struct ioctl ioc;
580 580
581 ioctl.iohdr.direction = DIR_IOWR; 581 ioc.iohdr.direction = DIR_IOWR;
582 ioctl.iohdr.length = sizeof(struct ioctl); 582 ioc.iohdr.length = sizeof(struct ioctl);
583 ioctl.cmd = IOCTL_SNMP_LOOP; 583 ioc.cmd = IOCTL_SNMP_LOOP;
584 ioctl.data = loop; 584 ioc.data = loop;
585 585
586 call_driver(LMCIOCTL, &ioctl.iohdr); 586 call_driver(LMCIOCTL, &ioc.iohdr);
587 } 587 }
588 588
589void ioctl_reset_cntrs() 589void ioctl_reset_cntrs()
590 { 590 {
591 struct ioctl ioctl; 591 struct ioctl ioc;
592 592
593 ioctl.iohdr.direction = DIR_IOWR; 593 ioc.iohdr.direction = DIR_IOWR;
594 ioctl.iohdr.length = sizeof(struct ioctl); 594 ioc.iohdr.length = sizeof(struct ioctl);
595 ioctl.cmd = IOCTL_RESET_CNTRS; 595 ioc.cmd = IOCTL_RESET_CNTRS;
596 596
597 call_driver(LMCIOCTL, &ioctl.iohdr); 597 call_driver(LMCIOCTL, &ioc.iohdr);
598 } 598 }
599 599
600void ioctl_read_config() 600void ioctl_read_config()
601 { 601 {
602 config.iohdr.direction = DIR_IOWR; 602 config.iohdr.direction = DIR_IOWR;
603 config.iohdr.length = sizeof(struct config); 603 config.iohdr.length = sizeof(struct config);
604 604
605 call_driver(LMCIOCGCFG, &config.iohdr); 605 call_driver(LMCIOCGCFG, &config.iohdr);
606 } 606 }
607 607
608void ioctl_write_config() 608void ioctl_write_config()
609 { 609 {
610 config.iohdr.direction = DIR_IOW; 610 config.iohdr.direction = DIR_IOW;
@@ -1098,43 +1098,43 @@ void print_hssi_sigs() @@ -1098,43 +1098,43 @@ void print_hssi_sigs()
1098 1098
1099 printf("Modem signals:\t\tTA=%s CA=%s\n", 1099 printf("Modem signals:\t\tTA=%s CA=%s\n",
1100 (mii16 & MII16_HSSI_TA) ? on : off, 1100 (mii16 & MII16_HSSI_TA) ? on : off,
1101 (mii16 & MII16_HSSI_CA) ? on : off); 1101 (mii16 & MII16_HSSI_CA) ? on : off);
1102 printf("Modem signals:\t\tLA=%s LB=%s LC=%s TM=%s\n", 1102 printf("Modem signals:\t\tLA=%s LB=%s LC=%s TM=%s\n",
1103 (mii16 & MII16_HSSI_LA) ? on : off, 1103 (mii16 & MII16_HSSI_LA) ? on : off,
1104 (mii16 & MII16_HSSI_LB) ? on : off, 1104 (mii16 & MII16_HSSI_LB) ? on : off,
1105 (mii16 & MII16_HSSI_LC) ? on : off, 1105 (mii16 & MII16_HSSI_LC) ? on : off,
1106 (mii16 & MII16_HSSI_TM) ? on : off); 1106 (mii16 & MII16_HSSI_TM) ? on : off);
1107 } 1107 }
1108 1108
1109void print_events() 1109void print_events()
1110 { 1110 {
1111 char *time; 1111 const char *timestr;
1112 struct timeval tv; 1112 struct timeval tv;
1113 time_t tv_sec; 1113 time_t tv_sec;
1114 1114
1115 (void)gettimeofday(&tv, NULL); 1115 (void)gettimeofday(&tv, NULL);
1116 tv_sec = tv.tv_sec; 1116 tv_sec = tv.tv_sec;
1117 time = ctime(&tv_sec); 1117 timestr = ctime(&tv_sec);
1118 printf("Current time:\t\t%s", time); 1118 printf("Current time:\t\t%s", timestr);
1119 1119
1120 if (status.cntrs.reset_time.tv_sec < 1000) 1120 if (status.cntrs.reset_time.tv_sec < 1000)
1121 time = "Never\n"; 1121 timestr = "Never\n";
1122 else 1122 else
1123 { 1123 {
1124 tv_sec = status.cntrs.reset_time.tv_sec; 1124 tv_sec = status.cntrs.reset_time.tv_sec;
1125 time = ctime(&tv_sec); 1125 timestr = ctime(&tv_sec);
1126 } 1126 }
1127 printf("Cntrs reset:\t\t%s", time); 1127 printf("Cntrs reset:\t\t%s", timestr);
1128 1128
1129 if (status.cntrs.ibytes) printf("Rx bytes:\t\t%llu\n", (unsigned long long)status.cntrs.ibytes); 1129 if (status.cntrs.ibytes) printf("Rx bytes:\t\t%llu\n", (unsigned long long)status.cntrs.ibytes);
1130 if (status.cntrs.obytes) printf("Tx bytes:\t\t%llu\n", (unsigned long long)status.cntrs.obytes); 1130 if (status.cntrs.obytes) printf("Tx bytes:\t\t%llu\n", (unsigned long long)status.cntrs.obytes);
1131 if (status.cntrs.ipackets) printf("Rx packets:\t\t%llu\n", (unsigned long long)status.cntrs.ipackets); 1131 if (status.cntrs.ipackets) printf("Rx packets:\t\t%llu\n", (unsigned long long)status.cntrs.ipackets);
1132 if (status.cntrs.opackets) printf("Tx packets:\t\t%llu\n", (unsigned long long)status.cntrs.opackets); 1132 if (status.cntrs.opackets) printf("Tx packets:\t\t%llu\n", (unsigned long long)status.cntrs.opackets);
1133 if (status.cntrs.ierrors) printf("Rx errors:\t\t%u\n", status.cntrs.ierrors); 1133 if (status.cntrs.ierrors) printf("Rx errors:\t\t%u\n", status.cntrs.ierrors);
1134 if (status.cntrs.oerrors) printf("Tx errors:\t\t%u\n", status.cntrs.oerrors); 1134 if (status.cntrs.oerrors) printf("Tx errors:\t\t%u\n", status.cntrs.oerrors);
1135 if (status.cntrs.idrops) printf("Rx drops:\t\t%u\n", status.cntrs.idrops); 1135 if (status.cntrs.idrops) printf("Rx drops:\t\t%u\n", status.cntrs.idrops);
1136 if (status.cntrs.missed) printf("Rx missed:\t\t%u\n", status.cntrs.missed); 1136 if (status.cntrs.missed) printf("Rx missed:\t\t%u\n", status.cntrs.missed);
1137 if (status.cntrs.odrops) printf("Tx drops:\t\t%u\n", status.cntrs.odrops); 1137 if (status.cntrs.odrops) printf("Tx drops:\t\t%u\n", status.cntrs.odrops);
1138 if (status.cntrs.fifo_over) printf("Rx fifo overruns:\t%u\n", status.cntrs.fifo_over); 1138 if (status.cntrs.fifo_over) printf("Rx fifo overruns:\t%u\n", status.cntrs.fifo_over);
1139 if (status.cntrs.overruns) printf("Rx overruns:\t\t%u\n", status.cntrs.overruns); 1139 if (status.cntrs.overruns) printf("Rx overruns:\t\t%u\n", status.cntrs.overruns);
1140 if (status.cntrs.fifo_under) printf("Tx fifo underruns:\t%u\n", status.cntrs.fifo_under); 1140 if (status.cntrs.fifo_under) printf("Tx fifo underruns:\t%u\n", status.cntrs.fifo_under);
@@ -1246,27 +1246,27 @@ void print_summary() @@ -1246,27 +1246,27 @@ void print_summary()
1246 print_synth_freq(); 1246 print_synth_freq();
1247 print_hssi_sigs(); 1247 print_hssi_sigs();
1248 print_events(); 1248 print_events();
1249 break; 1249 break;
1250 } 1250 }
1251 default: 1251 default:
1252 { 1252 {
1253 printf("%s: Unknown card type: %d\n", ifname, status.card_type); 1253 printf("%s: Unknown card type: %d\n", ifname, status.card_type);
1254 break; 1254 break;
1255 } 1255 }
1256 } 1256 }
1257 } 1257 }
1258 1258
1259char *print_t3_bop(int bop_code) 1259const char *print_t3_bop(int bop_code)
1260 { 1260 {
1261 switch(bop_code) 1261 switch(bop_code)
1262 { 1262 {
1263 case 0x00: 1263 case 0x00:
1264 return "far end LOF"; 1264 return "far end LOF";
1265 case 0x0E: 1265 case 0x0E:
1266 return "far end LOS"; 1266 return "far end LOS";
1267 case 0x16: 1267 case 0x16:
1268 return "far end AIS"; 1268 return "far end AIS";
1269 case 0x1A: 1269 case 0x1A:
1270 return "far end IDL"; 1270 return "far end IDL";
1271 case 0x07: 1271 case 0x07:
1272 return "Line Loopback activate"; 1272 return "Line Loopback activate";
@@ -1339,27 +1339,27 @@ void print_t3_dsu() @@ -1339,27 +1339,27 @@ void print_t3_dsu()
1339 print_t3_bop(read_framer(T3CSR_TX_FEAC) & 0x3F)); 1339 print_t3_bop(read_framer(T3CSR_TX_FEAC) & 0x3F));
1340 printf("Last dbl FEAC msg:\t0x%02X (%s)\n", 1340 printf("Last dbl FEAC msg:\t0x%02X (%s)\n",
1341 read_framer(T3CSR_DBL_FEAC) & 0x3F, 1341 read_framer(T3CSR_DBL_FEAC) & 0x3F,
1342 print_t3_bop(read_framer(T3CSR_DBL_FEAC) & 0x3F)); 1342 print_t3_bop(read_framer(T3CSR_DBL_FEAC) & 0x3F));
1343 printf("Last Rx FEAC msg:\t0x%02X (%s)\n", 1343 printf("Last Rx FEAC msg:\t0x%02X (%s)\n",
1344 read_framer(T3CSR_RX_FEAC) & 0x3F, 1344 read_framer(T3CSR_RX_FEAC) & 0x3F,
1345 print_t3_bop(read_framer(T3CSR_RX_FEAC) & 0x3F)); 1345 print_t3_bop(read_framer(T3CSR_RX_FEAC) & 0x3F));
1346 print_t3_snmp(); 1346 print_t3_snmp();
1347 } 1347 }
1348 1348
1349void t3_cmd(int argc, char **argv) 1349void t3_cmd(int argc, char **argv)
1350 { 1350 {
1351 int ch; 1351 int ch;
1352 char *optstring = "a:A:B:c:de:fF:lLsS:V:"; 1352 const char *optstring = "a:A:B:c:de:fF:lLsS:V:";
1353 1353
1354 while ((ch = getopt(argc, argv, optstring)) != -1) 1354 while ((ch = getopt(argc, argv, optstring)) != -1)
1355 { 1355 {
1356 switch (ch) 1356 switch (ch)
1357 { 1357 {
1358 case 'a': /* stop alarms */ 1358 case 'a': /* stop alarms */
1359 { 1359 {
1360 switch (optarg[0]) 1360 switch (optarg[0])
1361 { 1361 {
1362 case 'a': /* Stop sending AIS Signal */ 1362 case 'a': /* Stop sending AIS Signal */
1363 { 1363 {
1364 write_mii(16, 1364 write_mii(16,
1365 read_mii(16) & ~MII16_DS3_FRAME); 1365 read_mii(16) & ~MII16_DS3_FRAME);
@@ -1516,27 +1516,27 @@ void t3_cmd(int argc, char **argv) @@ -1516,27 +1516,27 @@ void t3_cmd(int argc, char **argv)
1516 write_dac(dac); 1516 write_dac(dac);
1517 if (verbose) printf("VCXO DAC value is %d\n", dac); 1517 if (verbose) printf("VCXO DAC value is %d\n", dac);
1518 break; 1518 break;
1519 } 1519 }
1520 default: 1520 default:
1521 { 1521 {
1522 printf("Unknown command char: %c\n", ch); 1522 printf("Unknown command char: %c\n", ch);
1523 exit(1); 1523 exit(1);
1524 } /* case */ 1524 } /* case */
1525 } /* switch */ 1525 } /* switch */
1526 } /* while */ 1526 } /* while */
1527 } /* proc */ 1527 } /* proc */
1528 1528
1529char *print_t1_bop(int bop_code) 1529const char *print_t1_bop(int bop_code)
1530 { 1530 {
1531 switch(bop_code) 1531 switch(bop_code)
1532 { 1532 {
1533 case 0x00: 1533 case 0x00:
1534 return "Yellow Alarm (far end LOF)"; 1534 return "Yellow Alarm (far end LOF)";
1535 case 0x07: 1535 case 0x07:
1536 return "Line Loop up"; 1536 return "Line Loop up";
1537 case 0x1C: 1537 case 0x1C:
1538 return "Line Loop down"; 1538 return "Line Loop down";
1539 case 0x0A: 1539 case 0x0A:
1540 return "Payload Loop up"; 1540 return "Payload Loop up";
1541 case 0x19: 1541 case 0x19:
1542 return "Payload Loop down"; 1542 return "Payload Loop down";
@@ -1595,29 +1595,29 @@ void print_t1_test_pattern(int patt) @@ -1595,29 +1595,29 @@ void print_t1_test_pattern(int patt)
1595 break; 1595 break;
1596 case 13: 1596 case 13:
1597 printf("framed X^15+X^14+1 w/7ZS\n"); 1597 printf("framed X^15+X^14+1 w/7ZS\n");
1598 break; 1598 break;
1599 case 14: 1599 case 14:
1600 printf("framed X^20+X^17+1 w/14ZS (QRSS)\n"); 1600 printf("framed X^20+X^17+1 w/14ZS (QRSS)\n");
1601 break; 1601 break;
1602 case 15: 1602 case 15:
1603 printf("framed X^23+X^18+1 w/14ZS\n"); 1603 printf("framed X^23+X^18+1 w/14ZS\n");
1604 break; 1604 break;
1605 } 1605 }
1606 } 1606 }
1607 1607
1608void print_t1_far_report(int index) 1608void print_t1_far_report(int idx)
1609 { 1609 {
1610 u_int16_t far = status.snmp.t1.prm[index]; 1610 u_int16_t far = status.snmp.t1.prm[idx];
1611 1611
1612 printf(" SEQ=%d ", (far & T1PRM_SEQ)>>8); 1612 printf(" SEQ=%d ", (far & T1PRM_SEQ)>>8);
1613 if (far & T1PRM_G1) printf("CRC=1"); 1613 if (far & T1PRM_G1) printf("CRC=1");
1614 else if (far & T1PRM_G2) printf("CRC=1 to 5"); 1614 else if (far & T1PRM_G2) printf("CRC=1 to 5");
1615 else if (far & T1PRM_G3) printf("CRC=5 to 10"); 1615 else if (far & T1PRM_G3) printf("CRC=5 to 10");
1616 else if (far & T1PRM_G4) printf("CRC=10 to 100"); 1616 else if (far & T1PRM_G4) printf("CRC=10 to 100");
1617 else if (far & T1PRM_G5) printf("CRC=100 to 319"); 1617 else if (far & T1PRM_G5) printf("CRC=100 to 319");
1618 else if (far & T1PRM_G6) printf("CRC>=320"); 1618 else if (far & T1PRM_G6) printf("CRC>=320");
1619 else printf("CRC=0"); 1619 else printf("CRC=0");
1620 printf(" SE=%d", (far & T1PRM_SE) ? 1 : 0); 1620 printf(" SE=%d", (far & T1PRM_SE) ? 1 : 0);
1621 printf(" FE=%d", (far & T1PRM_FE) ? 1 : 0); 1621 printf(" FE=%d", (far & T1PRM_FE) ? 1 : 0);
1622 printf(" LV=%d", (far & T1PRM_LV) ? 1 : 0); 1622 printf(" LV=%d", (far & T1PRM_LV) ? 1 : 0);
1623 printf(" SL=%d", (far & T1PRM_SL) ? 1 : 0); 1623 printf(" SL=%d", (far & T1PRM_SL) ? 1 : 0);
@@ -1731,27 +1731,27 @@ void print_t1_dsu() @@ -1731,27 +1731,27 @@ void print_t1_dsu()
1731 if (config.format == CFG_FORMAT_T1ESF) 1731 if (config.format == CFG_FORMAT_T1ESF)
1732 { 1732 {
1733 if ((bop = read_framer(Bt8370_TBOP))) 1733 if ((bop = read_framer(Bt8370_TBOP)))
1734 printf("Last Tx BOP msg:\t0x%02X (%s)\n", bop, print_t1_bop(bop)); 1734 printf("Last Tx BOP msg:\t0x%02X (%s)\n", bop, print_t1_bop(bop));
1735 if ((bop = read_framer(Bt8370_RBOP))) 1735 if ((bop = read_framer(Bt8370_RBOP)))
1736 printf("Last Rx BOP msg:\t0x%02X (%s)\n", bop, print_t1_bop(bop&0x3F)); 1736 printf("Last Rx BOP msg:\t0x%02X (%s)\n", bop, print_t1_bop(bop&0x3F));
1737 } 1737 }
1738 print_t1_snmp(); 1738 print_t1_snmp();
1739 } 1739 }
1740 1740
1741void t1_cmd(int argc, char **argv) 1741void t1_cmd(int argc, char **argv)
1742 { 1742 {
1743 int ch; 1743 int ch;
1744 char *optstring = "a:A:B:c:de:E:fF:g:iIlLpPstT:u:U:xX"; 1744 const char *optstring = "a:A:B:c:de:E:fF:g:iIlLpPstT:u:U:xX";
1745 1745
1746 while ((ch = getopt(argc, argv, optstring)) != -1) 1746 while ((ch = getopt(argc, argv, optstring)) != -1)
1747 { 1747 {
1748 switch (ch) 1748 switch (ch)
1749 { 1749 {
1750 case 'a': /* stop alarms */ 1750 case 'a': /* stop alarms */
1751 { 1751 {
1752 switch (optarg[0]) 1752 switch (optarg[0])
1753 { 1753 {
1754 case 'y': /* Stop sending Yellow Alarm */ 1754 case 'y': /* Stop sending Yellow Alarm */
1755 { 1755 {
1756 if ((config.format == CFG_FORMAT_T1SF) || 1756 if ((config.format == CFG_FORMAT_T1SF) ||
1757 (config.format == CFG_FORMAT_E1NONE)) 1757 (config.format == CFG_FORMAT_E1NONE))
@@ -2130,27 +2130,27 @@ u_int8_t crc8(u_int16_t *bufp, int len) @@ -2130,27 +2130,27 @@ u_int8_t crc8(u_int16_t *bufp, int len)
2130 2130
2131 for (i = 0; i < len; i++) 2131 for (i = 0; i < len; i++)
2132 for (data = *bufp++, bit = 15; bit >= 0; bit--) 2132 for (data = *bufp++, bit = 15; bit >= 0; bit--)
2133 { 2133 {
2134 if ((i==8) && (bit==7)) break; 2134 if ((i==8) && (bit==7)) break;
2135 crc = (crc << 1) ^ ((((crc >> 7) ^ (data >> bit)) & 1) ? poly : 0); 2135 crc = (crc << 1) ^ ((((crc >> 7) ^ (data >> bit)) & 1) ? poly : 0);
2136 } 2136 }
2137 return crc; 2137 return crc;
2138 } 2138 }
2139 2139
2140void main_cmd(int argc, char **argv) 2140void main_cmd(int argc, char **argv)
2141 { 2141 {
2142 int ch; 2142 int ch;
2143 char *optstring = "13a:bBcCdDeEf:gG:hi:L:mM:pP:sS:tT:uUvVw:x:X:yY?"; 2143 const char *optstring = "13a:bBcCdDeEf:gG:hi:L:mM:pP:sS:tT:uUvVw:x:X:yY?";
2144 2144
2145 while ((ch = getopt(argc, argv, optstring)) != -1) 2145 while ((ch = getopt(argc, argv, optstring)) != -1)
2146 { 2146 {
2147 switch (ch) 2147 switch (ch)
2148 { 2148 {
2149 case '1': /* T1 commands */ 2149 case '1': /* T1 commands */
2150 { 2150 {
2151 if (verbose) printf("Doing T1 settings\n"); 2151 if (verbose) printf("Doing T1 settings\n");
2152 if (status.card_type != CSID_LMC_T1E1) 2152 if (status.card_type != CSID_LMC_T1E1)
2153 { 2153 {
2154 printf("T1 settings only apply to T1E1 cards\n"); 2154 printf("T1 settings only apply to T1E1 cards\n");
2155 exit(1); 2155 exit(1);
2156 } 2156 }