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
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Use is subject to license terms.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#pragma ident "%Z%%M% %I% %E% SMI"
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Implementation private header file for bscv driver.
1c42de6d020629af774dd9e9fc81be3f3ed9398egdextern "C" {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Local #defines
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The following are used as progress indicators in bscv_attach()
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * macros to encode device minors and provide mapping to device instances.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The following is designed to get around the problem of a 32-bit app not
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * supporting a 32-bit minor number on an LP64 model system.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define DEVICETOINSTANCE(x) ((getminor(x)) & (~BSCV_CONTROL_NODE));
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The maximum number of leds which are supported by this lom implementation.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * general driver configuration constants which may be changed to improve
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define MAX_WDOGTIMEOUT 127 /* maximum wdog timout - 127s */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Event processing task status flags.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * strace(1M) prints out the debug data once the debug value is set in
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the bscv.conf file and the debug driver is installed.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Debug flags
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * '@' - Register (@)ccess
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'A' - (A)ttach
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'B' - (B)lom1 attach extra
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'C' - lom1 (C)allback
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'D' - (D)aemon
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'E' - (E)vents
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'F' - Sel(F)test
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'I' - (I)octl
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'L' - TSa(L)arms
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'M' - (M)odel parameters
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'N' - I(N)terrupt Service Routine
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'O' - (O)pen/Close
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'P' - (P)rogramming
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'Q' - (Q)ueue things
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'R' - Read/Write (R)etry summary.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'S' - Event (S)trings
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'U' - Programming ioctls
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'V' - ???
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'W' - (W)atchdog
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'X' - additional X86 functional calls
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * 'Z' - Temporary - just log things
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Debug tips :
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * strace(1M) prints out the debug data.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * A nice way to work out the debug value set in bscv.conf is to use mdb
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Say we want to show 'D' Daemon and 'I' IOCTL processing,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * you calculate the debug value with the following mdb session :
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * > 1<<('D'-'@') | 1<<('I'-'@') = X
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * When you insert "debug=0x210;" into bscv.conf, it causes the next
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * reboot with the debug driver to trace Daemon and IOCTL functionality.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Xbus channel access data
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * soft state structure
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Hardware instance variables
1c42de6d020629af774dd9e9fc81be3f3ed9398egd ddi_device_acc_attr_t attr; /* device access attributes */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * lom2 static information.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * setup at driver attach and restart after programming.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* dont have to re-read names */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* dont have to re-read names */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* dont have to re-read names */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * lom2 firmware communication
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * cmd_mutex protects the lom2 command progress variables.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * These should only be read/updated with the mutex held.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * command_error - acts as a return code and may be read
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * without the mutex held if a command is not in progress.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Note a read only returns failure if the lom does not respond.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * So you might need to check the error code to see if things really
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * did work!
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * addr_mu is used to protect stopping and starting of the queue.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * BUT when programming it has different semantics and relies
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * on only the programming thread being in the ioctl routine
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * whilst programming is in progress. The event queue must also
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * be paused at this time.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* valid until the next command */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* starts. */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t had_fault; /* Current command sequence faulted */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t had_session_error; /* Current session had error */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Programming variables
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t prog_mode_only; /* If true we can only reprogram */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t programming; /* TRUE is actually programming */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* the BSC */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t cssp_prog; /* TRUE is CSSP programming the BSC */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* 0x8000 set if last buffer */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* for programming */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* programming */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t image2_processing; /* boolean to say which of */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* 2 BSC images being processed */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t loader_running; /* Still have the loader running */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * LOM eeprom window access state
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Access under bscv_enter/bscv_exit protection.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Communication with the event processing thread
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Change these variables with task_mu held and signal task_cv
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * if an event/task needs processing.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd volatile int event_active_count; /* Count of event thread runs */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t event_waiting; /* New events are waiting in the lom */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t status_change; /* A status change is waiting */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t event_sleep; /* Error reading events - wait a bit */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t event_fault_reported; /* Event fault reported */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t watchdog_change; /* Watchdog config has changed */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __sparc */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd uint8_t last_event[8]; /* last event read and reported */
dd4eeefdb8e4583c47e28a7f315db6087931ef06eota ddi_periodic_t periodic_id; /* watchdog patter periodical callback */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd callb_id_t callb_id; /* Need to store the ID so we can */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* unschedule the panic callback */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd char last_nodename[128]; /* copy of last utsname.nodename */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* __i386 || __amd64 */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd boolean_t (*fn)(struct bscv_idi_info); /* Function's address */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * To allow for sanity check.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The instance number of "an" instance of the driver. This is assigned
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * during driver attach.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Table of services offered via the idi interface.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Error message count since last successful use of the idi interface.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSC_IMAGE_MAX_SIZE (0x20000 + sizeof (lom_prog_data_t))
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSC_PROBE_FAULT_LIMIT 8 /* Tries before declaring lom dead */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSC_EVENT_POLL_NORMAL (drv_usectohz(1000000)) /* 1 second */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSC_EVENT_POLL_FAULTY (drv_usectohz(10000000)) /* 10 second */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSC_FAILURE_RETRY_LIMIT 5 /* Access retries before giving up */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define BSC_NEXUS_OFFSET(as, index) (((as) * 256) + (index))
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define PSR_SUCCESS(status) (((status) & EBUS_PROGRAM_PSR_STATUS_MASK) == \
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define PSR_PROG(status) (((status) & EBUS_PROGRAM_PSR_PROG_MODE) != 0)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#endif /* _SYS_BSCV_IMPL_H */