/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Initialize and re-initialize synchronous serial clocking and loopback
* options. Interfaces through the S_IOCGETMODE and S_IOCSETMODE ioctls.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ser_sync.h>
#include <libdlpi.h>
static void usage(void);
static char *yesno[] = {
"no",
"yes",
"silent",
0,
};
static char *txnames[] = {
"txc",
"rxc",
"baud",
"pll",
"sysclk",
"-txc",
0,
};
static char *rxnames[] = {
"rxc",
"txc",
"baud",
"pll",
"sysclk",
"-rxc",
0,
};
#ifdef notdef
static char *txdnames[] = {
"txd",
" ", /* dummy entry, do not remove */
"-txd",
0,
};
static char *rxdnames[] = {
"rxd",
"-rxd",
0,
};
static char *portab[] = {
"rs422",
"v35",
0,
};
#endif
int
{
int retval;
char loopchange = 0;
char echochange = 0;
char clockchange = 0;
if (argc == 1) {
usage();
exit(1);
}
argc--;
argv++;
sizeof (cnambuf)) {
"syncinit: invalid device name (too long) %s\n", argv[0]);
exit(1);
}
while (*cp) /* find the end of the name */
cp++;
cp--;
"syncinit: %s missing minor device number\n", cnambuf);
exit(1);
}
if (retval != DLPI_SUCCESS) {
exit(1);
}
argc--;
argv++;
if (argc) { /* setting things */
perror("S_IOCGETMODE");
"syncinit: can't get sync mode info for %s\n",
cnambuf);
exit(1);
}
while (argc-- > 0) {
else
loopchange++;
else
echochange++;
else
clockchange++;
clockchange++;
} else
"syncinit: %s %s\n",
"bad speed:", arg);
}
sm.sm_baudrate = 0;
} else
}
/*
* If we're going to change the state of loopback, and we
* don't have our own plans for clock sources, use defaults.
*/
if (loopchange && !clockchange) {
} else {
}
}
perror("S_IOCSETMODE");
"syncinit: ioctl failure code = %x\n",
exit(1);
}
}
/* Report State */
perror("S_IOCGETMODE");
"syncinit: can't get sync mode info for %s\n",
cnambuf);
exit(1);
}
(void) printf(
"speed=%d, loopback=%s, echo=%s, nrzi=%s, txc=%s, rxc=%s\n",
return (0);
}
static void
usage()
{
exit(1);
}
static int
{
}
static int
{
int ival;
return (ival);
exit(1);
/* NOTREACHED */
}