bscv.c revision 1af83355f7af9ab90e0c801c0224182053a04533
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * CDDL HEADER START
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The contents of this file are subject to the terms of the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Common Development and Distribution License (the "License").
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * You may not use this file except in compliance with the License.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * See the License for the specific language governing permissions
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and limitations under the License.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * When distributing Covered Code, include this CDDL HEADER in each
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If applicable, add the following below this CDDL HEADER, with the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * fields enclosed by brackets "[]" replaced with your own identifying
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * information: Portions Copyright [yyyy] [name of copyright owner]
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * CDDL HEADER END
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Use is subject to license terms.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv.c - multi-threaded lom driver for the Stiletto platform.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Included files.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Variables defined here and visible internally only
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Forward declarations
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_map_chan_logical_physical(bscv_soft_state_t *);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.comstatic int bscv_tryenter(bscv_soft_state_t *ssp);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* DEBUG */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_put8(bscv_soft_state_t *, int, bscv_addr_t, uint8_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_put16(bscv_soft_state_t *, int, bscv_addr_t, uint16_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_put32(bscv_soft_state_t *, int, bscv_addr_t, uint32_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint8_t bscv_get8(bscv_soft_state_t *, int, bscv_addr_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint16_t bscv_get16(bscv_soft_state_t *, int, bscv_addr_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint32_t bscv_get32(bscv_soft_state_t *, int, bscv_addr_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_setclear8_volatile(bscv_soft_state_t *, int,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint8_t bscv_get8_cached(bscv_soft_state_t *, bscv_addr_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint8_t bscv_get8_locked(bscv_soft_state_t *, int, bscv_addr_t, int *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_rep_get8_locked(bscv_soft_state_t *, int,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_locked_result(bscv_soft_state_t *, int *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_put8_once(bscv_soft_state_t *, int, bscv_addr_t, uint8_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint8_t bscv_get8_once(bscv_soft_state_t *, int, bscv_addr_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint32_t bscv_probe(bscv_soft_state_t *, int, uint32_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_eerw(bscv_soft_state_t *, uint32_t, uint8_t *,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd unsigned, boolean_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_dogstate(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_psustate(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_fanstate(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_fledstate(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_ledstate(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_info(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_mread(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_volts(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_stats(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_temp(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_cons(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_eventlog2(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_info2(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_test(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_mprog2(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_ioc_mread2(bscv_soft_state_t *, intptr_t, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_event_daemon(void *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_resume_event_daemon(bscv_soft_state_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_event_process(bscv_soft_state_t *ssp, boolean_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_event_validate(bscv_soft_state_t *, uint32_t, uint8_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_event_process_one(bscv_soft_state_t *, lom_event_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd lom_event_t *, char *, char *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_status(bscv_soft_state_t *, uint8_t, uint8_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdchar *bscv_get_label(char [][MAX_LOM2_NAME_STR], int, int);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_generic_sysevent(bscv_soft_state_t *, char *, char *, char *,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd char *, int32_t, char *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_sysevent(bscv_soft_state_t *, lom_event_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_prog_image(bscv_soft_state_t *, boolean_t,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int bscv_prog_receive_image(bscv_soft_state_t *, lom_prog_t *,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_leave_programming_mode(bscv_soft_state_t *, boolean_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_read_hostname(bscv_soft_state_t *, char *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_write_hostname(bscv_soft_state_t *, char *, uint8_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint8_t bscv_read_env_name(bscv_soft_state_t *, uint8_t,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_trace(bscv_soft_state_t *, char, const char *,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd const char *, ...);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_idi_init();
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_idi_fini();
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_idi_clear_err();
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic boolean_t bscv_nodename_set(struct bscv_idi_info info);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic boolean_t bscv_wdog_pat(struct bscv_idi_info info);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic boolean_t bscv_wdog_cfg(struct bscv_idi_info info);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_write_sig(bscv_soft_state_t *ssp, bscv_sig_t s);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_inform_bsc(bscv_soft_state_t *, uint32_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_watchdog_pat_request(void *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_watchdog_cfg_request(bscv_soft_state_t *, uint8_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint_t bscv_set_watchdog_timer(bscv_soft_state_t *, uint_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_clear_watchdog_timer(bscv_soft_state_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_watchdog_cyclic_add(bscv_soft_state_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void bscv_watchdog_cyclic_remove(bscv_soft_state_t *);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Local Definitions
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define STATUS_READ_LIMIT 8 /* Read up to 8 status changes at a time */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSCV_INST_TO_MINOR(i) (i)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSCV_MINOR_TO_INST(m) (m)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Strings for daemon event reporting
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic char *eventSubsysStrings[] =
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic char *eventTypeStrings[] =
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * These store to mapping between the logical service, e.g. chan_prog for
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * programming, and the actual Xbus channel which carries that traffic.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Any services can be shared on the same channel apart from chan_wdogpat.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * cb_ops structure defining the driver entry points
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * dev_ops structure defining autoconfiguration driver autoconfiguration
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * routines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd 0, /* devo_refcnt */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * module configuration section
193974072f41a843678abf5f61979c748687e66bSherry Moore#define BSCV_VERSION_STRING "bscv driver - Debug"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#else /* DEBUG */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* DEBUG */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com/* Tracing is enabled if value is non-zero. */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com#define BSCV_TRACE if (bscv_trace_flag != 0) bscv_trace
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * kernel accessible routines. These routines are necessarily global so the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * driver can be loaded, and unloaded successfully
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - _init
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - initializes the driver state structure and installs the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * driver module into the kernel
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - success or failure of module installation
1c42de6d020629af774dd9e9fc81be3f3ed9398egd register int e;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (e);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (e == 0) bscv_idi_init();
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (e);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - _info
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - provide information about a kernel loaded module
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - module infomation
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - success or failure of information request
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - _fini
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - removes a module from the kernel and frees the driver soft
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * state memory
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - success or failure of module removal
1c42de6d020629af774dd9e9fc81be3f3ed9398egd register int e;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (e);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (e);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_getinfo
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - routine used to provide information on the driver
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device information structure, command, command arg, storage
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * area for the result
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (cmd) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_idi_mgr.valid_inst = (uint32_t)~0; /* No valid instances */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Now that all fields are initialized, set the magic flag. This is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * a kind of integrity check for the data structure.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_idi_err
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - error messaging service which throttles the number of error
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * messages to avoid overflowing storage
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * returns - boolean to indicate whether a message should be reported
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * side-effects - updates the error number counter
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We don't care how many instances we have, or their value, so long
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * as we have at least one valid value. This is so service routines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * can get any required locks via a soft state pointer.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_idi_mgr.valid_inst = (uint32_t)~0; /* No valid instances */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_attach
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - this routine is responsible for setting aside memory for the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * driver data structures, initialising the mutexes and creating
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the device minor nodes. Additionally, this routine calls the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the callback routine.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device information structure, DDI_ATTACH command
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (cmd) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * initialise the mutexes
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_attach: mutexes and condition vars initialised");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Map in physical communication channels */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Associate logical channels to physical channels */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * At this point the inter-driver-interface is made available.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The IDI uses the event thread service which
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_attach_common() sets up.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * now create the minor nodes
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_attach: device minor nodes created");
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota "detected: hardware watchdog disabled");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Before we enable the watchdog - register the panic
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * callback so that we get called to stop the watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * in the case of a panic.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_detach
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - routine that prepares a module to be unloaded. It undoes all
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the work done by the bscv_attach)() routine. This is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * facilitated by the use of the progress indicator
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device information structure, DDI_DETACH command
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_reset
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * description - routine that implements the obsolete devo_reset entry point.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * MAN page declares that devo_quiesce subsumes devo_reset
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * functionality.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device information structure, DDI_RESET command
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (cmd) {
193974072f41a843678abf5f61979c748687e66bSherry Moore * quiesce(9E) entry point.
193974072f41a843678abf5f61979c748687e66bSherry Moore * This function is called when the system is single-threaded at high
193974072f41a843678abf5f61979c748687e66bSherry Moore * PIL with preemption disabled. Therefore, this function must not be
193974072f41a843678abf5f61979c748687e66bSherry Moore * This function returns DDI_SUCCESS on success, or DDI_FAILURE on failure.
193974072f41a843678abf5f61979c748687e66bSherry Moore * DDI_FAILURE indicates an error condition and should almost never happen.
193974072f41a843678abf5f61979c748687e66bSherry Moore ssp = ddi_get_soft_state(bscv_statep, instance);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com /* Disable tracing, as we are executing at High-Interrupt level */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com /* quiesce the device */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * cb_ops routines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_open
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - routine to provide association between user fd and device
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * minor number. This routine is necessarily simple since a
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * read/write interface is not provided. Additionally, the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * driver does not enforce exclusive access (FEXCL) or
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * non-blocking during an open (FNDELAY). Deferred attach is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * supported.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device number, flag specifying open type, device type,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * permissions
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - success or failure of operation
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'O', "bscv_open", "instance 0x%x", instance);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_close
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - routine to perform the final close on the device. As per the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * open routine, neither FEXCL or FNDELAY accesses are enforced
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * by the driver.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device number,flag specifying open type, device type,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * permissions
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - success or failure of operation
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED1*/
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'O', "bscv_close", "instance 0x%x", instance);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd unsigned int nelements;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Work out how many channels are available by looking at the number
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * of elements of the regs property array.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd retval = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, ssp->dip,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* We don't need props anymore. Free memory if it was allocated */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Check for sanity of nelements */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_map_regs", "lookup reg returned"
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_map_regs", "nelements %d not"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (nelements > BSCV_MAXCHANNELS * LOMBUS_REGSPEC_SIZE) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_map_regs", "nelements %d too large"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (nelements < BSCV_MINCHANNELS * LOMBUS_REGSPEC_SIZE) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_map_regs", "nelements %d too small"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ", need to have at least a general and a wdog channel",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp->attr.devacc_attr_endian_flags = DDI_STRUCTURE_LE_ACC;
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_map_regs", "map failure"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Rewind all current mappings - avoiding failed one */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (; i >= 0; i--) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * It is important to set nchannels to 0 even if, say, only one of
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the two required handles was mapped. If we cannot achieve our
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * minimum config its not safe to do any IO; this keeps our failure
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * mode handling simpler.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Map logical services onto physical XBus channels.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We can assert that there will always be at least two channels,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * to allow watchdog pats to be segregated from all other traffic.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * By default move all other services onto the generic channel unless
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the hardware supports additional channels.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_full_stop
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - gracefully shut the lom down during panic or reboot.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * Disables the watchdog and sets up serial event reporting.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "turning off watchdog");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * Obtain the softstate lock only if it is not already owned,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * as this function can be called from a High-level interrupt
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * context. As a result, our thread cannot sleep.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * At end of function, our thread releases the lock only if
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * it acquired the lock.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com obtained_lock = (bscv_tryenter(ssp) != 0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* set serial event reporting */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Make sure serial event reporting is on */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Make sure serial event reporting is on */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com /* Do not free the lock if our thread did not obtain it. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOM I/O routines.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Two sets of routines are provided:
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * normal - must be called after acquiring an appropriate lock.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * locked - perform all the locking required and return any error
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * code in the supplied 'res' argument. If there is no
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * error 'res' is not changed.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The locked routines are designed for use in ioctl commands where
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * only a single operation needs to be performed and the overhead of
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * locking and result checking adds significantly to code complexity.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * locking primitives
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * bscv_enter() - acquires an I/O lock for the calling thread.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * bscv_tryenter() - conditionally acquires an I/O lock for calling thread.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * bscv_exit() - releases an I/O lock acquired by bscv_enter().
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com * bscv_held() - used to assert ownership of an I/O lock.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * normal I/O routines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note bscv_{put|get}{16|32} routines are big-endian. This assumes that
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the firmware works that way too.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_put8(), bscv_put16, bscv_put32 - write values to the LOM
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and handle any retries if necessary.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 16 and 32 bit values are big-endian.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_get8(), bscv_get16, bscv_get32 - read values from the LOM
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and handle any retries if necessary.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 16 and 32 bit values are big-endian.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_setclear8() - set or clear the specified bits in the register
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * at the supplied address.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_setclear8_volatile() - set or clear the specified bits in the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * register at the supplied address. If the lom reports
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * that the registers has changed since the last read
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * re-read and apply the set or clear to the new bits.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_get8_cached() - Return a cached register value (addr < 0x80).
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Does not access the hardware. A read of the hardware
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * automatically updates this cache.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * locked I/O routines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_get8_locked(), bscv_rep_get8_locked().
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Call the indicated function from above, but wrapping it with
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_enter()/bscv_exit().
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Fault management
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOM communications fault are grouped into three categories:
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 1) Faulty - the LOM is not responding and no attempt to communicate
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * with it should be made.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 2) Transient fault - something which might recover after a retry
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * but which doesn't affect our ability to perform other
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * commands.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 3) Command error - an inappropriate command was executed. A retry
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * will not fix it but the command failed.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The current implementation of the bscv driver is not very good at
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * noticing command errors due to the structure of the original code
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * that it is based on. It is possible to extend the driver to do this
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and would probably involve having a concept of a "session error"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * which is less severe than a fault but means that a sequence of
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * commands had some fault which cannot be recovered.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_faulty() - returns B_TRUE if the LOM (communications) have been
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * declared faulty.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_clear_fault() - marks the LOM as not faulty.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_set_fault() - marks the LOM as being faulty.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_clear_fault and bscv_set_fault should generally not be called
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * directly.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * command errors/transient faults
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_retcode() - returns the actual error code of the last operation.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_should_retry() - determines if last operation may suceed if
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * retried.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_locked_result() - Set the result of a locked register access.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * low level I/O primitives
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * These are generally not called directly. These perform a single
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * access to the LOM device. They do not handle retries.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_put8_once()
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_get8_once()
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_probe() - perform a probe (NOP) operation to check out lom comms.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_resync_comms() - resynchronise communications after a transient fault.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, '@', "bscv_tryenter", "");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com if ((rv = mutex_tryenter(&ssp->cmd_mutex)) != 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* DEBUG */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_put8(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint8_t val)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x <= 0x%02x", addr >> 8, addr & 0xff, val);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Failure - we ran out of retries */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "write %d times, giving up",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (num_failures > 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x retried write %d times, succeeded",
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_put16(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint16_t val)
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_put32(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint32_t val)
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get8(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Failure */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "read %d times, giving up",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (num_failures > 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x retried read %d times, succeeded",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x => %02x", addr >> 8, addr & 0xff, retval);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get16(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x => %04x", addr >> 8, addr & 0xff, retval);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get32(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x => %08x", addr >> 8, addr & 0xff, retval);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x, set %02x, clear %02x => %02x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, '@', "bscv_setclear8_volatile",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x => set %02x clear %02x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Re-read the stale register from the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Failure */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd cmn_err(CE_WARN, "bscv_setclear8_volatile: addr 0x%x.%02x "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "retried write %d times, giving up",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (num_failures > 0) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'R', "bscv_setclear8_volatile",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x retried write %d times, succeeded",
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_rep_rw8(bscv_soft_state_t *ssp, int chan, uint8_t *host_addr,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* We need this because _once routines don't do it */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * No retry here. If we were AUTOINCR then get/put
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * will have retried. For NO_AUTOINCR we cannot retry
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * because the data would be corrupted.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get8_cached(bscv_soft_state_t *ssp, bscv_addr_t addr)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Can be called with or without the lock held */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get8_locked(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, int *res)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, '@', "bscv_get8_locked",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x => %02x", addr >> 8, addr & 0xff, retval);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_rep_get8_locked(bscv_soft_state_t *ssp, int chan, uint8_t *host_addr,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_addr_t dev_addr, size_t repcount, uint_t flags, int *res)
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'J', "bscv_clear_fault", "clearing fault flag");
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'J', "bscv_set_fault", "setting fault flag");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* This command is due to an I/O fault - retry might fix */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (1);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The command itself was bad - there is no point in fixing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note. Whatever happens we should know that if we were
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * doing EBUS_IDX_SELFTEST0..EBUS_IDX_SELFTEST7 and we
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * had 0x80 set then this is a test error not a retry
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_put8_once(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr, uint8_t val)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Bail out things are not working */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Didn't manage to map handles so ddi_{get,put}* broken */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nchannels is 0x0 so cannot do IO");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Clear any pending fault */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG), 0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Do the access and get fault code - may take a long time */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG));
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (fault == 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Things were ok - update cache entry */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Store cacheable entries */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* lombus problem - do a resync session */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "for address 0x%x.%02x - data 0x%x, fault 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Attempt to resync with the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note: we do not set fault status here. That
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is done if our caller decides to give up talking to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the lom. The observant might notice that this means
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * that if we mend things on the last attempt we still
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * get the fault set - we just live with that!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x <= 0x%02x", addr >> 8, addr & 0xff, val);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get8_once(bscv_soft_state_t *ssp, int chan, bscv_addr_t addr)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Bail out things are not working */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0xff);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Didn't manage to map handles so ddi_{get,put}* broken */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nchannels is 0x0 so cannot do IO");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0xff);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Clear any pending fault */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG), 0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Do the access and get fault code - may take a long time */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG));
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* lombus problem - do a resync session */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "for address 0x%x.%02x - data 0x%x, fault 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Attempt to resync with the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note: we do not set fault status here. That
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is done if our caller decides to give up talking to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the lom. The observant might notice that this means
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * that if we mend things on the last attempt we still
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * get the fault set - we just live with that!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * FIXME - should report error if you get
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * EBUS_ERROR_DEVICEFAIL reported from the BSC. That gets
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * logged as a failure in bscv_should_retry and may contribute
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * to a permanent failure. Reference issues seen by Mitac.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Store cacheable entries */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "addr 0x%x.%02x => 0x%02x", addr >> 8, addr & 0xff, val);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_probe(bscv_soft_state_t *ssp, int chan, uint32_t *fault)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Failed to map handles, so cannot do any IO. Set the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * fault indicator and return a dummy value.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nchannels is 0x0 so cannot do any IO");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return ((~(int8_t)0));
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Clear faults */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_FAULT_REG), 0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Probe and Check faults */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_PROBE_REG));
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Read status */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (uint32_t *)BSC_NEXUS_ADDR(ssp, chan, 0, LOMBUS_ASYNC_REG));
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Didn't manage to map handles so ddi_{get,put}* broken.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Therefore, there is no way to resync comms.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, '@', "bscv_resync_comms",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nchannels is 0x0 so not possible to resync comms");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Resync here to make sure that the lom is talking */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Attempting comms resync after comms fault 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Probe */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (fault == 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "comms resync (probing) - try 0x%x "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (fault != 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Failed to resync comms - giving up");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMLite configuration/event eeprom access routines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_window_setup() - Read/Sanity check the eeprom parameters.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This must be called prior to calling bscv_eerw().
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_window_setup
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - this routine reads the eeprom parameters and sanity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * checks them to ensure that the lom is talking sense.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - B_TRUE if the eeprom is ok, B_FALSE if the eeprom is not OK.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Already have good cached values */
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota bscv_get8(ssp, chan_general, EBUS_IDX_EEPROM_SIZE_KB) * 1024;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The log does not run to the end of the EEPROM because it is a
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * logical partition. The last 8K partition is reserved for FRUID
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_window_setup", "eeprom size 0x%x log_start"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " 0x%x log_size 0x%x", ssp->eeprom_size, ssp->eventlog_start,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Sanity check values */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "!bscv_window_setup: read invalid eeprom parameters");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_window_setup", "returning eeinfo_valid %s",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_eerw
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - this routine reads/write data from/to the eeprom.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * It takes care of setting the window on the eeprom correctly.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr, eeprom offset, data buffer, size, read/write
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - B_TRUE if the eeprom is ok, B_FALSE if the eeprom is not OK.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_eerw(bscv_soft_state_t *ssp, uint32_t eeoffset, uint8_t *buf,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd while (remaining > 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Select correct eeprom page */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_put8(ssp, chan_eeprom, EBUS_IDX_EEPROM_PAGESEL, this_page);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "%s data @0x%x.%02x, size 0x%x, 0x%x bytes remaining",
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_is_null_event(bscv_soft_state_t *ssp, lom_event_t *e)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (EVENT_DECODE_SUBSYS(e->ev_subsys) == EVENT_SUBSYS_NONE &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This marks a NULL event.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_is_null_event",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (e->ev_subsys == 0xff && e->ev_event == 0xff) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Under some circumstances, we've seen all 1s to represent
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * a manually cleared event log at the BSC prompt. Only
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * a test/diagnosis environment is likely to show this.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_is_null_event", "0xffff null event");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Not a NULL event.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_is_null_event", "returning False");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * IOCTL Processing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_ioctl
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - routine that acts as a high level manager for ioctls. It
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * calls the appropriate handler for ioctls on the alarm:mon and
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * alarm:ctl minor nodes respectively
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Unsupported ioctls (now deprecated)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCALCTL
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCALSTATE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCCLEARLOG
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCCTL
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCCTL2
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDAEMON
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDMON
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDOGCTL, TSIOCDOGCTL
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDOGPAT, TSIOCDOGPAT
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDOGTIME, TSIOCDOGTIME
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCEVENTLOG
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCEVNT
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCGETMASK
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMPROG
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCNBMON, TSIOCNBMON
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCSLEEP
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCUNLOCK, TSIOCUNLOCK
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCWTMON, TSIOCWTMON
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Supported ioctls
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDOGSTATE, TSIOCDOGSTATE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCPROG
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCPSUSTATE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCFANSTATE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCFLEDSTATE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCINFO
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMREAD
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCVOLTS
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCSTATS
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCTEMP
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCCONS
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCEVENTLOG2
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCINFO2
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCTEST
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMPROG2
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMREAD2
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device number, command, user space arg, filemode, user
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * credentials, return value
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - the return value propagated back by the lower level routines.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred, int *rvalp)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The Combined Switch and Service Processor takes care of configuration
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and control. The CSSP tells the BSC chip about it; therefore the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv driver doesn't send such configuration and control to the BSC.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Additionally Watchdog configuration is no longer done from userland
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (cmd) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * set the default result.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Check that the caller has appropriate access permissions
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * (FWRITE set in mode) for those ioctls which change lom
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (cmd) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* NOTREACHED */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Does not require write access */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (cmd) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_ioctl", "Invalid IOCTL 0x%x", cmd);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCDOGSTATE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * TSIOCDOGSTATE - indicate whether the alarm watchdog and reset
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * circuitry is enabled or not.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_dogstate(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd dogval = bscv_get8_locked(ssp, chan_general, EBUS_IDX_WDOG_CTRL, &res);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd dogstate.dog_enable = (dogval & EBUS_WDOG_ENABLE) ? 1 : 0;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd dogstate.reset_enable = (dogval & EBUS_WDOG_RST) ? 1 : 0;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd dogstate.dog_timeout = bscv_get8_locked(ssp, chan_general,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCPSUSTATE - returns full information for 4 PSUs. All this
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * information is available from two bytes of LOMlite RAM, but if
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * on the first read it is noticed that two or more of the PSUs are
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * not present only 1 byte will be read subsequently.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_psustate(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < MAX_PSUS; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ddi_copyout((caddr_t)&psudata, (caddr_t)arg, sizeof (psudata),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCFANSTATE - returns full information including speed for 4
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * fans and the minimum and maximum operating speeds for each fan as
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * stored in the READ ONLY EEPROM data. As this EEPROM data is set
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * at manufacture time, this data should only be read by the driver
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * once and stored locally.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_fanstate(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&fandata, (caddr_t)arg, sizeof (fandata),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCFLEDSTATE - returns the state of the fault LED
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_fledstate(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd fledstate = bscv_get8_locked(ssp, chan_general, EBUS_IDX_ALARM, &res);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Decode of 0x0F is off and 0x00-0x07 is on. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* has +1 here - not 2 as in the info ioctl */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCLEDSTATE - returns the state of the requested LED
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_ledstate(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* copy in arguments supplied */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * check if led index is -1, if so set it to max value for
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * this implementation.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* is the index in a valid range */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((led_state.index > MAX_LED_ID) || (led_state.index < 0)) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* read the relevant led info */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* set the state values accordingly */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* set the label info */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* copy out lom_state */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCINFO - returns with a structure containing any information
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * stored on the LOMlite which a user should not need to access but
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * may be useful for diagnostic problems. The structure contains: the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * serial escape character, alarm3 mode, version and checksum read from
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * RAM and the Product revision and ID read from EEPROM.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_info(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd info.ser_char = bscv_get8_locked(ssp, chan_general, EBUS_IDX_ESCAPE,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd info.fver = bscv_get8_locked(ssp, chan_general, EBUS_IDX_FW_REV, &res);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd csum = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_HI, &res)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd csum |= bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_LO, &res);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd info.prod_rev = bscv_get8_locked(ssp, chan_general, EBUS_IDX_MODEL_REV,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_ALARM, &res) &
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&info, (caddr_t)arg, sizeof (info),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMREAD - used to query the LOMlite configuration parameters
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_mread(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd mprog.mod_rev = bscv_get8_locked(ssp, chan_general, EBUS_IDX_MODEL_REV,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd mprog.config = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CONFIG,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Read the fan calibration values */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < fanz; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&mprog, (caddr_t)arg, sizeof (mprog),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCVOLTS
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_volts(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd supply = (bscv_get8_locked(ssp, chan_general, EBUS_IDX_SUPPLY_HI, &res)
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota << 8) | bscv_get8_locked(ssp, chan_general, EBUS_IDX_SUPPLY_LO,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCSTATS
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_stats(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd status = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CBREAK_STATUS,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCTEMP
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_temp(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bcopy(ssp->temps.name_ov, temps.name_ov, sizeof (temps.name_ov));
1c42de6d020629af774dd9e9fc81be3f3ed9398egd status_ov = bscv_get8_locked(ssp, chan_general, EBUS_IDX_OTEMP_STATUS,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&temps, (caddr_t)arg, sizeof (temps),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCCONS
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_cons(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd datasize = EBUS_IDX1_CONS_BUF_END - EBUS_IDX1_CONS_BUF_START + 1;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Ensure that we do not overfill cbuf and that it is NUL terminated */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_rep_get8_locked(ssp, chan_general, (uint8_t *)cbuf.lrbuf,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd BSCVA(EBUS_CMD_SPACE1, (EBUS_IDX1_CONS_BUF_END - datasize + 1)),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* This is always within the array due to the checks above */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&cbuf, (caddr_t)arg, sizeof (cbuf),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCEVENTLOG2
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_eventlog2(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd eventlog2 = (lom_eventlog2_t *)kmem_zalloc(sizeof (*eventlog2),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * First get number of events and level requested.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * OK we have full private access to the LOM now so loop
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * over the eventlog addr spaces until we get the required
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * number of events.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Read count, next event ptr MSB,LSB. Note a read of count
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is necessary to latch values for the next event ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) bscv_get8(ssp, chan_general, EBUS_IDX_UNREAD_EVENTS);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd next_offset = bscv_get16(ssp, chan_general, EBUS_IDX_LOG_PTR_HI);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "log_ptr_hi 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Working backwards - read an event at a time.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * next_offset is one event on from where we want to be!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Decrement next_offset and maybe wrap to the end of the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note the unsigned arithmetic, so check values first!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Wrap to the end of the buffer */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "wrapping"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " around to end of buffer; next_offset 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Fault reading data - stop */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "read"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * No more events in this log so give up.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'I', "bscv_ioc_eventlog2", "no more"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Are we interested in this event
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Arggh why the funny byte ordering 3, 2, 0, 1 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCINFO2
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_info2(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd info2.serial_events = ssp->reporting_level | ssp->serial_reporting;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd info2.fver = bscv_get8_locked(ssp, chan_general, EBUS_IDX_FW_REV, &res);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd csum = bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_HI, &res)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd csum |= bscv_get8_locked(ssp, chan_general, EBUS_IDX_CHECK_LO, &res);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd info2.serial_config = bscv_get8_locked(ssp, chan_general,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_CONFIG_MISC, &res) &
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_CONFIG_MISC, &res) &
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (bscv_get8_locked(ssp, chan_general, EBUS_IDX_WDOG_CTRL, &res) &
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * There is no phone home support on the blade platform. We hardcode
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * FALSE and NUL for config and script respectively.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&info2, (caddr_t)arg, sizeof (info2),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCTEST
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_test(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ddi_copyin((caddr_t)arg, (caddr_t)&test, sizeof (test),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Extract num iterations.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "LOMIOCTEST data 0x%x (test 0x%x, arg 0x%x)",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Invalid test */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Run the test */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Stop other things and then run the test */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Then we simply write the argument to the relevant register
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and wait for the return code.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Get hold of the SunVTS error code */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&test, (caddr_t)arg, sizeof (test),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMPROG2
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_mprog2(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ddi_copyin((caddr_t)arg, (caddr_t)&mprog2, sizeof (mprog2),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note that originally this was accessed as 255 byte pages
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * in address spaces 240-255. We have to emulate this behaviour.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((mprog2.addr_space < 240) || (mprog2.addr_space > 255)) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Calculate required data location */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd eeprom_size = bscv_get8(ssp, chan_general, EBUS_IDX_EEPROM_SIZE_KB) *
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Request extends past end of eeprom");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_put8(ssp, chan_general, EBUS_IDX_CMD_RES, EBUS_CMD_UNLOCK1);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'M', "bscv_ioc_mprog2", "ML1 Write failed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_put8(ssp, chan_general, EBUS_IDX_CMD_RES, EBUS_CMD_UNLOCK2);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'M', "bscv_ioc_mprog2", "ML2 Write failed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Read a probe key to release the lock. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOMIOCMREAD2
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_ioc_mread2(bscv_soft_state_t *ssp, intptr_t arg, int mode)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ddi_copyin((caddr_t)arg, (caddr_t)&mprog2, sizeof (mprog2),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Need to stop the queue and then just read
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the bytes blind to the relevant addresses.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note that originally this was accessed as 255 byte pages
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * in address spaces 240-255. We have to emulate this behaviour.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((mprog2.addr_space < 240) || (mprog2.addr_space > 255)) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Calculate required data location */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd eeprom_size = bscv_get8(ssp, chan_general, EBUS_IDX_EEPROM_SIZE_KB) *
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Request extends past end of eeprom");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((res == 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (ddi_copyout((caddr_t)&mprog2, (caddr_t)arg, sizeof (mprog2),
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Are there any changes to process? */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd change = bscv_get8(ssp, chan_general, EBUS_IDX_STATE_CHNG);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Clarify the pending change */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd detail = bscv_get8(ssp, chan_general, EBUS_IDX_EVENT_DETAIL);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_get_state_changes",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Event Processing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_event_daemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - Perform periodic lom tasks in a separate thread.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_event_daemon: started");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Acquire task daemon lock. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (;;) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Stop request seen - terminate */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Poll for events reported to the nexus */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Probe and Check faults */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "process event: async_reg 0x%x, fault 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Treat non-fault conditions */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The BSC has become available again.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (fault_cnt > 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Previous fault has cleared */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "!bscv_event_daemon previous fault "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "cleared.");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Previous fault has cleared */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Sleep to avoid busy waiting */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Expect radio silence or error values
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * when the CSSP is upgrading the BSC firmware
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * so throw away any fault indication.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Count previous faults and maybe fail */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Declare the lom broken */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "!bscv_event_daemon had faults probing "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom - marking it as faulty.");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Increment fault_cnt to ensure that
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * next time we do not report a message
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * i.e. we drop out of the bottom
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * No recovery messages in this case
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * because there was never a fault
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * message here.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Getting ready to explode */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "!bscv_event_daemon had fault 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * we have no platmod hook on Solaris x86 to report
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * a change to the nodename so we keep a copy so
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * we can detect a change and request that the bsc
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * be updated when appropriate.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "utsname.nodename='%s' possible change detected",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* enforce null termination */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We must not hold task_mu whilst processing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * events because this can lead to priority
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inversion and hence our interrupts getting
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * locked out.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "do_nodename task");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "do_watchdog task");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Pending status changes are dealt with last because
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * if we see that the BSC is about to be programmed,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * then it will expect us to to quiescent in the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * first second so it can cleanly tear down its comms
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * protocols; this takes ~100 ms.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Had fault during event session. We always
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * sleep after one of these because there
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * may be a problem with the lom which stops
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * us doing useful work in the event daemon.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If we don't sleep then we may livelock.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "had session error - sleeping");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We have read any events which were
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * pending. Let the consumer continue.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Ignore the race condition with new events
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * arriving - just let the consumer have
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * whatever was pending when they asked.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* There was nothing to do - sleep */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Sleep until there is something to do */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We are going away so wake up any event consumer.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Pretend that any pending events have been processed.
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota ~(TASK_STOP_FLG | TASK_ALIVE_FLG | TASK_EVENT_CONSUMER_FLG);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "exiting.");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_start_event_daemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - Create the event daemon thread.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Start the event thread after the queue has started */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) thread_create(NULL, 0, (void (*)())bscv_event_daemon, ssp,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_stop_event_daemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - Attempt to stop the event daemon thread.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS OR DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Wait for task daemon to stop running. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Signal that the task daemon should stop */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Release task daemon lock. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * TODO - when the driver is modified to support
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * system suspend or if this routine gets called
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * during panic we should use drv_usecwait() rather
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * than delay in those circumstances.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_pause_event_daemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - Attempt to pause the event daemon thread.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS OR DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Nothing to do */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Attempting to pause event daemon");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Signal that the task daemon should pause */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Wait for task daemon to pause. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Paranoia */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Release task daemon lock. */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Pause event daemon - success");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Pause event daemon - failed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_resume_event_daemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - Resumethe event daemon thread.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - None.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Nothing to do */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Allow the task daemon to resume event processing */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_pause_event_daemon",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Event daemon resumed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_event_process
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - process (report) events
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - Soft state ptr, process event request
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_event_process(bscv_soft_state_t *ssp, boolean_t do_events)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd unsigned int count;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Raw values read from the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Read count, next event ptr MSB,LSB. Note a read of count
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * latches values for the next event ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd evcount = bscv_get8(ssp, chan_general, EBUS_IDX_UNREAD_EVENTS);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd logptr = bscv_get16(ssp, chan_general, EBUS_IDX_LOG_PTR_HI);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Sanity check the values from the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Nothing to do - or badly configured event log.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We really do not want to touch the lom in this
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * case because any data that we access may be bad!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This differs from zero because if we have zero
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * to read the lom probably things that unread is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * non-zero and we want that to be set to zero!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Signal event fault to make the thread wait
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * before attempting to re-read the log.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Clear down any old status - things are fixed */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Compute the first entry that we need to read. */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_event_process",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "processing %d events from 0x%x in 0x%x:0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Ensure window is positioned correctly */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Fault reading data - stop */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Clear event count - write the evcount value to remove that
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * many from the unread total.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Adjust the value to reflect how many we have left to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * read just in case we had a failure reading events.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (count == 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_put8(ssp, chan_general, EBUS_IDX_UNREAD_EVENTS, evcount);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Remember where we were for next time */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_event_validate
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - validate the event data supplied by the lom and determine
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * how many (if any) events to read.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This function performs complex checks to ensure that
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * events are not lost due to lom resets or host resets.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * A combination of lom reset and host reset (i.e. power fail)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * may cause some events to not be reported.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - Soft state ptr, next event pointer, number of unread events.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - the number of events to read. -1 on error.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * zero is a valid value because it forces the loms unread
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * count to be cleared.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_event_validate(bscv_soft_state_t *ssp, uint32_t newptr, uint8_t unread)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd unsigned int count;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Problem with lom eeprom setup we cannot do anything */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (-1);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Sanity check the event pointers */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (newptr >= (ssp->eventlog_start + ssp->eventlog_size))) {
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota "Cannot read events.");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (-1);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Now sanity check log pointer against count */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Must have wrapped add eventlog_size to get the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * correct relative values - this makes the checks
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * below work!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* We have just started up - we have to trust lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Nothing to do - we were just polling */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (-1);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (oldptr + (unread * sizeof (lom_event_t)) == newptr) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Ok - got as many events as we expected */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (oldptr + (unread * sizeof (lom_event_t)) > newptr) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Errrm more messages than there should have been.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Possible causes:
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 1. the event log has filled - we have been
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * away for a long time
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 2. software bug in lom or driver.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 3. something that I haven't thought of!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Always warn about this we should really never
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_event_process",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_event_process: lom reported "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "more events (%d) than expected (%d).",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Less messages - perhaps the lom has been reset */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_event_process",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom reported less events (%d) than expected (%d)"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - the lom may have been reset",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Whatever happens only read a maximum of 255 entries */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_event_process: too many events (%d) to "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_event_process_one
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - reports on state changes to the host.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_event_process_one(bscv_soft_state_t *ssp, lom_event_t *event)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Cleared entry - do not report it */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (level) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The message is important enough to be shown on the console
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * as well as the log.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The message goes only to the log.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * time formats
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The BSC represents times as seconds since epoch 1970. Currently it gives
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * us 32 bits, unsigned. In the future this might change to a 64-bit count,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * to allow a greater range.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Timestamp values below BSC_TIME_SANITY do not represent an absolute time,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * but instead represent an offset from the last reset. This must be
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * borne in mind by output routines.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * render a formatted time for display
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_event_snprintgmttime(char *buf, size_t bufsz, todinfo_t t)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* tod_year is base 1900 so this code needs to adjust */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (snprintf(buf, bufsz, "%04d-%02d-%02d %02d:%02d:%02dZ",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_build_eventstring
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - reports on state changes to the host.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_build_eventstring(bscv_soft_state_t *ssp, lom_event_t *event,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'S', "bscv_build_eventstring", "event %2x%2x%2x%2x",
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'S', "bscv_build_eventstring", "time %2x%2x%2x%2x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We accept bad subsystems and event type codes here.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The code decodes as much as possible and then produces
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * suitable output.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* time */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* offset */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* absolute time */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* subsysp */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (sizeof (eventSubsysStrings)/sizeof (*eventSubsysStrings))) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* resource */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd buf += snprintf(buf, bufend - buf, "%d ", event->ev_resource);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd buf += snprintf(buf, bufend - buf, "%s ", bscv_get_label(
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* fatal */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* eventp */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (sizeof (eventTypeStrings)/sizeof (*eventTypeStrings))) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "unknown event 0x%02x%02x%02x%02x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* detail */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ": v%d.%d to v%d.%d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - unclaimed exception 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " after flash download");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - unknown reason");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If both inputs are seen to have failed then simply
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * indicate that the PSU input has failed
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* At least one input is ok */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Only flag an output error if an input is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * still present
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " Output");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - no boot");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - reset defaults");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - full diag");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - skip diag");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - inserted");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " - removed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* shutd */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Ensure newline at end of string */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd cmn_err(CE_WARN, "!bscv_build_eventstring: buffer too small!");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* DEBUG */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_level_of_event
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - This routine determines which level an event should be
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * reported at.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - lom event structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - event level.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This is the same criteria that the firmware uses except we
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * log the fault led on as being EVENT_LEVEL_FAULT
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (EVENT_DECODE_SUBSYS(event->ev_subsys) == EVENT_SUBSYS_USER) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd EVENT_SUBSYS_ALARM) && (event->ev_event == EVENT_STATE_ON)) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd EVENT_SUBSYS_LOM) && event->ev_event == EVENT_TIME_REFERENCE) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * All recovery messages need to be reported to the console
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * because during boot, the faults which occurred whilst
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Solaris was not running are relayed to the console. There
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is a case whereby a fatal fault (eg. over temp) could
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * have occurred and then recovered. The recovery condition
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * needs to be reported so the user doesn't think that the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * failure (over temp) is still present.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* None of FAULT, FATAL or SHUTDOWN REQD are set */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (EVENT_DECODE_FAULT(event->ev_subsys) == EVENT_MASK_FAULT) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Only FAULT set i.e not FATAL or SHUTDOWN REQD */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_status
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - This routine is called when any change in the LOMlite2 status
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is indicated by the status registers.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - LOM soft state structure pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_status(bscv_soft_state_t *ssp, uint8_t state_chng, uint8_t dev_no)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'D', "bscv_status", "state_chng 0x%x dev_no 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The device that has changed is given by the state change
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * register and the event detail register so react
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * accordingly.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The BSC is indicating a self state change
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "ssp->cssp_prog changed to 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * It takes the BSC at least 100 ms to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * clear down the comms protocol.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We back-off from talking to the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * BSC during this period.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "completed delay");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The bsc has reset
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "BSC reset occured, re-synching");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "completed attach_common");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((state_chng & EBUS_STATE_FAN) && ((dev_no - 1) < MAX_FANS)) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Only remember fanspeeds which are real values or
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * NOT PRESENT values.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((state_chng & EBUS_STATE_PSU) && ((dev_no - 1) < MAX_PSUS)) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) bscv_get8(ssp, chan_general, EBUS_IDX_CBREAK_STATUS);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Only remember temperatures which are real values or
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * a NOT PRESENT value.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_get_label(char labels[][MAX_LOM2_NAME_STR], int limit, int index)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return ("");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return ("-");
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_generic_sysevent(bscv_soft_state_t *ssp, char *class, char *subclass,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd char *fru_id, char *res_id, int32_t fru_state, char *msg)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", "%s/%s:(%s,%s,%d) %s",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE, KM_SLEEP)) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist alloc failure");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist ENV_VERSION failure");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist ENV_FRU_ID failure");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (nvlist_add_string(attr_list, ENV_FRU_RESOURCE_ID, res_id)) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist ENV_FRU_RESOURCE_ID failure");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (nvlist_add_string(attr_list, ENV_FRU_DEVICE, ENV_RESERVED_ATTR)) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist ENV_FRU_DEVICE failure");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (nvlist_add_int32(attr_list, ENV_FRU_STATE, fru_state)) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist ENV_FRU_STATE failure");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nvlist ENV_MSG failure");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_generic_sysevent", "sent sysevent");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_sysevent
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - send out a sysevent on the given change if needed
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state pointer, event to report
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_sysevent", "processing event");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Map ev_subsys to sysevent class/sub-class */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd res_id = bscv_get_label(ssp->sflags.name, ssp->sflags.num,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * There are 3 LEDs : Power, Service, Ready-to-Remove on a
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * JBOS blade. We'll never report the Power since Solaris
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * won't be running when it is _switched_ ON. Ready-to-Remove
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * will only be lit when we're powered down which also means
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Solaris won't be running. We don't want to report it
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * during system testing / Sun VTS exercising the LEDs.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Therefore, we only report the Service Required LED.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'E', "bscv_sysevent", "class/subclass NULL");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_generic_sysevent(ssp, class, subclass, fru_id, res_id, fru_state,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Firmware download (programming)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_prog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - LOMlite2 flash programming code.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_prog_image - download a complete image to the lom.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_prog_receive_image - receive data to build up a
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * complete image.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_prog_stop_lom - pause the event daemon and prepare
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * lom for firmware upgrade.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_prog_start_lom - reinit the driver/lom after upgrade
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and restart the event daemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state pointer, arg ptr, ioctl mode
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - status
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We will get repeatedly called with bits of data first for
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * loader, then for main image.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd prog = (lom_prog_t *)kmem_alloc(sizeof (lom_prog_t), KM_SLEEP);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ddi_copyin((caddr_t)arg, (caddr_t)prog, sizeof (*prog),
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This is the initial request for the chip type so we
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * know what we are programming.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The type will have been read in at init so just
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * return it in data[0].
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_check_loader_config(bscv_soft_state_t *ssp, boolean_t is_image2)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_check_loader_config",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "loader_running %d, is_image2 %d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * loader_running TRUE means that we have told the microcontroller to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * JUMP into the loader code which has been downloaded into its RAM.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * At this point its an error to try and download another loader. We
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * should be downloading the actual image at this point.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Conversely, it is an error to download an image when the loader is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * not already downloaded and the microcontroller hasn't JUMPed into it.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is_image2 TRUE means the image is being downloaded.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * is_image2 FALSE means the loader is being downloaded.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "with loader image already active");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "failed firmware download - ignoring download attempt");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "without loader image active");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_get_pagesize", "pagesize 0x%x", pagesize);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Sets the pagesize, returning the old value.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_set_pagesize(bscv_soft_state_t *ssp, uint32_t pagesize)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The microcontroller remembers this value until until someone
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * changes it.
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PSIZ0), pagesize);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd retval = bscv_get8(ssp, chan_prog, BSCVA(EBUS_CMD_SPACE_PROGRAM,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_leave_programming_mode(bscv_soft_state_t *ssp, boolean_t with_jmp)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_leave_programming_mode",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "jumptoaddr");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_leave_programming_mode",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "prgmode_off");
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSR), reg);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_set_jump_to_addr(bscv_soft_state_t *ssp, uint32_t loadaddr)
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PADR0), loadaddr);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_set_jump_to_addr",
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_erase_once(bscv_soft_state_t *ssp, uint32_t loadaddr, uint32_t image_size)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * write PADR, PSIZ to define area to be erased
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We do not send erase for zero size because the current
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * downloader gets this wrong
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * start at 0
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_erase_once", "sending erase command");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* set PSIZ to full size of image to be programmed */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* write ERASE to PCSR */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* read PCSR to check status */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_do_erase(bscv_soft_state_t *ssp, uint32_t loadaddr, uint32_t image_size,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd while (retryable--) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ", base 0x%x, size 0x%x, %s image",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd while (retryable--) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Write the page address and read it back for confirmation.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "set page 0x%x, read back 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_do_page_data_once(bscv_soft_state_t *ssp, uint32_t index,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'P', "bscv_do_page_data_once", "index 0x%x", index);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* write PSIZ bytes to PDAT */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'P', "bscv_do_page_once",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Sending last block, last 0x%x bytes",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Now pad the rest of the page with zeros */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* write the checksum to PCSM */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < size; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Cope with non-pagesize sized bufers */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (; i < pagesize; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd BSCVA(EBUS_CMD_SPACE_PROGRAM, EBUS_PROGRAM_PCSM0), chksum);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic uint8_t bscv_do_page(bscv_soft_state_t *ssp, uint32_t loadaddr,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd uint32_t index, uint32_t image_size, uint32_t pagesize, uint8_t *imagep,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'P', "bscv_do_page", "index 0x%x", index);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd while (retryable--) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Set the page address (with retries). If this is not
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * successful, then there is no point carrying on and sending
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the page's data since that could cause random memory
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * corruption in the microcontroller.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "could not setup page address 0x%x, %s image",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Send down the data for the page
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'P', "bscv_do_page", "sending data for page");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " attempt %d, index 0x%x, checksum 0x%x, %s image",
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_do_page", "Returning 0x%x for index 0x%x,"
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_do_pages(bscv_soft_state_t *ssp, uint32_t loadaddr, uint32_t image_size,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'P', "bscv_do_pages", "entered");
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_prog_image(bscv_soft_state_t *ssp, boolean_t is_image2,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "image 0x%x, imagep %p, size 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Return no error to allow userland to continue on with
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * downloading the image.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd cmn_err(CE_WARN, "lom: Failed to enter program mode, error 0x%x"
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_prog_image", "entered programming mode");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Only issue an erase if we are downloading the image. The loader
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * does not need this step.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd retval = bscv_do_erase(ssp, loadaddr, image_size, is_image2);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom: Erase failed during programming, status 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "erase complete - programming...");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd retval = bscv_do_pages(ssp, loadaddr, image_size, pagesize, imagep,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We've downloaded the loader successfully. Now make the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * microcontroller jump to it.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We've just downloaded either the loader which failed, or
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the image (which may or may not have been successful).
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (res != 0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "got error 0x%x - leaving programming mode",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "programming complete - leaving programming mode");
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_prog_receive_image(bscv_soft_state_t *ssp, lom_prog_t *prog,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'U', "bscv_prog_receive_image",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Got wrong buffer 0x%x, expected 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We want to get the whole image and then do the download.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * It is assumed the device is now in programming mode.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Starting a new image */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom image exceeded maximum size: got 0x%x, maximum 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * OK we have the whole image so synch up and start download.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Old style programming data */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Take care image may not fill all of structure */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* sign extend loadaddr from 16 to 32 bits */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd " expected 0x%x, got 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Done the loading so set the flag to say we are doing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the other image.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Image too small for new style image */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* New style programming image */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Already programming - this may be a retry of a failed
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * programming attempt or just a software error!
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'Q', "bscv_prog_stop_lom",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "failed to pause event daemon thread");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Not programming so this is not a valid command */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * OK we are out of reset now so:
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Probe the firmware and set everything up.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Explicit clear fault because things may have been mended now */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd cmn_err(CE_WARN, "Firmware upgrade failed to exit loader - "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "performing forced exit");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Must try to restart the lom here. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Ensure prog mode entry to enable PRGMODE_OFF */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* give the lom chance to recover */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Start the event thread after the queue has started
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Not sure if this is entirely correct because
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the other code at the end of bscv_attach()
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * does not get run here.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Attach processing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * *********************************************************************
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_attach_common
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - this routine co-ordinates the initialisation of the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * driver both at attach time and after firmware programming.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * sequence - bscv_setup_capability - read LOMlite2 capabilities
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_probe_check - test comms and setup register cache
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_setup_hostname - sync stored name in lom with nodename.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_setup_static_info - read device names etc.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bscv_setup_events - start event daemon etc.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - device information structure, DDI_ATTACH command
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_attach_common:", "");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Set the threshold for reporting messages to the console to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Warnings or higher.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * When the system is not running the Operating System, make
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the microcontroller print event messages straight onto the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * console.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Setup capabilities */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We want lom -G to talk to this driver upon broken firmware
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * so we prematurely return success here.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Watchdog configuration and CPU signatures are sent asynchronously
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * with respect to attach so only inform the BSC if we've already
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * sent the data in the past.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_cleanup
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - routine that does the necessary tidying up if the attach
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * request fails or the driver is to be detached.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If the event thread has been started we may fail to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * stop it (because it is busy) so we fail the cleanup
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and hence the detach. All other calls to bscv_cleanup
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * are done before the event daemon is started.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state structure address.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Fail the cleanup - may be able to cleanup later */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * switch back on serial event reporting - cover all configs.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (ssp->serial_reporting == LOM_SER_EVENTS_OFF) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (ssp->serial_reporting == LOM_SER_EVENTS_DEF) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_setclear8_volatile(ssp, chan_general, EBUS_IDX_ALARM,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * disable the reset function if we have enabled
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * it. We don't want any nasty surprises like system
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * rebooting unexpectedly. If we timeout on the busy
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * flag we just have to carry on.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_cleanup - disable wdog");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * unmap registers
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * release any memory allocated for mutexes and condition
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * variables before deallocating the structures containing them
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_setup_capability
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - probe the lom find what capabilities are present for
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * us to use.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - returns DDI_SUCCESS or DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Turn off all capabilities */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_setup_capability",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Capability flags cap0=0x%x cap1=0x%x, cap2=0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_probe_check
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - probe the lom to check for correct operation
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * has a side effect of setting up the cached registers and
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * updates ssp->prog_mode_only.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - returns DDI_SUCCESS or DDI_FAILURE
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check", "");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Make sure probe location is OK so that we are
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * in sync.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We want to make sure that this is not faulty so we
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * do a bscv_clear_fault to clear any existing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * fault records down.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd probeval = bscv_get8(ssp, chan_general, EBUS_IDX_PROBEAA);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "LOMlite out of sync");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * It may be that the LOMlite was out of
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * sync so lets try the read again.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Init readAA1 failed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * OK that is twice we are out so I
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * guess the LOMlite is in trouble
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Init readAA probe failed - got 0x%x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Read in all page zero lom registers.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Read state change 1st so we dont miss anything and clear it.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note: we discard the values because we rely on bscv_get8 to
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * setup the cache of register values.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) bscv_get8(ssp, chan_general, EBUS_IDX_STATE_CHNG);
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Read of state change register failed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (i) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Should not read these - they have side
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * effects.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Initial read or register %2x failed", i);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Might as well give up now! */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Check the probe keys so we know the lom is OK
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "LOMlite Probe failed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < 0x8; i++) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_probe_check",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "%2x %2x %2x %2x %2x %2x %2x %2x %2x "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "%2x %2x %2x %2x %2x %2x %2x %2x %2x",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return ((ssp->prog_mode_only == B_FALSE) ? DDI_SUCCESS : DDI_FAILURE);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_idi_set
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - bscv inter driver interface set function
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - structure which defines type of service required and data
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * ouputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This is the Entry Point function for the platmod driver. It works out which
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * X Bus channel ought to deliver the service requested.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_callout_table");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This error message can appear in the context of
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * another driver, say platmod or todblade. We want
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * to clearly indicate the culprit driver so put in
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the driver name.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "driver instance of "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We service the request with a valid instance number
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * for the driver.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If the request was serviced, clear any accumulated
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * error counters so future warnings will be reported if
1c42de6d020629af774dd9e9fc81be3f3ed9398egd cmn_err(CE_WARN, "!bscv_idi_set : cannot match info.type %d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_nodename_set
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - notify the event thread that a nodename change has occurred.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - data from client driver
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * side-effects - the event thread will schedule an update to the lom firmware.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Get a lock on the SSP, notify our change, then exit */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_sig_set
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - write a signature
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - data from client driver
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Service the request */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The value of the dog pat is a sequence number which wraps around,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bounded by BSCV_WDOG_PAT_SEQ_MASK.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Set top nibble to indicate a pat */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Now pat the dog. This exercises a special protocol in the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bus nexus that offers : non-blocking IO, and timely delivery,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * callable from high-level interrupt context. The requirement
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * on us is that the channel is not shared for any other use.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This means for chan_wdogpat, nothing may use channel[chan].regs
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * or channel.[chan].handle.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'W', "bscv_wdog_pat", "patted the dog with seq %d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_wdog_pat
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - pat the watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - data from client driver
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This function remembers if it has ever been called with the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * configure option set.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Didn't manage to map handles so ddi_{get,put}* broken */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_wdog_cfg
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - configure the watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - data from client driver
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp = ddi_get_soft_state(bscv_statep, bscv_idi_mgr.valid_inst);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Didn't manage to map handles so ddi_{get,put}* broken */
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'W', "bscv_wdog_set", "data passed in is size"
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'W', "bscv_wdog_cfg", "enable_wdog %s, "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "wdog_timeout_s %d, reset_system_on_timeout %s",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ((bscv_wdog_t *)info.data)->enable_wdog ? "enabled" : "disabled",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ((bscv_wdog_t *)info.data)->reset_system_on_timeout ? "yes" : "no");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Configure the timeout value (1 to 127 seconds).
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note that a policy is implemented at the bsc/ssp which bounds
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the value further. The bounding here is to fit the timeout value
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * into the 7 bits the bsc uses.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Configure the watchdog on or off.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Configure whether the microcontroller should reset the system when
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the watchdog expires.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp->watchdog_reset_on_timeout = reset_system_on_timeout;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* have the event daemon set the timeout value and whether to reset */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_setup_watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - setup the bsc watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs -
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Set the timeout */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Set whether to reset the system on timeout */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Set other host defaults */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_setclear8_volatile(ssp, chan_general, EBUS_IDX_WDOG_CTRL,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* start the cyclic based watchdog patter */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_setup_hostname
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - setup the lom hostname if different from the nodename
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Check machine label is the same as the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * system nodename.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* read in lom hostname */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Enforce null termination */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd hostlen = (size_t)bscv_get8(ssp, chan_general, EBUS_IDX_HNAME_LENGTH);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((nodelen > 0) &&
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ((hostlen != nodelen) || (strcmp((const char *)&lom_nodename,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (const char *)&host_nodename)) ||
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_setup_hostname",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "nodename(%s,%d) != bsc label(%s,%d)",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Write new label into LOM EEPROM */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_read_hostname
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - read the current hostname from the lom
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state pointer and buffer to store the hostname in.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_read_hostname(bscv_soft_state_t *ssp, char *lom_nodename)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We have a special failure case here because a retry of a read
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * causes data to be lost. Thus we handle the retries ourselves
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and are also responsible for detemining if the lom is faulty
1c42de6d020629af774dd9e9fc81be3f3ed9398egd length = bscv_get8(ssp, chan_general, EBUS_IDX_HNAME_LENGTH);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < length; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Retry on any error */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* null terminate for strcmp later */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Force the nodename to be empty */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Failure - we ran out of retries */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_read_hostname: retried %d times, giving up",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (num_failures > 0) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'R', "bscv_read_hostname",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_write_hostname
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - write a new hostname to the lom
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state pointer, pointer to new name, name length
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We have a special failure case here because a retry of a read
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * causes data to be lost. Thus we handle the retries ourselves
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and are also responsible for detemining if the lom is faulty
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_put8(ssp, chan_general, EBUS_IDX_HNAME_LENGTH, length);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < length; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Retry on any error */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Failure - we ran out of retries */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_write_hostname: retried %d times, giving up",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (num_failures > 0) {
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'R', "bscv_write_hostname",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_setup_static_info
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - read in static information from the lom at attach time.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Finally read in some static info like device names,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * shutdown enabled, etc before the queue starts.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * To get the volts static info we need address space 2
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom: firmware reported too many voltage lines. ");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_setup_static_info",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd mask = bscv_get8(ssp, chan_general, BSCVA(EBUS_CMD_SPACE2,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd mask |= bscv_get8(ssp, chan_general, BSCVA(EBUS_CMD_SPACE2,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Get the temperature static info and populate initial temperatures.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Do not destroy old temperature values if the new value is not
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * known i.e. if the device is inaccessible.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom: firmware reported too many temperatures being "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "monitored.");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom: firmware reported too many over temperatures being "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "monitored.");
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_setup_static_info",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "num temps %d, over temps %d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp->temps.warning[i] = (int8_t)bscv_get8(ssp, chan_general,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If shutdown is not enabled then set it as zero so
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * it is not displayed by the utility.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* New value is not known - use old value */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Check for and skip a single 0xff character between the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * temperature and over temperature names
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * To get the CB static info we need address space 3
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ssp->sflags.num = EBUS_CONFIG3_NBREAKERS_DEC(bscv_get8(ssp,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom: firmware reported too many status flags.");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Reported %d, maximum is %d",
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_setup_static_info",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * To get the fan static info we need address space 5
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "lom: firmware reported too many fans. ");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "Reported %d, maximum is %d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Do not destroy previous values unless the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * value is definitive.
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_setup_static_info",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Get led static information from address space 10 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_read_env_name
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - read in static environment names
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * warning changes address space and the caller relies
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * on this behaviour.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr, chosen address space,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * start of name data, end of name data,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * name storage, number of names.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - next address for reading name data.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd unsigned int addr_space_ptr;
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'A', "bscv_read_env_name",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "bscv_read_env_name, space %d, start 0x%x, end 0x%x, numnames %d",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < numnames; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Read the current character.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Ran out of names - this must
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * be the end of the name.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This is really an error because
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * we have just seen either a non-NUL
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * terminated string or the number of
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * strings did not match what was
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * reported.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We increment the buffer pointer now so that
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * it is ready for the next read
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Found end of string - done */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Buffer not full - record character
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * NOTE we always leave room for the NUL
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * terminator.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Ensure null termination */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Clamp addr_space_ptr to 0xff because we return uint8_t */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_setup_events
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - initialise the event reporting code
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS or DDI_FAILURE
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * deal with event reporting - cover all cases
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (ssp->serial_reporting == LOM_SER_EVENTS_OFF) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd } else if (ssp->serial_reporting == LOM_SER_EVENTS_DEF) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd bscv_setclear8_volatile(ssp, chan_general, EBUS_IDX_ALARM,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_write_sig
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - write out a signature, taking care to deal with any strange
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * values for CPU ID
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr, signature
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* Upload the signature */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We always write the CPU ID last because this tells the firmware
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * that the signature is fully uploaded and therefore to consume the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * data. This is required since the signature is > 1 byte in size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and we transmit data in single bytes.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (s.cpu == ~0) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* ~0 means the signature applies to any CPU. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The CPU ID supplied is unexpectedly large. Lets
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * just use the bottom bits, in case other high order
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bits are being used for special meaning.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_inform_bsc
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - inform bsc of driver state for logging purposes
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - driver soft state, state
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_SIG_MSB), state);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd BSCVA(EBUS_CMD_SPACE_CPUSIG, EBUS_IDX11_CPU_ID), EBUS_ANY_CPU_ID);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_watchdog_pat_request
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - request a heartbeat pat
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - timeout value in seconds
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_watchdog_cfg_request
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - request configuration of the bsc hardware watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - new state (0=disabled, 1=enabled)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - one if successful, zero if unsuccesful
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_watchdog_cfg_request(bscv_soft_state_t *ssp, uint8_t new_state)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_watchdog_cfg_request",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_set_watchdog_timer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - setup the heartbeat timeout value
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - timeout value in seconds
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - zero if the value was not changed
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * otherwise the current value
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_set_watchdog_timer(bscv_soft_state_t *ssp, uint_t timeoutval)
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_set_watchdog_timer:",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We get started during bscv_attach only
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * if bscv_watchdog_enable is set.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_clear_watchdog_timer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - add the watchdog patter cyclic
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - driver soft state
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - value of watchdog timeout in seconds
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * This function is a copy of the SPARC implementation
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * in the todblade clock driver.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_clear_watchdog_timer", "");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_panic_callback
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - called when we panic so we can disabled the watchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - driver soft state pointer
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - DDI_SUCCESS
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED1*/
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_panic_callback",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "disabling watchdog");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We dont get interrupts during the panic callback. But bscbus
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * takes care of all this
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_watchdog_cyclic_add
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - add the watchdog patter cyclic
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - driver soft state
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota ssp->periodic_id = ddi_periodic_add(bscv_watchdog_pat_request, ssp,
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_watchdog_cyclic_add:",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "cyclic added");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * function - bscv_watchdog_cyclic_remove
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * description - remove the watchdog patter cyclic
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * inputs - soft state ptr
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * outputs - none
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1af83355f7af9ab90e0c801c0224182053a04533andrew.rutz@sun.com BSCV_TRACE(ssp, 'X', "bscv_watchdog_cyclic_remove:",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "cyclic removed");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * General utility routines ...
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_trace(bscv_soft_state_t *ssp, char code, const char *caller,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd const char *fmt, ...)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) strlog((short)ssp->majornum, (short)ssp->minornum, code,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#else /* DEBUG */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdbscv_trace(bscv_soft_state_t *ssp, char code, const char *caller,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd const char *fmt, ...)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* DEBUG */