diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-02-19 12:30:49 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-02-19 12:30:49 +0000 |
commit | 77d478ddacb21ab351a7726510b1d81236125173 (patch) | |
tree | 025730985044627844ef7bc2adbaaf3f7be611e5 | |
parent | 0c627058c79e5867b47468553d9ec113f2616984 (diff) | |
parent | 66582b606a8194f7f3ba5b3a3a6dca5b0d346361 (diff) | |
download | illumos-joyent-77d478ddacb21ab351a7726510b1d81236125173.tar.gz |
[illumos-gate merge]
commit 66582b606a8194f7f3ba5b3a3a6dca5b0d346361
12185 Remove B100s support
commit e912cc3d5decbbfbb3005d9f678e9fc3ccbcf91f
12314 ld fatal warnings miss some guidance messages
commit 20de283b9b1939fdc5b617ccc0c6e5ce8b7c6160
12313 nightly should check for ld guidance
commit f365545469641697196ce86d635cfe5f3fe68d27
12312 fix unused lib dependencies
commit 3e3015ce0eb82be8ac17954eba80f3f24204fcbd
12311 adjust NATIVE_LIBS in SMF makefiles
commit ced75a9309169d0177775214e3e1780ef5f7cf8a
12293 libfru: SOLARIS_UNIX is not needed
commit e371214c989050b68785a50c83f96cd04c4d18e8
12233 libsmbios fails to build on SPARC
Conflicts:
usr/src/man/man7d/Makefile
usr/src/cmd/svc/configd/Makefile
91 files changed, 96 insertions, 19749 deletions
diff --git a/usr/src/cmd/cmd-inet/sbin/dhcpagent/Makefile b/usr/src/cmd/cmd-inet/sbin/dhcpagent/Makefile index 5f677b7e7c..a005757e6c 100644 --- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/Makefile +++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/Makefile @@ -22,7 +22,7 @@ # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # Copyright (c) 2016, Chris Fraire <cfraire@me.com>. -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. # PROG = dhcpagent @@ -46,7 +46,7 @@ CERRWARN += -_gcc=-Wno-parentheses SMATCH=off CPPFLAGS += -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ LDLIBS += -lxnet -lnvpair -ldhcpagent -ldhcputil -linetutil -ldevinfo \ - -ldlpi -lresolv -lsocket -lipadm + -ldlpi -lresolv -lipadm # Disable warnings that affect all XPG applications. LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 -erroff=E_INCONS_VAL_TYPE_DECL2 diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile index 65077da947..f798fa2675 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile @@ -3,7 +3,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. ROUTEDPROG= in.routed ROUTEDOBJS= common.o if.o input.o main.o output.o parms.o radix.o \ @@ -43,7 +43,7 @@ CERRWARN += $(CNOWARN_UNINIT) # not linted SMATCH=off -LDLIBS += -lxnet -lmd -lsocket +LDLIBS += -lxnet -lmd CLEAN_FILES += $(ROUTEDOBJS) $(RTQUERYOBJS) CLOBBERFILES += $(ROUTEDPROG) $(RTQUERYPROG) # diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile index 3b5987b509..801fb40158 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile @@ -22,7 +22,7 @@ # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# +# Copyright 2020 Joyent, Inc. PROG = ipadm ROOTFS_PROG = $(PROG) @@ -46,10 +46,8 @@ ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%) # ipadm uses the ancillary data feature which is available only through # UNIX 98 standards version of Socket interface. This interface is supposed to -# be accessed by -lxnet. In addition -lsocket is used to capture new -# not-yet-standard interfaces. Someday -lxnet alone should be enough when IPv6 -# inspired new interfaces are part of standards. -LDLIBS += -lxnet -lsocket +# be accessed by -lxnet. +LDLIBS += -lxnet # these #defines are required to use UNIX 98 interfaces _D_UNIX98_EXTN= -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ diff --git a/usr/src/cmd/cron/Makefile b/usr/src/cmd/cron/Makefile index 3f3320e989..3e1eebe136 100644 --- a/usr/src/cmd/cron/Makefile +++ b/usr/src/cmd/cron/Makefile @@ -22,7 +22,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright 2019 Joyent, Inc. +# Copyright 2020 Joyent, Inc. # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. DEFAULTFILES = cron.dfl @@ -135,16 +135,14 @@ $(ROOTXPG6BIN)/crontab := FILEMODE = 04555 $(ROOTXPG4BIN)/crontab := FILEMODE = 04555 $(ROOTUSRSBIN)/cron := FILEMODE = 0555 -LDLIBS += -lbsm - -at := LDLIBS += -lproject -lsecdb -at.xpg4 := LDLIBS += -lproject -lsecdb -atq := LDLIBS += -lsecdb -atrm := LDLIBS += -lsecdb -cron := LDLIBS += -lpam -lproject -lcontract -lzoneinfo -lcustr -crontab := LDLIBS += -lsecdb -lpam -lzoneinfo -lcustr -crontab.xpg6 := LDLIBS += -lsecdb -lpam -lzoneinfo -lcustr -crontab.xpg4 := LDLIBS += -lsecdb -lpam -lzoneinfo -lcustr +at := LDLIBS += -lbsm -lproject -lsecdb +at.xpg4 := LDLIBS += -lbsm -lproject -lsecdb +atq := LDLIBS += -lbsm -lsecdb +atrm := LDLIBS += -lbsm -lsecdb +cron := LDLIBS += -lbsm -lpam -lproject -lcontract -lzoneinfo -lcustr +crontab := LDLIBS += -lbsm -lsecdb -lpam -lzoneinfo -lcustr +crontab.xpg6 := LDLIBS += -lbsm -lsecdb -lpam -lzoneinfo -lcustr +crontab.xpg4 := LDLIBS += -lbsm -lsecdb -lpam -lzoneinfo -lcustr parsetest := LDLIBS += -lcustr $(XPG4) := CFLAGS += -DXPG4 diff --git a/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile b/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile index a8ebbd4eb5..b32595b906 100644 --- a/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile +++ b/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile @@ -22,7 +22,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. FSTYPE = nfs @@ -33,7 +33,7 @@ ATTMK = $(TYPEPROG) include ../../Makefile.fstype LDLIBS += -L$(ROOT)/usr/lib/nfs -R/usr/lib/nfs -LDLIBS += -lnsl -lmapid -ldtrace -lidmap +$(TYPEPROG) := LDLIBS += -lnsl -lmapid -ldtrace -lidmap COMMON = nfs_resolve.o SRCS = nfsmapid.c ../lib/nfs_resolve.c nfsmapid_server.c DSRC = nfsmapid_dt.d diff --git a/usr/src/cmd/fwflash/plugins/transport/Makefile.targ b/usr/src/cmd/fwflash/plugins/transport/Makefile.targ index fa2b078452..46785e8c6c 100644 --- a/usr/src/cmd/fwflash/plugins/transport/Makefile.targ +++ b/usr/src/cmd/fwflash/plugins/transport/Makefile.targ @@ -21,7 +21,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# cmd/fwflash/plugins/transport +# Copyright 2020 Joyent, Inc. # include $(SRC)/lib/Makefile.lib @@ -48,7 +48,7 @@ CLEANFILES= $(PLUGINS) $(POFILES) $(POFILE) $(LINTFILE) $(SLINKS) LIBS= $(DYNLIB) CFLAGS += $(C_PICFLAGS) ROOTLIBDIR= $(ROOTUSRLIBFWFLASHIDF) -LDLIBS += -ldevinfo -lc +LDLIBS += -ldevinfo MAPFILES= ../common/mapfile-vers FILEMODE= 0755 @@ -65,8 +65,10 @@ $(SD_LIB):= SONAME = $(SD_LIB) $(HERMON_LIB):= MAPFILES += ../common/mapfile-vers-hermon $(SD_LIB):= MAPFILES += ../common/mapfile-vers-plus -$(SES_LIB):= LDLIBS += -L$(ROOT)/usr/lib/scsi -lscsi -lses -lnvpair -$(SD_LIB):= LDLIBS += -L$(ROOT)/usr/lib/scsi -lscsi -lumem +$(HERMON_LIB):= LDLIBS += -lc +$(TAVOR_LIB):= LDLIBS += -lc +$(SES_LIB):= LDLIBS += -L$(ROOT)/usr/lib/scsi -lscsi -lses -lnvpair -lc +$(SD_LIB):= LDLIBS += -L$(ROOT)/usr/lib/scsi -lscsi -lumem -lc $(SES_LIB):= DYNFLAGS += -R/usr/lib/scsi $(SD_LIB):= DYNFLAGS += -R/usr/lib/scsi diff --git a/usr/src/cmd/krb5/kwarn/Makefile b/usr/src/cmd/krb5/kwarn/Makefile index 977631646e..c4635bbe33 100644 --- a/usr/src/cmd/krb5/kwarn/Makefile +++ b/usr/src/cmd/krb5/kwarn/Makefile @@ -23,7 +23,7 @@ # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. TESTPROG = kwarndtest @@ -67,9 +67,10 @@ CPPFLAGS += -I../../lib/gss_mechs/mech_krb5/include \ ktkt_warnd := MAPFILES = $(MAPFILE.INT) $(MAPFILE.NGB) ktkt_warnd := LDFLAGS += $(KRUNPATH) $(MAPFILES:%=-M%) +ktkt_warnd := LDLIBS += -lnsl LDFLAGS += $(KRUNPATH) -LDLIBS += $(KMECHLIB) -lnsl +LDLIBS += $(KMECHLIB) .KEEP_STATE: diff --git a/usr/src/cmd/oawk/Makefile b/usr/src/cmd/oawk/Makefile index 5ebbaae559..37a2f60f09 100644 --- a/usr/src/cmd/oawk/Makefile +++ b/usr/src/cmd/oawk/Makefile @@ -23,7 +23,7 @@ # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. include ../Makefile.cmd @@ -58,8 +58,7 @@ CLEANFILES = proctab.c y.tab.h y.tab.c awk.h awk.g.c \ temp YFLAGS = -d -XLDLIBS5CC += -lm -LDLIBS += -lm +LDLIBS += -lm CPPFLAGS = -I. $(CPPFLAGS.master) CPPFLAGS += -D_FILE_OFFSET_BITS=64 diff --git a/usr/src/cmd/picl/plugins/common/memcfg/Makefile b/usr/src/cmd/picl/plugins/common/memcfg/Makefile index 481c7bd220..d1d28fadb3 100644 --- a/usr/src/cmd/picl/plugins/common/memcfg/Makefile +++ b/usr/src/cmd/picl/plugins/common/memcfg/Makefile @@ -23,7 +23,7 @@ # Copyright 2004 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# cmd/picl/plugins/common/memcfg/Makefile +# Copyright 2020 Joyent, Inc. # LIBRARY= libpiclmemcfg.a VERS= .1 @@ -46,13 +46,7 @@ CLEANFILES= $(LINTOUT) $(LINTLIB) CPPFLAGS += -I$(SRC)/uts/sun4u/sys -I$(SRC)/cmd/picl/plugins/common/memcfg CFLAGS += $(CCVERBOSE) $(C_PICFLAGS) -LDLIBS += -L$(SRC)/lib/libpicltree/$(MACH) -LDLIBS += -L../devtree -LDLIBS += -L$(ROOT)/usr/lib/picl/plugins -LDLIBS += -lc -lpicltree -lpicldevtree -lnvpair -$(SPARC_BLD)LDLIBS += -R/usr/platform/\$$PLATFORM/lib/picl/plugins \ - -R/usr/platform/sun4u/lib/picl/plugins -LDLIBS += -R/usr/lib/picl/plugins +LDLIBS += -lc -lpicltree -lnvpair CLOBBERFILES += $(LIBLINKS) diff --git a/usr/src/cmd/picl/plugins/sun4u/Makefile b/usr/src/cmd/picl/plugins/sun4u/Makefile index 2de3454ef2..a4e4c018d8 100644 --- a/usr/src/cmd/picl/plugins/sun4u/Makefile +++ b/usr/src/cmd/picl/plugins/sun4u/Makefile @@ -31,11 +31,11 @@ include $(SRC)/Makefile.master SUBDIRS= lib .WAIT envmon .WAIT \ frudata grover excalibur psvc littleneck daktari \ - cherrystone lw2plus lw8 taco enchilada chicago blade mpxu ents \ + cherrystone lw2plus lw8 taco enchilada chicago mpxu ents \ chalupa silverstone sebring schumacher seattle boston .WAIT MSGSUBDIRS= lib frudata grover excalibur psvc littleneck daktari \ - cherrystone lw2plus lw8 taco enchilada chicago blade envmon mpxu ents \ + cherrystone lw2plus lw8 taco enchilada chicago envmon mpxu ents \ silverstone sebring all := TARGET= all diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/Makefile b/usr/src/cmd/picl/plugins/sun4u/blade/Makefile deleted file mode 100644 index 8debfd7d68..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/picl/plugins/sun4u/blade/Makefile -# - -SUBDIRS= devtree frutree frudata bsc fruaccess .WAIT -MSGSUBDIRS= bsc fruaccess - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -.KEEP_STATE: - -all install clean clobber lint : $(SUBDIRS) - -_msg: $(MSGSUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/Makefile b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/Makefile deleted file mode 100644 index 7274aede33..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/Makefile +++ /dev/null @@ -1,123 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/picl/picl/plugins/sun4u/blade/bsc/Makefile -# -include $(SRC)/Makefile.psm - -LIBRARY= libpicllom.a -VERS= .1 - -OBJECTS= picllom.o - -# include library definitions -include $(SRC)/lib/Makefile.lib - -ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Serverblade1 - -include $(SRC)/cmd/picl/plugins/Makefile.com - -SRCS= $(OBJECTS:%.o=%.c) - -LIBS = $(DYNLIB) - -ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR) - -CONF= picllom.conf -ROOTCONF= $(CONF:%=$(ROOTLIBDIR)/%) -$(ROOTCONF) := FILEMODE = 0644 -INFOS= picllom.info - -LINTSRC = $(LINTLIB:%.ln=%) -ROOTLINTDIR = $(ROOTLIBDIR) -ROOTLINT = $(LINTSRC:%=$(ROOTLINTDIR)/%) - -CLEANFILES= $(LINTOUT) $(LINTLIB) - -CPPFLAGS += -I$(SRC)/uts/sun4u/ -I$(SRC)/uts/common/ -CPPFLAGS += -I$(SRC)/cmd/picl/plugins/lib/picld_pluginutil -CPPFLAGS += -D_REENTRANT -CFLAGS += $(CCVERBOSE) -LINTFLAGS = -uxmn -DYNFLAGS += -R/usr/platform/sun4u/lib/picl/plugins:/usr/lib/picl/plugins -LDLIBS += -L$(SRC)/cmd/picl/plugins/lib/picld_pluginutil/$(MACH) -LDLIBS += -L$(SRC)/lib/libpicltree/$(MACH) -LDLIBS += -L$(SRC)/cmd/picl/plugins/common/piclevent -LDLIBS += -L$(SRC)/cmd/picl/plugins/common/memcfg -LDLIBS += -L$(SRC)/cmd/picl/plugins/common/devtree -LDLIBS += -L$(SRC)/cmd/picl/plugins/common/frutree -LDLIBS += -lpicldevtree -lpiclfrutree -lpicltree -lpicld_pluginutil -LDLIBS += -ldevinfo -lc - -.KEEP_STATE: - -SUBDIRS= - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -POFILE = picllom_blade.po -POFILES = $(SRCS:%.c=%.po) - -all: $(LIBS) $(LIBLINKS) $(CONF) - -install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS) $(ROOTCONF) - -$(POFILE): $(POFILES) - $(CAT) $(POFILES) > $(POFILE) - -_msg: $(MSGDOMAIN) $(POFILE) - $(RM) $(MSGDOMAIN)/$(POFILE) - $(CP) $(POFILE) $(MSGDOMAIN)/$(POFILE) - -$(MSGDOMAIN): - $(INS.dir) - -$(CONF): $(INFOS) - $(RM) $@ - $(CPP) $(INFOS) | \ - $(SED) -e '/^[ ]*$$/d' -e '/^#/d' > $@ - -$(LIBLINKS): FRC - $(RM) $@; $(SYMLINK) $(DYNLIB) $@ - -# include library targets -include $(SRC)/lib/Makefile.targ -include $(SRC)/cmd/picl/plugins/Makefile.targ - -$(ROOTLINTDIR)/%: ../% - $(INS.file) - -lint: - $(LINT.c) $(SRCS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: - diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c deleted file mode 100644 index 462ccc1dec..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c +++ /dev/null @@ -1,1435 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -/* - * This plugin creates PICL nodes and properties for objects handled through - * the blade support chip (BSC). The BSC Solaris land device driver exposes - * information to the plugin and other clients through an existing LOM - * (Lights Out Management) ioctl interface. The plugin only exercises - * a subset of the interface which is known to be supported by the bsc. - * - * All the nodes which may be accessible through the BSC are included below - * the SUNW,bscv node (class system-controller) in the /platform tree. - * This plugin interrogates the BSC to determine which of - * those nodes are actually available. Properties are added to such nodes and - * in the case of volatile properties like temperature, a call-back function - * is established for on-demand access to the current value. - * - * NOTE: - * Depends on PICL devtree plugin. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <alloca.h> -#include <syslog.h> -#include <string.h> -#include <libintl.h> -#include <picl.h> -#include <picltree.h> -#include <errno.h> -#include <limits.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/obpdefs.h> -#include <sys/lom_io.h> -#include <sys/systeminfo.h> -#include <time.h> -#include <picldefs.h> -#include <picld_pluginutil.h> -#include "picllom.h" - -static void picllom_register(void); -static void picllom_init(void); -static void picllom_fini(void); -static node_el_t *create_node_el(picl_nodehdl_t nodeh); -static void delete_node_el(node_el_t *pel); -static node_list_t *create_node_list(); -static void delete_node_list_contents(node_list_t *pnl); -static void delete_node_list(node_list_t *pnl); -static void add_node_to_list(picl_nodehdl_t nodeh, - node_list_t *listp); -static void get_node_list_by_class(picl_nodehdl_t nodeh, - const char *classname, node_list_t *listp); -static int get_lom_node(picl_nodehdl_t *lominfh); -static int get_lom_device_path(picl_nodehdl_t *lominfh); -static int get_node_by_name_and_class(picl_nodehdl_t srchnodeh, - const char *nodename, const char *classname, picl_nodehdl_t *chdh); -static int add_regular_prop(picl_nodehdl_t nodeh, const char *name, - int type, int access, int size, const void *valbuf, picl_prophdl_t *prophp); -static int add_volatile_prop(picl_nodehdl_t nodeh, char *name, - int type, int access, int size, ptree_vol_rdfunc_t rdfunc, - ptree_vol_wrfunc_t wrfunc, picl_prophdl_t *prophp); -static int open_lom_rd(int *lom_fd); -static int get_lom_temp(int index, tempr_t *temp_p); -static int update_voltage_stats(); -static int get_lom_volts_status(int index, int *voltsStatus_p); -static int get_lom_volts_shutdown(int index, int *voltsShutdown_p); -static int update_fan_stats(); -static int get_lom_fan_speed(int index, int *fan_speed); -static int read_vol_temp(ptree_rarg_t *parg, void *buf); -static int read_vol_volts_status(ptree_rarg_t *parg, void *buf); -static int read_vol_volts_shutdown(ptree_rarg_t *parg, void *buf); -static int read_fan_speed(ptree_rarg_t *parg, void *buf); -static int read_fan_status(ptree_rarg_t *parg, void *buf); -static int lookup_led_status(int8_t state, const char **string); -static int read_led_status(ptree_rarg_t *parg, void *buf); -static void convert_node_name(char *ptr); -static int add_temp_sensors(int lom_fd, picl_nodehdl_t lominfh); -static int add_voltage_monitors(int lom_fd, - picl_nodehdl_t lominfh); -static int add_fan_nodes(int lom_fd, picl_nodehdl_t lominfh); -static int get_config_file(char *outfilename); - -#pragma init(picllom_register) - -static picld_plugin_reg_t my_reg_info = { - PICLD_PLUGIN_VERSION_1, - PICLD_PLUGIN_NON_CRITICAL, - "SUNW_picllom", - picllom_init, - picllom_fini -}; - -static const char str_OK[] = "OK"; -static const char str_FAIL[] = "FAIL"; -static const char str_On[] = "on"; -static const char str_Off[] = "off"; -static const char str_Enabled[] = "Enabled"; -static const char str_Disabled[] = "Disabled"; -static char lom_device_path[PATH_MAX]; -static tempr_t high_warnings[MAX_TEMPS]; -static tempr_t high_shutdowns[MAX_TEMPS]; -static picl_prophdl_t temp_handles[MAX_TEMPS]; -static lom_fandata_t fandata; -static picl_prophdl_t fan_speed_handles[MAX_FANS]; -static picl_prophdl_t fan_status_handles[MAX_FANS]; -static lom_volts_t voltsdata; -static picl_prophdl_t volts_status_handles[MAX_VOLTS]; -static picl_prophdl_t volts_shutdown_handles[MAX_VOLTS]; -static int n_leds = 0; -static int max_state_size = 0; -static picl_prophdl_t *led_handles = NULL; -static char **led_labels = NULL; -static lom2_info_t info2data; -static struct { - int size; - char *str_colour; -} colour_lkup[1 + LOM_LED_COLOUR_AMBER]; - -static struct { - int8_t state; - char *str_ledstate; -} ledstate_lkup[] = { - { LOM_LED_OFF }, - { LOM_LED_ON }, - { LOM_LED_BLINKING }, -}; - -static node_el_t * -create_node_el(picl_nodehdl_t nodeh) -{ - node_el_t *ptr = malloc(sizeof (node_el_t)); - - if (ptr != NULL) { - ptr->nodeh = nodeh; - ptr->next = NULL; - } - - return (ptr); -} - -static void -delete_node_el(node_el_t *pel) -{ - free(pel); -} - -static node_list_t * -create_node_list() -{ - node_list_t *ptr = malloc(sizeof (node_list_t)); - - if (ptr != NULL) { - ptr->head = NULL; - ptr->tail = NULL; - } - - return (ptr); -} - -static void -delete_node_list_contents(node_list_t *pnl) -{ - node_el_t *pel; - - if (pnl == NULL) - return; - - while ((pel = pnl->head) != NULL) { - pnl->head = pel->next; - delete_node_el(pel); - } - - pnl->tail = NULL; -} - -static void -delete_node_list(node_list_t *pnl) -{ - delete_node_list_contents(pnl); - free(pnl); -} - -/* - * Get a linking element and add handle to end of chain - */ -static void -add_node_to_list(picl_nodehdl_t nodeh, node_list_t *listp) -{ - node_el_t *pel = create_node_el(nodeh); - - if (pel != NULL) { - if (listp->tail == NULL) - listp->head = pel; - else - listp->tail->next = pel; - - listp->tail = pel; - } -} - -/* - * Get a list of nodes of the specified classname under nodeh. - * Once a node of the specified class is found, its children are not - * searched. - */ -static void -get_node_list_by_class(picl_nodehdl_t nodeh, const char *classname, - node_list_t *listp) -{ - int err; - char clname[PICL_CLASSNAMELEN_MAX+1]; - picl_nodehdl_t chdh; - - /* - * go through the children - */ - err = ptree_get_propval_by_name(nodeh, PICL_PROP_CHILD, &chdh, - sizeof (picl_nodehdl_t)); - - while (err == PICL_SUCCESS) { - err = ptree_get_propval_by_name(chdh, PICL_PROP_CLASSNAME, - clname, strlen(classname) + 1); - - if ((err == PICL_SUCCESS) && (strcmp(clname, classname) == 0)) - add_node_to_list(chdh, listp); - else - get_node_list_by_class(chdh, classname, listp); - - err = ptree_get_propval_by_name(chdh, PICL_PROP_PEER, &chdh, - sizeof (picl_nodehdl_t)); - } -} - -static int -get_lom_node(picl_nodehdl_t *lominfh) -{ - int err = PICL_SUCCESS; - node_list_t *listp; - - listp = create_node_list(); - - if ((err = ptree_get_node_by_path(PICL_NODE_ROOT PICL_NODE_PLATFORM, - lominfh)) != PICL_SUCCESS) { - syslog(LOG_ERR, EM_MISSING_NODE, - PICL_NODE_ROOT PICL_NODE_PLATFORM); - return (err); /* no /platform ! */ - } - - get_node_list_by_class(*lominfh, PICL_CLASS_SERVICE_PROCESSOR, listp); - - if (listp->head == NULL) { - *lominfh = 0; - syslog(LOG_ERR, EM_MISSING_NODE, PICL_CLASS_SERVICE_PROCESSOR); - err = PICL_NODENOTFOUND; - } else { - *lominfh = listp->head->nodeh; - - if (listp->head != listp->tail) - syslog(LOG_ERR, EM_LOM_DUPLICATE); - } - - delete_node_list(listp); - return (err); -} - -static int -get_lom_device_path(picl_nodehdl_t *lominfh) -{ - int err = PICL_SUCCESS; - char devfs_path[PATH_MAX]; - char devices_path[PATH_MAX]; - - err = ptree_get_propval_by_name(*lominfh, PICL_PROP_DEVFS_PATH, - devfs_path, sizeof (devfs_path)); - - /* Build up the full device path and set the global */ - strcpy(devices_path, "/devices"); - strcat(devices_path, devfs_path); - strcat(devices_path, LOM_DEV_MINOR_NAME); - strcpy(lom_device_path, devices_path); - - return (err); - -} - - - - -/* - * Look for a node of specified name and class - * Confine search to nodes one level below that of supplied handle - */ -static int -get_node_by_name_and_class(picl_nodehdl_t srchnodeh, const char *nodename, - const char *classname, picl_nodehdl_t *chdh) -{ - int err; - char namebuf[PATH_MAX]; - - err = ptree_get_propval_by_name(srchnodeh, PICL_PROP_CHILD, chdh, - sizeof (picl_nodehdl_t)); - - while (err == PICL_SUCCESS) { - err = ptree_get_propval_by_name(*chdh, PICL_PROP_NAME, namebuf, - sizeof (namebuf)); - if (err != PICL_SUCCESS) - break; - if (strcmp(namebuf, nodename) == 0) { - err = ptree_get_propval_by_name(*chdh, - PICL_PROP_CLASSNAME, namebuf, sizeof (namebuf)); - if ((err == PICL_SUCCESS) && - (strcmp(namebuf, classname) == 0)) - return (PICL_SUCCESS); - } - err = ptree_get_propval_by_name(*chdh, PICL_PROP_PEER, chdh, - sizeof (picl_nodehdl_t)); - } - - return (err); -} - -/* - * Create and add the specified regular property - */ - -static int -add_regular_prop(picl_nodehdl_t nodeh, const char *name, int type, int access, - int size, const void *valbuf, picl_prophdl_t *prophp) -{ - int err; - ptree_propinfo_t propinfo; - picl_prophdl_t proph; - - err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION, - type, access, size, (char *)name, NULL, NULL); - if (err != PICL_SUCCESS) - return (err); - - err = ptree_create_and_add_prop(nodeh, &propinfo, (void *)valbuf, - &proph); - if (err == PICL_SUCCESS && prophp) - *prophp = proph; - return (err); -} - - -/* - * Create and add the specified volatile property - */ -static int -add_volatile_prop(picl_nodehdl_t nodeh, char *name, int type, int access, - int size, ptree_vol_rdfunc_t rdfunc, ptree_vol_wrfunc_t wrfunc, - picl_prophdl_t *prophp) -{ - int err; - ptree_propinfo_t propinfo; - picl_prophdl_t proph; - - err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION, - type, (access|PICL_VOLATILE), size, name, rdfunc, wrfunc); - if (err != PICL_SUCCESS) - return (err); - - err = ptree_create_and_add_prop(nodeh, &propinfo, NULL, &proph); - if (err == PICL_SUCCESS && prophp) - *prophp = proph; - return (err); -} - -/* - * open LOM device to read - */ -static int -open_lom_rd(int *lom_fd) -{ - *lom_fd = open(lom_device_path, O_RDONLY); - - if (*lom_fd < 0) - return (PICL_FAILURE); - - return (PICL_SUCCESS); -} - -/* - * Function to open LOM and read temperature sensor values. - * The index to a specific sensor is supplied and that value returned. - */ -static int -get_lom_temp(int index, tempr_t *temp_p) -{ - lom_temp_t lom_temp; - int lom_fd; - int err; - int res; - - err = open_lom_rd(&lom_fd); - - if (err == PICL_SUCCESS) { - res = ioctl(lom_fd, LOMIOCTEMP, &lom_temp); - (void) close(lom_fd); - - if (res == 0) { - *temp_p = lom_temp.temp[index]; - } else { - err = PICL_FAILURE; - } - } - - return (err); -} - -/* - * Function to open LOM and read voltage monitor values. - * Called for each property, so only perform update if time has changed - */ -static int -update_voltage_stats() -{ - static time_t then = 0; - int lom_fd; - int err; - int res; - time_t now = time(NULL); - - if (now == then) - return (PICL_SUCCESS); - - then = now; - err = open_lom_rd(&lom_fd); - - if (err == PICL_SUCCESS) { - res = ioctl(lom_fd, LOMIOCVOLTS, &voltsdata); - (void) close(lom_fd); - if (res < 0) { - err = PICL_FAILURE; - } - } - - return (err); -} - -/* - * Function to open LOM and read voltage monitor values. - * The index to a specific voltage status is supplied and that value returned. - */ -static int -get_lom_volts_status(int index, int *voltsStatus_p) -{ - int res; - - if ((res = update_voltage_stats()) != PICL_SUCCESS) - return (res); - - *voltsStatus_p = voltsdata.status[index]; - return (PICL_SUCCESS); -} - -/* - * Function to open LOM and read voltage monitor values. - * The index to a specific shutdown flag is supplied and that value returned. - */ -static int -get_lom_volts_shutdown(int index, int *voltsShutdown_p) -{ - int res; - - if ((res = update_voltage_stats()) != PICL_SUCCESS) - return (res); - - *voltsShutdown_p = voltsdata.shutdown_enabled[index]; - return (PICL_SUCCESS); -} - - - -/* - * Function to open LOM and read fan values. - * Called for each property, so only perform update if time has changed - */ -static int -update_fan_stats() -{ - static time_t then = 0; - int lom_fd; - int err; - int res; - time_t now = time(NULL); - - if (now == then) - return (PICL_SUCCESS); - - then = now; - err = open_lom_rd(&lom_fd); - if (err == PICL_SUCCESS) { - res = ioctl(lom_fd, LOMIOCFANSTATE, &fandata); - (void) close(lom_fd); - if (res < 0) { - err = PICL_FAILURE; - } - } - - return (err); -} - - - -/* - * The index to a specific fan is supplied and its speed value returned. - */ -static int -get_lom_fan_speed(int index, int *fan_speed) -{ - int res; - - if ((res = update_fan_stats()) != PICL_SUCCESS) - return (res); - - *fan_speed = fandata.speed[index]; - return (PICL_SUCCESS); -} - - -/* - * Read function for volatile "Temperature" property via LOM - */ -static int -read_vol_temp(ptree_rarg_t *parg, void *buf) -{ - tempr_t temp; - picl_prophdl_t proph; - int index; - - /* - * get the sensor index from the displacement of the - * property handle and get its temperature. - */ - proph = parg->proph; - for (index = 0; index < MAX_TEMPS; index++) { - if (temp_handles[index] == proph) - break; - } - - if (index == MAX_TEMPS) { - /* - * Handle not found. As this is a plugin, stale handles - * cannot occur, so just fail. - */ - return (PICL_FAILURE); - } - - if (get_lom_temp(index, &temp) != PICL_SUCCESS) - return (PICL_FAILURE); - (void) memcpy(buf, (caddr_t)&temp, sizeof (tempr_t)); - return (PICL_SUCCESS); -} - -/* - * Read function for volatile "VoltageStatus" property via LOM - */ -static int -read_vol_volts_status(ptree_rarg_t *parg, void *buf) -{ - int voltsStatus; - picl_prophdl_t proph; - int index; - - /* - * get the voltage monitor index from the displacement of the - * status property handle and get its status. - */ - proph = parg->proph; - - for (index = 0; index < MAX_VOLTS; index++) { - if (volts_status_handles[index] == proph) - break; - } - - if (index == MAX_VOLTS) - return (PICL_FAILURE); - - if (get_lom_volts_status(index, &voltsStatus) != PICL_SUCCESS) - return (PICL_FAILURE); - - (void) strlcpy(buf, (voltsStatus == 0) ? str_OK : str_FAIL, - sizeof (str_FAIL)); - return (PICL_SUCCESS); -} - -/* - * Read function for volatile "VoltageShutdown" property via LOM - */ -static int -read_vol_volts_shutdown(ptree_rarg_t *parg, void *buf) -{ - int voltsShutdown; - picl_prophdl_t proph; - int index; - - /* - * get the voltage monitor index from the displacement of the - * shutdown property handle and get its value. - */ - proph = parg->proph; - - for (index = 0; index < MAX_VOLTS; index++) { - if (volts_shutdown_handles[index] == proph) - break; - } - - if (index == MAX_VOLTS) - return (PICL_FAILURE); - - if (get_lom_volts_shutdown(index, &voltsShutdown) != PICL_SUCCESS) - return (PICL_FAILURE); - - (void) strlcpy(buf, (voltsShutdown == 0) ? str_Disabled : str_Enabled, - sizeof (str_Disabled)); - return (PICL_SUCCESS); -} - - -/* - * Read function for volatile fan speed property via LOM - */ -static int -read_fan_speed(ptree_rarg_t *parg, void *buf) -{ - int fan_speed; - picl_prophdl_t proph; - int index; - - /* - * get the relevant fan from the displacement of its property handle - */ - proph = parg->proph; - - for (index = 0; index < MAX_FANS; index++) { - if (fan_speed_handles[index] == proph) - break; - } - - if (index == MAX_FANS) - return (PICL_FAILURE); - - if (get_lom_fan_speed(index, &fan_speed) != PICL_SUCCESS) - return (PICL_FAILURE); - - (void) memcpy(buf, (caddr_t)&fan_speed, sizeof (fan_speed)); - return (PICL_SUCCESS); -} - -/* - * look up function to convert led status into string - */ -static int -lookup_led_status(int8_t state, const char **string) -{ - int i; - int lim = sizeof (ledstate_lkup) / sizeof (ledstate_lkup[0]); - - for (i = 0; i < lim; i++) { - if (ledstate_lkup[i].state == state) { - *string = ledstate_lkup[i].str_ledstate; - return (PICL_SUCCESS); - } - } - - *string = ""; - switch (state) { - case LOM_LED_ACCESS_ERROR: - return (PICL_PROPVALUNAVAILABLE); - case LOM_LED_NOT_IMPLEMENTED: - /*FALLTHROUGH*/ - case LOM_LED_OUTOFRANGE: - /*FALLTHROUGH*/ - default: - return (PICL_FAILURE); - } -} - -/* - * Read function for volatile led status property. - */ -static int -read_led_status(ptree_rarg_t *parg, void *buf) -{ - lom_led_state_t led_data; - picl_prophdl_t proph; - int index; - int lom_fd; - int res; - const char *string; - - /* - * get the relevant led from the displacement of its property handle - */ - proph = parg->proph; - - for (index = 0; index < n_leds; index++) { - if (led_handles[index] == proph) - break; - } - - if (index == n_leds) - return (PICL_FAILURE); - - res = open_lom_rd(&lom_fd); - if (res != PICL_SUCCESS) - return (res); - /* - * The interface for reading LED status doesn't promise to maintain - * a constant mapping between LED index number and LED identity - * (as defined by its label). On the other hand, PICL does promise - * that whilst a handle remains valid the object it represents will - * remain constant. To reconcile these positions, we maintain - * tables of labels and handles linked by index value. We search - * for the handle with which we are presented and then locate its - * label. Then we request LED entries from the LOM and compare their - * labels with the one we seek. As an optimisation, we try the original - * index value first and then revert to a full search. - */ - (void) memset(&led_data, 0, sizeof (led_data)); - led_data.index = index; - res = ioctl(lom_fd, LOMIOCLEDSTATE, &led_data); - - if (res != 0 || led_data.state == LOM_LED_NOT_IMPLEMENTED || - strcmp(led_data.label, led_labels[index]) != 0) { - /* - * full scan required (bet it doesn't work!) - * first re-establish the range to scan - */ - int i; - int n; - - (void) memset(&led_data, 0, sizeof (led_data)); - led_data.index = -1; - res = ioctl(lom_fd, LOMIOCLEDSTATE, &led_data); - - if (res != 0) { - (void) close(lom_fd); - return (PICL_PROPVALUNAVAILABLE); - } - - if (led_data.state == LOM_LED_NOT_IMPLEMENTED || - strcmp(led_data.label, led_labels[index]) != 0) { - n = led_data.index; - for (i = 0; i < n; i++) { - (void) memset(&led_data, 0, sizeof (led_data)); - led_data.index = i; - res = ioctl(lom_fd, LOMIOCLEDSTATE, &led_data); - - if (res == 0 && - led_data.state != LOM_LED_NOT_IMPLEMENTED || - strcmp(led_data.label, led_labels[index]) == - 0) { - break; - } - } - - if (i == n) { - (void) close(lom_fd); - return (PICL_PROPVALUNAVAILABLE); - } - } - } - - /* - * if we get here, then we found the right LED. - */ - (void) close(lom_fd); - res = lookup_led_status(led_data.state, &string); - (void) strlcpy(buf, string, max_state_size); - return (res); -} - -/* - * Read function for volatile fan status property. - * This is a synthesized property using speed and min speed properties - */ -static int -read_fan_status(ptree_rarg_t *parg, void *buf) -{ - int fan_speed; - picl_prophdl_t proph; - int index; - - /* - * get the relevant fan from the displacement of its property handle - */ - proph = parg->proph; - - for (index = 0; index < MAX_FANS; index++) { - if (fan_status_handles[index] == proph) - break; - } - - if (index == MAX_FANS) - return (PICL_FAILURE); - - if (get_lom_fan_speed(index, &fan_speed) != PICL_SUCCESS) - return (PICL_FAILURE); - - (void) strlcpy(buf, - fan_speed < fandata.minspeed[index] ? str_FAIL : str_OK, - sizeof (str_FAIL)); - return (PICL_SUCCESS); -} - - - -/* - * change to lower case and convert any spaces into hyphens - */ -static void -convert_node_name(char *ptr) -{ - char ch; - - for (ch = *ptr; ch != '\0'; ch = *++ptr) { - if (isupper(ch)) { - *ptr = tolower(ch); - } else if (isspace(ch)) { - *ptr = '-'; - } - } -} - -static int -add_temp_sensors(int lom_fd, picl_nodehdl_t lominfh) -{ - lom_temp_t lom_temp; - int res; - int i; - int err = PICL_SUCCESS; - const char *cptr; - - res = ioctl(lom_fd, LOMIOCTEMP, &lom_temp); - - if ((res == 0) && (lom_temp.num > 0)) { - /* - * for each temperature location add a sensor node - */ - for (i = 0; i < lom_temp.num; i++) { - picl_nodehdl_t tempsensh; - picl_prophdl_t proph; - - high_warnings[i] = lom_temp.warning[i]; - high_shutdowns[i] = lom_temp.shutdown[i]; - - convert_node_name(lom_temp.name[i]); - - err = ptree_create_node(lom_temp.name[i], - PICL_CLASS_TEMPERATURE_SENSOR, &tempsensh); - if (err != PICL_SUCCESS) - break; - - err = add_volatile_prop(tempsensh, - PICL_PROP_TEMPERATURE, PICL_PTYPE_INT, PICL_READ, - sizeof (tempr_t), read_vol_temp, NULL, - &temp_handles[i]); - if (err != PICL_SUCCESS) - break; - - if (high_warnings[i] != 0) { - err = add_regular_prop( - tempsensh, PICL_PROP_HIGH_WARNING, - PICL_PTYPE_INT, PICL_READ, - sizeof (tempr_t), &high_warnings[i], - &proph); - if (err != PICL_SUCCESS) - break; - } - - if (high_shutdowns[i] != 0) { - err = add_regular_prop( - tempsensh, PICL_PROP_HIGH_SHUTDOWN, - PICL_PTYPE_INT, PICL_READ, - sizeof (tempr_t), &high_shutdowns[i], - &proph); - if (err != PICL_SUCCESS) - break; - } - - /* - * for the benefit of prtdiag, add a label of - * either enclosure or die where appropriate - */ - if ((strcasestr(lom_temp.name[i], CPU_ENCLOSURE) != - NULL) || - (strcasestr(lom_temp.name[i], CPU_AMBIENT) != - NULL)) { - cptr = CPU_AMBIENT; - } else if ((cptr = strcasestr(lom_temp.name[i], - CPU_DIE)) != NULL) { - cptr = CPU_DIE; - } - - if (cptr != NULL) { - err = add_regular_prop( - tempsensh, PICL_PROP_LABEL, - PICL_PTYPE_CHARSTRING, PICL_READ, - strlen(cptr) + 1, cptr, &proph); - - if (err != PICL_SUCCESS) { - break; - } - } - - err = ptree_add_node(lominfh, tempsensh); - - if (err != PICL_SUCCESS) - break; - } - - if (err != PICL_SUCCESS) { - syslog(LOG_ERR, EM_LOMINFO_TREE_FAILED); - } - } - - return (err); -} - -static int -add_voltage_monitors(int lom_fd, picl_nodehdl_t lominfh) -{ - int res; - int i; - int err = PICL_SUCCESS; - picl_prophdl_t proph; - - res = ioctl(lom_fd, LOMIOCVOLTS, &voltsdata); - - if ((res == 0) && (voltsdata.num > 0)) { - /* - * for each voltage monitor add a monitor node - */ - for (i = 0; i < voltsdata.num; i++) { - picl_nodehdl_t voltsmonh; - - convert_node_name(voltsdata.name[i]); - - err = ptree_create_node(voltsdata.name[i], - PICL_CLASS_VOLTAGE_INDICATOR, &voltsmonh); - if (err != PICL_SUCCESS) - break; - - err = add_regular_prop(voltsmonh, PICL_PROP_LABEL, - PICL_PTYPE_CHARSTRING, PICL_READ, - strlen(voltsdata.name[i]) + 1, - voltsdata.name[i], &proph); - if (err != PICL_SUCCESS) - break; - - err = add_volatile_prop(voltsmonh, PICL_VOLTS_SHUTDOWN, - PICL_PTYPE_CHARSTRING, PICL_READ, - sizeof (str_Disabled), read_vol_volts_shutdown, - NULL, &volts_shutdown_handles[i]); - if (err != PICL_SUCCESS) - break; - - err = add_volatile_prop(voltsmonh, PICL_PROP_CONDITION, - PICL_PTYPE_CHARSTRING, PICL_READ, - sizeof (str_FAIL), read_vol_volts_status, NULL, - &volts_status_handles[i]); - if (err != PICL_SUCCESS) - break; - - err = ptree_add_node(lominfh, voltsmonh); - - if (err != PICL_SUCCESS) - break; - } - - if (err != PICL_SUCCESS) { - syslog(LOG_ERR, EM_LOMINFO_TREE_FAILED); - } - } - - return (err); -} - -static void -add_led(const lom_led_state_t *led_state, picl_nodehdl_t lominfh) -{ - int err; - picl_nodehdl_t ledh; - picl_nodehdl_t proph; - - if (((unsigned char)led_state->state == LOM_LED_STATE_NOT_PRESENT) || - (led_state->label[0] == '\0')) { - return; - } - - err = ptree_create_node(led_state->label, PICL_CLASS_LED, &ledh); - /* - * the led may exist already, e.g. Fault - */ - if (err != PICL_SUCCESS) - return; - - /* - * Unlike LEDs derived from other interfaces, these are not - * writable. Establish a read-only volatile property. - */ - err = add_volatile_prop(ledh, PICL_PROP_STATE, PICL_PTYPE_CHARSTRING, - PICL_READ, max_state_size, read_led_status, NULL, - &led_handles[led_state->index]); - if (err != PICL_SUCCESS) - return; - - /* - * if colour was defined for this LED, add a colour property - */ - if ((led_state->colour != LOM_LED_COLOUR_NONE) && - (led_state->colour != LOM_LED_COLOUR_ANY)) { - err = add_regular_prop(ledh, PICL_PROP_COLOR, - PICL_PTYPE_CHARSTRING, PICL_READ, - colour_lkup[led_state->index].size, - colour_lkup[led_state->index].str_colour, &proph); - } - if (err != PICL_SUCCESS) - return; - - err = add_regular_prop(ledh, PICL_PROP_LABEL, - PICL_PTYPE_CHARSTRING, PICL_READ, strlen(led_state->label) + 1, - led_state->label, &proph); - if (err != PICL_SUCCESS) - return; - - err = ptree_add_node(lominfh, ledh); - - if (err != PICL_SUCCESS) { - syslog(LOG_ERR, EM_LOMINFO_TREE_FAILED); - } -} - -static void -fixstate(uint8_t state, const char *string, int *max_len) -{ - int i; - int len; - - for (i = 0; i < (sizeof (ledstate_lkup) / sizeof (ledstate_lkup[0])); - i++) { - if (ledstate_lkup[i].state == state) { - if (ledstate_lkup[i].str_ledstate != NULL) - free(ledstate_lkup[i].str_ledstate); - ledstate_lkup[i].str_ledstate = strdup(string); - len = strlen(string); - if (len >= *max_len) - *max_len = len + 1; - break; - } - } -} - -static void -add_led_nodes(int lom_fd, picl_nodehdl_t lominfh) -{ - lom_led_state_t led_data; - picl_nodehdl_t ledh; - int res; - int i; - - /* - * If the led state enquiry ioctl is supported, an enquiry on - * index -1 will return the state of the highest supported index - * value. - */ - (void) memset(&led_data, 0, sizeof (led_data)); - led_data.index = -1; - res = ioctl(lom_fd, LOMIOCLEDSTATE, &led_data); - - if (res != 0) - return; - - if (led_labels != NULL) { - for (i = 0; i < n_leds; i++) { - if (led_labels[i] != NULL) { - free(led_labels[i]); - } - } - - free(led_labels); - led_labels = NULL; - } - - if (led_handles != NULL) { - free(led_handles); - } - - n_leds = 0; - led_handles = calloc(led_data.index + 1, sizeof (picl_nodehdl_t)); - led_labels = calloc(led_data.index + 1, sizeof (char *)); - - if ((led_labels == NULL) || (led_handles == NULL)) { - if (led_labels != NULL) - free(led_labels); - if (led_handles != NULL) - free(led_handles); - led_labels = NULL; - led_handles = NULL; - syslog(LOG_ERR, EM_NO_LED_MEM); - return; - } - - n_leds = led_data.index + 1; - - /* - * For each LED with a valid state, add a node - * and because of the ludicrous API, stache a copy of its label too - */ - for (i = 0; i < n_leds; i++) { - (void) memset(&led_data, 0, sizeof (led_data)); - led_data.index = i; - res = ioctl(lom_fd, LOMIOCLEDSTATE, &led_data); - - if (res != 0) - continue; - - if (led_data.state == LOM_LED_OUTOFRANGE || - led_data.state == LOM_LED_NOT_IMPLEMENTED) - continue; - - - led_labels[i] = strdup(led_data.label); - convert_node_name(led_data.label); - - if (get_node_by_name_and_class(lominfh, led_data.label, - "led", &ledh) != PICL_SUCCESS) { - /* - * only add a new led node, - * if it's not already in place - */ - add_led(&led_data, lominfh); - } - } -} - -static int -add_fan_nodes(int lom_fd, picl_nodehdl_t lominfh) -{ - int res; - int i; - int err = PICL_SUCCESS; - - res = ioctl(lom_fd, LOMIOCFANSTATE, &fandata); - - if (res == 0) { - /* - * fan data available through lom, remove any placeholder - * fan-unit nodes, they will be superseded via lom.conf - */ - char path[80]; - int slot; - picl_nodehdl_t fan_unit_h; - - for (slot = 0; slot < MAX_FANS; slot++) { - (void) snprintf(path, sizeof (path), - "/frutree/chassis/fan-slot?Slot=%d/fan-unit", slot); - if (ptree_get_node_by_path(path, &fan_unit_h) != - PICL_SUCCESS) - continue; - if (ptree_delete_node(fan_unit_h) != PICL_SUCCESS) - continue; - (void) ptree_destroy_node(fan_unit_h); - } - /* - * see if fan names can be obtained - */ - (void) memset(&info2data, 0, sizeof (info2data)); - /* - * if LOMIOCINFO2 not supported, names area - * will remain empty - */ - (void) ioctl(lom_fd, LOMIOCINFO2, &info2data); - - /* - * for each fan which is present, add a fan node - */ - for (i = 0; i < MAX_FANS; i++) { - char fanname[80]; - picl_nodehdl_t fanh; - picl_nodehdl_t proph; - - if (fandata.fitted[i] == 0) - continue; - - if (info2data.fan_names[i][0] == '\0') { - (void) snprintf(fanname, sizeof (fanname), - "fan%d", i + 1); - } else { - (void) strlcpy(fanname, info2data.fan_names[i], - sizeof (fanname)); - } - convert_node_name(fanname); - err = ptree_create_node(fanname, PICL_CLASS_FAN, &fanh); - if (err != PICL_SUCCESS) - break; - - err = add_volatile_prop(fanh, PICL_PROP_FAN_SPEED, - PICL_PTYPE_INT, PICL_READ, sizeof (int), - read_fan_speed, NULL, &fan_speed_handles[i]); - if (err != PICL_SUCCESS) - break; - - err = add_regular_prop(fanh, PICL_PROP_LOW_WARNING, - PICL_PTYPE_INT, PICL_READ, sizeof (int), - &fandata.minspeed[i], &proph); - if (err != PICL_SUCCESS) - break; - - err = add_regular_prop(fanh, PICL_PROP_FAN_SPEED_UNIT, - PICL_PTYPE_CHARSTRING, PICL_READ, sizeof ("%"), - "%", &proph); - if (err != PICL_SUCCESS) - break; - - err = add_volatile_prop(fanh, PICL_PROP_CONDITION, - PICL_PTYPE_CHARSTRING, PICL_READ, - sizeof (str_FAIL), read_fan_status, NULL, - &fan_status_handles[i]); - if (err != PICL_SUCCESS) - break; - - /* - * add a label for prtdiag - */ - err = add_regular_prop(fanh, PICL_PROP_LABEL, - PICL_PTYPE_CHARSTRING, PICL_READ, - strlen(fanname) + 1, fanname, &proph); - if (err != PICL_SUCCESS) - break; - - err = ptree_add_node(lominfh, fanh); - if (err != PICL_SUCCESS) - break; - } - - if (err != PICL_SUCCESS) { - syslog(LOG_ERR, EM_LOMINFO_TREE_FAILED); - } - } - - return (err); -} - -static void -setup_strings() -{ - /* - * initialise led colours lookup - */ - int i; - int lim = sizeof (colour_lkup) / sizeof (colour_lkup[0]); - - for (i = 0; i < lim; i++) { - if (colour_lkup[i].str_colour != NULL) - free(colour_lkup[i].str_colour); - } - - colour_lkup[LOM_LED_COLOUR_ANY].str_colour = strdup(gettext("any")); - colour_lkup[LOM_LED_COLOUR_WHITE].str_colour = strdup(gettext("white")); - colour_lkup[LOM_LED_COLOUR_BLUE].str_colour = strdup(gettext("blue")); - colour_lkup[LOM_LED_COLOUR_GREEN].str_colour = strdup(gettext("green")); - colour_lkup[LOM_LED_COLOUR_AMBER].str_colour = strdup(gettext("amber")); - - for (i = 0; i < lim; i++) { - if (colour_lkup[i].str_colour != NULL) - colour_lkup[i].size = - 1 + strlen(colour_lkup[i].str_colour); - } - - /* - * initialise led state lookup strings - */ - fixstate(LOM_LED_OFF, gettext("off"), &max_state_size); - fixstate(LOM_LED_ON, gettext("on"), &max_state_size); - fixstate(LOM_LED_BLINKING, gettext("blinking"), &max_state_size); -} - -/* - * The size of outfilename must be PATH_MAX - */ -static int -get_config_file(char *outfilename) -{ - char nmbuf[SYS_NMLN]; - char pname[PATH_MAX]; - - if (sysinfo(SI_PLATFORM, nmbuf, sizeof (nmbuf)) != -1) { - (void) snprintf(pname, PATH_MAX, PICLD_PLAT_PLUGIN_DIRF, nmbuf); - (void) strlcat(pname, LOM_CONFFILE_NAME, PATH_MAX); - if (access(pname, R_OK) == 0) { - (void) strlcpy(outfilename, pname, PATH_MAX); - return (0); - } - } - - if (sysinfo(SI_MACHINE, nmbuf, sizeof (nmbuf)) != -1) { - (void) snprintf(pname, PATH_MAX, PICLD_PLAT_PLUGIN_DIRF, nmbuf); - (void) strlcat(pname, LOM_CONFFILE_NAME, PATH_MAX); - if (access(pname, R_OK) == 0) { - (void) strlcpy(outfilename, pname, PATH_MAX); - return (0); - } - } - - (void) snprintf(pname, PATH_MAX, "%s/%s", PICLD_COMMON_PLUGIN_DIR, - LOM_CONFFILE_NAME); - - if (access(pname, R_OK) == 0) { - (void) strlcpy(outfilename, pname, PATH_MAX); - return (0); - } - - return (-1); -} - - - -/* - * executed as part of .init when the plugin is dlopen()ed - */ -static void -picllom_register(void) -{ - (void) picld_plugin_register(&my_reg_info); -} - -/* - * Init entry point of the plugin - * Creates the PICL nodes and properties in the physical and logical aspects. - */ -static void -picllom_init(void) -{ - picl_nodehdl_t rooth; - picl_nodehdl_t plfh; - picl_nodehdl_t lominfh; - int lom_fd; - char fullfilename[PATH_MAX]; - - /* - * Get platform node - */ - if (ptree_get_node_by_path(PICL_NODE_ROOT PICL_NODE_PLATFORM, &plfh) - != PICL_SUCCESS) { - syslog(LOG_ERR, EM_MISSING_NODE, PICL_NODE_PLATFORM); - syslog(LOG_ERR, EM_INIT_FAILED); - return; - } - - /* - * Get lom node - */ - if (get_lom_node(&lominfh) != PICL_SUCCESS) { - syslog(LOG_ERR, EM_LOM_NODE_MISSING); - syslog(LOG_ERR, EM_INIT_FAILED); - return; - } - - /* - * Retrive the device path to open - */ - if (get_lom_device_path(&lominfh) < 0) { - syslog(LOG_ERR, EM_INIT_FAILED); - return; - } - - /* - * Open LOM device and interrogate for devices it monitors - */ - if ((lom_fd = open(lom_device_path, O_RDONLY)) < 0) { - syslog(LOG_ERR, EM_SYS_ERR, lom_device_path, strerror(errno)); - return; - } - - setup_strings(); - (void) add_temp_sensors(lom_fd, lominfh); - (void) add_voltage_monitors(lom_fd, lominfh); - (void) add_fan_nodes(lom_fd, lominfh); - add_led_nodes(lom_fd, lominfh); - - - if (get_config_file(fullfilename) < 0) { - (void) close(lom_fd); - syslog(LOG_ERR, EM_NO_CONFIG); - return; - } - - if (ptree_get_root(&rooth) != PICL_SUCCESS) { - (void) close(lom_fd); - return; - } - - if (picld_pluginutil_parse_config_file(rooth, fullfilename) != - PICL_SUCCESS) - syslog(LOG_ERR, EM_INIT_FAILED); - - (void) close(lom_fd); -} - -/* - * fini entry point of the plugin - */ -static void -picllom_fini(void) -{ -} diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.h b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.h deleted file mode 100644 index 193eef2c76..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _PICLLOM_H -#define _PICLLOM_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Log message texts - */ -#define EM_INIT_FAILED gettext("SUNW_picllom: init failed!\n") -#define EM_MISSING_NODE gettext("SUNW_picllom: no %s node!\n") -#define EM_LOM_MISSING \ - gettext("SUNW_picllom: Lights Out Module missing!\n") -#define EM_LOM_NODE_MISSING \ - gettext("SUNW_picllom: failed to locate LOM device node\n") -#define EM_LOM_DUPLICATE \ - gettext("SUNW_picllom: more than one LOM device node found\n") -#define EM_CREATE_FAILED \ - gettext("SUNW_picllom: failed to create %s node\n") -#define EM_NO_LED_MEM \ - gettext("SUNW_picllom: couldn't get memory for LED nodes\n") -#define EM_LOMINFO_TREE_FAILED \ - gettext("SUNW_picllom: failed to initialize lom nodes\n") -#define EM_SYS_ERR gettext("SUNW_picllom: %s: %s\n") -#define EM_NO_CONFIG \ - gettext("SUNW_picllom: no config file picllom.conf") - -/* - * define for super-user uid - used in credential checking - */ -#define SUPER_USER ((uid_t)0) - -/* - * CPU temperature sensor labels - * prtdiag relies on the labels "ambient" and "die" when reporting CPU temp. - */ -#define CPU_ENCLOSURE "Enclosure" -#define CPU_AMBIENT "Ambient" -#define CPU_DIE "Die" - -/* - * Constants for some PICL properties - */ -#define PICL_VOLTS_SHUTDOWN "VoltageShutdown" - -/* - * Config file name - */ -#define LOM_CONFFILE_NAME "picllom.conf" - -/* - * lom device mnior name - */ -#define LOM_DEV_MINOR_NAME ":lom" - -typedef int16_t tempr_t; - -typedef int (*ptree_vol_rdfunc_t)(ptree_rarg_t *arg, void *buf); -typedef int (*ptree_vol_wrfunc_t)(ptree_warg_t *arg, const void *buf); - -typedef struct node_el { - picl_nodehdl_t nodeh; - struct node_el *next; -} node_el_t; - -typedef struct node_list { - node_el_t *head; - node_el_t *tail; -} node_list_t; - -#ifdef __cplusplus -} -#endif - -#endif /* _PICLLOM_H */ diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.info b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.info deleted file mode 100644 index 06f97f5076..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.info +++ /dev/null @@ -1,179 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * #ident "%Z%%M% %I% %E% SMI" - * - * supported prop types: void, int, uint, float, string - * supported prop access_modes: r, w, rw - * - * VERSION <version_number> -- supported version number is 1.0 - * - * name:<namepath> -- gives the anchor node - * where <namepath> is <nodename>[@<bus-addr>][?<prop>=<val>] - * - * _class:<classpath> -- gives the anchor node - * where <classpath> is <classname>[@<bus-addr>][?<prop>=<val>] - * - * NODE <name> <class> - * {describes a subtree} - * ENDNODE - * - * PROP <name> <type> <access_mode> [<size> <value>] -- per property - * - * REFPROP <name> <dstnode> - * - * REFNODE <name> <class> with <destnode> -- Associates a new node - * with <destnode> if exists - * where - * <name> is the nodename - * <class> is the picl class. - * <destnode> is name:<namepath> or _class:<classpath> - * - * If "name:" or "_class:" is not specified in the <path>, - * the default is "name:" - * - */ -VERSION 1.1 -VERBOSE 1 - -/* Add a fan fru if the cpu fan node is present to the fan slot */ -name:/frutree/chassis/system-board/fan-slot?Slot=0 -REFNODE cpu-fan fru WITH name:/platform/pci/isa/bscbus/bscv/cpu_fan?_class=fan - -/* Add _fru_parent and Environment tables from cpu nodes */ -name:/platform/SUNW,UltraSPARC-IIe@0,0 -REFPROP _fru_parent name:/frutree/chassis/system-board/cpu-slot?Slot=0/cpu-module -TABLE Environment -ROW -PROP Class string r 0 "temperature-sensor" -REFPROP _temperature-sensor_ name:/platform/pci/isa/bscbus/bscv/cpu-die?_class=temperature-sensor -ENDROW -ROW -PROP Class string r 0 "temperature-sensor" -REFPROP _temperature-sensor_ name:/platform/pci/isa/bscbus/bscv/enclosure?_class=temperature-sensor -ENDROW -ROW -PROP Class string r 0 "fan" -REFPROP _fan_ name:/platform/pci/isa/bscbus/bscv/cpu_fan?_class=fan -ENDROW -ENDTABLE - - -/* Set the colour property of the leds */ -name:/platform/pci/isa/bscbus/bscv/active?_class=led -PROP Color string r 0 "green" -name:/platform/pci/isa/bscbus/bscv/svc_reqd?_class=led -PROP Color string r 0 "amber" -name:/platform/pci/isa/bscbus/bscv/rdy_to_rmv?_class=led -PROP Color string r 0 "blue" - -/* Add Devices tables from fru nodes to platform tree counterparts */ - -name:/frutree/chassis -TABLE Devices -ROW -PROP Class string r 0 "led" -REFPROP _led_ name:/platform/pci/isa/bscbus/bscv/active?_class=led -ENDROW -ROW -PROP Class string r 0 "led" -REFPROP _led_ name:/platform/pci/isa/bscbus/bscv/svc_reqd?_class=led -ENDROW -ROW -PROP Class string r 0 "led" -REFPROP _led_ name:/platform/pci/isa/bscbus/bscv/rdy_to_rmv?_class=led -ENDROW -ENDTABLE - - -name:/frutree/chassis/system-board -TABLE Devices -ROW -PROP Class string r 0 "voltage-indicator" -REFPROP _voltage-indicator_ name:/platform/pci/isa/bscbus/bscv/5v?_class=voltage-indicator -ENDROW -ROW -PROP Class string r 0 "voltage-indicator" -REFPROP _voltage-indicator_ name:/platform/pci/isa/bscbus/bscv/3.3v?_class=voltage-indicator -ENDROW -ROW -PROP Class string r 0 "voltage-indicator" -REFPROP _voltage-indicator_ name:/platform/pci/isa/bscbus/bscv/2.5v?_class=voltage-indicator -ENDROW -ROW -PROP Class string r 0 "voltage-indicator" -REFPROP _voltage-indicator_ name:/platform/pci/isa/bscbus/bscv/vcore?_class=voltage-indicator -ENDROW -ENDTABLE - - -name:/frutree/chassis/system-board/fan-slot?Slot=0/cpu-fan -TABLE Devices -ROW -PROP Class string r 0 "fan" -REFPROP _fan_ name:/platform/pci/isa/bscbus/bscv/cpu_fan?_class=fan -ENDROW -ENDTABLE - - -name:/frutree/chassis/system-board/cpu-slot?Slot=0/cpu-module -Table Devices -ROW -PROP Class string r 0 "temperature-sensor" -REFPROP _temperature-sensor_ name:/platform/pci/isa/bscbus/bscv/cpu-die?_class=temperature-sensor -ENDROW -ROW -PROP Class string r 0 "temperature-sensor" -REFPROP _temperature-sensor_ name:/platform/pci/isa/bscbus/bscv/enclosure?_class=temperature-sensor -ENDROW -ENDTABLE - - -/* now link back with _fru_parents */ - -name:/platform/pci/isa/bscbus/bscv/cpu_fan?_class=fan -REFPROP _fru_parent name:/frutree/chassis/system-board/fan-slot?Slot=0/cpu-fan - -name:/platform/pci/isa/bscbus/bscv/cpu-die?_class=temperature-sensor -REFPROP _fru_parent name:/frutree/chassis/system-board/cpu-slot?Slot=0/cpu-module -name:/platform/pci/isa/bscbus/bscv/enclosure?_class=temperature-sensor -REFPROP _fru_parent name:/frutree/chassis/system-board/cpu-slot?Slot=0/cpu-module - -name:/platform/pci/isa/bscbus/bscv/5v?_class=voltage-indicator -REFPROP _fru_parent name:/frutree/chassis/system-board -name:/platform/pci/isa/bscbus/bscv/3.3v?_class=voltage-indicator -REFPROP _fru_parent name:/frutree/chassis/system-board -name:/platform/pci/isa/bscbus/bscv/2.5v?_class=voltage-indicator -REFPROP _fru_parent name:/frutree/chassis/system-board -name:/platform/pci/isa/bscbus/bscv/vcore?_class=voltage-indicator -REFPROP _fru_parent name:/frutree/chassis/system-board - -name:/platform/pci/isa/bscbus/bscv/active?_class=led -REFPROP _fru_parent name:/frutree/chassis -name:/platform/pci/isa/bscbus/bscv/svc_reqd?_class=led -REFPROP _fru_parent name:/frutree/chassis -name:/platform/pci/isa/bscbus/bscv/rdy_to_rmv?_class=led -REFPROP _fru_parent name:/frutree/chassis - diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/devtree/Makefile b/usr/src/cmd/picl/plugins/sun4u/blade/devtree/Makefile deleted file mode 100644 index 22648acd00..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/devtree/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/picl/plugins/sun4u/blade/devtree/Makefile -# -include $(SRC)/Makefile.psm - -# include library definitions -include $(SRC)/lib/Makefile.lib - -ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Serverblade1 - -include $(SRC)/cmd/picl/plugins/Makefile.com - -ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR) - -CONF= picldevtree.conf -ROOTCONF= $(CONF:%=$(ROOTLIBDIR)/%) -$(ROOTCONF) := FILEMODE = 0644 - -ROOTLINTDIR = $(ROOTLIBDIR) - -.KEEP_STATE: - -SUBDIRS= - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint - -all: - -install: $(ROOTLIBDIR) $(ROOTCONF) - -# include library targets -include $(SRC)/lib/Makefile.targ -include $(SRC)/cmd/picl/plugins/Makefile.targ - -$(ROOTLINTDIR)/%: ../% - $(INS.file) - -lint: - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/devtree/picldevtree.conf b/usr/src/cmd/picl/plugins/sun4u/blade/devtree/picldevtree.conf deleted file mode 100644 index f3e98dac57..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/devtree/picldevtree.conf +++ /dev/null @@ -1,28 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# -# Platform specific .conf file for picldevtree plug-in -bscv service-processor diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/Makefile b/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/Makefile deleted file mode 100644 index c75189a6e4..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/Makefile +++ /dev/null @@ -1,119 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/picl/plugins/sun4u/blade/fruaccess/Makefile -# -LIBRARY= libfruaccess.a -VERS= .1 -OBJECTS= fru_access.o crcutils.o crcmodel.o - -# include library definitions -include $(SRC)/Makefile.psm -include $(SRC)/lib/Makefile.lib - -ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Serverblade1 - -include $(SRC)/cmd/picl/plugins/Makefile.com - -SRCS= fru_access.c ../../lib/fruaccess/crcutils.c \ - ../../lib/fruaccess/crcmodel.c - -SRCDIR= ../../lib/fruaccess/. - -LIBS= $(DYNLIB) - -ROOTLIBDIR = $(ROOT_PLATFORM)/lib - -CONF = fru_container.conf -ROOTCONF= $(CONF:%=$(ROOTLIBDIR)/%) -$(ROOTCONF) := FILEMODE = 0644 - - -CLEANFILES= $(LINTOUT) $(LINTLIB) -CLOBBERFILES += $(LIBLINKS) -CSTYLE = cstyle -p -P -HDRCHK = hdrchk - - -CPPFLAGS += -I$(SRC)/lib/libfru/include -CPPFLAGS += -I$(SRC)/lib/libfruutils/ -CPPFLAGS += -I$(SRC)/cmd/picl/plugins/sun4u/lib/fruaccess -CFLAGS += $(CCVERBOSE) -DBIG_ENDIAN -LDLIBS += -L$(SRC)/lib/libfruutils/$(MACH) -LDLIBS += -lc -lpicltree -lfruutils -LDLIBS += -ldevinfo -LDLIBS += -Wl,-f/opt/SUNWSMS/lib/$(DYNLIBPSR) # SMS before platform -LDLIBS += -Wl,-f/usr/platform/\$$PLATFORM/lib/$(DYNLIBPSR) - - -.KEEP_STATE: - - -SUBDIRS= - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -LN = ln -s - -POFILE= $(LIBRARY:.a=.po) - -all: $(DYNLIB) $(LIBLINKS) $(CONF) - -install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS) $(ROOTCONF) - -_msg: $(MSGDOMAIN) $(POFILE) - $(RM) $(MSGDOMAIN)/$(POFILE) - $(CP) $(POFILE) $(MSGDOMAIN) - -$(POFILE): - $(RM) $@ messages.po - $(XGETTEXT) $(XGETFLAGS) *.[ch]* */*.[ch]* - $(SED) -e '/^# msg/d' -e '/^domain/d' messages.po > $@ - $(RM) messages.po - -$(MSGDOMAIN): - $(INS.dir) - -$(LIBLINKS): FRC - $(RM) $@; $(SYMLINK) $(DYNLIB) $@ - -check-style: - $(CSTYLE) *.cc *.c *.h - $(HDRCHK) *.h - -# include library targets -include $(SRC)/cmd/picl/plugins/Makefile.targ -include $(SRC)/lib/Makefile.targ - -lint : - $(LINT.c) -m $(SRCS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_access.c b/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_access.c deleted file mode 100644 index 5eb01b4ec6..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_access.c +++ /dev/null @@ -1,2746 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <limits.h> -#include <alloca.h> -#include "fru_access_impl.h" - -#pragma init(initialize_fruaccess) /* .init section */ - -static hash_obj_t *hash_table[TABLE_SIZE]; - -/* - * seeprom is the driver_name for the SEEPROM device drivers in excalibur - * Define the devfsadm command to load the seeprom drivers if open fails. - */ - -static char devfsadm_cmd[] = "/usr/sbin/devfsadm -i seeprom"; - -/* this routine initialize the hash table. */ - -static void -initialize_fruaccess(void) -{ - int count; - for (count = 0; count < TABLE_SIZE; count++) { - hash_table[count] = NULL; - } -} - -/* - * called to lookup hash object for specified handle in the hash table. - * - */ - -static hash_obj_t * -lookup_handle_object(handle_t handle, int object_type) -{ - handle_t index_to_hash; - hash_obj_t *first_hash_obj; - hash_obj_t *next_hash_obj; - - index_to_hash = (handle % TABLE_SIZE); - - first_hash_obj = hash_table[index_to_hash]; - for (next_hash_obj = first_hash_obj; next_hash_obj != NULL; - next_hash_obj = next_hash_obj->next) { - if ((handle == next_hash_obj->obj_hdl) && - (object_type == next_hash_obj->object_type)) { - return (next_hash_obj); - } - } - return (NULL); -} - -/* called to allocate container hash object */ - -static hash_obj_t * -create_container_hash_object(void) -{ - hash_obj_t *hash_obj; - container_obj_t *cont_obj; - - cont_obj = malloc(sizeof (container_obj_t)); - if (cont_obj == NULL) { - return (NULL); - } - - hash_obj = malloc(sizeof (hash_obj_t)); - if (hash_obj == NULL) { - free(cont_obj); - return (NULL); - } - - cont_obj->sec_obj_list = NULL; - - hash_obj->object_type = CONTAINER_TYPE; - hash_obj->u.cont_obj = cont_obj; - hash_obj->next = NULL; - hash_obj->prev = NULL; - - return (hash_obj); -} - -/* called to allocate section hash object */ - -static hash_obj_t * -create_section_hash_object(void) -{ - hash_obj_t *hash_obj; - section_obj_t *sec_obj; - - sec_obj = malloc(sizeof (section_obj_t)); - if (sec_obj == NULL) { - return (NULL); - } - - hash_obj = malloc(sizeof (hash_obj_t)); - if (hash_obj == NULL) { - free(sec_obj); - return (NULL); - } - - sec_obj->next = NULL; - sec_obj->seg_obj_list = NULL; - - hash_obj->u.sec_obj = sec_obj; - hash_obj->object_type = SECTION_TYPE; - hash_obj->next = NULL; - hash_obj->prev = NULL; - - return (hash_obj); -} - -/* called to allocate segment hash object */ - -static hash_obj_t * -create_segment_hash_object(void) -{ - hash_obj_t *hash_obj; - segment_obj_t *seg_obj; - - seg_obj = malloc(sizeof (segment_obj_t)); - if (seg_obj == NULL) { - return (NULL); - } - - hash_obj = malloc(sizeof (hash_obj_t)); - if (hash_obj == NULL) { - free(seg_obj); - return (NULL); - } - - seg_obj->next = NULL; - seg_obj->pkt_obj_list = NULL; - - hash_obj->object_type = SEGMENT_TYPE; - hash_obj->u.seg_obj = seg_obj; - hash_obj->next = NULL; - hash_obj->prev = NULL; - - return (hash_obj); -} - -/* called to allocate packet hash object */ - -static hash_obj_t * -create_packet_hash_object(void) -{ - hash_obj_t *hash_obj; - packet_obj_t *pkt_obj; - - pkt_obj = malloc(sizeof (packet_obj_t)); - if (pkt_obj == NULL) { - return (NULL); - } - - hash_obj = malloc(sizeof (hash_obj_t)); - if (hash_obj == NULL) { - free(pkt_obj); - return (NULL); - } - - pkt_obj->next = NULL; - - hash_obj->object_type = PACKET_TYPE; - hash_obj->u.pkt_obj = pkt_obj; - hash_obj->next = NULL; - hash_obj->prev = NULL; - - return (hash_obj); -} - -/* called to add allocated hash object into the hash table */ - -static void -add_hashobject_to_hashtable(hash_obj_t *hash_obj) -{ - handle_t index_to_hash; - static uint64_t handle_count = 0; - - hash_obj->obj_hdl = ++handle_count; /* store the handle */ - - /* where to add ? */ - index_to_hash = ((hash_obj->obj_hdl) % TABLE_SIZE); - - hash_obj->next = hash_table[index_to_hash]; - hash_table[index_to_hash] = hash_obj; /* hash obj. added */ - - if (hash_obj->next != NULL) { - hash_obj->next->prev = hash_obj; - } -} - -/* called to add section object list into the section list */ - -static void -add_to_sec_object_list(hash_obj_t *parent_obj, hash_obj_t *child_obj) -{ - hash_obj_t *next_hash; - - child_obj->u.sec_obj->cont_hdl = parent_obj->obj_hdl; - if (parent_obj->u.cont_obj->sec_obj_list == NULL) { - parent_obj->u.cont_obj->sec_obj_list = child_obj; - return; - } - - for (next_hash = parent_obj->u.cont_obj->sec_obj_list; - next_hash->u.sec_obj->next != NULL; - next_hash = next_hash->u.sec_obj->next) { - ; - } - - next_hash->u.sec_obj->next = child_obj; -} - -/* called to add segment object list into segment list */ - -static void -add_to_seg_object_list(hash_obj_t *parent_obj, hash_obj_t *child_obj) -{ - hash_obj_t *next_hash; - - child_obj->u.seg_obj->section_hdl = parent_obj->obj_hdl; - if (parent_obj->u.sec_obj->seg_obj_list == NULL) { - parent_obj->u.sec_obj->seg_obj_list = child_obj; - return; - } - - for (next_hash = parent_obj->u.sec_obj->seg_obj_list; - next_hash->u.seg_obj->next != NULL; - next_hash = next_hash->u.seg_obj->next) { - ; - } - - next_hash->u.seg_obj->next = child_obj; -} - -/* called to add packet object list into packet list */ - -static void -add_to_pkt_object_list(hash_obj_t *parent_obj, hash_obj_t *child_obj) -{ - hash_obj_t *next_hash; - - /* add the packet object in the end of list */ - child_obj->u.pkt_obj->segment_hdl = parent_obj->obj_hdl; - - if (parent_obj->u.seg_obj->pkt_obj_list == NULL) { - parent_obj->u.seg_obj->pkt_obj_list = child_obj; - return; - } - - for (next_hash = parent_obj->u.seg_obj->pkt_obj_list; - next_hash->u.pkt_obj->next != NULL; - next_hash = next_hash->u.pkt_obj->next) { - ; - } - - next_hash->u.pkt_obj->next = child_obj; -} - -static void -copy_segment_layout(segment_t *seghdr, void *layout) -{ - segment_layout_t *seg_layout; - - seg_layout = (segment_layout_t *)layout; - (void) memcpy(seghdr->name, &seg_layout->name, SEG_NAME_LEN); - seghdr->descriptor = GET_SEGMENT_DESCRIPTOR; - seghdr->offset = seg_layout->offset; - seghdr->length = seg_layout->length; -} - -static hash_obj_t * -get_container_hash_object(int object_type, handle_t handle) -{ - hash_obj_t *hash_obj; - - switch (object_type) { - case CONTAINER_TYPE : - break; - case SECTION_TYPE : - hash_obj = lookup_handle_object(handle, CONTAINER_TYPE); - if (hash_obj == NULL) { - return (NULL); - } - break; - case SEGMENT_TYPE : - hash_obj = lookup_handle_object(handle, SECTION_TYPE); - if (hash_obj == NULL) { - return (NULL); - } - hash_obj = lookup_handle_object(hash_obj->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - break; - case PACKET_TYPE : - break; - default : - return (NULL); - } - return (hash_obj); -} - - -static void -sort_offsettbl(int segcnt, seg_info_t *offset_tbl) -{ - int cntx; - int cnty; - seg_info_t tmp; - - for (cntx = 0; cntx < segcnt+2; cntx++) { - for (cnty = cntx+1; cnty < segcnt + 2; cnty++) { - if (offset_tbl[cntx].offset > - offset_tbl[cnty].offset) { - (void) memcpy(&tmp, &offset_tbl[cnty], - sizeof (seg_info_t)); - (void) memcpy(&offset_tbl[cnty], - &offset_tbl[cntx], sizeof (seg_info_t)); - - (void) memcpy(&offset_tbl[cntx], &tmp, - sizeof (seg_info_t)); - } - } - } -} - -/* - * Description : move_segment_data() reads the segment data and writes it - * back to the new segment offset. - */ - -static void -move_segment_data(void *seghdr, int newoffset, container_hdl_t contfd) -{ - int ret; - char *buffer; - segment_layout_t *segment; - - segment = (segment_layout_t *)seghdr; - - buffer = alloca(segment->length); - if (buffer == NULL) { - return; - } - - ret = pread(contfd, buffer, - segment->length, segment->offset); - if (ret != segment->length) { - return; - } - - segment->offset = newoffset; - - ret = pwrite(contfd, buffer, segment->length, segment->offset); - if (ret != segment->length) { - return; - } -} - -/* - * Description : pack_segment_data() moves the segment data if there is - * a hole between two segments. - */ - -static void -pack_segment_data(char *seghdr, int segcnt, container_hdl_t contfd, - seg_info_t *offset_tbl) -{ - int cnt; - int diff; - int newoffset; - - for (cnt = segcnt + 1; cnt > 0; cnt--) { - if (!offset_tbl[cnt - 1].fixed) { - if (offset_tbl[cnt].offset - - (offset_tbl[cnt -1 ].offset - + offset_tbl[cnt - 1].length) > 0) { - - diff = offset_tbl[cnt].offset - - (offset_tbl[cnt - 1].offset - + offset_tbl[cnt - 1].length); - newoffset = offset_tbl[cnt - 1].offset - + diff; - - move_segment_data(seghdr, newoffset, - contfd); - - offset_tbl[cnt - 1].offset = newoffset; - - sort_offsettbl(segcnt, offset_tbl); - } - } - } -} - -/* - * Description : build_offset_tbl() builds the offset table by reading all the - * segment header. it makes two more entry into the table one for - * section size and another with start of the section after the - * segment header. - */ - -static int -build_offset_tbl(void *seghdr, int segcnt, int secsize, - seg_info_t *offset_tbl) -{ - int cnt; - fru_segdesc_t segdesc; - segment_layout_t *segment; - - for (cnt = 0; cnt < segcnt; cnt++) { - segment = (segment_layout_t *)(seghdr) + cnt; - - (void) memcpy(&segdesc, &segment->descriptor, - sizeof (uint32_t)); - offset_tbl[cnt].segnum = cnt; - offset_tbl[cnt].offset = segment->offset; - offset_tbl[cnt].length = segment->length; - offset_tbl[cnt].fixed = segdesc.field.fixed; - } - - /* upper boundary of segment area (lower address bytes) */ - offset_tbl[cnt].segnum = -1; - offset_tbl[cnt].offset = sizeof (section_layout_t) + ((cnt + 1) - * sizeof (segment_layout_t)); - - offset_tbl[cnt].length = 0; - offset_tbl[cnt].fixed = 1; - /* lower boundary of segment area (higher address bytes) */ - - offset_tbl[cnt+1].segnum = -1; - offset_tbl[cnt+1].offset = secsize; - offset_tbl[cnt+1].length = 0; - offset_tbl[cnt+1].fixed = 1; - return (0); -} - -static int -hole_discovery(int bytes, int segcnt, int *totsize, seg_info_t *offset_tbl) -{ - int cnt = 0; - - *totsize = 0; - for (cnt = segcnt + 1; cnt > 0; cnt--) { - if (bytes <= offset_tbl[cnt].offset - - (offset_tbl[cnt - 1].offset + - offset_tbl[cnt - 1].length)) { - return (offset_tbl[cnt].offset - bytes); - } - - *totsize += offset_tbl[cnt].offset - - (offset_tbl[cnt - 1].offset + - offset_tbl[cnt - 1].length); - } - return (0); -} - - -/* - * Description : segment_hdr_present() verify space for new segment header to - * be added. - */ - -static int -segment_hdr_present(int segoffset, int size, seg_info_t *offset_tbl) -{ - if ((segoffset + size) <= offset_tbl[0].offset) - return (0); - else - return (-1); -} - -/* - * Description : find_offset() is called from fru_add_segment routine to find - * a valid offset. - */ - -static int -find_offset(char *seghdr, int segcnt, int secsize, int *sectionoffset, - int segsize, int fix, container_hdl_t contfd) -{ - int ret; - int newoffset; - int totsize = 0; - seg_info_t *offset_tbl; - - if (segcnt == 0) { - if (!fix) { /* if not fixed segment */ - *sectionoffset = secsize - segsize; - } - return (0); - } - - /* - * two extra segment info structure are allocated for start of segment - * and other end of segment. first segment offset is first available - * space and length is 0. second segment offset is is segment length and - * offset is 0. build_offset_tbl() explains how upper boundary and lower - * boudary segment area are initialized in seg_info_t table. - */ - - offset_tbl = malloc((segcnt + 2) * sizeof (seg_info_t)); - if (offset_tbl == NULL) { - return (-1); - } - - /* read all the segment header to make offset table */ - ret = build_offset_tbl(seghdr, segcnt, secsize, offset_tbl); - if (ret != 0) { - free(offset_tbl); - return (-1); - } - - /* sort the table */ - sort_offsettbl(segcnt, offset_tbl); - - /* new segment header offset */ - newoffset = sizeof (section_layout_t) + segcnt * - sizeof (segment_layout_t); - - /* do? new segment header overlap any existing data */ - ret = segment_hdr_present(newoffset, sizeof (segment_layout_t), - offset_tbl); - if (ret != 0) { /* make room for new segment if possible */ - - /* look for hole in order to move segment data */ - if (offset_tbl[0].fixed == SEGMENT_FIXED) { /* fixed segment */ - free(offset_tbl); - return (-1); - } - - newoffset = hole_discovery(offset_tbl[0].length, - segcnt, &totsize, offset_tbl); - if (newoffset != 0) { /* found new offset */ - /* now new offset */ - offset_tbl[0].offset = newoffset; - - /* move the segment data */ - move_segment_data(seghdr, newoffset, contfd); - /* again sort the offset table */ - sort_offsettbl(segcnt, offset_tbl); - } else { - /* pack the existing hole */ - if (totsize > offset_tbl[0].length) { - pack_segment_data(seghdr, segcnt, - contfd, offset_tbl); - } else { - free(offset_tbl); - return (-1); - } - } - } - - totsize = 0; - newoffset = hole_discovery(segsize, segcnt, &totsize, offset_tbl); - - if (newoffset == 0) { /* No hole found */ - if (totsize >= segsize) { - pack_segment_data(seghdr, segcnt, contfd, - offset_tbl); - newoffset = hole_discovery(segsize, segcnt, - &totsize, offset_tbl); - if (newoffset != 0) { - *sectionoffset = newoffset; - free(offset_tbl); - return (0); - } - } - } else { - *sectionoffset = newoffset; - free(offset_tbl); - return (0); - } - free(offset_tbl); - return (-1); -} - -static char * -tokenizer(char *buf, char *separator, char **nextBuf, char *matched) -{ - int i = 0; - int j = 0; - - for (i = 0; buf[i] != '\0'; i++) { - for (j = 0; j < strlen(separator); j++) { - if (buf[i] == separator[j]) { - buf[i] = '\0'; - *nextBuf = &(buf[i+1]); - *matched = separator[j]; - return (buf); - } - } - } - - *nextBuf = buf; - *matched = '\0'; - return (NULL); -} - -static int -get_container_info(const char *def_file, const char *cont_desc_str, - container_info_t *cont_info) -{ - char *item; - char *token; - char *field; - char matched; - char buf[1024]; - int foundIt = 0; - FILE *file = fopen(def_file, "r"); - - if (file == NULL) - return (-1); - - cont_info->num_sections = 0; - - while (fgets(buf, sizeof (buf), file) != NULL) { - /* ignore all comments */ - token = tokenizer(buf, "#", &field, &matched); - /* find the names */ - token = tokenizer(buf, ":", &field, &matched); - if (token != 0x00) { - token = tokenizer(token, "|", &item, &matched); - while (token != 0x00) { - if (strcmp(token, cont_desc_str) == 0) { - foundIt = 1; - goto found; - } - token = tokenizer(item, "|", &item, &matched); - } - /* check the last remaining item */ - if ((item != 0x00) && - (strcmp(item, cont_desc_str) == 0)) { - foundIt = 1; - goto found; - } - } - } - -found : - if (foundIt == 1) { - token = tokenizer(field, ":", &field, &matched); - if (token == 0x00) { - (void) fclose(file); - return (-1); - } - cont_info->header_ver = (headerrev_t)atoi(token); - - token = tokenizer(field, ":\n", &field, &matched); - while (token != 0x00) { - token = tokenizer(token, ",", &item, &matched); - if (token == 0x00) { - (void) fclose(file); - return (-1); - } - if (atoi(token) == 1) { - cont_info->section_info[cont_info-> - num_sections].description.field.read_only = 1; - } else if (atoi(token) == 0) { - cont_info->section_info[cont_info-> - num_sections].description.field.read_only = 0; - } else { - (void) fclose(file); - return (-1); - } - - token = tokenizer(item, ",", &item, &matched); - if (token == 0x00) { - (void) fclose(file); - return (-1); - } - - if (atoi(token) == 1) { - cont_info->section_info[cont_info-> - num_sections].description.field.chk_type = 1; - } else if (atoi(token) == 0) { - cont_info->section_info[cont_info-> - num_sections].description.field.chk_type = 0; - } else { - (void) fclose(file); - return (-1); - } - - - token = tokenizer(item, ",", &item, &matched); - if (token == 0x00) { - (void) fclose(file); - return (-1); - } - - cont_info->section_info[cont_info->num_sections]. - address = atoi(token); - - - if (item == '\0') { - (void) fclose(file); - return (-1); - } - cont_info->section_info[cont_info->num_sections].size = - atoi(item); - (cont_info->num_sections)++; - - token = tokenizer(field, ":\n ", &field, &matched); - } - } - (void) fclose(file); - return (0); -} - -/* - * Description :fru_open_container() opens the container associated with a fru. - * it's called by data plugin module before creating container - * property. it calls picltree library routine to get the - * device path and driver binding name for the fru to get the - * corresponding fru name that describe the fru layout. - * - * Arguments :picl_hdl_t fru - * A handle for PICL tree node of class "fru" representing the - * FRU with the container to open. - * - * Return : - * On Success, a Positive integer container handle. is returned - * for use in subsequent fru operations;on error, 0 is returned - * and "errno" is set appropriately. - */ - -container_hdl_t -fru_open_container(picl_nodehdl_t fruhdl) -{ - int retval; - int count; - char *bname; - char devpath[PATH_MAX]; - hash_obj_t *cont_hash_obj; - hash_obj_t *sec_hash_obj; - picl_nodehdl_t tmphdl; - picl_prophdl_t prophdl; - ptree_propinfo_t propinfo; - container_info_t cont_info; - - /* Get property handle of _seeprom_source under fru node */ - retval = ptree_get_propval_by_name(fruhdl, PICL_REFPROP_SEEPROM_SRC, - &tmphdl, sizeof (tmphdl)); - if (retval != PICL_SUCCESS) { - return (NULL); - } - - /* Get the device path of the fru */ - retval = ptree_get_propval_by_name(tmphdl, PICL_PROP_DEVICEPATH, - devpath, PATH_MAX); - if (retval != PICL_SUCCESS) { - return (NULL); - } - - retval = ptree_get_prop_by_name(tmphdl, PICL_PROP_BINDING_NAME, - &prophdl); - if (retval != PICL_SUCCESS) { - return (NULL); - } - - retval = ptree_get_propinfo(prophdl, &propinfo); - if (retval != PICL_SUCCESS) { - return (NULL); - } - - bname = alloca(propinfo.piclinfo.size); - if (bname == NULL) { - return (NULL); - } - - /* get the driver binding name */ - retval = ptree_get_propval(prophdl, bname, propinfo.piclinfo.size); - if (retval != PICL_SUCCESS) { - return (NULL); - } - - cont_hash_obj = create_container_hash_object(); - if (cont_hash_obj == NULL) { - return (NULL); - } - - add_hashobject_to_hashtable(cont_hash_obj); - - (void) strlcpy(cont_hash_obj->u.cont_obj->device_pathname, devpath, - sizeof (devpath)); - - /* takes driver binding name as to get container information */ - retval = get_container_info(CONTAINER_CONF_FILE, bname, &cont_info); - if (retval < 0) { - return (NULL); - } - - cont_hash_obj->u.cont_obj->num_of_section = cont_info.num_sections; - cont_hash_obj->u.cont_obj->sec_obj_list = NULL; - - for (count = 0; count < cont_info.num_sections; count++) { - sec_hash_obj = create_section_hash_object(); - if (sec_hash_obj == NULL) { - return (NULL); - } - - add_hashobject_to_hashtable(sec_hash_obj); - - sec_hash_obj->u.sec_obj->section.offset = - cont_info.section_info[count].address; - - sec_hash_obj->u.sec_obj->section.protection = - cont_info.section_info[count].description.field.read_only; - - sec_hash_obj->u.sec_obj->checksum_method = - cont_info.section_info[count].description.field.chk_type; - - sec_hash_obj->u.sec_obj->section.length = - cont_info.section_info[count].size; - - sec_hash_obj->u.sec_obj->section.version = cont_info.header_ver; - - add_to_sec_object_list(cont_hash_obj, sec_hash_obj); - } - return (cont_hash_obj->obj_hdl); -} - -static int -verify_header_crc8(headerrev_t head_ver, unsigned char *bytes, int length) -{ - int crc_offset = 0; - unsigned char orig_crc8 = 0; - unsigned char calc_crc8 = 0; - - switch (head_ver) { - case SECTION_HDR_VER: - crc_offset = 4; - break; - default: - errno = EINVAL; - return (0); - } - - orig_crc8 = bytes[crc_offset]; - bytes[crc_offset] = 0x00; /* clear for calc */ - calc_crc8 = compute_crc8(bytes, length); - bytes[crc_offset] = orig_crc8; /* restore */ - - return (orig_crc8 == calc_crc8); -} - -/* - * Description : - * fru_get_num_sections() returns number of sections in a - * container. it calls get_container_index() to get the container - * index number in the container list. - * - * Arguments : - * container_hdl_t : container handle. - * - * Return : - * int - * On success, returns number of sections in a container. - * - */ -/*ARGSUSED*/ -int -fru_get_num_sections(container_hdl_t container, door_cred_t *cred) -{ - hash_obj_t *hash_object; - - hash_object = lookup_handle_object(container, CONTAINER_TYPE); - if (hash_object == NULL) { - return (-1); - } - - return (hash_object->u.cont_obj->num_of_section); -} - -/* - * called from fru_get_sections() - */ - -static void -get_section(int fd, hash_obj_t *sec_hash, section_t *section) -{ - int retval; - int size; - int count; - uint16_t hdrver; - hash_obj_t *seg_hash; - unsigned char *buffer; - section_obj_t *sec_obj; - section_layout_t sec_hdr; - segment_layout_t *seg_hdr; - segment_layout_t *seg_buf; - - sec_obj = sec_hash->u.sec_obj; - if (sec_obj == NULL) { - return; - } - - /* populate section_t */ - section->handle = sec_hash->obj_hdl; - section->offset = sec_obj->section.offset; - section->length = sec_obj->section.length; - section->protection = sec_obj->section.protection; - section->version = sec_obj->section.version; - sec_obj->num_of_segment = 0; - - /* read section header layout */ - retval = pread(fd, &sec_hdr, sizeof (sec_hdr), - sec_obj->section.offset); - if (retval != sizeof (sec_hdr)) { - return; - } - - hdrver = GET_SECTION_HDR_VERSION; - - if ((sec_hdr.headertag != SECTION_HDR_TAG) && - (hdrver != section->version)) { - return; - } - - /* size = section layout + total sizeof segment header */ - size = sizeof (sec_hdr) + ((sec_hdr.segmentcount) - * sizeof (segment_layout_t)); - - buffer = alloca(size); - if (buffer == NULL) { - return; - } - - /* segment header buffer */ - seg_buf = alloca(size - sizeof (sec_hdr)); - if (seg_buf == NULL) { - return; - } - - /* read segment header */ - retval = pread(fd, seg_buf, size - sizeof (sec_hdr), - sec_obj->section.offset + sizeof (sec_hdr)); - if (retval != (size - sizeof (sec_hdr))) { - return; - } - - /* copy section header layout */ - (void) memcpy(buffer, &sec_hdr, sizeof (sec_hdr)); - - /* copy segment header layout */ - (void) memcpy(buffer + sizeof (sec_hdr), seg_buf, size - - sizeof (sec_hdr)); - - /* verify crc8 */ - retval = verify_header_crc8(hdrver, buffer, size); - if (retval != TRUE) { - return; - } - - - section->version = hdrver; - sec_obj->section.version = hdrver; - - seg_hdr = (segment_layout_t *)seg_buf; - - for (count = 0; count < sec_hdr.segmentcount; count++, seg_hdr++) { - seg_hash = create_segment_hash_object(); - if (seg_hash == NULL) { - return; - } - - add_hashobject_to_hashtable(seg_hash); - - copy_segment_layout(&seg_hash->u.seg_obj->segment, seg_hdr); - - add_to_seg_object_list(sec_hash, seg_hash); - - sec_obj->num_of_segment++; - } -} - - -static int -call_devfsadm(void) -{ - char *phys_path; - di_node_t root_node; - di_node_t prom_node; - di_node_t f_node; - - if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { - return (-1); - } - - f_node = di_drv_first_node(PICL_CLASS_SEEPROM, root_node); - if (f_node != DI_NODE_NIL) { - phys_path = di_devfs_path(f_node); - if ((prom_node = di_init(phys_path, DINFOMINOR)) - != DI_NODE_NIL) { - di_fini(prom_node); - di_fini(root_node); - (void) pclose(popen(devfsadm_cmd, "r")); - return (0); - } - } - di_fini(root_node); - return (-1); -} - -/* - * Description : - * fru_get_sections() fills an array of section structures passed - * as an argument. - * - * Arguments : - * container_hdl_t : container handle(device descriptor). - * section_t : array of section structure. - * int : maximum number of section in a container. - * - * Returns : - * int - * On success,the number of section structures written is returned; - * on error, -1 is returned and "errno" is set appropriately. - * - */ - -/* ARGSUSED */ -int -fru_get_sections(container_hdl_t container, section_t *section, int maxsec, - door_cred_t *cred) -{ - int device_fd; - int retrys = 1; - int count; - hash_obj_t *cont_object; - hash_obj_t *sec_hash; - - cont_object = lookup_handle_object(container, CONTAINER_TYPE); - if (cont_object == NULL) { - return (-1); - } - - if (cont_object->u.cont_obj->num_of_section > maxsec) { - return (-1); - } - - sec_hash = cont_object->u.cont_obj->sec_obj_list; - if (sec_hash == NULL) { - return (-1); - } - - do { - device_fd = open(cont_object->u.cont_obj->device_pathname, - O_RDWR); - if (device_fd >= 0) { - break; - } - } while ((retrys-- > 0) && (call_devfsadm() == 0)); - - if (device_fd < 0) { - return (-1); - } - - for (count = 0; count < cont_object->u.cont_obj->num_of_section; - count++, section++) { - section->version = -1; - /* populate section_t */ - get_section(device_fd, sec_hash, section); - sec_hash = sec_hash->u.sec_obj->next; - } - - (void) close(device_fd); - - return (count); -} - -/* - * Description : - * fru_get_num_segments() returns the current number of segments - * in a section. - * - * Arguments : - * section_hdl_t : section header holding section information. - * - * Return : - * int - * On success, the number of segments in the argument section is - * returned; on error -1 is returned. - */ -/*ARGSUSED*/ -int -fru_get_num_segments(section_hdl_t section, door_cred_t *cred) -{ - hash_obj_t *sec_object; - section_obj_t *sec_obj; - - sec_object = lookup_handle_object(section, SECTION_TYPE); - if (sec_object == NULL) { - return (-1); - } - - sec_obj = sec_object->u.sec_obj; - if (sec_obj == NULL) { - return (-1); - } - - return (sec_obj->num_of_segment); -} - -/* - * Description : - * fru_get_segments() fills an array of structures representing the - * segments in a section. - * - * Arguments : - * section_hdl_t : holds section number. - * segment_t : on success will hold segment information. - * int : maximum number of segment. - * - * Return : - * int - * On success, the number of segment structures written is - * returned; on errno -1 is returned. - */ - -/* ARGSUSED */ -int -fru_get_segments(section_hdl_t section, segment_t *segment, int maxseg, - door_cred_t *cred) -{ - int count; - hash_obj_t *sec_object; - hash_obj_t *seg_object; - section_obj_t *sec_obj; - - sec_object = lookup_handle_object(section, SECTION_TYPE); - if (sec_object == NULL) { - return (-1); - } - - sec_obj = sec_object->u.sec_obj; - if (sec_obj == NULL) { - return (-1); - } - - if (sec_obj->num_of_segment > maxseg) { - return (-1); - } - - seg_object = sec_object->u.sec_obj->seg_obj_list; - if (seg_object == NULL) { - return (-1); - } - - for (count = 0; count < sec_obj->num_of_segment; count++) { - - /* populate segment_t */ - segment->handle = seg_object->obj_hdl; - (void) memcpy(segment->name, - seg_object->u.seg_obj->segment.name, SEG_NAME_LEN); - segment->descriptor = seg_object->u.seg_obj->segment.descriptor; - - segment->offset = seg_object->u.seg_obj->segment.offset; - segment->length = seg_object->u.seg_obj->segment.length; - seg_object = seg_object->u.seg_obj->next; - segment++; - } - return (0); -} - -/* - * Description : - * fru_add_segment() adds a segment to a section. - * - * Arguments : - * section_hdl_t section - * A handle for the section in which to add the segment. - * - * segment_t *segment - * On entry, the "handle" component of "segment" is ignored and the - * remaining components specify the parameters of the segment to be - * added. On return, the "handle" component is set to the handle - * for the added segment. The segment offset is mandatory for FIXED - * segments; otherwise, the offset is advisory. - * - * Return : - * int - * On success, 0 is returned; on error -1 is returned. - * - */ - -int -fru_add_segment(section_hdl_t section, segment_t *segment, - section_hdl_t *newsection, door_cred_t *cred) -{ - int fd; - int retval; - int offset; - int sec_size; - int seg_cnt; - int bufsize; - int new_seg_offset; - int new_seg_length; - int fixed_segment; - char trailer[] = { 0x0c, 0x00, 0x00, 0x00, 0x00 }; - hash_obj_t *cont_hash; - hash_obj_t *sec_hash; - hash_obj_t *seg_hash; - fru_segdesc_t *new_seg_desc; - unsigned char *crcbuf; - section_layout_t sec_layout; - segment_layout_t *seg_layout; - segment_layout_t *segment_buf; - - /* check the effective uid of the client */ - if (cred->dc_euid != 0) { - errno = EPERM; - return (-1); /* not a root */ - } - - /* section hash */ - sec_hash = lookup_handle_object(section, SECTION_TYPE); - if (sec_hash == NULL) { - return (-1); - } - - /* check for read-only section */ - if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) { - errno = EPERM; - return (-1); - } - - /* look for duplicate segment */ - seg_hash = sec_hash->u.sec_obj->seg_obj_list; - while (seg_hash != NULL) { - if (strncmp(segment->name, seg_hash->u.seg_obj->segment.name, - SEG_NAME_LEN) == 0) { - errno = EEXIST; - return (-1); /* can't add duplicate segment */ - } - seg_hash = seg_hash->u.seg_obj->next; - } - - /* get the container hash */ - cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - if (cont_hash == NULL) { - return (-1); - } - - /* open the container */ - fd = open(cont_hash->u.cont_obj->device_pathname, O_RDWR); - if (fd < 0) { - return (-1); - } - - /* section start here */ - offset = sec_hash->u.sec_obj->section.offset; - - /* read section header layout */ - retval = pread(fd, &sec_layout, sizeof (sec_layout), offset); - if (retval != sizeof (sec_layout)) { - (void) close(fd); - return (-1); - } - - /* check for valid section header */ - if (sec_layout.headertag != SECTION_HDR_TAG) { - /* write a new one */ - sec_layout.headertag = SECTION_HDR_TAG; - sec_layout.headerversion[0] = SECTION_HDR_VER_BIT0; - sec_layout.headerversion[1] = SECTION_HDR_VER_BIT1; - sec_layout.headerlength = sizeof (sec_layout); - sec_layout.segmentcount = 0; - } - - /* section size */ - sec_size = sec_hash->u.sec_obj->section.length; - - /* number of segment in the section */ - seg_cnt = sec_layout.segmentcount; - - /* total sizeof segment + new segment */ - bufsize = sizeof (segment_layout_t) * (seg_cnt + 1); - segment_buf = alloca(bufsize); - if (segment_buf == NULL) { - return (-1); - } - - /* read entire segment header */ - retval = pread(fd, segment_buf, (bufsize - sizeof (segment_layout_t)), - offset + sizeof (section_layout_t)); - if (retval != (bufsize - sizeof (segment_layout_t))) { - (void) close(fd); - return (-1); - } - - new_seg_offset = segment->offset; /* new segment offset */ - new_seg_length = segment->length; /* new segment length */ - - new_seg_desc = (fru_segdesc_t *)&segment->descriptor; - - fixed_segment = new_seg_desc->field.fixed; - - /* get new offset for new segment to be addedd */ - retval = find_offset((char *)segment_buf, seg_cnt, sec_size, - &new_seg_offset, new_seg_length, fixed_segment, fd); - - if (retval != 0) { - (void) close(fd); - errno = EAGAIN; - return (-1); - } - - /* copy new segment data in segment layout */ - seg_layout = (segment_layout_t *)(segment_buf + seg_cnt); - (void) memcpy(&seg_layout->name, segment->name, SEG_NAME_LEN); - (void) memcpy(seg_layout->descriptor, &segment->descriptor, - sizeof (uint32_t)); - seg_layout->length = segment->length; - seg_layout->offset = new_seg_offset; /* new segment offset */ - - sec_layout.segmentcount += 1; - - crcbuf = alloca(sizeof (section_layout_t) + bufsize); - if (crcbuf == NULL) { - (void) close(fd); - return (-1); - } - - sec_layout.headercrc8 = 0; - sec_layout.headerlength += sizeof (segment_layout_t); - - (void) memcpy(crcbuf, (char *)&sec_layout, sizeof (section_layout_t)); - (void) memcpy(crcbuf + sizeof (section_layout_t), segment_buf, bufsize); - - sec_layout.headercrc8 = compute_crc8(crcbuf, bufsize + - sizeof (section_layout_t)); - - /* write section header */ - retval = pwrite(fd, &sec_layout, sizeof (section_layout_t), offset); - if (retval != sizeof (section_layout_t)) { - (void) close(fd); - return (-1); - } - - /* write segment header */ - retval = pwrite(fd, segment_buf, bufsize, offset + - sizeof (section_layout_t)); - if (retval != bufsize) { - (void) close(fd); - return (-1); - } - - /* write segment trailer */ - retval = pwrite(fd, &trailer, sizeof (trailer), new_seg_offset); - if (retval != sizeof (trailer)) { - (void) close(fd); - return (-1); - } - - (void) close(fd); - - /* create new segment hash object */ - seg_hash = create_segment_hash_object(); - if (seg_hash == NULL) { - return (-1); - } - - add_hashobject_to_hashtable(seg_hash); - - copy_segment_layout(&seg_hash->u.seg_obj->segment, seg_layout); - - add_to_seg_object_list(sec_hash, seg_hash); - - sec_hash->u.sec_obj->num_of_segment += 1; - seg_hash->u.seg_obj->trailer_offset = new_seg_offset; - *newsection = section; /* return the new section handle */ - return (0); -} - -static void -free_pkt_object_list(hash_obj_t *hash_obj) -{ - hash_obj_t *next_obj; - hash_obj_t *free_obj; - - next_obj = hash_obj->u.seg_obj->pkt_obj_list; - while (next_obj != NULL) { - free_obj = next_obj; - next_obj = next_obj->u.pkt_obj->next; - /* if prev is NULL it's the first object in the list */ - if (free_obj->prev == NULL) { - hash_table[(free_obj->obj_hdl % TABLE_SIZE)] = - free_obj->next; - if (free_obj->next != NULL) { - free_obj->next->prev = free_obj->prev; - } - } else { - free_obj->prev->next = free_obj->next; - if (free_obj->next != NULL) { - free_obj->next->prev = free_obj->prev; - } - } - free(free_obj->u.pkt_obj); - free(free_obj); - } - - hash_obj->u.seg_obj->pkt_obj_list = NULL; -} - -static void -free_segment_hash(handle_t handle, hash_obj_t *sec_hash) -{ - hash_obj_t *seg_hash; - hash_obj_t *next_hash; - - seg_hash = sec_hash->u.sec_obj->seg_obj_list; - if (seg_hash == NULL) { - return; - } - - if (seg_hash->obj_hdl == handle) { - sec_hash->u.sec_obj->seg_obj_list = seg_hash->u.seg_obj->next; - } else { - while (seg_hash->obj_hdl != handle) { - next_hash = seg_hash; - seg_hash = seg_hash->u.seg_obj->next; - if (seg_hash == NULL) { - return; - } - } - next_hash->u.seg_obj->next = seg_hash->u.seg_obj->next; - } - - if (seg_hash->prev == NULL) { - hash_table[(seg_hash->obj_hdl % TABLE_SIZE)] = seg_hash->next; - if (seg_hash->next != NULL) { - seg_hash->next->prev = NULL; - } - } else { - seg_hash->prev->next = seg_hash->next; - if (seg_hash->next != NULL) { - seg_hash->next->prev = seg_hash->prev; - } - } - - free_pkt_object_list(seg_hash); - free(seg_hash->u.seg_obj); - free(seg_hash); -} - -/* - * Description : - * fru_delete_segment() deletes a segment from a section; the - * associated container data is not altered. - * - * Arguments : segment_hdl_t segment handle. - * section_hdl_t new section handle. - * - * Return : - * int - * On success, 0 returned; On error -1 is returned. - */ - -int -fru_delete_segment(segment_hdl_t segment, section_hdl_t *newsection, - door_cred_t *cred) -{ - int num_of_seg; - int bufsize; - int count; - int retval; - int fd; - int segnum; - hash_obj_t *seg_hash; - hash_obj_t *sec_hash; - hash_obj_t *cont_hash; - hash_obj_t *tmp_hash; - unsigned char *buffer; - fru_segdesc_t *desc; - segment_layout_t *seg_buf; - section_layout_t *sec_layout; - segment_layout_t *seg_layout; - segment_layout_t *next_layout; - - /* check the effective uid of the client */ - if (cred->dc_euid != 0) { - errno = EPERM; - return (-1); /* not a root */ - } - - seg_hash = lookup_handle_object(segment, SEGMENT_TYPE); - if (seg_hash == NULL) { - return (-1); - } - - desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor; - if (!(desc->field.field_perm & SEGMENT_DELETE)) { - errno = EPERM; - return (-1); /* can't delete this segment */ - } - - sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl, - SECTION_TYPE); - if (sec_hash == NULL) { - return (-1); - } - - if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) { - errno = EPERM; - return (-1); - } - - num_of_seg = sec_hash->u.sec_obj->num_of_segment; - - bufsize = (sizeof (segment_layout_t) * num_of_seg); - - seg_buf = alloca(bufsize); - if (seg_buf == NULL) { - return (-1); - } - - segnum = 0; - for (tmp_hash = sec_hash->u.sec_obj->seg_obj_list; tmp_hash != NULL; - tmp_hash = tmp_hash->u.seg_obj->next) { - if (tmp_hash->obj_hdl == segment) { - break; - } - segnum++; - } - - cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - if (cont_hash == NULL) { - return (-1); - } - - fd = open(cont_hash->u.cont_obj->device_pathname, O_RDWR); - if (fd < 0) { - return (-1); - } - - sec_layout = alloca(sizeof (section_layout_t)); - if (sec_layout == NULL) { - (void) close(fd); - return (-1); - } - - /* read section layout header */ - retval = pread(fd, sec_layout, sizeof (section_layout_t), - sec_hash->u.sec_obj->section.offset); - if (retval != sizeof (section_layout_t)) { - (void) close(fd); - return (-1); - } - - /* read segment header layout */ - retval = pread(fd, seg_buf, bufsize, - sec_hash->u.sec_obj->section.offset + - sizeof (section_layout_t)); - if (retval != bufsize) { - (void) close(fd); - return (-1); - } - - seg_layout = (segment_layout_t *)(seg_buf + segnum); - next_layout = seg_layout; - for (count = segnum; count < sec_hash->u.sec_obj->num_of_segment-1; - count++) { - next_layout++; - (void) memcpy(seg_layout, next_layout, - sizeof (segment_layout_t)); - seg_layout++; - } - - (void) memset(seg_layout, '\0', sizeof (segment_layout_t)); - - sec_layout->headercrc8 = 0; - - sec_layout->headerlength -= sizeof (segment_layout_t); - sec_layout->segmentcount -= 1; - - buffer = alloca(sec_layout->headerlength); - if (buffer == NULL) { - (void) close(fd); - return (-1); - } - - (void) memcpy(buffer, sec_layout, sizeof (section_layout_t)); - (void) memcpy(buffer + sizeof (section_layout_t), seg_buf, bufsize - - sizeof (segment_layout_t)); - sec_layout->headercrc8 = compute_crc8(buffer, - sec_layout->headerlength); - - /* write section header with update crc8 and header length */ - retval = pwrite(fd, sec_layout, sizeof (section_layout_t), - sec_hash->u.sec_obj->section.offset); - if (retval != sizeof (section_layout_t)) { - (void) close(fd); - return (-1); - } - - /* write the update segment header */ - retval = pwrite(fd, seg_buf, bufsize, - sec_hash->u.sec_obj->section.offset + - sizeof (section_layout_t)); - (void) close(fd); - if (retval != bufsize) { - return (-1); - } - - free_segment_hash(segment, sec_hash); - - *newsection = sec_hash->obj_hdl; - sec_hash->u.sec_obj->num_of_segment = sec_layout->segmentcount; - - return (0); -} - -/* - * Description : - * fru_read_segment() reads the raw contents of a segment. - * - * Arguments : segment_hdl_t : segment handle. - * void * : buffer containing segment data when function returns. - * size_t :number of bytes. - * - * Return : - * int - * On success, the number of bytes read is returned; - * - * Notes : - * Segments containing packets can be read in structured fashion - * using the fru_get_packets() and fru_get_payload() primitives;the - * entire byte range of a segment can be read using - * fru_read_segment(). - */ -/*ARGSUSED*/ -ssize_t -fru_read_segment(segment_hdl_t segment, void *buffer, size_t nbytes, - door_cred_t *cred) -{ - int fd; - int retval; - hash_obj_t *seg_hash; - hash_obj_t *sec_hash; - hash_obj_t *cont_hash; - - /* segment hash object */ - seg_hash = lookup_handle_object(segment, SEGMENT_TYPE); - if (seg_hash == NULL) { - return (-1); - } - - /* section hash object */ - sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl, - SECTION_TYPE); - if (sec_hash == NULL) { - return (-1); - } - - /* container hash object */ - cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - if (cont_hash == NULL) { - return (-1); - } - - if (seg_hash->u.seg_obj->segment.length < nbytes) { - return (-1); - } - - fd = open(cont_hash->u.cont_obj->device_pathname, O_RDWR); - if (fd < 0) { - return (-1); - } - - retval = pread(fd, buffer, nbytes, seg_hash->u.seg_obj->segment.offset); - (void) close(fd); - if (retval != nbytes) { - return (-1); - } - return (nbytes); -} - -/* - * Description : - * fru_write_segment() writes a raw segment. - * - * Arguments : segment_hdl_t :segment handle. - * const void * : data buffer. - * size_t : number of bytes. - * segment_hdl_t : new segment handle. - * - * Returns : - * int - * On success, the number of bytes written is returned - * - */ -/*ARGSUSED*/ -int -fru_write_segment(segment_hdl_t segment, const void *data, size_t nbytes, - segment_hdl_t *newsegment, door_cred_t *cred) -{ - return (ENOTSUP); -} - - -static int -get_packet(int device_fd, void *buffer, int size, int offset) -{ - int retval; - - retval = pread(device_fd, (char *)buffer, size, offset); - if (retval != -1) { - return (0); - } - return (-1); -} - -/* - * Description : - * get_payload() populates a buffer with the packets payload - * - * Arguments : hash_obj_t : packet. - * int : device file descriptor - * uint8_t* : pointer to a pre allocated buffer - * - * - * Return : - * int - * On success, 0 is returned; on failure - * -1 returned. - */ -int -get_payload(int device_fd, hash_obj_t *packet, uint8_t *payload) -{ - int retval; - packet_obj_t *packet_object; - - - packet_object = packet->u.pkt_obj; - if (packet_object == NULL) { - return (-1); - } - - /* Get the data */ - retval = pread(device_fd, payload, packet_object->paylen, - packet_object->payload_offset); - if (retval != packet_object->paylen) { - free(payload); - return (-1); - } - - return (0); - -} - - -static uint32_t -get_checksum_crc(int device_fd, hash_obj_t *seg_hash, int data_size) -{ - int checksum; - int offset = 0; - int retval; - uint8_t *payload; - uint32_t crc; - hash_obj_t *sec_hash; - hash_obj_t *pkt_hash; - unsigned char *buffer; - - sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl, - SECTION_TYPE); - if (sec_hash == NULL) { - return ((uint32_t)-1); - } - - buffer = alloca(data_size); - if (buffer == NULL) { - return ((uint32_t)-1); - } - - /* traverse the packet object list for all the tags and payload */ - for (pkt_hash = seg_hash->u.seg_obj->pkt_obj_list; pkt_hash != NULL; - pkt_hash = pkt_hash->u.pkt_obj->next) { - (void) memcpy(buffer + offset, &pkt_hash->u.pkt_obj->tag, - pkt_hash->u.pkt_obj->tag_size); - offset += pkt_hash->u.pkt_obj->tag_size; - - /* read packet payload */ - payload = malloc(pkt_hash->u.pkt_obj->paylen); - if (payload == NULL) { - return ((uint32_t)-1); - } - retval = get_payload(device_fd, pkt_hash, payload); - if (retval == -1) { - free(payload); - return ((uint32_t)-1); - } - (void) memcpy(buffer + offset, payload, - pkt_hash->u.pkt_obj->paylen); - offset += pkt_hash->u.pkt_obj->paylen; - free(payload); - } - - checksum = sec_hash->u.sec_obj->checksum_method; - - if (checksum == CRC32_SECTION) { /* read-only section */ - crc = compute_crc32(buffer, data_size); - } else { /* read/write section */ - crc = compute_checksum32(buffer, data_size); - } - return (crc); /* computed crc */ -} - -static int -get_packets(hash_obj_t *seg_hash, int device_fd, int offset, int length) -{ - int tag_size; - int paylen; - int retval; - int seg_limit = 0; - int pktcnt = 0; - char *data; - uint32_t crc; - uint32_t origcrc; - fru_tag_t tag; - hash_obj_t *pkt_hash_obj; - fru_segdesc_t *segdesc; - fru_tagtype_t tagtype; - - retval = get_packet(device_fd, &tag, sizeof (fru_tag_t), offset); - if (retval == -1) { - return (-1); - } - - seg_hash->u.seg_obj->trailer_offset = offset; - - data = (char *)&tag; - while (data[0] != SEG_TRAILER_TAG) { - tagtype = get_tag_type(&tag); /* verify tag type */ - if (tagtype == -1) { - return (-1); - } - - tag_size = get_tag_size(tagtype); - if (tag_size == -1) { - return (-1); - } - - seg_limit += tag_size; - if (seg_limit > length) { - return (-1); - } - - paylen = get_payload_length((void *)&tag); - if (paylen == -1) { - return (-1); - } - - seg_limit += paylen; - if (seg_limit > length) { - return (-1); - } - - pkt_hash_obj = create_packet_hash_object(); - if (pkt_hash_obj == NULL) { - return (-1); - } - - offset += tag_size; - - /* don't change this */ - pkt_hash_obj->u.pkt_obj->tag.raw_data = 0; - (void) memcpy(&pkt_hash_obj->u.pkt_obj->tag, &tag, tag_size); - pkt_hash_obj->u.pkt_obj->paylen = paylen; - pkt_hash_obj->u.pkt_obj->tag_size = tag_size; - pkt_hash_obj->u.pkt_obj->payload_offset = offset; - - offset += paylen; - - add_hashobject_to_hashtable(pkt_hash_obj); - add_to_pkt_object_list(seg_hash, pkt_hash_obj); - - pktcnt++; - - retval = get_packet(device_fd, &tag, sizeof (fru_tag_t), - offset); - if (retval == -1) { - return (retval); - } - - data = (char *)&tag; - } - - segdesc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor; - - seg_hash->u.seg_obj->trailer_offset = offset; - - if (!segdesc->field.ignore_checksum) { - crc = get_checksum_crc(device_fd, seg_hash, seg_limit); - offset = seg_hash->u.seg_obj->segment.offset; - - retval = pread(device_fd, &origcrc, sizeof (origcrc), - offset + seg_limit + 1); - if (retval != sizeof (origcrc)) { - return (-1); - } - - if (origcrc != crc) { - seg_hash->u.seg_obj->trailer_offset = offset; - return (-1); - } - } - - return (pktcnt); -} - -/* - * Description : - * fru_get_num_packets() returns the current number of packets - * in a segment. - * - * Arguments : segment_hdl_t : segment handle. - * - * Return : - * int - * On success, the number of packets is returned; - * -1 on failure. - */ -/*ARGSUSED*/ -int -fru_get_num_packets(segment_hdl_t segment, door_cred_t *cred) -{ - int device_fd; - int pktcnt; - int length; - uint16_t offset; - hash_obj_t *cont_hash_obj; - hash_obj_t *seg_hash; - fru_segdesc_t *segdesc; - segment_obj_t *segment_object; - - seg_hash = lookup_handle_object(segment, SEGMENT_TYPE); - if (seg_hash == NULL) { - return (-1); - } - - segment_object = seg_hash->u.seg_obj; - if (segment_object == NULL) { - return (-1); - } - - - segdesc = (fru_segdesc_t *)&segment_object->segment.descriptor; - if (segdesc->field.opaque) { - return (0); - } - - offset = segment_object->segment.offset; - length = segment_object->segment.length; - - cont_hash_obj = get_container_hash_object(SEGMENT_TYPE, - segment_object->section_hdl); - - if (cont_hash_obj == NULL) { - return (-1); - } - - if (seg_hash->u.seg_obj->pkt_obj_list != NULL) { - return (segment_object->num_of_packets); - } - - segment_object->num_of_packets = 0; - device_fd = open(cont_hash_obj->u.cont_obj->device_pathname, - O_RDWR); - if (device_fd < 0) { - return (-1); - } - - pktcnt = get_packets(seg_hash, device_fd, offset, - length); - if (pktcnt == -1) { - free_pkt_object_list(seg_hash); - seg_hash->u.seg_obj->pkt_obj_list = NULL; - } - - segment_object->num_of_packets = pktcnt; - (void) close(device_fd); - - return (segment_object->num_of_packets); -} - - -/* - * Description : - * fru_get_packets() fills an array of structures representing the - * packets in a segment. - * - * Arguments : segment_hdl_t : segment handle. - * packet_t : packet buffer. - * int : maximum number of packets. - * - * Return : - * int - * On success, the number of packet structures written is returned; - * On failure -1 is returned; - * - */ -/*ARGSUSED*/ -int -fru_get_packets(segment_hdl_t segment, packet_t *packet, int maxpackets, - door_cred_t *cred) -{ - int count; - hash_obj_t *seg_hash_obj; - hash_obj_t *pkt_hash_obj; - - /* segment hash object */ - seg_hash_obj = lookup_handle_object(segment, SEGMENT_TYPE); - if (seg_hash_obj == NULL) { - return (-1); - } - - if (seg_hash_obj->u.seg_obj->num_of_packets != maxpackets) { - return (-1); - } - - pkt_hash_obj = seg_hash_obj->u.seg_obj->pkt_obj_list; - if (pkt_hash_obj == NULL) { - return (-1); - } - - for (count = 0; count < maxpackets; count++, packet++) { - packet->handle = pkt_hash_obj->obj_hdl; - packet->tag = 0; - (void) memcpy(&packet->tag, &pkt_hash_obj->u.pkt_obj->tag, - pkt_hash_obj->u.pkt_obj->tag_size); - pkt_hash_obj = pkt_hash_obj->u.pkt_obj->next; - } - - return (0); -} - -/* - * Description : - * fru_get_payload() copies the contents of a packet's payload. - * - * Arguments : packet_hdl_t : packet handle. - * void * : payload buffer. - * size_t : sizeof the buffer. - * - * Return : - * int - * On success, the number of bytes copied is returned; On error - * -1 returned. - */ -/*ARGSUSED*/ -ssize_t -fru_get_payload(packet_hdl_t packet, void *buffer, size_t nbytes, - door_cred_t *cred) -{ - int retval; - int device_fd; - uint8_t *payload; - hash_obj_t *packet_hash_obj; - hash_obj_t *segment_hash_obj; - hash_obj_t *container_hash_obj; - - /* packet hash object */ - packet_hash_obj = lookup_handle_object(packet, PACKET_TYPE); - if (packet_hash_obj == NULL) { - return (-1); - } - - payload = malloc(packet_hash_obj->u.pkt_obj->paylen); - if (payload == NULL) { - return (-1); - } - - /* lookup the segment hash object */ - segment_hash_obj = - lookup_handle_object(packet_hash_obj->u.pkt_obj->segment_hdl, - SEGMENT_TYPE); - if (segment_hash_obj == NULL) { - free(payload); - return (-1); - } - - /* Get the container hash object to get the seeprom device path */ - container_hash_obj = get_container_hash_object(SEGMENT_TYPE, - segment_hash_obj->u.seg_obj->section_hdl); - if (container_hash_obj == NULL) { - free(payload); - return (-1); - } - - /* Open the seeprom device */ - device_fd = open(container_hash_obj->u.cont_obj->device_pathname, - O_RDWR); - if (device_fd < 0) { - free(payload); - return (-1); - } - - - /* Call to get the payload */ - retval = get_payload(device_fd, packet_hash_obj, payload); - if (retval == -1) { - free(payload); - (void) close(device_fd); - return (-1); - } - - - /* verify payload length */ - if (nbytes != packet_hash_obj->u.pkt_obj->paylen) { - free(payload); - (void) close(device_fd); - return (-1); - } - - (void) memcpy(buffer, payload, nbytes); - free(payload); - (void) close(device_fd); - return (nbytes); -} - -/* - * Description : - * fru_update_payload() writes the contents of a packet's payload. - * - * Arguments : packet_hdl_t : packet handle. - * const void * : data buffer. - * size_t : buffer size. - * packet_hdl_t : new packet handle. - * - * Return : - * int - * On success, 0 is returned; on failure - * -1 is returned. - */ - -int -fru_update_payload(packet_hdl_t packet, const void *data, size_t nbytes, - packet_hdl_t *newpacket, door_cred_t *cred) -{ - int fd; - int segment_offset; - int trailer_offset; - int retval; - uint32_t crc; - hash_obj_t *pkt_hash; - hash_obj_t *seg_hash; - hash_obj_t *sec_hash; - hash_obj_t *cont_hash; - fru_segdesc_t *desc; - - /* check the effective uid of the client */ - if (cred->dc_euid != 0) { - errno = EPERM; - return (-1); /* not a root */ - } - - /* packet hash object */ - pkt_hash = lookup_handle_object(packet, PACKET_TYPE); - if (pkt_hash == NULL) { - return (-1); - } - - /* segment hash object */ - seg_hash = lookup_handle_object(pkt_hash->u.pkt_obj->segment_hdl, - SEGMENT_TYPE); - if (seg_hash == NULL) { - return (-1); - } - - /* check for write perm. */ - desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor; - if (!(desc->field.field_perm & SEGMENT_WRITE)) { - errno = EPERM; - return (-1); /* write not allowed */ - } - - sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl, - SECTION_TYPE); - if (sec_hash == NULL) { - return (-1); - } - - if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) { - errno = EPERM; - return (-1); /* read-only section */ - } - - cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - if (cont_hash == NULL) { - return (-1); - } - - if (pkt_hash->u.pkt_obj->paylen != nbytes) { - return (-1); - } - - fd = open(cont_hash->u.cont_obj->device_pathname, O_RDWR); - if (fd < 0) { - return (-1); - } - - trailer_offset = seg_hash->u.seg_obj->trailer_offset; - segment_offset = seg_hash->u.seg_obj->segment.offset; - - crc = get_checksum_crc(fd, seg_hash, (trailer_offset - segment_offset)); - retval = pwrite(fd, data, nbytes, pkt_hash->u.pkt_obj->payload_offset); - if (retval != nbytes) { - (void) close(fd); - return (-1); - } - - retval = pwrite(fd, &crc, sizeof (crc), trailer_offset + 1); - (void) close(fd); - if (retval != sizeof (crc)) { - return (-1); - } - *newpacket = packet; - return (0); -} - -/* - * Description : - * fru_append_packet() appends a packet to a segment. - * - * Arguments : - * segment_hdl_t segment - * A handle for the segment to which the packet will be appended. - * - * packet_t *packet - * On entry, the "tag" component of "packet" specifies the tag - * value for the added packet; the "handle" component is ignored. - * On return, the "handle" component is set to the handle of the - * appended packet. - * - * const void *payload - * A pointer to the caller's buffer containing the payload data for - * the appended packet. - * - * size_t nbytes - * The size of the caller buffer. - * - * Return : - * int - * On success, 0 is returned; on error -1 is returned; - */ - -int -fru_append_packet(segment_hdl_t segment, packet_t *packet, const void *payload, - size_t nbytes, segment_hdl_t *newsegment, door_cred_t *cred) -{ - int trailer_offset; - int tag_size; - int fd; - int retval; - char trailer[] = {0x0c, 0x00, 0x00, 0x00, 0x00}; - uint32_t crc; - hash_obj_t *seg_hash; - hash_obj_t *sec_hash; - hash_obj_t *pkt_hash; - hash_obj_t *cont_hash; - fru_tagtype_t tagtype; - fru_segdesc_t *desc; - - /* check the effective uid of the client */ - if (cred->dc_euid != 0) { - errno = EPERM; - return (-1); /* not a root */ - } - - seg_hash = lookup_handle_object(segment, SEGMENT_TYPE); - if (seg_hash == NULL) { - return (-1); - } - - /* check for write perm. */ - desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor; - if (!(desc->field.field_perm & SEGMENT_WRITE)) { - errno = EPERM; - return (-1); /* write not allowed */ - } - - sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl, - SECTION_TYPE); - if (sec_hash == NULL) { - return (-1); - } - - if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) { - errno = EPERM; - return (-1); /* read-only section */ - } - - trailer_offset = seg_hash->u.seg_obj->trailer_offset; - - /* - * if trailer offset is 0 than parse the segment data to get the trailer - * offset to compute the remaining space left in the segment area for - * new packet to be added. - */ - if (trailer_offset == 0) { - (void) fru_get_num_packets(segment, cred); - trailer_offset = seg_hash->u.seg_obj->trailer_offset; - } - - tagtype = get_tag_type((void *)&packet->tag); - if (tagtype == -1) { - return (-1); - } - - tag_size = get_tag_size(tagtype); - if (tag_size == -1) { - return (-1); - } - - if (seg_hash->u.seg_obj->segment.length > - ((trailer_offset - seg_hash->u.seg_obj->segment.offset) + - tag_size + nbytes + sizeof (char) - + sizeof (uint32_t))) { - /* create new packet hash */ - pkt_hash = create_packet_hash_object(); - if (pkt_hash == NULL) { - return (-1); - } - - /* tag initialization */ - (void) memcpy(&pkt_hash->u.pkt_obj->tag, &packet->tag, - tag_size); - pkt_hash->u.pkt_obj->tag_size = tag_size; - pkt_hash->u.pkt_obj->paylen = nbytes; - pkt_hash->u.pkt_obj->payload_offset = trailer_offset + tag_size; - - /* add to hash table */ - add_hashobject_to_hashtable(pkt_hash); - - add_to_pkt_object_list(seg_hash, pkt_hash); - - cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - if (cont_hash == NULL) { - return (-1); - } - - fd = open(cont_hash->u.cont_obj->device_pathname, O_RDWR); - if (fd < 0) { - return (-1); - } - - /* update the trailer offset */ - trailer_offset += tag_size + nbytes; - - /* calculate new checksum */ - crc = get_checksum_crc(fd, seg_hash, (trailer_offset - - seg_hash->u.seg_obj->segment.offset)); - - retval = pwrite(fd, &packet->tag, tag_size, trailer_offset - - (tag_size + nbytes)); - if (retval != tag_size) { - (void) close(fd); - return (-1); - } - - retval = pwrite(fd, payload, nbytes, trailer_offset - nbytes); - if (retval != nbytes) { - (void) close(fd); - return (-1); - } - - retval = pwrite(fd, trailer, sizeof (trailer), trailer_offset); - if (retval != sizeof (trailer)) { - (void) close(fd); - return (-1); - } - - retval = pwrite(fd, &crc, sizeof (crc), trailer_offset + 1); - (void) close(fd); - if (retval != sizeof (crc)) { - return (-1); - } - - seg_hash->u.seg_obj->trailer_offset = trailer_offset; - seg_hash->u.seg_obj->num_of_packets += 1; - - *newsegment = segment; /* return new segment handle */ - return (0); - } else { - errno = EAGAIN; - } - - return (-1); -} - -static void -adjust_packets(int fd, hash_obj_t *free_obj, hash_obj_t *object_list) -{ - int retval; - uint8_t *payload; - uint32_t new_offset; - hash_obj_t *hash_ptr; - - - new_offset = free_obj->u.pkt_obj->payload_offset - - free_obj->u.pkt_obj->tag_size; - for (hash_ptr = object_list; hash_ptr != NULL; - hash_ptr = hash_ptr->u.pkt_obj->next) { - - payload = malloc(hash_ptr->u.pkt_obj->paylen); - if (payload == NULL) { - return; - } - retval = get_payload(fd, hash_ptr, payload); - if (retval == -1) { - free(payload); - return; - } - - retval = pwrite(fd, &hash_ptr->u.pkt_obj->tag, - hash_ptr->u.pkt_obj->tag_size, new_offset); - if (retval != hash_ptr->u.pkt_obj->tag_size) { - free(payload); - return; - } - new_offset += hash_ptr->u.pkt_obj->tag_size; - hash_ptr->u.pkt_obj->payload_offset = new_offset; - retval = pwrite(fd, payload, - hash_ptr->u.pkt_obj->paylen, new_offset); - if (retval != hash_ptr->u.pkt_obj->paylen) { - free(payload); - return; - } - new_offset += hash_ptr->u.pkt_obj->paylen; - free(payload); - } -} - -static void -free_packet_object(handle_t handle, hash_obj_t *seg_hash) -{ - hash_obj_t *pkt_hash; - hash_obj_t *next_hash; - - pkt_hash = seg_hash->u.seg_obj->pkt_obj_list; - if (pkt_hash == NULL) { - return; - } - - if (pkt_hash->obj_hdl == handle) { - seg_hash->u.seg_obj->pkt_obj_list = pkt_hash->u.pkt_obj->next; - } else { - while (pkt_hash->obj_hdl != handle) { - next_hash = pkt_hash; - pkt_hash = pkt_hash->u.pkt_obj->next; - if (pkt_hash == NULL) { - return; - } - } - next_hash->u.pkt_obj->next = pkt_hash->u.pkt_obj->next; - } - - if (pkt_hash->prev == NULL) { - hash_table[(pkt_hash->obj_hdl % TABLE_SIZE)] = pkt_hash->next; - if (pkt_hash->next != NULL) { - pkt_hash->next->prev = NULL; - } - } else { - pkt_hash->prev->next = pkt_hash->next; - if (pkt_hash->next != NULL) { - pkt_hash->next->prev = pkt_hash->prev; - } - } - - free(pkt_hash->u.pkt_obj); - free(pkt_hash); -} - -/* - * Description : - * fru_delete_packet() deletes a packet from a segment. - * - * Arguments : packet_hdl_t : packet number to be deleted. - * segment_hdl_t : new segment handler. - * - * Return : - * int - * On success, 0 is returned; on error, -1. - * - * NOTES - * Packets are adjacent; thus, deleting a packet requires moving - * succeeding packets to compact the resulting hole. - */ - -int -fru_delete_packet(packet_hdl_t packet, segment_hdl_t *newsegment, - door_cred_t *cred) -{ - int retval; - int fd; - char trailer[] = { 0x0c, 0x00, 0x00, 0x00, 0x00}; - uint32_t crc; - hash_obj_t *tmp_obj; - hash_obj_t *pkt_hash; - hash_obj_t *sec_hash; - hash_obj_t *cont_hash; - hash_obj_t *prev_obj; - hash_obj_t *seg_hash; - fru_segdesc_t *desc; - - /* check the effective uid of the client */ - if (cred->dc_euid != 0) { - errno = EPERM; - return (-1); /* not a root */ - } - - /* packet hash object */ - pkt_hash = lookup_handle_object(packet, PACKET_TYPE); - if (pkt_hash == NULL) { - return (-1); - } - - /* segment hash object */ - seg_hash = lookup_handle_object(pkt_hash->u.pkt_obj->segment_hdl, - SEGMENT_TYPE); - if (seg_hash == NULL) { - return (-1); - } - - /* check for write perm. */ - desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor; - if (!(desc->field.field_perm & SEGMENT_WRITE)) { - errno = EPERM; - return (-1); /* write not allowed */ - } - - /* section hash object */ - sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl, - SECTION_TYPE); - if (sec_hash == NULL) { - return (-1); - } - - if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) { - errno = EPERM; - return (-1); /* read-only section */ - } - - prev_obj = seg_hash->u.seg_obj->pkt_obj_list; - if (prev_obj == NULL) { - return (-1); - } - - /* container hash object */ - cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl, - CONTAINER_TYPE); - if (cont_hash == NULL) { - return (-1); - } - - fd = open(cont_hash->u.cont_obj->device_pathname, O_RDWR); - if (fd < 0) { - return (-1); - } - - if (prev_obj->obj_hdl == packet) { /* first object to be deleted */ - adjust_packets(fd, prev_obj, prev_obj->u.pkt_obj->next); - seg_hash->u.seg_obj->trailer_offset -= - (prev_obj->u.pkt_obj->tag_size - + prev_obj->u.pkt_obj->paylen); - free_packet_object(packet, seg_hash); - } else { - for (tmp_obj = prev_obj; - tmp_obj != NULL; tmp_obj = tmp_obj->u.pkt_obj->next) { - /* found the object */ - if (tmp_obj->obj_hdl == packet) { - adjust_packets(fd, tmp_obj, - tmp_obj->u.pkt_obj->next); - seg_hash->u.seg_obj->trailer_offset -= - (tmp_obj->u.pkt_obj->tag_size - + tmp_obj->u.pkt_obj->paylen); - free_packet_object(packet, seg_hash); - } - } - } - - seg_hash->u.seg_obj->num_of_packets -= 1; - - /* calculate checksum */ - crc = get_checksum_crc(fd, seg_hash, - (seg_hash->u.seg_obj->trailer_offset - - seg_hash->u.seg_obj->segment.offset)); - /* write trailer at new offset */ - retval = pwrite(fd, &trailer, sizeof (trailer), - seg_hash->u.seg_obj->trailer_offset); - if (retval != sizeof (trailer)) { - (void) close(fd); - return (-1); - } - - /* write the checksum value */ - retval = pwrite(fd, &crc, sizeof (crc), - seg_hash->u.seg_obj->trailer_offset + 1); - (void) close(fd); - if (retval != sizeof (crc)) { - return (-1); - } - - *newsegment = seg_hash->obj_hdl; /* return new segment handle */ - return (0); -} - -/* - * Description : - * fru_close_container() removes the association between a - * container and its handle. this routines free's up all the - * hash object contained under container. - * - * Arguments : - * container_hdl_t holds the file descriptor of the fru. - * - * Return : - * int - * return 0. - * - */ - -/* ARGSUSED */ -int -fru_close_container(container_hdl_t container) -{ - hash_obj_t *hash_obj; - hash_obj_t *prev_hash; - hash_obj_t *sec_hash_obj; - handle_t obj_hdl; - - /* lookup for container hash object */ - hash_obj = lookup_handle_object(container, CONTAINER_TYPE); - if (hash_obj == NULL) { - return (0); - } - - /* points to section object list */ - sec_hash_obj = hash_obj->u.cont_obj->sec_obj_list; - - /* traverse section object list */ - while (sec_hash_obj != NULL) { - - /* traverse segment hash object in the section */ - while (sec_hash_obj->u.sec_obj->seg_obj_list != NULL) { - /* object handle of the segment hash object */ - obj_hdl = - sec_hash_obj->u.sec_obj->seg_obj_list->obj_hdl; - free_segment_hash(obj_hdl, sec_hash_obj); - } - - /* going to free section hash object, relink the hash object */ - if (sec_hash_obj->prev == NULL) { - hash_table[(sec_hash_obj->obj_hdl % TABLE_SIZE)] - = sec_hash_obj->next; - if (sec_hash_obj->next != NULL) { - sec_hash_obj->next->prev = NULL; - } - } else { - sec_hash_obj->prev->next = sec_hash_obj->next; - if (sec_hash_obj->next != NULL) { - sec_hash_obj->next->prev = sec_hash_obj->prev; - } - } - - free(sec_hash_obj->u.sec_obj); /* free section hash object */ - - prev_hash = sec_hash_obj; - - sec_hash_obj = sec_hash_obj->u.sec_obj->next; - - free(prev_hash); /* free section hash */ - } - - /* free container hash object */ - if (hash_obj->prev == NULL) { - hash_table[(sec_hash_obj->obj_hdl % TABLE_SIZE)] = - hash_obj->next; - if (hash_obj->next != NULL) { - hash_obj->next->prev = NULL; - } - } else { - hash_obj->prev->next = hash_obj->next; - if (hash_obj->next != NULL) { - hash_obj->next->prev = hash_obj->prev; - } - } - - free(hash_obj->u.cont_obj); - free(hash_obj); - return (0); -} - -/* - * Description : - * fru_is_data_available() checks to see if the frudata - * is available on a fru. - * - * Arguments : - * picl_nodehdl_t holds the picl node handle of the fru. - * - * Return : - * int - * return 1: if FRUID information is available - * return 0: if FRUID information is not present - * - */ - -/* ARGSUSED */ -int -fru_is_data_available(picl_nodehdl_t fru) -{ - return (0); -} diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_access_impl.h b/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_access_impl.h deleted file mode 100644 index 72691a0ab0..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_access_impl.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -#ifndef _FRU_ACCESS_IMPL_H -#define _FRU_ACCESS_IMPL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <dial.h> -#include <strings.h> -#include <libdevinfo.h> -#include <sys/systeminfo.h> -#include <picl.h> -#include <picltree.h> -#include "picldefs.h" -#include <syslog.h> -#include <errno.h> -#include "libfru.h" -#include "fru_tag.h" -#include "fru_access.h" - -/* object types */ -typedef enum {CONTAINER_TYPE, SECTION_TYPE, SEGMENT_TYPE, PACKET_TYPE} object_t; - -#define TABLE_SIZE 64 /* hash table size */ - -/* container configuration file name */ -#define CONTAINER_CONF_FILE \ - "/usr/platform/SUNW,Serverblade1/lib/fru_container.conf" - -/* section header */ -#define SECTION_HDR_TAG 0x08 -#define SECTION_HDR_VER 0x0001 -#define SECTION_HDR_LENGTH 0x06 -#define SECTION_HDR_CRC8 0x00 -#define SECTION_HDR_VER_BIT0 0x00 -#define SECTION_HDR_VER_BIT1 0x01 - -#define READ_ONLY_SECTION 1 /* section is read-only */ - -#define CRC32_SECTION 0 -#define CHECKSUM32_SECTION 1 - -#define GET_SEGMENT_DESCRIPTOR \ - (seg_layout->descriptor[1]|seg_layout->descriptor[0] << 16) - -#define GET_SECTION_HDR_VERSION \ - (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8) - -/* Segment Trailer Tag */ -#define SEG_TRAILER_TAG 0x0C - -/* defines fixed segment */ -#define SEGMENT_FIXED 1 - -typedef union { - uint32_t all_bits; - struct { - unsigned read_only : 1; - unsigned chk_type : 1; - unsigned unused : 8; - unsigned : 8; - unsigned : 8; - unsigned : 6; - } field; -} sectdescbit_t; - -typedef struct { - sectdescbit_t description; - uint32_t address; /* for SEEPROMS this is the offset */ - uint32_t size; -} sectioninfo_t; - -typedef uint16_t headerrev_t; - -#define MAX_NUMOF_SECTION 2 - -typedef struct { - headerrev_t header_ver; - int num_sections; - sectioninfo_t section_info[MAX_NUMOF_SECTION]; -} container_info_t; - - -/* section header layout */ -typedef struct { - uint8_t headertag; /* section header tag */ - uint8_t headerversion[2]; /* header version (msb) */ - uint8_t headerlength; /* header length */ - uint8_t headercrc8; /* crc8 */ - uint8_t segmentcount; /* total number of segment */ -} section_layout_t; - -/* segment header layout */ -typedef struct { - uint16_t name; /* segment name */ - uint16_t descriptor[2]; /* descriptor (msb) */ - uint16_t offset; /* segment data offset */ - uint16_t length; /* segment length */ -} segment_layout_t; - -/* segment information used in finding new offset for a new segment */ -typedef struct { - int segnum; /* segment number */ - int offset; /* segment offset */ - int length; /* segment length */ - int fixed; /* fixed or non-fixed segment */ -} seg_info_t; - -typedef uint64_t handle_t; - -struct hash_obj; - -/* packet hash object */ -typedef struct { - handle_t segment_hdl; /* segment handle */ - fru_tag_t tag; - int tag_size; - uint32_t paylen; - uint32_t payload_offset; - struct hash_obj *next; -} packet_obj_t; - -/* segment hash object */ -typedef struct { - handle_t section_hdl; /* section handle */ - int num_of_packets; /* in a segment */ - int trailer_offset; - segment_t segment; - struct hash_obj *pkt_obj_list; /* packet object list */ - struct hash_obj *next; -} segment_obj_t; - -/* section hash object */ -typedef struct { - handle_t cont_hdl; /* container handle */ - section_t section; - int num_of_segment; /* in a section */ - int checksum_method; /* indicates the checksum method used */ - struct hash_obj *seg_obj_list; /* points to segment objects list */ - struct hash_obj *next; -} section_obj_t; - -/* container hash object */ -typedef struct { - char device_pathname[PATH_MAX]; /* device name */ - int num_of_section; /* num of section in container */ - struct hash_obj *sec_obj_list; /* points to section objects list */ -} container_obj_t; - -/* hash object */ -typedef struct hash_obj { - int object_type; - handle_t obj_hdl; - union { - container_obj_t *cont_obj; - section_obj_t *sec_obj; - segment_obj_t *seg_obj; - packet_obj_t *pkt_obj; - } u; - struct hash_obj *next; - struct hash_obj *prev; -} hash_obj_t; - -unsigned char compute_crc8(unsigned char *bytes, int length); -long compute_crc32(unsigned char *bytes, int length); -long compute_checksum32(unsigned char *bytes, int length); - -#ifdef __cplusplus -} -#endif - -#endif /* _FRU_ACCESS_IMPL_H */ diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_container.conf b/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_container.conf deleted file mode 100644 index 282f6c3db1..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/fruaccess/fru_container.conf +++ /dev/null @@ -1,36 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# - -# cut off read only section. -8k_6krw1792ro_SEEPROM:1:0,0,6144:1,6144,1792 - -# Note the extra flag per section to represent the checksum method -# 0 = CRC32 1 = CHECKSUM32 -# standard SEEPROM -i2c-at24c64|6krw2kro|8k_6krw2kro_SEEPROM:1:1,1,0,6144:1,0,6144,2048 - diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/frudata/Makefile b/usr/src/cmd/picl/plugins/sun4u/blade/frudata/Makefile deleted file mode 100644 index 0e76092544..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/frudata/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/picl/plugins/sun4u/blade/frudata/Makefile -# - -include $(SRC)/Makefile.psm - -# include library definitions -include $(SRC)/lib/Makefile.lib - -ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Serverblade1 - -include $(SRC)/cmd/picl/plugins/Makefile.com - -ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR) - -CONF= libpiclfrudata.conf -ROOTCONF= $(CONF:%=$(ROOTLIBDIR)/%) -$(ROOTCONF) := FILEMODE = 0644 - -ROOTLINTDIR = $(ROOTLIBDIR) - -.KEEP_STATE: - -SUBDIRS= - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint - -all: $(CONF) - -install: $(ROOTLIBDIR) $(ROOTCONF) - -# include library targets -include $(SRC)/lib/Makefile.targ -include $(SRC)/cmd/picl/plugins/Makefile.targ - -$(ROOTLINTDIR)/%: ../% - $(INS.file) - -lint: - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/frudata/libpiclfrudata.conf b/usr/src/cmd/picl/plugins/sun4u/blade/frudata/libpiclfrudata.conf deleted file mode 100644 index 1cfadefdcd..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/frudata/libpiclfrudata.conf +++ /dev/null @@ -1,34 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# -# This file creates the FRU device paths for the FRUAccess library -# - -VERSION 1.0 - -name:/platform/pci/isa/bscbus/i2c/motherboard-fru -PROP FRUDevicePath string r 0 "/devices/pci@1f,0/isa@7/bscbus@0,1000/i2c@300,0/motherboard-fru@0,a0:motherboard-fru" diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/frutree/Makefile b/usr/src/cmd/picl/plugins/sun4u/blade/frutree/Makefile deleted file mode 100644 index c71fdb90df..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/frutree/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/picl/plugins/sun4u/blade/frutree/Makefile -# - -include $(SRC)/Makefile.psm - -# include library definitions -include $(SRC)/lib/Makefile.lib - -ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Serverblade1 - - -include $(SRC)/cmd/picl/plugins/Makefile.com - -ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR) - -CONF= piclfrutree.conf -ROOTCONF= $(CONF:%=$(ROOTLIBDIR)/%) -$(ROOTCONF) := FILEMODE = 0644 -INFOS= piclfrutree.info system-board.info - -ROOTLINTDIR = $(ROOTLIBDIR) - -.KEEP_STATE: - -SUBDIRS= - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint - -all: $(CONF) - -install: $(ROOTLIBDIR) $(ROOTCONF) - -$(CONF): $(INFOS) - $(RM) $@ - $(CPP) piclfrutree.info | \ - $(SED) -e '/^[ ]*$$/d' -e '/^#/d' > $@ - -# include library targets -include $(SRC)/lib/Makefile.targ -include $(SRC)/cmd/picl/plugins/Makefile.targ - -$(ROOTLINTDIR)/%: ../% - $(INS.file) - -lint: - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/frutree/piclfrutree.info b/usr/src/cmd/picl/plugins/sun4u/blade/frutree/piclfrutree.info deleted file mode 100644 index 810c7b479c..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/frutree/piclfrutree.info +++ /dev/null @@ -1,74 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * #ident "%Z%%M% %I% %E% SMI" - * - * supported prop types: void, int, uint, float, string - * supported prop access_modes: r, w, rw - * - * VERSION <version_number> -- supported version number is 1.0 - * - * name:<namepath> -- gives the anchor node - * where <namepath> is <nodename>[@<bus-addr>][?<prop>=<val>] - * - * _class:<classpath> -- gives the anchor node - * where <classpath> is <classname>[@<bus-addr>][?<prop>=<val>] - * - * NODE <name> <class> - * {describes a subtree} - * ENDNODE - * - * PROP <name> <type> <access_mode> [<size> <value>] -- per property - * - * REFPROP <name> <dstnode> - * - * REFNODE <name> <class> with <destnode> -- Associates a new node - * with <destnode> if exists - * where - * <name> is the nodename - * <class> is the picl class. - * <destnode> is name:<namepath> or _class:<classpath> - * - * If "name:" or "_class:" is not specified in the <path>, - * the default is "name:" - * - */ - -VERSION 1.0 -VERBOSE 1 -NODE frutree picl - NODE chassis fru - /* - * SunMC physical view view_points for this platform - * This will get moved to a separate SunMC physical view plugin later. - */ - PROP ViewPoints string r 0 "front rear side" - PROP SlotType string r 0 "chassis" - PROP Label string r 0 "Blade" - ENDNODE -ENDNODE - -name:/frutree/chassis -#include "system-board.info" diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/frutree/system-board.info b/usr/src/cmd/picl/plugins/sun4u/blade/frutree/system-board.info deleted file mode 100644 index 6bb20ad990..0000000000 --- a/usr/src/cmd/picl/plugins/sun4u/blade/frutree/system-board.info +++ /dev/null @@ -1,115 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * #ident "%Z%%M% %I% %E% SMI" - * - * This file creates the system board structure - */ - -NODE system-board fru - PROP SlotType string r 0 "system-board" - NODE cpu-slot location - PROP SlotType string r 0 "cpu" - PROP Label string r 0 "CPU0" - PROP Slot uint r 4 0 - ENDNODE - NODE fan-slot location - PROP SlotType string r 0 "fan-unit" - PROP Label string r 0 "cpu-fan" - PROP Slot uint r 4 0 - ENDNODE - NODE mem-slot location - PROP SlotType string r 0 "memory-module" - PROP Slot uint r 4 0 - PROP Label string r 0 "DIMM0" - ENDNODE - NODE mem-slot location - PROP SlotType string r 0 "memory-module" - PROP Slot uint r 4 1 - PROP Label string r 0 "DIMM1" - ENDNODE -ENDNODE - -/* - * create the fru modules for CPUs in the fru tree - */ -name:/frutree/chassis/system-board/cpu-slot?Slot=0 -REFNODE cpu-module fru WITH _class:/upa/cpu?ID=0 - - -/* - * seeprom source for motherboard - */ -name:/frutree/chassis/system-board -PROP FRUDataAvailable void r -REFPROP _seeprom_source name:/platform/pci/isa/bscbus/i2c/motherboard-fru - - -/* - * Set up memory module fru - */ -name:/frutree/chassis/system-board/mem-slot?Label=DIMM0 -REFNODE mem-module fru WITH name:/platform/pci/pmu/i2c/dimm-fru-prom?UnitAddress=0,a8 - -name:/frutree/chassis/system-board/mem-slot?Label=DIMM1 -REFNODE mem-module fru WITH name:/platform/pci/pmu/i2c/dimm-fru-prom?UnitAddress=0,aa - - -/* - * _fru_parent memory seeprom devices - */ -name:/platform/pci/pmu/i2c/dimm-fru-prom?UnitAddress=0,a8 -REFPROP _fru_parent name:/frutree/chassis/system-board/mem-slot?Label=DIMM0/mem-module - -name:/platform/pci/pmu/i2c/dimm-fru-prom?UnitAddress=0,aa -REFPROP _fru_parent name:/frutree/chassis/system-board/mem-slot?Label=DIMM1/mem-module - - -/* - * _fru_parent CPU, memory-controller devices - */ -_class:cpu?ID=0 -REFPROP _fru_parent /frutree/chassis/system-board/cpu-slot?Slot=0/cpu-module - -name:/platform/memory-controller?portid=0 -REFPROP _fru_parent /frutree/chassis/system-board/cpu-slot?Slot=0/cpu-module - - -/* - * _fru_parent motherboard & platform - */ -name:/platform/pci/isa/bscbus/i2c/motherboard-fru -REFPROP _fru_parent /frutree/chassis/system-board -name:/platform -REFPROP _fru_parent /frutree/chassis/system-board - -/* - * _fru_parent memory modules - */ -name:/platform/memory-controller/memory-module?ID=0 -REFPROP _fru_parent name:/frutree/chassis/system-board/mem-slot?Label=DIMM0/mem-module - -name:/platform/memory-controller/memory-module?ID=1 -REFPROP _fru_parent name:/frutree/chassis/system-board/mem-slot?Label=DIMM1/mem-module diff --git a/usr/src/cmd/picl/plugins/sun4u/grover/memcfg/Makefile b/usr/src/cmd/picl/plugins/sun4u/grover/memcfg/Makefile index 05a2a87f81..a1a6034e34 100644 --- a/usr/src/cmd/picl/plugins/sun4u/grover/memcfg/Makefile +++ b/usr/src/cmd/picl/plugins/sun4u/grover/memcfg/Makefile @@ -21,6 +21,7 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2019 Peter Tribble. # include $(SRC)/Makefile.psm @@ -57,19 +58,6 @@ LDLIBS += -L$(ROOT)/usr/lib/picl/plugins LDLIBS += -lc -lpicltree -lpicldevtree LDLIBS += -R/usr/platform/\$$PLATFORM/lib/picl/plugins:/usr/platform/sun4u/lib/picl/plugins:/usr/lib/picl/plugins - -LINKED_PLATFORMS = SUNW,Serverblade1 - -LINKED_DIRS = $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%) -LINKED_LIB_DIRS = $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib) -LINKED_PICL_DIRS = $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/picl) -LINKED_PLUGIN_DIRS = $(LINKED_PLATFORMS:%=$(USR_PLAT_DIR)/%/lib/picl/plugins) - -LINKED_PLUGINS_DYNLIBS = $(LINKED_PLUGIN_DIRS:%=%/$(DYNLIB)) -LINKED_PLUGINS_LIBLINKS = $(LINKED_PLUGIN_DIRS:%=%/$(LIBLINKS)) - -GROVER_DYNLIB_DIR = ../../../../SUNW,Sun-Blade-100/lib/picl/plugins - PLATFORM= SUNW,Sun-Blade-100 .KEEP_STATE: @@ -87,9 +75,7 @@ POFILE= piclmemcfg.po all: $(LIBS) $(LIBLINKS) -install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS) \ - $(LINKED_PLUGIN_DIRS) $(LINKED_PLUGINS_DYNLIBS) \ - $(LINKED_PLUGINS_LIBLINKS) +install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS) _msg: $(MSGDOMAIN) $(POFILE) $(RM) $(MSGDOMAIN)/$(POFILE) @@ -101,25 +87,6 @@ $(MSGDOMAIN): $(LIBLINKS): FRC $(RM) $@; $(SYMLINK) $(DYNLIB) $@ -# Linked platforms directory hierarchy -$(LINKED_DIRS): - $(INS.dir) -$(LINKED_LIB_DIRS): $(LINKED_DIRS) - $(INS.dir) -$(LINKED_PICL_DIRS): $(LINKED_LIB_DIRS) - $(INS.dir) -$(LINKED_PLUGIN_DIRS): $(LINKED_PICL_DIRS) - $(INS.dir) - -# Linked platforms links -$(LINKED_PLUGINS_DYNLIBS): $(LINKED_PLUGIN_DIRS) - $(RM) -r $@ ;\ - $(SYMLINK) $(GROVER_DYNLIB_DIR)/$(DYNLIB) $@ - -$(LINKED_PLUGINS_LIBLINKS): $(LINKED_PLUGIN_DIRS) - $(RM) -r $@ ;\ - $(SYMLINK) $(GROVER_DYNLIB_DIR)/$(DYNLIB) $@ - # include library targets include $(SRC)/cmd/picl/plugins/Makefile.targ include $(SRC)/lib/Makefile.targ diff --git a/usr/src/cmd/rcm_daemon/Makefile.com b/usr/src/cmd/rcm_daemon/Makefile.com index a091064c93..bec924922a 100644 --- a/usr/src/cmd/rcm_daemon/Makefile.com +++ b/usr/src/cmd/rcm_daemon/Makefile.com @@ -22,7 +22,7 @@ # # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2016 Nexenta Systems, Inc. -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. # Copyright 2019 Peter Tribble. # @@ -137,7 +137,7 @@ SUNW_bridge_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm -lnvpair SUNW_mpxio_rcm.so := LDLIBS_MODULES += -ldevinfo LDLIBS_MODULES += -L$(ROOT)/lib -lrcm -lc -LDLIBS += -lgen -lelf -lrcm -lnvpair -ldevinfo -lnsl -lsocket +LDLIBS += -lrcm -lnvpair SRCS = $(RCM_SRC) $(COMMON_MOD_SRC) diff --git a/usr/src/cmd/sgs/ldprof/Makefile.com b/usr/src/cmd/sgs/ldprof/Makefile.com index 577ffbbc74..b12ae3a396 100644 --- a/usr/src/cmd/sgs/ldprof/Makefile.com +++ b/usr/src/cmd/sgs/ldprof/Makefile.com @@ -21,7 +21,7 @@ # # Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. # @@ -50,6 +50,8 @@ CFLAGS += $(C_PICFLAGS) SMOFF += indenting +ZGUIDANCE = -zguidance=nounused + LDLIBS += $(ZRECORD) -lmapmalloc -lc $(DLLIB) BLTDEFS= msg.h diff --git a/usr/src/cmd/sgs/libcrle/Makefile.com b/usr/src/cmd/sgs/libcrle/Makefile.com index c77dfa9500..e4c190f449 100644 --- a/usr/src/cmd/sgs/libcrle/Makefile.com +++ b/usr/src/cmd/sgs/libcrle/Makefile.com @@ -25,6 +25,8 @@ # # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. # +# Copyright 2020 Joyent, Inc. +# LIBRARY= libcrle.a VERS= .1 @@ -40,6 +42,8 @@ include $(SRC)/cmd/sgs/Makefile.com SRCDIR = ../common +ZGUIDANCE = -zguidance=nounused + LDLIBS += $(ZRECORD) -lmapmalloc $(DLLIB) -lc CPPFLAGS += -I$(SRC)/lib/libc/inc -I$(SRC)/common/sgsrtcid diff --git a/usr/src/cmd/sgs/libld/common/ldmain.c b/usr/src/cmd/sgs/libld/common/ldmain.c index 330a1cdf56..21703efc6f 100644 --- a/usr/src/cmd/sgs/libld/common/ldmain.c +++ b/usr/src/cmd/sgs/libld/common/ldmain.c @@ -24,6 +24,8 @@ * All Rights Reserved * * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * + * Copyright 2020 Joyent, Inc. */ /* @@ -480,8 +482,18 @@ ld_main(int argc, char **argv, Half mach) dbg_cleanup(); /* If any ERR_GUIDANCE messages were issued, add a summary */ - if (ofl->ofl_guideflags & FLG_OFG_ISSUED) + if (ofl->ofl_guideflags & FLG_OFG_ISSUED) { ld_eprintf(ofl, ERR_GUIDANCE, MSG_INTL(MSG_GUIDE_SUMMARY)); + ofl->ofl_guideflags &= ~FLG_OFG_ISSUED; + } + + /* + * One final check for any new warnings we found that should fail the + * link edit. + */ + if ((ofl->ofl_flags & (FLG_OF_WARN | FLG_OF_FATWARN)) == + (FLG_OF_WARN | FLG_OF_FATWARN)) + return (ld_exit(ofl)); /* * For performance reasons we don't actually free up the memory we've diff --git a/usr/src/cmd/svc/configd/Makefile b/usr/src/cmd/svc/configd/Makefile index 6312700741..e498673e40 100644 --- a/usr/src/cmd/svc/configd/Makefile +++ b/usr/src/cmd/svc/configd/Makefile @@ -24,7 +24,7 @@ # # Copyright 2015 RackTop Systems. # -# Copyright 2019 Joyent, Inc. +# Copyright 2020 Joyent, Inc. # MYPROG = svc.configd @@ -78,9 +78,10 @@ SCRIPTFILE = restore_repository ROOTSCRIPTFILE = $(ROOTCMDDIR)/$(SCRIPTFILE) # -# Native variant (used in ../seed) +# Native variant (used in ../seed). We only need to set NATIVE_LIBS if +# $(ADJUNCT_PROTO) is pointing outside of /usr/lib. # -$(NATIVE_BUILD)NATIVE_LIBS += libumem.so libc.so +$(NO_ADJUNCT_PROTO)NATIVE_LIBS += libumem.so libc.so $(NATIVE_BUILD)CC = $(NATIVECC) $(NATIVE_BUILD)LD = $(NATIVELD) $(NATIVE_BUILD)CFLAGS = $(NATIVE_CFLAGS) diff --git a/usr/src/cmd/svc/svccfg/Makefile b/usr/src/cmd/svc/svccfg/Makefile index 02e54e039c..ece4cb765e 100644 --- a/usr/src/cmd/svc/svccfg/Makefile +++ b/usr/src/cmd/svc/svccfg/Makefile @@ -21,7 +21,7 @@ # # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. # MYPROG = svccfg @@ -92,7 +92,11 @@ CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \ SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5 -lnvpair $(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla -NATIVE_LIBS += libxml2.so +# +# If no adjunct, then we'll already find /usr/lib via LDLIBS below. +# +$(NO_ADJUNCT_PROTO)NATIVE_LIBS += libxml2.so libl.so libumem.so \ + libmd5.so libnvpair.so libc.so LIBSCF = $(SRC)/lib/libscf LIBTECLA = $(SRC)/lib/libtecla # just for the header diff --git a/usr/src/cmd/ypcmd/Makefile b/usr/src/cmd/ypcmd/Makefile index 9667086a18..c94e593bd7 100644 --- a/usr/src/cmd/ypcmd/Makefile +++ b/usr/src/cmd/ypcmd/Makefile @@ -22,7 +22,7 @@ # Copyright 2015 Gary Mills # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. # BINPROG = ypmatch ypwhich ypcat @@ -157,6 +157,8 @@ CERRWARN += -_gcc=-Wno-unused-function # too many unknown types SMATCH = off +ZGUIDANCE = -zguidance=nounused + #conditional assignments ypalias.o := CPPFLAGS= -DMAIN $(CPPFLAGS.master) makedbm.o := CPPFLAGS= $(CPPFLAGS.master) @@ -178,7 +180,6 @@ all:= TARGET= all install:= TARGET= install clean:= TARGET= clean clobber:= TARGET= clobber -lint:= TARGET= lint cstyle := TARGET= cstyle all: $(SHAREDOBJ) $(SUBDIRS) $(PROG) $(TXTS) @@ -274,32 +275,6 @@ $(ROOTDIRS): $(SUBDIRS): FRC @cd $@; pwd; $(MAKE) $(TARGET) -lint := CPPFLAGS += -I$(SRC)/lib/libnisdb/yptol - -lint: $(SUBDIRS) - $(LINT.c) ypmatch.c nick.c -lnsl - $(LINT.c) ypwhich.c nick.c -lnsl - $(LINT.c) ypcat.c nick.c -lnsl - $(LINT.c) makedbm.c getlist.c yp_getalias.c - $(LINT.c) ypalias.c getlist.c yp_getalias.c - $(LINT.c) yp_b_svc.c yp_b_subr.c rpc_bootstrap.c getlist.c -lnsl - $(LINT.c) ypxfr.c ypxfrd_client.c ypxfrd_xdr.c getlist.c yp_getalias.c \ - ./shared/utils.c ./shared/lockmap.c ./shared/ancil.c -lnsl - $(LINT.c) yppush.c getlist.c yp_getalias.c -lnsl - $(LINT.c) udpublickey.c - $(LINT.c) mkalias.c -lnsl - $(LINT.c) stdethers.c -lsocket - $(LINT.c) stdhosts.c -lnsl - $(LINT.c) ypxfrd_svc.c ypxfrd_xdr.c ypxfrd_server.c \ - ypserv_net_secure.c \ - ./shared/utils.c ./shared/lockmap.c ./shared/ancil.c \ - -lnsl -lnisdb - $(LINT.c) ypserv.c ypserv_map.c ypserv_proc.c ypserv_ancil.c \ - ypserv_resolv.c ypserv_resolv_common.c ypv1_xdr.c \ - ypserv_net_secure.c getlist.c yp_getalias.c \ - ./shared/utils.c ./shared/lockmap.c ./shared/ancil.c \ - -lnsl -lnisdb - check: $(CHKMANIFEST) cstyle: $(SUBDIRS) diff --git a/usr/src/cmd/ypcmd/yppasswd/Makefile b/usr/src/cmd/ypcmd/yppasswd/Makefile index ac9f82d930..62cacdc3d1 100644 --- a/usr/src/cmd/ypcmd/yppasswd/Makefile +++ b/usr/src/cmd/ypcmd/yppasswd/Makefile @@ -21,7 +21,7 @@ # # Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. NETYPPROG = rpc.yppasswdd DEFAULTFILES = yppasswdd.dfl @@ -45,6 +45,8 @@ LDLIBS += -lnsl -lnisdb -lc MAPFILES = $(MAPFILE.INT) $(MAPFILE.NGB) LDFLAGS += $(MAPFILES:%=-M%) +ZGUIDANCE = -zguidance=nounused + # Pick up includes from library CPPFLAGS += -I$(SRC)/lib/libnisdb/yptol @@ -103,8 +105,6 @@ $(NETYP)/%: % clean: $(RM) $(OBJS) -lint: lint_SRCS - check: $(CHKMANIFEST) cstyle: diff --git a/usr/src/lib/auditd_plugins/remote/Makefile.com b/usr/src/lib/auditd_plugins/remote/Makefile.com index b8d4386412..363e1518e5 100644 --- a/usr/src/lib/auditd_plugins/remote/Makefile.com +++ b/usr/src/lib/auditd_plugins/remote/Makefile.com @@ -22,6 +22,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # +# Copyright 2020 Joyent, Inc. # LIBRARY= audit_remote.a @@ -33,7 +34,7 @@ LIBBSM= $(SRC)/lib/libbsm/common include $(SRC)/lib/Makefile.lib LIBS= $(DYNLIB) -LDLIBS += -lbsm -lsecdb -lc -lnsl -lsocket -lgss -lmtmalloc +LDLIBS += -lmtmalloc -lbsm -lsecdb -lc -lnsl -lsocket -lgss CFLAGS += $(CCVERBOSE) CPPFLAGS += -D_REENTRANT -I$(LIBBSM) diff --git a/usr/src/lib/brand/sn1/sn1_brand/Makefile.com b/usr/src/lib/brand/sn1/sn1_brand/Makefile.com index 4d26a454b0..8209995ce6 100644 --- a/usr/src/lib/brand/sn1/sn1_brand/Makefile.com +++ b/usr/src/lib/brand/sn1/sn1_brand/Makefile.com @@ -20,6 +20,7 @@ # # # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2020 Joyent, Inc. # LIBRARY = sn1_brand.a @@ -67,8 +68,9 @@ CFLAGS += $(CCVERBOSE) DYNFLAGS += $(DYNFLAGS_$(CLASS)) DYNFLAGS += $(BLOCAL) $(ZNOVERSION) -Wl,-e_start #DYNFLAGS += -R$(NATIVE_DIR)/lib -R$(NATIVE_DIR)/usr/lib -LDLIBS += -lc -lmapmalloc +LDLIBS += -lmapmalloc -lc +ZGUIDANCE = -zguidance=nounused $(LIBS):= PICS += $(SHAREDOBJS) .KEEP_STATE: diff --git a/usr/src/lib/brand/solaris10/s10_brand/Makefile.com b/usr/src/lib/brand/solaris10/s10_brand/Makefile.com index 2402984c2e..c644b3bc0b 100644 --- a/usr/src/lib/brand/solaris10/s10_brand/Makefile.com +++ b/usr/src/lib/brand/solaris10/s10_brand/Makefile.com @@ -21,6 +21,7 @@ # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright 2020 Joyent, Inc. # LIBRARY = s10_brand.a @@ -82,7 +83,7 @@ CSTD= $(CSTD_GNU99) C99LMODE= -Xc99=%all DYNFLAGS += $(DYNFLAGS_$(CLASS)) DYNFLAGS += $(BLOCAL) $(ZNOVERSION) -Wl,-e_start -LDLIBS += -lc -lmapmalloc +LDLIBS += -lmapmalloc -lc LINTFLAGS += -erroff=E_STATIC_UNUSED LINTFLAGS64 += -erroff=E_STATIC_UNUSED @@ -94,6 +95,4 @@ $(LIBS):= PICS += $(SHAREDOBJS) all: $(LIBS) -lint: lintcheck - include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/cfgadm_plugins/Makefile.com b/usr/src/lib/cfgadm_plugins/Makefile.com index 142d4f3314..99b6e8aadf 100644 --- a/usr/src/lib/cfgadm_plugins/Makefile.com +++ b/usr/src/lib/cfgadm_plugins/Makefile.com @@ -54,7 +54,6 @@ LINKED_PLATFORMS += SUNW,Sun-Fire-880 LINKED_PLATFORMS += SUNW,Sun-Fire-480R LINKED_PLATFORMS += SUNW,Sun-Fire-V890 LINKED_PLATFORMS += SUNW,Sun-Fire-V490 -LINKED_PLATFORMS += SUNW,Serverblade1 LINKED_PLATFORMS += SUNW,Netra-T12 LINKED_PLATFORMS += SUNW,Netra-T4 LINKED_PLATFORMS += SUNW,Netra-CP3010 diff --git a/usr/src/lib/fm/libfmd_snmp/Makefile.com b/usr/src/lib/fm/libfmd_snmp/Makefile.com index dc5b046c12..99dd888363 100644 --- a/usr/src/lib/fm/libfmd_snmp/Makefile.com +++ b/usr/src/lib/fm/libfmd_snmp/Makefile.com @@ -22,6 +22,8 @@ # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # +# Copyright 2020 Joyent, Inc. +# LIBRARY = libfmd_snmp.a VERS = .1 @@ -51,8 +53,8 @@ $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS) CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS) -SNMPLIBS = -lnetsnmp -lnetsnmphelpers -lnetsnmpagent -NATIVE_LIBS += libnetsnmp.so libnetsnmphelpers.so libnetsnmpagent.so +SNMPLIBS = -lnetsnmp -lnetsnmpagent +NATIVE_LIBS += libnetsnmp.so libnetsnmpagent.so LDLIBS += $(MACH_LDLIBS) LDLIBS += -lfmd_adm -luutil -lnvpair -ltopo diff --git a/usr/src/lib/libficl/Makefile.com b/usr/src/lib/libficl/Makefile.com index ec66e3d9be..9502a28def 100644 --- a/usr/src/lib/libficl/Makefile.com +++ b/usr/src/lib/libficl/Makefile.com @@ -12,7 +12,7 @@ # # Copyright 2016 Toomas Soome <tsoome@me.com> # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. LIBRARY=libficl-sys.a MAJOR = 4 @@ -41,7 +41,7 @@ CFLAGS64 += $(C_BIGPICFLAGS64) # for time being, till gcc 4.4.4 will be replaced. pics/vm.o := CERRWARN += -_gcc=-Wno-clobbered -LDLIBS += -luuid -lz -lc -lm -lumem +LDLIBS += -lumem -luuid -lz -lc -lm NATIVE_LIBS += libz.so HEADERS= $(FICLDIR)/ficl.h $(FICLDIR)/ficltokens.h ../ficllocal.h \ diff --git a/usr/src/lib/libfru/libfruraw/crcmodel.h b/usr/src/lib/libfru/libfruraw/crcmodel.h index 9c30c19061..4a2653573b 100644 --- a/usr/src/lib/libfru/libfruraw/crcmodel.h +++ b/usr/src/lib/libfru/libfruraw/crcmodel.h @@ -27,11 +27,7 @@ #ifndef _CRCMODEL_H #define _CRCMODEL_H -#ifdef SOLARIS_UNIX #include <sys/types.h> -#else -typedef long uint32_t; -#endif #ifdef __cplusplus extern "C" { diff --git a/usr/src/lib/libprtdiag_psr/sparc/desktop/picl/Makefile b/usr/src/lib/libprtdiag_psr/sparc/desktop/picl/Makefile index 93ec2dd449..e9c653d7d7 100644 --- a/usr/src/lib/libprtdiag_psr/sparc/desktop/picl/Makefile +++ b/usr/src/lib/libprtdiag_psr/sparc/desktop/picl/Makefile @@ -21,6 +21,7 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2019 Peter Tribble. # # lib/libprtdiag_psr/sparc/desktop/picl/Makefile @@ -51,7 +52,6 @@ LINKED_PLATFORMS += SUNW,Sun-Blade-2500 LINKED_PLATFORMS += SUNW,A70 LINKED_PLATFORMS += SUNW,Sun-Fire-V445 LINKED_PLATFORMS += SUNW,Sun-Fire-V215 -LINKED_PLATFORMS += SUNW,Serverblade1 LINKED_PLATFORMS += SUNW,Sun-Fire-V240 LINKED_PLATFORMS += SUNW,Sun-Fire-V250 LINKED_PLATFORMS += SUNW,Sun-Fire-V440 diff --git a/usr/src/lib/libsmbios/Makefile.com b/usr/src/lib/libsmbios/Makefile.com index 40345a3848..1534830317 100644 --- a/usr/src/lib/libsmbios/Makefile.com +++ b/usr/src/lib/libsmbios/Makefile.com @@ -53,6 +53,8 @@ CLEANFILES += ../common/smb_tables.c CPPFLAGS += -I../common -I$(COMMON_SRCDIR) CFLAGS += $(CCVERBOSE) LDLIBS += -ldevinfo -lc +CFLAGS += $(C_BIGPICFLAGS) +CFLAGS64 += $(C_BIGPICFLAGS64) $(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC) diff --git a/usr/src/man/man7d/Makefile b/usr/src/man/man7d/Makefile index 2657dbcedc..9de3a14886 100644 --- a/usr/src/man/man7d/Makefile +++ b/usr/src/man/man7d/Makefile @@ -35,7 +35,6 @@ _MANFILES= aac.7d \ bge.7d \ blkdev.7d \ bnxe.7d \ - bscv.7d \ ccid.7d \ chxge.7d \ console.7d \ @@ -244,10 +243,8 @@ i386_MANFILES= ahci.7d \ _MANLINKS= 1394.7d \ allkmem.7d \ - bscbus.7d \ fdc.7d \ firewire.7d \ - i2bsc.7d \ kmem.7d \ lo0.7d \ ticots.7d \ @@ -260,9 +257,6 @@ sparc_MANLINKS= drmach.7d MANFILES = $(_MANFILES) $($(MACH)_MANFILES) MANLINKS = $(_MANLINKS) $($(MACH)_MANLINKS) -bscbus.7d := LINKSRC = bscv.7d -i2bsc.7d := LINKSRC = bscv.7d - drmach.7d := LINKSRC = dr.7d fdc.7d := LINKSRC = fd.7d diff --git a/usr/src/man/man7d/bscv.7d b/usr/src/man/man7d/bscv.7d deleted file mode 100644 index 870f43a263..0000000000 --- a/usr/src/man/man7d/bscv.7d +++ /dev/null @@ -1,90 +0,0 @@ -'\" te -.\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved -.\" 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 or http://www.opensolaris.org/os/licensing. 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] -.TH BSCV 7D "Aug 22, 2003" -.SH NAME -bscv, bscbus, i2bsc \- Blade support chip interface driver -.SH DESCRIPTION -.sp -.LP -The \fBbscv\fR, \fBbscbus\fR and \fBi2bsc\fR drivers interface with the Blade -support chip used on Sun Microsystem's Blade server products. These drivers -provide a conduit for passing control, environmental, cpu signature and event -information between Solaris and the Blade support chip. -.sp -.LP -These drivers do not export public interfaces. Instead they make information -available via picl, prtdiag, prtfru and related tools. In addition, these -drivers log Blade support chip environmental event information into system -logs. -.SH FILES -.sp -.ne 2 -.na -\fB\fB/platform/sun4u/kernel/drv/sparcv9/bscbus\fR\fR -.ad -.sp .6 -.RS 4n -64-bit ELF kernel driver -.RE - -.sp -.ne 2 -.na -\fB\fB/platform/sun4u/kernel/drv/sparcv9/bscv\fR\fR -.ad -.sp .6 -.RS 4n -64-bit ELF kernel driver -.RE - -.sp -.ne 2 -.na -\fB\fB/platform/sun4u/kernel/drv/sparcv9/i2bsc\fR\fR -.ad -.sp .6 -.RS 4n -64-bit ELF kernel driver -.RE - -.sp -.ne 2 -.na -\fB\fB/platform/i86pc/kernel/drv/bscbus\fR\fR -.ad -.sp .6 -.RS 4n -32-bit ELF kernel file (x86 only) -.RE - -.sp -.ne 2 -.na -\fB\fB/platform/i86pc/kernel/drv/bscv\fR\fR -.ad -.sp .6 -.RS 4n -32-bit ELF kernel file (x86 only) -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -l | l -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Architecture T{ -Limited to systems with Blade Support Chip -T} -.TE - diff --git a/usr/src/pkg/manifests/developer-apptrace-platform.mf b/usr/src/pkg/manifests/developer-apptrace-platform.mf index ac3c5a93bd..d8ce8ee5f3 100644 --- a/usr/src/pkg/manifests/developer-apptrace-platform.mf +++ b/usr/src/pkg/manifests/developer-apptrace-platform.mf @@ -40,8 +40,6 @@ dir path=usr/platform/SUNW,Netra-T12 group=sys dir path=usr/platform/SUNW,Netra-T12/lib dir path=usr/platform/SUNW,Netra-T4 group=sys dir path=usr/platform/SUNW,Netra-T4/lib -dir path=usr/platform/SUNW,Serverblade1 group=sys -dir path=usr/platform/SUNW,Serverblade1/lib dir path=usr/platform/SUNW,Sun-Blade-100 group=sys dir path=usr/platform/SUNW,Sun-Blade-100/lib dir path=usr/platform/SUNW,Sun-Blade-1000 group=sys diff --git a/usr/src/pkg/manifests/service-picl.mf b/usr/src/pkg/manifests/service-picl.mf index 65e45e1d4a..3600b02c78 100644 --- a/usr/src/pkg/manifests/service-picl.mf +++ b/usr/src/pkg/manifests/service-picl.mf @@ -60,11 +60,6 @@ $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4/lib $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4/lib/picl group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4/lib/picl/plugins group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1 group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib/picl group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib/picl/plugins \ - group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-100 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-100/lib $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-100/lib/picl group=sys @@ -185,18 +180,6 @@ $(sparc_ONLY)file \ $(sparc_ONLY)file \ path=usr/platform/SUNW,Netra-T4/lib/picl/plugins/piclfrutree.conf \ group=sys -$(sparc_ONLY)file \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/libpicllom.so.1 \ - group=sys -$(sparc_ONLY)file \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/picldevtree.conf \ - group=sys -$(sparc_ONLY)file \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/piclfrutree.conf \ - group=sys -$(sparc_ONLY)file \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/picllom.conf \ - group=sys $(sparc_ONLY)file path=usr/platform/SUNW,Sun-Blade-100/lib/libprtdiag_psr.so.1 $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Blade-100/lib/picl/plugins/envmodel.conf \ @@ -696,17 +679,6 @@ $(sparc_ONLY)link path=usr/platform/SUNW,Netra-T4/lib/libprtdiag_psr.so.1 \ $(sparc_ONLY)link \ path=usr/platform/SUNW,Netra-T4/lib/picl/plugins/libfcal_leds.so \ target=libfcal_leds.so.1 -$(sparc_ONLY)link path=usr/platform/SUNW,Serverblade1/lib/libprtdiag_psr.so.1 \ - target=../../SUNW,Sun-Blade-100/lib/libprtdiag_psr.so.1 -$(sparc_ONLY)link \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/libpicllom.so \ - target=libpicllom.so.1 -$(sparc_ONLY)link \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/libpiclmemcfg.so \ - target=../../../../SUNW,Sun-Blade-100/lib/picl/plugins/libpiclmemcfg.so.1 -$(sparc_ONLY)link \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/libpiclmemcfg.so.1 \ - target=../../../../SUNW,Sun-Blade-100/lib/picl/plugins/libpiclmemcfg.so.1 $(sparc_ONLY)link \ path=usr/platform/SUNW,Sun-Blade-100/lib/picl/plugins/libpiclenvd.so \ target=./libpiclenvd.so.1 diff --git a/usr/src/pkg/manifests/system-fru-id-platform.mf b/usr/src/pkg/manifests/system-fru-id-platform.mf index cbeff44ab8..a09bc79302 100644 --- a/usr/src/pkg/manifests/system-fru-id-platform.mf +++ b/usr/src/pkg/manifests/system-fru-id-platform.mf @@ -54,11 +54,6 @@ $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4/lib/picl group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4/lib/picl/plugins group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,SPARC-Enterprise group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,SPARC-Enterprise/sbin -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1 group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib/picl group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib/picl/plugins \ - group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-1000 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-1000/lib $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-1000/lib/picl group=sys @@ -145,13 +140,6 @@ $(sparc_ONLY)file path=usr/platform/SUNW,Netra-T12/lib/libfruaccess.so.1 \ $(sparc_ONLY)file \ path=usr/platform/SUNW,Netra-T4/lib/picl/plugins/libpiclfrudata.conf \ group=sys -$(sparc_ONLY)file path=usr/platform/SUNW,Serverblade1/lib/fru_container.conf \ - group=sys -$(sparc_ONLY)file path=usr/platform/SUNW,Serverblade1/lib/libfruaccess.so.1 \ - group=sys -$(sparc_ONLY)file \ - path=usr/platform/SUNW,Serverblade1/lib/picl/plugins/libpiclfrudata.conf \ - group=sys $(sparc_ONLY)file \ path=usr/platform/SUNW,Sun-Blade-1000/lib/picl/plugins/libpiclfrudata.conf \ group=sys @@ -211,8 +199,6 @@ $(sparc_ONLY)link path=usr/platform/SUNW,Netra-T12/lib/libfruaccess.so \ target=libfruaccess.so.1 $(sparc_ONLY)link path=usr/platform/SUNW,SPARC-Enterprise/sbin/fruadm \ target=../../sun4u/sbin/fruadm -$(sparc_ONLY)link path=usr/platform/SUNW,Serverblade1/lib/libfruaccess.so \ - target=libfruaccess.so.1 $(sparc_ONLY)link path=usr/platform/SUNW,Sun-Fire-V215/sbin/fruadm \ target=../../sun4u/sbin/fruadm $(sparc_ONLY)link path=usr/platform/SUNW,Sun-Fire-V240/sbin/fruadm \ diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf index 27bb22343e..2e64bb85b2 100644 --- a/usr/src/pkg/manifests/system-header.mf +++ b/usr/src/pkg/manifests/system-header.mf @@ -132,7 +132,6 @@ $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-CP3010/include $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T12 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Netra-T4 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,SPARC-Enterprise group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-100 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-1000 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-1500 group=sys @@ -1968,8 +1967,6 @@ $(sparc_ONLY)link path=usr/platform/SUNW,Netra-T4/include \ target=../sun4u/include $(sparc_ONLY)link path=usr/platform/SUNW,SPARC-Enterprise/include \ target=../sun4u/include -$(sparc_ONLY)link path=usr/platform/SUNW,Serverblade1/include \ - target=../sun4u/include $(sparc_ONLY)link path=usr/platform/SUNW,Sun-Blade-100/include \ target=../sun4u/include $(sparc_ONLY)link path=usr/platform/SUNW,Sun-Blade-1000/include \ diff --git a/usr/src/pkg/manifests/system-kernel-platform.mf b/usr/src/pkg/manifests/system-kernel-platform.mf index d4da96a775..d306668d50 100644 --- a/usr/src/pkg/manifests/system-kernel-platform.mf +++ b/usr/src/pkg/manifests/system-kernel-platform.mf @@ -89,14 +89,6 @@ $(sparc_ONLY)dir path=platform/SUNW,SPARC-Enterprise/kernel/drv/$(ARCH64) \ $(sparc_ONLY)dir path=platform/SUNW,SPARC-Enterprise/kernel/misc group=sys $(sparc_ONLY)dir path=platform/SUNW,SPARC-Enterprise/kernel/misc/$(ARCH64) \ group=sys -$(sparc_ONLY)dir path=platform/SUNW,Serverblade1 group=sys -$(sparc_ONLY)dir path=platform/SUNW,Serverblade1/kernel group=sys -$(sparc_ONLY)dir path=platform/SUNW,Serverblade1/kernel/drv group=sys -$(sparc_ONLY)dir path=platform/SUNW,Serverblade1/kernel/drv/$(ARCH64) \ - group=sys -$(sparc_ONLY)dir path=platform/SUNW,Serverblade1/kernel/misc group=sys -$(sparc_ONLY)dir path=platform/SUNW,Serverblade1/kernel/misc/$(ARCH64) \ - group=sys $(sparc_ONLY)dir path=platform/SUNW,Sun-Blade-100 group=sys $(sparc_ONLY)dir path=platform/SUNW,Sun-Blade-100/kernel group=sys $(sparc_ONLY)dir path=platform/SUNW,Sun-Blade-100/kernel/drv group=sys @@ -384,7 +376,6 @@ $(sparc_ONLY)driver name=grppm alias=SUNW,smbus-ppm $(sparc_ONLY)driver name=hpc3130 perms="* 0644 root sys" \ alias=FJSV,hpc3130 \ alias=i2c-hpc3130 -$(sparc_ONLY)driver name=i2bsc alias=SUNW,i2bsc $(sparc_ONLY)driver name=ics951601 alias=i2c-ics951601 $(i386_ONLY)driver name=isa alias=pciclass,060100 class=sysbus $(sparc_ONLY)driver name=isadma @@ -570,19 +561,6 @@ $(sparc_ONLY)file \ $(sparc_ONLY)file \ path=platform/SUNW,SPARC-Enterprise/kernel/misc/$(ARCH64)/platmod \ group=sys mode=0755 -$(sparc_ONLY)file path=platform/SUNW,Serverblade1/kernel/drv/$(ARCH64)/bscbus \ - group=sys -$(sparc_ONLY)file path=platform/SUNW,Serverblade1/kernel/drv/$(ARCH64)/bscv \ - group=sys -$(sparc_ONLY)file path=platform/SUNW,Serverblade1/kernel/drv/bscbus.conf \ - group=sys -$(sparc_ONLY)file path=platform/SUNW,Serverblade1/kernel/drv/bscv.conf \ - group=sys -$(sparc_ONLY)file path=platform/SUNW,Serverblade1/kernel/drv/options.conf \ - group=sys -$(sparc_ONLY)file \ - path=platform/SUNW,Serverblade1/kernel/misc/$(ARCH64)/platmod group=sys \ - mode=0755 $(sparc_ONLY)file path=platform/SUNW,Sun-Blade-100/kernel/drv/$(ARCH64)/grfans \ group=sys $(sparc_ONLY)file path=platform/SUNW,Sun-Blade-100/kernel/drv/$(ARCH64)/grppm \ @@ -839,7 +817,6 @@ $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/fd group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/gpio_87317 \ group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/grbeep group=sys -$(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/i2bsc group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/ics951601 group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/isadma group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/jbusppm group=sys @@ -885,7 +862,6 @@ $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/trapstat group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/upa64s group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/zs group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/$(ARCH64)/zsh group=sys -$(sparc_ONLY)file path=platform/sun4u/kernel/drv/i2bsc.conf group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/mem_cache.conf group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/rmc_comm.conf group=sys $(sparc_ONLY)file path=platform/sun4u/kernel/drv/rmcadm.conf group=sys @@ -915,8 +891,6 @@ $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/sbd group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/vis group=sys \ mode=0755 -$(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todblade group=sys \ - mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todbq4802 group=sys \ mode=0755 $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todds1287 group=sys \ diff --git a/usr/src/pkg/manifests/system-kernel.man7d.inc b/usr/src/pkg/manifests/system-kernel.man7d.inc index d891935067..36014e3262 100644 --- a/usr/src/pkg/manifests/system-kernel.man7d.inc +++ b/usr/src/pkg/manifests/system-kernel.man7d.inc @@ -16,7 +16,6 @@ # Copyright 2019 Joyent, Inc. # -file path=usr/share/man/man7d/bscv.7d file path=usr/share/man/man7d/console.7d file path=usr/share/man/man7d/cpuid.7d file path=usr/share/man/man7d/devinfo.7d @@ -53,8 +52,6 @@ file path=usr/share/man/man7d/vni.7d file path=usr/share/man/man7d/wscons.7d file path=usr/share/man/man7d/zero.7d link path=usr/share/man/man7d/allkmem.7d target=mem.7d -link path=usr/share/man/man7d/bscbus.7d target=bscv.7d -link path=usr/share/man/man7d/i2bsc.7d target=bscv.7d link path=usr/share/man/man7d/kmem.7d target=mem.7d link path=usr/share/man/man7d/lo0.7d target=ipnet.7d link path=usr/share/man/man7d/ticots.7d target=ticlts.7d diff --git a/usr/src/pkg/manifests/system-kernel.mf b/usr/src/pkg/manifests/system-kernel.mf index 02186d11de..2af9b34303 100644 --- a/usr/src/pkg/manifests/system-kernel.mf +++ b/usr/src/pkg/manifests/system-kernel.mf @@ -127,10 +127,6 @@ driver name=arp perms="arp 0666 root sys" driver name=bl perms="* 0666 root sys" driver name=bridge clone_perms="bridge 0666 root sys" \ policy="read_priv_set=net_rawaccess write_priv_set=net_rawaccess" -$(sparc_ONLY)driver name=bscbus alias=SUNW,bscbus -$(i386_ONLY)driver name=bscbus alias=SVI0101 -$(sparc_ONLY)driver name=bscv alias=SUNW,bscv perms="* 0644 root sys" -$(i386_ONLY)driver name=bscv driver name=clone driver name=cn perms="* 0620 root tty" driver name=conskbd perms="kbd 0666 root sys" @@ -339,8 +335,6 @@ file path=kernel/drv/$(ARCH64)/aggr group=sys file path=kernel/drv/$(ARCH64)/arp group=sys file path=kernel/drv/$(ARCH64)/bl group=sys file path=kernel/drv/$(ARCH64)/bridge group=sys -$(i386_ONLY)file path=kernel/drv/$(ARCH64)/bscbus group=sys -$(i386_ONLY)file path=kernel/drv/$(ARCH64)/bscv group=sys file path=kernel/drv/$(ARCH64)/clone group=sys file path=kernel/drv/$(ARCH64)/cn group=sys file path=kernel/drv/$(ARCH64)/conskbd group=sys @@ -422,8 +416,6 @@ file path=kernel/drv/aggr.conf group=sys file path=kernel/drv/arp.conf group=sys file path=kernel/drv/bl.conf group=sys file path=kernel/drv/bridge.conf group=sys -$(i386_ONLY)file path=kernel/drv/bscbus.conf group=sys -$(i386_ONLY)file path=kernel/drv/bscv.conf group=sys file path=kernel/drv/clone.conf group=sys file path=kernel/drv/cn.conf group=sys file path=kernel/drv/conskbd.conf group=sys @@ -627,8 +619,6 @@ file path=usr/kernel/drv/$(ARCH64)/signalfd group=sys file path=usr/kernel/drv/signalfd.conf group=sys $(sparc_ONLY)file path=usr/share/man/man1m/monitor.1m $(sparc_ONLY)file path=usr/share/man/man1m/obpsym.1m -# On SPARC driver/bscv is Serverblade1 specific, and in system/kernel/platform -# We keep the manual page generic $(sparc_ONLY)file path=usr/share/man/man7d/dad.7d $(i386_ONLY)file path=usr/share/man/man7d/smbios.7d # Sadly vuid mouse support is in different packages on different platforms diff --git a/usr/src/pkg/manifests/system-library-platform.mf b/usr/src/pkg/manifests/system-library-platform.mf index 7e18e29ce4..c683f2718e 100644 --- a/usr/src/pkg/manifests/system-library-platform.mf +++ b/usr/src/pkg/manifests/system-library-platform.mf @@ -59,8 +59,6 @@ $(sparc_ONLY)dir path=usr/platform/SUNW,SPARC-Enterprise/lib/cfgadm group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,SPARC-Enterprise/lib/cfgadm/$(ARCH64) \ group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,SPARC-Enterprise/sbin -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1 group=sys -$(sparc_ONLY)dir path=usr/platform/SUNW,Serverblade1/lib $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-100 group=sys $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-100/lib $(sparc_ONLY)dir path=usr/platform/SUNW,Sun-Blade-1000 group=sys @@ -284,12 +282,6 @@ $(sparc_ONLY)link path=usr/platform/SUNW,SPARC-Enterprise/lib/fs \ target=../../sun4u/lib/fs $(sparc_ONLY)link path=usr/platform/SUNW,SPARC-Enterprise/sbin/prtdiag \ target=../../sun4u/sbin/prtdiag -$(sparc_ONLY)link path=usr/platform/SUNW,Serverblade1/lib/cfgadm \ - target=../../sun4u/lib/cfgadm -$(sparc_ONLY)link path=usr/platform/SUNW,Serverblade1/lib/fs \ - target=../../sun4u/lib/fs -$(sparc_ONLY)link path=usr/platform/SUNW,Serverblade1/sbin \ - target=../sun4u/sbin $(sparc_ONLY)link path=usr/platform/SUNW,Sun-Blade-100/lib/cfgadm \ target=../../sun4u/lib/cfgadm $(sparc_ONLY)link path=usr/platform/SUNW,Sun-Blade-100/lib/fs \ diff --git a/usr/src/psm/stand/boot/sparcv9/sun4u/Makefile b/usr/src/psm/stand/boot/sparcv9/sun4u/Makefile index 0f3024822c..ad72158c41 100644 --- a/usr/src/psm/stand/boot/sparcv9/sun4u/Makefile +++ b/usr/src/psm/stand/boot/sparcv9/sun4u/Makefile @@ -50,7 +50,6 @@ PLATLINKS += SUNW,Sun-Fire-880 PLATLINKS += SUNW,Sun-Fire-480R PLATLINKS += SUNW,Sun-Fire-V890 PLATLINKS += SUNW,Sun-Fire-V490 -PLATLINKS += SUNW,Serverblade1 PLATLINKS += SUNW,Netra-T12 PLATLINKS += SUNW,Netra-T4 PLATLINKS += SUNW,Netra-CP3010 diff --git a/usr/src/psm/stand/bootblks/ufs/sparc/sun4u/Makefile b/usr/src/psm/stand/bootblks/ufs/sparc/sun4u/Makefile index 058b6367d0..77e7bd0e42 100644 --- a/usr/src/psm/stand/bootblks/ufs/sparc/sun4u/Makefile +++ b/usr/src/psm/stand/bootblks/ufs/sparc/sun4u/Makefile @@ -54,7 +54,6 @@ PLATLINKS += SUNW,Sun-Fire-880 PLATLINKS += SUNW,Sun-Fire-480R PLATLINKS += SUNW,Sun-Fire-V890 PLATLINKS += SUNW,Sun-Fire-V490 -PLATLINKS += SUNW,Serverblade1 PLATLINKS += SUNW,Netra-T12 PLATLINKS += SUNW,Netra-T4 PLATLINKS += SUNW,SPARC-Enterprise diff --git a/usr/src/tools/scripts/nightly b/usr/src/tools/scripts/nightly index f4f10fda9c..489f63b897 100755 --- a/usr/src/tools/scripts/nightly +++ b/usr/src/tools/scripts/nightly @@ -191,7 +191,7 @@ function build { echo "\n==== Build errors ($LABEL) ====\n" >> $mail_msg_file egrep ":" $SRC/${INSTALLOG}.out | - egrep -e "(^${MAKE}:|[ ]error[: \n])" | \ + egrep -e "(^${MAKE}:|[ ]error[: \n]|ld: guidance:)" | \ egrep -v "Ignoring unknown host" | \ egrep -v "cc .* -o error " | \ egrep -v "warning" | tee $TMPDIR/build_errs${SUFFIX} \ diff --git a/usr/src/uts/common/io/bscbus.c b/usr/src/uts/common/io/bscbus.c deleted file mode 100644 index b229f08a76..0000000000 --- a/usr/src/uts/common/io/bscbus.c +++ /dev/null @@ -1,2637 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Copyright 2019 Joyent, Inc. - * - * The "bscbus" driver provides access to the LOMlite2 virtual registers, - * so that its clients (children) need not be concerned with the details - * of the access mechanism, which in this case is implemented via a - * packet-based protocol over a Xbus (similar to ebus) parallel link to the - * H8 host interface registers. - * - * On the other hand, this driver doesn't generally know what the virtual - * registers signify - only the clients need this information. - */ - - -#include <sys/note.h> -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/debug.h> -#include <sys/errno.h> -#include <sys/file.h> - -#if defined(__sparc) -#include <sys/intr.h> -#include <sys/membar.h> -#endif - -#include <sys/kmem.h> -#include <sys/modctl.h> -#include <sys/note.h> -#include <sys/open.h> -#include <sys/poll.h> -#include <sys/spl.h> -#include <sys/stat.h> -#include <sys/strlog.h> -#include <sys/atomic.h> - -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/sunndi.h> - -#include <sys/bscbus.h> - -#if defined(NDI_ACC_HDL_V2) - -/* - * Compiling for Solaris 10+ with access handle enhancements - */ -#define HANDLE_TYPE ndi_acc_handle_t -#define HANDLE_ADDR(hdlp) (hdlp->ah_addr) -#define HANDLE_FAULT(hdlp) (hdlp->ah_fault) -#define HANDLE_MAPLEN(hdlp) (hdlp->ah_len) -#define HANDLE_PRIVATE(hdlp) (hdlp->ah_bus_private) - -#else - -/* - * Compatibility definitions for backport to Solaris 8/9 - */ -#define HANDLE_TYPE ddi_acc_impl_t -#define HANDLE_ADDR(hdlp) (hdlp->ahi_common.ah_addr) -#define HANDLE_FAULT(hdlp) (hdlp->ahi_fault) -#define HANDLE_MAPLEN(hdlp) (hdlp->ahi_common.ah_len) -#define HANDLE_PRIVATE(hdlp) (hdlp->ahi_common.ah_bus_private) - -#define ddi_driver_major(dip) ddi_name_to_major(ddi_binding_name(dip)) - -#endif /* NDI_ACC_HDL_V2 */ - - -/* - * Local definitions - */ -#define MYNAME "bscbus" -#define NOMAJOR (~(major_t)0) -#define DUMMY_VALUE (~(int8_t)0) - -#define BSCBUS_INST_TO_MINOR(i) (i) -#define BSCBUS_MINOR_TO_INST(m) (m) - -#define BSCBUS_MAX_CHANNELS (4) - -#define BSCBUS_DUMMY_ADDRESS ((caddr_t)0x0CADD1ED) -#define ADDR_TO_OFFSET(a, hdlp) ((caddr_t)(a) - HANDLE_ADDR(hdlp)) -#define ADDR_TO_VREG(a) ((caddr_t)(a) - BSCBUS_DUMMY_ADDRESS) -#define VREG_TO_ADDR(v) (BSCBUS_DUMMY_ADDRESS + (v)) - -#ifdef DEBUG -#define BSCBUS_LOGSTATUS -#endif /* DEBUG */ - -#ifdef BSCBUS_LOGSTATUS -/* - * BSC command logging routines. - * Record the data passing to and from the BSC - */ - -typedef enum { - BSC_CMD_BUSY = 1, /* bsc reports busy */ - BSC_CMD_CLEARING = 2, /* clearing bsc busy */ - BSC_CMD_CLEARED = 3, /* cleared bsc busy */ - BSC_CMD_SENDING = 4, /* sending next byte */ - BSC_CMD_SENT = 5, /* sending last byte */ - BSC_CMD_PENDING = 6, /* got sent byte ack */ - BSC_CMD_REPLY = 7, /* got reply byte */ - BSC_CMD_COMPLETE = 8, /* command complete */ - BSC_CMD_ERROR_SEQ = 9, /* error status */ - BSC_CMD_ERROR_STATUS = 10, /* error status */ - BSC_CMD_ERROR_OFLOW = 11, /* error status */ - BSC_CMD_ERROR_TOUT = 12, /* error status */ - - BSC_CMD_PROCESS = 13, /* async intr */ - BSC_CMD_V1INTR = 14, /* v1 intr */ - BSC_CMD_V1INTRUNCL = 15, /* v1 intr unclaim */ - BSC_CMD_DOGPAT = 17 /* watchdog pat */ -} bsc_cmd_stamp_t; - -typedef struct { - hrtime_t bcl_now; - int bcl_seq; - bsc_cmd_stamp_t bcl_cat; - uint8_t bcl_chno; - uint8_t bcl_cmdstate; - uint8_t bcl_status; - uint8_t bcl_data; -} bsc_cmd_log_t; - -uint32_t bscbus_cmd_log_size = 1024; - -uint32_t bscbus_cmd_log_flags = 0xffffffff; - -#endif /* BSCBUS_LOGSTATUS */ - -/* - * The following definitions are taken from the Hardware Manual for - * the Hitachi H8S/2148 in conjunction with the hardware specification - * for the Stiletto blade. - * - * Each instance of the host interface has 3 registers on the H8: - * IDRn - Input Data Register - write-only for Solaris. - * writes to this can be done via two - * addresses - control and data. - * The H8 can determine which address was - * written by examining the C/D bit in - * the status register. - * ODRn - Output Data Register - read-only for Solaris. - * A read has the side effect of acknowledging - * interrupts. - * STRn - Status Register - read-only for Solaris. - * - * - * - * In terms of host access to this the Input and Output data registers are - * mapped at the same address. - */ -#define H8_IDRD 0 -#define H8_IDRC 1 -#define H8_ODR 0 -#define H8_STR 1 - -#define H8_STR_OBF 0x01 /* data available in ODR */ -#define H8_STR_IBF 0x02 /* data for H8 in IDR */ -#define H8_STR_IDRC 0x08 /* last write to IDR was to IDRC */ - /* 0=data, 1=command */ -#define H8_STR_BUSY 0x04 /* H8 busy processing command */ -#define H8_STR_TOKENPROTOCOL 0x80 /* token-passing protocol */ - -/* - * Packet format ... - */ -#define BSCBUS_MASK 0xc0 /* Byte-type bits */ -#define BSCBUS_PARAM 0x00 /* Parameter byte: 0b0xxxxxxx */ -#define BSCBUS_LAST 0x80 /* Last byte of packet */ -#define BSCBUS_CMD 0x80 /* Command byte: 0b10###XWV */ -#define BSCBUS_STATUS 0xc0 /* Status byte: 0b11###AEV */ - -#define BSCBUS_SEQ 0x38 /* Sequence number bits */ -#define BSCBUS_SEQ_LSB 0x08 /* Sequence number LSB */ -#define BSCBUS_CMD_XADDR 0x04 /* Extended (2-byte) addressing */ -#define BSCBUS_CMD_WRITE 0x02 /* Write command */ -#define BSCBUS_CMD_WMSB 0x01 /* Set MSB on Write */ -#define BSCBUS_CMD_READ 0x01 /* Read command */ -#define BSCBUS_CMD_NOP 0x00 /* NOP command */ - -#define BSCBUS_STATUS_ASYNC 0x04 /* Asynchronous event pending */ -#define BSCBUS_STATUS_ERR 0x02 /* Error in command processing */ -#define BSCBUS_STATUS_MSB 0x01 /* MSB of Value read */ - -#define BSCBUS_VREG_LO(x) ((x) & ((1 << 7) - 1)) -#define BSCBUS_VREG_HI(x) ((x) >> 7) - -#define BSCBUS_BUFSIZE 8 - -#define BSCBUS_CHANNEL_TO_OFFSET(chno) ((chno) * 2) /* Register offset */ - -/* - * Time periods, in nanoseconds - * - * Note that LOMBUS_ONE_SEC and some other time - * periods are defined in <sys/lombus.h> - */ -#define BSCBUS_CMD_POLL (LOMBUS_ONE_SEC) -#define BSCBUS_CMD_POLLNOINTS (LOMBUS_ONE_SEC/20) -#define BSCBUS_HWRESET_POLL (LOMBUS_ONE_SEC/20) -#define BSCBUS_HWRESET_TIMEOUT (LOMBUS_ONE_SEC*2) - -#define BSCBUS_DOG_PAT_POLL_LIMIT (1000) -#define BSCBUS_DOG_PAT_POLL (1) -#define BSCBUS_PAT_RETRY_LIMIT 5 - -/* - * Local datatypes - */ -enum bscbus_cmdstate { - BSCBUS_CMDSTATE_IDLE, /* No transaction in progress */ - BSCBUS_CMDSTATE_BUSY, /* Setting up command */ - BSCBUS_CMDSTATE_CLEARING, /* Clearing firmware busy status */ - BSCBUS_CMDSTATE_SENDING, /* Waiting to send data to f/w */ - BSCBUS_CMDSTATE_PENDING, /* Waiting for ack from f/w */ - BSCBUS_CMDSTATE_WAITING, /* Waiting for status from f/w */ - BSCBUS_CMDSTATE_READY, /* Status received/command done */ - BSCBUS_CMDSTATE_ERROR /* Command failed with error */ -}; - -struct bscbus_channel_state { - /* Changes to these are protected by the instance ch_mutex mutex */ - struct bscbus_state *ssp; - uint8_t *ch_regs; - ddi_acc_handle_t ch_handle; /* per channel access handle */ - unsigned int chno; - unsigned int map_count; /* Number of mappings to channel */ - boolean_t map_dog; /* channel is mapped for watchdog */ - - /* - * Flag to indicate that we've incurred a hardware fault on - * accesses to the H8; once this is set, we fake all further - * accesses in order not to provoke additional bus errors. - */ - boolean_t xio_fault; - - /* - * Data protected by the dog_mutex: the watchdog-patting - * protocol data (since the dog can be patted from a high-level - * cyclic), and the interrupt-enabled flag. - */ - kmutex_t dog_mutex[1]; - unsigned int pat_retry_count; - unsigned int pat_fail_count; - - /* - * Serial protocol state data, protected by lo_mutex - * (which is initialised using <lo_iblk>) - */ - kmutex_t lo_mutex[1]; - ddi_iblock_cookie_t lo_iblk; - kcondvar_t lo_cv[1]; - int unclaimed_count; - - volatile enum bscbus_cmdstate cmdstate; - clock_t deadline; - clock_t poll_hz; - boolean_t interrupt_failed; - uint8_t cmdbuf[BSCBUS_BUFSIZE]; - uint8_t *cmdp; /* Points to last tx'd in cmdbuf */ - uint8_t reply[BSCBUS_BUFSIZE]; - uint8_t async; - uint8_t index; - uint8_t result; - uint8_t sequence; - uint32_t error; -}; - -#define BSCBUS_TX_PENDING(csp) ((csp)->cmdp > (csp)->cmdbuf) - -/* - * This driver's soft-state structure - */ - -struct bscbus_state { - /* - * Configuration data, set during attach - */ - dev_info_t *dip; - major_t majornum; - int instance; - - ddi_acc_handle_t h8_handle; - uint8_t *h8_regs; - - /* - * Parameters derived from .conf properties - */ - uint32_t debug; - - /* - * Flag to indicate that we are using per channel - * mapping of the register sets and interrupts. - * reg set 0 is chan 0 - * reg set 1 is chan 1 ... - * - * Interrupts are specified in that order but later - * channels may not have interrupts. - */ - boolean_t per_channel_regs; - - /* - * channel state data, protected by ch_mutex - * channel claim/release requests are protected by this mutex. - */ - kmutex_t ch_mutex[1]; - struct bscbus_channel_state channel[BSCBUS_MAX_CHANNELS]; - -#ifdef BSCBUS_LOGSTATUS - /* - * Command logging buffer for recording transactions with the - * BSC. This is useful for debugging failed transactions and other - * such funnies. - */ - bsc_cmd_log_t *cmd_log; - uint32_t cmd_log_idx; - uint32_t cmd_log_size; - uint32_t cmd_log_flags; -#endif /* BSCBUS_LOGSTATUS */ -}; - -/* - * The auxiliary structure attached to each child - * (the child's parent-private-data points to this). - */ -struct bscbus_child_info { - lombus_regspec_t *rsp; - int nregs; -}; - -#ifdef BSCBUS_LOGSTATUS -void bscbus_cmd_log(struct bscbus_channel_state *, bsc_cmd_stamp_t, - uint8_t, uint8_t); -#else /* BSCBUS_LOGSTATUS */ -#define bscbus_cmd_log(state, stamp, status, data) -#endif /* BSCBUS_LOGSTATUS */ - - -/* - * Local data - */ - -static void *bscbus_statep; - -static major_t bscbus_major = NOMAJOR; - -static ddi_device_acc_attr_t bscbus_dev_acc_attr[1] = { - DDI_DEVICE_ATTR_V0, - DDI_STRUCTURE_LE_ACC, - DDI_STRICTORDER_ACC -}; - - -/* - * General utility routines ... - */ - -#ifdef DEBUG -static void -bscbus_trace(struct bscbus_channel_state *csp, char code, const char *caller, - const char *fmt, ...) -{ - char buf[256]; - char *p; - va_list va; - - if (csp->ssp->debug & (1 << (code-'@'))) { - p = buf; - (void) snprintf(p, sizeof (buf) - (p - buf), - "%s/%s: ", MYNAME, caller); - p += strlen(p); - - va_start(va, fmt); - (void) vsnprintf(p, sizeof (buf) - (p - buf), fmt, va); - va_end(va); - - buf[sizeof (buf) - 1] = '\0'; - (void) strlog(csp->ssp->majornum, csp->ssp->instance, - code, SL_TRACE, buf); - } -} -#else /* DEBUG */ -#define bscbus_trace(...) (void)(0) -#endif /* DEBUG */ - -static struct bscbus_state * -bscbus_getstate(dev_info_t *dip, int instance, const char *caller) -{ - struct bscbus_state *ssp = NULL; - dev_info_t *sdip = NULL; - major_t dmaj = NOMAJOR; - - if (dip != NULL) { - /* - * Use the instance number from the <dip>; also, - * check that it really corresponds to this driver - */ - instance = ddi_get_instance(dip); - dmaj = ddi_driver_major(dip); - if (bscbus_major == NOMAJOR && dmaj != NOMAJOR) - bscbus_major = dmaj; - else if (dmaj != bscbus_major) { - cmn_err(CE_WARN, - "%s: major number mismatch (%d vs. %d) in %s()," - "probably due to child misconfiguration", - MYNAME, bscbus_major, dmaj, caller); - instance = -1; - } - } - - if (instance >= 0) - ssp = ddi_get_soft_state(bscbus_statep, instance); - if (ssp != NULL) { - sdip = ssp->dip; - if (dip == NULL && sdip == NULL) - ssp = NULL; - else if (dip != NULL && sdip != NULL && sdip != dip) { - cmn_err(CE_WARN, - "%s: devinfo mismatch (%p vs. %p) in %s(), " - "probably due to child misconfiguration", - MYNAME, (void *)dip, (void *)sdip, caller); - ssp = NULL; - } - } - - return (ssp); -} - -/* - * Lowest-level I/O register read/write - */ - -static void -bscbus_put_reg(struct bscbus_channel_state *csp, uint_t reg, uint8_t val) -{ - if (csp->ch_handle != NULL && !csp->xio_fault) { - ddi_put8(csp->ch_handle, - csp->ch_regs + reg, val); - } -} - -static uint8_t -bscbus_get_reg(struct bscbus_channel_state *csp, uint_t reg) -{ - uint8_t val; - - if (csp->ch_handle != NULL && !csp->xio_fault) - val = ddi_get8(csp->ch_handle, - csp->ch_regs + reg); - else - val = DUMMY_VALUE; - - return (val); -} - -static void -bscbus_check_fault_status(struct bscbus_channel_state *csp) -{ - csp->xio_fault = - ddi_check_acc_handle(csp->ch_handle) != DDI_SUCCESS; -} - -static boolean_t -bscbus_faulty(struct bscbus_channel_state *csp) -{ - if (!csp->xio_fault) - bscbus_check_fault_status(csp); - return (csp->xio_fault); -} - -/* - * Write data into h8 registers - */ -static void -bscbus_pat_dog(struct bscbus_channel_state *csp, uint8_t val) -{ - uint8_t status; - uint32_t doglimit = BSCBUS_DOG_PAT_POLL_LIMIT; - - bscbus_trace(csp, 'W', "bscbus_pat_dog:", ""); - - bscbus_cmd_log(csp, BSC_CMD_DOGPAT, 0, val); - status = bscbus_get_reg(csp, H8_STR); - while (status & H8_STR_IBF) { - if (csp->pat_retry_count > BSCBUS_PAT_RETRY_LIMIT) { - /* - * Previous attempts to contact BSC have failed. - * Do not bother waiting for it to eat previous - * data. - * Pat anyway just in case the BSC is really alive - * and the IBF bit is lying. - */ - bscbus_put_reg(csp, H8_IDRC, val); - bscbus_trace(csp, 'W', "bscbus_pat_dog:", - "retry count exceeded"); - return; - } - if (--doglimit == 0) { - /* The BSC is not responding - give up */ - csp->pat_fail_count++; - csp->pat_retry_count++; - /* Pat anyway just in case the BSC is really alive */ - bscbus_put_reg(csp, H8_IDRC, val); - bscbus_trace(csp, 'W', "bscbus_pat_dog:", - "poll limit exceeded"); - return; - } - drv_usecwait(BSCBUS_DOG_PAT_POLL); - status = bscbus_get_reg(csp, H8_STR); - } - bscbus_put_reg(csp, H8_IDRC, val); - csp->pat_retry_count = 0; -} - -/* - * State diagrams for how bscbus_process works. - * BSCBUS_CMDSTATE_IDLE No transaction in progress - * BSCBUS_CMDSTATE_BUSY Setting up command - * BSCBUS_CMDSTATE_CLEARING Clearing firmware busy status - * BSCBUS_CMDSTATE_SENDING Waiting to send data to f/w - * BSCBUS_CMDSTATE_PENDING Waiting for ack from f/w - * BSCBUS_CMDSTATE_WAITING Waiting for status from f/w - * BSCBUS_CMDSTATE_READY Status received/command done - * BSCBUS_CMDSTATE_ERROR Command failed with error - * - * +----------+ - * | | - * | IDLE/BUSY| - * | (0/1) | abnormal - * +----------+ state - * | \ detected - * | \------>------+ +----<---+ - * bsc | | | | - * is | V V | - * ready| +----------+ | - * | | | ^ - * | | CLEARING | | - * | | (2) | | - * | +----------+ | - * | cleared / | \ | more to clear - * | / | \-->--+ - * | +-------<-------/ V - * | | | - * V V |timeout - * +----------+ timeout | - * | |------>---------+--------+ - * | SENDING | | - * | (3) |------<-------+ | - * +----------+ | V - * sent| \ send ^ack | - * last| \ next |received | - * | \ +----------+ | - * | \ | | | - * | \------>| PENDING |-->-+ - * | | (4) | | - * | +----------+ |timeout - * | +---<----+ | - * | | | | - * V V | | - * +----------+ | | - * | | | | - * | WAITING | ^ | - * | (5) | | | - * +----------+ | | - * | | |more | | - * | V |required| | - * done| | +--->----+ | - * | +--->--------------+ +---<---+ - * | error/timeout | | - * V V V - * +----------+ +----------+ - * | | | | - * | READY | | ERROR | - * | (7) | | (6) | - * +----------+ +----------+ - * | | - * V V - * | | - * +------>---+---<------+ - * | - * | - * Back to - * Idle - */ - -static void -bscbus_process_sending(struct bscbus_channel_state *csp, uint8_t status) -{ - /* - * When we get here we actually expect H8_STR_IBF to - * be clear but we check just in case of problems. - */ - ASSERT(BSCBUS_TX_PENDING(csp)); - if (!(status & H8_STR_IBF)) { - bscbus_put_reg(csp, H8_IDRD, *--csp->cmdp); - bscbus_trace(csp, 'P', "bscbus_process_sending", - "state %d; val $%x", - csp->cmdstate, *csp->cmdp); - if (!BSCBUS_TX_PENDING(csp)) { - bscbus_cmd_log(csp, BSC_CMD_SENT, - status, *csp->cmdp); - /* No more pending - move to waiting state */ - bscbus_trace(csp, 'P', "bscbus_process_sending", - "moving to waiting"); - csp->cmdstate = BSCBUS_CMDSTATE_WAITING; - /* Extend deadline because time has moved on */ - csp->deadline = ddi_get_lbolt() + - drv_usectohz(LOMBUS_CMD_TIMEOUT/1000); - } else { - /* Wait for ack of this byte */ - bscbus_cmd_log(csp, BSC_CMD_SENDING, - status, *csp->cmdp); - csp->cmdstate = BSCBUS_CMDSTATE_PENDING; - bscbus_trace(csp, 'P', "bscbus_process_sending", - "moving to pending"); - } - } -} - -static void -bscbus_process_clearing(struct bscbus_channel_state *csp, - uint8_t status, uint8_t data) -{ - /* - * We only enter this state if H8_STR_BUSY was set when - * we started the transaction. We just ignore all received - * data until we see OBF set AND BUSY cleared. - * It is not good enough to see BUSY clear on its own - */ - if ((status & H8_STR_OBF) && !(status & H8_STR_BUSY)) { - bscbus_cmd_log(csp, BSC_CMD_CLEARED, status, data); - csp->cmdstate = BSCBUS_CMDSTATE_SENDING; - /* Throw away any data received up until now */ - bscbus_trace(csp, 'P', "bscbus_process_clearing", - "busy cleared"); - /* - * Send the next byte immediately. - * At this stage we should clear the OBF flag because that - * data has been used. IBF is still valid so do not clear that. - */ - status &= ~(H8_STR_OBF); - bscbus_process_sending(csp, status); - } else { - if (status & H8_STR_OBF) { - bscbus_cmd_log(csp, BSC_CMD_CLEARING, status, data); - } - } -} - -static void -bscbus_process_pending(struct bscbus_channel_state *csp, uint8_t status) -{ - /* We are waiting for an acknowledgement of a byte */ - if (status & H8_STR_OBF) { - bscbus_cmd_log(csp, BSC_CMD_PENDING, - status, *csp->cmdp); - bscbus_trace(csp, 'P', "bscbus_process_pending", - "moving to sending"); - csp->cmdstate = BSCBUS_CMDSTATE_SENDING; - /* - * Send the next byte immediately. - * At this stage we should clear the OBF flag because that - * data has been used. IBF is still valid so do not clear that. - */ - status &= ~(H8_STR_OBF); - bscbus_process_sending(csp, status); - } -} - -static boolean_t -bscbus_process_waiting(struct bscbus_channel_state *csp, - uint8_t status, uint8_t data) -{ - uint8_t rcvd = 0; - boolean_t ready = B_FALSE; - uint8_t tmp; - - if (status & H8_STR_OBF) { - csp->reply[rcvd = csp->index] = data; - if (++rcvd < BSCBUS_BUFSIZE) - csp->index = rcvd; - - bscbus_trace(csp, 'D', "bscbus_process_waiting", - "rcvd %d: $%02x $%02x $%02x $%02x $%02x $%02x $%02x $%02x", - rcvd, - csp->reply[0], csp->reply[1], - csp->reply[2], csp->reply[3], - csp->reply[4], csp->reply[5], - csp->reply[6], csp->reply[7]); - } - - if (rcvd == 0) { - /* - * No bytes received this time through (though there - * might be a partial packet sitting in the buffer). - */ - /* EMPTY */ - ; - } else if (rcvd >= BSCBUS_BUFSIZE) { - /* - * Buffer overflow; discard the data & treat as an error - * (even if the last byte read did claim to terminate a - * packet, it can't be a valid one 'cos it's too long!) - */ - bscbus_cmd_log(csp, BSC_CMD_ERROR_OFLOW, status, data); - csp->index = 0; - csp->cmdstate = BSCBUS_CMDSTATE_ERROR; - csp->error = LOMBUS_ERR_OFLOW; - ready = B_TRUE; - } else if ((data & BSCBUS_LAST) == 0) { - /* - * Packet not yet complete; leave the partial packet in - * the buffer for later ... - */ - bscbus_cmd_log(csp, BSC_CMD_REPLY, status, data); - } else if ((data & BSCBUS_MASK) != BSCBUS_STATUS) { - /* Invalid "status" byte - maybe an echo of the command? */ - bscbus_cmd_log(csp, BSC_CMD_ERROR_STATUS, status, data); - - csp->cmdstate = BSCBUS_CMDSTATE_ERROR; - csp->error = LOMBUS_ERR_BADSTATUS; - ready = B_TRUE; - } else if ((data & BSCBUS_SEQ) != csp->sequence) { - /* Wrong sequence number! Flag this as an error */ - bscbus_cmd_log(csp, BSC_CMD_ERROR_SEQ, status, data); - - csp->cmdstate = BSCBUS_CMDSTATE_ERROR; - csp->error = LOMBUS_ERR_SEQUENCE; - ready = B_TRUE; - } else { - /* - * Finally, we know that's it's a valid reply to our - * last command. Update the ASYNC status, derive the - * reply parameter (if any), and check the ERROR bit - * to find out what the parameter means. - * - * Note that not all the values read/assigned here - * are meaningful, but it doesn't matter; the waiting - * thread will know which one(s) it should check. - */ - bscbus_cmd_log(csp, BSC_CMD_COMPLETE, status, data); - csp->async = (data & BSCBUS_STATUS_ASYNC) ? 1 : 0; - - tmp = ((data & BSCBUS_STATUS_MSB) ? 0x80 : 0) | csp->reply[0]; - if (data & BSCBUS_STATUS_ERR) { - csp->cmdstate = BSCBUS_CMDSTATE_ERROR; - csp->error = tmp; - } else { - csp->cmdstate = BSCBUS_CMDSTATE_READY; - csp->result = tmp; - } - ready = B_TRUE; - } - return (ready); -} - -/* - * Packet receive handler - * - * This routine should be called from the low-level softint, - * or bscbus_cmd() (for polled operation), with the - * low-level mutex already held. - */ -static void -bscbus_process(struct bscbus_channel_state *csp, - uint8_t status, uint8_t data) -{ - boolean_t ready = B_FALSE; - - ASSERT(mutex_owned(csp->lo_mutex)); - - if ((status & H8_STR_OBF) || (status & H8_STR_IBF)) { - bscbus_trace(csp, 'D', "bscbus_process", - "state %d; error $%x", - csp->cmdstate, csp->error); - } - - switch (csp->cmdstate) { - case BSCBUS_CMDSTATE_CLEARING: - bscbus_process_clearing(csp, status, data); - break; - case BSCBUS_CMDSTATE_SENDING: - bscbus_process_sending(csp, status); - break; - case BSCBUS_CMDSTATE_PENDING: - bscbus_process_pending(csp, status); - break; - case BSCBUS_CMDSTATE_WAITING: - ready = bscbus_process_waiting(csp, status, data); - break; - default: - /* Nothing to do */ - break; - } - - /* - * Check for timeouts - but only if the command has not yet - * completed (ready is true when command completes in this - * call to bscbus_process OR cmdstate is READY or ERROR if - * this is a spurious call to bscbus_process i.e. a spurious - * interrupt) - */ - if (!ready && - ((ddi_get_lbolt() - csp->deadline) > 0) && - csp->cmdstate != BSCBUS_CMDSTATE_READY && - csp->cmdstate != BSCBUS_CMDSTATE_ERROR) { - bscbus_trace(csp, 'P', "bscbus_process", - "timeout previous state %d; error $%x", - csp->cmdstate, csp->error); - bscbus_cmd_log(csp, BSC_CMD_ERROR_TOUT, status, data); - if (csp->cmdstate == BSCBUS_CMDSTATE_CLEARING) { - /* Move onto sending because busy might be stuck */ - csp->cmdstate = BSCBUS_CMDSTATE_SENDING; - /* Extend timeout relative to original start time */ - csp->deadline += drv_usectohz(LOMBUS_CMD_TIMEOUT/1000); - } else if (csp->cmdstate != BSCBUS_CMDSTATE_IDLE) { - csp->cmdstate = BSCBUS_CMDSTATE_ERROR; - csp->error = LOMBUS_ERR_TIMEOUT; - } - ready = B_TRUE; - } - - if ((status & H8_STR_OBF) || (status & H8_STR_IBF) || ready) { - bscbus_trace(csp, 'D', "bscbus_process", - "last $%02x; state %d; error $%x; ready %d", - data, csp->cmdstate, csp->error, ready); - } - if (ready) - cv_broadcast(csp->lo_cv); -} - -static uint_t -bscbus_hwintr(caddr_t arg) -{ - struct bscbus_channel_state *csp = (void *)arg; - - uint8_t status; - uint8_t data = 0xb0 /* Dummy value */; - - mutex_enter(csp->lo_mutex); - /* - * Read the registers to ensure that the interrupt is cleared. - * Status must be read first because reading data changes the - * status. - * We always read the data because that clears the interrupt down. - * This is horrible hardware semantics but we have to do it! - */ - status = bscbus_get_reg(csp, H8_STR); - data = bscbus_get_reg(csp, H8_ODR); - if (!(status & H8_STR_OBF)) { - bscbus_cmd_log(csp, BSC_CMD_V1INTRUNCL, status, data); - csp->unclaimed_count++; - } else { - bscbus_cmd_log(csp, BSC_CMD_V1INTR, status, data); - } - if (status & H8_STR_TOKENPROTOCOL) { - bscbus_process(csp, status, data); - if (csp->interrupt_failed) { - bscbus_trace(csp, 'I', "bscbus_hwintr:", - "interrupt fault cleared channel %d", csp->chno); - csp->interrupt_failed = B_FALSE; - csp->poll_hz = drv_usectohz(BSCBUS_CMD_POLL / 1000); - } - } - - mutex_exit(csp->lo_mutex); - return (DDI_INTR_CLAIMED); -} - -void -bscbus_poll(struct bscbus_channel_state *csp) -{ - /* - * This routine is only called if we timeout in userland - * waiting for an interrupt. This generally means that we have - * lost interrupt capabilities or that something has gone - * wrong. In this case we are allowed to access the hardware - * and read the data register if necessary. - * If interrupts return then recovery actions should mend us! - */ - uint8_t status; - uint8_t data = 0xfa; /* Dummy value */ - - ASSERT(mutex_owned(csp->lo_mutex)); - - /* Should look for data to receive */ - status = bscbus_get_reg(csp, H8_STR); - if (status & H8_STR_OBF) { - /* There is data available */ - data = bscbus_get_reg(csp, H8_ODR); - bscbus_cmd_log(csp, BSC_CMD_PROCESS, status, data); - } - bscbus_process(csp, status, data); -} - -/* - * Serial protocol - * - * This routine builds a command and sets it in progress. - */ -static uint8_t -bscbus_cmd(HANDLE_TYPE *hdlp, ptrdiff_t vreg, uint_t val, uint_t cmd) -{ - struct bscbus_channel_state *csp; - clock_t start; - uint8_t status; - - /* - * First of all, wait for the interface to be available. - * - * NOTE: we blow through all the mutex/cv/state checking and - * preempt any command in progress if the system is panicking! - */ - csp = HANDLE_PRIVATE(hdlp); - mutex_enter(csp->lo_mutex); - while (csp->cmdstate != BSCBUS_CMDSTATE_IDLE && !ddi_in_panic()) - cv_wait(csp->lo_cv, csp->lo_mutex); - - csp->cmdstate = BSCBUS_CMDSTATE_BUSY; - csp->sequence = (csp->sequence + BSCBUS_SEQ_LSB) & BSCBUS_SEQ; - - /* - * We have exclusive ownership, so assemble the command (backwards): - * - * [byte 0] Command: modified by XADDR and/or WMSB bits - * [Optional] Parameter: Value to write (low 7 bits) - * [Optional] Parameter: Register number (high 7 bits) - * [Optional] Parameter: Register number (low 7 bits) - */ - csp->cmdp = &csp->cmdbuf[0]; - *csp->cmdp++ = BSCBUS_CMD | csp->sequence | cmd; - switch (cmd) { - case BSCBUS_CMD_WRITE: - *csp->cmdp++ = val & 0x7f; - if (val >= 0x80) - csp->cmdbuf[0] |= BSCBUS_CMD_WMSB; - /*FALLTHRU*/ - case BSCBUS_CMD_READ: - if (BSCBUS_VREG_HI(vreg) != 0) { - *csp->cmdp++ = BSCBUS_VREG_HI(vreg); - csp->cmdbuf[0] |= BSCBUS_CMD_XADDR; - } - *csp->cmdp++ = BSCBUS_VREG_LO(vreg); - /*FALLTHRU*/ - case BSCBUS_CMD_NOP: - break; - } - - /* - * Check and update the H8 h/w fault status before accessing - * the chip registers. If there's a (new or previous) fault, - * we'll run through the protocol but won't really touch the - * hardware and all commands will timeout. If a previously - * discovered fault has now gone away (!), then we can (try to) - * proceed with the new command (probably a probe). - */ - bscbus_check_fault_status(csp); - - /* - * Prepare for the command (to be processed by the interrupt - * handler and/or polling loop below), and wait for a response - * or timeout. - */ - start = ddi_get_lbolt(); - csp->deadline = start + drv_usectohz(LOMBUS_CMD_TIMEOUT/1000); - csp->error = 0; - csp->index = 0; - csp->result = DUMMY_VALUE; - - status = bscbus_get_reg(csp, H8_STR); - if (status & H8_STR_BUSY) { - bscbus_cmd_log(csp, BSC_CMD_BUSY, status, 0xfd); - /* - * Must ensure that the busy state has cleared before - * sending the command - */ - csp->cmdstate = BSCBUS_CMDSTATE_CLEARING; - bscbus_trace(csp, 'P', "bscbus_cmd", - "h8 reporting status (%x) busy - clearing", status); - } else { - /* It is clear to send the command immediately */ - csp->cmdstate = BSCBUS_CMDSTATE_SENDING; - bscbus_trace(csp, 'P', "bscbus_cmd", - "sending first byte of command, status %x", status); - bscbus_poll(csp); - } - - csp->poll_hz = drv_usectohz( - (csp->interrupt_failed ? - BSCBUS_CMD_POLLNOINTS : BSCBUS_CMD_POLL) / 1000); - - while ((csp->cmdstate != BSCBUS_CMDSTATE_READY) && - (csp->cmdstate != BSCBUS_CMDSTATE_ERROR)) { - ASSERT(csp->cmdstate != BSCBUS_CMDSTATE_IDLE); - - if ((cv_reltimedwait(csp->lo_cv, csp->lo_mutex, - csp->poll_hz, TR_CLOCK_TICK) == -1) && - csp->cmdstate != BSCBUS_CMDSTATE_READY && - csp->cmdstate != BSCBUS_CMDSTATE_ERROR) { - if (!csp->interrupt_failed) { - bscbus_trace(csp, 'I', "bscbus_cmd:", - "interrupt_failed channel %d", csp->chno); - csp->interrupt_failed = B_TRUE; - csp->poll_hz = drv_usectohz( - BSCBUS_CMD_POLLNOINTS / 1000); - } - bscbus_poll(csp); - } - } - - /* - * The return value may not be meaningful but retrieve it anyway - */ - val = csp->result; - if (bscbus_faulty(csp)) { - val = DUMMY_VALUE; - HANDLE_FAULT(hdlp) = LOMBUS_ERR_SIOHW; - } else if (csp->cmdstate != BSCBUS_CMDSTATE_READY) { - /* - * Some problem here ... transfer the error code from - * the per-instance state to the per-handle fault flag. - * The error code shouldn't be zero! - */ - if (csp->error != 0) - HANDLE_FAULT(hdlp) = csp->error; - else - HANDLE_FAULT(hdlp) = LOMBUS_ERR_BADERRCODE; - } - - /* - * All done now! - */ - csp->index = 0; - csp->cmdstate = BSCBUS_CMDSTATE_IDLE; - cv_broadcast(csp->lo_cv); - mutex_exit(csp->lo_mutex); - - return (val); -} - -/* - * Space 0 - LOM virtual register access - * Only 8-bit accesses are supported. - */ -static uint8_t -bscbus_vreg_get8(HANDLE_TYPE *hdlp, uint8_t *addr) -{ - ptrdiff_t offset; - - /* - * Check the offset that the caller has added to the base address - * against the length of the mapping originally requested. - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - if (offset < 0 || offset >= HANDLE_MAPLEN(hdlp)) { - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_NUM; - return (DUMMY_VALUE); - } - - /* - * Derive the virtual register number and run the command - */ - return (bscbus_cmd(hdlp, ADDR_TO_VREG(addr), 0, BSCBUS_CMD_READ)); -} - -static void -bscbus_vreg_put8(HANDLE_TYPE *hdlp, uint8_t *addr, uint8_t val) -{ - ptrdiff_t offset; - - /* - * Check the offset that the caller has added to the base address - * against the length of the mapping originally requested. - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - if (offset < 0 || offset >= HANDLE_MAPLEN(hdlp)) { - /* - * Invalid access - flag a fault and return - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_NUM; - return; - } - - /* - * Derive the virtual register number and run the command - */ - (void) bscbus_cmd(hdlp, ADDR_TO_VREG(addr), val, BSCBUS_CMD_WRITE); -} - -static void -bscbus_vreg_rep_get8(HANDLE_TYPE *hdlp, uint8_t *host_addr, - uint8_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - *host_addr++ = bscbus_vreg_get8(hdlp, dev_addr); -} - -static void -bscbus_vreg_rep_put8(HANDLE_TYPE *hdlp, uint8_t *host_addr, - uint8_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - bscbus_vreg_put8(hdlp, dev_addr, *host_addr++); -} - - -/* - * Space 1 - LOM watchdog pat register access - * Only 8-bit accesses are supported. - * - * Reads have no effect and return 0. - * - * Multi-byte reads (using ddi_rep_get8(9F)) are a fairly inefficient - * way of zeroing the destination area ;-) and still won't pat the dog. - * - * Multi-byte writes (using ddi_rep_put8(9F)) will almost certainly - * only count as a single pat, no matter how many bytes the caller - * says to write, as the inter-pat time is VERY long compared with - * the time it will take to read the memory source area. - */ - -static uint8_t -bscbus_pat_get8(HANDLE_TYPE *hdlp, uint8_t *addr) -{ - ptrdiff_t offset; - - /* - * Check the offset that the caller has added to the base address - * against the length of the mapping originally requested. - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - if (offset < 0 || offset >= HANDLE_MAPLEN(hdlp)) { - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_NUM; - return (DUMMY_VALUE); - } - - return (0); -} - -static void -bscbus_pat_put8(HANDLE_TYPE *hdlp, uint8_t *addr, uint8_t val) -{ - struct bscbus_channel_state *csp; - ptrdiff_t offset; - - /* - * Check the offset that the caller has added to the base address - * against the length of the mapping originally requested. - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - if (offset < 0 || offset >= HANDLE_MAPLEN(hdlp)) { - /* - * Invalid access - flag a fault and return - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_NUM; - return; - } - - csp = HANDLE_PRIVATE(hdlp); - mutex_enter(csp->dog_mutex); - bscbus_pat_dog(csp, val); - mutex_exit(csp->dog_mutex); -} - -static void -bscbus_pat_rep_get8(HANDLE_TYPE *hdlp, uint8_t *host_addr, - uint8_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - *host_addr++ = bscbus_pat_get8(hdlp, dev_addr); -} - -static void -bscbus_pat_rep_put8(HANDLE_TYPE *hdlp, uint8_t *host_addr, - uint8_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - bscbus_pat_put8(hdlp, dev_addr, *host_addr++); -} - - -/* - * Space 2 - LOM async event flag register access - * Only 16-bit accesses are supported. - */ -static uint16_t -bscbus_event_get16(HANDLE_TYPE *hdlp, uint16_t *addr) -{ - struct bscbus_channel_state *csp; - ptrdiff_t offset; - - /* - * Check the offset that the caller has added to the base address - * against the length of the mapping orignally requested. - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - if (offset < 0 || (offset%2) != 0 || offset >= HANDLE_MAPLEN(hdlp)) { - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_NUM; - return (DUMMY_VALUE); - } - - /* - * Return the value of the asynchronous-event-pending flag - * as passed back by the LOM at the end of the last command. - */ - csp = HANDLE_PRIVATE(hdlp); - return (csp->async); -} - -static void -bscbus_event_put16(HANDLE_TYPE *hdlp, uint16_t *addr, uint16_t val) -{ - ptrdiff_t offset; - - _NOTE(ARGUNUSED(val)) - - /* - * Check the offset that the caller has added to the base address - * against the length of the mapping originally requested. - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - if (offset < 0 || (offset%2) != 0 || offset >= HANDLE_MAPLEN(hdlp)) { - /* - * Invalid access - flag a fault and return - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_NUM; - return; - } - - /* - * The user can't overwrite the asynchronous-event-pending flag! - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_RO; -} - -static void -bscbus_event_rep_get16(HANDLE_TYPE *hdlp, uint16_t *host_addr, - uint16_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - *host_addr++ = bscbus_event_get16(hdlp, dev_addr); -} - -static void -bscbus_event_rep_put16(HANDLE_TYPE *hdlp, uint16_t *host_addr, - uint16_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - bscbus_event_put16(hdlp, dev_addr, *host_addr++); -} - - -/* - * All spaces - access handle fault information - * Only 32-bit accesses are supported. - */ -static uint32_t -bscbus_meta_get32(HANDLE_TYPE *hdlp, uint32_t *addr) -{ - struct bscbus_channel_state *csp; - ptrdiff_t offset; - - /* - * Derive the offset that the caller has added to the base - * address originally returned, and use it to determine - * which meta-register is to be accessed ... - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - switch (offset) { - case LOMBUS_FAULT_REG: - /* - * This meta-register provides a code for the most - * recent virtual register access fault, if any. - */ - return (HANDLE_FAULT(hdlp)); - - case LOMBUS_PROBE_REG: - /* - * Reading this meta-register clears any existing fault - * (at the virtual, not the hardware access layer), then - * runs a NOP command and returns the fault code from that. - */ - HANDLE_FAULT(hdlp) = 0; - (void) bscbus_cmd(hdlp, 0, 0, BSCBUS_CMD_NOP); - return (HANDLE_FAULT(hdlp)); - - case LOMBUS_ASYNC_REG: - /* - * Obsolescent - but still supported for backwards - * compatibility. This is an alias for the newer - * LOMBUS_EVENT_REG, but doesn't require a separate - * "reg" entry and ddi_regs_map_setup() call. - * - * It returns the value of the asynchronous-event-pending - * flag as passed back by the BSC at the end of the last - * completed command. - */ - csp = HANDLE_PRIVATE(hdlp); - return (csp->async); - - default: - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; - return (DUMMY_VALUE); - } -} - -static void -bscbus_meta_put32(HANDLE_TYPE *hdlp, uint32_t *addr, uint32_t val) -{ - ptrdiff_t offset; - - /* - * Derive the offset that the caller has added to the base - * address originally returned, and use it to determine - * which meta-register is to be accessed ... - */ - offset = ADDR_TO_OFFSET(addr, hdlp); - switch (offset) { - case LOMBUS_FAULT_REG: - /* - * This meta-register contains a code for the most - * recent virtual register access fault, if any. - * It can be cleared simply by writing 0 to it. - */ - HANDLE_FAULT(hdlp) = val; - return; - - case LOMBUS_PROBE_REG: - /* - * Writing this meta-register clears any existing fault - * (at the virtual, not the hardware acess layer), then - * runs a NOP command. The caller can check the fault - * code later if required. - */ - HANDLE_FAULT(hdlp) = 0; - (void) bscbus_cmd(hdlp, 0, 0, BSCBUS_CMD_NOP); - return; - - default: - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; - return; - } -} - -static void -bscbus_meta_rep_get32(HANDLE_TYPE *hdlp, uint32_t *host_addr, - uint32_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - *host_addr++ = bscbus_meta_get32(hdlp, dev_addr); -} - -static void -bscbus_meta_rep_put32(HANDLE_TYPE *hdlp, uint32_t *host_addr, - uint32_t *dev_addr, size_t repcount, uint_t flags) -{ - size_t inc; - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) - bscbus_meta_put32(hdlp, dev_addr, *host_addr++); -} - - -/* - * Finally, some dummy functions for all unsupported access - * space/size/mode combinations ... - */ -static uint8_t -bscbus_no_get8(HANDLE_TYPE *hdlp, uint8_t *addr) -{ - _NOTE(ARGUNUSED(addr)) - - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; - return (DUMMY_VALUE); -} - -static void -bscbus_no_put8(HANDLE_TYPE *hdlp, uint8_t *addr, uint8_t val) -{ - _NOTE(ARGUNUSED(addr, val)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static void -bscbus_no_rep_get8(HANDLE_TYPE *hdlp, uint8_t *host_addr, - uint8_t *dev_addr, size_t repcount, uint_t flags) -{ - _NOTE(ARGUNUSED(host_addr, dev_addr, repcount, flags)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static void -bscbus_no_rep_put8(HANDLE_TYPE *hdlp, uint8_t *host_addr, - uint8_t *dev_addr, size_t repcount, uint_t flags) -{ - _NOTE(ARGUNUSED(host_addr, dev_addr, repcount, flags)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static uint16_t -bscbus_no_get16(HANDLE_TYPE *hdlp, uint16_t *addr) -{ - _NOTE(ARGUNUSED(addr)) - - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; - return (DUMMY_VALUE); -} - -static void -bscbus_no_put16(HANDLE_TYPE *hdlp, uint16_t *addr, uint16_t val) -{ - _NOTE(ARGUNUSED(addr, val)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static void -bscbus_no_rep_get16(HANDLE_TYPE *hdlp, uint16_t *host_addr, - uint16_t *dev_addr, size_t repcount, uint_t flags) -{ - _NOTE(ARGUNUSED(host_addr, dev_addr, repcount, flags)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static void -bscbus_no_rep_put16(HANDLE_TYPE *hdlp, uint16_t *host_addr, - uint16_t *dev_addr, size_t repcount, uint_t flags) -{ - _NOTE(ARGUNUSED(host_addr, dev_addr, repcount, flags)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static uint64_t -bscbus_no_get64(HANDLE_TYPE *hdlp, uint64_t *addr) -{ - _NOTE(ARGUNUSED(addr)) - - /* - * Invalid access - flag a fault and return a dummy value - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; - return (DUMMY_VALUE); -} - -static void -bscbus_no_put64(HANDLE_TYPE *hdlp, uint64_t *addr, uint64_t val) -{ - _NOTE(ARGUNUSED(addr, val)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static void -bscbus_no_rep_get64(HANDLE_TYPE *hdlp, uint64_t *host_addr, - uint64_t *dev_addr, size_t repcount, uint_t flags) -{ - _NOTE(ARGUNUSED(host_addr, dev_addr, repcount, flags)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static void -bscbus_no_rep_put64(HANDLE_TYPE *hdlp, uint64_t *host_addr, - uint64_t *dev_addr, size_t repcount, uint_t flags) -{ - _NOTE(ARGUNUSED(host_addr, dev_addr, repcount, flags)) - - /* - * Invalid access - flag a fault - */ - HANDLE_FAULT(hdlp) = LOMBUS_ERR_REG_SIZE; -} - -static int -bscbus_acc_fault_check(HANDLE_TYPE *hdlp) -{ - return (HANDLE_FAULT(hdlp) != 0); -} - -/* - * Hardware setup - ensure that there are no pending transactions and - * hence no pending interrupts. We do this be ensuring that the BSC is - * not reporting a busy condition and that it does not have any data - * pending in its output buffer. - * This is important because if we have pending interrupts at attach - * time Solaris will hang due to bugs in ddi_get_iblock_cookie. - */ -static void -bscbus_hw_reset(struct bscbus_channel_state *csp) -{ - int64_t timeout; - uint8_t status; - - if (csp->map_count == 0) { - /* No-one using this instance - no need to reset hardware */ - return; - } - - bscbus_trace(csp, 'R', "bscbus_hw_reset", - "resetting channel %d", csp->chno); - - status = bscbus_get_reg(csp, H8_STR); - if (status & H8_STR_BUSY) { - /* - * Give the h8 time to complete a reply. - * In practice we should never worry about this - * because whenever we get here it will have been - * long enough for the h8 to complete a reply - */ - bscbus_cmd_log(csp, BSC_CMD_BUSY, status, 0); - bscbus_trace(csp, 'R', "bscbus_hw_reset", - "h8 reporting status (%x) busy - waiting", status); - if (ddi_in_panic()) { - drv_usecwait(BSCBUS_HWRESET_POLL/1000); - } else { - delay(drv_usectohz(BSCBUS_HWRESET_POLL/1000)); - } - } - /* Reply should be completed by now. Try to clear busy status */ - status = bscbus_get_reg(csp, H8_STR); - if (status & (H8_STR_BUSY | H8_STR_OBF)) { - bscbus_trace(csp, 'R', "bscbus_hw_reset", - "clearing busy status for channel %d", csp->chno); - - for (timeout = BSCBUS_HWRESET_TIMEOUT; - (timeout > 0); - timeout -= BSCBUS_HWRESET_POLL) { - if (status & H8_STR_OBF) { - (void) bscbus_get_reg(csp, H8_ODR); - if (!(status & H8_STR_BUSY)) { - /* We are done */ - break; - } - } - if (ddi_in_panic()) { - drv_usecwait(BSCBUS_HWRESET_POLL/1000); - } else { - delay(drv_usectohz(BSCBUS_HWRESET_POLL/1000)); - } - status = bscbus_get_reg(csp, H8_STR); - } - if (timeout <= 0) { - cmn_err(CE_WARN, "bscbus_hw_reset: timed out " - "clearing busy status"); - } - } - /* - * We read ODR just in case there is a pending interrupt with - * no data. This is potentially dangerous because we could get - * out of sync due to race conditions BUT at this point the - * channel should be idle so it is safe. - */ - (void) bscbus_get_reg(csp, H8_ODR); -} - -/* - * Higher-level setup & teardown - */ - -static void -bscbus_offline(struct bscbus_state *ssp) -{ - if (ssp->h8_handle != NULL) - ddi_regs_map_free(&ssp->h8_handle); - ssp->h8_handle = NULL; - ssp->h8_regs = NULL; -} - -static int -bscbus_online(struct bscbus_state *ssp) -{ - ddi_acc_handle_t h; - caddr_t p; - int nregs; - int err; - - ssp->h8_handle = NULL; - ssp->h8_regs = (void *)NULL; - ssp->per_channel_regs = B_FALSE; - - if (ddi_dev_nregs(ssp->dip, &nregs) != DDI_SUCCESS) - nregs = 0; - - switch (nregs) { - case 1: - /* - * regset 0 represents the H8 interface registers - */ - err = ddi_regs_map_setup(ssp->dip, 0, &p, 0, 0, - bscbus_dev_acc_attr, &h); - if (err != DDI_SUCCESS) - return (EIO); - - ssp->h8_handle = h; - ssp->h8_regs = (void *)p; - break; - - case 0: - /* - * If no registers are defined, succeed vacuously; - * commands will be accepted, but we fake the accesses. - */ - break; - - default: - /* - * Remember that we are using the new register scheme. - * reg set 0 is chan 0 - * reg set 1 is chan 1 ... - * Interrupts are specified in that order but later - * channels may not have interrupts. - * We map the regs later on a per channel basis. - */ - ssp->per_channel_regs = B_TRUE; - break; - } - return (0); -} - -static int -bscbus_claim_channel(struct bscbus_channel_state *csp, boolean_t map_dog) -{ - int err; - - mutex_enter(csp->ssp->ch_mutex); - csp->map_count++; - bscbus_trace(csp, 'C', "bscbus_claim_channel", - "claim channel for channel %d, count %d", - csp->chno, csp->map_count); - - if (csp->map_count == 1) { - /* No-one is using this channel - initialise it */ - bscbus_trace(csp, 'C', "bscbus_claim_channel", - "initialise channel %d, count %d", - csp->chno, csp->map_count); - - mutex_init(csp->dog_mutex, NULL, MUTEX_DRIVER, - (void *)(uintptr_t)__ipltospl(SPL7 - 1)); - csp->map_dog = map_dog; - csp->interrupt_failed = B_FALSE; - csp->cmdstate = BSCBUS_CMDSTATE_IDLE; - csp->pat_retry_count = 0; - csp->pat_fail_count = 0; - - /* Map appropriate register set for this channel */ - if (csp->ssp->per_channel_regs == B_TRUE) { - ddi_acc_handle_t h; - caddr_t p; - - err = ddi_regs_map_setup(csp->ssp->dip, csp->chno, - &p, 0, 0, bscbus_dev_acc_attr, &h); - - if (err != DDI_SUCCESS) { - goto failed1; - } - - csp->ch_handle = h; - csp->ch_regs = (void *)p; - - bscbus_trace(csp, 'C', "bscbus_claim_channel", - "mapped chno=%d ch_handle=%d ch_regs=%p", - csp->chno, h, p); - } else { - /* - * if using the old reg property scheme use the - * common mapping. - */ - csp->ch_handle = csp->ssp->h8_handle; - csp->ch_regs = - csp->ssp->h8_regs + - BSCBUS_CHANNEL_TO_OFFSET(csp->chno); - } - - /* Ensure no interrupts pending prior to getting iblk cookie */ - bscbus_hw_reset(csp); - - if (csp->map_dog == 1) { - /* - * we don't want lo_mutex to be initialised - * with an iblock cookie if we are the wdog, - * because we don't use interrupts. - */ - mutex_init(csp->lo_mutex, NULL, - MUTEX_DRIVER, NULL); - cv_init(csp->lo_cv, NULL, - CV_DRIVER, NULL); - csp->unclaimed_count = 0; - } else { - int ninterrupts; - - /* - * check that there is an interrupt for this - * this channel. If we fail to setup interrupts we - * must unmap the registers and fail. - */ - err = ddi_dev_nintrs(csp->ssp->dip, &ninterrupts); - - if (err != DDI_SUCCESS) { - ninterrupts = 0; - } - - if (ninterrupts <= csp->chno) { - cmn_err(CE_WARN, - "no interrupt available for " - "bscbus channel %d", csp->chno); - goto failed2; - } - - if (ddi_intr_hilevel(csp->ssp->dip, csp->chno) != 0) { - cmn_err(CE_WARN, - "bscbus interrupts are high " - "level - channel not usable."); - goto failed2; - } else { - err = ddi_get_iblock_cookie(csp->ssp->dip, - csp->chno, &csp->lo_iblk); - if (err != DDI_SUCCESS) { - goto failed2; - } - - mutex_init(csp->lo_mutex, NULL, - MUTEX_DRIVER, csp->lo_iblk); - cv_init(csp->lo_cv, NULL, - CV_DRIVER, NULL); - csp->unclaimed_count = 0; - - err = ddi_add_intr(csp->ssp->dip, csp->chno, - &csp->lo_iblk, NULL, - bscbus_hwintr, (caddr_t)csp); - if (err != DDI_SUCCESS) { - cv_destroy(csp->lo_cv); - mutex_destroy(csp->lo_mutex); - goto failed2; - } - } - } - /* - * The channel is now live and may - * receive interrupts - */ - } else if (csp->map_dog != map_dog) { - bscbus_trace(csp, 'C', "bscbus_claim_channel", - "request conflicts with previous mapping. old %x, new %x.", - csp->map_dog, map_dog); - goto failed1; - } - mutex_exit(csp->ssp->ch_mutex); - return (1); - -failed2: - /* unmap regs for failed channel */ - if (csp->ssp->per_channel_regs == B_TRUE) { - ddi_regs_map_free(&csp->ch_handle); - } - csp->ch_handle = NULL; - csp->ch_regs = (void *)NULL; -failed1: - csp->map_count--; - mutex_exit(csp->ssp->ch_mutex); - return (0); -} - -static void -bscbus_release_channel(struct bscbus_channel_state *csp) -{ - mutex_enter(csp->ssp->ch_mutex); - if (csp->map_count == 1) { - /* No-one is now using this channel - shutdown channel */ - bscbus_trace(csp, 'C', "bscbus_release_channel", - "shutdown channel %d, count %d", - csp->chno, csp->map_count); - - if (csp->map_dog == 0) { - ASSERT(!ddi_intr_hilevel(csp->ssp->dip, csp->chno)); - ddi_remove_intr(csp->ssp->dip, csp->chno, csp->lo_iblk); - } - cv_destroy(csp->lo_cv); - mutex_destroy(csp->lo_mutex); - mutex_destroy(csp->dog_mutex); - bscbus_hw_reset(csp); - - /* unmap registers if using the new register scheme */ - if (csp->ssp->per_channel_regs == B_TRUE) { - ddi_regs_map_free(&csp->ch_handle); - } - csp->ch_handle = NULL; - csp->ch_regs = (void *)NULL; - } - csp->map_count--; - bscbus_trace(csp, 'C', "bscbus_release_channel", - "release channel %d, count %d", - csp->chno, csp->map_count); - mutex_exit(csp->ssp->ch_mutex); -} - - -/* - * Nexus routines - */ - -#if defined(NDI_ACC_HDL_V2) - -static const ndi_acc_fns_t bscbus_vreg_acc_fns = { - NDI_ACC_FNS_CURRENT, - NDI_ACC_FNS_V1, - - bscbus_vreg_get8, - bscbus_vreg_put8, - bscbus_vreg_rep_get8, - bscbus_vreg_rep_put8, - - bscbus_no_get16, - bscbus_no_put16, - bscbus_no_rep_get16, - bscbus_no_rep_put16, - - bscbus_meta_get32, - bscbus_meta_put32, - bscbus_meta_rep_get32, - bscbus_meta_rep_put32, - - bscbus_no_get64, - bscbus_no_put64, - bscbus_no_rep_get64, - bscbus_no_rep_put64, - - bscbus_acc_fault_check -}; - -static const ndi_acc_fns_t bscbus_pat_acc_fns = { - NDI_ACC_FNS_CURRENT, - NDI_ACC_FNS_V1, - - bscbus_pat_get8, - bscbus_pat_put8, - bscbus_pat_rep_get8, - bscbus_pat_rep_put8, - - bscbus_no_get16, - bscbus_no_put16, - bscbus_no_rep_get16, - bscbus_no_rep_put16, - - bscbus_meta_get32, - bscbus_meta_put32, - bscbus_meta_rep_get32, - bscbus_meta_rep_put32, - - bscbus_no_get64, - bscbus_no_put64, - bscbus_no_rep_get64, - bscbus_no_rep_put64, - - bscbus_acc_fault_check -}; - -static const ndi_acc_fns_t bscbus_event_acc_fns = { - NDI_ACC_FNS_CURRENT, - NDI_ACC_FNS_V1, - - bscbus_no_get8, - bscbus_no_put8, - bscbus_no_rep_get8, - bscbus_no_rep_put8, - - bscbus_event_get16, - bscbus_event_put16, - bscbus_event_rep_get16, - bscbus_event_rep_put16, - - bscbus_meta_get32, - bscbus_meta_put32, - bscbus_meta_rep_get32, - bscbus_meta_rep_put32, - - bscbus_no_get64, - bscbus_no_put64, - bscbus_no_rep_get64, - bscbus_no_rep_put64, - - bscbus_acc_fault_check -}; - -static int -bscbus_map_handle(struct bscbus_channel_state *csp, ddi_map_op_t op, - int space, caddr_t vaddr, off_t len, - ndi_acc_handle_t *hdlp, caddr_t *addrp) -{ - switch (op) { - default: - return (DDI_ME_UNIMPLEMENTED); - - case DDI_MO_MAP_LOCKED: - if (bscbus_claim_channel(csp, - (space == LOMBUS_PAT_SPACE)) == 0) { - return (DDI_ME_GENERIC); - } - - switch (space) { - default: - return (DDI_ME_REGSPEC_RANGE); - - case LOMBUS_VREG_SPACE: - ndi_set_acc_fns(hdlp, &bscbus_vreg_acc_fns); - break; - - case LOMBUS_PAT_SPACE: - ndi_set_acc_fns(hdlp, &bscbus_pat_acc_fns); - break; - - case LOMBUS_EVENT_SPACE: - ndi_set_acc_fns(hdlp, &bscbus_event_acc_fns); - break; - } - hdlp->ah_addr = *addrp = vaddr; - hdlp->ah_len = len; - hdlp->ah_bus_private = csp; - return (DDI_SUCCESS); - - case DDI_MO_UNMAP: - *addrp = NULL; - hdlp->ah_bus_private = NULL; - bscbus_release_channel(csp); - return (DDI_SUCCESS); - } -} - -#else - -static int -bscbus_map_handle(struct bscbus_channel_state *csp, ddi_map_op_t op, - int space, caddr_t vaddr, off_t len, - ddi_acc_hdl_t *hdlp, caddr_t *addrp) -{ - ddi_acc_impl_t *aip = hdlp->ah_platform_private; - - switch (op) { - default: - return (DDI_ME_UNIMPLEMENTED); - - case DDI_MO_MAP_LOCKED: - if (bscbus_claim_channel(csp, - (space == LOMBUS_PAT_SPACE)) == 0) { - return (DDI_ME_GENERIC); - } - - switch (space) { - default: - return (DDI_ME_REGSPEC_RANGE); - - case LOMBUS_VREG_SPACE: - aip->ahi_get8 = bscbus_vreg_get8; - aip->ahi_put8 = bscbus_vreg_put8; - aip->ahi_rep_get8 = bscbus_vreg_rep_get8; - aip->ahi_rep_put8 = bscbus_vreg_rep_put8; - - aip->ahi_get16 = bscbus_no_get16; - aip->ahi_put16 = bscbus_no_put16; - aip->ahi_rep_get16 = bscbus_no_rep_get16; - aip->ahi_rep_put16 = bscbus_no_rep_put16; - - aip->ahi_get32 = bscbus_meta_get32; - aip->ahi_put32 = bscbus_meta_put32; - aip->ahi_rep_get32 = bscbus_meta_rep_get32; - aip->ahi_rep_put32 = bscbus_meta_rep_put32; - - aip->ahi_get64 = bscbus_no_get64; - aip->ahi_put64 = bscbus_no_put64; - aip->ahi_rep_get64 = bscbus_no_rep_get64; - aip->ahi_rep_put64 = bscbus_no_rep_put64; - - aip->ahi_fault_check = bscbus_acc_fault_check; - break; - - case LOMBUS_PAT_SPACE: - aip->ahi_get8 = bscbus_pat_get8; - aip->ahi_put8 = bscbus_pat_put8; - aip->ahi_rep_get8 = bscbus_pat_rep_get8; - aip->ahi_rep_put8 = bscbus_pat_rep_put8; - - aip->ahi_get16 = bscbus_no_get16; - aip->ahi_put16 = bscbus_no_put16; - aip->ahi_rep_get16 = bscbus_no_rep_get16; - aip->ahi_rep_put16 = bscbus_no_rep_put16; - - aip->ahi_get32 = bscbus_meta_get32; - aip->ahi_put32 = bscbus_meta_put32; - aip->ahi_rep_get32 = bscbus_meta_rep_get32; - aip->ahi_rep_put32 = bscbus_meta_rep_put32; - - aip->ahi_get64 = bscbus_no_get64; - aip->ahi_put64 = bscbus_no_put64; - aip->ahi_rep_get64 = bscbus_no_rep_get64; - aip->ahi_rep_put64 = bscbus_no_rep_put64; - - aip->ahi_fault_check = bscbus_acc_fault_check; - break; - - case LOMBUS_EVENT_SPACE: - aip->ahi_get8 = bscbus_no_get8; - aip->ahi_put8 = bscbus_no_put8; - aip->ahi_rep_get8 = bscbus_no_rep_get8; - aip->ahi_rep_put8 = bscbus_no_rep_put8; - - aip->ahi_get16 = bscbus_event_get16; - aip->ahi_put16 = bscbus_event_put16; - aip->ahi_rep_get16 = bscbus_event_rep_get16; - aip->ahi_rep_put16 = bscbus_event_rep_put16; - - aip->ahi_get32 = bscbus_meta_get32; - aip->ahi_put32 = bscbus_meta_put32; - aip->ahi_rep_get32 = bscbus_meta_rep_get32; - aip->ahi_rep_put32 = bscbus_meta_rep_put32; - - aip->ahi_get64 = bscbus_no_get64; - aip->ahi_put64 = bscbus_no_put64; - aip->ahi_rep_get64 = bscbus_no_rep_get64; - aip->ahi_rep_put64 = bscbus_no_rep_put64; - - aip->ahi_fault_check = bscbus_acc_fault_check; - break; - } - hdlp->ah_addr = *addrp = vaddr; - hdlp->ah_len = len; - hdlp->ah_bus_private = csp; - return (DDI_SUCCESS); - - case DDI_MO_UNMAP: - *addrp = NULL; - hdlp->ah_bus_private = NULL; - bscbus_release_channel(csp); - return (DDI_SUCCESS); - } -} - -#endif /* NDI_ACC_HDL_V2 */ - -static int -bscbus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, - off_t off, off_t len, caddr_t *addrp) -{ - struct bscbus_child_info *lcip; - struct bscbus_state *ssp; - lombus_regspec_t *rsp; - - if ((ssp = bscbus_getstate(dip, -1, "bscbus_map")) == NULL) - return (DDI_FAILURE); /* this "can't happen" */ - - /* - * Validate mapping request ... - */ - - if (mp->map_flags != DDI_MF_KERNEL_MAPPING) - return (DDI_ME_UNSUPPORTED); - if (mp->map_handlep == NULL) - return (DDI_ME_UNSUPPORTED); - if (mp->map_type != DDI_MT_RNUMBER) - return (DDI_ME_UNIMPLEMENTED); - if ((lcip = ddi_get_parent_data(rdip)) == NULL) - return (DDI_ME_INVAL); - if ((rsp = lcip->rsp) == NULL) - return (DDI_ME_INVAL); - if (mp->map_obj.rnumber >= lcip->nregs) - return (DDI_ME_RNUMBER_RANGE); - rsp += mp->map_obj.rnumber; - if (off < 0 || off >= rsp->lombus_size) - return (DDI_ME_INVAL); - if (len == 0) - len = rsp->lombus_size-off; - if (len < 0) - return (DDI_ME_INVAL); - if (off+len < 0 || off+len > rsp->lombus_size) - return (DDI_ME_INVAL); - - return (bscbus_map_handle( - &ssp->channel[LOMBUS_SPACE_TO_CHANNEL(rsp->lombus_space)], - mp->map_op, LOMBUS_SPACE_TO_REGSET(rsp->lombus_space), - VREG_TO_ADDR(rsp->lombus_base+off), len, mp->map_handlep, addrp)); -} - - -static int -bscbus_ctlops(dev_info_t *dip, dev_info_t *rdip, ddi_ctl_enum_t op, - void *arg, void *result) -{ - struct bscbus_child_info *lcip; - lombus_regspec_t *rsp; - dev_info_t *cdip; - char addr[32]; - uint_t nregs; - uint_t rnum; - int *regs; - int limit; - int err; - int i; - - if (bscbus_getstate(dip, -1, "bscbus_ctlops") == NULL) - return (DDI_FAILURE); /* this "can't happen" */ - - switch (op) { - default: - break; - - case DDI_CTLOPS_INITCHILD: - /* - * First, look up and validate the "reg" property. - * - * It must be a non-empty integer array containing a set - * of triples. Once we've verified that, we can treat it - * as an array of type lombus_regspec_t[], which defines - * the meaning of the elements of each triple: - * + the first element of each triple must be a valid space - * + the second and third elements (base, size) of each - * triple must define a valid subrange of that space - * If it passes all the tests, we save it away for future - * reference in the child's parent-private-data field. - */ - cdip = arg; - err = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cdip, - DDI_PROP_DONTPASS, "reg", ®s, &nregs); - if (err != DDI_PROP_SUCCESS) - return (DDI_FAILURE); - - err = (nregs <= 0 || (nregs % LOMBUS_REGSPEC_SIZE) != 0); - nregs /= LOMBUS_REGSPEC_SIZE; - rsp = (lombus_regspec_t *)regs; - for (i = 0; i < nregs && !err; ++i) { - switch (LOMBUS_SPACE_TO_REGSET(rsp[i].lombus_space)) { - default: - limit = 0; - err = 1; - cmn_err(CE_WARN, - "child(%p): unknown reg space %d", - (void *)cdip, rsp[i].lombus_space); - break; - - case LOMBUS_VREG_SPACE: - limit = LOMBUS_MAX_REG+1; - break; - - case LOMBUS_PAT_SPACE: - limit = LOMBUS_PAT_REG+1; - break; - - case LOMBUS_EVENT_SPACE: - limit = LOMBUS_EVENT_REG+1; - break; - } - - err |= (rsp[i].lombus_base < 0); - err |= (rsp[i].lombus_base >= limit); - - if (rsp[i].lombus_size == 0) - rsp[i].lombus_size = limit-rsp[i].lombus_base; - - err |= (rsp[i].lombus_size < 0); - err |= (rsp[i].lombus_base+rsp[i].lombus_size < 0); - err |= (rsp[i].lombus_base+rsp[i].lombus_size > limit); - - err |= (rsp[i].lombus_base+rsp[i].lombus_size > limit); - - } - - if (err) { - ddi_prop_free(regs); - return (DDI_FAILURE); - } - - lcip = kmem_zalloc(sizeof (*lcip), KM_SLEEP); - lcip->nregs = nregs; - lcip->rsp = rsp; - ddi_set_parent_data(cdip, lcip); - - (void) snprintf(addr, sizeof (addr), - "%x,%x", rsp[0].lombus_space, rsp[0].lombus_base); - ddi_set_name_addr(cdip, addr); - - return (DDI_SUCCESS); - - case DDI_CTLOPS_UNINITCHILD: - cdip = arg; - ddi_set_name_addr(cdip, NULL); - lcip = ddi_get_parent_data(cdip); - ddi_set_parent_data(cdip, NULL); - ddi_prop_free(lcip->rsp); - kmem_free(lcip, sizeof (*lcip)); - return (DDI_SUCCESS); - - case DDI_CTLOPS_REPORTDEV: - if (rdip == NULL) - return (DDI_FAILURE); - - cmn_err(CE_CONT, "?BSC device: %s@%s, %s#%d\n", - ddi_node_name(rdip), ddi_get_name_addr(rdip), - ddi_driver_name(dip), ddi_get_instance(dip)); - - return (DDI_SUCCESS); - - case DDI_CTLOPS_REGSIZE: - if ((lcip = ddi_get_parent_data(rdip)) == NULL) - return (DDI_FAILURE); - if ((rnum = *(uint_t *)arg) >= lcip->nregs) - return (DDI_FAILURE); - *(off_t *)result = lcip->rsp[rnum].lombus_size; - return (DDI_SUCCESS); - - case DDI_CTLOPS_NREGS: - if ((lcip = ddi_get_parent_data(rdip)) == NULL) - return (DDI_FAILURE); - *(int *)result = lcip->nregs; - return (DDI_SUCCESS); - } - - return (ddi_ctlops(dip, rdip, op, arg, result)); -} - - -/* - * This nexus does not support passing interrupts to leaf drivers, so - * all the intrspec-related operations just fail as cleanly as possible. - */ - -/*ARGSUSED*/ -static int -bscbus_intr_op(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, - ddi_intr_handle_impl_t *hdlp, void *result) -{ -#if defined(__sparc) - return (i_ddi_intr_ops(dip, rdip, op, hdlp, result)); -#else - _NOTE(ARGUNUSED(dip, rdip, op, hdlp, result)) - return (DDI_FAILURE); -#endif -} - -/* - * Clean up on detach or failure of attach - */ -static int -bscbus_unattach(struct bscbus_state *ssp, int instance) -{ - int chno; - - if (ssp != NULL) { - for (chno = 0; chno < BSCBUS_MAX_CHANNELS; chno++) { - ASSERT(ssp->channel[chno].map_count == 0); - } - bscbus_offline(ssp); - ddi_set_driver_private(ssp->dip, NULL); - mutex_destroy(ssp->ch_mutex); - } -#ifdef BSCBUS_LOGSTATUS - if (ssp->cmd_log_size != 0) { - kmem_free(ssp->cmd_log, - ssp->cmd_log_size * sizeof (bsc_cmd_log_t)); - } -#endif /* BSCBUS_LOGSTATUS */ - - - ddi_soft_state_free(bscbus_statep, instance); - return (DDI_FAILURE); -} - -/* - * Autoconfiguration routines - */ - -static int -bscbus_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - struct bscbus_state *ssp = NULL; - int chno; - int instance; - int err; - - switch (cmd) { - default: - return (DDI_FAILURE); - - case DDI_ATTACH: - break; - } - - /* - * Allocate the soft-state structure - */ - instance = ddi_get_instance(dip); - if (ddi_soft_state_zalloc(bscbus_statep, instance) != DDI_SUCCESS) - return (DDI_FAILURE); - if ((ssp = bscbus_getstate(dip, instance, "bscbus_attach")) == NULL) - return (bscbus_unattach(ssp, instance)); - ddi_set_driver_private(dip, ssp); - - /* - * Initialise devinfo-related fields - */ - ssp->dip = dip; - ssp->majornum = ddi_driver_major(dip); - ssp->instance = instance; - - /* - * Set various options from .conf properties - */ - ssp->debug = ddi_prop_get_int(DDI_DEV_T_ANY, dip, - DDI_PROP_DONTPASS, "debug", 0); - - mutex_init(ssp->ch_mutex, NULL, MUTEX_DRIVER, NULL); - -#ifdef BSCBUS_LOGSTATUS - ssp->cmd_log_size = bscbus_cmd_log_size; - if (ssp->cmd_log_size != 0) { - ssp->cmd_log_idx = 0; - ssp->cmd_log = kmem_zalloc(ssp->cmd_log_size * - sizeof (bsc_cmd_log_t), KM_SLEEP); - } -#endif /* BSCBUS_LOGSTATUS */ - - /* - * Online the hardware ... - */ - err = bscbus_online(ssp); - if (err != 0) - return (bscbus_unattach(ssp, instance)); - - for (chno = 0; chno < BSCBUS_MAX_CHANNELS; chno++) { - struct bscbus_channel_state *csp = &ssp->channel[chno]; - - /* - * Initialise state - * The hardware/interrupts are setup at map time to - * avoid claiming hardware that OBP is using - */ - csp->ssp = ssp; - csp->chno = chno; - csp->map_count = 0; - csp->map_dog = B_FALSE; - } - - /* - * All done, report success - */ - ddi_report_dev(dip); - return (DDI_SUCCESS); -} - -static int -bscbus_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - struct bscbus_state *ssp; - int instance; - - switch (cmd) { - default: - return (DDI_FAILURE); - - case DDI_DETACH: - break; - } - - instance = ddi_get_instance(dip); - if ((ssp = bscbus_getstate(dip, instance, "bscbus_detach")) == NULL) - return (DDI_FAILURE); /* this "can't happen" */ - - (void) bscbus_unattach(ssp, instance); - return (DDI_SUCCESS); -} - -static int -bscbus_reset(dev_info_t *dip, ddi_reset_cmd_t cmd) -{ - struct bscbus_state *ssp; - int chno; - - _NOTE(ARGUNUSED(cmd)) - - if ((ssp = bscbus_getstate(dip, -1, "bscbus_reset")) == NULL) - return (DDI_FAILURE); - - for (chno = 0; chno < BSCBUS_MAX_CHANNELS; chno++) { - bscbus_hw_reset(&ssp->channel[chno]); - } - return (DDI_SUCCESS); -} - - -/* - * System interface structures - */ - -static struct cb_ops bscbus_cb_ops = -{ - nodev, /* b/c open */ - nodev, /* b/c close */ - nodev, /* b strategy */ - nodev, /* b print */ - nodev, /* b dump */ - nodev, /* c read */ - nodev, /* c write */ - nodev, /* c ioctl */ - nodev, /* c devmap */ - nodev, /* c mmap */ - nodev, /* c segmap */ - nochpoll, /* c poll */ - ddi_prop_op, /* b/c prop_op */ - NULL, /* c streamtab */ - D_MP | D_NEW /* b/c flags */ -}; - -static struct bus_ops bscbus_bus_ops = -{ - BUSO_REV, /* revision */ - bscbus_map, /* bus_map */ - 0, /* get_intrspec */ - 0, /* add_intrspec */ - 0, /* remove_intrspec */ - i_ddi_map_fault, /* map_fault */ - ddi_no_dma_map, /* dma_map */ - ddi_no_dma_allochdl, /* allocate DMA handle */ - ddi_no_dma_freehdl, /* free DMA handle */ - ddi_no_dma_bindhdl, /* bind DMA handle */ - ddi_no_dma_unbindhdl, /* unbind DMA handle */ - ddi_no_dma_flush, /* flush DMA */ - ddi_no_dma_win, /* move DMA window */ - ddi_no_dma_mctl, /* generic DMA control */ - bscbus_ctlops, /* generic control */ - ddi_bus_prop_op, /* prop_op */ - ndi_busop_get_eventcookie, /* get_eventcookie */ - ndi_busop_add_eventcall, /* add_eventcall */ - ndi_busop_remove_eventcall, /* remove_eventcall */ - ndi_post_event, /* post_event */ - 0, /* interrupt control */ - 0, /* bus_config */ - 0, /* bus_unconfig */ - 0, /* bus_fm_init */ - 0, /* bus_fm_fini */ - 0, /* bus_fm_access_enter */ - 0, /* bus_fm_access_exit */ - 0, /* bus_power */ - bscbus_intr_op /* bus_intr_op */ -}; - -static struct dev_ops bscbus_dev_ops = -{ - DEVO_REV, - 0, /* refcount */ - ddi_no_info, /* getinfo */ - nulldev, /* identify */ - nulldev, /* probe */ - bscbus_attach, /* attach */ - bscbus_detach, /* detach */ - bscbus_reset, /* reset */ - &bscbus_cb_ops, /* driver operations */ - &bscbus_bus_ops, /* bus operations */ - NULL, /* power */ - ddi_quiesce_not_needed, /* quiesce */ -}; - -static struct modldrv modldrv = -{ - &mod_driverops, - "bscbus driver", - &bscbus_dev_ops -}; - -static struct modlinkage modlinkage = -{ - MODREV_1, - { - &modldrv, - NULL - } -}; - - -/* - * Dynamic loader interface code - */ - -int -_init(void) -{ - int err; - - err = ddi_soft_state_init(&bscbus_statep, - sizeof (struct bscbus_state), 0); - if (err == DDI_SUCCESS) - if ((err = mod_install(&modlinkage)) != DDI_SUCCESS) { - ddi_soft_state_fini(&bscbus_statep); - } - - return (err); -} - -int -_info(struct modinfo *mip) -{ - return (mod_info(&modlinkage, mip)); -} - -int -_fini(void) -{ - int err; - - if ((err = mod_remove(&modlinkage)) == DDI_SUCCESS) { - ddi_soft_state_fini(&bscbus_statep); - bscbus_major = NOMAJOR; - } - - return (err); -} - -#ifdef BSCBUS_LOGSTATUS -void bscbus_cmd_log(struct bscbus_channel_state *csp, bsc_cmd_stamp_t cat, - uint8_t status, uint8_t data) -{ - int idx; - bsc_cmd_log_t *logp; - struct bscbus_state *ssp; - - if ((csp) == NULL) - return; - if ((ssp = (csp)->ssp) == NULL) - return; - if (ssp->cmd_log_size == 0) - return; - if ((bscbus_cmd_log_flags & (1 << cat)) == 0) - return; - idx = atomic_inc_32_nv(&ssp->cmd_log_idx); - logp = &ssp->cmd_log[idx % ssp->cmd_log_size]; - logp->bcl_seq = idx; - logp->bcl_cat = cat; - logp->bcl_now = gethrtime(); - logp->bcl_chno = csp->chno; - logp->bcl_cmdstate = csp->cmdstate; - logp->bcl_status = status; - logp->bcl_data = data; -} -#endif /* BSCBUS_LOGSTATUS */ diff --git a/usr/src/uts/common/io/bscv.c b/usr/src/uts/common/io/bscv.c deleted file mode 100644 index a3923d5287..0000000000 --- a/usr/src/uts/common/io/bscv.c +++ /dev/null @@ -1,6420 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright 2019 Joyent, Inc. - */ - -/* - * bscv.c - multi-threaded lom driver for the Stiletto platform. - */ - -/* - * Included files. - */ - -#include <sys/note.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/uio.h> -#include <sys/open.h> -#include <sys/cred.h> -#include <sys/stream.h> -#include <sys/systm.h> -#include <sys/conf.h> -#include <sys/reboot.h> -#include <sys/modctl.h> -#include <sys/mkdev.h> -#include <sys/errno.h> -#include <sys/debug.h> -#include <sys/kmem.h> -#include <sys/consdev.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <sys/disp.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/stream.h> -#include <sys/strlog.h> -#include <sys/log.h> -#include <sys/utsname.h> -#include <sys/callb.h> -#include <sys/sysevent.h> -#include <sys/nvpair.h> -#include <sys/sysevent/eventdefs.h> -#include <sys/sysevent/domain.h> -#include <sys/sysevent/env.h> -#include <sys/sysevent/dr.h> - -#include <sys/lom_io.h> -#include <sys/bscbus.h> -#include <sys/bscv_impl.h> - -/* - * Variables defined here and visible internally only - */ - -static void *bscv_statep = NULL; - -/* - * Forward declarations - */ - -static int bscv_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); -static int bscv_attach(dev_info_t *, ddi_attach_cmd_t); -static int bscv_detach(dev_info_t *, ddi_detach_cmd_t); -static int bscv_quiesce(dev_info_t *); -static int bscv_map_regs(bscv_soft_state_t *); -static void bscv_unmap_regs(bscv_soft_state_t *); -static void bscv_map_chan_logical_physical(bscv_soft_state_t *); - -static int bscv_open(dev_t *, int, int, cred_t *); -static int bscv_close(dev_t, int, int, cred_t *); -static void bscv_full_stop(bscv_soft_state_t *); - -static void bscv_enter(bscv_soft_state_t *); -static int bscv_tryenter(bscv_soft_state_t *ssp); -static void bscv_exit(bscv_soft_state_t *); -#ifdef DEBUG -static int bscv_held(bscv_soft_state_t *); -#endif /* DEBUG */ - -static void bscv_put8(bscv_soft_state_t *, int, bscv_addr_t, uint8_t); -static void bscv_put16(bscv_soft_state_t *, int, bscv_addr_t, uint16_t); -static void bscv_put32(bscv_soft_state_t *, int, bscv_addr_t, uint32_t); -static uint8_t bscv_get8(bscv_soft_state_t *, int, bscv_addr_t); -static uint16_t bscv_get16(bscv_soft_state_t *, int, bscv_addr_t); -static uint32_t bscv_get32(bscv_soft_state_t *, int, bscv_addr_t); -static void bscv_setclear8(bscv_soft_state_t *, int, - bscv_addr_t, uint8_t, uint8_t); -static void bscv_setclear8_volatile(bscv_soft_state_t *, int, - bscv_addr_t, uint8_t, uint8_t); -static void bscv_rep_rw8(bscv_soft_state_t *, int, - uint8_t *, bscv_addr_t, size_t, uint_t, boolean_t); -static uint8_t bscv_get8_cached(bscv_soft_state_t *, bscv_addr_t); - -static uint8_t bscv_get8_locked(bscv_soft_state_t *, int, bscv_addr_t, int *); -static void bscv_rep_get8_locked(bscv_soft_state_t *, int, - uint8_t *, bscv_addr_t, size_t, uint_t, int *); - -static boolean_t bscv_faulty(bscv_soft_state_t *); -static void bscv_clear_fault(bscv_soft_state_t *); -static void bscv_set_fault(bscv_soft_state_t *); -static boolean_t bscv_session_error(bscv_soft_state_t *); -static int bscv_retcode(bscv_soft_state_t *); -static int bscv_should_retry(bscv_soft_state_t *); -static void bscv_locked_result(bscv_soft_state_t *, int *); - -static void bscv_put8_once(bscv_soft_state_t *, int, bscv_addr_t, uint8_t); -static uint8_t bscv_get8_once(bscv_soft_state_t *, int, bscv_addr_t); -static uint32_t bscv_probe(bscv_soft_state_t *, int, uint32_t *); -static void bscv_resync_comms(bscv_soft_state_t *, int); - -static boolean_t bscv_window_setup(bscv_soft_state_t *); -static int bscv_eerw(bscv_soft_state_t *, uint32_t, uint8_t *, - unsigned, boolean_t); - -static int bscv_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); -static int bscv_ioc_dogstate(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_psustate(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_fanstate(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_fledstate(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_ledstate(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_info(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_mread(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_volts(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_stats(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_temp(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_cons(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_eventlog2(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_info2(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_test(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_mprog2(bscv_soft_state_t *, intptr_t, int); -static int bscv_ioc_mread2(bscv_soft_state_t *, intptr_t, int); - -static void bscv_event_daemon(void *); -static void bscv_start_event_daemon(bscv_soft_state_t *); -static int bscv_stop_event_daemon(bscv_soft_state_t *); -static int bscv_pause_event_daemon(bscv_soft_state_t *); -static void bscv_resume_event_daemon(bscv_soft_state_t *); -static void bscv_event_process(bscv_soft_state_t *ssp, boolean_t); -static int bscv_event_validate(bscv_soft_state_t *, uint32_t, uint8_t); -static void bscv_event_process_one(bscv_soft_state_t *, lom_event_t *); -static void bscv_build_eventstring(bscv_soft_state_t *, - lom_event_t *, char *, char *); -static int bscv_level_of_event(lom_event_t *); -static void bscv_status(bscv_soft_state_t *, uint8_t, uint8_t); -char *bscv_get_label(char [][MAX_LOM2_NAME_STR], int, int); -static void bscv_generic_sysevent(bscv_soft_state_t *, char *, char *, char *, - char *, int32_t, char *); -static void bscv_sysevent(bscv_soft_state_t *, lom_event_t *); - -static int bscv_prog(bscv_soft_state_t *, intptr_t, int); -static int bscv_prog_image(bscv_soft_state_t *, boolean_t, - uint8_t *, int, uint32_t); -static int bscv_prog_receive_image(bscv_soft_state_t *, lom_prog_t *, - uint8_t *, int); -static void bscv_leave_programming_mode(bscv_soft_state_t *, boolean_t); -static int bscv_prog_stop_lom(bscv_soft_state_t *); -static int bscv_prog_start_lom(bscv_soft_state_t *); - -static int bscv_attach_common(bscv_soft_state_t *); -static int bscv_cleanup(bscv_soft_state_t *); -static void bscv_setup_capability(bscv_soft_state_t *); -static int bscv_probe_check(bscv_soft_state_t *); -static void bscv_setup_hostname(bscv_soft_state_t *); -static void bscv_read_hostname(bscv_soft_state_t *, char *); -static void bscv_write_hostname(bscv_soft_state_t *, char *, uint8_t); -static void bscv_setup_static_info(bscv_soft_state_t *); -static uint8_t bscv_read_env_name(bscv_soft_state_t *, uint8_t, - uint8_t, uint8_t, char [][MAX_LOM2_NAME_STR], int); -static void bscv_setup_events(bscv_soft_state_t *); - -static void bscv_trace(bscv_soft_state_t *, char, const char *, - const char *, ...); - -#ifdef __sparc -static void bscv_idi_init(); -static void bscv_idi_fini(); -static void bscv_idi_new_instance(dev_info_t *dip); -static void bscv_idi_clear_err(); -void bscv_idi_set(struct bscv_idi_info info); -static boolean_t bscv_idi_err(); -static boolean_t bscv_nodename_set(struct bscv_idi_info info); -static boolean_t bscv_sig_set(struct bscv_idi_info info); -static boolean_t bscv_wdog_pat(struct bscv_idi_info info); -static boolean_t bscv_wdog_cfg(struct bscv_idi_info info); -static void bscv_write_sig(bscv_soft_state_t *ssp, bscv_sig_t s); -#endif /* __sparc */ - -static void bscv_setup_watchdog(bscv_soft_state_t *ssp); -static void bscv_write_wdog_cfg(bscv_soft_state_t *, - uint_t, boolean_t, uint8_t); - -#if defined(__i386) || defined(__amd64) -static void bscv_inform_bsc(bscv_soft_state_t *, uint32_t); -static void bscv_watchdog_pat_request(void *); -static void bscv_watchdog_cfg_request(bscv_soft_state_t *, uint8_t); -static uint_t bscv_set_watchdog_timer(bscv_soft_state_t *, uint_t); -static void bscv_clear_watchdog_timer(bscv_soft_state_t *); - -static boolean_t bscv_panic_callback(void *, int); -static void bscv_watchdog_cyclic_add(bscv_soft_state_t *); -static void bscv_watchdog_cyclic_remove(bscv_soft_state_t *); - -static uint8_t wdog_reset_on_timeout = 1; - -#define WDOG_ON 1 -#define WDOG_OFF 0 -#define CLK_WATCHDOG_DEFAULT 10 /* 10 seconds */ -#define WATCHDOG_PAT_INTERVAL 1000000000 /* 1 second */ - -static int bscv_watchdog_enable; -static int bscv_watchdog_available; -static int watchdog_activated; -static uint_t bscv_watchdog_timeout_seconds; -#endif /* __i386 || __amd64 */ - -#ifdef __sparc -struct bscv_idi_callout bscv_idi_callout_table[] = { - {BSCV_IDI_NODENAME, &bscv_nodename_set }, - {BSCV_IDI_SIG, &bscv_sig_set }, - {BSCV_IDI_WDOG_PAT, &bscv_wdog_pat }, - {BSCV_IDI_WDOG_CFG, &bscv_wdog_cfg }, - {BSCV_IDI_NULL, NULL } -}; - -static struct bscv_idi_callout_mgr bscv_idi_mgr; -#endif /* __sparc */ - -/* - * Local Definitions - */ -#define STATUS_READ_LIMIT 8 /* Read up to 8 status changes at a time */ -#define MYNAME "bscv" -#define BSCV_INST_TO_MINOR(i) (i) -#define BSCV_MINOR_TO_INST(m) (m) - -/* - * Strings for daemon event reporting - */ - -static char *eventSubsysStrings[] = -{ "", /* 00 */ - "Alarm ", /* 01 */ - "temperature sensor ", /* 02 */ - "overheat sensor ", /* 03 */ - "Fan ", /* 04 */ - "supply rail ", /* 05 */ - "circuit breaker ", /* 06 */ - "PSU ", /* 07 */ - "user ", /* 08 */ - "phonehome ", /* 09; unutilized */ - "LOM ", /* 0a */ - "host ", /* 0b */ - "event log ", /* 0c */ - "", /* 0d; EVENT_SUBSYS_EXTRA unutilized */ - "LED ", /* 0e */ -}; - -static char *eventTypeStrings[] = -{ - "[null event]", /* 00 */ - "ON", /* 01 */ - "OFF", /* 02 */ - "state change", /* 03 */ - "power on", /* 04 */ - "power off", /* 05 */ - "powered off unexpectedly", /* 06 */ - "reset unexpectedly", /* 07 */ - "booted", /* 08 */ - "watchdog enabled", /* 09 */ - "watchdog disabled", /* 0a */ - "watchdog triggered", /* 0b */ - "failed", /* 0c */ - "recovered", /* 0d */ - "reset", /* 0e */ - "XIR reset", /* 0f */ - "console selected", /* 10 */ - "time reference", /* 11 */ - "script failure", /* 12 */ - "modem access failure", /* 13 */ - "modem dialing failure", /* 14 */ - "bad checksum", /* 15 */ - "added", /* 16 */ - "removed", /* 17 */ - "changed", /* 18 */ - "login", /* 19 */ - "password changed", /* 1a */ - "login failed", /* 1b */ - "logout", /* 1c */ - "flash download", /* 1d */ - "data lost", /* 1e */ - "device busy", /* 1f */ - "fault led state", /* 20 */ - "overheat", /* 21 */ - "severe overheat", /* 22 */ - "no overheat", /* 23 */ - "SCC", /* 24 */ - "device inaccessible", /* 25 */ - "Hostname change", /* 26 */ - "CPU signature timeout", /* 27 */ - "Bootmode change", /* 28 */ - "Watchdog change policy", /* 29 */ - "Watchdog change timeout", /* 2a */ -}; - -/* - * These store to mapping between the logical service, e.g. chan_prog for - * programming, and the actual Xbus channel which carries that traffic. - * Any services can be shared on the same channel apart from chan_wdogpat. - */ -static int chan_general; /* General Traffic */ -static int chan_wdogpat; /* Watchdog Patting */ -static int chan_cpusig; /* CPU signatures */ -static int chan_eeprom; /* EEPROM I/O */ -static int chan_prog; /* Programming */ - -/* - * cb_ops structure defining the driver entry points - */ - -static struct cb_ops bscv_cb_ops = { - bscv_open, /* open */ - bscv_close, /* close */ - nodev, /* strategy */ - nodev, /* print */ - nodev, /* dump */ - nodev, /* read */ - nodev, /* write */ - bscv_ioctl, /* ioctl */ - nodev, /* devmap */ - nodev, /* mmap */ - nodev, /* segmap */ - nochpoll, /* poll */ - ddi_prop_op, /* prop op */ - NULL, /* ! STREAMS */ - D_NEW | D_MP /* MT/MP Safe */ -}; - -/* - * dev_ops structure defining autoconfiguration driver autoconfiguration - * routines - */ - -static struct dev_ops bscv_dev_ops = { - DEVO_REV, /* devo_rev */ - 0, /* devo_refcnt */ - bscv_getinfo, /* devo_getinfo */ - nulldev, /* devo_identify */ - nulldev, /* devo_probe */ - bscv_attach, /* devo_attach */ - bscv_detach, /* devo_detach */ - nodev, /* devo_reset */ - &bscv_cb_ops, /* devo_cb_ops */ - (struct bus_ops *)0, /* devo_bus_ops */ - NULL, /* devo_power */ - bscv_quiesce, /* devo_quiesce */ -}; - -/* - * module configuration section - */ - -#ifdef DEBUG -#define BSCV_VERSION_STRING "bscv driver - Debug" -#else /* DEBUG */ -#define BSCV_VERSION_STRING "bscv driver" -#endif /* DEBUG */ - -static struct modldrv modldrv = { - &mod_driverops, - BSCV_VERSION_STRING, - &bscv_dev_ops, -}; - -static struct modlinkage modlinkage = { - MODREV_1, - &modldrv, - NULL -}; - -#ifdef DEBUG -/* Tracing is enabled if value is non-zero. */ -static int bscv_trace_flag = 1; - -#define BSCV_TRACE if (bscv_trace_flag != 0) bscv_trace -#else -#define BSCV_TRACE(...) (void)(0) -#endif - -/* - * kernel accessible routines. These routines are necessarily global so the - * driver can be loaded, and unloaded successfully - */ - -/* - * function - _init - * description - initializes the driver state structure and installs the - * driver module into the kernel - * inputs - none - * outputs - success or failure of module installation - */ - -int -_init(void) -{ - register int e; - - if ((e = ddi_soft_state_init(&bscv_statep, - sizeof (bscv_soft_state_t), 1)) != 0) { - return (e); - } - - if ((e = mod_install(&modlinkage)) != 0) { - ddi_soft_state_fini(&bscv_statep); - } - -#ifdef __sparc - if (e == 0) bscv_idi_init(); -#endif /* __sparc */ - return (e); -} - -/* - * function - _info - * description - provide information about a kernel loaded module - * inputs - module infomation - * outputs - success or failure of information request - */ - -int -_info(struct modinfo *modinfop) -{ - return (mod_info(&modlinkage, modinfop)); -} - -/* - * function - _fini - * description - removes a module from the kernel and frees the driver soft - * state memory - * inputs - none - * outputs - success or failure of module removal - */ - -int -_fini(void) -{ - register int e; - - if ((e = mod_remove(&modlinkage)) != 0) { - return (e); - } - -#ifdef __sparc - bscv_idi_fini(); -#endif /* __sparc */ - ddi_soft_state_fini(&bscv_statep); - - return (e); -} - -/* - * function - bscv_getinfo - * description - routine used to provide information on the driver - * inputs - device information structure, command, command arg, storage - * area for the result - * outputs - DDI_SUCCESS or DDI_FAILURE - */ - -/*ARGSUSED*/ -static int -bscv_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result) -{ - bscv_soft_state_t *ssp; - dev_t dev = (dev_t)arg; - int instance; - int error; - - instance = DEVICETOINSTANCE(dev); - - switch (cmd) { - case DDI_INFO_DEVT2INSTANCE: - *result = (void *)(uintptr_t)instance; - error = DDI_SUCCESS; - break; - - case DDI_INFO_DEVT2DEVINFO: - ssp = ddi_get_soft_state(bscv_statep, instance); - if (ssp == NULL) - return (DDI_FAILURE); - *result = (void *) ssp->dip; - error = DDI_SUCCESS; - break; - - default: - error = DDI_FAILURE; - break; - } - - return (error); -} - -#ifdef __sparc -void -bscv_idi_init() -{ - bscv_idi_mgr.valid_inst = (uint32_t)~0; /* No valid instances */ - bscv_idi_mgr.tbl = bscv_idi_callout_table; - bscv_idi_mgr.errs = 0; - - /* - * Now that all fields are initialized, set the magic flag. This is - * a kind of integrity check for the data structure. - */ - bscv_idi_mgr.magic = BSCV_IDI_CALLOUT_MAGIC; -} - -static void -bscv_idi_clear_err() -{ - ASSERT(bscv_idi_mgr.magic == BSCV_IDI_CALLOUT_MAGIC); - - bscv_idi_mgr.errs = 0; -} - -/* - * function - bscv_idi_err - * description - error messaging service which throttles the number of error - * messages to avoid overflowing storage - * inputs - none - * returns - boolean to indicate whether a message should be reported - * side-effects - updates the error number counter - */ -static boolean_t -bscv_idi_err() -{ - ASSERT(bscv_idi_mgr.magic == BSCV_IDI_CALLOUT_MAGIC); - - bscv_idi_mgr.errs++; - - if (bscv_idi_mgr.errs++ < BSCV_IDI_ERR_MSG_THRESHOLD) - return (B_TRUE); - - return (B_FALSE); -} - -void -bscv_idi_new_instance(dev_info_t *dip) -{ - ASSERT(bscv_idi_mgr.magic == BSCV_IDI_CALLOUT_MAGIC); - - /* - * We don't care how many instances we have, or their value, so long - * as we have at least one valid value. This is so service routines - * can get any required locks via a soft state pointer. - */ - if (bscv_idi_mgr.valid_inst == (uint32_t)~0) { - bscv_idi_mgr.valid_inst = ddi_get_instance(dip); - } -} - -void -bscv_idi_fini() -{ - bscv_idi_mgr.valid_inst = (uint32_t)~0; /* No valid instances */ - bscv_idi_mgr.tbl = NULL; -} -#endif /* __sparc */ - -/* - * function - bscv_attach - * description - this routine is responsible for setting aside memory for the - * driver data structures, initialising the mutexes and creating - * the device minor nodes. Additionally, this routine calls the - * the callback routine. - * inputs - device information structure, DDI_ATTACH command - * outputs - DDI_SUCCESS or DDI_FAILURE - */ - -int -bscv_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - bscv_soft_state_t *ssp; - int instance; - - switch (cmd) { - case DDI_ATTACH: - - instance = ddi_get_instance(dip); - - if (ddi_soft_state_zalloc(bscv_statep, instance) != - DDI_SUCCESS) { - return (DDI_FAILURE); - } - - - ssp = ddi_get_soft_state(bscv_statep, instance); - - ssp->progress = 0; - - ssp->dip = dip; - ssp->instance = instance; - ssp->event_waiting = B_FALSE; - ssp->status_change = B_FALSE; - ssp->nodename_change = B_FALSE; - ssp->cap0 = 0; - ssp->cap1 = 0; - ssp->cap2 = 0; - ssp->prog_mode_only = B_FALSE; - ssp->programming = B_FALSE; - ssp->cssp_prog = B_FALSE; - ssp->task_flags = 0; - ssp->debug = ddi_prop_get_int(DDI_DEV_T_ANY, dip, - DDI_PROP_DONTPASS, "debug", 0); - ssp->majornum = ddi_driver_major(dip); - ssp->minornum = BSCV_INST_TO_MINOR(instance); -#if defined(__i386) || defined(__amd64) - ssp->last_nodename[0] = '\0'; -#endif /* __i386 || __amd64 */ - - /* - * initialise the mutexes - */ - - mutex_init(&ssp->cmd_mutex, NULL, MUTEX_DRIVER, NULL); - - mutex_init(&ssp->task_mu, NULL, MUTEX_DRIVER, NULL); - cv_init(&ssp->task_cv, NULL, CV_DRIVER, NULL); - cv_init(&ssp->task_evnt_cv, NULL, CV_DRIVER, NULL); - mutex_init(&ssp->prog_mu, NULL, MUTEX_DRIVER, NULL); - ssp->progress |= BSCV_LOCKS; - - BSCV_TRACE(ssp, 'A', "bscv_attach", - "bscv_attach: mutexes and condition vars initialised"); - - /* Map in physical communication channels */ - - if (bscv_map_regs(ssp) != DDI_SUCCESS) { - (void) bscv_cleanup(ssp); - return (DDI_FAILURE); - } - ssp->progress |= BSCV_MAPPED_REGS; - - /* Associate logical channels to physical channels */ - - bscv_map_chan_logical_physical(ssp); - - bscv_enter(ssp); - - bscv_leave_programming_mode(ssp, B_FALSE); - - if (bscv_attach_common(ssp) == DDI_FAILURE) { - bscv_exit(ssp); - (void) bscv_cleanup(ssp); - return (DDI_FAILURE); - } - -#ifdef __sparc - /* - * At this point the inter-driver-interface is made available. - * The IDI uses the event thread service which - * bscv_attach_common() sets up. - */ - bscv_idi_new_instance(dip); -#endif /* __sparc */ - - bscv_exit(ssp); - - /* - * now create the minor nodes - */ - if (ddi_create_minor_node(ssp->dip, "lom", S_IFCHR, - BSCV_INST_TO_MINOR(instance), - DDI_PSEUDO, 0) != DDI_SUCCESS) { - (void) bscv_cleanup(ssp); - return (DDI_FAILURE); - } - BSCV_TRACE(ssp, 'A', "bscv_attach", - "bscv_attach: device minor nodes created"); - ssp->progress |= BSCV_NODES; - - if (!ssp->prog_mode_only) - bscv_start_event_daemon(ssp); - -#if defined(__i386) || defined(__amd64) - bscv_watchdog_enable = 1; - bscv_watchdog_available = 1; - watchdog_activated = 0; - bscv_watchdog_timeout_seconds = CLK_WATCHDOG_DEFAULT; - - if (bscv_watchdog_enable && (boothowto & RB_DEBUG)) { - bscv_watchdog_available = 0; - cmn_err(CE_WARN, "bscv: kernel debugger " - "detected: hardware watchdog disabled"); - } - - /* - * Before we enable the watchdog - register the panic - * callback so that we get called to stop the watchdog - * in the case of a panic. - */ - ssp->callb_id = callb_add(bscv_panic_callback, - (void *)ssp, CB_CL_PANIC, ""); - - if (bscv_watchdog_available) { - (void) bscv_set_watchdog_timer(ssp, - CLK_WATCHDOG_DEFAULT); - bscv_enter(ssp); - bscv_setup_watchdog(ssp); /* starts cyclic callback */ - bscv_exit(ssp); - } -#endif /* __i386 || __amd64 */ - ddi_report_dev(dip); - return (DDI_SUCCESS); - default: - return (DDI_FAILURE); - } -} - -/* - * function - bscv_detach - * description - routine that prepares a module to be unloaded. It undoes all - * the work done by the bscv_attach)() routine. This is - * facilitated by the use of the progress indicator - * inputs - device information structure, DDI_DETACH command - * outputs - DDI_SUCCESS or DDI_FAILURE - */ - -/*ARGSUSED*/ -static int -bscv_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - return (DDI_FAILURE); -} - -/* - * quiesce(9E) entry point. - * - * This function is called when the system is single-threaded at high - * PIL with preemption disabled. Therefore, this function must not be - * blocked. - * - * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure. - * DDI_FAILURE indicates an error condition and should almost never happen. - */ -static int -bscv_quiesce(dev_info_t *dip) -{ - bscv_soft_state_t *ssp; - int instance; - - - instance = ddi_get_instance(dip); - ssp = ddi_get_soft_state(bscv_statep, instance); - if (ssp == NULL) { - return (DDI_FAILURE); - } -#ifdef DEBUG - /* Disable tracing, as we are executing at High-Interrupt level */ - bscv_trace_flag = 0; -#endif - /* quiesce the device */ - bscv_full_stop(ssp); - - return (DDI_SUCCESS); -} - -/* - * cb_ops routines - */ - -/* - * function - bscv_open - * description - routine to provide association between user fd and device - * minor number. This routine is necessarily simple since a - * read/write interface is not provided. Additionally, the - * driver does not enforce exclusive access (FEXCL) or - * non-blocking during an open (FNDELAY). Deferred attach is - * supported. - * inputs - device number, flag specifying open type, device type, - * permissions - * outputs - success or failure of operation - */ - -/*ARGSUSED*/ -static int -bscv_open(dev_t *devp, int flag, int otype, cred_t *cred) -{ - bscv_soft_state_t *ssp; - int instance; - - instance = DEVICETOINSTANCE(*devp); - ssp = ddi_get_soft_state(bscv_statep, instance); - if (ssp == NULL) { - return (ENXIO); /* not attached yet */ - } - BSCV_TRACE(ssp, 'O', "bscv_open", "instance 0x%x", instance); - - if (otype != OTYP_CHR) { - return (EINVAL); - } - - return (0); -} - -/* - * function - bscv_close - * description - routine to perform the final close on the device. As per the - * open routine, neither FEXCL or FNDELAY accesses are enforced - * by the driver. - * inputs - device number,flag specifying open type, device type, - * permissions - * outputs - success or failure of operation - */ - -/*ARGSUSED1*/ -static int -bscv_close(dev_t dev, int flag, int otype, cred_t *cred) -{ - bscv_soft_state_t *ssp; - int instance; - - instance = DEVICETOINSTANCE(dev); - ssp = ddi_get_soft_state(bscv_statep, instance); - if (ssp == NULL) { - return (ENXIO); - } - BSCV_TRACE(ssp, 'O', "bscv_close", "instance 0x%x", instance); - - return (0); -} - -static int -bscv_map_regs(bscv_soft_state_t *ssp) -{ - int i; - int retval; - int *props; - unsigned int nelements; - - ASSERT(ssp); - - ssp->nchannels = 0; - - /* - * Work out how many channels are available by looking at the number - * of elements of the regs property array. - */ - retval = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, ssp->dip, - DDI_PROP_DONTPASS, "reg", &props, &nelements); - - /* We don't need props anymore. Free memory if it was allocated */ - if (retval == DDI_PROP_SUCCESS) - ddi_prop_free(props); - - /* Check for sanity of nelements */ - if (retval != DDI_PROP_SUCCESS) { - BSCV_TRACE(ssp, 'A', "bscv_map_regs", "lookup reg returned" - " 0x%x", retval); - goto cleanup_exit; - } else if (nelements % LOMBUS_REGSPEC_SIZE != 0) { - BSCV_TRACE(ssp, 'A', "bscv_map_regs", "nelements %d not" - " a multiple of %d", nelements, LOMBUS_REGSPEC_SIZE); - goto cleanup_exit; - } else if (nelements > BSCV_MAXCHANNELS * LOMBUS_REGSPEC_SIZE) { - BSCV_TRACE(ssp, 'A', "bscv_map_regs", "nelements %d too large" - ", probably a misconfiguration", nelements); - goto cleanup_exit; - } else if (nelements < BSCV_MINCHANNELS * LOMBUS_REGSPEC_SIZE) { - BSCV_TRACE(ssp, 'A', "bscv_map_regs", "nelements %d too small" - ", need to have at least a general and a wdog channel", - nelements); - goto cleanup_exit; - } - - ssp->nchannels = nelements / LOMBUS_REGSPEC_SIZE; - - ssp->attr.devacc_attr_version = DDI_DEVICE_ATTR_V0; - ssp->attr.devacc_attr_endian_flags = DDI_STRUCTURE_LE_ACC; - ssp->attr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; - - for (i = 0; i < ssp->nchannels; i++) { - retval = ddi_regs_map_setup(ssp->dip, i, - (caddr_t *)&ssp->channel[i].regs, - 0, 0, &ssp->attr, &ssp->channel[i].handle); - if (retval != DDI_SUCCESS) { - BSCV_TRACE(ssp, 'A', "bscv_map_regs", "map failure" - " 0x%x on space %d", retval, i); - - /* Rewind all current mappings - avoiding failed one */ - i--; - for (; i >= 0; i--) { - ddi_regs_map_free(&ssp->channel[i].handle); - } - - goto cleanup_exit; - } - } - - return (DDI_SUCCESS); - -cleanup_exit: - /* - * It is important to set nchannels to 0 even if, say, only one of - * the two required handles was mapped. If we cannot achieve our - * minimum config its not safe to do any IO; this keeps our failure - * mode handling simpler. - */ - ssp->nchannels = 0; - return (DDI_FAILURE); -} - -static void -bscv_unmap_regs(bscv_soft_state_t *ssp) -{ - int i; - - ASSERT(ssp); - - for (i = 0; i < ssp->nchannels; i++) { - ddi_regs_map_free(&ssp->channel[i].handle); - } -} - -/* - * Map logical services onto physical XBus channels. - */ -static void -bscv_map_chan_logical_physical(bscv_soft_state_t *ssp) -{ - ASSERT(ssp); - - /* - * We can assert that there will always be at least two channels, - * to allow watchdog pats to be segregated from all other traffic. - */ - chan_general = 0; - chan_wdogpat = 1; - - /* - * By default move all other services onto the generic channel unless - * the hardware supports additional channels. - */ - - chan_cpusig = chan_eeprom = chan_prog = chan_general; - - if (ssp->nchannels > 2) - chan_cpusig = 2; - if (ssp->nchannels > 3) - chan_eeprom = 3; - if (ssp->nchannels > 4) - chan_prog = 4; -} - - -/* - * function - bscv_full_stop - * description - gracefully shut the lom down during panic or reboot. - * Disables the watchdog and sets up serial event reporting. - * inputs - soft state pointer - * outputs - none - */ -void -bscv_full_stop(bscv_soft_state_t *ssp) -{ - uint8_t bits2set = 0; - uint8_t bits2clear = 0; - int obtained_lock; - - BSCV_TRACE(ssp, 'W', "bscv_full_stop", - "turning off watchdog"); - - /* - * Obtain the softstate lock only if it is not already owned, - * as this function can be called from a High-level interrupt - * context. As a result, our thread cannot sleep. - * At end of function, our thread releases the lock only if - * it acquired the lock. - */ - obtained_lock = (bscv_tryenter(ssp) != 0); - -#if defined(__i386) || defined(__amd64) - if (ddi_in_panic()) { - bscv_inform_bsc(ssp, BSC_INFORM_PANIC); - } else { - bscv_inform_bsc(ssp, BSC_INFORM_OFFLINE); - } -#endif /* __i386 || __amd64 */ - - /* set serial event reporting */ - switch (ssp->serial_reporting) { - case LOM_SER_EVENTS_ON: - case LOM_SER_EVENTS_DEF: - /* Make sure serial event reporting is on */ - bits2clear = EBUS_ALARM_NOEVENTS; - break; - case LOM_SER_EVENTS_OFF: - /* Make sure serial event reporting is on */ - bits2set = EBUS_ALARM_NOEVENTS; - break; - default: - break; - } - bscv_setclear8_volatile(ssp, chan_general, - EBUS_IDX_ALARM, bits2set, bits2clear); - - /* Do not free the lock if our thread did not obtain it. */ - if (obtained_lock != 0) { - bscv_exit(ssp); - } -} - -/* - * LOM I/O routines. - * - * locking - * - * Two sets of routines are provided: - * normal - must be called after acquiring an appropriate lock. - * locked - perform all the locking required and return any error - * code in the supplied 'res' argument. If there is no - * error 'res' is not changed. - * The locked routines are designed for use in ioctl commands where - * only a single operation needs to be performed and the overhead of - * locking and result checking adds significantly to code complexity. - * - * locking primitives - * - * bscv_enter() - acquires an I/O lock for the calling thread. - * bscv_tryenter() - conditionally acquires an I/O lock for calling thread. - * bscv_exit() - releases an I/O lock acquired by bscv_enter(). - * bscv_held() - used to assert ownership of an I/O lock. - * - * normal I/O routines - * - * Note bscv_{put|get}{16|32} routines are big-endian. This assumes that - * the firmware works that way too. - * - * bscv_put8(), bscv_put16, bscv_put32 - write values to the LOM - * and handle any retries if necessary. - * 16 and 32 bit values are big-endian. - * bscv_get8(), bscv_get16, bscv_get32 - read values from the LOM - * and handle any retries if necessary. - * 16 and 32 bit values are big-endian. - * bscv_setclear8() - set or clear the specified bits in the register - * at the supplied address. - * bscv_setclear8_volatile() - set or clear the specified bits in the - * register at the supplied address. If the lom reports - * that the registers has changed since the last read - * re-read and apply the set or clear to the new bits. - * bscv_get8_cached() - Return a cached register value (addr < 0x80). - * Does not access the hardware. A read of the hardware - * automatically updates this cache. - * - * locked I/O routines - * - * bscv_get8_locked(), bscv_rep_get8_locked(). - * - * Call the indicated function from above, but wrapping it with - * bscv_enter()/bscv_exit(). - * - * - * Fault management - * - * LOM communications fault are grouped into three categories: - * 1) Faulty - the LOM is not responding and no attempt to communicate - * with it should be made. - * 2) Transient fault - something which might recover after a retry - * but which doesn't affect our ability to perform other - * commands. - * 3) Command error - an inappropriate command was executed. A retry - * will not fix it but the command failed. - * - * The current implementation of the bscv driver is not very good at - * noticing command errors due to the structure of the original code - * that it is based on. It is possible to extend the driver to do this - * and would probably involve having a concept of a "session error" - * which is less severe than a fault but means that a sequence of - * commands had some fault which cannot be recovered. - * - * - * faults - * - * bscv_faulty() - returns B_TRUE if the LOM (communications) have been - * declared faulty. - * bscv_clear_fault() - marks the LOM as not faulty. - * bscv_set_fault() - marks the LOM as being faulty. - * - * bscv_clear_fault and bscv_set_fault should generally not be called - * directly. - * - * command errors/transient faults - * - * bscv_retcode() - returns the actual error code of the last operation. - * bscv_should_retry() - determines if last operation may suceed if - * retried. - * bscv_locked_result() - Set the result of a locked register access. - * - * low level I/O primitives - * - * These are generally not called directly. These perform a single - * access to the LOM device. They do not handle retries. - * - * bscv_put8_once() - * bscv_get8_once() - * bscv_probe() - perform a probe (NOP) operation to check out lom comms. - * bscv_resync_comms() - resynchronise communications after a transient fault. - */ - -static void -bscv_enter(bscv_soft_state_t *ssp) -{ - BSCV_TRACE(ssp, '@', "bscv_enter", ""); - mutex_enter(&ssp->cmd_mutex); - ssp->had_session_error = B_FALSE; -} - -static int -bscv_tryenter(bscv_soft_state_t *ssp) -{ - int rv; - - BSCV_TRACE(ssp, '@', "bscv_tryenter", ""); - if ((rv = mutex_tryenter(&ssp->cmd_mutex)) != 0) { - ssp->had_session_error = B_FALSE; - } - return (rv); -} - -static void -bscv_exit(bscv_soft_state_t *ssp) -{ - mutex_exit(&ssp->cmd_mutex); - BSCV_TRACE(ssp, '@', "bscv_exit", ""); -} - -#ifdef DEBUG -static int -bscv_held(bscv_soft_state_t *ssp) -{ - return (mutex_owned(&ssp->cmd_mutex)); -} -#endif /* DEBUG */ - -static void -bscv_put8(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint8_t val) -{ - boolean_t needretry; - int num_failures; - - ASSERT(bscv_held(ssp)); - - if (bscv_faulty(ssp)) { - return; - } - - BSCV_TRACE(ssp, '@', "bscv_put8", - "addr 0x%x.%02x <= 0x%02x", addr >> 8, addr & 0xff, val); - - for (num_failures = 0; - num_failures < BSC_FAILURE_RETRY_LIMIT; - num_failures++) { - bscv_put8_once(ssp, chan, addr, val); - needretry = bscv_should_retry(ssp); - if (!needretry) { - break; - } - } - if (ssp->command_error != 0) { - ssp->had_session_error = B_TRUE; - } - - if (needretry) { - /* Failure - we ran out of retries */ - cmn_err(CE_WARN, "bscv_put8: addr 0x%x.%02x retried " - "write %d times, giving up", - addr >> 8, addr & 0xff, num_failures); - bscv_set_fault(ssp); - } else if (num_failures > 0) { - BSCV_TRACE(ssp, 'R', "bscv_put8", - "addr 0x%x.%02x retried write %d times, succeeded", - addr >> 8, addr & 0xff, num_failures); - } -} - -static void -bscv_put16(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint16_t val) -{ - ASSERT(bscv_held(ssp)); - BSCV_TRACE(ssp, '@', "bscv_put16", - "addr 0x%x.%02x <= %04x", addr >> 8, addr & 0xff, val); - bscv_put8(ssp, chan, addr, val >> 8); - bscv_put8(ssp, chan, addr + 1, val & 0xff); -} - -static void -bscv_put32(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint32_t val) -{ - ASSERT(bscv_held(ssp)); - BSCV_TRACE(ssp, '@', "bscv_put32", - "addr 0x%x.%02x <= %08x", addr >> 8, addr & 0xff, val); - bscv_put8(ssp, chan, addr, (val >> 24) & 0xff); - bscv_put8(ssp, chan, addr + 1, (val >> 16) & 0xff); - bscv_put8(ssp, chan, addr + 2, (val >> 8) & 0xff); - bscv_put8(ssp, chan, addr + 3, val & 0xff); -} - -static uint8_t -bscv_get8(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr) -{ - uint8_t retval; - boolean_t needretry; - int num_failures; - - ASSERT(bscv_held(ssp)); - - if (bscv_faulty(ssp)) { - return (0); - } - - for (num_failures = 0; - num_failures < BSC_FAILURE_RETRY_LIMIT; - num_failures++) { - retval = bscv_get8_once(ssp, chan, addr); - needretry = bscv_should_retry(ssp); - if (!needretry) { - break; - } - } - if (ssp->command_error != 0) { - ssp->had_session_error = B_TRUE; - } - - if (needretry) { - /* Failure */ - cmn_err(CE_WARN, "bscv_get8: addr 0x%x.%02x retried " - "read %d times, giving up", - addr >> 8, addr & 0xff, num_failures); - bscv_set_fault(ssp); - } else if (num_failures > 0) { - BSCV_TRACE(ssp, 'R', "bscv_get8", - "addr 0x%x.%02x retried read %d times, succeeded", - addr >> 8, addr & 0xff, num_failures); - } - - BSCV_TRACE(ssp, '@', "bscv_get8", - "addr 0x%x.%02x => %02x", addr >> 8, addr & 0xff, retval); - return (retval); -} - -static uint16_t -bscv_get16(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr) -{ - uint16_t retval; - - ASSERT(bscv_held(ssp)); - - retval = bscv_get8(ssp, chan, addr) << 8; - retval |= bscv_get8(ssp, chan, addr + 1); - - BSCV_TRACE(ssp, '@', "bscv_get16", - "addr 0x%x.%02x => %04x", addr >> 8, addr & 0xff, retval); - return (retval); -} - -static uint32_t -bscv_get32(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr) -{ - uint32_t retval; - - ASSERT(bscv_held(ssp)); - - retval = bscv_get8(ssp, chan, addr) << 24; - retval |= bscv_get8(ssp, chan, addr + 1) << 16; - retval |= bscv_get8(ssp, chan, addr + 2) << 8; - retval |= bscv_get8(ssp, chan, addr + 3); - - BSCV_TRACE(ssp, '@', "bscv_get32", - "addr 0x%x.%02x => %08x", addr >> 8, addr & 0xff, retval); - return (retval); -} - -static void -bscv_setclear8(bscv_soft_state_t *ssp, int chan, - bscv_addr_t addr, uint8_t set, uint8_t clear) -{ - uint8_t val; - - ASSERT(bscv_held(ssp)); - ASSERT(addr < BSC_ADDR_CACHE_LIMIT); - - val = ssp->lom_regs[addr] | set; - val &= ~clear; - - BSCV_TRACE(ssp, '@', "bscv_setclear8", - "addr 0x%x.%02x, set %02x, clear %02x => %02x", - addr >> 8, addr & 0xff, - set, clear, val); - - bscv_put8(ssp, chan, addr, val); -} - -static void -bscv_setclear8_volatile(bscv_soft_state_t *ssp, int chan, - bscv_addr_t addr, uint8_t set, uint8_t clear) -{ - uint8_t val; - boolean_t needretry; - int num_failures; - - ASSERT(bscv_held(ssp)); - ASSERT(addr < BSC_ADDR_CACHE_LIMIT); - - if (bscv_faulty(ssp)) { - return; - } - - BSCV_TRACE(ssp, '@', "bscv_setclear8_volatile", - "addr 0x%x.%02x => set %02x clear %02x", - addr >> 8, addr & 0xff, set, clear); - - val = bscv_get8_cached(ssp, addr); - for (num_failures = 0; - num_failures < BSC_FAILURE_RETRY_LIMIT; - num_failures++) { - val |= set; - val &= ~clear; - bscv_put8_once(ssp, chan, addr, val); - if (ssp->command_error == EBUS_ERROR_STALEDATA) { - /* Re-read the stale register from the lom */ - val = bscv_get8_once(ssp, chan, addr); - needretry = 1; - } else { - needretry = bscv_should_retry(ssp); - if (!needretry) { - break; - } - } - } - if (ssp->command_error != 0) { - ssp->had_session_error = B_TRUE; - } - - if (needretry) { - /* Failure */ - cmn_err(CE_WARN, "bscv_setclear8_volatile: addr 0x%x.%02x " - "retried write %d times, giving up", - addr >> 8, addr & 0xff, num_failures); - if (ssp->command_error != EBUS_ERROR_STALEDATA) { - bscv_set_fault(ssp); - } - } else if (num_failures > 0) { - BSCV_TRACE(ssp, 'R', "bscv_setclear8_volatile", - "addr 0x%x.%02x retried write %d times, succeeded", - addr >> 8, addr & 0xff, num_failures); - } -} - -static void -bscv_rep_rw8(bscv_soft_state_t *ssp, int chan, uint8_t *host_addr, - bscv_addr_t dev_addr, size_t repcount, uint_t flags, - boolean_t is_write) -{ - size_t inc; - - ASSERT(bscv_held(ssp)); - - inc = (flags & DDI_DEV_AUTOINCR) ? 1 : 0; - for (; repcount--; dev_addr += inc) { - if (flags & DDI_DEV_AUTOINCR) { - if (is_write) { - bscv_put8(ssp, chan, dev_addr, *host_addr++); - } else { - *host_addr++ = bscv_get8(ssp, chan, dev_addr); - } - } else { - if (is_write) { - bscv_put8_once(ssp, chan, - dev_addr, *host_addr++); - } else { - *host_addr++ = bscv_get8_once(ssp, chan, - dev_addr); - } - /* We need this because _once routines don't do it */ - if (ssp->command_error != 0) { - ssp->had_session_error = B_TRUE; - } - } - if (bscv_faulty(ssp) || bscv_session_error(ssp)) { - /* - * No retry here. If we were AUTOINCR then get/put - * will have retried. For NO_AUTOINCR we cannot retry - * because the data would be corrupted. - */ - break; - } - } -} - -static uint8_t -bscv_get8_cached(bscv_soft_state_t *ssp, bscv_addr_t addr) -{ - ASSERT(addr < BSC_ADDR_CACHE_LIMIT); - /* Can be called with or without the lock held */ - - return (ssp->lom_regs[addr]); -} - -static uint8_t -bscv_get8_locked(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, int *res) -{ - uint8_t retval; - - ASSERT(addr < BSC_ADDR_CACHE_LIMIT); - bscv_enter(ssp); - retval = bscv_get8(ssp, chan, addr); - bscv_locked_result(ssp, res); - bscv_exit(ssp); - BSCV_TRACE(ssp, '@', "bscv_get8_locked", - "addr 0x%x.%02x => %02x", addr >> 8, addr & 0xff, retval); - return (retval); -} - -static void -bscv_rep_get8_locked(bscv_soft_state_t *ssp, int chan, uint8_t *host_addr, - bscv_addr_t dev_addr, size_t repcount, uint_t flags, int *res) -{ - bscv_enter(ssp); - bscv_rep_rw8(ssp, chan, host_addr, dev_addr, repcount, - flags, B_FALSE /* read */); - bscv_locked_result(ssp, res); - bscv_exit(ssp); -} - -static boolean_t -bscv_faulty(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - return (ssp->had_fault); -} - -static void -bscv_clear_fault(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - BSCV_TRACE(ssp, 'J', "bscv_clear_fault", "clearing fault flag"); - ssp->had_fault = B_FALSE; - ssp->had_session_error = B_FALSE; -} - -static void -bscv_set_fault(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - BSCV_TRACE(ssp, 'J', "bscv_set_fault", "setting fault flag"); - ssp->had_fault = B_TRUE; -} - -static boolean_t -bscv_session_error(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - return (ssp->had_session_error); -} - -static int -bscv_retcode(bscv_soft_state_t *ssp) -{ - BSCV_TRACE(ssp, '@', "bscv_retcode", - "code 0x%x", ssp->command_error); - return (ssp->command_error); -} - -static int -bscv_should_retry(bscv_soft_state_t *ssp) -{ - if ((ssp->command_error == EBUS_ERROR_DEVICEFAIL) || - (ssp->command_error >= LOMBUS_ERR_BASE)) { - /* This command is due to an I/O fault - retry might fix */ - return (1); - } else { - /* - * The command itself was bad - there is no point in fixing - * Note. Whatever happens we should know that if we were - * doing EBUS_IDX_SELFTEST0..EBUS_IDX_SELFTEST7 and we - * had 0x80 set then this is a test error not a retry - * error. - */ - return (0); - } -} - -static void -bscv_locked_result(bscv_soft_state_t *ssp, int *res) -{ - if (bscv_faulty(ssp) || (bscv_retcode(ssp) != 0)) { - *res = EIO; - } -} - -static void -bscv_put8_once(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint8_t val) -{ - uint32_t fault; - - ASSERT(bscv_held(ssp)); - - ssp->command_error = 0; - - if (bscv_faulty(ssp)) { - /* Bail out things are not working */ - return; - } else if (ssp->nchannels == 0) { - /* Didn't manage to map handles so ddi_{get,put}* broken */ - BSCV_TRACE(ssp, '@', "bscv_put8_once", - "nchannels is 0x0 so cannot do IO"); - return; - } - - /* Clear any pending fault */ - ddi_put32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG), 0); - - /* Do the access and get fault code - may take a long time */ - ddi_put8(ssp->channel[chan].handle, - &ssp->channel[chan].regs[addr], val); - fault = ddi_get32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG)); - - ssp->command_error = fault; - - if (fault == 0) { - /* Things were ok - update cache entry */ - if (addr < BSC_ADDR_CACHE_LIMIT) { - /* Store cacheable entries */ - ssp->lom_regs[addr] = val; - } - } else if (fault >= LOMBUS_ERR_BASE) { - /* lombus problem - do a resync session */ - cmn_err(CE_WARN, "!bscv_put8_once: Had comms fault " - "for address 0x%x.%02x - data 0x%x, fault 0x%x", - addr >> 8, addr & 0xff, val, fault); - /* Attempt to resync with the lom */ - bscv_resync_comms(ssp, chan); - /* - * Note: we do not set fault status here. That - * is done if our caller decides to give up talking to - * the lom. The observant might notice that this means - * that if we mend things on the last attempt we still - * get the fault set - we just live with that! - */ - } - - BSCV_TRACE(ssp, '@', "bscv_put8_once", - "addr 0x%x.%02x <= 0x%02x", addr >> 8, addr & 0xff, val); -} - -static uint8_t -bscv_get8_once(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr) -{ - uint8_t val; - uint32_t fault; - - ASSERT(bscv_held(ssp)); - - ssp->command_error = 0; - - if (bscv_faulty(ssp)) { - /* Bail out things are not working */ - return (0xff); - } else if (ssp->nchannels == 0) { - /* Didn't manage to map handles so ddi_{get,put}* broken */ - BSCV_TRACE(ssp, '@', "bscv_get8_once", - "nchannels is 0x0 so cannot do IO"); - return (0xff); - } - - /* Clear any pending fault */ - ddi_put32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG), 0); - - /* Do the access and get fault code - may take a long time */ - val = ddi_get8(ssp->channel[chan].handle, - &ssp->channel[chan].regs[addr]); - fault = ddi_get32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG)); - ssp->command_error = fault; - - if (fault >= LOMBUS_ERR_BASE) { - /* lombus problem - do a resync session */ - cmn_err(CE_WARN, "!bscv_get8_once: Had comms fault " - "for address 0x%x.%02x - data 0x%x, fault 0x%x", - addr >> 8, addr & 0xff, val, fault); - /* Attempt to resync with the lom */ - bscv_resync_comms(ssp, chan); - /* - * Note: we do not set fault status here. That - * is done if our caller decides to give up talking to - * the lom. The observant might notice that this means - * that if we mend things on the last attempt we still - * get the fault set - we just live with that! - */ - } - /* - * FIXME - should report error if you get - * EBUS_ERROR_DEVICEFAIL reported from the BSC. That gets - * logged as a failure in bscv_should_retry and may contribute - * to a permanent failure. Reference issues seen by Mitac. - */ - - if (!bscv_faulty(ssp)) { - if (addr < BSC_ADDR_CACHE_LIMIT) { - /* Store cacheable entries */ - ssp->lom_regs[addr] = val; - } - } - - BSCV_TRACE(ssp, '@', "bscv_get8_once", - "addr 0x%x.%02x => 0x%02x", addr >> 8, addr & 0xff, val); - return (val); -} - -static uint32_t -bscv_probe(bscv_soft_state_t *ssp, int chan, uint32_t *fault) -{ - uint32_t async_reg; - - if (ssp->nchannels == 0) { - /* - * Failed to map handles, so cannot do any IO. Set the - * fault indicator and return a dummy value. - */ - BSCV_TRACE(ssp, '@', "bscv_probe", - "nchannels is 0x0 so cannot do any IO"); - *fault = LOMBUS_ERR_REG_NUM; - return ((~(int8_t)0)); - } - - /* Clear faults */ - ddi_put32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG), 0); - /* Probe and Check faults */ - *fault = ddi_get32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_PROBE_REG)); - /* Read status */ - async_reg = ddi_get32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_ASYNC_REG)); - - BSCV_TRACE(ssp, '@', "bscv_probe", - "async status 0x%x, fault 0x%x", async_reg, *fault); - return (async_reg); -} - -static void -bscv_resync_comms(bscv_soft_state_t *ssp, int chan) -{ - int try; - uint32_t command_error = ssp->command_error; - uint32_t fault = 0; - - if (ssp->nchannels == 0) { - /* - * Didn't manage to map handles so ddi_{get,put}* broken. - * Therefore, there is no way to resync comms. - */ - BSCV_TRACE(ssp, '@', "bscv_resync_comms", - "nchannels is 0x0 so not possible to resync comms"); - return; - } - if (command_error >= LOMBUS_ERR_BASE && - command_error != LOMBUS_ERR_REG_NUM && - command_error != LOMBUS_ERR_REG_SIZE && - command_error != LOMBUS_ERR_TIMEOUT) { - /* Resync here to make sure that the lom is talking */ - cmn_err(CE_WARN, "!bscv_resync_comms: " - "Attempting comms resync after comms fault 0x%x", - command_error); - for (try = 1; try <= 8; try++) { - /* Probe */ - fault = ddi_get32(ssp->channel[chan].handle, - (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, - LOMBUS_PROBE_REG)); - - if (fault == 0) { - break; - } else { - cmn_err(CE_WARN, "!bscv_resync_comms: " - "comms resync (probing) - try 0x%x " - "had fault 0x%x", try, fault); - } - } - if (fault != 0) { - cmn_err(CE_WARN, "!bscv_resync_comms: " - "Failed to resync comms - giving up"); - ssp->bad_resync++; - } else { - cmn_err(CE_WARN, "!bscv_resync_comms: " - "resync comms after 0x%x tries", try); - ssp->bad_resync = 0; - } - } - -} - - -/* - * LOMLite configuration/event eeprom access routines - * - * bscv_window_setup() - Read/Sanity check the eeprom parameters. - * This must be called prior to calling bscv_eerw(). - * bscv_eerw() - Read/write data from/to the eeprom. - */ - -/* - * function - bscv_window_setup - * description - this routine reads the eeprom parameters and sanity - * checks them to ensure that the lom is talking sense. - * inputs - soft state ptr - * outputs - B_TRUE if the eeprom is ok, B_FALSE if the eeprom is not OK. - */ -static boolean_t -bscv_window_setup(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - - if (ssp->eeinfo_valid) { - /* Already have good cached values */ - return (ssp->eeinfo_valid); - } - ssp->eeprom_size = - bscv_get8(ssp, chan_general, EBUS_IDX_EEPROM_SIZE_KB) * 1024; - ssp->eventlog_start = bscv_get16(ssp, chan_general, - EBUS_IDX_LOG_START_HI); - - /* - * The log does not run to the end of the EEPROM because it is a - * logical partition. The last 8K partition is reserved for FRUID - * usage. - */ - ssp->eventlog_size = EBUS_LOG_END - ssp->eventlog_start; - - BSCV_TRACE(ssp, 'I', "bscv_window_setup", "eeprom size 0x%x log_start" - " 0x%x log_size 0x%x", ssp->eeprom_size, ssp->eventlog_start, - ssp->eventlog_size); - - if (bscv_faulty(ssp) || bscv_session_error(ssp)) { - ssp->eeinfo_valid = B_FALSE; - } else if ((ssp->eeprom_size == 0) || - (ssp->eventlog_start >= ssp->eeprom_size)) { - /* Sanity check values */ - cmn_err(CE_WARN, - "!bscv_window_setup: read invalid eeprom parameters"); - ssp->eeinfo_valid = B_FALSE; - } else { - ssp->eeinfo_valid = B_TRUE; - } - - BSCV_TRACE(ssp, 'I', "bscv_window_setup", "returning eeinfo_valid %s", - ssp->eeinfo_valid ? "true" : "false"); - return (ssp->eeinfo_valid); -} - -/* - * function - bscv_eerw - * description - this routine reads/write data from/to the eeprom. - * It takes care of setting the window on the eeprom correctly. - * inputs - soft state ptr, eeprom offset, data buffer, size, read/write - * outputs - B_TRUE if the eeprom is ok, B_FALSE if the eeprom is not OK. - */ -static int -bscv_eerw(bscv_soft_state_t *ssp, uint32_t eeoffset, uint8_t *buf, - unsigned size, boolean_t is_write) -{ - uint32_t blk_addr = eeoffset; - unsigned remaining = size; - uint8_t page_idx; - uint8_t this_page; - uint8_t blk_size; - int res = 0; - - while (remaining > 0) { - page_idx = blk_addr & 0xff; - if ((page_idx + remaining) > 0x100) { - blk_size = 0x100 - page_idx; - } else { - blk_size = remaining; - } - - /* Select correct eeprom page */ - this_page = blk_addr >> 8; - bscv_put8(ssp, chan_eeprom, EBUS_IDX_EEPROM_PAGESEL, this_page); - - BSCV_TRACE(ssp, 'M', "lom_eerw", - "%s data @0x%x.%02x, size 0x%x, 0x%x bytes remaining", - is_write ? "writing" : "reading", - this_page, page_idx, blk_size, remaining - blk_size); - - bscv_rep_rw8(ssp, chan_eeprom, - buf, BSCVA(EBUS_CMD_SPACE_EEPROM, page_idx), - blk_size, DDI_DEV_AUTOINCR, is_write); - - if (bscv_faulty(ssp) || bscv_session_error(ssp)) { - res = EIO; - break; - } - - remaining -= blk_size; - blk_addr += blk_size; - buf += blk_size; - } - - return (res); -} - -static boolean_t -bscv_is_null_event(bscv_soft_state_t *ssp, lom_event_t *e) -{ - ASSERT(e != NULL); - - if (EVENT_DECODE_SUBSYS(e->ev_subsys) == EVENT_SUBSYS_NONE && - e->ev_event == EVENT_NONE) { - /* - * This marks a NULL event. - */ - BSCV_TRACE(ssp, 'E', "bscv_is_null_event", - "EVENT_SUBSYS_NONE/EVENT_NONE null event"); - return (B_TRUE); - } else if (e->ev_subsys == 0xff && e->ev_event == 0xff) { - /* - * Under some circumstances, we've seen all 1s to represent - * a manually cleared event log at the BSC prompt. Only - * a test/diagnosis environment is likely to show this. - */ - BSCV_TRACE(ssp, 'E', "bscv_is_null_event", "0xffff null event"); - return (B_TRUE); - } else { - /* - * Not a NULL event. - */ - BSCV_TRACE(ssp, 'E', "bscv_is_null_event", "returning False"); - return (B_FALSE); - } -} - -/* - * ********************************************************************* - * IOCTL Processing - * ********************************************************************* - */ - -/* - * function - bscv_ioctl - * description - routine that acts as a high level manager for ioctls. It - * calls the appropriate handler for ioctls on the alarm:mon and - * alarm:ctl minor nodes respectively - * - * Unsupported ioctls (now deprecated) - * LOMIOCALCTL - * LOMIOCALSTATE - * LOMIOCCLEARLOG - * LOMIOCCTL - * LOMIOCCTL2 - * LOMIOCDAEMON - * LOMIOCDMON - * LOMIOCDOGCTL, TSIOCDOGCTL - * LOMIOCDOGPAT, TSIOCDOGPAT - * LOMIOCDOGTIME, TSIOCDOGTIME - * LOMIOCEVENTLOG - * LOMIOCEVNT - * LOMIOCGETMASK - * LOMIOCMPROG - * LOMIOCNBMON, TSIOCNBMON - * LOMIOCSLEEP - * LOMIOCUNLOCK, TSIOCUNLOCK - * LOMIOCWTMON, TSIOCWTMON - * - * Supported ioctls - * LOMIOCDOGSTATE, TSIOCDOGSTATE - * LOMIOCPROG - * LOMIOCPSUSTATE - * LOMIOCFANSTATE - * LOMIOCFLEDSTATE - * LOMIOCINFO - * LOMIOCMREAD - * LOMIOCVOLTS - * LOMIOCSTATS - * LOMIOCTEMP - * LOMIOCCONS - * LOMIOCEVENTLOG2 - * LOMIOCINFO2 - * LOMIOCTEST - * LOMIOCMPROG2 - * LOMIOCMREAD2 - * - * inputs - device number, command, user space arg, filemode, user - * credentials, return value - * outputs - the return value propagated back by the lower level routines. - */ - -/*ARGSUSED*/ -static int -bscv_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred, int *rvalp) -{ - bscv_soft_state_t *ssp; - int instance; - int res = 0; - - instance = DEVICETOINSTANCE(dev); - ssp = ddi_get_soft_state(bscv_statep, instance); - if (ssp == NULL) { - return (ENXIO); - } - - /* - * The Combined Switch and Service Processor takes care of configuration - * and control. The CSSP tells the BSC chip about it; therefore the - * bscv driver doesn't send such configuration and control to the BSC. - * Additionally Watchdog configuration is no longer done from userland - * lom. - */ - switch (cmd) { - case LOMIOCALCTL: - case LOMIOCALSTATE: - case LOMIOCCLEARLOG: - case LOMIOCCTL: - case LOMIOCCTL2: - case LOMIOCDAEMON: - case LOMIOCDMON: - case LOMIOCDOGCTL: - case LOMIOCDOGPAT: - case LOMIOCDOGTIME: - case LOMIOCEVENTLOG: - case LOMIOCEVNT: - case LOMIOCGETMASK: - case LOMIOCMPROG: - case LOMIOCNBMON: - case LOMIOCSLEEP: - case LOMIOCUNLOCK: - case LOMIOCWTMON: - return (ENOTSUP); - } - - /* - * set the default result. - */ - - *rvalp = 0; - - if (ssp->cssp_prog) { - return (ENXIO); - } else if ((ssp->prog_mode_only || ssp->programming) && - cmd != LOMIOCPROG) { - return (ENXIO); - } - - /* - * Check that the caller has appropriate access permissions - * (FWRITE set in mode) for those ioctls which change lom - * state - */ - if (!(mode & FWRITE)) { - switch (cmd) { - case LOMIOCMPROG2: - case LOMIOCMREAD2: - case LOMIOCPROG: - case LOMIOCTEST: - return (EACCES); - /* NOTREACHED */ - default: - /* Does not require write access */ - break; - } - } - - switch (cmd) { - - case LOMIOCDOGSTATE: - res = bscv_ioc_dogstate(ssp, arg, mode); - break; - - case LOMIOCPROG: - res = bscv_prog(ssp, arg, mode); - break; - - case LOMIOCPSUSTATE: - res = bscv_ioc_psustate(ssp, arg, mode); - break; - - case LOMIOCFANSTATE: - res = bscv_ioc_fanstate(ssp, arg, mode); - break; - - case LOMIOCFLEDSTATE: - res = bscv_ioc_fledstate(ssp, arg, mode); - break; - - case LOMIOCLEDSTATE: - res = bscv_ioc_ledstate(ssp, arg, mode); - break; - - case LOMIOCINFO: - res = bscv_ioc_info(ssp, arg, mode); - break; - - case LOMIOCMREAD: - res = bscv_ioc_mread(ssp, arg, mode); - break; - - case LOMIOCVOLTS: - res = bscv_ioc_volts(ssp, arg, mode); - break; - - case LOMIOCSTATS: - res = bscv_ioc_stats(ssp, arg, mode); - break; - - case LOMIOCTEMP: - res = bscv_ioc_temp(ssp, arg, mode); - break; - - case LOMIOCCONS: - res = bscv_ioc_cons(ssp, arg, mode); - break; - - case LOMIOCEVENTLOG2: - res = bscv_ioc_eventlog2(ssp, arg, mode); - break; - - case LOMIOCINFO2: - res = bscv_ioc_info2(ssp, arg, mode); - break; - - case LOMIOCTEST: - res = bscv_ioc_test(ssp, arg, mode); - break; - - case LOMIOCMPROG2: - res = bscv_ioc_mprog2(ssp, arg, mode); - break; - - case LOMIOCMREAD2: - res = bscv_ioc_mread2(ssp, arg, mode); - break; - - default: - BSCV_TRACE(ssp, 'I', "bscv_ioctl", "Invalid IOCTL 0x%x", cmd); - res = EINVAL; - } - return (res); -} - -/* - * LOMIOCDOGSTATE - * TSIOCDOGSTATE - indicate whether the alarm watchdog and reset - * circuitry is enabled or not. - */ -static int -bscv_ioc_dogstate(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_dogstate_t dogstate; - uint8_t dogval; - int res = 0; - - dogval = bscv_get8_locked(ssp, chan_general, EBUS_IDX_WDOG_CTRL, &res); - dogstate.dog_enable = (dogval & EBUS_WDOG_ENABLE) ? 1 : 0; - dogstate.reset_enable = (dogval & EBUS_WDOG_RST) ? 1 : 0; - dogstate.dog_timeout = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_WDOG_TIME, &res); - - if ((res == 0) && - (ddi_copyout((caddr_t)&dogstate, - (caddr_t)arg, sizeof (dogstate), mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCPSUSTATE - returns full information for 4 PSUs. All this - * information is available from two bytes of LOMlite RAM, but if - * on the first read it is noticed that two or more of the PSUs are - * not present only 1 byte will be read subsequently. - */ -static int -bscv_ioc_psustate(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_psudata_t psudata; - uint8_t psustat; - int i; - int res = 0; - - for (i = 0; i < MAX_PSUS; i++) { - psustat = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_PSU1_STAT + i, &res); - psudata.fitted[i] = psustat & EBUS_PSU_PRESENT; - psudata.output[i] = psustat & EBUS_PSU_OUTPUT; - psudata.supplyb[i] = psustat & EBUS_PSU_INPUTB; - psudata.supplya[i] = psustat & EBUS_PSU_INPUTA; - psudata.standby[i] = psustat & EBUS_PSU_STANDBY; - } - - if (ddi_copyout((caddr_t)&psudata, (caddr_t)arg, sizeof (psudata), - mode) < 0) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCFANSTATE - returns full information including speed for 4 - * fans and the minimum and maximum operating speeds for each fan as - * stored in the READ ONLY EEPROM data. As this EEPROM data is set - * at manufacture time, this data should only be read by the driver - * once and stored locally. - */ -static int -bscv_ioc_fanstate(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_fandata_t fandata; - int numfans; - int i; - int res = 0; - - bzero(&fandata, sizeof (lom_fandata_t)); - numfans = EBUS_CONFIG_NFAN_DEC(bscv_get8_locked(ssp, - chan_general, EBUS_IDX_CONFIG, &res)); - for (i = 0; (i < numfans) && (res == 0); i++) { - if (ssp->fanspeed[i] != LOM_FAN_NOT_PRESENT) { - fandata.fitted[i] = 1; - fandata.speed[i] = ssp->fanspeed[i]; - fandata.minspeed[i] = bscv_get8_cached(ssp, - EBUS_IDX_FAN1_LOW + i); - } - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&fandata, (caddr_t)arg, sizeof (fandata), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCFLEDSTATE - returns the state of the fault LED - */ -static int -bscv_ioc_fledstate(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_fled_info_t fled_info; - uint8_t fledstate; - int res = 0; - - fledstate = bscv_get8_locked(ssp, chan_general, EBUS_IDX_ALARM, &res); - - /* Decode of 0x0F is off and 0x00-0x07 is on. */ - if (EBUS_ALARM_LED_DEC(fledstate) == 0x0F) { - fled_info.on = 0; - } else { - /* has +1 here - not 2 as in the info ioctl */ - fled_info.on = EBUS_ALARM_LED_DEC(fledstate) + 1; - } - if ((res == 0) && - (ddi_copyout((caddr_t)&fled_info, (caddr_t)arg, - sizeof (fled_info), mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCLEDSTATE - returns the state of the requested LED - */ -static int -bscv_ioc_ledstate(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_led_state_t led_state; - int fw_led_state; - int res = 0; - - /* copy in arguments supplied */ - if (ddi_copyin((caddr_t)arg, (caddr_t)&led_state, - sizeof (lom_led_state_t), mode) < 0) { - return (EFAULT); - } - - /* - * check if led index is -1, if so set it to max value for - * this implementation. - */ - if (led_state.index == -1) { - led_state.index = MAX_LED_ID; - } - - /* is the index in a valid range */ - if ((led_state.index > MAX_LED_ID) || (led_state.index < 0)) { - led_state.state = LOM_LED_OUTOFRANGE; - } else { - /* read the relevant led info */ - fw_led_state = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_LED1_STATUS + led_state.index, &res); - - /* set the state values accordingly */ - switch (fw_led_state) { - case LOM_LED_STATE_OFF: - led_state.state = LOM_LED_OFF; - led_state.colour = LOM_LED_COLOUR_ANY; - break; - case LOM_LED_STATE_ON_STEADY: - led_state.state = LOM_LED_ON; - led_state.colour = LOM_LED_COLOUR_ANY; - break; - case LOM_LED_STATE_ON_FLASHING: - case LOM_LED_STATE_ON_SLOWFLASH: - led_state.state = LOM_LED_BLINKING; - led_state.colour = LOM_LED_COLOUR_ANY; - break; - case LOM_LED_STATE_NOT_PRESENT: - led_state.state = LOM_LED_NOT_IMPLEMENTED; - led_state.colour = LOM_LED_COLOUR_NONE; - break; - case LOM_LED_STATE_INACCESSIBLE: - case LOM_LED_STATE_STANDBY: - default: - led_state.state = LOM_LED_ACCESS_ERROR; - led_state.colour = LOM_LED_COLOUR_NONE; - break; - } - - /* set the label info */ - (void) strcpy(led_state.label, - ssp->led_names[led_state.index]); - } - - /* copy out lom_state */ - if ((res == 0) && - (ddi_copyout((caddr_t)&led_state, (caddr_t)arg, - sizeof (lom_led_state_t), mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCINFO - returns with a structure containing any information - * stored on the LOMlite which a user should not need to access but - * may be useful for diagnostic problems. The structure contains: the - * serial escape character, alarm3 mode, version and checksum read from - * RAM and the Product revision and ID read from EEPROM. - */ -static int -bscv_ioc_info(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_info_t info; - int i; - uint16_t csum; - int res = 0; - - info.ser_char = bscv_get8_locked(ssp, chan_general, EBUS_IDX_ESCAPE, - &res); - info.a3mode = WATCHDOG; - info.fver = bscv_get8_locked(ssp, chan_general, EBUS_IDX_FW_REV, &res); - csum = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_HI, &res) - << 8; - csum |= bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_LO, &res); - info.fchksum = csum; - info.prod_rev = bscv_get8_locked(ssp, chan_general, EBUS_IDX_MODEL_REV, - &res); - for (i = 0; i < sizeof (info.prod_id); i++) { - info.prod_id[i] = bscv_get8_locked(ssp, - chan_general, EBUS_IDX_MODEL_ID1 + i, &res); - } - if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_ALARM, &res) & - EBUS_ALARM_NOEVENTS) { - info.events = OFF; - } else { - info.events = ON; - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&info, (caddr_t)arg, sizeof (info), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCMREAD - used to query the LOMlite configuration parameters - */ -static int -bscv_ioc_mread(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_mprog_t mprog; - int i; - int fanz; - int res = 0; - - for (i = 0; i < sizeof (mprog.mod_id); i++) { - mprog.mod_id[i] = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_MODEL_ID1 + i, &res); - } - mprog.mod_rev = bscv_get8_locked(ssp, chan_general, EBUS_IDX_MODEL_REV, - &res); - mprog.config = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CONFIG, - &res); - - /* Read the fan calibration values */ - fanz = sizeof (mprog.fanhz) / sizeof (mprog.fanhz[0]); - for (i = 0; i < fanz; i++) { - mprog.fanhz[i] = bscv_get8_cached(ssp, - EBUS_IDX_FAN1_CAL + i); - mprog.fanmin[i] = bscv_get8_cached(ssp, - EBUS_IDX_FAN1_LOW + i); - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&mprog, (caddr_t)arg, sizeof (mprog), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCVOLTS - */ -static int -bscv_ioc_volts(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - int i; - uint16_t supply; - int res = 0; - - supply = (bscv_get8_locked(ssp, chan_general, EBUS_IDX_SUPPLY_HI, &res) - << 8) | bscv_get8_locked(ssp, chan_general, EBUS_IDX_SUPPLY_LO, - &res); - - for (i = 0; i < ssp->volts.num; i++) { - ssp->volts.status[i] = (supply >> i) & 1; - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&ssp->volts, (caddr_t)arg, - sizeof (ssp->volts), mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCSTATS - */ -static int -bscv_ioc_stats(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - int i; - uint8_t status; - int res = 0; - - status = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CBREAK_STATUS, - &res); - for (i = 0; i < ssp->sflags.num; i++) { - ssp->sflags.status[i] = (int)((status >> i) & 1); - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&ssp->sflags, (caddr_t)arg, - sizeof (ssp->sflags), mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCTEMP - */ -static int -bscv_ioc_temp(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - int i; - int idx; - uint8_t status_ov; - lom_temp_t temps; - int res = 0; - - bzero(&temps, sizeof (temps)); - idx = 0; - for (i = 0; i < ssp->temps.num; i++) { - if (ssp->temps.temp[i] != LOM_TEMP_STATE_NOT_PRESENT) { - temps.temp[idx] = ssp->temps.temp[i]; - bcopy(ssp->temps.name[i], temps.name[idx], - sizeof (temps.name[idx])); - temps.warning[idx] = ssp->temps.warning[i]; - temps.shutdown[idx] = ssp->temps.shutdown[i]; - idx++; - } - } - temps.num = idx; - - bcopy(ssp->temps.name_ov, temps.name_ov, sizeof (temps.name_ov)); - temps.num_ov = ssp->temps.num_ov; - status_ov = bscv_get8_locked(ssp, chan_general, EBUS_IDX_OTEMP_STATUS, - &res); - for (i = 0; i < ssp->temps.num_ov; i++) { - ssp->temps.status_ov[i] = (status_ov >> i) & 1; - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&temps, (caddr_t)arg, sizeof (temps), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCCONS - */ -static int -bscv_ioc_cons(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_cbuf_t cbuf; - int datasize; - int res = 0; - - bzero(&cbuf, sizeof (cbuf)); - datasize = EBUS_IDX1_CONS_BUF_END - EBUS_IDX1_CONS_BUF_START + 1; - /* Ensure that we do not overfill cbuf and that it is NUL terminated */ - if (datasize > (sizeof (cbuf) - 1)) { - datasize = sizeof (cbuf) - 1; - } - bscv_rep_get8_locked(ssp, chan_general, (uint8_t *)cbuf.lrbuf, - BSCVA(EBUS_CMD_SPACE1, (EBUS_IDX1_CONS_BUF_END - datasize + 1)), - datasize, DDI_DEV_AUTOINCR, &res); - /* This is always within the array due to the checks above */ - cbuf.lrbuf[datasize] = '\0'; - - if ((res == 0) && - (ddi_copyout((caddr_t)&cbuf, (caddr_t)arg, sizeof (cbuf), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCEVENTLOG2 - */ -static int -bscv_ioc_eventlog2(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_eventlog2_t *eventlog2; - int events_recorded; - int level; - uint16_t next_offset; - lom_event_t event; - int res = 0; - - eventlog2 = (lom_eventlog2_t *)kmem_zalloc(sizeof (*eventlog2), - KM_SLEEP); - - /* - * First get number of events and level requested. - */ - - if (ddi_copyin((caddr_t)arg, (caddr_t)eventlog2, - sizeof (lom_eventlog2_t), mode) < 0) { - kmem_free((void *)eventlog2, sizeof (*eventlog2)); - return (EFAULT); - } - - bscv_enter(ssp); - - /* - * OK we have full private access to the LOM now so loop - * over the eventlog addr spaces until we get the required - * number of events. - */ - - if (!bscv_window_setup(ssp)) { - res = EIO; - bscv_exit(ssp); - kmem_free((void *)eventlog2, sizeof (*eventlog2)); - return (res); - } - - /* - * Read count, next event ptr MSB,LSB. Note a read of count - * is necessary to latch values for the next event ptr - */ - (void) bscv_get8(ssp, chan_general, EBUS_IDX_UNREAD_EVENTS); - next_offset = bscv_get16(ssp, chan_general, EBUS_IDX_LOG_PTR_HI); - BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "log_ptr_hi 0x%x", - next_offset); - - events_recorded = 0; - - while (events_recorded < eventlog2->num) { - /* - * Working backwards - read an event at a time. - * next_offset is one event on from where we want to be! - * Decrement next_offset and maybe wrap to the end of the - * buffer. - * Note the unsigned arithmetic, so check values first! - */ - if (next_offset <= ssp->eventlog_start) { - /* Wrap to the end of the buffer */ - next_offset = ssp->eventlog_start + ssp->eventlog_size; - BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "wrapping" - " around to end of buffer; next_offset 0x%x", - next_offset); - } - next_offset -= sizeof (event); - - if (bscv_eerw(ssp, next_offset, (uint8_t *)&event, - sizeof (event), B_FALSE /* read */) != 0) { - /* Fault reading data - stop */ - BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "read" - " failure for offset 0x%x", next_offset); - res = EIO; - break; - } - - if (bscv_is_null_event(ssp, &event)) { - /* - * No more events in this log so give up. - */ - BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "no more" - " events left at offset 0x%x", next_offset); - break; - } - - /* - * Are we interested in this event - */ - - level = bscv_level_of_event(&event); - if (level <= eventlog2->level) { - /* Arggh why the funny byte ordering 3, 2, 0, 1 */ - eventlog2->code[events_recorded] = - ((unsigned)event.ev_event | - ((unsigned)event.ev_subsys << 8) | - ((unsigned)event.ev_resource << 16) | - ((unsigned)event.ev_detail << 24)); - - eventlog2->time[events_recorded] = - ((unsigned)event.ev_data[0] | - ((unsigned)event.ev_data[1] << 8) | - ((unsigned)event.ev_data[3] << 16) | - ((unsigned)event.ev_data[2] << 24)); - - bscv_build_eventstring(ssp, - &event, eventlog2->string[events_recorded], - eventlog2->string[events_recorded] + - sizeof (eventlog2->string[events_recorded])); - events_recorded++; - } - } - - eventlog2->num = events_recorded; - - bscv_exit(ssp); - - if ((res == 0) && - (ddi_copyout((caddr_t)eventlog2, (caddr_t)arg, - sizeof (lom_eventlog2_t), mode) < 0)) { - res = EFAULT; - } - - kmem_free((void *)eventlog2, sizeof (lom_eventlog2_t)); - return (res); -} - -/* - * LOMIOCINFO2 - */ -static int -bscv_ioc_info2(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom2_info_t info2; - int i; - uint16_t csum; - int res = 0; - - bzero(&info2, sizeof (info2)); - - (void) strncpy(info2.escape_chars, ssp->escape_chars, - sizeof (info2.escape_chars)); - info2.serial_events = ssp->reporting_level | ssp->serial_reporting; - info2.a3mode = WATCHDOG; - - info2.fver = bscv_get8_locked(ssp, chan_general, EBUS_IDX_FW_REV, &res); - csum = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_HI, &res) - << 8; - csum |= bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_LO, &res); - info2.fchksum = csum; - info2.prod_rev = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_MODEL_REV, &res); - for (i = 0; i < sizeof (info2.prod_id); i++) { - info2.prod_id[i] = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_MODEL_ID1 + i, &res); - } - info2.serial_config = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_SER_TIMEOUT, &res); - if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_CONFIG_MISC, &res) & - EBUS_CONFIG_MISC_SECURITY_ENABLED) { - info2.serial_config |= LOM_SER_SECURITY; - } - if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_CONFIG_MISC, &res) & - EBUS_CONFIG_MISC_AUTO_CONSOLE) { - info2.serial_config |= LOM_SER_RETURN; - } - if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_WDOG_CTRL, &res) & - EBUS_WDOG_BREAK_DISABLE) { - info2.serial_config |= LOM_DISABLE_WDOG_BREAK; - } - info2.baud_rate = bscv_get8_locked(ssp, chan_general, - EBUS_IDX_SER_BAUD, &res); - info2.serial_hw_config = - ((int)bscv_get8_locked(ssp, chan_general, - EBUS_IDX_SER_CHARMODE, &res) | - ((int)bscv_get8_locked(ssp, chan_general, - EBUS_IDX_SER_FLOWCTL, &res) << 8) | - ((int)bscv_get8_locked(ssp, chan_general, - EBUS_IDX_SER_MODEMTYPE, &res) << 16)); - - /* - * There is no phone home support on the blade platform. We hardcode - * FALSE and NUL for config and script respectively. - */ - info2.phone_home_config = B_FALSE; - info2.phone_home_script[0] = '\0'; - - for (i = 0; i < ssp->num_fans; i++) { - (void) strcpy(info2.fan_names[i], ssp->fan_names[i]); - } - - if ((res == 0) && - (ddi_copyout((caddr_t)&info2, (caddr_t)arg, sizeof (info2), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCTEST - */ -static int -bscv_ioc_test(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - uint32_t test; - uint8_t testnum; - uint8_t testarg; - int res = 0; - - if (ddi_copyin((caddr_t)arg, (caddr_t)&test, sizeof (test), - mode) < 0) { - return (EFAULT); - } - - /* - * Extract num iterations. - */ - - testarg = (test & 0xff00) >> 8; - testnum = test & 0xff; - - BSCV_TRACE(ssp, 'F', "bscv_ioc_test", - "LOMIOCTEST data 0x%x (test 0x%x, arg 0x%x)", - test, (EBUS_IDX_SELFTEST0 + testnum), testarg); - - switch (testnum + EBUS_IDX_SELFTEST0) { - default: - /* Invalid test */ - res = EINVAL; - break; - - case EBUS_IDX_SELFTEST0: /* power on self-test result */ - case EBUS_IDX_SELFTEST1: /* not used currently */ - case EBUS_IDX_SELFTEST2: /* not used currently */ - case EBUS_IDX_SELFTEST3: /* not used currently */ - case EBUS_IDX_SELFTEST4: /* not used currently */ - case EBUS_IDX_SELFTEST5: /* not used currently */ - case EBUS_IDX_SELFTEST6: /* LED self-test */ - case EBUS_IDX_SELFTEST7: /* platform-specific tests */ - /* Run the test */ - - /* Stop other things and then run the test */ - bscv_enter(ssp); - - /* - * Then we simply write the argument to the relevant register - * and wait for the return code. - */ - bscv_put8(ssp, chan_general, - EBUS_IDX_SELFTEST0 + testnum, testarg); - if (bscv_faulty(ssp)) { - res = EIO; - } else { - /* Get hold of the SunVTS error code */ - test = bscv_retcode(ssp); - } - - bscv_exit(ssp); - break; - } - - BSCV_TRACE(ssp, 'F', "bscv_ioc_test", - "LOMIOCTEST status 0x%x, res 0x%x", test, res); - if ((res == 0) && - (ddi_copyout((caddr_t)&test, (caddr_t)arg, sizeof (test), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -/* - * LOMIOCMPROG2 - */ -static int -bscv_ioc_mprog2(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom2_mprog_t mprog2; - uint32_t base_addr; - uint32_t data_size; - uint32_t eeprom_size; - int res = 0; - - if (ddi_copyin((caddr_t)arg, (caddr_t)&mprog2, sizeof (mprog2), - mode) < 0) { - return (EFAULT); - } - - /* - * Note that originally this was accessed as 255 byte pages - * in address spaces 240-255. We have to emulate this behaviour. - */ - if ((mprog2.addr_space < 240) || (mprog2.addr_space > 255)) { - return (EINVAL); - } - - bscv_enter(ssp); - - /* Calculate required data location */ - data_size = 255; - base_addr = (mprog2.addr_space - 240) * data_size; - - eeprom_size = bscv_get8(ssp, chan_general, EBUS_IDX_EEPROM_SIZE_KB) * - 1024; - - if (bscv_faulty(ssp)) { - bscv_exit(ssp); - return (EIO); - } else if ((base_addr + data_size) > eeprom_size) { - BSCV_TRACE(ssp, 'M', "bscv_ioc_mprog2", - "Request extends past end of eeprom"); - bscv_exit(ssp); - return (ENXIO); - } - - bscv_put8(ssp, chan_general, EBUS_IDX_CMD_RES, EBUS_CMD_UNLOCK1); - if (bscv_faulty(ssp)) { - BSCV_TRACE(ssp, 'M', "bscv_ioc_mprog2", "ML1 Write failed"); - bscv_exit(ssp); - return (EIO); - } - - bscv_put8(ssp, chan_general, EBUS_IDX_CMD_RES, EBUS_CMD_UNLOCK2); - if (bscv_faulty(ssp)) { - BSCV_TRACE(ssp, 'M', "bscv_ioc_mprog2", "ML2 Write failed"); - bscv_exit(ssp); - return (EIO); - } - - if (bscv_eerw(ssp, base_addr, &mprog2.data[0], - data_size, B_TRUE /* write */) != 0) { - res = EIO; - } - - /* Read a probe key to release the lock. */ - (void) bscv_get8(ssp, chan_general, EBUS_IDX_PROBEAA); - - if (bscv_faulty(ssp)) { - res = EIO; - } - bscv_exit(ssp); - - return (res); -} - -/* - * LOMIOCMREAD2 - */ -static int -bscv_ioc_mread2(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom2_mprog_t mprog2; - uint32_t base_addr; - uint32_t data_size; - uint32_t eeprom_size; - int res = 0; - - if (ddi_copyin((caddr_t)arg, (caddr_t)&mprog2, sizeof (mprog2), - mode) < 0) { - return (EFAULT); - } - - /* - * Need to stop the queue and then just read - * the bytes blind to the relevant addresses. - * Note that originally this was accessed as 255 byte pages - * in address spaces 240-255. We have to emulate this behaviour. - */ - if ((mprog2.addr_space < 240) || (mprog2.addr_space > 255)) { - return (EINVAL); - } - - bscv_enter(ssp); - - /* Calculate required data location */ - data_size = 255; - base_addr = (mprog2.addr_space - 240) * data_size; - eeprom_size = bscv_get8(ssp, chan_general, EBUS_IDX_EEPROM_SIZE_KB) * - 1024; - - if (bscv_faulty(ssp)) { - bscv_exit(ssp); - return (EIO); - } else if ((base_addr + data_size) > eeprom_size) { - BSCV_TRACE(ssp, 'M', "bscv_ioc_mread2", - "Request extends past end of eeprom"); - bscv_exit(ssp); - return (ENXIO); - } - - if (bscv_eerw(ssp, base_addr, &mprog2.data[0], - data_size, B_FALSE /* read */) != 0) { - res = EIO; - } - - if (bscv_faulty(ssp)) { - res = EIO; - } - bscv_exit(ssp); - - if ((res == 0) && - (ddi_copyout((caddr_t)&mprog2, (caddr_t)arg, sizeof (mprog2), - mode) < 0)) { - res = EFAULT; - } - return (res); -} - -static void -bscv_get_state_changes(bscv_soft_state_t *ssp) -{ - int i = STATUS_READ_LIMIT; - uint8_t change; - uint8_t detail; - - ASSERT(bscv_held(ssp)); - - while (i-- && !ssp->cssp_prog) { - /* Are there any changes to process? */ - change = bscv_get8(ssp, chan_general, EBUS_IDX_STATE_CHNG); - change &= EBUS_STATE_MASK; - if (!change) - break; - - /* Clarify the pending change */ - detail = bscv_get8(ssp, chan_general, EBUS_IDX_EVENT_DETAIL); - - bscv_status(ssp, change, detail); - } - - BSCV_TRACE(ssp, 'D', "bscv_get_state_changes", - "loop index %d ssp->cssp_prog 0x%x", i, ssp->cssp_prog); -} - -/* - * ********************************************************************* - * Event Processing - * ********************************************************************* - */ - -/* - * function - bscv_event_daemon - * description - Perform periodic lom tasks in a separate thread. - * inputs - LOM soft state structure pointer - * outputs - none. - */ -static void -bscv_event_daemon(void *arg) -{ - bscv_soft_state_t *ssp = (void *)arg; - boolean_t do_events; - boolean_t do_status; - boolean_t do_nodename; - boolean_t do_watchdog; - uint32_t async_reg; - uint32_t fault; - clock_t poll_period = BSC_EVENT_POLL_NORMAL; - int fault_cnt = 0; - - BSCV_TRACE(ssp, 'D', "bscv_event_daemon", - "bscv_event_daemon: started"); - - /* Acquire task daemon lock. */ - mutex_enter(&ssp->task_mu); - - ssp->task_flags |= TASK_ALIVE_FLG; - - for (;;) { - if ((ssp->task_flags & TASK_STOP_FLG) != 0) { - /* Stop request seen - terminate */ - break; - } - if ((ssp->task_flags & TASK_PAUSE_FLG) == 0) { - /* Poll for events reported to the nexus */ - mutex_exit(&ssp->task_mu); - /* Probe and Check faults */ - bscv_enter(ssp); - async_reg = bscv_probe(ssp, chan_general, &fault); - BSCV_TRACE(ssp, 'D', "bscv_event_daemon", - "process event: async_reg 0x%x, fault 0x%x", - async_reg, fault); - - if (!fault) { - /* Treat non-fault conditions */ - - if (ssp->cssp_prog || ssp->prog_mode_only) { - /* - * The BSC has become available again. - */ - fault_cnt = 0; - ssp->cssp_prog = B_FALSE; - ssp->prog_mode_only = B_FALSE; - (void) bscv_attach_common(ssp); - } else if (fault_cnt > 0) { - /* Previous fault has cleared */ - bscv_clear_fault(ssp); - fault_cnt = 0; - cmn_err(CE_WARN, - "!bscv_event_daemon previous fault " - "cleared."); - } else if (bscv_faulty(ssp)) { - /* Previous fault has cleared */ - bscv_clear_fault(ssp); - /* Sleep to avoid busy waiting */ - ssp->event_sleep = B_TRUE; - } - poll_period = BSC_EVENT_POLL_NORMAL; - - if (async_reg) { - ssp->status_change = B_TRUE; - ssp->event_waiting = B_TRUE; - } - } else if (ssp->cssp_prog) { - /* - * Expect radio silence or error values - * when the CSSP is upgrading the BSC firmware - * so throw away any fault indication. - */ - fault = B_FALSE; - } else if (fault_cnt == BSC_PROBE_FAULT_LIMIT) { - /* Count previous faults and maybe fail */ - /* Declare the lom broken */ - bscv_set_fault(ssp); - poll_period = BSC_EVENT_POLL_FAULTY; - cmn_err(CE_WARN, - "!bscv_event_daemon had faults probing " - "lom - marking it as faulty."); - /* - * Increment fault_cnt to ensure that - * next time we do not report a message - * i.e. we drop out of the bottom - */ - fault_cnt = BSC_PROBE_FAULT_LIMIT + 1; - ssp->event_sleep = B_TRUE; - } else if (fault_cnt < BSC_PROBE_FAULT_LIMIT) { - if (bscv_faulty(ssp)) { - poll_period = BSC_EVENT_POLL_FAULTY; - /* - * No recovery messages in this case - * because there was never a fault - * message here. - */ - fault_cnt = 0; - } else { - /* Getting ready to explode */ - fault_cnt++; - cmn_err(CE_WARN, - "!bscv_event_daemon had fault 0x%x", - fault); - } - ssp->event_sleep = B_TRUE; - } - bscv_exit(ssp); - mutex_enter(&ssp->task_mu); - } - -#if defined(__i386) || defined(__amd64) - /* - * we have no platmod hook on Solaris x86 to report - * a change to the nodename so we keep a copy so - * we can detect a change and request that the bsc - * be updated when appropriate. - */ - if (strcmp(ssp->last_nodename, utsname.nodename) != 0) { - - BSCV_TRACE(ssp, 'X', "bscv_event_daemon", - "utsname.nodename='%s' possible change detected", - utsname.nodename); - ssp->nodename_change = B_TRUE; - (void) strncpy(ssp->last_nodename, utsname.nodename, - sizeof (ssp->last_nodename)); - /* enforce null termination */ - ssp->last_nodename[sizeof (ssp->last_nodename) - 1] = - '\0'; - } -#endif /* __i386 || __amd64 */ - - if (((ssp->task_flags & TASK_PAUSE_FLG) == 0) && - fault_cnt == 0 && ssp->cssp_prog == B_FALSE && - (ssp->event_waiting || ssp->status_change || - ssp->nodename_change || ssp->watchdog_change)) { - - do_events = ssp->event_waiting; - ssp->event_waiting = B_FALSE; - ssp->task_flags |= do_events ? - TASK_EVENT_PENDING_FLG : 0; - do_status = ssp->status_change; - ssp->status_change = B_FALSE; - do_nodename = ssp->nodename_change; - ssp->nodename_change = B_FALSE; - do_watchdog = ssp->watchdog_change; - if (ssp->watchdog_change) { - ssp->watchdog_change = B_FALSE; - } - - mutex_exit(&ssp->task_mu); - /* - * We must not hold task_mu whilst processing - * events because this can lead to priority - * inversion and hence our interrupts getting - * locked out. - */ - bscv_enter(ssp); - if (do_events) { - bscv_event_process(ssp, do_events); - } - if (do_nodename) { - BSCV_TRACE(ssp, 'D', "bscv_event_daemon", - "do_nodename task"); - bscv_setup_hostname(ssp); - } - if (do_watchdog) { - BSCV_TRACE(ssp, 'D', "bscv_event_daemon", - "do_watchdog task"); - bscv_setup_watchdog(ssp); - } - /* - * Pending status changes are dealt with last because - * if we see that the BSC is about to be programmed, - * then it will expect us to to quiescent in the - * first second so it can cleanly tear down its comms - * protocols; this takes ~100 ms. - */ - if (do_status) { - bscv_get_state_changes(ssp); - } - if (bscv_session_error(ssp)) { - /* - * Had fault during event session. We always - * sleep after one of these because there - * may be a problem with the lom which stops - * us doing useful work in the event daemon. - * If we don't sleep then we may livelock. - */ - BSCV_TRACE(ssp, 'D', "bscv_event_daemon", - "had session error - sleeping"); - ssp->event_sleep = B_TRUE; - } - bscv_exit(ssp); - - mutex_enter(&ssp->task_mu); - - if (ssp->task_flags & TASK_EVENT_PENDING_FLG) { - /* - * We have read any events which were - * pending. Let the consumer continue. - * Ignore the race condition with new events - * arriving - just let the consumer have - * whatever was pending when they asked. - */ - ssp->event_active_count++; - ssp->task_flags &= ~(TASK_EVENT_PENDING_FLG | - TASK_EVENT_CONSUMER_FLG); - cv_broadcast(&ssp->task_evnt_cv); - } - } else { - /* There was nothing to do - sleep */ - ssp->event_sleep = B_TRUE; - } - - if (ssp->event_sleep) { - ssp->task_flags |= TASK_SLEEPING_FLG; - /* Sleep until there is something to do */ - (void) cv_reltimedwait(&ssp->task_cv, - &ssp->task_mu, poll_period, TR_CLOCK_TICK); - ssp->task_flags &= ~TASK_SLEEPING_FLG; - ssp->event_sleep = B_FALSE; - } - } - - if (ssp->task_flags & TASK_EVENT_CONSUMER_FLG) { - /* - * We are going away so wake up any event consumer. - * Pretend that any pending events have been processed. - */ - ssp->event_active_count += 2; - cv_broadcast(&ssp->task_evnt_cv); - } - - ASSERT(!(ssp->task_flags & TASK_EVENT_PENDING_FLG)); - ssp->task_flags &= - ~(TASK_STOP_FLG | TASK_ALIVE_FLG | TASK_EVENT_CONSUMER_FLG); - mutex_exit(&ssp->task_mu); - - BSCV_TRACE(ssp, 'D', "bscv_event_daemon", - "exiting."); -} - -/* - * function - bscv_start_event_daemon - * description - Create the event daemon thread. - * inputs - LOM soft state structure pointer - * outputs - none - */ -static void -bscv_start_event_daemon(bscv_soft_state_t *ssp) -{ - if (ssp->progress & BSCV_THREAD) - return; - - /* Start the event thread after the queue has started */ - (void) thread_create(NULL, 0, (void (*)())bscv_event_daemon, ssp, - 0, &p0, TS_RUN, minclsyspri); - - ssp->progress |= BSCV_THREAD; -} - -/* - * function - bscv_stop_event_daemon - * description - Attempt to stop the event daemon thread. - * inputs - LOM soft state structure pointer - * outputs - DDI_SUCCESS OR DDI_FAILURE - */ -static int -bscv_stop_event_daemon(bscv_soft_state_t *ssp) -{ - int try; - int res = DDI_SUCCESS; - - mutex_enter(&ssp->task_mu); - - /* Wait for task daemon to stop running. */ - for (try = 0; - ((ssp->task_flags & TASK_ALIVE_FLG) && try < 10); - try++) { - /* Signal that the task daemon should stop */ - ssp->task_flags |= TASK_STOP_FLG; - cv_signal(&ssp->task_cv); - /* Release task daemon lock. */ - mutex_exit(&ssp->task_mu); - /* - * TODO - when the driver is modified to support - * system suspend or if this routine gets called - * during panic we should use drv_usecwait() rather - * than delay in those circumstances. - */ - delay(drv_usectohz(1000000)); - mutex_enter(&ssp->task_mu); - } - - if (ssp->task_flags & TASK_ALIVE_FLG) { - res = DDI_FAILURE; - } - mutex_exit(&ssp->task_mu); - - return (res); -} - -/* - * function - bscv_pause_event_daemon - * description - Attempt to pause the event daemon thread. - * inputs - LOM soft state structure pointer - * outputs - DDI_SUCCESS OR DDI_FAILURE - */ -static int -bscv_pause_event_daemon(bscv_soft_state_t *ssp) -{ - int try; - - if (!(ssp->progress & BSCV_THREAD)) { - /* Nothing to do */ - return (BSCV_SUCCESS); - } - - BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon", - "Attempting to pause event daemon"); - - mutex_enter(&ssp->task_mu); - /* Signal that the task daemon should pause */ - ssp->task_flags |= TASK_PAUSE_FLG; - - /* Wait for task daemon to pause. */ - for (try = 0; - (!(ssp->task_flags & TASK_SLEEPING_FLG) && - (ssp->task_flags & TASK_ALIVE_FLG) && - try < 10); - try++) { - /* Paranoia */ - ssp->task_flags |= TASK_PAUSE_FLG; - cv_signal(&ssp->task_cv); - /* Release task daemon lock. */ - mutex_exit(&ssp->task_mu); - delay(drv_usectohz(1000000)); - mutex_enter(&ssp->task_mu); - } - if ((ssp->task_flags & TASK_SLEEPING_FLG) || - !(ssp->task_flags & TASK_ALIVE_FLG)) { - mutex_exit(&ssp->task_mu); - BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon", - "Pause event daemon - success"); - return (BSCV_SUCCESS); - } - mutex_exit(&ssp->task_mu); - BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon", - "Pause event daemon - failed"); - return (BSCV_FAILURE); -} - -/* - * function - bscv_resume_event_daemon - * description - Resumethe event daemon thread. - * inputs - LOM soft state structure pointer - * outputs - None. - */ -static void -bscv_resume_event_daemon(bscv_soft_state_t *ssp) -{ - if (!(ssp->progress & BSCV_THREAD)) { - /* Nothing to do */ - return; - } - - mutex_enter(&ssp->task_mu); - /* Allow the task daemon to resume event processing */ - ssp->task_flags &= ~TASK_PAUSE_FLG; - cv_signal(&ssp->task_cv); - mutex_exit(&ssp->task_mu); - - BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon", - "Event daemon resumed"); -} - -/* - * function - bscv_event_process - * description - process (report) events - * inputs - Soft state ptr, process event request - * outputs - none - */ -static void -bscv_event_process(bscv_soft_state_t *ssp, boolean_t do_events) -{ - uint32_t currptr; - unsigned int count; - - /* Raw values read from the lom */ - uint8_t evcount; - uint16_t logptr; - - lom_event_t event; - - if (do_events) { - /* - * Read count, next event ptr MSB,LSB. Note a read of count - * latches values for the next event ptr - */ - evcount = bscv_get8(ssp, chan_general, EBUS_IDX_UNREAD_EVENTS); - logptr = bscv_get16(ssp, chan_general, EBUS_IDX_LOG_PTR_HI); - - /* Sanity check the values from the lom */ - count = bscv_event_validate(ssp, logptr, evcount); - - if (count == -1) { - /* - * Nothing to do - or badly configured event log. - * We really do not want to touch the lom in this - * case because any data that we access may be bad! - * This differs from zero because if we have zero - * to read the lom probably things that unread is - * non-zero and we want that to be set to zero! - * Signal event fault to make the thread wait - * before attempting to re-read the log. - */ - ssp->event_sleep = B_TRUE; - - goto logdone; - } - if (ssp->event_fault_reported) { - /* Clear down any old status - things are fixed */ - cmn_err(CE_NOTE, "Event pointer fault recovered."); - ssp->event_fault_reported = B_FALSE; - } - - /* Compute the first entry that we need to read. */ - currptr = logptr - ssp->eventlog_start; - currptr += ssp->eventlog_size; - currptr -= (count * sizeof (event)); - currptr %= ssp->eventlog_size; - currptr += ssp->eventlog_start; - - BSCV_TRACE(ssp, 'E', "bscv_event_process", - "processing %d events from 0x%x in 0x%x:0x%x", - count, currptr, - ssp->eventlog_start, - ssp->eventlog_start + ssp->eventlog_size); - - for (; count > 0; count--) { - /* Ensure window is positioned correctly */ - if (bscv_eerw(ssp, currptr, (uint8_t *)&event, - sizeof (event), B_FALSE /* read */) != 0) { - /* Fault reading data - stop */ - break; - } - - bscv_event_process_one(ssp, &event); - bscv_sysevent(ssp, &event); - - currptr += sizeof (event); - if (currptr >= ssp->eventlog_start + - ssp->eventlog_size) { - currptr = ssp->eventlog_start; - } - } - /* - * Clear event count - write the evcount value to remove that - * many from the unread total. - * Adjust the value to reflect how many we have left to - * read just in case we had a failure reading events. - */ - if (count == 0) { - /*EMPTY*/ - ASSERT(logptr == currptr); - } else if (count > evcount) { - evcount = 0; - } else { - evcount -= count; - } - bscv_put8(ssp, chan_general, EBUS_IDX_UNREAD_EVENTS, evcount); - /* Remember where we were for next time */ - ssp->oldeeptr = currptr; - ssp->oldeeptr_valid = B_TRUE; -logdone: - ; - } -} - -/* - * function - bscv_event_validate - * description - validate the event data supplied by the lom and determine - * how many (if any) events to read. - * This function performs complex checks to ensure that - * events are not lost due to lom resets or host resets. - * A combination of lom reset and host reset (i.e. power fail) - * may cause some events to not be reported. - * inputs - Soft state ptr, next event pointer, number of unread events. - * outputs - the number of events to read. -1 on error. - * zero is a valid value because it forces the loms unread - * count to be cleared. - */ -static int -bscv_event_validate(bscv_soft_state_t *ssp, uint32_t newptr, uint8_t unread) -{ - uint32_t oldptr; - unsigned int count; - - if (!bscv_window_setup(ssp)) { - /* Problem with lom eeprom setup we cannot do anything */ - return (-1); - } - - /* Sanity check the event pointers */ - if ((newptr < ssp->eventlog_start) || - (newptr >= (ssp->eventlog_start + ssp->eventlog_size))) { - if (!ssp->event_fault_reported) { - cmn_err(CE_WARN, "Event pointer out of range. " - "Cannot read events."); - ssp->event_fault_reported = B_TRUE; - } - return (-1); - } - oldptr = ssp->oldeeptr; - /* Now sanity check log pointer against count */ - if (newptr < oldptr) { - /* - * Must have wrapped add eventlog_size to get the - * correct relative values - this makes the checks - * below work! - */ - newptr += ssp->eventlog_size; - } - if (!ssp->oldeeptr_valid) { - /* We have just started up - we have to trust lom */ - count = unread; - } else if ((unread == 0) && (newptr == oldptr)) { - /* Nothing to do - we were just polling */ - return (-1); - } else if (oldptr + (unread * sizeof (lom_event_t)) == newptr) { - /* Ok - got as many events as we expected */ - count = unread; - } else if (oldptr + (unread * sizeof (lom_event_t)) > newptr) { - /* - * Errrm more messages than there should have been. - * Possible causes: - * 1. the event log has filled - we have been - * away for a long time - * 2. software bug in lom or driver. - * 3. something that I haven't thought of! - * Always warn about this we should really never - * see it! - */ - count = (newptr - oldptr) / sizeof (lom_event_t); - BSCV_TRACE(ssp, 'E', "bscv_event_process", - "bscv_event_process: lom reported " - "more events (%d) than expected (%d).", - unread, count); - cmn_err(CE_CONT, "only processing %d events", count); - } else { - /* Less messages - perhaps the lom has been reset */ - count = (newptr - oldptr) / sizeof (lom_event_t); - BSCV_TRACE(ssp, 'E', "bscv_event_process", - "lom reported less events (%d) than expected (%d)" - " - the lom may have been reset", - unread, count); - } - /* Whatever happens only read a maximum of 255 entries */ - if ((count >= 0xff)) { - cmn_err(CE_WARN, - "bscv_event_process: too many events (%d) to " - "process - some may have been lost", count); - count = 0xff; - } - return (count); -} - -/* - * function - bscv_event_process_one - * description - reports on state changes to the host. - * - * inputs - LOM soft state structure pointer. - * - * outputs - none. - */ - -static void -bscv_event_process_one(bscv_soft_state_t *ssp, lom_event_t *event) -{ - int level; - char eventstr[100]; - int msg_type = 0; - - if (bscv_is_null_event(ssp, event)) { - /* Cleared entry - do not report it */ - return; - } - - level = bscv_level_of_event(event); - - switch (level) { - default: - msg_type = CE_NOTE; - break; - - case EVENT_LEVEL_FATAL: - case EVENT_LEVEL_FAULT: - msg_type = CE_WARN; - break; - } - - bscv_build_eventstring(ssp, event, eventstr, eventstr + - sizeof (eventstr)); - - if (level <= ssp->reporting_level) { - /* - * The message is important enough to be shown on the console - * as well as the log. - */ - cmn_err(msg_type, "%s", eventstr); - } else { - /* - * The message goes only to the log. - */ - cmn_err(msg_type, "!%s", eventstr); - } -} - -/* - * time formats - * - * The BSC represents times as seconds since epoch 1970. Currently it gives - * us 32 bits, unsigned. In the future this might change to a 64-bit count, - * to allow a greater range. - * - * Timestamp values below BSC_TIME_SANITY do not represent an absolute time, - * but instead represent an offset from the last reset. This must be - * borne in mind by output routines. - */ - -typedef uint32_t bsctime_t; - -#define BSC_TIME_SANITY 1000000000 - -/* - * render a formatted time for display - */ - -static size_t -bscv_event_snprintgmttime(char *buf, size_t bufsz, todinfo_t t) -{ - int year; - - /* tod_year is base 1900 so this code needs to adjust */ - year = 1900 + t.tod_year; - - return (snprintf(buf, bufsz, "%04d-%02d-%02d %02d:%02d:%02dZ", - year, t.tod_month, t.tod_day, t.tod_hour, - t.tod_min, t.tod_sec)); -} - -/* - * function - bscv_build_eventstring - * description - reports on state changes to the host. - * - * inputs - LOM soft state structure pointer. - * - * outputs - none. - */ - -static void -bscv_build_eventstring(bscv_soft_state_t *ssp, lom_event_t *event, - char *buf, char *bufend) -{ - uint8_t subsystem; - uint8_t eventtype; - bsctime_t bsctm; - - BSCV_TRACE(ssp, 'S', "bscv_build_eventstring", "event %2x%2x%2x%2x", - event->ev_subsys, event->ev_event, - event->ev_resource, event->ev_detail); - BSCV_TRACE(ssp, 'S', "bscv_build_eventstring", "time %2x%2x%2x%2x", - event->ev_data[0], event->ev_data[1], - event->ev_data[2], event->ev_data[3]); - - /* - * We accept bad subsystems and event type codes here. - * The code decodes as much as possible and then produces - * suitable output. - */ - subsystem = EVENT_DECODE_SUBSYS(event->ev_subsys); - eventtype = event->ev_event; - - /* time */ - bsctm = (((uint32_t)event->ev_data[0]) << 24) | - (((uint32_t)event->ev_data[1]) << 16) | - (((uint32_t)event->ev_data[2]) << 8) | - ((uint32_t)event->ev_data[3]); - if (bsctm < BSC_TIME_SANITY) { - /* offset */ - buf += snprintf(buf, bufend-buf, "+P%dd%02dh%02dm%02ds", - (int)(bsctm/86400), (int)(bsctm/3600%24), - (int)(bsctm/60%60), (int)(bsctm%60)); - } else { - /* absolute time */ - mutex_enter(&tod_lock); - buf += bscv_event_snprintgmttime(buf, bufend-buf, - utc_to_tod(bsctm)); - mutex_exit(&tod_lock); - } - buf += snprintf(buf, bufend-buf, " "); - - /* subsysp */ - if (subsystem < - (sizeof (eventSubsysStrings)/sizeof (*eventSubsysStrings))) { - buf += snprintf(buf, bufend - buf, "%s", - eventSubsysStrings[subsystem]); - } else { - buf += snprintf(buf, bufend - buf, - "unknown subsystem %d ", subsystem); - } - - /* resource */ - switch (subsystem) { - case EVENT_SUBSYS_ALARM: - case EVENT_SUBSYS_TEMP: - case EVENT_SUBSYS_OVERTEMP: - case EVENT_SUBSYS_FAN: - case EVENT_SUBSYS_SUPPLY: - case EVENT_SUBSYS_BREAKER: - case EVENT_SUBSYS_PSU: - buf += snprintf(buf, bufend - buf, "%d ", event->ev_resource); - break; - case EVENT_SUBSYS_LED: - buf += snprintf(buf, bufend - buf, "%s ", bscv_get_label( - ssp->led_names, MAX_LED_ID, event->ev_resource - 1)); - break; - default: - break; - } - - /* fatal */ - if (event->ev_subsys & EVENT_MASK_FAULT) { - if (event->ev_subsys & EVENT_MASK_FATAL) { - buf += snprintf(buf, bufend - buf, "FATAL FAULT: "); - } else { - buf += snprintf(buf, bufend - buf, "FAULT: "); - } - } - - /* eventp */ - if (eventtype < - (sizeof (eventTypeStrings)/sizeof (*eventTypeStrings))) { - buf += snprintf(buf, bufend - buf, "%s", - eventTypeStrings[eventtype]); - } else { - buf += snprintf(buf, bufend - buf, - "unknown event 0x%02x%02x%02x%02x", - event->ev_subsys, event->ev_event, - event->ev_resource, event->ev_detail); - } - - /* detail */ - switch (subsystem) { - case EVENT_SUBSYS_TEMP: - if ((eventtype != EVENT_RECOVERED) && - eventtype != EVENT_DEVICE_INACCESSIBLE) { - buf += snprintf(buf, bufend - buf, " - %d degC", - (int8_t)event->ev_detail); - } - break; - case EVENT_SUBSYS_FAN: - if (eventtype == EVENT_FAILED) { - buf += snprintf(buf, bufend - buf, - " %d%%", event->ev_detail); - } - break; - case EVENT_SUBSYS_LOM: - switch (eventtype) { - case EVENT_FLASH_DOWNLOAD: - buf += snprintf(buf, bufend - buf, - ": v%d.%d to v%d.%d", - (event->ev_resource >> 4), - (event->ev_resource & 0x0f), - (event->ev_detail >> 4), - (event->ev_detail & 0x0f)); - break; - case EVENT_WATCHDOG_TRIGGER: - buf += snprintf(buf, bufend - buf, - event->ev_detail ? "- soft" : " - hard"); - break; - case EVENT_UNEXPECTED_RESET: - if (event->ev_detail & - LOM_UNEXPECTEDRESET_MASK_BADTRAP) { - buf += snprintf(buf, bufend - buf, - " - unclaimed exception 0x%x", - event->ev_detail & - ~LOM_UNEXPECTEDRESET_MASK_BADTRAP); - } - break; - case EVENT_RESET: - switch (event->ev_detail) { - case LOM_RESET_DETAIL_BYUSER: - buf += snprintf(buf, bufend - buf, " by user"); - break; - case LOM_RESET_DETAIL_REPROGRAMMING: - buf += snprintf(buf, bufend - buf, - " after flash download"); - break; - default: - buf += snprintf(buf, bufend - buf, - " - unknown reason"); - break; - } - break; - default: - break; - } - break; - case EVENT_SUBSYS_LED: - switch (event->ev_detail) { - case LOM_LED_STATE_OFF: - buf += snprintf(buf, bufend - buf, ": OFF"); - break; - case LOM_LED_STATE_ON_STEADY: - buf += snprintf(buf, bufend - buf, ": ON"); - break; - case LOM_LED_STATE_ON_FLASHING: - case LOM_LED_STATE_ON_SLOWFLASH: - buf += snprintf(buf, bufend - buf, ": BLINKING"); - break; - case LOM_LED_STATE_INACCESSIBLE: - buf += snprintf(buf, bufend - buf, ": inaccessible"); - break; - case LOM_LED_STATE_STANDBY: - buf += snprintf(buf, bufend - buf, ": standby"); - break; - case LOM_LED_STATE_NOT_PRESENT: - buf += snprintf(buf, bufend - buf, ": not present"); - break; - default: - buf += snprintf(buf, bufend - buf, ": 0x%x", - event->ev_resource); - break; - } - break; - case EVENT_SUBSYS_USER: - switch (eventtype) { - case EVENT_USER_ADDED: - case EVENT_USER_REMOVED: - case EVENT_USER_PERMSCHANGED: - case EVENT_USER_LOGIN: - case EVENT_USER_PASSWORD_CHANGE: - case EVENT_USER_LOGINFAIL: - case EVENT_USER_LOGOUT: - buf += snprintf(buf, bufend - buf, " %d", - event->ev_resource); - default: - break; - } - break; - case EVENT_SUBSYS_PSU: - if (event->ev_detail & LOM_PSU_NOACCESS) { - buf += snprintf(buf, bufend - buf, " - inaccessible"); - } else if ((event->ev_detail & LOM_PSU_STATUS_MASK) - == LOM_PSU_STATUS_MASK) { - buf += snprintf(buf, bufend - buf, " - OK"); - } else { - buf += snprintf(buf, bufend - buf, " -"); - /* - * If both inputs are seen to have failed then simply - * indicate that the PSU input has failed - */ - if (!(event->ev_detail & - (LOM_PSU_INPUT_A_OK | LOM_PSU_INPUT_B_OK))) { - buf += snprintf(buf, bufend - buf, " Input"); - } else { - /* At least one input is ok */ - if (!(event->ev_detail & LOM_PSU_INPUT_A_OK)) { - buf += snprintf(buf, bufend - buf, - " InA"); - } - if (!(event->ev_detail & LOM_PSU_INPUT_B_OK)) { - buf += snprintf(buf, bufend - buf, - " InB"); - } - /* - * Only flag an output error if an input is - * still present - */ - if (!(event->ev_detail & LOM_PSU_OUTPUT_OK)) { - buf += snprintf(buf, bufend - buf, - " Output"); - } - } - buf += snprintf(buf, bufend - buf, " failed"); - } - break; - case EVENT_SUBSYS_NONE: - if (eventtype == EVENT_FAULT_LED) { - switch (event->ev_detail) { - case 0: - buf += snprintf(buf, bufend - buf, " - ON"); - break; - case 255: - buf += snprintf(buf, bufend - buf, " - OFF"); - break; - default: - buf += snprintf(buf, bufend - buf, - " - %dHz", event->ev_detail); - break; - } - } - break; - case EVENT_SUBSYS_HOST: - if (eventtype == EVENT_BOOTMODE_CHANGE) { - switch (event->ev_detail & - ~EBUS_BOOTMODE_FORCE_CONSOLE) { - case EBUS_BOOTMODE_FORCE_NOBOOT: - buf += snprintf(buf, bufend - buf, - " - no boot"); - break; - case EBUS_BOOTMODE_RESET_DEFAULT: - buf += snprintf(buf, bufend - buf, - " - reset defaults"); - break; - case EBUS_BOOTMODE_FULLDIAG: - buf += snprintf(buf, bufend - buf, - " - full diag"); - break; - case EBUS_BOOTMODE_SKIPDIAG: - buf += snprintf(buf, bufend - buf, - " - skip diag"); - break; - default: - break; - } - } - if (eventtype == EVENT_SCC_STATUS) { - switch (event->ev_detail) { - case 0: - buf += snprintf(buf, bufend - buf, - " - inserted"); - break; - case 1: - buf += snprintf(buf, bufend - buf, - " - removed"); - break; - default: - break; - } - } - break; - - default: - break; - } - - /* shutd */ - if (event->ev_subsys & EVENT_MASK_SHUTDOWN_REQD) { - buf += snprintf(buf, bufend - buf, " - shutdown req'd"); - } - - buf += snprintf(buf, bufend - buf, "\n"); - - if (buf >= bufend) { - /* Ensure newline at end of string */ - bufend[-2] = '\n'; - bufend[-1] = '\0'; -#ifdef DEBUG - cmn_err(CE_WARN, "!bscv_build_eventstring: buffer too small!"); -#endif /* DEBUG */ - } -} - -/* - * function - bscv_level_of_event - * description - This routine determines which level an event should be - * reported at. - * inputs - lom event structure pointer - * outputs - event level. - */ -static int -bscv_level_of_event(lom_event_t *event) -{ - int level; - /* - * This is the same criteria that the firmware uses except we - * log the fault led on as being EVENT_LEVEL_FAULT - */ - if (EVENT_DECODE_SUBSYS(event->ev_subsys) == EVENT_SUBSYS_USER) { - level = EVENT_LEVEL_USER; - } else if ((EVENT_DECODE_SUBSYS(event->ev_subsys) == - EVENT_SUBSYS_ALARM) && (event->ev_event == EVENT_STATE_ON)) { - level = EVENT_LEVEL_FAULT; - } else if ((EVENT_DECODE_SUBSYS(event->ev_subsys) == - EVENT_SUBSYS_NONE) && - (event->ev_event == EVENT_FAULT_LED) && - (event->ev_detail != 0xff)) { - level = EVENT_LEVEL_FAULT; - } else if ((EVENT_DECODE_SUBSYS(event->ev_subsys) == - EVENT_SUBSYS_LOM) && event->ev_event == EVENT_TIME_REFERENCE) { - level = EVENT_LEVEL_NOTICE; - } else if (event->ev_event == EVENT_RECOVERED) { - /* - * All recovery messages need to be reported to the console - * because during boot, the faults which occurred whilst - * Solaris was not running are relayed to the console. There - * is a case whereby a fatal fault (eg. over temp) could - * have occurred and then recovered. The recovery condition - * needs to be reported so the user doesn't think that the - * failure (over temp) is still present. - */ - level = EVENT_LEVEL_FAULT; - } else if (EVENT_DECODE_FAULT(event->ev_subsys) == 0) { - /* None of FAULT, FATAL or SHUTDOWN REQD are set */ - level = EVENT_LEVEL_NOTICE; - } else if (EVENT_DECODE_FAULT(event->ev_subsys) == EVENT_MASK_FAULT) { - /* Only FAULT set i.e not FATAL or SHUTDOWN REQD */ - level = EVENT_LEVEL_FAULT; - } else { - level = EVENT_LEVEL_FATAL; - } - - return (level); -} - -/* - * function - bscv_status - * description - This routine is called when any change in the LOMlite2 status - * is indicated by the status registers. - * - * inputs - LOM soft state structure pointer - * - * outputs - none. - */ -static void -bscv_status(bscv_soft_state_t *ssp, uint8_t state_chng, uint8_t dev_no) -{ - int8_t temp; - uint8_t fanspeed; - - ASSERT(bscv_held(ssp)); - - BSCV_TRACE(ssp, 'D', "bscv_status", "state_chng 0x%x dev_no 0x%x", - state_chng, dev_no); - - /* - * The device that has changed is given by the state change - * register and the event detail register so react - * accordingly. - */ - - if (state_chng == EBUS_STATE_NOTIFY) { - /* - * The BSC is indicating a self state change - */ - if (dev_no == EBUS_DETAIL_FLASH) { - ssp->cssp_prog = B_TRUE; - BSCV_TRACE(ssp, 'D', "bscv_status", - "ssp->cssp_prog changed to 0x%x", - ssp->cssp_prog); - /* - * It takes the BSC at least 100 ms to - * clear down the comms protocol. - * We back-off from talking to the - * BSC during this period. - */ - delay(BSC_EVENT_POLL_NORMAL); - BSCV_TRACE(ssp, 'D', "bscv_status", - "completed delay"); - } else if (dev_no == EBUS_DETAIL_RESET) { - /* - * The bsc has reset - */ - BSCV_TRACE(ssp, 'D', "bscv_status", - "BSC reset occured, re-synching"); - (void) bscv_attach_common(ssp); - BSCV_TRACE(ssp, 'D', "bscv_status", - "completed attach_common"); - } - - } - - if ((state_chng & EBUS_STATE_FAN) && ((dev_no - 1) < MAX_FANS)) { - fanspeed = bscv_get8(ssp, chan_general, - EBUS_IDX_FAN1_SPEED + dev_no - 1); - /* - * Only remember fanspeeds which are real values or - * NOT PRESENT values. - */ - if ((fanspeed <= LOM_FAN_MAX_SPEED) || - (fanspeed == LOM_FAN_NOT_PRESENT)) { - ssp->fanspeed[dev_no - 1] = fanspeed; - } - } - - if ((state_chng & EBUS_STATE_PSU) && ((dev_no - 1) < MAX_PSUS)) { - (void) bscv_get8(ssp, chan_general, - EBUS_IDX_PSU1_STAT + dev_no - 1); - } - - if (state_chng & EBUS_STATE_GP) { - (void) bscv_get8(ssp, chan_general, EBUS_IDX_GPIP); - } - - if (state_chng & EBUS_STATE_CB) { - (void) bscv_get8(ssp, chan_general, EBUS_IDX_CBREAK_STATUS); - } - - if ((state_chng & EBUS_STATE_TEMPERATURE) && - ((dev_no - 1) < MAX_TEMPS)) { - temp = bscv_get8(ssp, chan_general, - EBUS_IDX_TEMP1 + dev_no - 1); - /* - * Only remember temperatures which are real values or - * a NOT PRESENT value. - */ - if ((temp <= LOM_TEMP_MAX_VALUE) || - (temp == LOM_TEMP_STATE_NOT_PRESENT)) { - ssp->temps.temp[dev_no - 1] = temp; - } - } - - if (state_chng & EBUS_STATE_RAIL) { - (void) bscv_get8(ssp, chan_general, EBUS_IDX_SUPPLY_LO); - (void) bscv_get8(ssp, chan_general, EBUS_IDX_SUPPLY_HI); - } -} - -char * -bscv_get_label(char labels[][MAX_LOM2_NAME_STR], int limit, int index) -{ - - if (labels == NULL) - return (""); - - if (limit < 0 || index < 0 || index > limit) - return ("-"); - - return (labels[index]); -} - -static void -bscv_generic_sysevent(bscv_soft_state_t *ssp, char *class, char *subclass, - char *fru_id, char *res_id, int32_t fru_state, char *msg) -{ - int rv; - nvlist_t *attr_list; - - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", "%s/%s:(%s,%s,%d) %s", - class, subclass, fru_id, res_id, fru_state, msg); - - - if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE, KM_SLEEP)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist alloc failure"); - return; - } - if (nvlist_add_uint32(attr_list, ENV_VERSION, 1)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist ENV_VERSION failure"); - nvlist_free(attr_list); - return; - } - if (nvlist_add_string(attr_list, ENV_FRU_ID, fru_id)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist ENV_FRU_ID failure"); - nvlist_free(attr_list); - return; - } - if (nvlist_add_string(attr_list, ENV_FRU_RESOURCE_ID, res_id)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist ENV_FRU_RESOURCE_ID failure"); - nvlist_free(attr_list); - return; - } - if (nvlist_add_string(attr_list, ENV_FRU_DEVICE, ENV_RESERVED_ATTR)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist ENV_FRU_DEVICE failure"); - nvlist_free(attr_list); - return; - } - if (nvlist_add_int32(attr_list, ENV_FRU_STATE, fru_state)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist ENV_FRU_STATE failure"); - nvlist_free(attr_list); - return; - } - if (nvlist_add_string(attr_list, ENV_MSG, msg)) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", - "nvlist ENV_MSG failure"); - nvlist_free(attr_list); - return; - } - - rv = ddi_log_sysevent(ssp->dip, DDI_VENDOR_SUNW, class, - subclass, attr_list, NULL, DDI_SLEEP); - - if (rv == DDI_SUCCESS) { - BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", "sent sysevent"); - } else { - cmn_err(CE_WARN, "!cannot deliver sysevent"); - } - - nvlist_free(attr_list); -} - -/* - * function - bscv_sysevent - * description - send out a sysevent on the given change if needed - * inputs - soft state pointer, event to report - * outputs - none - */ - -static void -bscv_sysevent(bscv_soft_state_t *ssp, lom_event_t *event) -{ - char *class = NULL; - char *subclass = NULL; - char *fru_id = "Blade"; /* The blade is only one FRU */ - char *res_id; - int32_t fru_state = 0; - - BSCV_TRACE(ssp, 'E', "bscv_sysevent", "processing event"); - - ASSERT(event != NULL); - - /* Map ev_subsys to sysevent class/sub-class */ - - switch (EVENT_DECODE_SUBSYS(event->ev_subsys)) { - case EVENT_SUBSYS_NONE: - break; - case EVENT_SUBSYS_ALARM: - break; - case EVENT_SUBSYS_TEMP: - class = EC_ENV, subclass = ESC_ENV_TEMP; - res_id = bscv_get_label(ssp->temps.name, ssp->temps.num, - event->ev_resource - 1); - switch (event->ev_event) { - case EVENT_SEVERE_OVERHEAT: - fru_state = ENV_FAILED; - break; - case EVENT_OVERHEAT: - fru_state = ENV_WARNING; - break; - case EVENT_NO_OVERHEAT: - fru_state = ENV_OK; - break; - default: - return; - } - break; - case EVENT_SUBSYS_OVERTEMP: - break; - case EVENT_SUBSYS_FAN: - class = EC_ENV, subclass = ESC_ENV_FAN; - res_id = bscv_get_label(ssp->fan_names, ssp->num_fans, - event->ev_resource - 1); - switch (event->ev_event) { - case EVENT_FAILED: - fru_state = ENV_FAILED; - break; - case EVENT_RECOVERED: - fru_state = ENV_OK; - break; - default: - return; - } - break; - case EVENT_SUBSYS_SUPPLY: - class = EC_ENV, subclass = ESC_ENV_POWER; - res_id = bscv_get_label(ssp->sflags.name, ssp->sflags.num, - event->ev_resource - 1); - switch (event->ev_event) { - case EVENT_FAILED: - fru_state = ENV_FAILED; - break; - case EVENT_RECOVERED: - fru_state = ENV_OK; - break; - default: - return; - } - break; - case EVENT_SUBSYS_BREAKER: - break; - case EVENT_SUBSYS_PSU: - break; - case EVENT_SUBSYS_USER: - break; - case EVENT_SUBSYS_PHONEHOME: - break; - case EVENT_SUBSYS_LOM: - break; - case EVENT_SUBSYS_HOST: - break; - case EVENT_SUBSYS_EVENTLOG: - break; - case EVENT_SUBSYS_EXTRA: - break; - case EVENT_SUBSYS_LED: - if (event->ev_event != EVENT_FAULT_LED && - event->ev_event != EVENT_STATE_CHANGE) - return; - /* - * There are 3 LEDs : Power, Service, Ready-to-Remove on a - * JBOS blade. We'll never report the Power since Solaris - * won't be running when it is _switched_ ON. Ready-to-Remove - * will only be lit when we're powered down which also means - * Solaris won't be running. We don't want to report it - * during system testing / Sun VTS exercising the LEDs. - * - * Therefore, we only report the Service Required LED. - */ - class = EC_ENV, subclass = ESC_ENV_LED; - res_id = bscv_get_label(ssp->led_names, MAX_LED_ID, - event->ev_resource - 1); - - switch (event->ev_detail) { - case LOM_LED_STATE_ON_STEADY: - fru_state = ENV_LED_ON; - break; - case LOM_LED_STATE_ON_FLASHING: - case LOM_LED_STATE_ON_SLOWFLASH: - fru_state = ENV_LED_BLINKING; - break; - case LOM_LED_STATE_OFF: - fru_state = ENV_LED_OFF; - break; - case LOM_LED_STATE_INACCESSIBLE: - fru_state = ENV_LED_INACCESSIBLE; - break; - case LOM_LED_STATE_STANDBY: - fru_state = ENV_LED_STANDBY; - break; - case LOM_LED_STATE_NOT_PRESENT: - fru_state = ENV_LED_NOT_PRESENT; - break; - default: - fru_state = ENV_LED_INACCESSIBLE; - break; - } - break; - default : - break; - } - - if (class == NULL || subclass == NULL) { - BSCV_TRACE(ssp, 'E', "bscv_sysevent", "class/subclass NULL"); - return; - } - - bscv_generic_sysevent(ssp, class, subclass, fru_id, res_id, fru_state, - ENV_RESERVED_ATTR); -} - -/* - * ********************************************************************* - * Firmware download (programming) - * ********************************************************************* - */ - -/* - * function - bscv_prog - * description - LOMlite2 flash programming code. - * - * bscv_prog_image - download a complete image to the lom. - * bscv_prog_receive_image - receive data to build up a - * complete image. - * bscv_prog_stop_lom - pause the event daemon and prepare - * lom for firmware upgrade. - * bscv_prog_start_lom - reinit the driver/lom after upgrade - * and restart the event daemon - * - * inputs - soft state pointer, arg ptr, ioctl mode - * outputs - status - */ - -static int -bscv_prog(bscv_soft_state_t *ssp, intptr_t arg, int mode) -{ - lom_prog_t *prog; - int res = 0; - - /* - * We will get repeatedly called with bits of data first for - * loader, then for main image. - */ - prog = (lom_prog_t *)kmem_alloc(sizeof (lom_prog_t), KM_SLEEP); - - if (ddi_copyin((caddr_t)arg, (caddr_t)prog, sizeof (*prog), - mode) < 0) { - kmem_free((void *)prog, sizeof (*prog)); - return (EFAULT); - } - - BSCV_TRACE(ssp, 'U', "bscv_prog", - "index 0x%x size 0x%x", prog->index, prog->size); - - mutex_enter(&ssp->prog_mu); - if (prog->size == 0) { - if (prog->index == 2) { - /* - * This is the initial request for the chip type so we - * know what we are programming. - * The type will have been read in at init so just - * return it in data[0]. - */ - prog->data[0] = bscv_get8_cached(ssp, - EBUS_IDX_CPU_IDENT); - - if (ddi_copyout((caddr_t)prog, (caddr_t)arg, - sizeof (lom_prog_t), mode) < 0) { - res = EFAULT; - } - } else if (prog->index == 0) { - res = bscv_prog_stop_lom(ssp); - } else if (prog->index == 1) { - res = bscv_prog_start_lom(ssp); - } else { - res = EINVAL; - } - } else { - if (ssp->image == NULL) { - ssp->image = (uint8_t *)kmem_zalloc( - BSC_IMAGE_MAX_SIZE, KM_SLEEP); - } - res = bscv_prog_receive_image(ssp, prog, - ssp->image, BSC_IMAGE_MAX_SIZE); - } - mutex_exit(&ssp->prog_mu); - kmem_free((void *)prog, sizeof (lom_prog_t)); - - return (res); -} - -static int -bscv_check_loader_config(bscv_soft_state_t *ssp, boolean_t is_image2) -{ - BSCV_TRACE(ssp, 'U', "bscv_check_loader_config", - "loader_running %d, is_image2 %d", - ssp->loader_running, is_image2); - - /* - * loader_running TRUE means that we have told the microcontroller to - * JUMP into the loader code which has been downloaded into its RAM. - * At this point its an error to try and download another loader. We - * should be downloading the actual image at this point. - * Conversely, it is an error to download an image when the loader is - * not already downloaded and the microcontroller hasn't JUMPed into it. - * is_image2 TRUE means the image is being downloaded. - * is_image2 FALSE means the loader is being downloaded. - */ - if (ssp->loader_running && !is_image2) { - cmn_err(CE_WARN, "Attempt to download loader image " - "with loader image already active"); - cmn_err(CE_CONT, "This maybe an attempt to restart a " - "failed firmware download - ignoring download attempt"); - return (B_FALSE); - } else if (!ssp->loader_running && is_image2) { - cmn_err(CE_WARN, "Attempt to download firmware image " - "without loader image active"); - return (B_FALSE); - - } - - return (B_TRUE); -} - -static uint32_t -bscv_get_pagesize(bscv_soft_state_t *ssp) -{ - uint32_t pagesize; - - ASSERT(bscv_held(ssp)); - - pagesize = bscv_get32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PAGE0)); - - BSCV_TRACE(ssp, 'U', "bscv_get_pagesize", "pagesize 0x%x", pagesize); - - return (pagesize); -} - -/* - * Sets the pagesize, returning the old value. - */ -static uint32_t -bscv_set_pagesize(bscv_soft_state_t *ssp, uint32_t pagesize) -{ - uint32_t old_pagesize; - - ASSERT(bscv_held(ssp)); - - old_pagesize = bscv_get_pagesize(ssp); - - /* - * The microcontroller remembers this value until until someone - * changes it. - */ - bscv_put32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PSIZ0), pagesize); - - return (old_pagesize); -} - -static uint8_t -bscv_enter_programming_mode(bscv_soft_state_t *ssp) -{ - uint8_t retval; - - ASSERT(bscv_held(ssp)); - - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), - EBUS_PROGRAM_PCR_PRGMODE_ON); - - retval = bscv_get8(ssp, chan_prog, BSCVA(EBUS_CMD_SPACE_PROGRAM, - EBUS_PROGRAM_PCSR)); - - return (retval); -} - -static void -bscv_leave_programming_mode(bscv_soft_state_t *ssp, boolean_t with_jmp) -{ - uint8_t reg; - ASSERT(bscv_held(ssp)); - - if (with_jmp) { - reg = EBUS_PROGRAM_PCR_PROGOFF_JUMPTOADDR; - BSCV_TRACE(ssp, 'U', "bscv_leave_programming_mode", - "jumptoaddr"); - } else { - reg = EBUS_PROGRAM_PCR_PRGMODE_OFF; - BSCV_TRACE(ssp, 'U', "bscv_leave_programming_mode", - "prgmode_off"); - } - - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), reg); -} - - -static void -bscv_set_jump_to_addr(bscv_soft_state_t *ssp, uint32_t loadaddr) -{ - ASSERT(bscv_held(ssp)); - - bscv_put32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PADR0), loadaddr); - - BSCV_TRACE(ssp, 'U', "bscv_set_jump_to_addr", - "set jump to loadaddr 0x%x", loadaddr); -} - -static uint8_t -bscv_erase_once(bscv_soft_state_t *ssp, uint32_t loadaddr, uint32_t image_size) -{ - uint8_t retval; - - ASSERT(bscv_held(ssp)); - - /* - * write PADR, PSIZ to define area to be erased - * We do not send erase for zero size because the current - * downloader gets this wrong - */ - - /* - * start at 0 - */ - BSCV_TRACE(ssp, 'U', "bscv_erase_once", "sending erase command"); - - bscv_put32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PADR0), - loadaddr); - - /* set PSIZ to full size of image to be programmed */ - bscv_put32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PSIZ0), - image_size); - - /* write ERASE to PCSR */ - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), - EBUS_PROGRAM_PCR_ERASE); - - /* read PCSR to check status */ - retval = bscv_get8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR)); - return (retval); -} - -static uint8_t -bscv_do_erase(bscv_soft_state_t *ssp, uint32_t loadaddr, uint32_t image_size, - boolean_t is_image2) -{ - int retryable = BSC_ERASE_RETRY_LIMIT; - uint8_t retval; - - while (retryable--) { - retval = bscv_erase_once(ssp, loadaddr, image_size); - if (PSR_SUCCESS(retval)) - break; - else - cmn_err(CE_WARN, "erase error 0x%x, attempt %d" - ", base 0x%x, size 0x%x, %s image", - retval, BSC_ERASE_RETRY_LIMIT - retryable, - loadaddr, image_size, - is_image2 ? "main" : "loader"); - } - - return (retval); -} - -static uint8_t -bscv_set_page(bscv_soft_state_t *ssp, uint32_t addr) -{ - uint32_t retval; - int retryable = BSC_PAGE_RETRY_LIMIT; - - ASSERT(bscv_held(ssp)); - - while (retryable--) { - - /* - * Write the page address and read it back for confirmation. - */ - bscv_put32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PADR0), - addr); - retval = bscv_get32(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PADR0)); - - if (retval == addr) - break; - else { - cmn_err(CE_WARN, "programmming error, attempt %d, " - "set page 0x%x, read back 0x%x", - BSC_PAGE_RETRY_LIMIT - retryable, - addr, retval); - } - } - return ((addr == retval) ? EBUS_PROGRAM_PSR_SUCCESS : - EBUS_PROGRAM_PSR_INVALID_OPERATION); -} - -static uint8_t -bscv_do_page_data_once(bscv_soft_state_t *ssp, uint32_t index, - uint32_t image_size, uint32_t pagesize, uint8_t *imagep, - uint16_t *calcd_chksum) -{ - uint32_t size; - uint16_t chksum; - int i; - uint8_t retval; - - ASSERT(bscv_held(ssp)); - - BSCV_TRACE(ssp, 'P', "bscv_do_page_data_once", "index 0x%x", index); - - /* write PSIZ bytes to PDAT */ - if (index + pagesize < image_size) { - bscv_rep_rw8(ssp, chan_prog, imagep + index, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_DATA), - pagesize, DDI_DEV_NO_AUTOINCR, B_TRUE /* write */); - size = pagesize; - } else { - BSCV_TRACE(ssp, 'P', "bscv_do_page_once", - "Sending last block, last 0x%x bytes", - (image_size % pagesize)); - size = (image_size - index); - bscv_rep_rw8(ssp, chan_prog, imagep + index, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_DATA), - size, DDI_DEV_NO_AUTOINCR, B_TRUE /* write */); - /* Now pad the rest of the page with zeros */ - for (i = size; i < pagesize; i++) { - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, - EBUS_PROGRAM_DATA), - 0); - } - } - - /* write the checksum to PCSM */ - chksum = 0; - for (i = 0; i < size; i++) { - chksum = ((chksum << 3) | (chksum >> 13)) ^ - *(imagep + index + i); - } - /* Cope with non-pagesize sized bufers */ - for (; i < pagesize; i++) { - chksum = ((chksum << 3) | (chksum >> 13)) ^ 0; - } - bscv_put16(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSM0), chksum); - - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), - EBUS_PROGRAM_PCR_PROGRAM); - - retval = bscv_get8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR)); - - *calcd_chksum = chksum; - return (retval); -} - -static uint8_t bscv_do_page(bscv_soft_state_t *ssp, uint32_t loadaddr, - uint32_t index, uint32_t image_size, uint32_t pagesize, uint8_t *imagep, - boolean_t is_image2) -{ - int retryable = BSC_PAGE_RETRY_LIMIT; - uint8_t retval; - uint16_t checksum; - - BSCV_TRACE(ssp, 'P', "bscv_do_page", "index 0x%x", index); - - while (retryable--) { - /* - * Set the page address (with retries). If this is not - * successful, then there is no point carrying on and sending - * the page's data since that could cause random memory - * corruption in the microcontroller. - */ - retval = bscv_set_page(ssp, loadaddr + index); - if (!PSR_SUCCESS(retval)) { - cmn_err(CE_WARN, "programming error 0x%x, " - "could not setup page address 0x%x, %s image", - retval, loadaddr + index, - is_image2 ? "main" : "loader"); - break; - } - - /* - * Send down the data for the page - */ - - BSCV_TRACE(ssp, 'P', "bscv_do_page", "sending data for page"); - - retval = bscv_do_page_data_once(ssp, index, image_size, - pagesize, imagep, &checksum); - if (PSR_SUCCESS(retval)) - break; - else - cmn_err(CE_WARN, "programming error 0x%x," - " attempt %d, index 0x%x, checksum 0x%x, %s image", - retval, BSC_PAGE_RETRY_LIMIT - retryable, - index, checksum, is_image2 ? "main" : "loader"); - } - - BSCV_TRACE(ssp, 'U', "bscv_do_page", "Returning 0x%x for index 0x%x," - " checksum 0x%x, %s image", retval, index, checksum, - is_image2 ? "main" : "loader"); - - return (retval); -} - -static uint8_t -bscv_do_pages(bscv_soft_state_t *ssp, uint32_t loadaddr, uint32_t image_size, - uint32_t pagesize, uint8_t *imagep, boolean_t is_image2) -{ - uint8_t retval; - uint32_t index; - - BSCV_TRACE(ssp, 'P', "bscv_do_pages", "entered"); - - for (index = 0; index < image_size; index += pagesize) { - retval = bscv_do_page(ssp, loadaddr, index, image_size, - pagesize, imagep, is_image2); - if (bscv_faulty(ssp) || !PSR_SUCCESS(retval)) { - BSCV_TRACE(ssp, 'U', "bscv_do_pages", - "Failed to program lom (status 0x%x)", retval); - break; - } - } - - return (retval); -} - -static int -bscv_prog_image(bscv_soft_state_t *ssp, boolean_t is_image2, - uint8_t *imagep, int image_size, uint32_t loadaddr) -{ - uint32_t pagesize; - int res = 0; - uint8_t retval; - - BSCV_TRACE(ssp, 'U', "bscv_prog_image", - "image 0x%x, imagep %p, size 0x%x", - is_image2 ? 2 : 1, imagep, image_size); - - if (!bscv_check_loader_config(ssp, is_image2)) - /* - * Return no error to allow userland to continue on with - * downloading the image. - */ - return (0); - - bscv_enter(ssp); - - pagesize = bscv_get_pagesize(ssp); - - retval = bscv_enter_programming_mode(ssp); - if (bscv_faulty(ssp) || !PSR_PROG(retval)) { - cmn_err(CE_WARN, "lom: Failed to enter program mode, error 0x%x" - ", %s image", retval, is_image2 ? "main" : "loader"); - res = EIO; - goto BSCV_PROG_IMAGE_END; - } - BSCV_TRACE(ssp, 'U', "bscv_prog_image", "entered programming mode"); - - /* - * Only issue an erase if we are downloading the image. The loader - * does not need this step. - */ - if (is_image2 && (image_size != 0)) { - retval = bscv_do_erase(ssp, loadaddr, image_size, is_image2); - if (bscv_faulty(ssp) || !PSR_SUCCESS(retval)) { - cmn_err(CE_WARN, - "lom: Erase failed during programming, status 0x%x", - retval); - res = EIO; - goto BSCV_PROG_IMAGE_END; - } else { - BSCV_TRACE(ssp, 'U', "bscv_prog_image", - "erase complete - programming..."); - - } - } - - (void) bscv_set_pagesize(ssp, pagesize); - - retval = bscv_do_pages(ssp, loadaddr, image_size, pagesize, imagep, - is_image2); - if (bscv_faulty(ssp) || !PSR_SUCCESS(retval)) { - BSCV_TRACE(ssp, 'U', "bscv_prog_image", - "Failed to program lom (status 0x%x)", retval); - res = EIO; - goto BSCV_PROG_IMAGE_END; - } - -BSCV_PROG_IMAGE_END: - if (res == 0 && !is_image2) { - /* - * We've downloaded the loader successfully. Now make the - * microcontroller jump to it. - */ - bscv_set_jump_to_addr(ssp, loadaddr); - ssp->loader_running = B_TRUE; - bscv_leave_programming_mode(ssp, B_TRUE); - } else { - /* - * We've just downloaded either the loader which failed, or - * the image (which may or may not have been successful). - */ - bscv_set_jump_to_addr(ssp, 0); - - if (res != 0) { - BSCV_TRACE(ssp, 'U', "bscv_prog_image", - "got error 0x%x - leaving programming mode", - res); - cmn_err(CE_WARN, "programming error 0x%x, %s image", - res, is_image2 ? "main" : "loader"); - } else { - BSCV_TRACE(ssp, 'U', "bscv_prog_image", - "programming complete - leaving programming mode"); - } - - bscv_leave_programming_mode(ssp, B_FALSE); - ssp->loader_running = B_FALSE; - } - - bscv_exit(ssp); - - return (res); -} - - -static int -bscv_prog_receive_image(bscv_soft_state_t *ssp, lom_prog_t *prog, - uint8_t *imagep, int max_size) -{ - int res = 0; - uint_t size; - int32_t loadaddr; - lom_prog_data_t *prog_data; - - if ((prog->index & 0x7FFF) != ssp->prog_index) { - BSCV_TRACE(ssp, 'U', "bscv_prog_receive_image", - "Got wrong buffer 0x%x, expected 0x%x", - prog->index & 0x7fff, ssp->prog_index); - return (EINVAL); - } - - /* - * We want to get the whole image and then do the download. - * It is assumed the device is now in programming mode. - */ - - if ((prog->index & 0x7fff) == 0) { - /* Starting a new image */ - ssp->image_ptr = 0; - } - - if ((ssp->image_ptr + prog->size) > max_size) { - cmn_err(CE_WARN, - "lom image exceeded maximum size: got 0x%x, maximum 0x%x", - (ssp->image_ptr + prog->size), max_size); - return (EFAULT); - } - bcopy(prog->data, &imagep[ssp->image_ptr], prog->size); - ssp->image_ptr += prog->size; - - ssp->prog_index++; - - if (prog->index & 0x8000) { - /* - * OK we have the whole image so synch up and start download. - */ - prog_data = (lom_prog_data_t *)imagep; - if (prog_data->header.magic != PROG_MAGIC) { - /* Old style programming data */ - /* Take care image may not fill all of structure */ - - /* sign extend loadaddr from 16 to 32 bits */ - loadaddr = (int16_t)((uint16_t)((imagep[2] << 8) + - imagep[3])); - - size = (imagep[0] << 8) + imagep[1]; - if (size != (ssp->image_ptr - 4)) { - cmn_err(CE_WARN, "Image size mismatch:" - " expected 0x%x, got 0x%x", - size, (ssp->image_ptr - 1)); - } - - res = bscv_prog_image(ssp, - ssp->image2_processing, - imagep + 4, ssp->image_ptr - 4, loadaddr); - - /* - * Done the loading so set the flag to say we are doing - * the other image. - */ - ssp->image2_processing = !ssp->image2_processing; - } else if ((ssp->image_ptr < sizeof (*prog_data)) || - (prog_data->platform.bscv.size != - (ssp->image_ptr - sizeof (*prog_data)))) { - /* Image too small for new style image */ - cmn_err(CE_WARN, "image too small"); - res = EINVAL; - } else { - /* New style programming image */ - switch (prog_data->platmagic) { - case PROG_PLAT_BSCV_IMAGE: - res = bscv_prog_image(ssp, B_TRUE, - imagep + sizeof (*prog_data), - prog_data->platform.bscv.size, - prog_data->platform.bscv.loadaddr); - ssp->image2_processing = B_FALSE; - break; - case PROG_PLAT_BSCV_LOADER: - res = bscv_prog_image(ssp, B_FALSE, - imagep + sizeof (*prog_data), - prog_data->platform.bscv.size, - prog_data->platform.bscv.loadaddr); - ssp->image2_processing = B_TRUE; - break; - default: - cmn_err(CE_WARN, "unknown platmagic 0x%x", - prog_data->platmagic); - res = EINVAL; - break; - } - } - ssp->prog_index = 0; - ssp->image_ptr = 0; - } - return (res); -} - -static int -bscv_prog_stop_lom(bscv_soft_state_t *ssp) -{ - if (ssp->programming) { - /* - * Already programming - this may be a retry of a failed - * programming attempt or just a software error! - */ - goto queue_stopped; - } - - if (bscv_pause_event_daemon(ssp) == BSCV_FAILURE) { - BSCV_TRACE(ssp, 'Q', "bscv_prog_stop_lom", - "failed to pause event daemon thread"); - return (EAGAIN); - } - - bscv_enter(ssp); - - ssp->programming = B_TRUE; - - bscv_exit(ssp); - -queue_stopped: - - ssp->prog_index = 0; - ssp->image2_processing = B_FALSE; - - return (0); -} - -static int -bscv_prog_start_lom(bscv_soft_state_t *ssp) -{ - int res = 0; - - if (!ssp->programming) { - /* Not programming so this is not a valid command */ - return (EINVAL); - } - - if (ssp->image != NULL) { - kmem_free((void *)ssp->image, BSC_IMAGE_MAX_SIZE); - ssp->image = NULL; - } - - /* - * OK we are out of reset now so: - * Probe the firmware and set everything up. - */ - - bscv_enter(ssp); - - /* Explicit clear fault because things may have been mended now */ - bscv_clear_fault(ssp); - - if (ssp->loader_running) { - cmn_err(CE_WARN, "Firmware upgrade failed to exit loader - " - "performing forced exit"); - /* Must try to restart the lom here. */ - /* Ensure prog mode entry to enable PRGMODE_OFF */ - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), - EBUS_PROGRAM_PCR_PRGMODE_ON); - bscv_put8(ssp, chan_prog, - BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), - EBUS_PROGRAM_PCR_PRGMODE_OFF); - ssp->loader_running = B_FALSE; - /* give the lom chance to recover */ - delay(drv_usectohz(5000000)); /* 5 seconds */ - } - - ssp->prog_mode_only = B_FALSE; - ssp->programming = B_FALSE; - - if (bscv_attach_common(ssp) == DDI_FAILURE) { - ssp->prog_mode_only = B_TRUE; - res = EIO; - } - - bscv_exit(ssp); - - if (!ssp->prog_mode_only) { - /* - * Start the event thread after the queue has started - * - * Not sure if this is entirely correct because - * the other code at the end of bscv_attach() - * does not get run here. - */ - bscv_start_event_daemon(ssp); - bscv_resume_event_daemon(ssp); - } - - return (res); -} - - -/* - * ********************************************************************* - * Attach processing - * ********************************************************************* - */ - -/* - * function - bscv_attach_common - * description - this routine co-ordinates the initialisation of the - * driver both at attach time and after firmware programming. - * sequence - bscv_setup_capability - read LOMlite2 capabilities - * bscv_probe_check - test comms and setup register cache - * bscv_setup_hostname - sync stored name in lom with nodename. - * bscv_setup_static_info - read device names etc. - * bscv_setup_events - start event daemon etc. - * - * inputs - device information structure, DDI_ATTACH command - * outputs - DDI_SUCCESS or DDI_FAILURE - */ - -static int -bscv_attach_common(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - - BSCV_TRACE(ssp, 'A', "bscv_attach_common:", ""); - - /* - * Set the threshold for reporting messages to the console to - * Warnings or higher. - */ - ssp->reporting_level = 2; - - /* - * When the system is not running the Operating System, make - * the microcontroller print event messages straight onto the - * console. - */ - ssp->serial_reporting = LOM_SER_EVENTS_DEF; - - /* Setup capabilities */ - bscv_setup_capability(ssp); - - if (bscv_probe_check(ssp) == DDI_FAILURE) { - cmn_err(CE_WARN, "BSC chip not responding"); - /* - * We want lom -G to talk to this driver upon broken firmware - * so we prematurely return success here. - */ - return (DDI_SUCCESS); - } - - bscv_setup_hostname(ssp); - bscv_setup_static_info(ssp); - bscv_setup_events(ssp); - -#if defined(__i386) || defined(__amd64) - bscv_inform_bsc(ssp, BSC_INFORM_ONLINE); -#endif /* __i386 || __amd64 */ - /* - * Watchdog configuration and CPU signatures are sent asynchronously - * with respect to attach so only inform the BSC if we've already - * sent the data in the past. - */ - - if (ssp->progress & BSCV_WDOG_CFG) - bscv_setup_watchdog(ssp); - -#ifdef __sparc - if (ssp->progress & BSCV_SIG_SENT) - bscv_write_sig(ssp, ssp->last_sig); -#endif /* __sparc */ - - return (DDI_SUCCESS); -} - -/* - * function - bscv_cleanup - * description - routine that does the necessary tidying up if the attach - * request fails or the driver is to be detached. - * If the event thread has been started we may fail to - * stop it (because it is busy) so we fail the cleanup - * and hence the detach. All other calls to bscv_cleanup - * are done before the event daemon is started. - * inputs - soft state structure address. - * outputs - DDI_SUCCESS or DDI_FAILURE. - */ - -static int -bscv_cleanup(bscv_soft_state_t *ssp) -{ - int instance; - uint8_t bits2set; - uint8_t bits2clear; - - instance = ssp->instance; - - if (ssp->progress & BSCV_LOCKS) { - bscv_enter(ssp); - } - - if (ssp->progress & BSCV_THREAD) { - if (bscv_stop_event_daemon(ssp) == DDI_FAILURE) { - /* Fail the cleanup - may be able to cleanup later */ - if (ssp->progress & BSCV_LOCKS) { - bscv_exit(ssp); - } - return (DDI_FAILURE); - } - } - - if (ssp->progress & BSCV_NODES) { - ddi_remove_minor_node(ssp->dip, NULL); - } - - if (ssp->progress & BSCV_MAPPED_REGS) { - /* - * switch back on serial event reporting - cover all configs. - */ - bits2set = 0; - bits2clear = 0; - if (ssp->serial_reporting == LOM_SER_EVENTS_ON) { - bits2clear |= EBUS_ALARM_NOEVENTS; - } else if (ssp->serial_reporting == LOM_SER_EVENTS_OFF) { - bits2set |= EBUS_ALARM_NOEVENTS; - } else if (ssp->serial_reporting == LOM_SER_EVENTS_DEF) { - bits2clear |= EBUS_ALARM_NOEVENTS; - } - bscv_setclear8_volatile(ssp, chan_general, EBUS_IDX_ALARM, - bits2set, bits2clear); - - /* - * disable the reset function if we have enabled - * it. We don't want any nasty surprises like system - * rebooting unexpectedly. If we timeout on the busy - * flag we just have to carry on. - */ - - BSCV_TRACE(ssp, 'W', "bscv_cleanup", - "bscv_cleanup - disable wdog"); - if (bscv_get8_cached(ssp, EBUS_IDX_WDOG_CTRL) & - EBUS_WDOG_ENABLE) { - bscv_setclear8(ssp, chan_general, EBUS_IDX_WDOG_CTRL, - 0, EBUS_WDOG_RST | EBUS_WDOG_ENABLE); - } - } - - /* - * unmap registers - */ - - if (ssp->progress & BSCV_MAPPED_REGS) { - bscv_unmap_regs(ssp); - } - - /* - * release any memory allocated for mutexes and condition - * variables before deallocating the structures containing them - */ - - if (ssp->progress & BSCV_LOCKS) { - bscv_exit(ssp); - cv_destroy(&ssp->task_cv); - cv_destroy(&ssp->task_evnt_cv); - mutex_destroy(&ssp->task_mu); - mutex_destroy(&ssp->prog_mu); - mutex_destroy(&ssp->cmd_mutex); - } - - if (ssp->image != NULL) { - kmem_free((void *)ssp->image, BSC_IMAGE_MAX_SIZE); - } - -#if defined(__i386) || defined(__amd64) - bscv_watchdog_cyclic_remove(ssp); -#endif /* __i386 || __amd64 */ - ddi_soft_state_free(bscv_statep, instance); - - return (DDI_SUCCESS); -} - -/* - * function - bscv_setup_capability - * description - probe the lom find what capabilities are present for - * us to use. - * inputs - soft state ptr - * outputs - returns DDI_SUCCESS or DDI_FAILURE - */ -static void bscv_setup_capability(bscv_soft_state_t *ssp) -{ - ASSERT(bscv_held(ssp)); - - if (ssp->prog_mode_only) { - /* Turn off all capabilities */ - ssp->cap0 = 0; - ssp->cap1 = 0; - ssp->cap2 = 0; - return; - } - - ssp->cap0 = bscv_get8(ssp, chan_general, EBUS_IDX_CAP0); - ssp->cap1 = bscv_get8(ssp, chan_general, EBUS_IDX_CAP1); - ssp->cap2 = bscv_get8(ssp, chan_general, EBUS_IDX_CAP2); - if (!bscv_faulty(ssp)) { - BSCV_TRACE(ssp, 'A', "bscv_setup_capability", - "Capability flags cap0=0x%x cap1=0x%x, cap2=0x%x", - ssp->cap0, ssp->cap1, ssp->cap2); - } else { - cmn_err(CE_WARN, "!Could not read capability flags"); - ssp->cap0 = 0; ssp->cap1 = 0; ssp->cap2 = 0; - } -} - -/* - * function - bscv_probe_check - * description - probe the lom to check for correct operation - * has a side effect of setting up the cached registers and - * updates ssp->prog_mode_only. - * inputs - soft state ptr - * outputs - returns DDI_SUCCESS or DDI_FAILURE - */ - -static int bscv_probe_check(bscv_soft_state_t *ssp) -{ - int i; - uint8_t probeval; - - ASSERT(bscv_held(ssp)); - - BSCV_TRACE(ssp, 'A', "bscv_probe_check", ""); - - if (!ssp->prog_mode_only) { - /* - * Make sure probe location is OK so that we are - * in sync. - * We want to make sure that this is not faulty so we - * do a bscv_clear_fault to clear any existing - * fault records down. - */ - bscv_clear_fault(ssp); - probeval = bscv_get8(ssp, chan_general, EBUS_IDX_PROBEAA); - if (bscv_faulty(ssp)) { - ssp->prog_mode_only = B_TRUE; - } else if (probeval != 0xAA) { - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "LOMlite out of sync"); - - /* - * It may be that the LOMlite was out of - * sync so lets try the read again. - */ - probeval = bscv_get8(ssp, chan_general, - EBUS_IDX_PROBEAA); - if (bscv_faulty(ssp)) { - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "Init readAA1 failed"); - ssp->prog_mode_only = B_TRUE; - } else if (probeval != 0xAA) { - /* - * OK that is twice we are out so I - * guess the LOMlite is in trouble - */ - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "Init readAA probe failed - got 0x%x", - probeval); - ssp->prog_mode_only = B_TRUE; - } - } - } - - /* - * Read in all page zero lom registers. - * Read state change 1st so we dont miss anything and clear it. - * Note: we discard the values because we rely on bscv_get8 to - * setup the cache of register values. - */ - - if (!ssp->prog_mode_only) { - (void) bscv_get8(ssp, chan_general, EBUS_IDX_STATE_CHNG); - if (bscv_faulty(ssp)) { - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "Read of state change register failed"); - ssp->prog_mode_only = B_TRUE; - } - } - - if (!ssp->prog_mode_only) { - for (i = 1; i < 0x80; i++) { - switch (i) { - case EBUS_IDX_STATE_CHNG: - case EBUS_IDX_CMD_RES: - case EBUS_IDX_HNAME_CHAR: - /* - * Should not read these - they have side - * effects. - */ - break; - default: - (void) bscv_get8(ssp, chan_general, i); - break; - } - if (bscv_faulty(ssp)) { - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "Initial read or register %2x failed", i); - ssp->prog_mode_only = B_TRUE; - /* Might as well give up now! */ - break; - } - } - } - - /* - * Check the probe keys so we know the lom is OK - */ - - if (!ssp->prog_mode_only) { - if ((bscv_get8_cached(ssp, EBUS_IDX_PROBE55) != 0x55) || - (bscv_get8_cached(ssp, EBUS_IDX_PROBEAA) != 0xAA)) { - - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "LOMlite Probe failed"); - for (i = 0; i < 0x8; i++) { - BSCV_TRACE(ssp, 'A', "bscv_probe_check", - "%2x %2x %2x %2x %2x %2x %2x %2x %2x " - "%2x %2x %2x %2x %2x %2x %2x %2x %2x", - bscv_get8_cached(ssp, i), - bscv_get8_cached(ssp, i + 1), - bscv_get8_cached(ssp, i + 2), - bscv_get8_cached(ssp, i + 3), - bscv_get8_cached(ssp, i + 4), - bscv_get8_cached(ssp, i + 5), - bscv_get8_cached(ssp, i + 6), - bscv_get8_cached(ssp, i + 7), - bscv_get8_cached(ssp, i + 8), - bscv_get8_cached(ssp, i + 9), - bscv_get8_cached(ssp, i + 10), - bscv_get8_cached(ssp, i + 11), - bscv_get8_cached(ssp, i + 12), - bscv_get8_cached(ssp, i + 13), - bscv_get8_cached(ssp, i + 14), - bscv_get8_cached(ssp, i + 15)); - } - ssp->prog_mode_only = B_TRUE; - } - } - - return ((ssp->prog_mode_only == B_FALSE) ? DDI_SUCCESS : DDI_FAILURE); -} - -#ifdef __sparc -/* - * function - bscv_idi_set - * description - bscv inter driver interface set function - * inputs - structure which defines type of service required and data - * ouputs - none - * - * This is the Entry Point function for the platmod driver. It works out which - * X Bus channel ought to deliver the service requested. - */ -void -bscv_idi_set(struct bscv_idi_info info) -{ - struct bscv_idi_callout *tbl; - boolean_t retval; - - ASSERT(bscv_idi_mgr.magic == BSCV_IDI_CALLOUT_MAGIC); - - if (bscv_idi_mgr.tbl == NULL) { - if (bscv_idi_err()) - cmn_err(CE_WARN, "!bscv_idi_set : cannot find " - "bscv_callout_table"); - return; - } else if (bscv_idi_mgr.valid_inst == (uint32_t)~0) { - if (bscv_idi_err()) - /* - * This error message can appear in the context of - * another driver, say platmod or todblade. We want - * to clearly indicate the culprit driver so put in - * the driver name. - */ - cmn_err(CE_WARN, "!bscv_idi_set : no valid " - "driver instance of " - MYNAME); - return; - } - - tbl = bscv_idi_mgr.tbl; - - while (tbl->type != BSCV_IDI_NULL) { - if (tbl->type == info.type) { - /* - * We service the request with a valid instance number - * for the driver. - */ - retval = ((tbl->fn) (info)); - - /* - * If the request was serviced, clear any accumulated - * error counters so future warnings will be reported if - * seen. - */ - if (retval == B_TRUE) - bscv_idi_clear_err(); - return; - } else { - tbl++; - } - } - - if (bscv_idi_err()) - cmn_err(CE_WARN, "!bscv_idi_set : cannot match info.type %d", - info.type); -} - -/* - * function - bscv_nodename_set - * description - notify the event thread that a nodename change has occurred. - * inputs - data from client driver - * outputs - none. - * side-effects - the event thread will schedule an update to the lom firmware. - */ -/*ARGSUSED*/ -static boolean_t -bscv_nodename_set(struct bscv_idi_info info) -{ - bscv_soft_state_t *ssp; - - ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst); - - if (ssp == NULL) { - if (bscv_idi_err()) - cmn_err(CE_WARN, "!blade_nodename_set: cannot get ssp"); - return (B_FALSE); - } - - /* Get a lock on the SSP, notify our change, then exit */ - mutex_enter(&ssp->task_mu); - ssp->nodename_change = B_TRUE; - cv_signal(&ssp->task_cv); - mutex_exit(&ssp->task_mu); - - return (B_TRUE); -} - -/* - * function - bscv_sig_set - * description - write a signature - * inputs - data from client driver - * outputs - none. - */ -static boolean_t -bscv_sig_set(struct bscv_idi_info info) -{ - bscv_soft_state_t *ssp; - bscv_sig_t sig; - - ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst); - - if (ssp == NULL) { - if (bscv_idi_err()) - cmn_err(CE_WARN, "!blade_nodename_set: cannot get ssp"); - return (B_FALSE); - } - - /* Service the request */ - bcopy(info.data, &sig, sizeof (sig)); - bscv_enter(ssp); - bscv_write_sig(ssp, sig); - bscv_exit(ssp); - - return (B_TRUE); -} -#endif /* __sparc */ - -static void -bscv_wdog_do_pat(bscv_soft_state_t *ssp) -{ - uint8_t pat; - - /* - * The value of the dog pat is a sequence number which wraps around, - * bounded by BSCV_WDOG_PAT_SEQ_MASK. - */ - pat = ssp->pat_seq++; - pat &= EBUS_WDOG_NB_PAT_SEQ_MASK; - - /* Set top nibble to indicate a pat */ - pat |= EBUS_WDOG_NB_PAT; - - /* - * Now pat the dog. This exercises a special protocol in the - * bus nexus that offers : non-blocking IO, and timely delivery, - * callable from high-level interrupt context. The requirement - * on us is that the channel is not shared for any other use. - * This means for chan_wdogpat, nothing may use channel[chan].regs - * or channel.[chan].handle. - */ - - ddi_put8(ssp->channel[chan_wdogpat].handle, - ssp->channel[chan_wdogpat].regs, pat); - - BSCV_TRACE(ssp, 'W', "bscv_wdog_pat", "patted the dog with seq %d", - pat); -} - -#ifdef __sparc -/* - * function - bscv_wdog_pat - * description - pat the watchdog - * inputs - data from client driver - * outputs - none. - */ -/*ARGSUSED*/ -static boolean_t -bscv_wdog_pat(struct bscv_idi_info info) -{ - /* - * This function remembers if it has ever been called with the - * configure option set. - */ - bscv_soft_state_t *ssp; - - ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst); - - if (ssp == NULL) { - if (bscv_idi_err()) - cmn_err(CE_WARN, "!bscv_wdog_pat: cannot get ssp"); - return (B_FALSE); - } else if (ssp->nchannels == 0) { - /* Didn't manage to map handles so ddi_{get,put}* broken */ - if (bscv_idi_err()) - cmn_err(CE_WARN, "!bscv_wdog_pat: handle not mapped"); - return (B_FALSE); - } - - bscv_wdog_do_pat(ssp); - return (B_TRUE); -} - -/* - * function - bscv_wdog_cfg - * description - configure the watchdog - * inputs - data from client driver - * outputs - none. - */ -static boolean_t -bscv_wdog_cfg(struct bscv_idi_info info) -{ - bscv_soft_state_t *ssp; - - ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst); - - if (ssp == NULL) { - if (bscv_idi_err()) - cmn_err(CE_WARN, "!bscv_wdog_cfg: cannot get ssp"); - return (B_FALSE); - } else if (ssp->nchannels == 0) { - /* Didn't manage to map handles so ddi_{get,put}* broken */ - if (bscv_idi_err()) - cmn_err(CE_WARN, "!bscv_wdog_cfg: handle not mapped"); - return (B_FALSE); - } - - if (sizeof (bscv_wdog_t) != info.size) { - BSCV_TRACE(ssp, 'W', "bscv_wdog_set", "data passed in is size" - " %d instead of %d", info.size, - sizeof (bscv_wdog_t)); - return (B_FALSE); - } - - BSCV_TRACE(ssp, 'W', "bscv_wdog_cfg", "enable_wdog %s, " - "wdog_timeout_s %d, reset_system_on_timeout %s", - ((bscv_wdog_t *)info.data)->enable_wdog ? "enabled" : "disabled", - ((bscv_wdog_t *)info.data)->wdog_timeout_s, - ((bscv_wdog_t *)info.data)->reset_system_on_timeout ? "yes" : "no"); - bscv_write_wdog_cfg(ssp, - ((bscv_wdog_t *)info.data)->wdog_timeout_s, - ((bscv_wdog_t *)info.data)->enable_wdog, - ((bscv_wdog_t *)info.data)->reset_system_on_timeout); - return (B_TRUE); -} -#endif /* __sparc */ - -static void -bscv_write_wdog_cfg(bscv_soft_state_t *ssp, - uint_t wdog_timeout_s, - boolean_t enable_wdog, - uint8_t reset_system_on_timeout) -{ - uint8_t cfg = EBUS_WDOG_NB_CFG; - - /* - * Configure the timeout value (1 to 127 seconds). - * Note that a policy is implemented at the bsc/ssp which bounds - * the value further. The bounding here is to fit the timeout value - * into the 7 bits the bsc uses. - */ - if (wdog_timeout_s < 1) - ssp->watchdog_timeout = 1; - else if (wdog_timeout_s > 127) - ssp->watchdog_timeout = 127; - else - ssp->watchdog_timeout = wdog_timeout_s; - - /* - * Configure the watchdog on or off. - */ - if (enable_wdog) - cfg |= EBUS_WDOG_NB_CFG_ENB; - else - cfg &= ~EBUS_WDOG_NB_CFG_ENB; - - /* - * Configure whether the microcontroller should reset the system when - * the watchdog expires. - */ - ssp->watchdog_reset_on_timeout = reset_system_on_timeout; - - ddi_put8(ssp->channel[chan_wdogpat].handle, - ssp->channel[chan_wdogpat].regs, cfg); - - /* have the event daemon set the timeout value and whether to reset */ - ssp->watchdog_change = B_TRUE; - - BSCV_TRACE(ssp, 'W', "bscv_wdog_cfg", - "configured the dog with cfg 0x%x", cfg); -} - -/* - * function - bscv_setup_watchdog - * description - setup the bsc watchdog - * inputs - soft state ptr - * outputs - - */ -static void bscv_setup_watchdog(bscv_soft_state_t *ssp) -{ - uint8_t set = 0; - uint8_t clear = 0; -#ifdef __sparc - extern int watchdog_activated; -#endif /* __sparc */ - - ASSERT(bscv_held(ssp)); - - /* Set the timeout */ - bscv_put8(ssp, chan_general, - EBUS_IDX_WDOG_TIME, ssp->watchdog_timeout); - - /* Set whether to reset the system on timeout */ - if (ssp->watchdog_reset_on_timeout) { - set |= EBUS_WDOG_RST; - } else { - clear |= EBUS_WDOG_RST; - } - - if (watchdog_activated) { - set |= EBUS_WDOG_ENABLE; - } else { - clear |= EBUS_WDOG_ENABLE; - } - - /* Set other host defaults */ - clear |= (EBUS_WDOG_BREAK_DISABLE | EBUS_WDOG_AL3_FANPSU - | EBUS_WDOG_AL3_WDOG); - - bscv_setclear8_volatile(ssp, chan_general, EBUS_IDX_WDOG_CTRL, - set, clear); - -#if defined(__i386) || defined(__amd64) - /* start the cyclic based watchdog patter */ - bscv_watchdog_cyclic_add(ssp); -#endif /* __i386 || __amd64 */ - ssp->progress |= BSCV_WDOG_CFG; -} - - -/* - * function - bscv_setup_hostname - * description - setup the lom hostname if different from the nodename - * inputs - soft state ptr - * outputs - none - */ - -static void bscv_setup_hostname(bscv_soft_state_t *ssp) -{ - char host_nodename[128]; - char lom_nodename[128]; - size_t hostlen; - size_t nodelen; - - ASSERT(bscv_held(ssp)); - - /* - * Check machine label is the same as the - * system nodename. - */ - (void) strncpy(host_nodename, utsname.nodename, - sizeof (host_nodename)); - - /* read in lom hostname */ - bscv_read_hostname(ssp, lom_nodename); - - /* Enforce null termination */ - host_nodename[sizeof (host_nodename) - 1] = '\0'; - lom_nodename[sizeof (lom_nodename) - 1] = '\0'; - - hostlen = (size_t)bscv_get8(ssp, chan_general, EBUS_IDX_HNAME_LENGTH); - nodelen = (size_t)strlen(host_nodename); - if ((nodelen > 0) && - ((hostlen != nodelen) || (strcmp((const char *)&lom_nodename, - (const char *)&host_nodename)) || - (hostlen == 0))) { - BSCV_TRACE(ssp, 'A', "bscv_setup_hostname", - "nodename(%s,%d) != bsc label(%s,%d)", - host_nodename, nodelen, lom_nodename, hostlen); - - /* Write new label into LOM EEPROM */ - bscv_write_hostname(ssp, - host_nodename, - (uint8_t)strlen(host_nodename)); - } - - ssp->progress |= BSCV_HOSTNAME_DONE; -} - -/* - * function - bscv_read_hostname - * description - read the current hostname from the lom - * inputs - soft state pointer and buffer to store the hostname in. - * outputs - none - */ - -static void -bscv_read_hostname(bscv_soft_state_t *ssp, char *lom_nodename) -{ - int num_failures; - boolean_t needretry; - int length; - int i; - - ASSERT(bscv_held(ssp)); - - /* - * We have a special failure case here because a retry of a read - * causes data to be lost. Thus we handle the retries ourselves - * and are also responsible for detemining if the lom is faulty - */ - for (num_failures = 0; - num_failures < BSC_FAILURE_RETRY_LIMIT; - num_failures++) { - bscv_clear_fault(ssp); - length = bscv_get8(ssp, chan_general, EBUS_IDX_HNAME_LENGTH); - if (bscv_faulty(ssp)) { - needretry = 1; - } else { - needretry = 0; - for (i = 0; i < length; i++) { - lom_nodename[i] = bscv_get8_once(ssp, - chan_general, EBUS_IDX_HNAME_CHAR); - /* Retry on any error */ - if (bscv_retcode(ssp) != 0) { - needretry = 1; - break; - } - } - /* null terminate for strcmp later */ - lom_nodename[length] = '\0'; - } - if (!needretry) { - break; - } - /* Force the nodename to be empty */ - lom_nodename[0] = '\0'; - } - - if (needretry) { - /* Failure - we ran out of retries */ - cmn_err(CE_WARN, - "bscv_read_hostname: retried %d times, giving up", - num_failures); - ssp->had_fault = B_TRUE; - } else if (num_failures > 0) { - BSCV_TRACE(ssp, 'R', "bscv_read_hostname", - "retried %d times, succeeded", num_failures); - } -} - -/* - * function - bscv_write_hostname - * description - write a new hostname to the lom - * inputs - soft state pointer, pointer to new name, name length - * outputs - none - */ -static void -bscv_write_hostname(bscv_soft_state_t *ssp, - char *host_nodename, uint8_t length) -{ - int num_failures; - boolean_t needretry; - int i; - - ASSERT(bscv_held(ssp)); - - /* - * We have a special failure case here because a retry of a read - * causes data to be lost. Thus we handle the retries ourselves - * and are also responsible for detemining if the lom is faulty - */ - for (num_failures = 0; - num_failures < BSC_FAILURE_RETRY_LIMIT; - num_failures++) { - bscv_clear_fault(ssp); - bscv_put8(ssp, chan_general, EBUS_IDX_HNAME_LENGTH, length); - if (bscv_faulty(ssp)) { - needretry = 1; - } else { - needretry = 0; - for (i = 0; i < length; i++) { - bscv_put8_once(ssp, chan_general, - EBUS_IDX_HNAME_CHAR, host_nodename[i]); - /* Retry on any error */ - if (bscv_retcode(ssp) != 0) { - needretry = 1; - break; - } - } - } - if (!needretry) { - break; - } - } - - if (needretry) { - /* Failure - we ran out of retries */ - cmn_err(CE_WARN, - "bscv_write_hostname: retried %d times, giving up", - num_failures); - ssp->had_fault = B_TRUE; - } else if (num_failures > 0) { - BSCV_TRACE(ssp, 'R', "bscv_write_hostname", - "retried %d times, succeeded", num_failures); - } -} - -/* - * function - bscv_setup_static_info - * description - read in static information from the lom at attach time. - * inputs - soft state ptr - * outputs - none - */ - -static void -bscv_setup_static_info(bscv_soft_state_t *ssp) -{ - uint8_t addr_space_ptr; - uint16_t mask; - uint8_t fanspeed; - int oldtemps[MAX_TEMPS]; - int8_t temp; - int i; - - ASSERT(bscv_held(ssp)); - - /* - * Finally read in some static info like device names, - * shutdown enabled, etc before the queue starts. - */ - - /* - * To get the volts static info we need address space 2 - */ - bzero(&ssp->volts, sizeof (lom_volts_t)); - ssp->volts.num = EBUS_CONFIG2_NSUPPLY_DEC( - bscv_get8(ssp, chan_general, EBUS_IDX_CONFIG2)); - if (ssp->volts.num > MAX_VOLTS) { - cmn_err(CE_WARN, - "lom: firmware reported too many voltage lines. "); - cmn_err(CE_CONT, "Reported %d, maximum is %d", - ssp->volts.num, MAX_VOLTS); - ssp->volts.num = MAX_VOLTS; - } - - BSCV_TRACE(ssp, 'A', "bscv_setup_static_info", - "num volts %d", ssp->volts.num); - (void) bscv_read_env_name(ssp, - EBUS_CMD_SPACE2, - EBUS_IDX2_SUPPLY_NAME_START, - EBUS_IDX2_SUPPLY_NAME_END, - ssp->volts.name, - ssp->volts.num); - - mask = bscv_get8(ssp, chan_general, BSCVA(EBUS_CMD_SPACE2, - EBUS_IDX2_SUPPLY_FATAL_MASK1)) << 8; - mask |= bscv_get8(ssp, chan_general, BSCVA(EBUS_CMD_SPACE2, - EBUS_IDX2_SUPPLY_FATAL_MASK2)); - - for (i = 0; i < ssp->volts.num; i++) { - ssp->volts.shutdown_enabled[i] = - (((mask >> i) & 1) == 0) ? 0 : 1; - } - - /* - * Get the temperature static info and populate initial temperatures. - * Do not destroy old temperature values if the new value is not - * known i.e. if the device is inaccessible. - */ - bcopy(ssp->temps.temp, oldtemps, sizeof (oldtemps)); - - bzero(&ssp->temps, sizeof (lom_temp_t)); - ssp->temps.num = EBUS_CONFIG2_NTEMP_DEC( - bscv_get8(ssp, chan_general, EBUS_IDX_CONFIG2)); - if (ssp->temps.num > MAX_TEMPS) { - cmn_err(CE_WARN, - "lom: firmware reported too many temperatures being " - "monitored."); - cmn_err(CE_CONT, "Reported %d, maximum is %d", - ssp->temps.num, MAX_TEMPS); - ssp->temps.num = MAX_TEMPS; - } - ssp->temps.num_ov = EBUS_CONFIG3_NOTEMP_DEC( - bscv_get8(ssp, chan_general, EBUS_IDX_CONFIG3)); - if (ssp->temps.num_ov > MAX_TEMPS) { - cmn_err(CE_WARN, - "lom: firmware reported too many over temperatures being " - "monitored."); - cmn_err(CE_CONT, "Reported %d, maximum is %d", - ssp->temps.num_ov, MAX_TEMPS); - ssp->temps.num_ov = MAX_TEMPS; - } - BSCV_TRACE(ssp, 'A', "bscv_setup_static_info", - "num temps %d, over temps %d", - ssp->temps.num, ssp->temps.num_ov); - - addr_space_ptr = bscv_read_env_name(ssp, - EBUS_CMD_SPACE4, - EBUS_IDX4_TEMP_NAME_START, - EBUS_IDX4_TEMP_NAME_END, - ssp->temps.name, - ssp->temps.num); - - for (i = 0; i < ssp->temps.num; i++) { - ssp->temps.warning[i] = (int8_t)bscv_get8(ssp, chan_general, - BSCVA(EBUS_CMD_SPACE4, EBUS_IDX4_TEMP_WARN1 + i)); - - /* - * If shutdown is not enabled then set it as zero so - * it is not displayed by the utility. - */ - if ((bscv_get8(ssp, chan_general, BSCVA(EBUS_CMD_SPACE4, - EBUS_IDX4_TEMP_FATAL_MASK)) >> i) & 0x01) { - ssp->temps.shutdown[i] = (int8_t)bscv_get8(ssp, - chan_general, - BSCVA(EBUS_CMD_SPACE4, EBUS_IDX4_TEMP_SDOWN1 + i)); - } else { - ssp->temps.shutdown[i] = 0; - } - } - - for (i = 0; i < ssp->temps.num; i++) { - temp = bscv_get8(ssp, chan_general, EBUS_IDX_TEMP1 + i); - if ((temp <= LOM_TEMP_MAX_VALUE) || - (temp == LOM_TEMP_STATE_NOT_PRESENT)) { - ssp->temps.temp[i] = temp; - } else { - /* New value is not known - use old value */ - ssp->temps.temp[i] = oldtemps[i]; - } - } - - /* - * Check for and skip a single 0xff character between the - * temperature and over temperature names - */ - if (bscv_get8(ssp, chan_general, - BSCVA(EBUS_CMD_SPACE4, addr_space_ptr)) == 0xff) { - addr_space_ptr++; - } - - (void) bscv_read_env_name(ssp, - EBUS_CMD_SPACE4, - addr_space_ptr, - EBUS_IDX4_TEMP_NAME_END, - ssp->temps.name_ov, - ssp->temps.num_ov); - - /* - * To get the CB static info we need address space 3 - */ - bzero(&ssp->sflags, sizeof (lom_sflags_t)); - ssp->sflags.num = EBUS_CONFIG3_NBREAKERS_DEC(bscv_get8(ssp, - chan_general, EBUS_IDX_CONFIG3)); - if (ssp->sflags.num > MAX_STATS) { - cmn_err(CE_WARN, - "lom: firmware reported too many status flags."); - cmn_err(CE_CONT, - "Reported %d, maximum is %d", - ssp->sflags.num, MAX_STATS); - ssp->sflags.num = MAX_STATS; - } - BSCV_TRACE(ssp, 'A', "bscv_setup_static_info", - "num sflags %d", ssp->sflags.num); - - (void) bscv_read_env_name(ssp, - EBUS_CMD_SPACE3, - EBUS_IDX3_BREAKER_NAME_START, - EBUS_IDX3_BREAKER_NAME_END, - ssp->sflags.name, - ssp->sflags.num); - - - /* - * To get the fan static info we need address space 5 - */ - ssp->num_fans = EBUS_CONFIG_NFAN_DEC( - bscv_get8(ssp, chan_general, EBUS_IDX_CONFIG)); - if (ssp->num_fans > MAX_FANS) { - cmn_err(CE_WARN, - "lom: firmware reported too many fans. "); - cmn_err(CE_CONT, - "Reported %d, maximum is %d", - ssp->num_fans, MAX_FANS); - ssp->num_fans = MAX_FANS; - } - - for (i = 0; i < ssp->num_fans; i++) { - fanspeed = bscv_get8(ssp, chan_general, - EBUS_IDX_FAN1_SPEED + i); - if ((fanspeed <= LOM_FAN_MAX_SPEED) || - (fanspeed == LOM_FAN_NOT_PRESENT)) { - /* - * Do not destroy previous values unless the - * value is definitive. - */ - ssp->fanspeed[i] = fanspeed; - } - } - - BSCV_TRACE(ssp, 'A', "bscv_setup_static_info", - "num fans %d", ssp->num_fans); - - (void) bscv_read_env_name(ssp, - EBUS_CMD_SPACE5, - EBUS_IDX5_FAN_NAME_START, - EBUS_IDX5_FAN_NAME_END, - ssp->fan_names, - ssp->num_fans); - - /* Get led static information from address space 10 */ - - (void) bscv_read_env_name(ssp, - EBUS_CMD_SPACE_LEDS, - EBUS_IDX10_LED_NAME_START, - EBUS_IDX10_LED_NAME_END, - ssp->led_names, - MAX_LED_ID); -} - -/* - * function - bscv_read_env_name - * description - read in static environment names - * warning changes address space and the caller relies - * on this behaviour. - * inputs - soft state ptr, chosen address space, - * start of name data, end of name data, - * name storage, number of names. - * outputs - next address for reading name data. - */ - -static uint8_t -bscv_read_env_name(bscv_soft_state_t *ssp, - uint8_t addr_space, - uint8_t addr_start, - uint8_t addr_end, - char namebuf[][MAX_LOM2_NAME_STR], - int numnames) -{ - int i; - int nameidx; - int namemax; - unsigned int addr_space_ptr; - uint8_t this_char; - - ASSERT(bscv_held(ssp)); - - BSCV_TRACE(ssp, 'A', "bscv_read_env_name", - "bscv_read_env_name, space %d, start 0x%x, end 0x%x, numnames %d", - addr_space, addr_start, addr_end, numnames); - - addr_space_ptr = addr_start; - - for (i = 0; i < numnames; i++) { - nameidx = 0; - namemax = sizeof (namebuf[i]); - bzero(namebuf[i], namemax); - - while (addr_space_ptr <= addr_end) { - /* - * Read the current character. - */ - this_char = bscv_get8(ssp, chan_general, - BSCVA(addr_space, addr_space_ptr)); - - if (this_char == 0xff) { - /* - * Ran out of names - this must - * be the end of the name. - * This is really an error because - * we have just seen either a non-NUL - * terminated string or the number of - * strings did not match what was - * reported. - */ - break; - } - /* - * We increment the buffer pointer now so that - * it is ready for the next read - */ - addr_space_ptr++; - - if (this_char == '\0') { - /* Found end of string - done */ - break; - } - if (nameidx < (namemax - 1)) { - /* - * Buffer not full - record character - * NOTE we always leave room for the NUL - * terminator. - */ - namebuf[i][nameidx++] = this_char; - } - } - /* Ensure null termination */ - namebuf[i][nameidx] = '\0'; - } - /* Clamp addr_space_ptr to 0xff because we return uint8_t */ - if (addr_space_ptr > 0xff) { - addr_space_ptr = 0xff; - } - return (addr_space_ptr); -} - -/* - * function - bscv_setup_events - * description - initialise the event reporting code - * inputs - soft state ptr - * outputs - DDI_SUCCESS or DDI_FAILURE - */ - -static void -bscv_setup_events(bscv_soft_state_t *ssp) -{ - uint8_t bits2set; - uint8_t bits2clear; - - ASSERT(bscv_held(ssp)); - - /* - * deal with event reporting - cover all cases - */ - - bits2set = 0; - bits2clear = 0; - if (ssp->serial_reporting == LOM_SER_EVENTS_ON) { - bits2clear |= EBUS_ALARM_NOEVENTS; - } else if (ssp->serial_reporting == LOM_SER_EVENTS_OFF) { - bits2set |= EBUS_ALARM_NOEVENTS; - } else if (ssp->serial_reporting == LOM_SER_EVENTS_DEF) { - bits2set |= EBUS_ALARM_NOEVENTS; - } - bscv_setclear8_volatile(ssp, chan_general, EBUS_IDX_ALARM, - bits2set, bits2clear); -} - -#ifdef __sparc -/* - * function - bscv_write_sig - * description - write out a signature, taking care to deal with any strange - * values for CPU ID - * inputs - soft state ptr, signature - * outputs - none - */ -static void -bscv_write_sig(bscv_soft_state_t *ssp, bscv_sig_t s) -{ - ASSERT(bscv_held(ssp)); - - /* Upload the signature */ - bscv_put32(ssp, chan_cpusig, - BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_SIG_MSB), - s.sig_info.signature); - - /* - * We always write the CPU ID last because this tells the firmware - * that the signature is fully uploaded and therefore to consume the - * data. This is required since the signature is > 1 byte in size - * and we transmit data in single bytes. - */ - if (s.cpu == ~0) { - /* ~0 means the signature applies to any CPU. */ - bscv_put8(ssp, chan_cpusig, - BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_ID), - EBUS_ANY_CPU_ID); - } else { - if (s.cpu > 255) { - /* - * The CPU ID supplied is unexpectedly large. Lets - * just use the bottom bits, in case other high order - * bits are being used for special meaning. - */ - cmn_err(CE_WARN, "CPU Signature ID 0x%x > 255", s.cpu); - s.cpu %= 256; - cmn_err(CE_CONT, "using ID 0x%x instead ", s.cpu); - } - bscv_put8(ssp, chan_cpusig, - BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_ID), - (uint8_t)s.cpu); - } - - ssp->last_sig = s; - ssp->progress |= BSCV_SIG_SENT; -} -#endif /* __sparc */ - -#if defined(__i386) || defined(__amd64) - -/* - * function - bscv_inform_bsc - * description - inform bsc of driver state for logging purposes - * inputs - driver soft state, state - * outputs - none - * - */ -static void -bscv_inform_bsc(bscv_soft_state_t *ssp, uint32_t state) -{ - ASSERT(bscv_held(ssp)); - - BSCV_TRACE(ssp, 'X', "bscv_inform_bsc", - "bscv_inform_bsc: state=%d", state); - - bscv_put32(ssp, chan_general, - BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_SIG_MSB), state); - bscv_put8(ssp, chan_cpusig, - BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_ID), EBUS_ANY_CPU_ID); -} - -/* - * function - bscv_watchdog_pat_request - * description - request a heartbeat pat - * inputs - timeout value in seconds - * outputs - none - */ -static void -bscv_watchdog_pat_request(void *arg) -{ - bscv_soft_state_t *ssp = (bscv_soft_state_t *)arg; - - bscv_wdog_do_pat(ssp); -} - -/* - * function - bscv_watchdog_cfg_request - * description - request configuration of the bsc hardware watchdog - * inputs - new state (0=disabled, 1=enabled) - * outputs - one if successful, zero if unsuccesful - */ -static void -bscv_watchdog_cfg_request(bscv_soft_state_t *ssp, uint8_t new_state) -{ - ASSERT(new_state == WDOG_ON || new_state == WDOG_OFF); - - watchdog_activated = new_state; - BSCV_TRACE(ssp, 'X', "bscv_watchdog_cfg_request", - "watchdog_activated=%d", watchdog_activated); - bscv_write_wdog_cfg(ssp, - bscv_watchdog_timeout_seconds, - new_state, - wdog_reset_on_timeout); -} - -/* - * function - bscv_set_watchdog_timer - * description - setup the heartbeat timeout value - * inputs - timeout value in seconds - * outputs - zero if the value was not changed - * otherwise the current value - */ -static uint_t -bscv_set_watchdog_timer(bscv_soft_state_t *ssp, uint_t timeoutval) -{ - BSCV_TRACE(ssp, 'X', "bscv_set_watchdog_timer:", - "timeout=%d", timeoutval); - - /* - * We get started during bscv_attach only - * if bscv_watchdog_enable is set. - */ - if (bscv_watchdog_available && (!watchdog_activated || - (watchdog_activated && - (timeoutval != bscv_watchdog_timeout_seconds)))) { - bscv_watchdog_timeout_seconds = timeoutval; - bscv_watchdog_cfg_request(ssp, WDOG_ON); - return (bscv_watchdog_timeout_seconds); - } - return (0); -} - -/* - * function - bscv_clear_watchdog_timer - * description - add the watchdog patter cyclic - * inputs - driver soft state - * outputs - value of watchdog timeout in seconds - * - * This function is a copy of the SPARC implementation - * in the todblade clock driver. - */ -static void -bscv_clear_watchdog_timer(bscv_soft_state_t *ssp) -{ - BSCV_TRACE(ssp, 'X', "bscv_clear_watchdog_timer", ""); - - if (bscv_watchdog_available && watchdog_activated) { - bscv_watchdog_enable = 0; - bscv_watchdog_cfg_request(ssp, WDOG_OFF); - } -} - -/* - * function - bscv_panic_callback - * description - called when we panic so we can disabled the watchdog - * inputs - driver soft state pointer - * outputs - DDI_SUCCESS - */ -/*ARGSUSED1*/ -static boolean_t -bscv_panic_callback(void *arg, int code) -{ - bscv_soft_state_t *ssp = (bscv_soft_state_t *)arg; - - BSCV_TRACE(ssp, 'X', "bscv_panic_callback", - "disabling watchdog"); - - bscv_clear_watchdog_timer(ssp); - /* - * We dont get interrupts during the panic callback. But bscbus - * takes care of all this - */ - bscv_full_stop(ssp); - return (DDI_SUCCESS); -} - -/* - * function - bscv_watchdog_cyclic_add - * description - add the watchdog patter cyclic - * inputs - driver soft state - * outputs - none - */ -static void -bscv_watchdog_cyclic_add(bscv_soft_state_t *ssp) -{ - if (ssp->periodic_id != NULL) { - return; - } - - ssp->periodic_id = ddi_periodic_add(bscv_watchdog_pat_request, ssp, - WATCHDOG_PAT_INTERVAL, DDI_IPL_10); - - BSCV_TRACE(ssp, 'X', "bscv_watchdog_cyclic_add:", - "cyclic added"); -} - -/* - * function - bscv_watchdog_cyclic_remove - * description - remove the watchdog patter cyclic - * inputs - soft state ptr - * outputs - none - */ -static void -bscv_watchdog_cyclic_remove(bscv_soft_state_t *ssp) -{ - if (ssp->periodic_id == NULL) { - return; - } - ddi_periodic_delete(ssp->periodic_id); - ssp->periodic_id = NULL; - BSCV_TRACE(ssp, 'X', "bscv_watchdog_cyclic_remove:", - "cyclic removed"); -} -#endif /* __i386 || __amd64 */ - - -/* - * General utility routines ... - */ - -#ifdef DEBUG - -static void -bscv_trace(bscv_soft_state_t *ssp, char code, const char *caller, - const char *fmt, ...) -{ - char buf[256]; - char *p; - va_list va; - - if (ssp->debug & (1 << (code-'@'))) { - p = buf; - (void) snprintf(p, sizeof (buf) - (p - buf), - "%s/%s: ", MYNAME, caller); - p += strlen(p); - - va_start(va, fmt); - (void) vsnprintf(p, sizeof (buf) - (p - buf), fmt, va); - va_end(va); - - buf[sizeof (buf) - 1] = '\0'; - (void) strlog((short)ssp->majornum, (short)ssp->minornum, code, - SL_TRACE, buf); - } -} - -#else /* DEBUG */ - -_NOTE(ARGSUSED(0)) -static void -bscv_trace(bscv_soft_state_t *ssp, char code, const char *caller, - const char *fmt, ...) -{ -} - -#endif /* DEBUG */ diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index c340476574..d12adf7bd8 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -27,6 +27,7 @@ # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> # Copyright 2017 Nexenta Systems, Inc. # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> +# Copyright 2019 Peter Tribble. # include $(SRC)/uts/Makefile.uts @@ -704,12 +705,8 @@ AUDIOHDRS= \ AVHDRS= \ iec61883.h -BSCHDRS= \ - bscbus.h \ - bscv_impl.h \ - lom_ebuscodes.h \ +LOMHDRS= \ lom_io.h \ - lom_priv.h \ lombus.h MDESCHDRS= \ @@ -1146,7 +1143,7 @@ CHECKHDRS= \ $($(MACH)_HDRS:%.h=%.check) \ $(AUDIOHDRS:%.h=audio/%.check) \ $(AVHDRS:%.h=av/%.check) \ - $(BSCHDRS:%.h=%.check) \ + $(LOMHDRS:%.h=%.check) \ $(CHKHDRS:%.h=%.check) \ $(CPUDRVHDRS:%.h=%.check) \ $(CRYPTOHDRS:%.h=crypto/%.check) \ diff --git a/usr/src/uts/common/sys/bscbus.h b/usr/src/uts/common/sys/bscbus.h deleted file mode 100644 index 0c57cb93f3..0000000000 --- a/usr/src/uts/common/sys/bscbus.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2001-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_BSCBUS_H -#define _SYS_BSCBUS_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The bscbus nexus driver provides the same client interface as the lombus - * nexus driver. - */ -#include <sys/lombus.h> - -/* - * Register spaces (as lombus.h but spaces now have a channel - * value encoded in it too) - * - * Space* Size Range Meaning - * (bits) - * - * xx00 8 [0 .. 16383] LOM virtual registers - * xx01 8 [0] Watchdog pat (on write) - * xx02 16 [0] Async event info (read only) - * All 32 [-4 .. -12] Access handle fault info - * * xx is the channel number. - */ - -#define LOMBUS_SPACE_TO_REGSET(rsp) ((rsp) & 0xff) -#define LOMBUS_SPACE_TO_CHANNEL(rsp) (((rsp) & 0xff00) >> 8) -#define LOMBUS_SPACE(regset, channel) ((regset) | ((channel) << 8)) - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_BSCBUS_H */ diff --git a/usr/src/uts/common/sys/bscv_impl.h b/usr/src/uts/common/sys/bscv_impl.h deleted file mode 100644 index e11f92f6b5..0000000000 --- a/usr/src/uts/common/sys/bscv_impl.h +++ /dev/null @@ -1,369 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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. - */ - -#ifndef _SYS_BSCV_IMPL_H -#define _SYS_BSCV_IMPL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Implementation private header file for bscv driver. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/lom_priv.h> - - -/* - * Local #defines - */ - -#define BSCV_SUCCESS DDI_SUCCESS -#define BSCV_FAILURE DDI_FAILURE - -/* - * The following are used as progress indicators in bscv_attach() - */ - -#define BSCV_LOCKS 0x01 -#define BSCV_MAPPED_REGS 0x02 -#define BSCV_NODES 0x04 -#define BSCV_THREAD 0x08 -#define BSCV_HOSTNAME_DONE 0x10 -#define BSCV_WDOG_CFG 0x20 -#define BSCV_SIG_SENT 0x40 - -/* - * macros to encode device minors and provide mapping to device instances. - * The following is designed to get around the problem of a 32-bit app not - * supporting a 32-bit minor number on an LP64 model system. - */ - -#ifdef NBITSMINOR -#undef NBITSMINOR -#define NBITSMINOR 18 -#endif - -#define BSCV_MONITOR_NODE 0 -#define BSCV_CONTROL_NODE (1 << (NBITSMINOR - 1)) - -#define DEVICETOINSTANCE(x) ((getminor(x)) & (~BSCV_CONTROL_NODE)); - -/* - * The maximum number of leds which are supported by this lom implementation. - */ -#define MAX_LED_ID 7 - -/* - * general driver configuration constants which may be changed to improve - * performance/efficiency. - */ - -#define INIT_BUSY_WAIT 10 /* 10 microsecs */ - -#define MAX_WDOGTIMEOUT 127 /* maximum wdog timout - 127s */ - - -/* - * Event processing task status flags. - */ -#define TASK_ALIVE_FLG 0x01 -#define TASK_STOP_FLG 0x02 -#define TASK_SLEEPING_FLG 0x04 -#define TASK_PAUSE_FLG 0x08 -#define TASK_EVENT_PENDING_FLG 0x10 -#define TASK_EVENT_CONSUMER_FLG 0x20 - -/* - * strace(1M) prints out the debug data once the debug value is set in - * the bscv.conf file and the debug driver is installed. - * - * Debug flags - * - * '@' - Register (@)ccess - * 'A' - (A)ttach - * 'B' - (B)lom1 attach extra - * 'C' - lom1 (C)allback - * 'D' - (D)aemon - * 'E' - (E)vents - * 'F' - Sel(F)test - * 'I' - (I)octl - * 'L' - TSa(L)arms - * 'M' - (M)odel parameters - * 'N' - I(N)terrupt Service Routine - * 'O' - (O)pen/Close - * 'P' - (P)rogramming - * 'Q' - (Q)ueue things - * 'R' - Read/Write (R)etry summary. - * 'S' - Event (S)trings - * 'U' - Programming ioctls - * 'V' - ??? - * 'W' - (W)atchdog - * 'X' - additional X86 functional calls - * 'Z' - Temporary - just log things - */ - -/* - * Debug tips : - * - * strace(1M) prints out the debug data. - * A nice way to work out the debug value set in bscv.conf is to use mdb - * Say we want to show 'D' Daemon and 'I' IOCTL processing, - * you calculate the debug value with the following mdb session : - * # mdb - * > 1<<('D'-'@') | 1<<('I'-'@') = X - * 210 - * > $q - * When you insert "debug=0x210;" into bscv.conf, it causes the next - * reboot with the debug driver to trace Daemon and IOCTL functionality. - */ - -/* - * Xbus channel access data - */ - -struct xbus_channel { - ddi_acc_handle_t handle; - uint8_t *regs; -}; - -#define BSCV_MINCHANNELS 2 -#define BSCV_MAXCHANNELS 16 - -/* - * soft state structure - */ - -typedef -struct { - /* - * Hardware instance variables - */ - uint64_t debug; /* debugging turned on */ - major_t majornum; /* debugging - major number */ - minor_t minornum; /* debugging - minor number */ - - dev_info_t *dip; /* pointer to device info tree */ - int instance; /* instance number for the device */ - ddi_device_acc_attr_t attr; /* device access attributes */ - - struct xbus_channel channel[BSCV_MAXCHANNELS]; - int nchannels; - - int progress; /* progress indicator for attach */ - - int bad_resync; /* Number of bad resyncs */ - - /* - * lom data variables/arrays - */ - uint8_t lom_regs[0x80]; /* registers on the lomlite */ - int serial_reporting; - int reporting_level; - - /* - * lom2 static information. - * setup at driver attach and restart after programming. - */ - int num_fans; - char fan_names[MAX_FANS][MAX_LOM2_NAME_STR]; - uint8_t fanspeed[MAX_FANS]; - char led_names[MAX_LED_ID][MAX_LOM2_NAME_STR]; - lom_volts_t volts; /* keep a static copy of this so */ - /* dont have to re-read names */ - lom_temp_t temps; /* keep a static copy of this so */ - /* dont have to re-read names */ - lom_sflags_t sflags; /* keep a static copy of this so */ - /* dont have to re-read names */ - char escape_chars[6]; /* local copy */ - - uint_t watchdog_timeout; - uint8_t watchdog_reset_on_timeout; - - /* - * lom2 firmware communication - */ - - /* - * cmd_mutex protects the lom2 command progress variables. - * These should only be read/updated with the mutex held. - * - * command_error - acts as a return code and may be read - * without the mutex held if a command is not in progress. - * Note a read only returns failure if the lom does not respond. - * So you might need to check the error code to see if things really - * did work! - * - * addr_mu is used to protect stopping and starting of the queue. - * BUT when programming it has different semantics and relies - * on only the programming thread being in the ioctl routine - * whilst programming is in progress. The event queue must also - * be paused at this time. - */ - kmutex_t cmd_mutex; /* LOM command mutual exclusion */ - - int command_error; /* error code from last command */ - /* valid until the next command */ - /* starts. */ - - boolean_t had_fault; /* Current command sequence faulted */ - boolean_t had_session_error; /* Current session had error */ - - uint8_t pat_seq; /* Watchdog patting sequence number */ - uint8_t cap0; /* capability byte */ - uint8_t cap1; /* capability byte */ - uint8_t cap2; /* capability byte */ - - /* - * Programming variables - */ - kmutex_t prog_mu; /* Programming mutex. - lom 2 */ - boolean_t prog_mode_only; /* If true we can only reprogram */ - /* the lom */ - boolean_t programming; /* TRUE is actually programming */ - /* the BSC */ - boolean_t cssp_prog; /* TRUE is CSSP programming the BSC */ - - int prog_index; /* data buffer number - bit */ - /* 0x8000 set if last buffer */ - int image_ptr; /* ptr to next byte in image buffer */ - /* for programming */ - uint8_t *image; /* ptr to image buffer for */ - /* programming */ - boolean_t image2_processing; /* boolean to say which of */ - /* 2 BSC images being processed */ - boolean_t loader_running; /* Still have the loader running */ - - /* - * LOM eeprom window access state - * Access under bscv_enter/bscv_exit protection. - */ - boolean_t eeinfo_valid; - uint32_t eeprom_size; - uint32_t eventlog_start; - uint32_t eventlog_size; - boolean_t oldeeptr_valid; - uint16_t oldeeptr; - - /* - * Communication with the event processing thread - * - * Change these variables with task_mu held and signal task_cv - * if an event/task needs processing. - */ - kmutex_t task_mu; /* mutex for wait on event thread */ - kcondvar_t task_cv; /* cv for wait on event thread */ - kcondvar_t task_evnt_cv; /* cv for lom2 wait on event */ - int task_flags; /* To monitor/stop the event thread */ - volatile int event_active_count; /* Count of event thread runs */ - boolean_t event_waiting; /* New events are waiting in the lom */ - boolean_t status_change; /* A status change is waiting */ - boolean_t nodename_change; /* Nodename has changed */ - boolean_t event_sleep; /* Error reading events - wait a bit */ - boolean_t event_fault_reported; /* Event fault reported */ - boolean_t watchdog_change; /* Watchdog config has changed */ -#ifdef __sparc - bscv_sig_t last_sig; /* Record of last signature sent */ -#endif /* __sparc */ - uint8_t last_event[8]; /* last event read and reported */ -#if defined(__i386) || defined(__amd64) - ddi_periodic_t periodic_id; /* watchdog patter periodical callback */ - callb_id_t callb_id; /* Need to store the ID so we can */ - /* unschedule the panic callback */ - char last_nodename[128]; /* copy of last utsname.nodename */ -#endif /* __i386 || __amd64 */ -} bscv_soft_state_t; - -struct bscv_idi_callout { - enum bscv_idi_type type; /* Type of service */ - boolean_t (*fn)(struct bscv_idi_info); /* Function's address */ -}; - -#define BSCV_IDI_CALLOUT_MAGIC 0xb5c1ca11 -#define BSCV_IDI_ERR_MSG_THRESHOLD 10 -struct bscv_idi_callout_mgr { - /* - * To allow for sanity check. - */ - uint32_t magic; - - /* - * The instance number of "an" instance of the driver. This is assigned - * during driver attach. - */ - uint32_t valid_inst; - - /* - * Table of services offered via the idi interface. - */ - struct bscv_idi_callout *tbl; - - /* - * Error message count since last successful use of the idi interface. - */ - uint64_t errs; -}; - - - -#define BSC_IMAGE_MAX_SIZE (0x20000 + sizeof (lom_prog_data_t)) - -#define BSC_PROBE_FAULT_LIMIT 8 /* Tries before declaring lom dead */ -#define BSC_EVENT_POLL_NORMAL (drv_usectohz(1000000)) /* 1 second */ -#define BSC_EVENT_POLL_FAULTY (drv_usectohz(10000000)) /* 10 second */ - -#define BSC_FAILURE_RETRY_LIMIT 5 /* Access retries before giving up */ -#define BSC_ERASE_RETRY_LIMIT 5 /* Erase retries */ -#define BSC_PAGE_RETRY_LIMIT 5 /* Page write retries */ - -#define BSC_ADDR_CACHE_LIMIT \ - (sizeof (((bscv_soft_state_t *)NULL)->lom_regs)) -#define BSC_INFORM_ONLINE 0x4f530100 -#define BSC_INFORM_OFFLINE 0x4f530201 -#define BSC_INFORM_PANIC 0x4f530204 - -#include <sys/lom_ebuscodes.h> - -typedef uint32_t bscv_addr_t; - -#define BSC_NEXUS_ADDR(ssp, chan, as, index) \ - (&((ssp)->channel[chan].regs[((as) * 256) + (index)])) - -#define BSC_NEXUS_OFFSET(as, index) (((as) * 256) + (index)) - -#define BSCVA(as, index) (((as) * 256) + (index)) - -#define PSR_SUCCESS(status) (((status) & EBUS_PROGRAM_PSR_STATUS_MASK) == \ - EBUS_PROGRAM_PSR_SUCCESS) - -#define PSR_PROG(status) (((status) & EBUS_PROGRAM_PSR_PROG_MODE) != 0) -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_BSCV_IMPL_H */ diff --git a/usr/src/uts/common/sys/lom_ebuscodes.h b/usr/src/uts/common/sys/lom_ebuscodes.h deleted file mode 100644 index 88435bca17..0000000000 --- a/usr/src/uts/common/sys/lom_ebuscodes.h +++ /dev/null @@ -1,647 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 1999-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_LOM_EBUSCODES_H -#define _SYS_LOM_EBUSCODES_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file enumerates the virtual registers exported by the microcontroller. - * It cannot be changed without also revising the firwmare. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define EBUS_CMD_SPACE_GENERIC 0x00 /* generic space */ -#define EBUS_CMD_SPACE1 0x01 /* space 1 - console buffer or */ - /* boot script */ -#define EBUS_CMD_SPACE2 0x02 /* space 2 - supply rail data */ -#define EBUS_CMD_SPACE3 0x03 /* space 3 - circuit breaker data */ -#define EBUS_CMD_SPACE4 0x04 /* space 4 - fan data */ -#define EBUS_CMD_SPACE5 0x05 /* space 5 - temp/otemp sensor data */ -#define EBUS_CMD_SPACE6 0x06 /* space 6 - phone-home config */ -#define EBUS_CMD_SPACE_PROGRAM 0x07 /* space 7 - send a program */ -#define EBUS_CMD_SPACE_EEPROM 0x08 /* space 8 - eeprom/event-log access */ -#define EBUS_CMD_SPACE_SELFTEST 0x09 /* space 9 - selftest control */ -#define EBUS_CMD_SPACE_LEDS 0x0a /* space 10 - LED name access */ - -/* - * Read only values - */ -#define EBUS_IDX_FW_REV 0x01 /* Firmware Revision */ -#define EBUS_IDX_CHECK_HI 0x02 /* Firmware checksum high */ -#define EBUS_IDX_CHECK_LO 0x03 /* Firmware checksum low */ -#define EBUS_IDX_FAN1_SPEED 0x04 /* Fan 1 current speed % of max */ -#define EBUS_IDX_FAN2_SPEED 0x05 /* Fan 2 current speed % of max */ -#define EBUS_IDX_FAN3_SPEED 0x06 /* Fan 3 current speed % of max */ -#define EBUS_IDX_FAN4_SPEED 0x07 /* Fan 4 current speed % of max */ -#define EBUS_IDX_PSU1_STAT 0x08 /* PSU 1 status */ -#define EBUS_IDX_PSU2_STAT 0x09 /* PSU 2 status */ -#define EBUS_IDX_PSU3_STAT 0x0a /* PSU 3 status */ -#define EBUS_IDX_STATE_CHNG 0x0b /* State change flags */ -#define EBUS_IDX_GPIP 0x0c /* General purpose inputs */ - -/* RESERVED 0x0d */ -/* RESERVED 0x0e */ -/* RESERVED 0x0f */ -#define EBUS_IDX_LOG_START_HI 0x10 /* MSB of start of eventlog in eeprom */ -#define EBUS_IDX_LOG_START_LO 0x11 /* LSB of start of eventlog in eeprom */ -#define EBUS_IDX_LOG_PTR_HI 0x12 /* MSB of current position in log */ -#define EBUS_IDX_LOG_PTR_LO 0x13 /* LSB of current position in log */ - -/* - * We currently don't have a virtual register to indicate the end of the log. - * We cannot assume the log runs to the end of the EEPROM because the EEPROM - * is logically partitioned into a Log portion (first 8K) and then a FRUID - * portion (next 8K). For the moment we therefore need to use a hardcoded - * value to represent the end of the event log. - */ -#define EBUS_LOG_END 0x2000 - -#define EBUS_IDX_EEPROM_SIZE_KB 0x14 /* Size of eeprom in kilobytes */ -#define EBUS_IDX_UNREAD_EVENTS 0x15 /* Number of events (un)read by host */ -/* RESERVED 0x16 */ -/* RESERVED 0x17 */ - -#define EBUS_IDX_TEMP1 0x18 /* Temperature sensors */ -#define EBUS_IDX_TEMP2 0x19 -#define EBUS_IDX_TEMP3 0x1A -#define EBUS_IDX_TEMP4 0x1B -#define EBUS_IDX_TEMP5 0x1C -#define EBUS_IDX_TEMP6 0x1D -#define EBUS_IDX_TEMP7 0x1E -#define EBUS_IDX_TEMP8 0x1F - -#define EBUS_IDX_ALARMNEW 0x20 -#define EBUS_IDX_SUPPLY_LO 0x21 /* 1 bit per voltage line status */ -#define EBUS_IDX_SUPPLY_HI 0x22 /* whether faulty or not; 1=>faulty */ -#define EBUS_IDX_CBREAK_STATUS 0x23 -#define EBUS_IDX_OTEMP_STATUS 0x24 - -#define EBUS_IDX_LED1_STATUS 0x25 -#define EBUS_IDX_LED2_STATUS 0x26 -#define EBUS_IDX_LED3_STATUS 0x27 -#define EBUS_IDX_LED4_STATUS 0x28 -#define EBUS_IDX_LED5_STATUS 0x29 -#define EBUS_IDX_LED6_STATUS 0x2a -#define EBUS_IDX_LED7_STATUS 0x2b -#define EBUS_IDX_LED8_STATUS 0x2c -/* RESERVED 0x2d */ - -#define EBUS_IDX_CPU_IDENT 0x2e -#define EBUS_IDX_EVENT_DETAIL 0x2f - -/* - * Read/write access registers - */ -#define EBUS_IDX_ALARM 0x30 /* Alarm control/status */ -#define EBUS_IDX_WDOG_CTRL 0x31 /* Watchdog control */ -#define EBUS_IDX_WDOG_TIME 0x32 /* Watchdog timeout */ - -#define EBUS_IDX_SER_BAUD 0x33 -#define EBUS_IDX_SER_CHARMODE 0x34 -#define EBUS_IDX_SER_FLOWCTL 0x35 -#define EBUS_IDX_SER_MODEMTYPE 0x36 -#define EBUS_IDX_EEPROM_PAGESEL 0x37 - -#define EBUS_IDX_HNAME_LENGTH 0x38 -#define EBUS_IDX_HNAME_CHAR 0x39 - -#define EBUS_IDX_CONFIG_MISC 0x3a /* Host specific configuration */ - -#define EBUS_IDX_TIME0 0x3b -#define EBUS_IDX_TIME1 0x3c -#define EBUS_IDX_TIME2 0x3d -#define EBUS_IDX_TIME3 0x3e - -#define EBUS_IDX_ESCAPE 0x3f /* Escape character, default '#' */ -#define EBUS_IDX_EVENT_CNT 0x40 /* Number of unread (via EBus) events */ - -#define EBUS_IDX_SELFTEST0 0x41 -#define EBUS_IDX_SELFTEST1 0x42 -#define EBUS_IDX_SELFTEST2 0x43 -#define EBUS_IDX_SELFTEST3 0x44 -#define EBUS_IDX_SELFTEST4 0x45 -#define EBUS_IDX_SELFTEST5 0x46 -#define EBUS_IDX_SELFTEST6 0x47 -#define EBUS_IDX_SELFTEST7 0x48 - -#define EBUS_IDX_ESCAPE_LEN 0x49 -#define EBUS_IDX_SER_TIMEOUT 0x4a -#define EBUS_IDX_EVENT_FILTER 0x4b -#define EBUS_IDX_POWERON_DELAY 0x4c - -#define EBUS_IDX_BOOTMODE 0x4d /* boot-mode for PROM */ - -#define EBUS_IDX_I2C_HOLDOFF 0x4e /* hold off i2c bus while obp starts */ -/* RESERVED 0x4f */ - -#define EBUS_IDX_MODEL_ID1 0x50 /* Model identifier */ -#define EBUS_IDX_MODEL_ID2 0x51 -#define EBUS_IDX_MODEL_ID3 0x52 -#define EBUS_IDX_MODEL_ID4 0x53 -#define EBUS_IDX_MODEL_ID5 0x54 -#define EBUS_IDX_MODEL_ID6 0x55 -#define EBUS_IDX_MODEL_ID7 0x56 -#define EBUS_IDX_MODEL_ID8 0x57 -#define EBUS_IDX_MODEL_ID9 0x58 -#define EBUS_IDX_MODEL_ID10 0x59 -#define EBUS_IDX_MODEL_ID11 0x5a -#define EBUS_IDX_MODEL_ID12 0x5b -#define EBUS_IDX_MODEL_REV 0x5c /* Model Revision */ - -#define EBUS_IDX_CONFIG 0x5d /* Model specific configuration */ -#define EBUS_IDX_FAN1_CAL 0x5e /* Fan 1 calibration value */ -#define EBUS_IDX_FAN2_CAL 0x5f /* Fan 2 calibration value */ -#define EBUS_IDX_FAN3_CAL 0x60 /* Fan 3 calibration value */ -#define EBUS_IDX_FAN4_CAL 0x61 /* Fan 4 calibration value */ -#define EBUS_IDX_FAN1_LOW 0x62 /* Fan 1 low limit */ -#define EBUS_IDX_FAN2_LOW 0x63 /* Fan 2 low limit */ -#define EBUS_IDX_FAN3_LOW 0x64 /* Fan 3 low limit */ -#define EBUS_IDX_FAN4_LOW 0x65 /* Fan 4 low limit */ - -#define EBUS_IDX_CONFIG2 0x66 /* Model specific configuration */ -#define EBUS_IDX_CONFIG3 0x67 /* Model specific configuration */ - -#define EBUS_IDX_HOSTID1 0X68 /* Host ID, MSB */ -#define EBUS_IDX_HOSTID2 0X69 /* Host ID */ -#define EBUS_IDX_HOSTID3 0X6a /* Host ID */ -#define EBUS_IDX_HOSTID4 0X6b /* Host ID */ - -/* RESERVED 0x6c */ -/* RESERVED 0x6d */ -/* RESERVED 0x6e */ -/* RESERVED 0x6f */ -/* RESERVED 0x70 */ -/* RESERVED 0x71 */ -/* RESERVED 0x72 */ -/* RESERVED 0x73 */ -/* RESERVED 0x74 */ -/* RESERVED 0x75 */ -/* RESERVED 0x76 */ -/* RESERVED 0x77 */ -/* RESERVED 0x78 */ -/* RESERVED 0x79 */ -/* RESERVED 0x7a */ - -/* - * Capability bits: - * - * Register starting from 0x7e and downward are used to describe various - * capabilities that the LOM firmware has. A capability is present if the - * corresponding bit returns '1'. - */ -#define EBUS_IDX_CAP2 0x7b /* Capabilities - Read only */ -#define EBUS_IDX_CAP1 0x7c /* Capabilities - Read only */ -#define EBUS_IDX_CAP0 0x7d /* Capabilities - Read only */ - -#define EBUS_IDX_PROBE55 0x7e /* Always returns 0x55 */ -#define EBUS_IDX_PROBEAA 0x7f /* Always returns 0xaa */ - -#define EBUS_FIRST_READONLY EBUS_IDX_FW_REV -#define EBUS_LAST_READONLY EBUS_IDX_EVENT_DETAIL -#define EBUS_FIRST_MODELLOCKED EBUS_IDX_MODEL_ID1 -#define EBUS_LAST_MODELLOCKED EBUS_IDX_CONFIG3 - -/* - * Register for special address spaces - */ -#define EBUS_IDX1_CONS_BUF_START 0x00 -#define EBUS_IDX1_CONS_BUF_END 0xff - -#define EBUS_IDX2_SUPPLY_ENABLE_MASK1 0x01 -#define EBUS_IDX2_SUPPLY_ENABLE_MASK2 0x02 -#define EBUS_IDX2_SUPPLY_FATAL_MASK1 0x03 -#define EBUS_IDX2_SUPPLY_FATAL_MASK2 0x04 -#define EBUS_IDX2_SUPPLY_FINE_TOL 0x05 -#define EBUS_IDX2_SUPPLY_GROSS_TOL 0x06 -#define EBUS_IDX2_SUPPLY_READING1 0x10 -#define EBUS_IDX2_SUPPLY_READING2 0x11 -#define EBUS_IDX2_SUPPLY_READING3 0x12 -#define EBUS_IDX2_SUPPLY_READING4 0x13 -#define EBUS_IDX2_SUPPLY_READING5 0x14 -#define EBUS_IDX2_SUPPLY_READING6 0x15 -#define EBUS_IDX2_SUPPLY_READING7 0x16 -#define EBUS_IDX2_SUPPLY_READING8 0x17 -#define EBUS_IDX2_SUPPLY_READING9 0x18 -#define EBUS_IDX2_SUPPLY_READING10 0x19 -#define EBUS_IDX2_SUPPLY_READING11 0x1a -#define EBUS_IDX2_SUPPLY_READING12 0x1b -#define EBUS_IDX2_SUPPLY_READING13 0x1c -#define EBUS_IDX2_SUPPLY_READING14 0x1d -#define EBUS_IDX2_SUPPLY_READING15 0x1e -#define EBUS_IDX2_SUPPLY_READING16 0x1f -#define EBUS_IDX2_SUPPLY_CAL1 0x20 -#define EBUS_IDX2_SUPPLY_CAL2 0x21 -#define EBUS_IDX2_SUPPLY_CAL3 0x22 -#define EBUS_IDX2_SUPPLY_CAL4 0x23 -#define EBUS_IDX2_SUPPLY_CAL5 0x24 -#define EBUS_IDX2_SUPPLY_CAL6 0x25 -#define EBUS_IDX2_SUPPLY_CAL7 0x26 -#define EBUS_IDX2_SUPPLY_CAL8 0x27 -#define EBUS_IDX2_SUPPLY_CAL9 0x28 -#define EBUS_IDX2_SUPPLY_CAL10 0x29 -#define EBUS_IDX2_SUPPLY_CAL11 0x2a -#define EBUS_IDX2_SUPPLY_CAL12 0x2b -#define EBUS_IDX2_SUPPLY_CAL13 0x2c -#define EBUS_IDX2_SUPPLY_CAL14 0x2d -#define EBUS_IDX2_SUPPLY_CAL15 0x2e -#define EBUS_IDX2_SUPPLY_CAL16 0x2f -#define EBUS_IDX2_SUPPLY_NAME_START 0x40 -#define EBUS_IDX2_SUPPLY_NAME_END 0xff - -#define EBUS_IDX3_BREAKER_ENABLE_MASK 0x01 -#define EBUS_IDX3_BREAKER_NAME_START 0x40 -#define EBUS_IDX3_BREAKER_NAME_END 0xff - -#define EBUS_IDX4_TEMP_ENABLE_MASK 0x01 -#define EBUS_IDX4_OTEMP_ENABLE_MASK 0x02 -#define EBUS_IDX4_TEMP_FATAL_MASK 0x03 -#define EBUS_IDX4_OTEMP_FATAL_MASK 0x04 -#define EBUS_IDX4_TEMP_HYSTERESIS 0x05 -#define EBUS_IDX4_TEMP_FAN_LINK_MASK 0x06 -#define EBUS_IDX4_TEMP_WARN1 0x10 /* Temp warning levels */ -#define EBUS_IDX4_TEMP_WARN2 0x11 -#define EBUS_IDX4_TEMP_WARN3 0x12 -#define EBUS_IDX4_TEMP_WARN4 0x13 -#define EBUS_IDX4_TEMP_WARN5 0x14 -#define EBUS_IDX4_TEMP_WARN6 0x15 -#define EBUS_IDX4_TEMP_WARN7 0x16 -#define EBUS_IDX4_TEMP_WARN8 0x17 -#define EBUS_IDX4_TEMP_SDOWN1 0x18 /* Temp shutdown levels */ -#define EBUS_IDX4_TEMP_SDOWN2 0x19 -#define EBUS_IDX4_TEMP_SDOWN3 0x1a -#define EBUS_IDX4_TEMP_SDOWN4 0x1b -#define EBUS_IDX4_TEMP_SDOWN5 0x1c -#define EBUS_IDX4_TEMP_SDOWN6 0x1d -#define EBUS_IDX4_TEMP_SDOWN7 0x1e -#define EBUS_IDX4_TEMP_SDOWN8 0x1f -#define EBUS_IDX4_TEMP_CORRECT1 0x20 /* Temp warning levels */ -#define EBUS_IDX4_TEMP_CORRECT2 0x21 -#define EBUS_IDX4_TEMP_CORRECT3 0x22 -#define EBUS_IDX4_TEMP_CORRECT4 0x23 -#define EBUS_IDX4_TEMP_CORRECT5 0x24 -#define EBUS_IDX4_TEMP_CORRECT6 0x25 -#define EBUS_IDX4_TEMP_CORRECT7 0x26 -#define EBUS_IDX4_TEMP_CORRECT8 0x27 -#define EBUS_IDX4_TEMP_NAME_START 0x40 -#define EBUS_IDX4_TEMP_NAME_END 0xff - -#define EBUS_IDX5_FAN_ENABLE_CONFIG 0x01 -#define EBUS_IDX5_FAN_NAME_START 0x40 -#define EBUS_IDX5_FAN_NAME_END 0xff - -#define EBUS_IDX10_LED_NAME_START 0x40 -#define EBUS_IDX10_LED_NAME_END 0xff - -/* - * This arrangement for CPU signatures allows only one CPU to generate a - * CPU Signature at a time. Since the signature won't fit into one byte - * it is recommended to datafill the MSB, LSB, STATE, SUBSTATE first, and - * then write the ID. A one byte ID limits the number of CPUs to 255. - * CPU 255 is handled specially; it denotes that the signature applies to - * "all", or rather "any" CPU ID. - */ - -#define EBUS_ANY_CPU_ID 255 - -#define EBUS_IDX11_CPU_ID 0x01 /* CPU with signature pending */ -#define EBUS_IDX11_CPU_SIG_MSB 0x02 /* MSB of sig */ -#define EBUS_IDX11_CPU_SIG_LSB 0x03 /* LSB of sig */ -#define EBUS_IDX11_CPU_STATE 0x04 /* state of sig */ -#define EBUS_IDX11_CPU_SUBSTATE 0x05 /* sub-state of sig */ - -/* - * OBP-defined reset reasons. Solaris never generates these. - */ -#define EBUS_IDX11_HOST_RESET_REASON 0x07 -#define RESET_REASON_HOST 0x01 /* host reset itself */ -#define RESET_REASON_LOM 0x02 /* lom CLI or SSP request */ -#define RESET_REASON_ASR 0x04 /* watchdog or cpusig timeout */ - -/* - * I2C Transfers can be done using the BSC as a proxy. We transfer data at - * the conceptual level of struct i2c_transfer defined by the i2c services - * framework in Solaris. - */ - -/* - * TRANSFER_TYPE mirrors the i2c_transfer.i2c_flags used in Solaris i2c - * services framework. - */ -#define EBUS_I2C_WR 0x01 /* write */ -#define EBUS_I2C_RD 0x02 /* read */ -#define EBUS_I2C_WR_RD 0x04 /* write then read */ - -/* - * RESULT mirrors the i2c_transfer.i2c_result used the Solaris i2c services - * framework. - */ -#define EBUS_I2C_SUCCESS 0x00 -#define EBUS_I2C_FAILURE 0xFF -#define EBUS_I2C_INCOMPLETE 0xFE - - -#define EBUS_IDX12_MAX_TRANSFER_SZ 0x01 -#define EBUS_IDX12_BUS_ADDRESS 0x02 -#define EBUS_IDX12_CLIENT_ADDRESS 0x03 -#define EBUS_IDX12_WR_RD_BOUNDARY 0x04 -#define EBUS_IDX12_TRANSFER_TYPE 0x05 -#define EBUS_IDX12_RESIDUAL_DATA 0x06 -#define EBUS_IDX12_DATA_INOUT 0x07 -#define EBUS_IDX12_RESULT 0x08 - -#define EBUS_IDX12_TRANSACTION_LOCK 0x09 /* 1=> lock out i2c devices */ - /* so multi i2c transactions */ - /* can complete atomically */ - -#define EBUS_PROGRAM_PCSR 0x01 -#define EBUS_PROGRAM_PCR_RSVD 0x00 -#define EBUS_PROGRAM_PCR_READ 0x02 -#define EBUS_PROGRAM_PCR_PRGMODE_ON 0x03 -#define EBUS_PROGRAM_PCR_ERASE 0x04 -#define EBUS_PROGRAM_PCR_PROGRAM 0x05 -#define EBUS_PROGRAM_PCR_PRSVD 0x06 -#define EBUS_PROGRAM_PCR_PRGMODE_OFF 0x07 -#define EBUS_PROGRAM_PCR_PROGOFF_JUMPTOADDR 0x08 -#define EBUS_PROGRAM_PSR_SUCCESS 0x00 -#define EBUS_PROGRAM_PSR_PROGRAM_FAIL 0x01 -#define EBUS_PROGRAM_PSR_ERASE_FAIL 0x02 -#define EBUS_PROGRAM_PSR_INVALID_AREA 0x03 -#define EBUS_PROGRAM_PSR_INCORRECT_CSUM 0x04 -#define EBUS_PROGRAM_PSR_INCORRECT_COUNT 0x05 -#define EBUS_PROGRAM_PSR_INVALID_OPERATION 0x06 -#define EBUS_PROGRAM_PSR_STATUS_MASK 0x7f -#define EBUS_PROGRAM_PSR_PROG_MODE 0x80 -#define EBUS_PROGRAM_DATA 0x02 -#define EBUS_PROGRAM_PCSM0 0x03 /* MSB of checksum data */ -#define EBUS_PROGRAM_PCSM1 0x04 -#define EBUS_PROGRAM_PADR0 0x05 /* MSB of addr */ -#define EBUS_PROGRAM_PADR1 0x06 -#define EBUS_PROGRAM_PADR2 0x07 -#define EBUS_PROGRAM_PADR3 0x08 -#define EBUS_PROGRAM_PSIZ0 0x09 /* MSB of size */ -#define EBUS_PROGRAM_PSIZ1 0x0a -#define EBUS_PROGRAM_PSIZ2 0x0b -#define EBUS_PROGRAM_PSIZ3 0x0c -#define EBUS_PROGRAM_PAGE0 0x0d /* MSB of ROM page size */ -#define EBUS_PROGRAM_PAGE1 0x0e -#define EBUS_PROGRAM_PAGE2 0x0f -#define EBUS_PROGRAM_PAGE3 0x10 - -/* - * Command register and codes - */ - -#define EBUS_IDX_CMD_RES 0x00 /* Command/Result register */ -#define EBUS_CMD_CODE_CHK 'C' /* Recheck alarm conditions */ -#define EBUS_CMD_CODE_CLR 'E' /* Clear event log */ -#define EBUS_CMD_UNLOCK1 'M' /* Model Unlock step 1 */ -#define EBUS_CMD_UNLOCK2 'u' /* Model Unlock step 2 */ -#define EBUS_CMD_POWERINGOFF 'P' /* host sends before powering off */ -#define EBUS_CMD_RESETTING 'R' /* host sends before resetting self */ -#define EBUS_CMD_CONLOG_ON 'F' -#define EBUS_CMD_CONLOG_OFF 'D' -#define EBUS_CMD_INTERRUPTS_ON 'i' -#define EBUS_CMD_INTERRUPTS_OFF 'I' -#define EBUS_CMD_DOG_PAT 'W' /* Host pats it's watchdog */ -#define EBUS_CMD_PROG_START 'z' - - -/* - * space 11 - CPU signatures and OBP reset information. - */ -#define EBUS_CMD_SPACE_CPUSIG 0x0b -#define EBUS_CMD_SPACE_I2C 0x0c /* space 12 - I2C transfers */ -#define EBUS_CMD_SPACE13 0x0d -#define EBUS_CMD_SPACE14 0x0e -#define EBUS_CMD_SPACE15 0x0f - -#define EBUS_MAX_ADDRESS_SPACES 64 /* as defined by the protocol elsewhere */ - -/* - * Number of unread events flag - */ -#define EBUS_EVENT_CNT_CLEAR 0x80 /* Event log cleared since last read */ - -/* - * Prom boot mode parameters - */ -#define EBUS_BOOTMODE_FORCE_CONSOLE 0x01 -#define EBUS_BOOTMODE_FORCE_NOBOOT 0x02 -#define EBUS_BOOTMODE_RESET_DEFAULT 0x04 -#define EBUS_BOOTMODE_FULLDIAG 0x08 -#define EBUS_BOOTMODE_SKIPDIAG 0x10 - -/* - * Configuration register - */ -#define EBUS_CONFIG_NFAN_DEC(n) (((n)>>5)&0x7) /* Extract no. of fans */ -#define EBUS_CONFIG_NFAN_ENC(n) (((n)&0x7)<<5) /* Insert no. of fans */ -#define EBUS_CONFIG_NPSU_DEC(n) (((n)>>3)&0x3) /* Extract no. of PSUs */ -#define EBUS_CONFIG_NPSU_ENC(n) (((n)&0x3)<<3) /* Insert no. of PSUs */ -#define EBUS_CONFIG_TTY_CON 0x04 /* Set if TTY/LOM switchable */ -#define EBUS_CONFIG_STEADY_LED 0x02 /* Set to stop LED flashing */ -#define EBUS_CONFIG_USER_LOG 0x01 /* log user operations */ - -/* - * Configuration register 2 - */ -#define EBUS_CONFIG2_NTEMP_DEC(n) (((n)>>4)&0xf) -#define EBUS_CONFIG2_NTEMP_ENC(n) (((n)&0xf)<<4) -#define EBUS_CONFIG2_NSUPPLY_DEC(n) ((n)&0xf) -#define EBUS_CONFIG2_NSUPPLY_ENC(n) ((n)&0xf) - -/* - * Configuration register 3 - */ -#define EBUS_CONFIG3_NOTEMP_DEC(n) (((n)>>4)&0xf) -#define EBUS_CONFIG3_NOTEMP_ENC(n) (((n)&0xf)<<4) -#define EBUS_CONFIG3_NBREAKERS_DEC(n) ((n)&0xf) -#define EBUS_CONFIG3_NBREAKERS_ENC(n) ((n)&0xf) - -/* - * Miscellaneous host configuration register - */ -#define EBUS_CONFIG_MISC_PSUIPFAILEVENTS 0x80 -#define EBUS_CONFIG_MISC_DELAYED_STARTUP 0x40 -#define EBUS_CONFIG_MISC_RANDOM_DELAY 0x20 -#define EBUS_CONFIG_MISC_DECLINE_STARTUP 0x10 -#define EBUS_CONFIG_MISC_ALARM0_ENABLED 0x08 -#define EBUS_CONFIG_MISC_PHONEHOME_ENABLED 0x04 -#define EBUS_CONFIG_MISC_SECURITY_ENABLED 0x02 -#define EBUS_CONFIG_MISC_AUTO_CONSOLE 0x01 - -/* - * Alarm control/status register - */ -#define EBUS_ALARM_LED_DEC(n) (((n)>>4)&0xf) /* Extract LED Hz */ -#define EBUS_ALARM_LED_ENC(n) (((n)&0xf)<<4) /* Insert LED Hz */ -#define EBUS_ALARM_NOEVENTS 0x08 /* No serial event reports */ -#define EBUS_ALARM_ENABLE3 0x04 /* Alarm 3 enable */ -#define EBUS_ALARM_ENABLE2 0x02 /* Alarm 2 enable */ -#define EBUS_ALARM_ENABLE1 0x01 /* Alarm 1 enable */ - -/* - * General Channel Watchdog control - */ -#define EBUS_WDOG_BREAK_DISABLE 0x10 /* Set if wdog disabled if break seen */ -#define EBUS_WDOG_AL3_FANPSU 0x08 /* Set if fan/PSU errors set AL3 */ -#define EBUS_WDOG_AL3_WDOG 0x04 /* Set if wdog timeouts set AL3 */ -#define EBUS_WDOG_RST 0x02 /* Reset host on expiry */ -#define EBUS_WDOG_ENABLE 0x01 /* Enable host WDOG */ - -/* - * Watchdog channel non-blocking byte - * Top nibble command, bottom nibble data - */ -#define EBUS_WDOG_NB_PAT 0x00 -#define EBUS_WDOG_NB_PAT_SEQ_MASK 0x0F /* Sequence number */ -#define EBUS_WDOG_NB_CFG 0x10 -#define EBUS_WDOG_NB_CFG_ENB 0x01 /* enable/disable wdog */ - -/* - * PSU status - */ -#define EBUS_PSU_INPUTA 0x01 /* Input A OK */ -#define EBUS_PSU_INPUTB 0x02 /* Input B OK */ -#define EBUS_PSU_OUTPUT 0x04 /* Output OK */ -#define EBUS_PSU_PRESENT 0x08 /* PSU is present */ -#define EBUS_PSU_STANDBY 0x10 /* PSU is in standby */ - -/* - * State change flags - */ -#define EBUS_STATE_TEMPERATURE 0x80 /* a temperature was exceeded */ -#define EBUS_STATE_RAIL 0x40 /* a supply rail failed */ -#define EBUS_STATE_EVENT 0x20 /* An event has been logged */ -#define EBUS_STATE_CB 0x10 /* A circuit breaker failed */ -#define EBUS_STATE_GP 0x08 /* A GP input has changed */ -#define EBUS_STATE_PSU 0x04 /* A PSU state has changed */ -#define EBUS_STATE_FAN 0x02 /* A fan speed has changed */ - - -/* - * Bit-0 is overloaded. It is used by the BSC to notify of a status change - * The detail field will then be one of EBUS_DETAIL_XXXX. Otherwise, it's used - * to indicate that an Alarm state has changed. The detail field would then - * be the alarm number. - */ -#define EBUS_STATE_ALARM 0x01 /* An alarm state has changed */ -#define EBUS_STATE_NOTIFY 0x01 /* BSC state changes */ - -/* - * State Notify detail values - */ -#define EBUS_DETAIL_FLASH 0xff /* CSSP going to program BSC */ -#define EBUS_DETAIL_RESET 0xfe /* BSC has been reset */ - -#define EBUS_STATE_MASK 0xff /* All state changes */ - -/* - * Alarm config bytes for register $20 - */ -#define ALARM_0 0x01 -#define ALARM_0_ENABLE 0x02 - -/* - * Phone home configuration information - */ -#define PHONEHOME_CONFIG_REG 0x01 -#define PHONEHOME_SCRIPT_START_REG 0x02 - -#define PHONEHOME_CONFIG_ON_UNXPOWEROFF 0x01 -#define PHONEHOME_CONFIG_ON_WATCHDOGTRG 0x02 -#define PHONEHOME_CONFIG_ON_DEMAND 0x04 - -/* - * CPU type ident codes. This determines the programming mode. - */ -#define CPU_IDENT_UNKNOWN 0x80 -#define CPU_IDENT_H8_3434 0x81 -#define CPU_IDENT_H8_3436 0x82 -#define CPU_IDENT_H8_3437 0x83 -#define CPU_IDENT_H8_3437SF 0x84 -#define CPU_IDENT_H8S_2148 0x85 -#define CPU_IDENT_H8S_2148A 0x86 -#define CPU_IDENT_H8S_BSC 0x87 - -/* - * Capability codes - */ -#define EBUS_CAP0_ASYNC_DOG 0x01 /* EBUS_CMD_DOGPAT implemented */ -#define EBUS_CAP0_SYNC_EVENTS 0x02 /* event report at command end */ -#define EBUS_CAP0_NEW_EVENTLOG_SPACE 0x04 /* new implementation of space8 */ -#define EBUS_CAP0_NEW_SELFTESTS 0x08 /* new implementation of tests */ -#define EBUS_CAP0_NEW_PROGRAMMING 0x10 /* new flash programming scheme */ -#define EBUS_CAP0_LED_INFORMATION 0x20 /* new LED modelling scheme */ -#define EBUS_CAP0_CPU_SIG 0x40 /* understands CPU signatures */ -#define EBUS_CAP0_I2C_PROXY 0x80 /* implements i2c proxy service */ -#define EBUS_CAP1_H8_SETS_IDX_TIME 0x01 /* H8 writes IDX_TIME values */ -#define EBUS_CAP1_SPACE1_IS_BOOTSCRIPT 0x02 /* SPACE1 used for Boot Script */ -#define EBUS_CAP1_FRUID_OFFSET 0x04 /* i2c reads are already offset */ - -/* Error codes as returned via the EBUS interface */ - -#define EBUS_ERROR_NONE 0 /* no error occured */ -#define EBUS_ERROR_NOREAD 1 /* this register cannot be read */ -#define EBUS_ERROR_NOWRITE 2 /* this register cannot be written */ -#define EBUS_ERROR_PROTO_CMD 3 /* command sent unexpected */ -#define EBUS_ERROR_PROTO_DATA 4 /* data sent unexpected */ -#define EBUS_ERROR_INVALID_BIT 5 /* invalid bit was set in data passed */ -#define EBUS_ERROR_VALUE_BAD 6 /* data passed was plain bad */ -#define EBUS_ERROR_NOX_SPECCMD 7 /* no such special command exists */ -#define EBUS_ERROR_NOTUNLOCKED 8 /* need model-lock unlocked to do this */ -#define EBUS_ERROR_TIMEOUT 9 /* too long between cmd and data */ -#define EBUS_ERROR_DEVICEFAIL 10 /* Some device (e.g. eeprom) didn't work */ -#define EBUS_ERROR_STALEDATA 11 /* Data has changed - host must reread */ -#define EBUS_ERROR_NOX_DEVICE 12 /* Device doesn't exist */ -#define EBUS_ERROR_RESETNEEDED 13 /* host must reset the LOM */ -#define EBUS_ERROR_PROTO_PARAM 14 /* incorrect parameter count for command */ -#define EBUS_ERROR_PROTO_SEQ 15 /* Sequence number from host incorrect */ -#define EBUS_ERROR_IN_PROG_MODE 16 /* not supported in programming mode */ -#define EBUS_ERROR_NOT_PROG_MODE 17 /* must be in prog mode first */ - -/* Magic values for specific registers. */ -#define LOM_TEMP_MAX_VALUE 0x7c -#define LOM_TEMP_STATE_INACCESSIBLE 0x7d /* can't tell - i2c faulted */ -#define LOM_TEMP_STATE_STANDBY 0x7e /* standby mode */ -#define LOM_TEMP_STATE_NOT_PRESENT 0x7f /* not fitted/present */ - -#define LOM_FAN_MAX_SPEED 0xfb /* protects folllowing special cases */ -#define LOM_FAN_RECOUNT 0xfc /* last access failed */ -#define LOM_FAN_NOACCESS 0xfd /* can't tell - i2c/lm80 faulted */ -#define LOM_FAN_STANDBY 0xfe /* standby mode */ -#define LOM_FAN_NOT_PRESENT 0xff /* no fan fitted */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_LOM_EBUSCODES_H */ diff --git a/usr/src/uts/common/sys/lom_priv.h b/usr/src/uts/common/sys/lom_priv.h deleted file mode 100644 index 5c786690a2..0000000000 --- a/usr/src/uts/common/sys/lom_priv.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2001-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_LOM_PRIV_H -#define _SYS_LOM_PRIV_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Project private LOMlite definitions. - * The definitions here are not used by the end user. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _KERNEL -#ifdef __sparc -#include <sys/cpu_sgnblk_defs.h> -#endif /* __sparc */ -#endif /* _KERNEL */ - -/* - * Data structures which are passed to the driver via the LOMIOCPROG ioctl. - * - * The userland utility constructs an image which begins with a - * lom_prog_data_t structure and is followed by platform specific data - * the contents of which are identified by the 'platmagic' value. - */ -typedef struct { - union { - uint32_t magic; - struct { - uint16_t size; - uint16_t loadaddr; - } old_prog; - } header; - uint32_t platmagic; - /* Platform specific */ - union { - struct { - uint32_t loadaddr; - uint32_t size; - } bscv; - } platform; -} lom_prog_data_t; - -/* - * header.magic value - this is chosen because it never occurs on the old - * programming data - */ -#define PROG_MAGIC 0 - -/* - * platmagic values. - * Top two bytes assigned to specific lom implementations/platform - * Bottom two bytes assigned by the implementations/platform. - * - * 0x4c56 "LV" - bscv and derivatives. - * 0x4c564c4f "LVLO" - firmware downloader. - * 0x4c56494d "LVIM" - firmware image. - * 0x5347 "SG" - serengeti based lom. - * Not specified here. - */ - -#define PROG_PLAT_BSCV_LOADER 0x4c564c4f -#define PROG_PLAT_BSCV_IMAGE 0x4c56494d -#define PROG_PLAT_SG_IMAGE 0x5347494d - -/* defn for top byte of 16bit event code */ -#define EVENT_SUBSYS_NONE 0x00 -#define EVENT_SUBSYS_ALARM 0x01 -#define EVENT_SUBSYS_TEMP 0x02 -#define EVENT_SUBSYS_OVERTEMP 0x03 -#define EVENT_SUBSYS_FAN 0x04 -#define EVENT_SUBSYS_SUPPLY 0x05 -#define EVENT_SUBSYS_BREAKER 0x06 -#define EVENT_SUBSYS_PSU 0x07 -#define EVENT_SUBSYS_USER 0x08 -#define EVENT_SUBSYS_PHONEHOME 0x09 -#define EVENT_SUBSYS_LOM 0x0a -#define EVENT_SUBSYS_HOST 0x0b -#define EVENT_SUBSYS_EVENTLOG 0x0c -#define EVENT_SUBSYS_EXTRA 0x0d /* reserved for future use */ -#define EVENT_SUBSYS_LED 0x0e - -#define EVENT_MASK_SHUTDOWN_REQD 0x20 -#define EVENT_MASK_FAULT 0x40 -#define EVENT_MASK_FATAL 0x80 - - -#define EVENT_NONE 0x00 -#define EVENT_STATE_ON 0x01 -#define EVENT_STATE_OFF 0x02 -#define EVENT_STATE_CHANGE 0x03 -#define EVENT_POWER_ON 0x04 -#define EVENT_POWER_OFF 0x05 -#define EVENT_UNEXPECTED_POWER_OFF 0x06 -#define EVENT_UNEXPECTED_RESET 0x07 -#define EVENT_BOOTED 0x08 -#define EVENT_WATCHDOG_ON 0x09 -#define EVENT_WATCHDOG_OFF 0x0a -#define EVENT_WATCHDOG_TRIGGER 0x0b -#define EVENT_FAILED 0x0c -#define EVENT_RECOVERED 0x0d -#define EVENT_RESET 0x0e -#define EVENT_ABORT 0x0f -#define EVENT_CONSOLE_SELECT 0x10 -#define EVENT_TIME_REFERENCE 0x11 -#define EVENT_SCRIPT_FAILURE 0x12 -#define EVENT_MODEM_ACCESS_FAIL 0x13 -#define EVENT_MODEM_DIAL_FAIL 0x14 -#define EVENT_BAD_CHECKSUM 0x15 -#define EVENT_USER_ADDED 0x16 -#define EVENT_USER_REMOVED 0x17 -#define EVENT_USER_PERMSCHANGED 0x18 -#define EVENT_USER_LOGIN 0x19 -#define EVENT_USER_PASSWORD_CHANGE 0x1a -#define EVENT_USER_LOGINFAIL 0x1b -#define EVENT_USER_LOGOUT 0x1c -#define EVENT_FLASH_DOWNLOAD 0x1d -#define EVENT_DATA_LOST 0x1e -#define EVENT_DEVICE_BUSY 0x1f -#define EVENT_FAULT_LED 0x20 -#define EVENT_OVERHEAT 0x21 -#define EVENT_SEVERE_OVERHEAT 0x22 -#define EVENT_NO_OVERHEAT 0x23 -#define EVENT_SCC_STATUS 0x24 -/* bscv only */ -#define EVENT_DEVICE_INACCESSIBLE 0x25 -#define EVENT_HOSTNAME_CHANGE 0x26 -#define EVENT_CPUSIG_TIMEOUT 0x27 -#define EVENT_BOOTMODE_CHANGE 0x28 -#define EVENT_WATCHDOG_CHANGE_POLICY 0x29 -#define EVENT_WATCHDOG_CHANGE_TIMEOUT 0x2a - -/* - * Event "detail" information - bscv only - */ -#define LOM_RESET_DETAIL_BYUSER 1 -#define LOM_RESET_DETAIL_REPROGRAMMING 2 - -#define LOM_WDOGTRIGGER_DETAIL_HARD 0 -#define LOM_WDOGTRIGGER_DETAIL_SOFT 1 - -#define LOM_UNEXPECTEDRESET_MASK_BADTRAP 0x80 -#define EBUS_BOOTMODE_FORCE_CONSOLE 0x01 - -/* - * Event log filtering - */ -#define EVENT_LEVEL_USER 4 -#define EVENT_LEVEL_NOTICE 3 -#define EVENT_LEVEL_FAULT 2 -#define EVENT_LEVEL_FATAL 1 - -/* - * Event data - */ -typedef struct { - uint8_t ev_subsys; - uint8_t ev_event; - uint8_t ev_resource; - uint8_t ev_detail; - uint8_t ev_data[4]; -} lom_event_t; - - -#define EVENT_DECODE_SUBSYS(evcode) ((evcode) & 0x1f) -#define EVENT_DECODE_FAULT(evcode) ((evcode) & (EVENT_MASK_FAULT| \ - EVENT_MASK_FATAL| \ - EVENT_MASK_SHUTDOWN_REQD)) - -/* Magic numbers for reading values from conf files */ -#define LOM_TEMP_PROP_NOT_SET 0x80000000 /* Use current setting */ -#define LOM_TEMP_PROP_MIN 40 /* Minimum temp settable */ -#define LOM_TEMP_PROP_MAX 120 /* Maximum temp settable */ - -#define LOM_SERIAL_TOUT_DEFAULT 0 /* Default value */ -#define LOM_SERIAL_TOUT_MIN 5 /* Minimum timeout period */ -#define LOM_SERIAL_TOUT_MAX 0xff /* Maximum timeout period */ - -#ifdef _KERNEL -/* Inter Driver Interface */ - -#define SUNW_KERN_BSCV_MODULENAME "bscv" -#define SUNW_KERN_BSCV_IDI_FN "bscv_idi_set" - -enum bscv_idi_type { - BSCV_IDI_NULL = 0, - BSCV_IDI_NODENAME, - BSCV_IDI_SIG, - BSCV_IDI_WDOG_PAT, - BSCV_IDI_WDOG_CFG -}; - -#ifdef __sparc -typedef -struct { - uint32_t cpu; - sig_state_t sig_info; -} bscv_sig_t; -#endif /* __sparc */ - -typedef -struct { - /* - * Enable the watchdog. This must be done before patting is done. - */ - uint8_t enable_wdog; - - /* - * wdog_timeout_s seconds before watchdog expires; minimum - * value is 1, maximum value is 127. The dog must be patted - * once per second. - */ - uint_t wdog_timeout_s; - - /* - * reset_system_on_timeout false means the microcontroller will only - * log the fact that the watchdog expired, rather than actually - * resetting the host. - */ - uint8_t reset_system_on_timeout; - -} bscv_wdog_t; - -struct bscv_idi_info { - enum bscv_idi_type type; - void *data; - size_t size; -}; - -void bscv_idi_set(struct bscv_idi_info info); - -#endif /* _KERNEL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_LOM_PRIV_H */ diff --git a/usr/src/uts/intel/Makefile.files b/usr/src/uts/intel/Makefile.files index 5bfb94c49c..057a89f138 100644 --- a/usr/src/uts/intel/Makefile.files +++ b/usr/src/uts/intel/Makefile.files @@ -23,6 +23,7 @@ # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2019 Joyent, Inc. # Copyright 2018 Nexenta Systems, Inc. +# Copyright 2019 Peter Tribble. # # @@ -153,8 +154,6 @@ ARCMSR_OBJS += arcmsr.o ATA_OBJS += $(GHD_OBJS) ata_blacklist.o ata_common.o ata_disk.o \ ata_dma.o atapi.o atapi_fsm.o ata_debug.o \ sil3xxx.o -BSCBUS_OBJS += bscbus.o -BSCV_OBJS += bscv.o CMDK_OBJS += cmdk.o CMLB_OBJS += cmlb.o CPUNEX_OBJS += cpunex.o diff --git a/usr/src/uts/intel/Makefile.intel b/usr/src/uts/intel/Makefile.intel index 52f24dd802..820e0a4e31 100644 --- a/usr/src/uts/intel/Makefile.intel +++ b/usr/src/uts/intel/Makefile.intel @@ -26,6 +26,7 @@ # Copyright 2016 Garrett D'Amore <garrett@damore.org> # Copyright 2018 Nexenta Systems, Inc. # Copyright 2019 RackTop Systems +# Copyright 2019 Peter Tribble. # # @@ -255,8 +256,6 @@ DRV_KMODS += bge DRV_KMODS += bofi DRV_KMODS += bpf DRV_KMODS += bridge -DRV_KMODS += bscbus -DRV_KMODS += bscv DRV_KMODS += chxge DRV_KMODS += cxgbe DRV_KMODS += ntxn diff --git a/usr/src/uts/intel/bscbus/Makefile b/usr/src/uts/intel/bscbus/Makefile deleted file mode 100644 index ec4acf91b5..0000000000 --- a/usr/src/uts/intel/bscbus/Makefile +++ /dev/null @@ -1,95 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# uts/intel/bscbus/Makefile -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the bscbus driver -# -# intel architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = bscbus -OBJECTS = $(BSCBUS_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(BSCBUS_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/intel/io - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(CONFMOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW -LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV -LINTTAGS += -erroff=E_SUSPICIOUS_COMPARISON - -CERRWARN += -_gcc=-Wno-unused-value - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/intel/bscv/Makefile b/usr/src/uts/intel/bscv/Makefile deleted file mode 100644 index 6a61281ca9..0000000000 --- a/usr/src/uts/intel/bscv/Makefile +++ /dev/null @@ -1,97 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# uts/intel/bscv/Makefile -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the bscv driver -# -# intel architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = bscv -OBJECTS = $(BSCV_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(BSCV_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/intel/io - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(CONFMOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW -LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV -LINTTAGS += -erroff=E_SUSPICIOUS_COMPARISON - -CERRWARN += $(CNOWARN_UNINIT) -CERRWARN += -_gcc=-Wno-unused-value - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/intel/io/bscbus.conf b/usr/src/uts/intel/io/bscbus.conf deleted file mode 100644 index c783e2619d..0000000000 --- a/usr/src/uts/intel/io/bscbus.conf +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2003 Sun Microsystems, Inc. -# All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# -# Configuration file for "bscbus" driver -# - -interrupt-priorities = 8, 8; diff --git a/usr/src/uts/intel/io/bscv.conf b/usr/src/uts/intel/io/bscv.conf deleted file mode 100644 index 20f96109e4..0000000000 --- a/usr/src/uts/intel/io/bscv.conf +++ /dev/null @@ -1,38 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# Configuration file for bscv driver -# - -ddi-forceattach=1; - -# -# The DEBUG version of the bscv driver supports a debug option value. -# -debug=0x0; - -parent="bscbus" name="bscv" instance=0; -reg=0x0, 0x0, 0x4000, 0x201, 0x0, 0x1; diff --git a/usr/src/uts/sun4u/Makefile.files b/usr/src/uts/sun4u/Makefile.files index 5e6e640a1f..740f792c5d 100644 --- a/usr/src/uts/sun4u/Makefile.files +++ b/usr/src/uts/sun4u/Makefile.files @@ -132,7 +132,6 @@ PMUBUS_OBJS += pmubus.o PMUGPIO_OBJS += pmugpio.o PMC_OBJS += pmc.o TRAPSTAT_OBJS += trapstat.o -I2BSC_OBJS += i2bsc.o GPTWOCFG_OBJS += gptwocfg.o GPTWO_CPU_OBJS += gptwo_cpu.o @@ -161,7 +160,6 @@ SHA1_OBJS += sha1_asm.o TODMOSTEK_OBJS += todmostek.o TODDS1287_OBJS += todds1287.o TODDS1337_OBJS += todds1337.o -TODBLADE_OBJS += todblade.o TODM5819_OBJS += todm5819.o TODM5819P_RMC_OBJS += todm5819p_rmc.o TODBQ4802_OBJS += todbq4802.o diff --git a/usr/src/uts/sun4u/Makefile.sun4u b/usr/src/uts/sun4u/Makefile.sun4u index c69198cb2e..7b4b7c0985 100644 --- a/usr/src/uts/sun4u/Makefile.sun4u +++ b/usr/src/uts/sun4u/Makefile.sun4u @@ -174,7 +174,6 @@ IMPLEMENTATIONS += daktari IMPLEMENTATIONS += cherrystone IMPLEMENTATIONS += fjlite IMPLEMENTATIONS += schumacher -IMPLEMENTATIONS += blade IMPLEMENTATIONS += boston IMPLEMENTATIONS += seattle IMPLEMENTATIONS += chicago @@ -389,7 +388,6 @@ DRV_KMODS += rmcadm DRV_KMODS += rmclomv DRV_KMODS += sf DRV_KMODS += nxge -DRV_KMODS += i2bsc DRV_KMODS += mem_cache # @@ -457,7 +455,7 @@ CPU_KMODS += cheetah cheetahplus jalapeno serrano spitfire hummingbird # sun4u 'TOD' Modules (/platform/.../kernel/tod): # TOD_KMODS += todds1287 todds1337 todmostek -TOD_KMODS += todm5819 todblade todbq4802 todsg todopl +TOD_KMODS += todm5819 todbq4802 todsg todopl TOD_KMODS += todm5819p_rmc # diff --git a/usr/src/uts/sun4u/blade/Makefile b/usr/src/uts/sun4u/blade/Makefile deleted file mode 100644 index 0a93a62379..0000000000 --- a/usr/src/uts/sun4u/blade/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# This makefile drives the production of the sun4u JBOS - blade platform -# module. -# -# sun4u jbos-blade implementation architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -include $(UTSBASE)/sun4u/blade/Makefile.blade - -# -# -# - -def := TARGET= def -all := TARGET= all -install := TARGET= install -install_h := TARGET= install_h -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -lintlib := TARGET= lintlib -modlintlib := TARGET= modlintlib -modlist := TARGET= modlist -modlist := NO_STATE= -K $$MODSTATE$$$$ -clean.lint := TARGET= clean.lint -check := TARGET= check - -IMPLEMENTED_PLATFORM = SUNW,Serverblade1 -LINK1DESTDIR = ../../../../SUNW,Sun-Blade-100/kernel/drv/sparcv9 -BLADE_LINK_1 = SUNW,Serverblade1/kernel/drv/sparcv9/pmubus -BLADE_PLAT_LINK1 = $(BLADE_LINK_1:%=$(ROOT_PLAT_DIR)/%) - -# -# Default build targets. -# -.KEEP_STATE: - -.PARALLEL: $(BLADE_KMODS) $(CLOSED_BLADE_KMODS) - -def all clean clobber clean.lint modlist: $(BLADE_KMODS) $(CLOSED_BLADE_KMODS) - -install: $(ROOT_BLADE_DIR) \ - $(USR_BLADE_DIR) \ - $(USR_BLADE_INC_DIR) \ - $(USR_BLADE_SBIN_DIR) \ - $(USR_BLADE_LIB_DIR) \ - .WAIT $(BLADE_KMODS) $(CLOSED_BLADE_KMODS) \ - $(BLADE_OPTION) \ - $(BLADE_PLAT_LINK_1) - -modlintlib: $(BLADE_KMODS) $(CLOSED_BLADE_KMODS) - -$(BLADE_KMODS): FRC - @cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET) - -$(CLOSED_BLADE_KMODS): FRC - cd $(CLOSED)/uts/sun4u/blade/$@; pwd; $(MAKE) $(NO_STATE) $(TARGET) - -$(BLADE_OPTION): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -install_h check: - -lint: modlintlib .WAIT $(LINT_DEPS) - -LINT_LIBS = $(LINT_LIB) \ - -L$(BLADE_LINT_LIB_DIR) \ - -L$(LINT_LIB_DIR) $(LINT_KMODS:%=-l%) \ - $(CLOSED_LINT_KMODS:%=-l%) \ - -L$(SPARC_LIB_DIR) $(SPARC_LINTS:%=-l%) - -lint.platmod: modlintlib - @-$(ECHO) "\nJBOS-blade Platform-dependent module: global crosschecks:" - @-$(LINT) $(LINTFLAGS) $(LINT_LIBS) 2>&1 | $(LGREP.2) - - -$(BLADE_PLAT_LINK_1): $(ROOT_BLADE_DRV_DIR) - $(RM) $@; $(SYMLINK) $(LINK1DESTDIR)/$(@F) $@ -# -# Include common targets. -# -include $(UTSBASE)/sun4u/blade/Makefile.targ diff --git a/usr/src/uts/sun4u/blade/Makefile.blade b/usr/src/uts/sun4u/blade/Makefile.blade deleted file mode 100644 index 0ccf460698..0000000000 --- a/usr/src/uts/sun4u/blade/Makefile.blade +++ /dev/null @@ -1,122 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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. -# -# Global definitions for sun4u jbos-blade implementation specific modules. -# - -# -# Define directories. -# -ROOT_BLADE_DIR = $(ROOT_PLAT_DIR)/SUNW,Serverblade1 -ROOT_BLADE_MOD_DIR = $(ROOT_BLADE_DIR)/kernel -ROOT_BLADE_MISC_DIR_32 = $(ROOT_BLADE_DIR)/kernel/misc -ROOT_BLADE_MISC_DIR_64 = $(ROOT_BLADE_MISC_DIR_32)/$(SUBDIR64) -ROOT_BLADE_KERN_DIR_32 = $(ROOT_BLADE_MOD_DIR) -ROOT_BLADE_KERN_DIR_64 = $(ROOT_BLADE_MOD_DIR)/$(SUBDIR64) -ROOT_BLADE_DRV_DIR_32 = $(ROOT_BLADE_MOD_DIR)/drv -ROOT_BLADE_DRV_DIR_64 = $(ROOT_BLADE_MOD_DIR)/drv/$(SUBDIR64) - -ROOT_BLADE_KERN_DIR = $(ROOT_BLADE_KERN_DIR_$(CLASS)) -ROOT_BLADE_DRV_DIR = $(ROOT_BLADE_DRV_DIR_$(CLASS)) -ROOT_BLADE_MISC_DIR = $(ROOT_BLADE_MISC_DIR_$(CLASS)) - -ROOT_PLAT_MOD_DIRS += $(ROOT_BLADE_MOD_DIR) -ROOT_PLAT_MISC_DIRS += $(ROOT_BLADE_MISC_DIR) - - -USR_SUN4U_PLAT_DIR = $(USR_PLAT_DIR)/sun4u -USR_BLADE_DIR = $(USR_PLAT_DIR)/SUNW,Serverblade1 -USR_BLADE_INC_DIR = $(USR_BLADE_DIR)/include -USR_BLADE_ISYS_DIR = $(USR_BLADE_INC_DIR)/sys -USR_BLADE_SBIN_DIR = $(USR_BLADE_DIR)/sbin -USR_BLADE_LIB_DIR = $(USR_BLADE_DIR)/lib - - -BLADE_LINT_LIB_DIR= $(UTSBASE)/$(PLATFORM)/blade/lint-libs/$(OBJS_DIR) - - -# Define Objects -# -BLADE_OBJS = blade.o - -# -# Option conf file -BLADE_OPTION = options - -# -# Include the makefiles which define build rule templates, the -# collection of files per module, and a few specific flags. Note -# that order is significant, just as with an include path. The -# first build rule template which matches the files name will be -# used. By including these in order from most machine dependent -# to most machine independent, we allow a machine dependent file -# to be used in preference over a machine independent version -# (Such as a machine specific optimization, which preserves the -# interfaces.) -# - -include $(UTSBASE)/sun4u/blade/Makefile.files - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/Makefile.sun4u - -# -# Define modules (must come after Makefile.sun4u). -# -BLADE_KMODS = platmod -BLADE_KMODS += bscbus -BLADE_KMODS += bscv - -LINTS_DIR = $(OBJS_DIR) -LINT_LIB_DIR = $(UTSBASE)/$(PLATFORM)/blade/lint-libs/$(OBJS_DIR) -LINT_LIB= $(UTSBASE)/$(PLATFORM)/lint-libs/$(OBJS_DIR)/llib-lunix.ln -GEN_LINT_LIB= $(UTSBASE)/$(PLATFORM)/lint-libs/$(OBJS_DIR)/llib-lgenunix.ln - - -# -# Define the actual specific platforms -# -MACHINE_DEFS += -D$(PLATFORM) -D_MACHDEP -DSFMMU - -# -# Define for inline pre-processing since -# cpp not smart about v9 yet. -# -#CPP_DEFS_32 = -#CPP_DEFS_64 = -D__sparcv9 -#CPP_DEFS = $(CPP_DEFS_$(CLASS)) - -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_SUSPICIOUS_COMPARISON -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED -LINTTAGS += -erroff=E_STATIC_UNUSED -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW -LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV diff --git a/usr/src/uts/sun4u/blade/Makefile.files b/usr/src/uts/sun4u/blade/Makefile.files deleted file mode 100644 index e28eaae1e6..0000000000 --- a/usr/src/uts/sun4u/blade/Makefile.files +++ /dev/null @@ -1,41 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# This Makefile defines all file modules for the directory -# uts/sun4u/blade and its children. These are the source files which -# are blade "implementation architecture" dependent. -# - -# -# Object lists -# -BSCBUS_OBJS = bscbus.o -BSCV_OBJS = bscv.o - -# -# Miscellaneous -# -INC_PATH += -I$(UTSBASE)/sun4u/blade diff --git a/usr/src/uts/sun4u/blade/Makefile.rules b/usr/src/uts/sun4u/blade/Makefile.rules deleted file mode 100644 index eff3be4612..0000000000 --- a/usr/src/uts/sun4u/blade/Makefile.rules +++ /dev/null @@ -1,60 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# This Makefile defines the build rules for the directory -# uts/sun4u/blade and its children. -# - -# -# C object build rules -# - -# -# blade specific drivers -# - -$(OBJS_DIR)/%.o: $(UTSBASE)/sun4u/blade/os/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - -$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - -# -# Lint object build rules -# - -# -# blade specific drivers -# - -$(LINTS_DIR)/%.ln: $(UTSBASE)/sun4u/blade/os/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) - -$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/sun4u/blade/Makefile.targ b/usr/src/uts/sun4u/blade/Makefile.targ deleted file mode 100644 index c1982355a9..0000000000 --- a/usr/src/uts/sun4u/blade/Makefile.targ +++ /dev/null @@ -1,80 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Common targets for sun4u jbos-blade implementation specific modules. -# - -.KEEP_STATE: - -# -# Rules for implementation subdirectories. -# -$(ROOT_BLADE_DIR): $(ROOT_PLAT_DIR) - -$(INS.dir) - -$(ROOT_BLADE_MOD_DIR): $(ROOT_BLADE_DIR) - -$(INS.dir) - -$(ROOT_BLADE_DRV_DIR_32): $(ROOT_BLADE_MOD_DIR) - -$(INS.dir) - -$(ROOT_BLADE_DRV_DIR_64): $(ROOT_BLADE_DRV_DIR_32) - -$(INS.dir) - -$(ROOT_BLADE_MISC_DIR_32): $(ROOT_BLADE_MOD_DIR) - -$(INS.dir) - -$(ROOT_BLADE_MISC_DIR_64): $(ROOT_BLADE_MISC_DIR_32) - -$(INS.dir) - -$(ROOT_BLADE_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_BLADE_MOD_DIR) FRC - $(INS.file) - -$(ROOT_BLADE_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_BLADE_MISC_DIR) FRC - $(INS.file) - -$(ROOT_BLADE_DRV_DIR)/%: $(OBJS_DIR)/% $(ROOT_BLADE_DRV_DIR) FRC - $(INS.file) - -$(USR_BLADE_DIR): $(USR_PLAT_DIR) - -$(INS.dir) - -$(USR_BLADE_INC_DIR): $(USR_BLADE_DIR) - -$(INS.slink4) - -$(USR_BLADE_ISYS_DIR): $(USR_BLADE_INC_DIR) - -$(INS.dir) - -$(USR_BLADE_SBIN_DIR): $(USR_BLADE_DIR) - $(INS.slink5) - -$(USR_BLADE_LIB_DIR): $(USR_BLADE_DIR) - -$(INS.dir) -# -# Include common targets. -# -include $(UTSBASE)/sun4u/blade/Makefile.rules -include $(UTSBASE)/sun4u/Makefile.targ diff --git a/usr/src/uts/sun4u/blade/bscbus/Makefile b/usr/src/uts/sun4u/blade/bscbus/Makefile deleted file mode 100644 index 916901075b..0000000000 --- a/usr/src/uts/sun4u/blade/bscbus/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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. -# -# ident "%Z%%M% %I% %E% SMI" -# -# uts/sun4u/blade/bscbus/Makefile -# -# This makefile drives the production of the bscbus driver kernel -# module in the sun4u blade systems -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../../.. - -# -# Define the module and object file sets. -# -MODULE = bscbus -OBJECTS = $(BSCBUS_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(BSCBUS_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_BLADE_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/sun4u/blade/io - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/blade/Makefile.blade - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(SRC_CONFILE) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# Overrides -# -ALL_BUILDS = $(ALL_BUILDSONLY64) -DEF_BUILDS = $(DEF_BUILDSONLY64) -CLEANLINTFILES += $(LINT32_FILES) - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - -# -# Turn on doubleword alignment for 64 bit registers -# -CFLAGS += -dalign - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sun4u/blade/Makefile.targ diff --git a/usr/src/uts/sun4u/blade/bscv/Makefile b/usr/src/uts/sun4u/blade/bscv/Makefile deleted file mode 100644 index b87a1cb5fd..0000000000 --- a/usr/src/uts/sun4u/blade/bscv/Makefile +++ /dev/null @@ -1,95 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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. -# - -# -# This makefile drives the production of the sun4u "bscv" driver module. -# -# sun4u implementation architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../../.. - -# -# Define the module and object file sets. -# -MODULE = bscv -OBJECTS = $(BSCV_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(BSCV_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_BLADE_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/sun4u/blade/io - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/blade/Makefile.blade - -# -# Overrides -# -ALL_BUILDS = $(ALL_BUILDSONLY64) -DEF_BUILDS = $(DEF_BUILDSONLY64) -CLEANLINTFILES += $(LINT32_FILES) - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(SRC_CONFFILE) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) -CERRWARN += $(CNOWARN_UNINIT) - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sun4u/blade/Makefile.targ diff --git a/usr/src/uts/sun4u/blade/io/bscbus.conf b/usr/src/uts/sun4u/blade/io/bscbus.conf deleted file mode 100644 index a00c7f80f6..0000000000 --- a/usr/src/uts/sun4u/blade/io/bscbus.conf +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2002 Sun Microsystems, Inc. -# All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# -# Configuration file for "bscbus" driver -# - -interrupt-priorities = 8, 8, 8, 8; diff --git a/usr/src/uts/sun4u/blade/io/bscv.conf b/usr/src/uts/sun4u/blade/io/bscv.conf deleted file mode 100644 index 238e0ff7f3..0000000000 --- a/usr/src/uts/sun4u/blade/io/bscv.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# Configuration file for bscv driver -# - -# -# The DEBUG version of the bscv driver supports a debug option value. -# -debug=0x0; diff --git a/usr/src/uts/sun4u/blade/io/options.conf b/usr/src/uts/sun4u/blade/io/options.conf deleted file mode 100644 index 99dabb338d..0000000000 --- a/usr/src/uts/sun4u/blade/io/options.conf +++ /dev/null @@ -1,41 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# The property "ttymodes" defines the default termios modes -# (upon driver open) for the console ttys on Stiletto/JBOS blades. -# -# ttymodes=<string> -# -# The format of <string> is the same format as the output of -# the "-g" option to /usr/bin/stty. Some standard termios modes -# have been included for reference: -# -# For SVID compliance, use these modes, -# "522:1805:4b7:2b:7f:1c:23:40:4:0:0:0:11:13:1a:19:12:f:17:16" -# -# - -name="options" class="root" -ttymodes="2502:1805:800000bd:8a3b:3:1c:7f:15:4:0:0:0:11:13:1a:19:12:f:17:16:14:8"; diff --git a/usr/src/uts/sun4u/blade/options/Makefile b/usr/src/uts/sun4u/blade/options/Makefile deleted file mode 100644 index 6ba8255bc4..0000000000 --- a/usr/src/uts/sun4u/blade/options/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# -# This makefile drives the production of the blade options conf file -# -# sparc architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../../.. - -# -# Define the module and object file sets. -# -MODULE = options -ROOTMODULE = $(ROOT_BLADE_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/sun4u/blade/io - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/blade/Makefile.blade - -# -# Define targets -# -ALL_TARGET = $(SRC_CONFILE) -LINT_TARGET = -INSTALL_TARGET = $(ROOT_BLADE_DRV_DIR) $(ROOT_CONFFILE) - -# -# Overrides. -# -CFLAGS += $(CCVERBOSE) - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sun4u/blade/Makefile.targ diff --git a/usr/src/uts/sun4u/blade/os/blade.c b/usr/src/uts/sun4u/blade/os/blade.c deleted file mode 100644 index 54e57d535d..0000000000 --- a/usr/src/uts/sun4u/blade/os/blade.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/sunddi.h> -#include <sys/esunddi.h> -#include <sys/ddi.h> - -#include <sys/platform_module.h> -#include <sys/modctl.h> -#include <sys/lom_priv.h> -#include <sys/errno.h> -#include <sys/utsname.h> - -#define TOD_DRIVER_NAME "todblade" -#define BSC_DRV SUNW_KERN_BSCV_MODULENAME -#define BSC_DRV_FUNC SUNW_KERN_BSCV_IDI_FN - - -/* local functions */ -static void cpu_sgn_update(ushort_t, uchar_t, uchar_t, int); - -/* Globals */ -void (*bsc_drv_func_ptr)(struct bscv_idi_info *) = NULL; - - -void -startup_platform(void) -{ - extern char *tod_module_name; - extern int watchdog_available; - extern int watchdog_enable; - extern int disable_watchdog_on_exit; - - /* Set appropriate tod module for blade */ - tod_module_name = TOD_DRIVER_NAME; - - /* Set watchdog default configuration */ - watchdog_available = 1; - watchdog_enable = 1; - disable_watchdog_on_exit = 1; -} - -int -set_platform_tsb_spares() -{ - return (0); -} - -void -set_platform_defaults(void) -{ - /* Set the CPU signature function pointer */ - cpu_sgn_func = cpu_sgn_update; -} - -/* - * Definitions for accessing the pci config space of the isa node - * of Southbridge. - */ -#define PLATFORM_ISA_PATHNAME "/pci@1f,0/isa@7" -#define PLATFORM_ISA_PATHNAME_WITH_SIMBA "/pci@1f,0/pci@1,1/isa@7" -static ddi_acc_handle_t platform_isa_handle; /* handle for isa pci space */ - -void -load_platform_drivers(void) -{ - extern int watchdog_available; - extern int watchdog_enable; - dev_info_t *dip; /* dip of the isa driver */ - int simba_present = 0; - dev_info_t *root_child_node; - major_t major; - - if (ddi_install_driver("power") != DDI_SUCCESS) - cmn_err(CE_WARN, "Failed to install \"power\" driver."); - - /* - * Install Isa driver. This is required for the southbridge IDE - * workaround - to reset the IDE channel during IDE bus reset. - * Panic the system in case ISA driver could not be loaded or - * any problem in accessing its pci config space. Since the register - * to reset the channel for IDE is in ISA config space!. - */ - root_child_node = ddi_get_child(ddi_root_node()); - - while (root_child_node != NULL) { - if (strcmp(ddi_node_name(root_child_node), "pci") == 0) { - root_child_node = ddi_get_child(root_child_node); - if (strcmp(ddi_node_name(root_child_node), "pci") == 0) - simba_present = 1; - break; - } - root_child_node = ddi_get_next_sibling(root_child_node); - } - - if (simba_present) - dip = e_ddi_hold_devi_by_path(PLATFORM_ISA_PATHNAME_WITH_SIMBA, - 0); - else - dip = e_ddi_hold_devi_by_path(PLATFORM_ISA_PATHNAME, 0); - - if (dip == NULL) { - cmn_err(CE_PANIC, "Could not install the isa driver\n"); - return; - } - - if (pci_config_setup(dip, &platform_isa_handle) != DDI_SUCCESS) { - cmn_err(CE_PANIC, "Could not get the config space of isa\n"); - return; - } - - /* - * Load the blade support chip driver. - * - */ - - if (((major = ddi_name_to_major(BSC_DRV)) == -1) || - (ddi_hold_installed_driver(major) == NULL)) { - cmn_err(CE_WARN, "%s: failed to load", BSC_DRV); - } else { - - bsc_drv_func_ptr = (void (*)(struct bscv_idi_info *)) - modgetsymvalue(BSC_DRV_FUNC, 0); - - if (bsc_drv_func_ptr == NULL) { - cmn_err(CE_WARN, "load_platform_defaults: %s()" - " not found; signatures will not be updated\n", - BSC_DRV_FUNC); - watchdog_available = 0; - if (watchdog_enable) { - cmn_err(CE_WARN, "load_platform_defaults: %s()" - " not found; BSC OS watchdog service not available\n", - BSC_DRV_FUNC); - } - } - } -} - -/* - * This routine provides a workaround for a bug in the SB chip which - * can cause data corruption. Will be invoked from the IDE HBA driver for - * Acer SouthBridge at the time of IDE bus reset. - */ -/*ARGSUSED*/ -int -plat_ide_chipreset(dev_info_t *dip, int chno) -{ - uint8_t val; - int ret = DDI_SUCCESS; - - if (platform_isa_handle == NULL) - return (DDI_FAILURE); - - val = pci_config_get8(platform_isa_handle, 0x58); - /* - * The dip passed as the argument is not used for platform. - * This will be needed for platforms which have multiple on-board SB, - * The dip passed will be used to match the corresponding ISA node. - */ - switch (chno) { - case 0: - /* - * First disable the primary channel then re-enable it. - * As per ALI no wait should be required in between have - * given 1ms delay in between to be on safer side. - * bit 2 of register 0x58 when 0 disable the channel 0. - * bit 2 of register 0x58 when 1 enables the channel 0. - */ - pci_config_put8(platform_isa_handle, 0x58, val & 0xFB); - drv_usecwait(1000); - pci_config_put8(platform_isa_handle, 0x58, val); - break; - case 1: - /* - * bit 3 of register 0x58 when 0 disable the channel 1. - * bit 3 of register 0x58 when 1 enables the channel 1. - */ - pci_config_put8(platform_isa_handle, 0x58, val & 0xF7); - drv_usecwait(1000); - pci_config_put8(platform_isa_handle, 0x58, val); - break; - default: - /* - * Unknown channel number passed. Return failure. - */ - ret = DDI_FAILURE; - } - - return (ret); -} - - - -/*ARGSUSED*/ -int -plat_cpu_poweron(struct cpu *cp) -{ - return (ENOTSUP); /* not supported on this platform */ -} - -/*ARGSUSED*/ -int -plat_cpu_poweroff(struct cpu *cp) -{ - return (ENOTSUP); /* not supported on this platform */ -} - -/*ARGSUSED*/ -void -plat_freelist_process(int mnode) -{ -} - -char *platform_module_list[] = { - (char *)0 -}; - -/*ARGSUSED*/ -void -plat_tod_fault(enum tod_fault_type tod_bad) -{ -} - -/* - * Our nodename has been set, pass it along to the BSC. - */ -void -plat_nodename_set(void) -{ - struct bscv_idi_info bscv_info; - - bscv_info.type = BSCV_IDI_NODENAME; - bscv_info.data = utsname.nodename; - bscv_info.size = strlen(utsname.nodename); - - if (bsc_drv_func_ptr != NULL) - (bsc_drv_func_ptr)(&bscv_info); -} - -/* - * Send an updated CPU signature to the BSC. - */ - -static void -cpu_sgn_update(ushort_t sig, uchar_t state, uchar_t sub_state, int cpuid) -{ - struct bscv_idi_info bscv_info; - bscv_sig_t sc; - - sc.sig_info.signature = CPU_SIG_BLD(sig, state, sub_state); - sc.cpu = cpuid; - - bscv_info.type = BSCV_IDI_SIG; - bscv_info.data = ≻ - bscv_info.size = sizeof (sc); - - - if (bsc_drv_func_ptr != NULL) - (*bsc_drv_func_ptr)(&bscv_info); -} diff --git a/usr/src/uts/sun4u/blade/platmod/Makefile b/usr/src/uts/sun4u/blade/platmod/Makefile deleted file mode 100644 index 623d5d1da6..0000000000 --- a/usr/src/uts/sun4u/blade/platmod/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# This makefile drives the production of the sun4u blade platform module. -# -# sun4u implementation architecture dependent -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../../.. - -# -# Define the module and object file sets. -# -MODULE = platmod -OBJECTS = $(BLADE_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(BLADE_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_BLADE_MISC_DIR)/$(MODULE) - -PLAT_DIR = . -HERE = ../blade/platmod - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/blade/Makefile.blade - -# -# Override defaults -# -CLEANFILES += $(PLATLIB) $(SYM_MOD) - -# -# Define targets -# -ALL_TARGET = $(SYM_MOD) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -check: - -LINT_LIB_DIR = $(BLADE_LINT_LIB_DIR) - -$(PLATLIB): $(OBJECTS) - $(BUILD.SO) $(OBJECTS) - -$(SYM_MOD): $(UNIX_O) $(PLATLIB) - @echo "resolving symbols against unix.o" - @(cd $(UNIX_DIR); pwd; \ - PLAT_DIR=$(HERE) SYM_MOD=$(HERE)/$(SYM_MOD) $(MAKE) symcheck) - -# -# Include common targets. -# -include $(UTSBASE)/sun4u/blade/Makefile.targ diff --git a/usr/src/uts/sun4u/i2bsc/Makefile b/usr/src/uts/sun4u/i2bsc/Makefile deleted file mode 100644 index 5db65683dc..0000000000 --- a/usr/src/uts/sun4u/i2bsc/Makefile +++ /dev/null @@ -1,90 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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. -# - -# This makefile drives the production of the i2bsc nexus driver. -# -# Path to the base of the uts directory tree (usually /usr/src/uts). - -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = i2bsc -OBJECTS = $(I2BSC_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(I2BSC_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_PSM_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/sun4u/io/i2c/nexus - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/Makefile.sun4u - -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) -I$(UTSBASE)/sun4u - -LDFLAGS += -dy -N misc/i2c_svc - -# -# Define targets -# -ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW -LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV - -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets -# -include $(UTSBASE)/sun4u/Makefile.targ diff --git a/usr/src/uts/sun4u/io/i2c/nexus/i2bsc.c b/usr/src/uts/sun4u/io/i2c/nexus/i2bsc.c deleted file mode 100644 index 7c19bb17ba..0000000000 --- a/usr/src/uts/sun4u/io/i2c/nexus/i2bsc.c +++ /dev/null @@ -1,1258 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -/* - * i2bsc.c is the nexus driver i2c traffic against devices hidden behind the - * Blade Support Chip (BSC). It supports both interrupt and polled - * mode operation, but defaults to interrupt. - */ - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/open.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> -#include <sys/sunndi.h> -#include <sys/modctl.h> -#include <sys/stat.h> -#include <sys/kmem.h> -#include <sys/platform_module.h> -#include <sys/stream.h> -#include <sys/strlog.h> -#include <sys/log.h> -#include <sys/debug.h> -#include <sys/note.h> - -#include <sys/bscbus.h> -#include <sys/lom_ebuscodes.h> - -#include <sys/i2c/clients/i2c_client.h> -#include <sys/i2c/misc/i2c_svc.h> -#include <sys/i2c/misc/i2c_svc_impl.h> -#include <sys/i2c/nexus/i2bsc_impl.h> - -/* - * static function declarations - */ -static void i2bsc_resume(dev_info_t *dip); -static void i2bsc_suspend(dev_info_t *dip); -static int i2bsc_bus_ctl(dev_info_t *dip, dev_info_t *rdip, - ddi_ctl_enum_t op, void *arg, void *result); -static void i2bsc_acquire(i2bsc_t *, dev_info_t *dip, - i2c_transfer_t *tp); -static void i2bsc_release(i2bsc_t *); -static int i2bsc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); -static int i2bsc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); -static int i2bsc_open(dev_t *devp, int flag, int otyp, - cred_t *cred_p); -static int i2bsc_close(dev_t dev, int flag, int otyp, - cred_t *cred_p); -static int i2bsc_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); -static int i2bsc_initchild(dev_info_t *dip, dev_info_t *cdip); -static int i2bsc_uninitchild(dev_info_t *dip, dev_info_t *cdip); -static int i2bsc_setup_regs(i2bsc_t *); -static void i2bsc_start_session(i2bsc_t *); -static void i2bsc_fail_session(i2bsc_t *); -static int i2bsc_end_session(i2bsc_t *); -static void i2bsc_free_regs(i2bsc_t *); -static int i2bsc_reportdev(dev_info_t *dip, dev_info_t *rdip); -int i2bsc_transfer(dev_info_t *dip, i2c_transfer_t *tp); -static void i2bsc_trace(i2bsc_t *, char, const char *, - const char *, ...); -static int i2bsc_notify_max_transfer_size(i2bsc_t *); -static int i2bsc_discover_capability(i2bsc_t *); -static void i2bsc_put8(i2bsc_t *, uint8_t, uint8_t, uint8_t); -static uint8_t i2bsc_get8(i2bsc_t *, uint8_t, uint8_t); -static int i2bsc_safe_upload(i2bsc_t *, i2c_transfer_t *); -static boolean_t i2bsc_is_firmware_broken(i2bsc_t *); - -static struct bus_ops i2bsc_busops = { - BUSO_REV, - nullbusmap, /* bus_map */ - NULL, /* bus_get_intrspec */ - NULL, /* bus_add_intrspec */ - NULL, /* bus_remove_intrspec */ - NULL, /* bus_map_fault */ - ddi_no_dma_map, /* bus_dma_map */ - ddi_no_dma_allochdl, /* bus_dma_allochdl */ - ddi_no_dma_freehdl, /* bus_dma_freehdl */ - ddi_no_dma_bindhdl, /* bus_dma_bindhdl */ - ddi_no_dma_unbindhdl, /* bus_unbindhdl */ - ddi_no_dma_flush, /* bus_dma_flush */ - ddi_no_dma_win, /* bus_dma_win */ - ddi_no_dma_mctl, /* bus_dma_ctl */ - i2bsc_bus_ctl, /* bus_ctl */ - ddi_bus_prop_op, /* bus_prop_op */ - NULL, /* bus_get_eventcookie */ - NULL, /* bus_add_eventcall */ - NULL, /* bus_remove_eventcall */ - NULL, /* bus_post_event */ - 0, /* bus_intr_ctl */ - 0, /* bus_config */ - 0, /* bus_unconfig */ - 0, /* bus_fm_init */ - 0, /* bus_fm_fini */ - 0, /* bus_fm_access_enter */ - 0, /* bus_fm_access_exit */ - 0, /* bus_power */ - i_ddi_intr_ops /* bus_intr_op */ - -}; - -struct cb_ops i2bsc_cb_ops = { - i2bsc_open, /* open */ - i2bsc_close, /* close */ - nodev, /* strategy */ - nodev, /* print */ - nodev, /* dump */ - nodev, /* read */ - nodev, /* write */ - i2bsc_ioctl, /* ioctl */ - nodev, /* devmap */ - nodev, /* mmap */ - nodev, /* segmap */ - nochpoll, /* poll */ - ddi_prop_op, /* cb_prop_op */ - 0, /* streamtab */ - D_MP | D_NEW /* Driver compatibility flag */ -}; - -static struct dev_ops i2bsc_ops = { - DEVO_REV, - 0, - ddi_getinfo_1to1, - nulldev, - nulldev, - i2bsc_attach, - i2bsc_detach, - nodev, - &i2bsc_cb_ops, - &i2bsc_busops, - NULL, - ddi_quiesce_not_supported, /* devo_quiesce */ -}; - -#ifdef DEBUG -#define I2BSC_VERSION_STRING "i2bsc driver - Debug" -#else -#define I2BSC_VERSION_STRING "i2bsc driver" -#endif - -static struct modldrv modldrv = { - &mod_driverops, /* Type of module. This one is a driver */ - I2BSC_VERSION_STRING, /* Name of the module. */ - &i2bsc_ops, /* driver ops */ -}; - -static struct modlinkage modlinkage = { - MODREV_1, - &modldrv, - NULL -}; - -/* - * i2bsc soft state - */ -static void *i2bsc_state; - -i2c_nexus_reg_t i2bsc_regvec = { - I2C_NEXUS_REV, - i2bsc_transfer, -}; - -int -_init(void) -{ - int status; - - status = ddi_soft_state_init(&i2bsc_state, sizeof (i2bsc_t), - I2BSC_INITIAL_SOFT_SPACE); - if (status != 0) { - return (status); - } - - if ((status = mod_install(&modlinkage)) != 0) { - ddi_soft_state_fini(&i2bsc_state); - } - - return (status); -} - -int -_fini(void) -{ - int status; - - if ((status = mod_remove(&modlinkage)) == 0) { - ddi_soft_state_fini(&i2bsc_state); - } - - return (status); -} - -/* - * The loadable-module _info(9E) entry point - */ -int -_info(struct modinfo *modinfop) -{ - return (mod_info(&modlinkage, modinfop)); -} - -static void -i2bsc_dodetach(dev_info_t *dip) -{ - i2bsc_t *i2c; - int instance = ddi_get_instance(dip); - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - - if ((i2c->i2bsc_attachflags & IMUTEX) != 0) { - mutex_destroy(&i2c->i2bsc_imutex); - cv_destroy(&i2c->i2bsc_icv); - } - if ((i2c->i2bsc_attachflags & SETUP_REGS) != 0) { - i2bsc_free_regs(i2c); - } - if ((i2c->i2bsc_attachflags & NEXUS_REGISTER) != 0) { - i2c_nexus_unregister(dip); - } - if ((i2c->i2bsc_attachflags & MINOR_NODE) != 0) { - ddi_remove_minor_node(dip, NULL); - } - - ddi_soft_state_free(i2bsc_state, instance); -} - -static int -i2bsc_doattach(dev_info_t *dip) -{ - i2bsc_t *i2c; - int instance = ddi_get_instance(dip); - - /* - * Allocate soft state structure. - */ - if (ddi_soft_state_zalloc(i2bsc_state, instance) != DDI_SUCCESS) { - return (DDI_FAILURE); - } - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - - i2c->majornum = ddi_driver_major(dip); - i2c->minornum = instance; - i2c->i2bsc_dip = dip; - i2c->debug = ddi_prop_get_int(DDI_DEV_T_ANY, dip, - DDI_PROP_DONTPASS, "debug", 0); - - (void) snprintf(i2c->i2bsc_name, sizeof (i2c->i2bsc_name), - "%s_%d", ddi_node_name(dip), instance); - - if (i2bsc_setup_regs(i2c) != DDI_SUCCESS) { - goto bad; - } - - i2c->i2bsc_attachflags |= SETUP_REGS; - - mutex_init(&i2c->i2bsc_imutex, NULL, MUTEX_DRIVER, - (void *) 0); - cv_init(&i2c->i2bsc_icv, NULL, CV_DRIVER, NULL); - i2c->i2bsc_attachflags |= IMUTEX; - - i2c_nexus_register(dip, &i2bsc_regvec); - i2c->i2bsc_attachflags |= NEXUS_REGISTER; - - if (ddi_create_minor_node(dip, "devctl", S_IFCHR, instance, - DDI_NT_NEXUS, 0) == DDI_FAILURE) { - cmn_err(CE_WARN, "%s ddi_create_minor_node failed", - i2c->i2bsc_name); - goto bad; - } - - i2c->i2bsc_attachflags |= MINOR_NODE; - - /* - * Now actually start talking to the microcontroller. The first - * thing to check is whether the firmware is broken. - */ - if (i2bsc_is_firmware_broken(i2c)) { - cmn_err(CE_WARN, "Underlying BSC hardware not communicating;" - " shutting down my i2c services"); - goto bad; - } - - i2c->i2bsc_attachflags |= FIRMWARE_ALIVE; - - /* - * Now see if the BSC chip supports the i2c service we rely upon. - */ - (void) i2bsc_discover_capability(i2c); - - if (i2bsc_notify_max_transfer_size(i2c) == DDI_SUCCESS) - i2c->i2bsc_attachflags |= TRANSFER_SZ; - - i2bsc_trace(i2c, 'A', "i2bsc_doattach", "attachflags %d", - i2c->i2bsc_attachflags); - - return (DDI_SUCCESS); - -bad: - i2bsc_dodetach(dip); - - return (DDI_FAILURE); -} - -static int -i2bsc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - switch (cmd) { - case DDI_ATTACH: - return (i2bsc_doattach(dip)); - - case DDI_RESUME: - i2bsc_resume(dip); - return (DDI_SUCCESS); - - default: - return (DDI_FAILURE); - } -} - -static int -i2bsc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - switch (cmd) { - case DDI_DETACH: - i2bsc_dodetach(dip); - return (DDI_SUCCESS); - - case DDI_SUSPEND: - i2bsc_suspend(dip); - return (DDI_SUCCESS); - - default: - return (DDI_FAILURE); - } -} - -/*ARGSUSED*/ -static int -i2bsc_open(dev_t *devp, int flag, int otyp, cred_t *cred_p) -{ - int instance; - i2bsc_t *i2c; - - /* - * Make sure the open is for the right file type - */ - if (otyp != OTYP_CHR) - return (EINVAL); - - instance = getminor(*devp); - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - if (i2c == NULL) - return (ENXIO); - - /* - * Enforce exclusive access - */ - mutex_enter(&i2c->i2bsc_imutex); - if (i2c->i2bsc_open) { - mutex_exit(&i2c->i2bsc_imutex); - return (EBUSY); - } else - i2c->i2bsc_open = 1; - - mutex_exit(&i2c->i2bsc_imutex); - - return (0); -} - -/*ARGSUSED*/ -static int -i2bsc_close(dev_t dev, int flag, int otyp, cred_t *cred_p) -{ - int instance; - i2bsc_t *i2c; - - /* - * Make sure the close is for the right file type - */ - if (otyp != OTYP_CHR) - return (EINVAL); - - instance = getminor(dev); - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - if (i2c == NULL) - return (ENXIO); - - mutex_enter(&i2c->i2bsc_imutex); - i2c->i2bsc_open = 0; - mutex_exit(&i2c->i2bsc_imutex); - - return (0); -} - -/*ARGSUSED*/ -static int -i2bsc_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, - int *rvalp) -{ - i2bsc_t *i2c; - dev_info_t *self; - dev_info_t *child; - struct devctl_iocdata *dcp; - int rv; - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, getminor(dev)); - - if (i2c == NULL) - return (ENXIO); - - self = (dev_info_t *)i2c->i2bsc_dip; - - /* - * read devctl ioctl data - */ - if (ndi_dc_allochdl((void *)arg, &dcp) != NDI_SUCCESS) { - return (EFAULT); - } - - switch (cmd) { - case DEVCTL_BUS_DEV_CREATE: - rv = ndi_dc_devi_create(dcp, self, 0, NULL); - break; - - case DEVCTL_DEVICE_REMOVE: - if (ndi_dc_getname(dcp) == NULL || - ndi_dc_getaddr(dcp) == NULL) { - rv = EINVAL; - break; - } - - /* - * lookup and hold child device - */ - child = ndi_devi_find(self, - ndi_dc_getname(dcp), ndi_dc_getaddr(dcp)); - if (child == NULL) { - rv = ENXIO; - break; - } - - if ((rv = ndi_devi_offline(child, NDI_DEVI_REMOVE)) != - NDI_SUCCESS) { - rv = (rv == NDI_BUSY) ? EBUSY : EIO; - } - - break; - - default: - rv = ENOTSUP; - } - - ndi_dc_freehdl(dcp); - - return (rv); -} - -static int -i2bsc_bus_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_ctl_enum_t op, - void *arg, void *result) -{ - i2bsc_t *i2c; - int instance = ddi_get_instance(dip); - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - - i2bsc_trace(i2c, 'A', "i2bsc_bus_ctl", "dip/rdip,op/arg" - " %p/%p,%d/%p", dip, rdip, (int)op, arg); - - switch (op) { - case DDI_CTLOPS_INITCHILD: - return (i2bsc_initchild(dip, (dev_info_t *)arg)); - - case DDI_CTLOPS_UNINITCHILD: - return (i2bsc_uninitchild(dip, (dev_info_t *)arg)); - - case DDI_CTLOPS_REPORTDEV: - return (i2bsc_reportdev(dip, rdip)); - - case DDI_CTLOPS_DMAPMAPC: - case DDI_CTLOPS_POKE: - case DDI_CTLOPS_PEEK: - case DDI_CTLOPS_IOMIN: - case DDI_CTLOPS_REPORTINT: - case DDI_CTLOPS_SIDDEV: - case DDI_CTLOPS_SLAVEONLY: - case DDI_CTLOPS_AFFINITY: - case DDI_CTLOPS_PTOB: - case DDI_CTLOPS_BTOP: - case DDI_CTLOPS_BTOPR: - case DDI_CTLOPS_DVMAPAGESIZE: - return (DDI_FAILURE); - - default: - return (ddi_ctlops(dip, rdip, op, arg, result)); - } -} - -/* - * i2bsc_suspend() is called before the system suspends. Existing - * transfer in progress or waiting will complete, but new transfers are - * effectively blocked by "acquiring" the bus. - */ -static void -i2bsc_suspend(dev_info_t *dip) -{ - i2bsc_t *i2c; - int instance; - - instance = ddi_get_instance(dip); - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - - i2bsc_acquire(i2c, NULL, NULL); -} - -/* - * i2bsc_resume() is called when the system resumes from CPR. It releases - * the hold that was placed on the i2c bus, which allows any real - * transfers to continue. - */ -static void -i2bsc_resume(dev_info_t *dip) -{ - i2bsc_t *i2c; - int instance; - - instance = ddi_get_instance(dip); - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, instance); - - i2bsc_release(i2c); -} - -/* - * i2bsc_acquire() is called by a thread wishing to "own" the I2C bus. - * It should not be held across multiple transfers. - */ -static void -i2bsc_acquire(i2bsc_t *i2c, dev_info_t *dip, i2c_transfer_t *tp) -{ - mutex_enter(&i2c->i2bsc_imutex); - while (i2c->i2bsc_busy) { - cv_wait(&i2c->i2bsc_icv, &i2c->i2bsc_imutex); - } - i2c->i2bsc_busy = 1; - i2c->i2bsc_cur_tran = tp; - i2c->i2bsc_cur_dip = dip; - mutex_exit(&i2c->i2bsc_imutex); -} - -/* - * i2bsc_release() is called to release a hold made by i2bsc_acquire(). - */ -static void -i2bsc_release(i2bsc_t *i2c) -{ - mutex_enter(&i2c->i2bsc_imutex); - i2c->i2bsc_busy = 0; - i2c->i2bsc_cur_tran = NULL; - cv_signal(&i2c->i2bsc_icv); - mutex_exit(&i2c->i2bsc_imutex); -} - -static int -i2bsc_initchild(dev_info_t *dip, dev_info_t *cdip) -{ - i2bsc_t *i2c; - int32_t address_cells; - int len; - int32_t regs[3]; - int err; - i2bsc_ppvt_t *ppvt; - char name[30]; - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, ddi_get_instance(dip)); - - i2bsc_trace(i2c, 'A', "i2bsc_initchild", "dip/cdip %p/%p", dip, cdip); - - ppvt = kmem_alloc(sizeof (i2bsc_ppvt_t), KM_SLEEP); - - len = sizeof (address_cells); - - err = ddi_getlongprop_buf(DDI_DEV_T_ANY, cdip, - DDI_PROP_CANSLEEP, "#address-cells", - (caddr_t)&address_cells, &len); - if (err != DDI_PROP_SUCCESS || len != sizeof (address_cells)) { - return (DDI_FAILURE); - } - - len = sizeof (regs); - err = ddi_getlongprop_buf(DDI_DEV_T_ANY, cdip, - DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, - "reg", (caddr_t)regs, &len); - if (err != DDI_PROP_SUCCESS) - return (DDI_FAILURE); - - if (address_cells == 1) { - ppvt->i2bsc_ppvt_bus = I2BSC_DEFAULT_BUS; - ppvt->i2bsc_ppvt_addr = regs[0]; - (void) sprintf(name, "%x", regs[0]); - i2bsc_trace(i2c, 'A', "i2bsc_initchild", "#address-cells = 1" - " regs[0] = %d", regs[0]); - } else if (address_cells == 2) { - ppvt->i2bsc_ppvt_bus = regs[0]; - ppvt->i2bsc_ppvt_addr = regs[1]; - (void) sprintf(name, "%x,%x", regs[0], regs[1]); - i2bsc_trace(i2c, 'A', "i2bsc_initchild", "#address-cells = 2" - " regs[0] = %d, regs[1] = %d", regs[0], regs[1]); - } else { - return (DDI_FAILURE); - } - - /* - * Attach the parent's private data structure to the child's devinfo - * node, and store the child's address on the nexus in the child's - * devinfo node. - */ - ddi_set_parent_data(cdip, ppvt); - ddi_set_name_addr(cdip, name); - - i2bsc_trace(i2c, 'A', "i2bsc_initchild", "success(%s)", - ddi_node_name(cdip)); - - return (DDI_SUCCESS); -} - -static int -i2bsc_uninitchild(dev_info_t *dip, dev_info_t *cdip) -{ - i2bsc_t *i2c; - i2bsc_ppvt_t *ppvt; - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, ddi_get_instance(dip)); - - i2bsc_trace(i2c, 'D', "i2bsc_uninitchild", "dip/cdip %p/%p", dip, cdip); - - ppvt = ddi_get_parent_data(cdip); - kmem_free(ppvt, sizeof (i2bsc_ppvt_t)); - - ddi_set_parent_data(cdip, NULL); - ddi_set_name_addr(cdip, NULL); - - i2bsc_trace(i2c, 'D', "i2bsc_uninitchild", "success(%s)", - ddi_node_name(cdip)); - - return (DDI_SUCCESS); -} - -/* - * i2bsc_setup_regs() is called to map in registers specific to - * the i2bsc. - */ -static int -i2bsc_setup_regs(i2bsc_t *i2c) -{ - int nregs; - - i2c->bscbus_attr.devacc_attr_version = DDI_DEVICE_ATTR_V0; - i2c->bscbus_attr.devacc_attr_endian_flags = DDI_STRUCTURE_LE_ACC; - i2c->bscbus_attr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; - - if (ddi_dev_nregs(i2c->i2bsc_dip, &nregs) != DDI_SUCCESS) { - return (DDI_FAILURE); - } - - if (nregs < 1) { - return (DDI_FAILURE); - } - - if (ddi_regs_map_setup(i2c->i2bsc_dip, 0, - (caddr_t *)&i2c->bscbus_regs, 0, 0, &i2c->bscbus_attr, - &i2c->bscbus_handle) != DDI_SUCCESS) { - return (DDI_FAILURE); - } - - return (DDI_SUCCESS); -} - -/* - * i2bsc_free_regs() frees any registers previously - * allocated. - */ -static void -i2bsc_free_regs(i2bsc_t *i2c) -{ - if (i2c->bscbus_regs != NULL) { - ddi_regs_map_free(&i2c->bscbus_handle); - } -} - -/*ARGSUSED*/ -static int -i2bsc_reportdev(dev_info_t *dip, dev_info_t *rdip) -{ - if (rdip == (dev_info_t *)0) - return (DDI_FAILURE); - - cmn_err(CE_CONT, "?i2bsc-device: %s@%s, %s%d\n", - ddi_node_name(rdip), ddi_get_name_addr(rdip), ddi_driver_name(rdip), - ddi_get_instance(rdip)); - - return (DDI_SUCCESS); -} - -/* - * I/O Functions - * - * i2bsc_{put,get}8_once are wrapper functions to ddi_{get,put}8. - * i2bsc_{put,get}8 are equivalent functions but with retry code. - * i2bsc_bscbus_state determines underlying bus error status. - * i2bsc_clear_acc_fault clears the underlying bus error status. - * - * I/O Flags - * - * bscbus_fault - Error register in underlying bus for last IO operation. - * session_failure - Set by any failed IO command. This is a sticky flag - * reset explicitly using i2bsc_start_session - * - * Session Management - * - * i2bsc_{start,end}_session need to be used to detect an error across multiple - * gets/puts rather than having to test for an error on each get/put. - */ - -static int i2bsc_bscbus_state(i2bsc_t *i2c) -{ - uint32_t retval; - - retval = ddi_get32(i2c->bscbus_handle, - (uint32_t *)I2BSC_NEXUS_ADDR(i2c, EBUS_CMD_SPACE_GENERIC, - LOMBUS_FAULT_REG)); - i2c->bscbus_fault = retval; - - return ((retval == 0) ? DDI_SUCCESS : DDI_FAILURE); -} - -static void i2bsc_clear_acc_fault(i2bsc_t *i2c) -{ - i2bsc_trace(i2c, '@', "i2bsc_clear_acc_fault", "clearing acc fault"); - ddi_put32(i2c->bscbus_handle, - (uint32_t *)I2BSC_NEXUS_ADDR(i2c, EBUS_CMD_SPACE_GENERIC, - LOMBUS_FAULT_REG), 0); -} - -static void -i2bsc_start_session(i2bsc_t *i2c) -{ - i2bsc_trace(i2c, 'S', "i2bsc_start_session", "session started"); - i2c->bscbus_session_failure = 0; -} - -static void -i2bsc_fail_session(i2bsc_t *i2c) -{ - i2bsc_trace(i2c, 'S', "i2bsc_fail_session", "session failed"); - i2c->bscbus_session_failure = 1; -} - -static int -i2bsc_end_session(i2bsc_t *i2c) -{ - /* - * The ONLY way to get the session status is to end the session. - * If clients of the session interface ever wanted the status mid-way - * then they are really working with multiple contigious sessions. - */ - i2bsc_trace(i2c, 'S', "i2bsc_end_session", "session ended with %d", - i2c->bscbus_session_failure); - return ((i2c->bscbus_session_failure) ? DDI_FAILURE : DDI_SUCCESS); -} - -static boolean_t -i2bsc_is_firmware_broken(i2bsc_t *i2c) -{ - int i; - int niterations = I2BSC_SHORT_RETRY_LIMIT; - - i2bsc_trace(i2c, 'A', "i2bsc_is_firmware_broken", "called"); - - for (i = 0; i < niterations; i++) { - (void) ddi_get8(i2c->bscbus_handle, - I2BSC_NEXUS_ADDR(i2c, EBUS_CMD_SPACE_I2C, - EBUS_IDX12_RESULT)); - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) { - i2bsc_clear_acc_fault(i2c); - continue; - } else { - /* - * Firmware communication succeeded. - */ - i2bsc_trace(i2c, 'A', "i2bsc_is_firmware_broken", - "firmware communications okay"); - return (B_FALSE); - } - } - - /* - * Firmware is not communicative. Some possible causes : - * Broken hardware - * BSC held in reset - * Corrupt BSC image - * OBP incompatiblity preventing drivers loading properly - */ - i2bsc_trace(i2c, 'A', "i2bsc_is_firmware_broken", "%d read fails", - niterations); - return (B_TRUE); -} - -static void -i2bsc_put8(i2bsc_t *i2c, uint8_t space, uint8_t index, uint8_t value) -{ - int retryable = I2BSC_RETRY_LIMIT; - - i2bsc_trace(i2c, '@', "i2bsc_put8", "(space,index)<-val (%d,%d)<-%d", - space, index, value); - - i2bsc_clear_acc_fault(i2c); - - /* - * If a session failure has already occurred, reduce the level of - * retries to a minimum. This is a optimization of the failure - * recovery strategy. - */ - if (i2c->bscbus_session_failure) - retryable = 1; - - while (retryable--) { - ddi_put8(i2c->bscbus_handle, - I2BSC_NEXUS_ADDR(i2c, space, index), value); - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) { - i2bsc_clear_acc_fault(i2c); - } else - break; - } - - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) - i2bsc_fail_session(i2c); - - i2bsc_trace(i2c, '@', "i2bsc_put8", "tried %d time(s)", - I2BSC_RETRY_LIMIT - retryable); -} - -static uint8_t -i2bsc_get8(i2bsc_t *i2c, uint8_t space, uint8_t index) -{ - uint8_t value; - int retryable = I2BSC_RETRY_LIMIT; - - i2bsc_clear_acc_fault(i2c); - - /* - * If a session failure has already occurred, reduce the level of - * retries to a minimum. This is a optimization of the failure - * recovery strategy. - */ - if (i2c->bscbus_session_failure) - retryable = 1; - - while (retryable--) { - value = ddi_get8(i2c->bscbus_handle, - I2BSC_NEXUS_ADDR(i2c, space, index)); - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) { - i2bsc_clear_acc_fault(i2c); - } else - break; - } - - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) - i2bsc_fail_session(i2c); - - i2bsc_trace(i2c, '@', "i2bsc_get8", "tried %d time(s)", - I2BSC_RETRY_LIMIT - retryable); - - i2bsc_trace(i2c, '@', "i2bsc_get8", "(space,index)->val (%d,%d)->%d", - space, index, value); - return (value); -} - -static void -i2bsc_put8_once(i2bsc_t *i2c, uint8_t space, uint8_t index, uint8_t value) -{ - i2bsc_trace(i2c, '@', "i2bsc_put8_once", - "(space,index)<-val (%d,%d)<-%d", space, index, value); - - i2bsc_clear_acc_fault(i2c); - - ddi_put8(i2c->bscbus_handle, - I2BSC_NEXUS_ADDR(i2c, space, index), value); - - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) - i2bsc_fail_session(i2c); -} - -static uint8_t -i2bsc_get8_once(i2bsc_t *i2c, uint8_t space, uint8_t index) -{ - uint8_t value; - - i2bsc_clear_acc_fault(i2c); - - value = ddi_get8(i2c->bscbus_handle, - I2BSC_NEXUS_ADDR(i2c, space, index)); - - if (i2bsc_bscbus_state(i2c) != DDI_SUCCESS) - i2bsc_fail_session(i2c); - - i2bsc_trace(i2c, '@', "i2bsc_get8_once", - "(space,index)->val (%d,%d)->%d", space, index, value); - - return (value); -} - -static int -i2bsc_notify_max_transfer_size(i2bsc_t *i2c) -{ - /* - * If the underlying hardware does not support the i2c service and - * we are not running in fake_mode, then we cannot set the - * MAX_TRANSFER_SZ. - */ - if (i2c->i2c_proxy_support == 0) - return (DDI_FAILURE); - - i2bsc_start_session(i2c); - - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_MAX_TRANSFER_SZ, - I2BSC_MAX_TRANSFER_SZ); - - if (i2bsc_end_session(i2c) != DDI_SUCCESS) - return (DDI_FAILURE); - - return (DDI_SUCCESS); -} - -/* - * Discover if the microcontroller implements the I2C Proxy Service this - * driver requires. If it does not, i2c transactions will abort with - * I2C_FAILURE, unless fake_mode is being used. - */ -static int -i2bsc_discover_capability(i2bsc_t *i2c) -{ - i2bsc_start_session(i2c); - - i2c->i2c_proxy_support = i2bsc_get8(i2c, EBUS_CMD_SPACE_GENERIC, - EBUS_IDX_CAP0); - i2c->i2c_proxy_support &= EBUS_CAP0_I2C_PROXY; - - if (i2bsc_end_session(i2c) != DDI_SUCCESS) - return (DDI_FAILURE); - - return (DDI_SUCCESS); -} - -static int -i2bsc_upload_preamble(i2bsc_t *i2c, i2c_transfer_t *tp) -{ - i2bsc_ppvt_t *ppvt; - int wr_rd; - - ppvt = ddi_get_parent_data(i2c->i2bsc_cur_dip); - - /* Get a lock on the i2c devices owned by the microcontroller */ - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_TRANSACTION_LOCK, 1); - if (!i2bsc_get8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_TRANSACTION_LOCK)) { - /* - * i2c client driver must timeout retry, NOT this nexus - */ - tp->i2c_result = I2C_INCOMPLETE; - i2bsc_trace(i2c, 'U', "i2bsc_upload_preamble", - "Couldn't get transaction lock"); - return (tp->i2c_result); - } - - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_BUS_ADDRESS, - ppvt->i2bsc_ppvt_bus); - - /* - * The Solaris architecture for I2C uses 10-bit I2C addresses where - * bit-0 is zero (the read/write bit). The microcontroller uses 7 bit - * I2C addresses (read/write bit excluded). Hence we need to convert - * the address by bit-shifting. - */ - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_CLIENT_ADDRESS, - ppvt->i2bsc_ppvt_addr >> 1); - - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_TRANSFER_TYPE, - tp->i2c_flags); - - /* - * We have only one register used for data input and output. When - * a WR_RD is issued, this means we want to do a Random-Access-Read. - * First a series of bytes are written which define the address to - * read from. In hardware this sets an address pointer. Then a series - * of bytes are read. The read/write boundary tells you how many - * bytes are to be written before reads will be issued. - */ - if (tp->i2c_flags == I2C_WR_RD) - wr_rd = tp->i2c_wlen; - else - wr_rd = 0; - - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_WR_RD_BOUNDARY, wr_rd); - - return (I2C_SUCCESS); -} - -/* - * Function i2bsc_upload - * - * Description This function runs the i2c transfer protocol down to the - * microcontroller. Its goal is to be as reliable as possible. - * This is achieved by making all the state-less aspects - * re-tryable. For stateful aspects, we take care to ensure the - * counters are decremented only when data transfer has been - * successful. - */ -static int -i2bsc_upload(i2bsc_t *i2c, i2c_transfer_t *tp) -{ - int quota = I2BSC_MAX_TRANSFER_SZ; - uint8_t res; - int residual; - - /* - * Total amount of data outstanding - */ - residual = tp->i2c_w_resid + tp->i2c_r_resid; - - /* - * Anything in this session *could* be re-tried without side-effects. - * Therefore, error exit codes are I2C_INCOMPLETE rather than - * I2C_FAILURE. - */ - i2bsc_start_session(i2c); - if (i2bsc_upload_preamble(i2c, tp) != I2C_SUCCESS) - return (I2C_INCOMPLETE); - if (i2bsc_end_session(i2c) != DDI_SUCCESS) - return (I2C_INCOMPLETE); - - /* The writes done here are not retryable */ - while (tp->i2c_w_resid && quota) { - i2bsc_put8_once(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_DATA_INOUT, - tp->i2c_wbuf[tp->i2c_wlen - tp->i2c_w_resid]); - if (i2bsc_bscbus_state(i2c) == DDI_SUCCESS) { - tp->i2c_w_resid--; - quota--; - residual--; - } else { - i2bsc_trace(i2c, 'T', "i2bsc_upload", "write failed"); - return (tp->i2c_result = I2C_INCOMPLETE); - } - } - - /* The reads done here are not retryable */ - while (tp->i2c_r_resid && quota) { - tp->i2c_rbuf[tp->i2c_rlen - tp->i2c_r_resid] = - i2bsc_get8_once(i2c, EBUS_CMD_SPACE_I2C, - EBUS_IDX12_DATA_INOUT); - if (i2bsc_bscbus_state(i2c) == DDI_SUCCESS) { - tp->i2c_r_resid--; - quota--; - residual--; - } else { - i2bsc_trace(i2c, 'T', "i2bsc_upload", "read failed"); - return (tp->i2c_result = I2C_INCOMPLETE); - } - } - - i2bsc_start_session(i2c); - - /* - * A possible future enhancement would be to allow early breakout of the - * loops seen above. In such circumstances, "residual" would be non- - * zero. This may be useful if we want to support the interruption of - * transfer part way through an i2c_transfer_t. - */ - i2bsc_put8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_RESIDUAL_DATA, residual); - res = i2bsc_get8(i2c, EBUS_CMD_SPACE_I2C, EBUS_IDX12_RESULT); - if (i2bsc_end_session(i2c) != DDI_SUCCESS) - return (tp->i2c_result = I2C_INCOMPLETE); - - switch (res) { - case EBUS_I2C_SUCCESS: - tp->i2c_result = I2C_SUCCESS; - break; - case EBUS_I2C_FAILURE: - /* - * This is rare but possible. A retry may still fix this - * so lets allow that by returning I2C_INCOMPLETE. - * "hifTxRing still contains 1 bytes" is reported by the - * microcontroller when this return value is seen. - */ - i2bsc_trace(i2c, 'T', "i2bsc_upload", "EBUS_I2C_FAILURE" - " but returning I2C_INCOMPLETE for possible re-try"); - tp->i2c_result = I2C_INCOMPLETE; - break; - case EBUS_I2C_INCOMPLETE: - tp->i2c_result = I2C_INCOMPLETE; - break; - default: - tp->i2c_result = I2C_FAILURE; - } - - return (tp->i2c_result); -} - -/* - * Function i2bsc_safe_upload - * - * Description This function is called "safe"-upload because it attempts to - * do transaction re-tries for cases where state is not spoiled - * by a transaction-level retry. - */ -static int -i2bsc_safe_upload(i2bsc_t *i2c, i2c_transfer_t *tp) -{ - int retryable = I2BSC_RETRY_LIMIT; - int result; - - i2bsc_trace(i2c, 'T', "i2bsc_safe_upload", "Transaction %s", - (tp->i2c_flags == I2C_WR_RD) ? "retryable" : "single-shot"); - - /* - * The only re-tryable transaction type is I2C_WR_RD. If we don't - * have this we can only use session-based recovery offered by - * i2bsc_upload. - */ - if (tp->i2c_flags != I2C_WR_RD) - return (i2bsc_upload(i2c, tp)); - - while (retryable--) { - result = i2bsc_upload(i2c, tp); - if (result == I2C_INCOMPLETE) { - /* Have another go */ - tp->i2c_r_resid = tp->i2c_rlen; - tp->i2c_w_resid = tp->i2c_wlen; - tp->i2c_result = I2C_SUCCESS; - i2bsc_trace(i2c, 'T', "i2bsc_safe_upload", - "Retried (%d)", I2BSC_RETRY_LIMIT - retryable); - continue; - } else { - i2bsc_trace(i2c, 'T', "i2bsc_safe_upload", - "Exiting while loop on result %d", result); - return (result); - } - } - - i2bsc_trace(i2c, 'T', "i2bsc_safe_upload", "Exiting on %d", result); - return (result); -} - -/* - * Function i2bsc_transfer - * - * Description This is the entry-point that clients use via the Solaris i2c - * framework. It kicks off the servicing of i2c transfer requests. - */ -int -i2bsc_transfer(dev_info_t *dip, i2c_transfer_t *tp) -{ - i2bsc_t *i2c; - - i2c = (i2bsc_t *)ddi_get_soft_state(i2bsc_state, - ddi_get_instance(ddi_get_parent(dip))); - - i2bsc_acquire(i2c, dip, tp); - - tp->i2c_r_resid = tp->i2c_rlen; - tp->i2c_w_resid = tp->i2c_wlen; - tp->i2c_result = I2C_SUCCESS; - - i2bsc_trace(i2c, 'T', "i2bsc_transfer", "Transaction i2c_version/flags" - " %d/%d", tp->i2c_version, tp->i2c_flags); - i2bsc_trace(i2c, 'T', "i2bsc_transfer", "Transaction buffer rlen/wlen" - " %d/%d", tp->i2c_rlen, tp->i2c_wlen); - i2bsc_trace(i2c, 'T', "i2bsc_transfer", "Transaction ptrs wbuf/rbuf" - " %p/%p", tp->i2c_wbuf, tp->i2c_rbuf); - - if (i2c->i2c_proxy_support) - (void) i2bsc_safe_upload(i2c, tp); - else - tp->i2c_result = I2C_FAILURE; - - i2bsc_trace(i2c, 'T', "i2bsc_transfer", "Residual writes/reads" - " %d/%d", tp->i2c_w_resid, tp->i2c_r_resid); - i2bsc_trace(i2c, 'T', "i2bsc_transfer", "i2c_result" - " %d", tp->i2c_result); - - i2bsc_release(i2c); - - return (tp->i2c_result); -} - -/* - * General utility routines ... - */ - -#ifdef DEBUG - -static void -i2bsc_trace(i2bsc_t *ssp, char code, const char *caller, - const char *fmt, ...) -{ - char buf[256]; - char *p; - va_list va; - - if (ssp->debug & (1 << (code-'@'))) { - p = buf; - (void) snprintf(p, sizeof (buf) - (p - buf), - "%s/%s: ", ssp->i2bsc_name, caller); - p += strlen(p); - - va_start(va, fmt); - (void) vsnprintf(p, sizeof (buf) - (p - buf), fmt, va); - va_end(va); - - buf[sizeof (buf) - 1] = '\0'; - (void) strlog(ssp->majornum, ssp->minornum, code, SL_TRACE, - buf); - } -} - -#else /* DEBUG */ - -_NOTE(ARGSUSED(0)) -static void -i2bsc_trace(i2bsc_t *ssp, char code, const char *caller, - const char *fmt, ...) -{ -} - -#endif /* DEBUG */ diff --git a/usr/src/uts/sun4u/io/i2c/nexus/i2bsc.conf b/usr/src/uts/sun4u/io/i2c/nexus/i2bsc.conf deleted file mode 100644 index 6608ada6b9..0000000000 --- a/usr/src/uts/sun4u/io/i2c/nexus/i2bsc.conf +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# Configuration file for i2bsc driver -# - -# 64-bit Debug bit-vector; requires DEBUG driver to be installed -debug=0; diff --git a/usr/src/uts/sun4u/io/todblade.c b/usr/src/uts/sun4u/io/todblade.c deleted file mode 100644 index 3be6c1409d..0000000000 --- a/usr/src/uts/sun4u/io/todblade.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <sys/types.h> -#include <sys/conf.h> -#include <sys/kmem.h> -#include <sys/open.h> -#include <sys/ddi.h> -#include <sys/sunddi.h> - -#include <sys/todm5819.h> -#include <sys/modctl.h> -#include <sys/stat.h> -#include <sys/clock.h> -#include <sys/reboot.h> -#include <sys/machsystm.h> -#include <sys/poll.h> -#include <sys/pbio.h> -#include <sys/lom_priv.h> - -#define WDOG_ON 1 -#define WDOG_OFF 0 - -static timestruc_t todbl_get(void); -static void todbl_set(timestruc_t); -static uint_t todbl_set_watchdog_timer(uint_t); -static uint_t todbl_clear_watchdog_timer(void); -static void todbl_set_power_alarm(timestruc_t); -static void todbl_clear_power_alarm(void); -static uint64_t todbl_get_cpufrequency(void); - -static todinfo_t rtc_to_tod(struct rtc_t *); -static uint_t read_rtc(struct rtc_t *); -static void write_rtc_time(struct rtc_t *); -static uint_t configure_wdog(uint8_t new_state); - -extern uint64_t find_cpufrequency(volatile uint8_t *); - -/* - * External variables - */ -extern int watchdog_enable; -extern int watchdog_available; -extern int watchdog_activated; -extern uint_t watchdog_timeout_seconds; -extern int boothowto; -extern void (*bsc_drv_func_ptr)(struct bscv_idi_info *); - -/* - * Global variables - */ -int m5819_debug_flags; -uint8_t wdog_reset_on_timeout = 1; -static clock_t last_pat_lbt; - - -static struct modlmisc modlmisc = { - &mod_miscops, "todblade module", -}; - -static struct modlinkage modlinkage = { - MODREV_1, &modlmisc, NULL -}; - - -int -_init(void) -{ - if (strcmp(tod_module_name, "todblade") == 0) { - RTC_PUT8(RTC_B, (RTC_DM | RTC_HM)); - - tod_ops.tod_get = todbl_get; - tod_ops.tod_set = todbl_set; - tod_ops.tod_set_watchdog_timer = todbl_set_watchdog_timer; - tod_ops.tod_clear_watchdog_timer = todbl_clear_watchdog_timer; - tod_ops.tod_set_power_alarm = todbl_set_power_alarm; - tod_ops.tod_clear_power_alarm = todbl_clear_power_alarm; - tod_ops.tod_get_cpufrequency = todbl_get_cpufrequency; - - if (watchdog_enable && (boothowto & RB_DEBUG)) { - watchdog_available = 0; - cmn_err(CE_WARN, "todblade: kernel debugger " - "detected: hardware watchdog disabled"); - } - } - return (mod_install(&modlinkage)); -} - -int -_fini(void) -{ - if (strcmp(tod_module_name, "todblade") == 0) { - return (EBUSY); - } else { - return (mod_remove(&modlinkage)); - } -} - -/* - * The loadable-module _info(9E) entry point - */ -int -_info(struct modinfo *modinfop) -{ - return (mod_info(&modlinkage, modinfop)); -} - - -/* - * Read the current time from the clock chip and convert to UNIX form. - * Assumes that the year in the clock chip is valid. - * Must be called with tod_lock held. - */ -static timestruc_t -todbl_get(void) -{ - int i; - timestruc_t ts; - struct rtc_t rtc; - struct bscv_idi_info bscv_info; - - ASSERT(MUTEX_HELD(&tod_lock)); - - /* - * We must check that the value of watchdog enable hasnt changed - * as its a user knob for turning it on and off - */ - if (watchdog_available) { - if (watchdog_activated && !watchdog_enable) { - (void) configure_wdog(WDOG_OFF); - } else if (!watchdog_activated && watchdog_enable) { - (void) configure_wdog(WDOG_ON); - } else if (watchdog_activated && - (ddi_get_lbolt() - last_pat_lbt) >= SEC_TO_TICK(1)) { - /* - * PAT THE WATCHDOG!! - * We dont want to accelerate the pat frequency - * when userland calls to the TOD_GET_DATE ioctl - * pass through here. - */ - bscv_info.type = BSCV_IDI_WDOG_PAT; - bscv_info.data = NULL; - bscv_info.size = 0; - if (bsc_drv_func_ptr != NULL) { - (*bsc_drv_func_ptr)(&bscv_info); - last_pat_lbt = ddi_get_lbolt(); - } - } - } - - /* - * Read from the tod, and if it isnt accessible wait - * before retrying. - */ - for (i = 0; i < TODM5819_UIP_RETRY_THRESH; i++) { - if (read_rtc(&rtc)) - break; - drv_usecwait(TODM5819_UIP_WAIT_USEC); - } - if (i == TODM5819_UIP_RETRY_THRESH) { - /* - * We couldn't read from the TOD. - */ - tod_status_set(TOD_GET_FAILED); - return (hrestime); - } - - DPRINTF("todbl_get: century=%d year=%d dom=%d hrs=%d\n", - rtc.rtc_century, rtc.rtc_year, rtc.rtc_dom, rtc.rtc_hrs); - - /* read was successful so ensure failure flag is clear */ - tod_status_clear(TOD_GET_FAILED); - - ts.tv_sec = tod_to_utc(rtc_to_tod(&rtc)); - ts.tv_nsec = 0; - return (ts); -} - -static todinfo_t -rtc_to_tod(struct rtc_t *rtc) -{ - todinfo_t tod; - - /* - * tod_year is base 1900 so this code needs to adjust the true - * year retrieved from the rtc's century and year fields. - */ - tod.tod_year = rtc->rtc_year + (rtc->rtc_century * 100) - 1900; - tod.tod_month = rtc->rtc_mon; - tod.tod_day = rtc->rtc_dom; - tod.tod_dow = rtc->rtc_dow; - tod.tod_hour = rtc->rtc_hrs; - tod.tod_min = rtc->rtc_min; - tod.tod_sec = rtc->rtc_sec; - - return (tod); -} - - -static uint_t -read_rtc(struct rtc_t *rtc) -{ - int s; - uint_t rtc_readable = 0; - - s = splhi(); - /* - * If UIP bit is not set we have at least 274us - * to read the values. - */ - if (!(RTC_GET8(RTC_A) & RTC_UIP)) { - rtc_readable = 1; - - rtc->rtc_sec = RTC_GET8(RTC_SEC); - rtc->rtc_asec = RTC_GET8(RTC_ASEC); - rtc->rtc_min = RTC_GET8(RTC_MIN); - rtc->rtc_amin = RTC_GET8(RTC_AMIN); - - rtc->rtc_hrs = RTC_GET8(RTC_HRS); - rtc->rtc_ahrs = RTC_GET8(RTC_AHRS); - rtc->rtc_dow = RTC_GET8(RTC_DOW); - rtc->rtc_dom = RTC_GET8(RTC_DOM); - rtc->rtc_adom = RTC_GET8(RTC_D) & 0x3f; - - rtc->rtc_mon = RTC_GET8(RTC_MON); - rtc->rtc_year = RTC_GET8(RTC_YEAR); - rtc->rtc_century = RTC_GET8(RTC_CENTURY); - rtc->rtc_amon = 0; - - /* Clear wakeup data */ - rtc->apc_wdwr = 0; - rtc->apc_wdmr = 0; - rtc->apc_wmr = 0; - rtc->apc_wyr = 0; - rtc->apc_wcr = 0; - } - - splx(s); - return (rtc_readable); -} - -/* - * Write the specified time into the clock chip. - * Must be called with tod_lock held. - */ -static void -todbl_set(timestruc_t ts) -{ - struct rtc_t rtc; - todinfo_t tod = utc_to_tod(ts.tv_sec); - struct bscv_idi_info bscv_info; - int year; - - ASSERT(MUTEX_HELD(&tod_lock)); - - /* tod_year is base 1900 so this code needs to adjust */ - year = 1900 + tod.tod_year; - rtc.rtc_year = year % 100; - rtc.rtc_century = year / 100; - rtc.rtc_mon = (uint8_t)tod.tod_month; - rtc.rtc_dom = (uint8_t)tod.tod_day; - rtc.rtc_dow = (uint8_t)tod.tod_dow; - rtc.rtc_hrs = (uint8_t)tod.tod_hour; - rtc.rtc_min = (uint8_t)tod.tod_min; - rtc.rtc_sec = (uint8_t)tod.tod_sec; - DPRINTF("todbl_set: century=%d year=%d dom=%d hrs=%d\n", - rtc.rtc_century, rtc.rtc_year, rtc.rtc_dom, rtc.rtc_hrs); - - write_rtc_time(&rtc); - - /* - * Because of a generic solaris problem where calls to stime() - * starve calls to tod_get(), we need to check to see when the - * watchdog was last patted and pat it if necessary. - */ - if (watchdog_activated && - (ddi_get_lbolt() - last_pat_lbt) >= SEC_TO_TICK(1)) { - /* - * Pat the watchdog! - */ - bscv_info.type = BSCV_IDI_WDOG_PAT; - bscv_info.data = NULL; - bscv_info.size = 0; - if (bsc_drv_func_ptr != NULL) { - (*bsc_drv_func_ptr)(&bscv_info); - last_pat_lbt = ddi_get_lbolt(); - } - } -} - -static void -write_rtc_time(struct rtc_t *rtc) -{ - uint8_t regb; - int i; - - /* - * Freeze - */ - regb = RTC_GET8(RTC_B); - RTC_PUT8(RTC_B, (regb | RTC_SET)); - - /* - * If an update is in progress wait for the UIP flag to clear. - * If we write whilst UIP is still set there is a slight but real - * possibility of corrupting the RTC date and time registers. - * - * The expected wait is one internal cycle of the chip. We could - * simply spin but this may hang a CPU if we were to have a broken - * RTC chip where UIP is stuck, so we use a retry loop instead. - * No critical section is needed here as the UIP flag will not be - * re-asserted until we clear RTC_SET. - */ - for (i = 0; i < TODM5819_UIP_RETRY_THRESH; i++) { - if (!(RTC_GET8(RTC_A) & RTC_UIP)) { - break; - } - drv_usecwait(TODM5819_UIP_WAIT_USEC); - } - if (i < TODM5819_UIP_RETRY_THRESH) { - RTC_PUT8(RTC_SEC, (rtc->rtc_sec)); - RTC_PUT8(RTC_ASEC, (rtc->rtc_asec)); - RTC_PUT8(RTC_MIN, (rtc->rtc_min)); - RTC_PUT8(RTC_AMIN, (rtc->rtc_amin)); - - RTC_PUT8(RTC_HRS, (rtc->rtc_hrs)); - RTC_PUT8(RTC_AHRS, (rtc->rtc_ahrs)); - RTC_PUT8(RTC_DOW, (rtc->rtc_dow)); - RTC_PUT8(RTC_DOM, (rtc->rtc_dom)); - - RTC_PUT8(RTC_MON, (rtc->rtc_mon)); - RTC_PUT8(RTC_YEAR, (rtc->rtc_year)); - RTC_PUT8(RTC_CENTURY, (rtc->rtc_century)); - } else { - cmn_err(CE_WARN, "todblade: Could not write the RTC\n"); - } - - /* - * Unfreeze - */ - RTC_PUT8(RTC_B, regb); -} - - - -/* - * The TOD alarm functionality is not supported on our platform - * as the interrupt is not wired, so do nothing. - */ -/*ARGSUSED*/ -static void -todbl_set_power_alarm(timestruc_t ts) -{ - ASSERT(MUTEX_HELD(&tod_lock)); -} - -/* - * clear alarm interrupt - */ -static void -todbl_clear_power_alarm(void) -{ - ASSERT(MUTEX_HELD(&tod_lock)); -} - -/* - * Determine the cpu frequency by watching the TOD chip rollover twice. - * Cpu clock rate is determined by computing the ticks added (in tick register) - * during one second interval on TOD. - */ -uint64_t -todbl_get_cpufrequency(void) -{ - ASSERT(MUTEX_HELD(&tod_lock)); - M5819_ADDR_REG = RTC_SEC; - return (find_cpufrequency(v_rtc_data_reg)); -} - - -static uint_t -todbl_set_watchdog_timer(uint_t timeoutval) -{ - /* - * We get started during kernel intilaisation only - * if watchdog_enable is set. - */ - ASSERT(MUTEX_HELD(&tod_lock)); - - if (watchdog_available && (!watchdog_activated || - (watchdog_activated && (timeoutval != watchdog_timeout_seconds)))) { - watchdog_timeout_seconds = timeoutval; - if (configure_wdog(WDOG_ON)) - return (watchdog_timeout_seconds); - } - return (0); -} - -static uint_t -todbl_clear_watchdog_timer(void) -{ - /* - * The core kernel will call us here to disable the wdog when: - * 1. we're panicing - * 2. we're entering debug - * 3. we're rebooting - */ - ASSERT(MUTEX_HELD(&tod_lock)); - - if (watchdog_available && watchdog_activated) { - watchdog_enable = 0; - if (!configure_wdog(WDOG_OFF)) - return (0); - } - return (watchdog_timeout_seconds); -} - -static uint_t -configure_wdog(uint8_t new_state) -{ - bscv_wdog_t wdog_cmd; - struct bscv_idi_info bscv_info; - - if (new_state == WDOG_ON || new_state == WDOG_OFF) { - - wdog_cmd.enable_wdog = new_state; - wdog_cmd.wdog_timeout_s = watchdog_timeout_seconds; - wdog_cmd.reset_system_on_timeout = wdog_reset_on_timeout; - bscv_info.type = BSCV_IDI_WDOG_CFG; - bscv_info.data = &wdog_cmd; - bscv_info.size = sizeof (wdog_cmd); - - if (bsc_drv_func_ptr != NULL) { - watchdog_activated = new_state; - (*bsc_drv_func_ptr)(&bscv_info); - return (1); - } - } - return (0); - -} diff --git a/usr/src/uts/sun4u/sys/i2c/nexus/i2bsc_impl.h b/usr/src/uts/sun4u/sys/i2c/nexus/i2bsc_impl.h deleted file mode 100644 index 91c08f9dad..0000000000 --- a/usr/src/uts/sun4u/sys/i2c/nexus/i2bsc_impl.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _NEXUS_I2BSC_IMPL_H -#define _NEXUS_I2BSC_IMPL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/modctl.h> -#include <sys/promif.h> -#include <sys/lom_ebuscodes.h> -#include <sys/bscbus.h> - -/* - * When "#address-cells" is 1, it means we aren't multiplexing i2c busses. We - * therefore mark the bus number to I2BSC_DEFAULT_BUS. - */ -#define I2BSC_DEFAULT_BUS 0 - -/* - * Since i2c transfers are slow and take up lots of time, we limit our i2c - * transfer size to an advertised limit, I2BSC_MAX_TRANSFER_SZ bytes. - * The value was derived from an EEPROM page size of 32 bytes + 2 bytes to - * denote the address offset within the EEPROM. - */ -#define I2BSC_MAX_TRANSFER_SZ 34 - -/* - * Address Space Accessors - */ -#define I2BSC_NEXUS_ADDR(ssp, as, index) \ - (&((ssp)->bscbus_regs[((as) * 256) + (index)])) - -/* - * Re-try limit on Accessors was determined empircally. During a firmware - * download (the most heavy use of the comms channel), retries of up to 21 - * attempts have been seen. The next power of 2 up is 32; the chosen retry - * limit. - */ -#define I2BSC_RETRY_LIMIT 32 - -/* - * During attach processing we need to figure out if the firmware is broken - * from the start. If our re-try strategy is too aggressive we get poor - * boot times. Therefore, the initial broken firmware check done during attach - * is given a relatively low retry threshold. - */ -#define I2BSC_SHORT_RETRY_LIMIT 4 - - -/* - * strace(1M) prints out the debug data once the debug value is set in - * the i2bsc.conf file and the debug driver is installed. - * - * Debug flags - * - * '@' - Register (@)ccess - * 'A' - (A)ttach - * 'D' - (D)ettach - * 'S' - (S)ession - * 'T' - I2C (T)ransfer - * 'U' - (U)pload - */ - -/* - * Debug tips : - * - * strace(1M) prints out the debug data. - * A nice way to work out the debug value set in i2bsc.conf is to use mdb - * Say we want to show 'T' i2c transfer and 'U' upload processing, - * you calculate the debug value with the following mdb session : - * # mdb - * > 1<<('T'-'@') | 1<<('U'-'@') = X - * 300000 - * - * > $q - * When you explicitly set "debug=0x300000;" in i2bsc.conf, it causes the - * debug driver to log Transfer and upload messages for strace(1M). - */ - -typedef struct i2bsc { - uint64_t debug; /* debugging turned on */ - short majornum; /* debugging - major number */ - short minornum; /* debugging - minor number */ - - int i2c_proxy_support; - - ddi_device_acc_attr_t bscbus_attr; /* bscbus attributes */ - ddi_acc_handle_t bscbus_handle; /* bscbus opaque handle */ - uint32_t bscbus_fault; /* 0 => okay */ - - /* - * A session is a set of contigious gets/puts marked either as - * successful or failed. - */ - int bscbus_session_failure; - uint8_t *bscbus_regs; /* bscbus register space */ - - dev_info_t *i2bsc_dip; - int i2bsc_attachflags; - kmutex_t i2bsc_imutex; - kcondvar_t i2bsc_icv; - int i2bsc_open; - int i2bsc_busy; - int i2bsc_bus; - i2c_transfer_t *i2bsc_cur_tran; - dev_info_t *i2bsc_cur_dip; - char i2bsc_name[MODMAXNAMELEN]; -} i2bsc_t; - -/* - * i2c_parent_pvt contains info that is chip specific - * and is stored on the child's devinfo parent private data. - */ -typedef struct i2bsc_ppvt { - int i2bsc_ppvt_bus; /* multiple I2C busses on a single set of */ - /* registers. this tells it what bus to */ - /* use */ - int i2bsc_ppvt_addr; /* address of I2C device */ -} i2bsc_ppvt_t; - -#define I2BSC_INITIAL_SOFT_SPACE 1 - -/* - * Attach flags - */ -#define SETUP_REGS 0x01 -#define NEXUS_REGISTER 0x02 -#define IMUTEX 0x04 -#define MINOR_NODE 0x08 -#define FIRMWARE_ALIVE 0x10 -#define TRANSFER_SZ 0x20 - -#ifdef __cplusplus -} -#endif - -#endif /* _NEXUS_I2BSC_IMPL_H */ diff --git a/usr/src/uts/sun4u/todblade/Makefile b/usr/src/uts/sun4u/todblade/Makefile deleted file mode 100644 index 2d4c89934a..0000000000 --- a/usr/src/uts/sun4u/todblade/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (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 -# or http://www.opensolaris.org/os/licensing. -# 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 -# -# -# uts/sun4u/todblade/Makefile -# Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# This makefile drives the production of the todblade -# kernel module. -# - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = todblade -OBJECTS = $(TODBLADE_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(TODBLADE_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_PSM_TOD_DIR)/$(MODULE) - -# -# Include common rules. -# -include $(UTSBASE)/sun4u/Makefile.sun4u - -INC_PATH += -I$(UTSBASE)/sun4u/blade -# -# Define targets -# -ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sun4u/Makefile.targ |