home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
7000-7999
/
7541
< prev
next >
Wrap
Internet Message Format
|
1993-03-16
|
52KB
Path: wupost!howland.reston.ans.net!bogus.sura.net!darwin.sura.net!sgiblab!bazooka!ti
From: ti@bazooka.amb.org (Ti Kan)
Newsgroups: alt.sources
Subject: Cyrix 486DLC/SLC internal cache UNIX SVR3/SVR4 driver
Keywords: Cyrix 486 DLC SLC cache UNIX SVR3 SVR4 driver
Message-ID: <1294@bazooka.amb.org>
Date: 16 Mar 93 06:41:55 GMT
Reply-To: ti@bazooka.amb.org (Ti Kan)
Organization: AMB Research Labs, Sunnyvale, CA.
Lines: 2072
UNIX(tm) System V/386 software to control the Cyrix(tm)
Cx486DLC/SLC CPU internal cache
by Ti Kan
-------------------------------------------------------------------
INTRODUCTION
This package includes all the source code components of the
following:
1. A device driver (cx) for UNIX SVR3.2 and SVR4 for detecting a
Cyrix Cx486DLC or Cx486SLC microprocessor, and enabling/disabling
the on-chip internal cache memory, as well as configuring
the cache-control option registers.
2. A utility (cxctl) that allows a super-user to change the Cyrix
Cx486DLC/SLC microprocessor internal cache configuration
"on-the-fly".
I have compiled and tested this package on the following platforms:
USL UNIX System V/386 Release 4.2 (Destiny) version 1
SCO UNIX System V/386 Release 3.2 version 2.0
SCO UNIX System V/386 Release 3.2 version 4.0
Since this software was specifically written to be portable, I
believe that it will compile and function correctly under other
UNIX System V/386 environments, such as ISC SVR3.2/SVR4, Dell SVR4,
etc. If you have successfully build and used this software on a
platform not listed above please inform me so that I can add to
the list. If you have to make modifications to make it run on
a particular platform I would appreciate if you can send me the
changes so I can incorporate it into a future release.
This software can be loaded on a non-Cyrix 386/486 system and it
should have no adverse effects (See below).
UNPACKING INSTRUCTIONS
1. Make a directory named "cx" in which these source files are to
reside, and change to this directory.
2. Save the distribution shar-format file as "cx.shar".
3. Run the following command:
sh cx.shar
This will unbundle the package into the individual files.
BUILD/INSTALL/USE INSTRUCTIONS
Read the README.src file after unpacking the distribution.
BINARY DISTRIBUTION
Binaries for SCO UNIX 3.2v2/3.2v4, as well as all current
flavors of SVR4.2 (USL, Consensys, Univel UnixWare) are available
for download at File Area 3 on the Bazooka BBS. This source
distribution, as well as an MS-DOS driver for the Cyrix Cx486DLC/SLC
CPU are also available on Bazooka BBS.
Bazooka BBS:
+1 408 736 0118 (Hayes V-Series Ultra V.32/V.32bis/V.42/V.42bis)
+1 408 736 3071 (Telebit Worldblazer TPEP/PEP/V.32/V.32bis/V.42/V.42bis)
Log in as "bbs". You will have access to the File Area 3 on your
first call. If you only need to download the Cyrix driver files
and have no intention of otherwise using Bazooka BBS again, please
leave a note to the Sysop stating so when logging out.
----------------X cut here X-----------------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: COPYRIGHT MANIFEST Makefile Master.ver0 Master.ver1 Node
# README.src Space.c System.ver0 System.ver1 cx.c cx.h cx_ml.s
# cxctl.c cxinstall.sh
# Wrapped by ti@bazooka on Mon Mar 15 22:22:07 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'COPYRIGHT'\"
else
echo shar: Extracting \"'COPYRIGHT'\" \(626 characters\)
sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
X#ident "@(#)COPYRIGHT 1.5 93/03/14"
X/*
X * cx UNIX(tm) System V/386 driver to control the Cyrix(tm)
X * Cx486DLC/SLC CPU internal cache.
X *
X * by Ti Kan
X * E-mail: Internet: ti@amb.org
X * UUCP: ...!decwrl!sgiblab!bazooka!ti
X * ...!uunet!bazooka!ti
X *
X * Copyright (c) Ti Kan 1993, All rights reserved.
X *
X * This software can be distributed freely. This software,
X * and software based on or that uses code from it cannot
X * be used for commercial purposes without consent of the
X * copyright holder. This copyright notice must appear in
X * all products that is based on or uses code from this
X * software.
X */
X
END_OF_FILE
if test 626 -ne `wc -c <'COPYRIGHT'`; then
echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
fi
# end of 'COPYRIGHT'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(778 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X/* @(#)MANIFEST 1.2 93/03/15 */
X
XThis source distribution of CX version 1.1 should include the following:
X
XCOPYRIGHT Copyright banner
XMANIFEST This file
XMakefile Makefile to build the source release
XMaster.ver0 Driver Software Package component for SVR3.2 and SVR4.0
XMaster.ver1 Driver Software Package component for SVR4.2
XNode Driver Software Package component
XREADME.src Build and install instructions
XSpace.c Driver Software Package component
XSystem.ver0 Driver Software Package component for SVR3.2 and SVR4.0
XSystem.ver1 Driver Software Package component for SVR4.2
Xcx.c Driver source file
Xcx.h Driver source file
Xcx_ml.s Driver source file
Xcxctl.c Utility source file
Xcxinstall.sh Install shell script
X
XYou must have all these files in order to build the package.
X
END_OF_FILE
if test 778 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(2426 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#ident "@(#)Makefile 1.10 93/03/14"
X#
X# Makefile UNIX(tm) System V/386 driver to control the Cyrix(tm)
X# Cx486DLC/SLC CPU internal cache.
X#
X# by Ti Kan
X# E-mail: Internet: ti@amb.org
X# UUCP: ...!decwrl!sgiblab!bazooka!ti
X# ...!uunet!bazooka!ti
X#
X# Copyright (c) Ti Kan 1993, All rights reserved.
X#
X# This software can be distributed freely. This software,
X# and software based on or that uses code from it cannot
X# be used for commercial purposes without consent of the
X# copyright holder. This copyright notice must appear in
X# all products that is based on or uses code from this
X# software.
X#
X
X#
X# All but one of the following ARCH lines should be commented-out.
X#
XARCH = -DSVR3 -Dsco # For SCO UNIX SVR3.2
X#ARCH = -DSVR3 # For other UNIX SVR3.2
X#ARCH = -DSVR4 # For most variants of SVR4
X
X#
X# Uncomment the following for debugging purposes: causes debug output on
X# the console, and makes static references global (So debuggers can
X# do reasonable things).
X#
X#DEBUG = -DDEBUG -g
X
X#
X# Uncomment the following to disallow changes to cache settings
X# which can potentially cause a system crash.
X#
X#PARANOID = -DPARANOID
X
X#
X# Other definitions
X#
XCC = cc
X#CC = gcc -fpcc-struct-return
XLD = ld
XMCS = mcs
XLN = ln -f
XRM = rm -f
XSHELL = /bin/sh
X
X#
X# No modifications should be necessary below here
X#
XVERS = 1.1
XSRC = cx.c cx_ml.s
XOBJ = cx.o cx_ml.o
XDRIVER = Driver.o
XUSRC = cxctl.c
XUTIL = cxctl
XIDFILES = Driver.o Space.c Master.ver0 Master.ver1 System.ver0 System.ver1 Node
XRELDIR = cxrelease
X
XCFLAGS = -O -I. -DVERS=\"$(VERS)\" $(DEBUG) $(PARANOID) $(ARCH)
XLDFLAGS = -r
X
Xall: $(DRIVER) $(UTIL)
X
Xcx.o: cx.c
X @if [ ! -d sys ] ;\
X then \
X mkdir sys ;\
X fi
X @$(RM) sys/cx.h
X @$(LN) cx.h sys/cx.h
X $(CC) $(CFLAGS) -D_INKERNEL -c $<
X
Xcx_ml.o: cx_ml.s
X $(CC) $(CFLAGS) -D_INKERNEL -c $<
X
X$(DRIVER): $(OBJ)
X $(LD) $(LDFLAGS) $(OBJ) -o $@
X $(MCS) -da "@(#)cx v$(VERS) `date +%D` (c) Ti Kan 1993" $@
X
X$(UTIL): $(USRC)
X $(CC) $(CFLAGS) -o $@ $(USRC)
X $(MCS) -da "@(#)cxctl v$(VERS) `date +%D` (c) Ti Kan 1993" $@
X
Xclean:
X rm -rf $(OBJ) $(DRIVER) $(UTIL) sys
X
Xdelete: clean
X rm -rf $(RELDIR)
X
Xrelease: all
X @if [ ! -d $(RELDIR) ] ;\
X then \
X mkdir $(RELDIR) ;\
X fi
X @if [ ! -d $(RELDIR)/cx ] ;\
X then \
X mkdir $(RELDIR)/cx ;\
X fi
X rm -f $(RELDIR)/cx/* $(RELDIR)/cxctl $(RELDIR)/cx.h
X cp $(IDFILES) $(RELDIR)/cx
X cp $(UTIL) $(RELDIR)
X cp cx.h $(RELDIR)
X cp cxinstall.sh $(RELDIR)/cxinstall
X chmod 755 $(RELDIR)/cxinstall
X
END_OF_FILE
if test 2426 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'Master.ver0' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Master.ver0'\"
else
echo shar: Extracting \"'Master.ver0'\" \(26 characters\)
sed "s/^X//" >'Master.ver0' <<'END_OF_FILE'
Xcx Ii Hico cx_ 0 0 0 1 -1
END_OF_FILE
if test 26 -ne `wc -c <'Master.ver0'`; then
echo shar: \"'Master.ver0'\" unpacked with wrong size!
fi
# end of 'Master.ver0'
fi
if test -f 'Master.ver1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Master.ver1'\"
else
echo shar: Extracting \"'Master.ver1'\" \(85 characters\)
sed "s/^X//" >'Master.ver1' <<'END_OF_FILE'
X#ident "@(#)Master.ver1 1.2 93/03/14"
X$version 1
X$entry init ioctl
Xcx cx_ Hico 1 0 0
END_OF_FILE
if test 85 -ne `wc -c <'Master.ver1'`; then
echo shar: \"'Master.ver1'\" unpacked with wrong size!
fi
# end of 'Master.ver1'
fi
if test -f 'Node' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Node'\"
else
echo shar: Extracting \"'Node'\" \(10 characters\)
sed "s/^X//" >'Node' <<'END_OF_FILE'
Xcx cx c 0
END_OF_FILE
if test 10 -ne `wc -c <'Node'`; then
echo shar: \"'Node'\" unpacked with wrong size!
fi
# end of 'Node'
fi
if test -f 'README.src' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README.src'\"
else
echo shar: Extracting \"'README.src'\" \(7064 characters\)
sed "s/^X//" >'README.src' <<'END_OF_FILE'
X/* @(#)README.src 1.3 93/03/15 */
X
XUNIX(tm) System V/386 software to control the Cyrix(tm)
XCx486DLC/SLC CPU internal cache
X
Xby Ti Kan
X-------------------------------------------------------------------
X
XINTRODUCTION
X
XThis package includes all the source code components of the
Xfollowing:
X1. A device driver (cx) for UNIX SVR3.2 and SVR4 for detecting a
X Cyrix Cx486DLC or Cx486SLC microprocessor, and enabling/disabling
X the on-chip internal cache memory, as well as configuring
X the cache-control option registers.
X2. A utility (cxctl) that allows a super-user to change the Cyrix
X Cx486DLC/SLC microprocessor internal cache configuration
X "on-the-fly".
X
XSee the "MANIFEST" file, which should be included in this distribution
Xfor a list of all files in the package.
X
XI have compiled and tested this package on the following platforms:
X
XUSL UNIX System V/386 Release 4.2 (Destiny) version 1
XSCO UNIX System V/386 Release 3.2 version 2.0
XSCO UNIX System V/386 Release 3.2 version 4.0
X
XSince this software was specifically written to be portable, I
Xbelieve that it will compile and function correctly under other
XUNIX System V/386 environments, such as ISC SVR3.2/SVR4, Dell SVR4,
Xetc. If you have successfully build and used this software on a
Xplatform not listed above please inform me so that I can add to
Xthe list. If you have to make modifications to make it run on
Xa particular platform I would appreciate if you can send me the
Xchanges so I can incorporate it into a future release.
X
XThis software can be loaded on a non-Cyrix 386/486 system and it
Xshould have no adverse effects (See below).
X
X
XUNPACKING INSTRUCTIONS
X
XIf your distribution is bundled in "shar" format, use the following
Xsteps:
X
X1. Make a directory named "cx" in which these source files are to
X reside, and change to this directory.
X2. Save the distribution shar-format file as "cx.shar".
X3. Run the following command:
X
X sh cx.shar
X
X This will unbundle the package into the individual files.
X
XIf your distribution is bundled in compressed tar file format, use the
Xthe following steps:
X
X1. Make a directory named "cx" in which these source files are to
X reside, and change to this directory.
X2. Save the distribution compressed-tar-format file as "cx.tar.Z".
X3. Run the following command:
X
X uncompress cx.tar.Z
X tar xvf cx.tar
X
X This will unbundle the package into the individual files.
X
X
XBUILD INSTRUCTIONS
X
XYou must have the C software development package installed on your
Xoperating system in order to compile these sources. Some of the
Xsource code in this package are in assembly language with as(1)
Xsyntax. Thus, your development package must be able to handle this.
XThe target system where the binaries are to be loaded must have the
Xkernel rebuild package installed (under /etc/conf). SCO calls this
Xenvironment the "Link Kit".
X
XYou can compile the sources as a non-privileged user, but you must
Xbe the super-user on the target system to install it.
X
X1. Edit the Makefile and change the lines with "ARCH=", "CC=" and
X "PARANOID=" to suit your local environment. See the comments in
X the Makefile for details.
X
X2. Type "make". This should compile the source code and generate the
X "Driver.o" device driver binary as well as the "cxctl" utility
X executable binary.
X
X3. Type "make release" to copy all relevant release files to the
X cxrelease directory.
X
X4. Make a tar format diskette of the cxrelease directory, and
X install target systems with it:
X
X tar cvf /dev/rfd0 cxrelease
X
X Replace "/dev/rfd0" with the appropriate floppy device on your system.
X
X Note: This diskette can only be used to install another system running
X the same operating system as the one you compiled the source code
X on.
X
X5. You may also make a tar format file, compressed and uuencoded, suitable
X for transmission over electronic mail:
X
X tar cvf cx.tar cxrelease
X compress cx.tar
X uuencode cx.tar.Z cx.tar.Z > cx.uue
X
X "cx.uue" is the distribution file.
X
X
XINSTALL INSTRUCTIONS
X
X1. If your distribution is on a tar format floppy diskette (created using
X the BUILD INSTRUCTIONS above), on the target system, extract the
X diskette as follows:
X
X cd /tmp
X tar xvf /dev/rfd0
X
X Replace "/dev/rfd0" with the appropriate floppy device on your system.
X
X2. If the distrbution is in a uuencoded and compressed tar format file,
X unpack the distribution as follows (assuming that the distrbution file
X is named "cx.uue"):
X
X mv cx.uue /tmp
X cd /tmp
X uudecode cx.uue
X uncompress cx.tar.Z
X tar xvf cx.tar
X
X3. Run the software installation script:
X
X cd /tmp/cxrelease
X ./cxinstall
X
X4. You can clean up the directories after installation:
X
X cd /tmp
X rm -rf cxrelease
X
X
XUSE INSTRUCTIONS
X
XAfter installation, rebuilding the kernel, and rebooting the system, the
XCX driver will attempt to detect a Cx486DLC/SLC processor when the UNIX
Xkernel is initialized. If a Cx486DLC/SLC chip is found, then its internal
Xcache will be enabled by default, with the 640K-1M physical address region
Xmade non-cacheable (this region is normally used as I/O space by controller
Xboards on the PC architecture and should be non-cacheable).
X
XThe Cx486DLC/SLC internal cache can be disabled, or many of the cache
Xconfiguration parameters can be modified at run time with the cxctl
Xutility. The utility is menu-driven and self-explanatory. The function
Xof most of these parameters require knowledge of the internal design of
Xthe Cx486DLC/SLC chip.
X
XWARNING: changing some of these parameters may cause a system
Xcrash due to cache incoherency or DMA problems. The default setting
Xshould work fine for most systems and changing the parameters is not
Xrecommended. Modifying these paramters should only be done on an
Xexperimental basis by a knowledgeable individual, on a system in
Xsingle-user mode.
X
X
XCOPYRIGHT
X
XCopyright (C) 1993 Ti Kan. All rights reserved.
XThis software can be distributed freely. This software, and software
Xbased on or that uses code from it cannot be used for commercial purposes
Xwithout consent of the copyright holder. This copyright notice must
Xappear in all products that is based on or uses code from this software.
X
X
XWARRANTY
X
XThere is no warranty provided by the author for the usefulness or
Xsuitability of purpose. These is also no warranty provided for any
Xconsequences as a result of the use or misuse of this software.
XThis software is in no way associated with Cyrix Corporation, and
XCyrix cannot be responsible for any support.
X
XIf you find a problem with this package your feedback to the author
Xwill be apprciated. Please provide a detailed description of the
Xproblem, as well as the hardware and software configuration. If the
Xproblem can be traceable to a bug in the software provided in this
Xpackage, the author will attempt to provide a fix in a future release.
X
X
XACKNOWLEGEMENTS
X
XUNIX and USL are registered trademarks of UNIX System Laboratories
XCyrix is a registered trademark of Cyrix Corporation
XSCO is a registered trademark of The Santa Cruz Operation, Inc.
XISC is a trademark of Sunsoft, Inc.
XDell is a trademark of Dell Coporation.
X
END_OF_FILE
if test 7064 -ne `wc -c <'README.src'`; then
echo shar: \"'README.src'\" unpacked with wrong size!
fi
# end of 'README.src'
fi
if test -f 'Space.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Space.c'\"
else
echo shar: Extracting \"'Space.c'\" \(1518 characters\)
sed "s/^X//" >'Space.c' <<'END_OF_FILE'
X/*
X * Space.c UNIX(tm) System V/386 driver to control the Cyrix(tm)
X * Cx486DLC/SLC CPU internal cache.
X *
X * by Ti Kan
X * E-mail: Internet: ti@amb.org
X * UUCP: ...!decwrl!sgiblab!bazooka!ti
X * ...!uunet!bazooka!ti
X *
X * Copyright (c) Ti Kan 1993, All rights reserved.
X *
X * This software can be distributed freely. This software,
X * and software based on or that uses code from it cannot
X * be used for commercial purposes without consent of the
X * copyright holder. This copyright notice must appear in
X * all products that is based on or uses code from this
X * software.
X */
X#ident "@(#)Space.c 1.9 93/03/14"
X
X#include "sys/types.h"
X#include "sys/cx.h"
X#include "config.h"
X
X/* Cache control register I/O port address base */
Xint cx_base = 0x22;
X
X/* Default cache control parameters - see <sys/cx.h> */
Xcxparms_t cx_dfltparms = {
X /*** Cache mode ***/
X {
X CX_ENABLE /* mode */
X },
X
X /*** Cache control register 0 ***/
X {
X 0, /* nc0 */
X 1, /* nc1 */
X 0, /* a20m */
X 0, /* ken */
X 0, /* flush */
X 1, /* barb */
X 0, /* co */
X 0 /* susp */
X },
X
X /*** Cache control register 1 ***/
X {
X 0, /* rpl */
X 0 /* reserved: must be 0 */
X },
X
X /*** Non-cacheable regions ***/
X {
X /* region 0 */
X {
X 0xa0000, /* addr */
X NCREG_128KB /* offset */
X },
X
X /* region 1 */
X {
X 0xc0000, /* addr */
X NCREG_256KB /* offset */
X },
X
X /* region 2 */
X {
X 0x0, /* addr */
X NCREG_DISABLE /* offset */
X },
X
X /* region 3 */
X {
X 0x0, /* addr */
X NCREG_DISABLE /* offset */
X }
X }
X};
X
END_OF_FILE
if test 1518 -ne `wc -c <'Space.c'`; then
echo shar: \"'Space.c'\" unpacked with wrong size!
fi
# end of 'Space.c'
fi
if test -f 'System.ver0' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'System.ver0'\"
else
echo shar: Extracting \"'System.ver0'\" \(21 characters\)
sed "s/^X//" >'System.ver0' <<'END_OF_FILE'
Xcx Y 1 0 0 0 0 0 0 0
END_OF_FILE
if test 21 -ne `wc -c <'System.ver0'`; then
echo shar: \"'System.ver0'\" unpacked with wrong size!
fi
# end of 'System.ver0'
fi
if test -f 'System.ver1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'System.ver1'\"
else
echo shar: Extracting \"'System.ver1'\" \(72 characters\)
sed "s/^X//" >'System.ver1' <<'END_OF_FILE'
X#ident "@(#)System.4_2 1.1 92/12/01"
X$version 1
Xcx Y 1 0 0 0 0 0 0 0 -1
END_OF_FILE
if test 72 -ne `wc -c <'System.ver1'`; then
echo shar: \"'System.ver1'\" unpacked with wrong size!
fi
# end of 'System.ver1'
fi
if test -f 'cx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cx.c'\"
else
echo shar: Extracting \"'cx.c'\" \(5731 characters\)
sed "s/^X//" >'cx.c' <<'END_OF_FILE'
X/*
X * cx.c UNIX(tm) System V/386 driver to control the Cyrix(tm)
X * Cx486DLC/SLC CPU internal cache.
X *
X * by Ti Kan
X * E-mail: Internet: ti@amb.org
X * UUCP: ...!decwrl!sgiblab!bazooka!ti
X * ...!uunet!bazooka!ti
X *
X * Copyright (c) Ti Kan 1993, All rights reserved.
X *
X * This software can be distributed freely. This software,
X * and software based on or that uses code from it cannot
X * be used for commercial purposes without consent of the
X * copyright holder. This copyright notice must appear in
X * all products that is based on or uses code from this
X * software.
X */
X#ident "@(#)cx.c 1.16 93/03/14"
X
X#include "sys/types.h"
X#include "sys/param.h"
X#include "sys/cmn_err.h"
X#include "sys/errno.h"
X#include "sys/dir.h"
X#include "sys/user.h"
X#ifdef SVR4
X#include "sys/cred.h"
X#include "sys/file.h"
X#include "sys/conf.h"
X#include "sys/ddi.h"
X#endif
X#include "sys/cx.h"
X
X#ifdef DEBUG
X#define STATIC
X#define DPRINTF(f,a) cmn_err(CE_NOTE,(f),(a))
X#else
X#define STATIC static
X#define DPRINTF(f,a)
X#endif
X
X#ifndef VERS
X#define VERS "undef"
X#endif
X
X#ifdef SVR4
Xint cx_devflag = 0; /* DDI/DKI compliance */
X#endif
X
Xextern void cx_i486cacheon(void),
X cx_i486cacheoff(void);
Xextern int cx_i486cachemode(void),
X cx_iscyrix(void);
X
Xextern int cx_base;
Xextern cxparms_t cx_dfltparms;
X
Xint cx_found = 0;
Xcxparms_t cx_savparms;
X
X
X/*
X * Internal Routines
X */
X
XSTATIC void
Xcx_setcachectl(cxparms_t *ctl_p)
X{
X int i;
X u_char *cp,
X buf0,
X buf1,
X buf2;
X
X /*
X * The following sets cache control attributes
X */
X
X /* Cache config register 0: C0 */
X cp = (u_char *) &ctl_p->reg0;
X outb(cx_base, 0xc0);
X outb(cx_base + 1, *cp);
X
X /* Cache config register 1: C1 */
X cp = (u_char *) &ctl_p->reg1;
X outb(cx_base, 0xc1);
X outb(cx_base + 1, *cp);
X
X /*
X * The following sets cacheable regions
X */
X
X for (i = 0; i < NNCREGS; i++) {
X buf0 = (ctl_p->noncache[i].addr >> 24) & 0xff;
X buf1 = (ctl_p->noncache[i].addr >> 16) & 0xff;
X buf2 = ((ctl_p->noncache[i].addr >> 8) & 0xf0) |
X (ctl_p->noncache[i].offset & 0x0f);
X
X /* registers C4, C7, CA, CD */
X outb(cx_base, 0xc4 + i);
X outb(cx_base + 1, buf0);
X
X /* registers C5, C8, CB, CE */
X outb(cx_base, 0xc5 + i);
X outb(cx_base + 1, buf1);
X
X /* registers C6, C9, CC, CF */
X outb(cx_base, 0xc6 + i);
X outb(cx_base + 1, buf2);
X }
X
X /* Save a copy of the current configuration */
X bcopy((caddr_t) ctl_p, (caddr_t) &cx_savparms, sizeof(cxparms_t));
X}
X
X
XSTATIC void
Xcx_getcachectl(cxparms_t *ctl_p)
X{
X u_char *cp,
X buf0,
X buf1,
X buf2;
X
X
X /* Set the parameters to the saved version */
X bcopy((caddr_t) &cx_savparms, (caddr_t) ctl_p, sizeof(cxparms_t));
X
X /*
X * The following gets cache control attributes. We rely on
X * the saved version of the noncacheable region parameters
X * because the C4-CF registers are write-only. We could just
X * use the saved parameters for everything else as well,
X * but why not query the hardware when we can?
X */
X
X /* Cache config register 0: C0 */
X cp = (u_char *) &ctl_p->reg0;
X outb(cx_base, 0xc0);
X *cp = inb(cx_base + 1);
X
X /* Cache config register 1: C1 */
X cp = (u_char *) &ctl_p->reg1;
X outb(cx_base, 0xc1);
X *cp = inb(cx_base + 1);
X
X /* Cache mode */
X ctl_p->mode = cx_i486cachemode();
X}
X
X
XSTATIC int
Xcx_do_ioctl(int cmd, void *arg, int priv)
X{
X int i, ospl;
X cxparms_t curparms,
X *cp;
X
X if (!cx_found)
X return(ENODEV);
X
X switch (cmd) {
X case CX_SETPARM:
X if (!priv)
X return(EPERM);
X
X /* Check parameters in the NC region for validity */
X cp = (cxparms_t *) arg;
X#ifdef PARANOID
X cx_getcachectl(&curparms);
X
X /* Changing these parameters on-the-fly will likely
X * be risky...
X */
X if (cp->reg0.co != curparms.reg0.co ||
X cp->reg0.a20m != curparms.reg0.a20m ||
X cp->reg0.ken != curparms.reg0.ken ||
X cp->reg0.flush != curparms.reg0.flush ||
X cp->reg0.susp != curparms.reg0.susp ||
X cp->reg1.rpl != curparms.reg1.rpl) {
X return(EACCES);
X }
X#endif
X for (i = 0; i < NNCREGS; i++) {
X if ((cp->noncache[i].addr & 0x0fff) ||
X (cp->noncache[i].offset & 0xf0))
X return(EINVAL);
X }
X
X if (copyin(arg, (caddr_t) &curparms, sizeof(cxparms_t)) < 0)
X return(EFAULT);
X
X ospl = splhi();
X cx_i486cacheoff();
X cx_setcachectl(&curparms);
X if (curparms.mode == CX_ENABLE)
X cx_i486cacheon();
X splx(ospl);
X break;
X
X case CX_GETPARM:
X ospl = splhi();
X cx_getcachectl(&curparms);
X splx(ospl);
X
X if (copyout((caddr_t) &curparms, arg, sizeof(cxparms_t)) < 0)
X return(EFAULT);
X break;
X
X case CX_SETDFLT:
X if (!priv)
X return(EPERM);
X
X ospl = splhi();
X cx_i486cacheoff();
X cx_setcachectl(&cx_dfltparms);
X if (cx_dfltparms.mode == CX_ENABLE)
X cx_i486cacheon();
X splx(ospl);
X break;
X
X case CX_GETDFLT:
X if (copyout((caddr_t) &cx_dfltparms, arg,
X sizeof(cxparms_t)) < 0)
X return(EFAULT);
X break;
X
X default:
X return(EINVAL);
X }
X
X return(0);
X}
X
X
X/*
X * Public Routines
X */
X
Xvoid
Xcx_init(void)
X{
X if ((cx_found = cx_iscyrix()) == 1) {
X cx_i486cacheoff();
X cx_setcachectl(&cx_dfltparms);
X if (cx_dfltparms.mode == CX_ENABLE)
X cx_i486cacheon();
X#if defined(SVR3) && defined(sco)
X printcfg("cx", cx_base, 1, -1, -1, "vers=%s type=Cx486DLC/SLC",
X VERS);
X#else /* sco */
X DPRINTF("cx %s: Running on Cx486DLC/SLC CPU.", VERS);
X#endif /* sco */
X }
X
X /* Copy the default parameters into the save buffer */
X bcopy((caddr_t) &cx_dfltparms, (caddr_t) &cx_savparms,
X sizeof(cxparms_t));
X}
X
X
X#ifdef SVR4
Xint
Xcx_ioctl(dev_t dev, int cmd, void *arg, int mode, cred_t *crp, int *rvalp)
X#else
Xvoid
Xcx_ioctl(dev_t dev, int cmd, void *arg, int mode)
X#endif
X{
X int priv = 0,
X ret;
X
X#ifdef SVR4
X if (drv_priv(crp) == 0)
X#else
X if (suser())
X#endif
X priv = 1;
X
X ret = cx_do_ioctl(cmd, arg, priv);
X
X#ifdef SVR4
X return(ret);
X#else
X u.u_error = ret;
X#endif
X}
X
END_OF_FILE
if test 5731 -ne `wc -c <'cx.c'`; then
echo shar: \"'cx.c'\" unpacked with wrong size!
fi
# end of 'cx.c'
fi
if test -f 'cx.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cx.h'\"
else
echo shar: Extracting \"'cx.h'\" \(3058 characters\)
sed "s/^X//" >'cx.h' <<'END_OF_FILE'
X/*
X * cx.h UNIX(tm) System V/386 driver to control the Cyrix(tm)
X * Cx486DLC/SLC CPU internal cache.
X *
X * by Ti Kan
X * E-mail: Internet: ti@amb.org
X * UUCP: ...!decwrl!sgiblab!bazooka!ti
X * ...!uunet!bazooka!ti
X *
X * Copyright (c) Ti Kan 1993, All rights reserved.
X *
X * This software can be distributed freely. This software,
X * and software based on or that uses code from it cannot
X * be used for commercial purposes without consent of the
X * copyright holder. This copyright notice must appear in
X * all products that is based on or uses code from this
X * software.
X */
X
X#ifndef _SYS_CX_H_
X#define _SYS_CX_H_
X
X#ident "@(#)cx.h 1.9 93/03/14"
X
X/* Used for ioctl */
X#define CX_PREFIX ('c'<<16|'x'<<8)
X#define CX_SETPARM (CX_PREFIX|1) /* Set cache parameters */
X#define CX_GETPARM (CX_PREFIX|2) /* Get current cache parameters */
X#define CX_SETDFLT (CX_PREFIX|3) /* Set cache parameters to default */
X#define CX_GETDFLT (CX_PREFIX|4) /* Get default cache parameters */
X
X#define CX_DISABLE 0 /* Cache disable */
X#define CX_ENABLE 1 /* Cache enable */
X
X#define NNCREGS 4 /* Max non-cacheable regions */
X
X/* Non-cacheable region size code macros */
X#define NCREG_DISABLE 0x00 /* Disabled */
X#define NCREG_4KB 0x01 /* 4KB */
X#define NCREG_8KB 0x02 /* 8KB */
X#define NCREG_16KB 0x03 /* 16KB */
X#define NCREG_32KB 0x04 /* 32KB */
X#define NCREG_64KB 0x05 /* 64KB */
X#define NCREG_128KB 0x06 /* 128KB */
X#define NCREG_256KB 0x07 /* 256KB */
X#define NCREG_512KB 0x08 /* 512KB */
X#define NCREG_1MB 0x09 /* 1MB */
X#define NCREG_2MB 0x0a /* 2MB */
X#define NCREG_4MB 0x0b /* 4MB */
X#define NCREG_8MB 0x0c /* 8MB */
X#define NCREG_16MB 0x0d /* 16MB */
X#define NCREG_32MB 0x0e /* 32MB */
X#define NCREG_4GB 0x0f /* 4GB */
X
X
X/* Non-cacheable regions parameters */
Xtypedef struct {
X ulong addr; /* Starting address */
X u_char offset; /* Region size code: use macros above */
X} ncreg_t;
X
X
X/* Cache configuration register 0 */
Xtypedef struct {
X u_char nc0:1; /* Set first 64KB of every 1MB boundary non-
X * cacheable, when operating in real or v86
X * mode.
X */
X
X u_char nc1:1; /* Set the 640K-1M region as non-cacheable */
X
X u_char a20m:1; /* Enable A20M# input pin */
X
X u_char ken:1; /* Enable KEN# input pin */
X
X u_char flush:1; /* Enable KEN# input pin */
X
X u_char barb:1; /* Flush internal cache when hold state
X * entered.
X */
X
X u_char co:1; /* cache organization:
X * 0: 2-way set associative
X * 1: direct mapped
X */
X u_char susp:1; /* Enable SUSP# input and SUSPA# output pins */
X} cxreg0_t;
X
X
X/* Cache configuration register 1 */
Xtypedef struct {
X u_char rpl:1; /* Enable output pins RPLSET and RPLVAL#. If
X * not enabled, both output pins will float.
X */
X
X u_char reserved:7; /* Reserved */
X} cxreg1_t;
X
X
X/* Cache control parameters */
Xtypedef struct cxparms {
X int mode; /* Cache on/off: CX_ENABLE, CX_DISABLE */
X cxreg0_t reg0; /* Cache config register 0 */
X cxreg1_t reg1; /* Cache config register 1 */
X ncreg_t noncache[NNCREGS]; /* Non-cacheable regions */
X} cxparms_t;
X
X#endif /* _SYS_CX_H_ */
END_OF_FILE
if test 3058 -ne `wc -c <'cx.h'`; then
echo shar: \"'cx.h'\" unpacked with wrong size!
fi
# end of 'cx.h'
fi
if test -f 'cx_ml.s' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cx_ml.s'\"
else
echo shar: Extracting \"'cx_ml.s'\" \(4660 characters\)
sed "s/^X//" >'cx_ml.s' <<'END_OF_FILE'
X/
X/ cx_ml.s UNIX(tm) System V/386 driver to control the Cyrix(tm)
X/ Cx486DLC/SLC CPU internal cache.
X/
X/ by Ti Kan
X/ E-mail: Internet: ti@amb.org
X/ UUCP: ...!decwrl!sgiblab!bazooka!ti
X/ ...!uunet!bazooka!ti
X/
X/ This file contains some code fragments adapted from the public
X/ domain.
X/
X/ Copyright (c) Ti Kan 1993, All rights reserved.
X/
X/ This software can be distributed freely. This software,
X/ and software based on or that uses code from it cannot
X/ be used for commercial purposes without consent of the
X/ copyright holder. This copyright notice must appear in
X/ all products that is based on or uses code from this
X/ software.
X/
X .ident "@(#)cx_ml.s 1.7 93/03/14"
X
X .data / Data section
X
X .align 4
Xcx_flags_mask: .long 0x08d5 / Mask to isolate the undefined bits
X / masks all but OF, SF, ZF, AF, PF, CF
Xcx_flags_before: .long 0 / Flags before div
Xcx_flags_after: .long 0 / Flags after div
Xcx_dividend: .long 0xffff / Dividend
Xcx_divisor: .long 0x4 / Divisor
Xcx_result: .long 0 / Results of flags compare
X / 0=different (Intel), 1=same (Cyrix)
X
X .text / Text section
X
X .set CR0_CD_ENB, 0xbfffffff / Enable cache with CR0
X .set CR0_NW_ENB, 0xdfffffff / Enable writethru with CR0
X .set CR0_CD_DIS, 0x40000000 / Disable cache with CR0
X .set CR0_NW_DIS, 0x20000000 / Disable writethru with CR0
X / Actually, the NW bit on hardwired
X / to 0 at all times on the Cyrix,
X / but we set and clear it anyway...
X
X/
X/ void cx_i486cacheon(void)
X/
X/ This routine flushes and enables the i486 internal cache.
X/
X .align 4
X .globl cx_i486cacheon
Xcx_i486cacheon:
X pushl %ebp
X movl %esp, %ebp
X movl cx_found, %eax / Are we running on a Cyrix?
X orl %eax, %eax
X jz cx_cacheon_done / Not Cyrix: just return
X .byte 0x0f / INVD instruction:
X .byte 0x08 / Flush i486 cache
X .byte 0x0f / WBINVD instruction:
X .byte 0x09 / Flush i486 cache with write back
X jmp cx_postinvd1 / jmp to next to force queue flush
Xcx_postinvd1:
X movl %cr0, %eax / cr0 -> eax
X andl $CR0_CD_ENB, %eax / Turn "on" CD bit
X andl $CR0_NW_ENB, %eax / Turn "on" NW bit
X movl %eax, %cr0 / eax -> cr0
Xcx_cacheon_done:
X popl %ebp
X ret
X
X/
X/ void cx_i486cacheoff(void)
X/
X/ This routine disables and flushes the i486 internal cache.
X/
X .align 4
X .globl cx_i486cacheoff
Xcx_i486cacheoff:
X pushl %ebp
X movl %esp, %ebp
X movl cx_found, %eax / Are we running on a Cyrix?
X orl %eax, %eax
X jz cx_cacheoff_done / Not Cyrix: just return
X movl %cr0, %eax / cr0 -> eax
X orl $CR0_CD_DIS, %eax / Turn "off" CD bit
X orl $CR0_NW_DIS, %eax / Turn "off" CD bit
X movl %eax, %cr0 / eax -> cr0
X .byte 0x0f / INVD instruction:
X .byte 0x08 / Flush i486 cache
X .byte 0x0f / WBINVD instruction:
X .byte 0x09 / Flush i486 cache with write back
X jmp cx_postinvd2 / Jmp to next to force queue flush
Xcx_postinvd2:
Xcx_cacheoff_done:
X popl %ebp
X ret
X
X/
X/ int cx_iscyrix(void)
X/
X/ This routine returns 1 if we are running on a 486DLC/SLC CPU.
X/ Otherwise, it returns 0.
X/
X .align 4
X .globl cx_iscyrix
Xcx_iscyrix:
X pushl %ebp
X movl %esp, %ebp
X
X pushal / Save processor state
X pushfl
X
X movl $0, %eax / Set flags to known state
X cmpl %eax, %eax
X
X pushfl / Load flags into eax
X popl %eax
X movl %eax, cx_flags_before / Save flags to mem
X
X / Do a div instruction so that the signature of the undefined flags
X / can be observed
X movl cx_dividend, %eax
X movl $0, %edx
X movl cx_divisor, %ebx
X divl %ebx
X
X pushfl / Load flags into eax
X popl %eax
X
X movl %eax, cx_flags_after / Save flags to mem
X
X / Recall cx_flags_before and clear unwanted bits
X movl cx_flags_mask, %eax
X andl cx_flags_before, %eax
X
X / Recall cx_flags_after and clear unwanted bits
X movl cx_flags_mask, %ebx
X andl cx_flags_after, %ebx
X
X / Compare the signature of the undefined bits before and after
X cmpl %ebx, %eax
X jnz cx_not_cyrix
X movl $1, cx_result / Set if flag bits are unchanged
X / Cyrix part found
X jmp cx_detect_done
Xcx_not_cyrix:
X movl $0, cx_result / Clear if flag bits are changed
X / Cyrix part not found
Xcx_detect_done:
X popfl / Restore processor state
X popal
X
X movl cx_result, %eax / Return value
X
X popl %ebp
X ret
X
X/
X/ int cx_i486cachemode(void)
X/
X/ This routine returns 1 if we the i486 cache is enabled.
X/ Otherwise, it returns 0.
X/
X .align 4
X .globl cx_i486cachemode
Xcx_i486cachemode:
X pushl %ebp
X movl %esp, %ebp
X
X movl %cr0, %eax / cr0 -> eax
X andl $CR0_CD_DIS, %eax / Test if CD bit "on"
X orl %eax, %eax
X jnz cx_cacheisoff
X
X movl $1, %eax / Cache is on: set return value
X jmp cx_mode_done
X
Xcx_cacheisoff:
X movl $0, %eax / Cache is off: set return value
X
Xcx_mode_done:
X
X popl %ebp
X ret
X
END_OF_FILE
if test 4660 -ne `wc -c <'cx_ml.s'`; then
echo shar: \"'cx_ml.s'\" unpacked with wrong size!
fi
# end of 'cx_ml.s'
fi
if test -f 'cxctl.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cxctl.c'\"
else
echo shar: Extracting \"'cxctl.c'\" \(11523 characters\)
sed "s/^X//" >'cxctl.c' <<'END_OF_FILE'
X/*
X * cxctl.c UNIX(tm) System V/386 utility to control the Cyrix(tm)
X * Cx486DLC/SLC CPU internal cache.
X *
X * The utility can be used only on systems installed with the
X * Cyrix cache device driver (cx).
X *
X * Warning: Changing some of the cache parameters on a live system
X * can lead to a system crash or data corruption. Compile
X * with -DPARANOID to prevent this from happening.
X *
X * by Ti Kan
X * E-mail: Internet: ti@amb.org
X * UUCP: ...!decwrl!sgiblab!bazooka!ti
X * ...!uunet!bazooka!ti
X *
X * Copyright (c) Ti Kan 1993, All rights reserved.
X *
X * This software can be distributed freely. This software,
X * and software based on or that uses code from it cannot
X * be used for commercial purposes without consent of the
X * copyright holder. This copyright notice must appear in
X * all products that is based on or uses code from this
X * software.
X */
X#ident "@(#)cxctl.c 1.15 93/03/15"
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <ctype.h>
X#include <fcntl.h>
X#include <errno.h>
X#include "sys/cx.h"
X
X#ifndef VERS
X#define VERS "undef"
X#endif
X
X
Xextern int opterr,
X optind;
Xextern char *optarg;
X
Xint changed = 0; /* Flag to indicate change to parameters */
X
X
Xint
Xdo_ioctl(int fd, cxparms_t *pp, int cmd)
X{
X if (ioctl(fd, cmd, pp) < 0) {
X perror("ioctl error");
X
X switch (errno) {
X case EACCES:
X fprintf(stderr,
X "Attempt to change parameters that are disallowed.\n");
X break;
X case EPERM:
X fprintf(stderr,
X "You must be the super user to effect change.\n");
X break;
X default:
X break;
X }
X
X return(0);
X }
X return(1);
X}
X
X
Xchar *
Xoffset_str(u_char offset)
X{
X static char buf[10];
X
X switch (offset) {
X case NCREG_4KB:
X strcpy(buf, "4KB");
X break;
X case NCREG_8KB:
X strcpy(buf, "8KB");
X break;
X case NCREG_16KB:
X strcpy(buf, "16KB");
X break;
X case NCREG_32KB:
X strcpy(buf, "32KB");
X break;
X case NCREG_64KB:
X strcpy(buf, "64KB");
X break;
X case NCREG_128KB:
X strcpy(buf, "128KB");
X break;
X case NCREG_256KB:
X strcpy(buf, "256KB");
X break;
X case NCREG_512KB:
X strcpy(buf, "512KB");
X break;
X case NCREG_1MB:
X strcpy(buf, "1MB");
X break;
X case NCREG_2MB:
X strcpy(buf, "2MB");
X break;
X case NCREG_4MB:
X strcpy(buf, "4MB");
X break;
X case NCREG_8MB:
X strcpy(buf, "8MB");
X break;
X case NCREG_16MB:
X strcpy(buf, "16MB");
X break;
X case NCREG_32MB:
X strcpy(buf, "32MB");
X break;
X case NCREG_4GB:
X strcpy(buf, "4GB");
X break;
X }
X
X return(buf);
X}
X
X
Xvoid
Xshow_parms(cxparms_t *pp)
X{
X int i;
X
X printf("Cache:\t\t\t%s\n",
X (pp->mode == CX_ENABLE) ? "Enable" : "Disable");
X
X printf("Config register 0:");
X printf("\tNC0=%d NC1=%d A20M=%d KEN=%d FLUSH=%d BARB=%d CO=%d SUSP=%d\n",
X pp->reg0.nc0,
X pp->reg0.nc1,
X pp->reg0.a20m,
X pp->reg0.ken,
X pp->reg0.flush,
X pp->reg0.barb,
X pp->reg0.co,
X pp->reg0.susp);
X
X printf("Config register 1:");
X printf("\tRPL=%d\n", pp->reg1.rpl);
X
X for (i = 0; i < NNCREGS; i++) {
X printf("Non-cacheable region %d:\t", i);
X if (pp->noncache[i].offset == NCREG_DISABLE)
X printf("Disable\n");
X else
X printf("addr=0x%lx offset=%s\n",
X pp->noncache[i].addr,
X offset_str(pp->noncache[i].offset));
X }
X}
X
X
Xvoid
Xshow_help(void)
X{
X printf("Valid commands are:\n%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
X "\tc\tEnable/Disable cache\n",
X "\t1\tToggle Cache Config Register 0 - bit NC0\n",
X "\t2\tToggle Cache Config Register 0 - bit NC1\n",
X "\t3\tToggle Cache Config Register 0 - bit A20M\n",
X "\t4\tToggle Cache Config Register 0 - bit KEN\n",
X "\t5\tToggle Cache Config Register 0 - bit FLUSH\n",
X "\t6\tToggle Cache Config Register 0 - bit BARB\n",
X "\t7\tToggle Cache Config Register 0 - bit CO \n",
X "\t8\tToggle Cache Config Register 0 - bit SUSP\n",
X "\t9\tToggle Cache Config Register 1 - bit RPL\n",
X "\tn\tConfigure Non-cacheable Region\n",
X "\ts\tShow current parameters\n",
X "\td\tShow default parameters\n",
X "\tD\tChange to default parameters\n",
X "\te\tSet hardware to current parameters\n",
X "\t?\tDisplay this help information\n",
X "\tq\tQuit\n");
X}
X
X
Xchar
Xget_yn(char *msg)
X{
X char buf[5];
X
X while (1) {
X printf(msg);
X if (fgets(buf, sizeof(buf), stdin) == NULL)
X continue;
X if (buf[0] == 'y' || buf[0] == 'n' ||
X buf[0] == 'Y' || buf[0] == 'N')
X break;
X printf("Please answer 'y' or 'n'.\n");
X }
X return(tolower(buf[0]));
X}
X
X
Xint
Xget_dec(char *msg)
X{
X char buf[40];
X
X while (1) {
X printf(msg);
X if (fgets(buf, sizeof(buf), stdin) == NULL)
X continue;
X if (isdigit(buf[0]))
X break;
X printf("Invalid value entered.\n");
X }
X return(atoi(buf));
X}
X
X
Xulong
Xget_hex(char *msg)
X{
X char buf[40];
X ulong result;
X
X while (1) {
X printf(msg);
X if (fgets(buf, sizeof(buf), stdin) == NULL)
X continue;
X if (sscanf(buf, "%lx\n", &result) >= 1 ||
X sscanf(buf, "%lX\n", &result) >= 1)
X break;
X printf("Invalid value entered.\n");
X }
X return(result);
X}
X
X
Xvoid
Xncreg_config(cxparms_t *pp)
X{
X int ncregion;
X ulong addr, offset;
X char msg[256];
X
X sprintf(msg, "Region number? [0-%d] ", NNCREGS - 1);
X
X do {
X if ((ncregion = get_dec(msg)) >= NNCREGS || ncregion < 0)
X printf("Invalid region number.\n");
X else
X break;
X } while (1);
X
X sprintf(msg,
X "\n%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\nChoose Region %d size: ",
X "\t0\tDisable\n",
X "\t1\t 4KB\n",
X "\t2\t 8KB\n",
X "\t3\t 16KB\n",
X "\t4\t 32KB\n",
X "\t5\t 64KB\n",
X "\t6\t128KB\n",
X "\t7\t256KB\n",
X "\t8\t512KB\n",
X "\t9\t 1MB\n",
X "\ta\t 2MB\n",
X "\tb\t 4MB\n",
X "\tc\t 8MB\n",
X "\td\t 16MB\n",
X "\te\t 32MB\n",
X "\tf\t 4GB\n",
X ncregion);
X
X do {
X if ((offset = get_hex(msg)) & 0xf0)
X printf("Invalid selection.\n");
X else
X break;
X } while (1);
X
X if (offset > 0) {
X sprintf(msg,
X "\nRegion %d starting address? (4KB boundaries) 0x",
X ncregion);
X
X do {
X if ((addr = get_hex(msg)) & 0x0fff)
X printf("Address is not on 4KB boundary.\n");
X else
X break;
X } while (1);
X }
X else
X addr = 0L;
X
X pp->noncache[ncregion].addr = addr;
X pp->noncache[ncregion].offset = (u_char) offset;
X
X printf("Non-cacheable Region %d set to ", ncregion);
X if (offset > 0)
X printf("addr=0x%lx offset=%s\n",
X addr, offset_str((u_char) offset));
X else
X printf("Disable\n");
X}
X
X
Xchar
Xget_cmd(void)
X{
X char buf[5];
X
X do {
X printf("\ncx> ");
X } while (fgets(buf, sizeof(buf), stdin) == NULL || buf[0] == '\n');
X
X return(buf[0]);
X}
X
X
Xint
Xprocess_cmd(int fd, char cmd, cxparms_t *pp)
X{
X static cxparms_t tmp;
X
X switch (cmd) {
X case 'c':
X if (pp->mode == CX_ENABLE)
X pp->mode = CX_DISABLE;
X else
X pp->mode = CX_ENABLE;
X changed = 1;
X printf("Cache mode set to %s\n",
X (pp->mode == CX_ENABLE) ? "Enable" : "Disable");
X break;
X case '1':
X pp->reg0.nc0 = !pp->reg0.nc0;
X changed = 1;
X printf("Control register 0 - NC0 set to %d\n",
X pp->reg0.nc0);
X break;
X case '2':
X pp->reg0.nc1 = !pp->reg0.nc1;
X changed = 1;
X printf("Control register 0 - NC1 set to %d\n",
X pp->reg0.nc1);
X break;
X case '3':
X#ifdef PARANOID
X printf("The A20M bit cannot be changed in this version.\n");
X#else
X printf("\nChanging the A20M bit is not recommended.\n");
X if (get_yn("Proceed? [ny] ") == 'y') {
X pp->reg0.a20m = !pp->reg0.a20m;
X changed = 1;
X printf("Control register 0 - A20M set to %d\n",
X pp->reg0.a20m);
X }
X else
X printf("The A20M bit is not changed.\n");
X#endif
X break;
X case '4':
X#ifdef PARANOID
X printf("The KEN bit cannot be changed in this version.\n");
X#else
X printf("\nChanging the KEN bit is not recommended.\n");
X if (get_yn("Proceed? [ny] ") == 'y') {
X pp->reg0.ken = !pp->reg0.ken;
X changed = 1;
X printf("Control register 0 - KEN set to %d\n",
X pp->reg0.ken);
X }
X else
X printf("The KEN bit is not changed.\n");
X#endif
X break;
X case '5':
X#ifdef PARANOID
X printf("The FLUSH bit cannot be changed in this version.\n");
X#else
X printf("\nChanging the FLUSH bit is not recommended.\n");
X if (get_yn("Proceed? [ny] ") == 'y') {
X pp->reg0.flush = !pp->reg0.flush;
X changed = 1;
X printf("Control register 0 - FLUSH set to %d\n",
X pp->reg0.flush);
X }
X else
X printf("The FLUSH bit is not changed.\n");
X#endif
X break;
X case '6':
X pp->reg0.barb = !pp->reg0.barb;
X changed = 1;
X printf("Control register 0 - BARB set to %d\n",
X pp->reg0.barb);
X break;
X case '7':
X#ifdef PARANOID
X printf("The CO bit cannot be changed in this version.\n");
X#else
X printf("\nChanging the CO bit is not recommended.\n");
X if (get_yn("Proceed? [ny] ") == 'y') {
X pp->reg0.co = !pp->reg0.co;
X changed = 1;
X printf("Control register 0 - CO set to %d\n",
X pp->reg0.co);
X }
X else
X printf("The CO bit is not changed.\n");
X#endif
X break;
X case '8':
X#ifdef PARANOID
X printf("The SUSP bit cannot be changed in this version.\n");
X#else
X printf("\nChanging the SUSP bit is not recommended.\n");
X if (get_yn("Proceed? [ny] ") == 'y') {
X pp->reg0.susp = !pp->reg0.susp;
X changed = 1;
X printf("Control register 0 - SUSP set to %d\n",
X pp->reg0.susp);
X }
X else
X printf("The SUSP bit is not changed.\n");
X#endif
X break;
X case '9':
X#ifdef PARANOID
X printf("The RPL bit cannot be changed in this version.\n");
X#else
X printf("\nChanging the RPL bit is not recommended.\n");
X if (get_yn("Proceed? [ny] ") == 'y') {
X pp->reg1.rpl = !pp->reg1.rpl;
X changed = 1;
X printf("Control register 1 - RPL set to %d\n",
X pp->reg1.rpl);
X }
X else
X printf("The RPL bit is not changed.\n");
X#endif
X break;
X case 'n':
X ncreg_config(pp);
X changed = 1;
X break;
X case 's':
X printf("Current cache control parameters:\n\n");
X show_parms(pp);
X break;
X case 'd':
X if (!do_ioctl(fd, &tmp, CX_GETDFLT))
X printf("Cannot get default parameters.\n");
X else {
X printf("Default cache control parameters:\n\n");
X show_parms(&tmp);
X }
X break;
X case 'D':
X if (!do_ioctl(fd, pp, CX_GETDFLT))
X printf("Cannot set parameters to default values.\n");
X else
X printf("All parameters set to default values.\n");
X break;
X case 'e':
X if (!do_ioctl(fd, pp, CX_SETPARM))
X printf("Unable to set hardware.\n");
X else {
X printf("Hardware set to specified parameters.\n");
X changed = 0;
X }
X break;
X case '\n':
X case '\0':
X break;
X case 'q':
X return(0);
X case '?':
X show_help();
X break;
X default:
X printf("Invalid command.\n");
X show_help();
X break;
X }
X
X return(1);
X}
X
X
Xvoid
Xusage(char *progname)
X{
X fprintf(stderr, "Usage: %s [-d]\n", progname);
X}
X
X
Xint
Xdone(int fd, int exit_status)
X{
X if (fd >= 0)
X close(fd);
X exit(exit_status);
X}
X
X
Xint
Xmain(int argc, char **argv)
X{
X char c,
X cmd;
X int fd = -1,
X displayonly = 0,
X quit = 0;
X cxparms_t cxparms;
X
X /* Parse command line arguments */
X opterr = 0;
X while ((c = getopt(argc, argv, "d")) != EOF) {
X switch (c) {
X case 'd':
X displayonly = 1;
X break;
X default:
X usage(argv[0]);
X done(fd, 1);
X }
X }
X
X#ifdef DEBUG
X setbuf(stdout, NULL);
X#endif
X
X printf("%s v%s\n%s\n%s\n",
X "Cx486DLC/SLC Internal Cache Configuration Utility",
X VERS,
X "Copyright (c) Ti Kan 1993",
X "------------------------------------------------------------");
X
X /* Open device node for ioctls */
X if ((fd = open("/dev/cx", O_RDWR)) < 0) {
X perror("Cannot open /dev/cx");
X done(fd, 2);
X }
X
X /* Get current cache configuration */
X if (!do_ioctl(fd, &cxparms, CX_GETPARM))
X done(fd, 3);
X
X if (!displayonly)
X printf("Type '?' for a list of valid commands.\n\n");
X
X /* Show current cache configuration */
X show_parms(&cxparms);
X
X if (displayonly)
X done(fd, 0);
X
X /* Enter configuration editor */
X do {
X if (!process_cmd(fd, get_cmd(), &cxparms))
X quit = 1;
X
X if (quit && changed &&
X get_yn("\nQuit without setting hardware? [ny] ") != 'y')
X quit = 0;
X } while (!quit);
X
X done(fd, 0);
X}
X
X
END_OF_FILE
if test 11523 -ne `wc -c <'cxctl.c'`; then
echo shar: \"'cxctl.c'\" unpacked with wrong size!
fi
# end of 'cxctl.c'
fi
if test -f 'cxinstall.sh' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cxinstall.sh'\"
else
echo shar: Extracting \"'cxinstall.sh'\" \(3806 characters\)
sed "s/^X//" >'cxinstall.sh' <<'END_OF_FILE'
X#!/bin/sh
X
X#
X# cxinstall UNIX(tm) System V/386 driver to control the Cyrix(tm)
X# Cx486DLC/SLC CPU internal cache.
X#
X# by Ti Kan
X# E-mail: Internet: ti@amb.org
X# UUCP: ...!decwrl!sgiblab!bazooka!ti
X# ...!uunet!bazooka!ti
X#
X# Copyright (c) Ti Kan 1993, All rights reserved.
X#
X# This software can be distributed freely. This software,
X# and software based on or that uses code from it cannot
X# be used for commercial purposes without consent of the
X# copyright holder. This copyright notice must appear in
X# all products that is based on or uses code from this
X# software.
X#
X#ident "@(#)cxinstall.sh 1.4 93/03/15"
X
XOK=0
XFAIL=1
XPATH=/bin:/usr/bin:/etc; export PATH
X
X
Xgetyn() {
X echo "$* [yn] \c"
X while :
X do
X read ANS
X case "$ANS" in
X y|Y)
X return $OK
X ;;
X n|N)
X return $FAIL
X ;;
X *)
X echo "Please type y or n."
X ;;
X esac
X done
X}
X
X
Xsys_type() {
X if [ ! -d $ROOT/etc/conf ]
X then
X echo "Kernel configuration directory /etc/conf not present."
X echo "Aborting..."
X return $FAIL
X fi
X
X # The following is a pretty crude way to figure out the UNIX flavor,
X # for for our purposes it should suffice...
X
X KERNFILE=
X if [ -r /stand/unix ]
X then
X KERNFILE=/stand/unix
X elif [ -r /unix ]
X then
X KERNFILE=/unix
X fi
X
X if [ -n "$KERNFILE" ]
X then
X if (file $KERNFILE | fgrep ELF) >/dev/null 2>&1
X then
X if [ -d $ROOT/etc/conf/mdevice.d ] && \
X (fgrep "version 1" $ROOT/etc/conf/mdevice.d/*) \
X >/dev/null 2>&1
X then
X echo SVR42
X else
X echo SVR4
X fi
X else
X echo SVR3
X fi
X
X return $OK
X fi
X
X echo "Unknown system type. Aborting..."
X return $FAIL
X}
X
X
X
X# Main starts here
X
XRELDIR=`pwd`
X
Xif (id | fgrep uid=0) >/dev/null 2>&1
Xthen
X if [ -z "$ROOT" ]
X then
X root=/
X else
X if [ -n "$ROOT" ]
X then
X echo "The ROOT environment variable is currently set"
X echo "to $ROOT. Installation of the driver will use"
X echo "$ROOT/etc/conf."
X if getyn "Proceed?"
X then
X break
X else
X echo "Installation aborted."
X exit $FAIL
X fi
X fi
X root=$ROOT
X fi
X echo "CX driver installation: ROOT is $root"
Xelse
X echo "You must be the super-user ro install the CX driver."
X exit $FAIL
Xfi
Xecho ""
X
XSYSTYPE=`sys_type`
Xif [ $? -ne 0 ]
Xthen
X exit 1
Xfi
X
Xif [ ! -d cx ]
Xthen
X echo "Cannot find the cx directory."
X echo "You must run this install script from the directory where"
X echo "the binary distribution is unpacked. Aborting..."
X exit $FAIL
Xfi
X
Xcd cx
Xcase "$SYSTYPE" in
XSVR3)
X cp Master.ver0 Master
X cp System.ver0 System
X ;;
XSVR4)
X cp Master.ver0 Master
X cp System.ver0 System
X ;;
XSVR42)
X cp Master.ver1 Master
X cp System.ver1 System
X ;;
X*)
X echo "Unknown system type. Aborting..."
X exit $FAIL
X ;;
Xesac
X
Xif [ -f $ROOT/etc/conf/sdevice.d/cx ]
Xthen
X $ROOT/etc/conf/bin/idinstall -d cx >/dev/null 2>&1
Xfi
X
X$ROOT/etc/conf/bin/idinstall -a cx
Xif [ $? -eq 0 ]
Xthen
X echo "The CX driver has been installed."
Xelse
X echo "idinstall failed."
X exit $FAIL
Xfi
X
Xcd $RELDIR
X
Xcp cx.h /usr/include/sys/cx.h
Xchown bin /usr/include/sys/cx.h
Xchgrp bin /usr/include/sys/cx.h
Xchmod 444 /usr/include/sys/cx.h
Xecho "The header file has been installed as /usr/include/sys/cx.h."
X
Xcp cxctl /etc/cxctl
Xchown root /etc/cxctl
Xchgrp root /etc/cxctl
Xchmod 700 /etc/cxctl
Xecho "The cache control utility has been installed as /etc/cxctl."
Xecho ""
X
Xcase "$SYSTYPE" in
XSVR3|SVR4)
X echo "The kernel must be rebuilt to enable the CX driver."
X if getyn "Do you want to rebuild the kernel now?"
X then
X $ROOT/etc/conf/bin/idbuild
X echo "\nYou must now reboot the system to enable the CX driver."
X else
X echo ""
X echo "The kernel will not be rebuilt now."
X echo "To rebuild the kernel, you must invoke the command"
X echo "$ROOT/etc/conf/bin/idbuild"
X exit $OK
X fi
X ;;
XSVR42)
X $ROOT/etc/conf/bin/idbuild
X echo "\nYou must now reboot the system to enable the CX driver."
X ;;
Xesac
X
Xexit $OK
X
END_OF_FILE
if test 3806 -ne `wc -c <'cxinstall.sh'`; then
echo shar: \"'cxinstall.sh'\" unpacked with wrong size!
fi
# end of 'cxinstall.sh'
fi
echo shar: End of shell archive.
exit 0
--
/// Ti Kan vorsprung durch technik
/// AMB Research Laboratories, Sunnyvale, CA. USA
/// ti@amb.org
////// ...!{decwrl,synopsys,tandem,tsoft,ultra}!sgiblab!bazooka!ti
/// ...!{uunet,sun,apple,sco}!altos!bazooka!ti