fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 4500 - 4999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The following define is not to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file from sys/socalio.h, since it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * has same structure defines as in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Defines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The next define is to work around a problem with sbusmem driver not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * able to round up mmap() requests that are not around page boundaries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We'll leave this on leadville, as the onboard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * isn't allowed to be zapped by luxadm
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int load_file(char *, caddr_t, volatile socal_reg_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void usec_delay(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void getbootdev(unsigned int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void getsocpath(char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int loadsocpath(const char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int warn(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int write_feprom(uchar_t *, uchar_t *, volatile socal_reg_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int feprom_erase(volatile uchar_t *, volatile socal_reg_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: open() failed on file "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We will just make a check to see if it the file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * has the "SUNW,socal" strings in it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We cannot use strstr() here because we are operating on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * binary data and so is very likely to have embedded NULLs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First check for the SUNW,socal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: %s is not a "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get count of, and names of SBus slots using the SBus memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * interface.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " Bootpath: %s\n", bootpath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4503, "\n Found Path to %d FC100/S Cards\n"), numslots);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < numslots; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open SBus memory for this slot.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fflag && (strcmp(slotname, bootpath) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4504, " Ignoring %s (bootpath)\n"), slotname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(socal, "%s:0", &sbussoc_list[i][0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(socal, "%s:1", &sbussoc_list[i][0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mmap that SBus memory into my memory space.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr = mmap((caddr_t)0, PROM_SIZ_ROUNDED, PROT_READ|PROT_WRITE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Load the New FCode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (vflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (findversion(i, (uchar_t *)&version[0]) == FOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(125, "Complete\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dev_type = g_get_path_type(&sbussoc_list[index][0])) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(socal, "%s:0", &sbussoc_list[index][0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(socal, "%s:1", &sbussoc_list[index][0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Error: Unable to allocate memory."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, FCIO_FCODE_MCODE_VERSION, buffer) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fcal_s_download: could not get"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " fcode version.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the fcode and prom's fw version
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using new ioctls. Currently, we pass
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only the fcode version to the calling function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and ignore the FW version (using the existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * implementation). The function definition
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * might be changed in future to pass both the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcode and FW revisions to the calling function, if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * needed by the calling function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the fcode version */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Information read operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ntries = 0; ntries < MAX_RETRIES; ntries++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* wait 30 secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the FW revision */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Information read operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ntries = 0; ntries < MAX_RETRIES; ntries++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* wait 30 secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * program an FEprom with data from 'source_address'.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * program the FEprom with zeroes,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * program it with the real data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefeprom_program(uchar_t *source_address, uchar_t *dest_address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(4513, "Filling with zeroes...\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!write_feprom((uchar_t *)0, dest_address, regs)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4514, "FEprom at 0x%x: zero fill failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(4515, "Erasing...\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < FEPROM_MAX_ERASE; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4516, "FEprom at 0x%x: failed to erase\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "FEprom erased after %d attempt\n"), i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "FEprom erased after %d attempts\n"), i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(4519, "Programming...\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(write_feprom(source_address, dest_address, regs))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* select the zeroth bank at end so we can read it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(4521, "Programming done\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * program an FEprom one byte at a time using hot electron injection.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewrite_feprom(uchar_t *source_address, uchar_t *dest_address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < FEPROM_SIZE; i++, s++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((i & 0xffff) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (pulse = 0; pulse < FEPROM_MAX_PROGRAM; pulse++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *d = source_address ? *s : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*d == (source_address ? *s : 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * erase an FEprom using Fowler-Nordheim tunneling.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefeprom_erase(volatile uchar_t *dest_address, volatile socal_reg_t *regs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte usec_delay(10000); /* wait 10ms while FEprom erases */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < FEPROM_SIZE; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((i & 0xffff) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*d != 0xff) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We're searching the /devices directory, so... */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the directory entries under /devices for socal sbusmem */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "root is not on a local disk!\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset((char *)&bootpath[0], 0, PATH_MAX);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset((char *)&bootpath[0], 0, PATH_MAX);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function reads "size" bytes from the FC100/S PROM.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * source_address: PROM address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dest_address: local memeory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * offset: Location in PROM to start reading from.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefeprom_read(uchar_t *source_address, uchar_t *dest_address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int offset, int size, volatile socal_reg_t *regs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " feprom_read: selecting bank %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; s < source_address + (i & 0xffff) + size; d++, s++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteload_file(char *file, caddr_t prom, volatile socal_reg_t *regs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(4525, "Loading FCode: %s\n"), file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read(ffd, &exec, sizeof (exec)) != sizeof (exec)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Loading 0x%x bytes from %s at offset 0x%x\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read(ffd, &buffer, exec.a_text) != exec.a_text) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwn_hi |= wwn_d8 & 0x0f; /* only last digit is interesting */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " load_file: Writing WWN hi:0x%x lo:0x%x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* put wwn into buffer location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (feprom_program((uchar_t *)buffer, (uchar_t *)prom, regs) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* here 0 means failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"\nWARNING!! This program will update the FCode in this FC100/S Sbus Card.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"This may take a few (5) minutes. Please be patient.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Do you wish to continue ? (y/n) "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((strcmp(input, MSGSTR(4536, "n")) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(4537, "Not Downloading FCode\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(4538, "Invalid input\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getsocpath():
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Searches the /devices directory recursively returning all soc_name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entries in sbussoc_list (global). This excludes port entries and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * onboard socal (which leaves only directory entries with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * soc_name included). devcnt is updated to reflect number of soc_name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devices found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4539, "Error: %s lstat() error\n"), devpath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not a directory so
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we don't care about it - return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* It's a keeper - call the load function */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if socal directory - return,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nothing else to see here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It's a directory. Call ourself to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * traverse the path(s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Forget the /devices/pseudo/ directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4541, "Error: %s Can't read directory\n"), devpath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ptr, dirp->d_name); /* append name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(4542, "Error: %s Can't close directory\n"), devpath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Okay we found a device, now let's load it in to sbussoc_list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and load the sbusmem file into sbus_list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp_tmp = strstr(sbussoc_list[*devcnt], SOCAL_STR)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* len_tmp will be len of "SUNW,socal@" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen(sbussoc_list[*devcnt]) - strlen(sp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(buffer, sbussoc_list[*devcnt], len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(sbus_list[*devcnt], "%ssbusmem@%c,0:slot%c",