03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER START
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The contents of this file are subject to the terms of the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Common Development and Distribution License (the "License").
03831d35f7499c87d51205817c93e9a8d42c4baestevel * You may not use this file except in compliance with the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
03831d35f7499c87d51205817c93e9a8d42c4baestevel * See the License for the specific language governing permissions
03831d35f7499c87d51205817c93e9a8d42c4baestevel * and limitations under the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * When distributing Covered Code, include this CDDL HEADER in each
03831d35f7499c87d51205817c93e9a8d42c4baestevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * If applicable, add the following below this CDDL HEADER, with the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * fields enclosed by brackets "[]" replaced with your own identifying
03831d35f7499c87d51205817c93e9a8d42c4baestevel * information: Portions Copyright [yyyy] [name of copyright owner]
03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER END
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Use is subject to license terms.
03831d35f7499c87d51205817c93e9a8d42c4baestevel#pragma ident "%Z%%M% %I% %E% SMI"
03831d35f7499c87d51205817c93e9a8d42c4baestevel * download.c: support to the scadm download option (download service
03831d35f7499c87d51205817c93e9a8d42c4baestevel * processor firmware)
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic void usage();
03831d35f7499c87d51205817c93e9a8d42c4baestevel } else { /* no [boot] option */
03831d35f7499c87d51205817c93e9a8d42c4baestevel gettext("scadm: file could not be opened"), Filename);
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* Verify file is s-record */
03831d35f7499c87d51205817c93e9a8d42c4baestevel gettext("scadm: file not a valid s-record"), Filename);
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Don't call rscp_start() because SC may still be in the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * boot monitor. The boot monitor will not respond to
03831d35f7499c87d51205817c93e9a8d42c4baestevel * rscp_start()
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Initialize Message Queue used between ADM_Callback and
03831d35f7499c87d51205817c93e9a8d42c4baestevel * ADM_Boot_recv(). ADM_Callback is called from seperate thread.
03831d35f7499c87d51205817c93e9a8d42c4baestevel gettext("scadm: ERROR, unable to setup message queue"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* Initialize callback for Boot Monitor RX */
03831d35f7499c87d51205817c93e9a8d42c4baestevel while (BootRetry > 0) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Initialize Message each time because this structure is reused
03831d35f7499c87d51205817c93e9a8d42c4baestevel * during receive. Since this operation is not time critical,
03831d35f7499c87d51205817c93e9a8d42c4baestevel * this is not a concern
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Initialize Timeout each time just to be robust. Since this
03831d35f7499c87d51205817c93e9a8d42c4baestevel * operation is not time critical, this is not a concern.
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* If we timeout, decrement BootRetry and try again */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* We got a timeout */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* we got a message back, see what it is */
03831d35f7499c87d51205817c93e9a8d42c4baestevel * We got a valid acknowledge, break out of loop and
03831d35f7499c87d51205817c93e9a8d42c4baestevel * start to download s-record
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* See if we ever got a response */
03831d35f7499c87d51205817c93e9a8d42c4baestevel "initialization"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* Download s-record */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* wait a second for BootMonitor to catch up */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* Send Reset boot protocol message to reboot SC */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* Cleanup */
03831d35f7499c87d51205817c93e9a8d42c4baestevel (void) printf("%s\n\n", gettext("Download completed successfully"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel (void) printf("%s\n\n", gettext("Please wait for verification"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel * scadm cannot tell if the SC successfully verified the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * download or not, but instead attempts to send a
03831d35f7499c87d51205817c93e9a8d42c4baestevel * status message (up to 60 times) and assumes proper
03831d35f7499c87d51205817c93e9a8d42c4baestevel * operation when sucessfully sent.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * When the boot option is used, the SC may hang after
03831d35f7499c87d51205817c93e9a8d42c4baestevel * resetting itself (after it sucessfully downloads and
03831d35f7499c87d51205817c93e9a8d42c4baestevel * verifies the boot file). To work around this, scadm
03831d35f7499c87d51205817c93e9a8d42c4baestevel * will (1) do a hard reset and pause for 10 seconds
03831d35f7499c87d51205817c93e9a8d42c4baestevel * (2) retry the sending of status messages.
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* reset the SC before retrying */
03831d35f7499c87d51205817c93e9a8d42c4baestevel if (rsc_nmi() != 0) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel "scadm: Unable to reset SC hardware"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* delay while SC resets */
03831d35f7499c87d51205817c93e9a8d42c4baestevel for (i = 0; i < 60; i++) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel (void) printf("\n%s\n\n", gettext("Error during verification"));