Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/lmcctl Add lmcctl, to configure lmc driver. Reason it ...



details:   https://anonhg.NetBSD.org/src/rev/d813707c7b33
branches:  trunk
changeset: 467476:d813707c7b33
user:      explorer <explorer%NetBSD.org@localhost>
date:      Thu Mar 25 04:05:36 1999 +0000

description:
Add lmcctl, to configure lmc driver.  Reason it belongs in /sbin is that
it might need to be run before /usr is mounted.

diffstat:

 sbin/lmcctl/Makefile   |    9 +
 sbin/lmcctl/clockgen.c |  123 ++++++++++++++++
 sbin/lmcctl/extern.h   |   39 +++++
 sbin/lmcctl/lmcctl.c   |  373 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 544 insertions(+), 0 deletions(-)

diffs (truncated from 560 to 300 lines):

diff -r cc43652b335f -r d813707c7b33 sbin/lmcctl/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/lmcctl/Makefile      Thu Mar 25 04:05:36 1999 +0000
@@ -0,0 +1,9 @@
+#      $NetBSD: Makefile,v 1.1 1999/03/25 04:05:36 explorer Exp $
+
+PROG=  lmcctl
+SRCS=  lmcctl.c clockgen.c
+NOMAN= lmcctl.8
+BINOWN=        root
+BINMODE=555
+
+.include <bsd.prog.mk>
diff -r cc43652b335f -r d813707c7b33 sbin/lmcctl/clockgen.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/lmcctl/clockgen.c    Thu Mar 25 04:05:36 1999 +0000
@@ -0,0 +1,123 @@
+/*     $NetBSD: clockgen.c,v 1.1 1999/03/25 04:05:37 explorer Exp $    */
+
+/*-
+ * Copyright (c) 1997-1999 LAN Media Corporation (LMC)
+ * All rights reserved.  www.lanmedia.com
+ *
+ * This code is written by Michael Graff <graff%vix.com@localhost> for LMC.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following disclaimer
+ *    in the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. All marketing or advertising materials mentioning features or
+ *    use of this software must display the following acknowledgement:
+ *      This product includes software developed by LAN Media Corporation
+ *      and its contributors.
+ * 4. Neither the name of LAN Media Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY LAN MEDIA CORPORATION AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+
+#include <dev/pci/if_lmc_types.h>
+#include <dev/pci/if_lmcioctl.h>
+
+#include "extern.h"
+
+#define T1_FREF  20000000
+#define T1_FMIN  30000000
+#define T1_FMAX 330000000
+
+void
+lmc_av9110_freq(u_int32_t target, lmc_av9110_t *av)
+{
+       unsigned int n, m, v, x, r;
+       unsigned long f;
+       unsigned long iFvco;
+
+       av->n = 0;
+       av->m = 0;
+       av->v = 0;
+       av->x = 0;
+       av->r = 0;
+       av->f = 0;
+       av->exact = 0;
+
+       target *= 16;
+
+       for (n = 3 ; n <= 127 ; n++)
+               for (m = 3 ; m <= 127 ; m++)
+                       for (v = 1 ; v <= 8 ; v *= 8)
+                               for (x = 1 ; x <= 8 ; x <<= 1)
+                                       for (r = 1 ; r <= 8 ; r <<= 1) {
+                                               iFvco = (T1_FREF / m) * n * v;
+                                               if (iFvco < T1_FMIN || iFvco > T1_FMAX)
+                                                       continue;
+                                               f = iFvco / (x * r);
+                                               if (f >= target)
+                                                       if ((av->f == 0) || (f - target < av->f - target)) {
+                                               
+                                                       av->n = n;
+                                                       av->m = m;
+                                                       if (v == 1)
+                                                               av->v = 0;
+                                                       else
+                                                               av->v = 1;
+                                                       if (x == 1)
+                                                               av->x = 0;
+                                                       else if (x == 2)
+                                                               av->x = 1;
+                                                       else if (x == 4)
+                                                               av->x = 2;
+                                                       else if (x == 8)
+                                                               av->x = 3;
+                                                       if (r == 1)
+                                                               av->r = 0;
+                                                       else if (r == 2)
+                                                               av->r = 1;
+                                                       else if (r == 4)
+                                                               av->r = 2;
+                                                       else if (r == 8)
+                                                               av->r = 3;
+                                                       av->f = f;
+                                                       if (f == target) {
+                                                               av->exact = 1;
+                                                               av->f /= 16;
+                                                               return;
+                                                       }
+                                               }
+                                       }
+       av->f /= 16;
+}
+
diff -r cc43652b335f -r d813707c7b33 sbin/lmcctl/extern.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/lmcctl/extern.h      Thu Mar 25 04:05:36 1999 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: extern.h,v 1.1 1999/03/25 04:05:37 explorer Exp $      */
+
+/*-
+ * Copyright (c) 1997-1999 LAN Media Corporation (LMC)
+ * All rights reserved.  www.lanmedia.com
+ *
+ * This code is written by Michael Graff <graff%vix.com@localhost> for LMC.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following disclaimer
+ *    in the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. All marketing or advertising materials mentioning features or
+ *    use of this software must display the following acknowledgement:
+ *      This product includes software developed by LAN Media Corporation
+ *      and its contributors.
+ * 4. Neither the name of LAN Media Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY LAN MEDIA CORPORATION AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void lmc_av9110_freq(u_int32_t target, lmc_av9110_t *av);
diff -r cc43652b335f -r d813707c7b33 sbin/lmcctl/lmcctl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/lmcctl/lmcctl.c      Thu Mar 25 04:05:36 1999 +0000
@@ -0,0 +1,373 @@
+/*     $NetBSD: lmcctl.c,v 1.1 1999/03/25 04:05:37 explorer Exp $      */
+
+/*-
+ * Copyright (c) 1997-1999 LAN Media Corporation (LMC)
+ * All rights reserved.  www.lanmedia.com
+ *
+ * This code is written by Michael Graff <graff%vix.com@localhost> for LMC.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following disclaimer
+ *    in the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. All marketing or advertising materials mentioning features or
+ *    use of this software must display the following acknowledgement:
+ *      This product includes software developed by LAN Media Corporation
+ *      and its contributors.
+ * 4. Neither the name of LAN Media Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY LAN MEDIA CORPORATION AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+
+#include <dev/pci/if_lmc_types.h>
+#include <dev/pci/if_lmcioctl.h>
+
+#include "extern.h"
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+void lmc_av9110_freq(u_int32_t, lmc_av9110_t *);
+static void dumpdata(char *, lmc_ctl_t *);
+
+void usage(char *);
+
+#define DEFAULT_INTERFACE "lmc0"
+
+void
+usage(char *s)
+{
+       fprintf(stderr,
+               "Usage: %s [-i interface] [-l speed] [-cCeEsKkSoO]\n", s);
+       fprintf(stderr,
+               "\tinterface is the interface name, default '%s'\n",
+               DEFAULT_INTERFACE);
+       fprintf(stderr, "\t-l sets line speed [T1]\n");
+       fprintf(stderr, "\t-c sets external clock source [T1, HSSI]\n");
+       fprintf(stderr, "\t-C sets internal clock source [T1, HSSI]\n");
+       fprintf(stderr, "\t-e selects 16 bit CRC\n");
+       fprintf(stderr, "\t-E selects 32 bit CRC\n");
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+       fprintf(stderr, "\t-k enables Cisco HDLC keepalive protocol\n");
+       fprintf(stderr, "\t-K disables Cisco HDLC keepalive protocol\n");
+#endif
+       fprintf(stderr, "\t-s turns DS3 scrambler off [DS3]\n");
+       fprintf(stderr, "\t-S turns DS3 scrambler on [DS3]\n");
+       fprintf(stderr, "\t-o sets DS3 cable length < 100 feet [DS3]\n");
+       fprintf(stderr, "\t-O sets DS3 cable length > 100 feet [DS3]\n");
+}
+
+int
+main(int argc, char **argv)
+{
+       lmc_ctl_t       ctl;
+       int             fd;
+       struct ifreq    ifr;
+       int             ch;
+       char           *ifname = DEFAULT_INTERFACE;
+       lmc_ctl_t       wanted;
+       int             flag_c; /* clock source external, internal */
+       int             flag_l; /* line speed */
+       int             flag_s; /* Scrambler on, off */
+       int             flag_o; /* cable length < 100, > 100 */
+       int             flag_e; /* crc 16, 32 */
+       int             flag_k; /* HDLC keepalive */
+       int             just_print;
+
+       flag_c = 0;
+       flag_l = 0;
+       flag_s = 0;
+       flag_o = 0;
+       flag_e = 0;
+       flag_k = 0;



Home | Main Index | Thread Index | Old Index