3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sbin/atm/fore_dnld/fore_dnld.c,v 1.6.2.2 2000/12/11 01:03:24 obrien Exp $
34 * Download (pre)processed microcode into Fore Series-200 host adapter
35 * Interact with i960 uart on Fore Series-200 host adapter
39 #include <sys/param.h>
41 #include <sys/socket.h>
44 #include <netatm/atm.h>
45 #include <netatm/atm_if.h>
46 #include <netatm/atm_sap.h>
47 #include <netatm/atm_sys.h>
48 #include <netatm/atm_ioctl.h>
49 #include <dev/hfa/fore.h>
50 #include <dev/hfa/fore_aali.h>
51 #include <dev/hfa/fore_slave.h>
59 #if (defined(BSD) && (BSD >= 199103))
67 __RCSID("@(#) $FreeBSD: src/sbin/atm/fore_dnld/fore_dnld.c,v 1.6.2.2 2000/12/11 01:03:24 obrien Exp $");
70 extern u_char pca200e_microcode[];
71 extern int pca200e_microcode_size;
74 #define DEV_NAME "/dev/sbus%d"
76 #if (defined(BSD) && (BSD >= 199103))
77 #define DEV_NAME _PATH_KMEM
87 #if (defined(BSD) && (BSD >= 199103))
89 #define TCSETA TIOCSETA
90 #define TCGETA TIOCGETA
116 return ( ntohl ( val ) );
126 return ( htonl ( val ) );
132 * Print an error message and exit.
144 printf ( "%s\n", msg );
149 * Get a byte for the uart and if printing, display it.
152 * prn Are we displaying characters
155 * c Character from uart
163 while ( ! ( CP_READ(Uart->mon_xmithost) & UART_VALID ) )
166 c = ( CP_READ(Uart->mon_xmithost) & UART_DATAMASK );
167 Uart->mon_xmithost = CP_WRITE(UART_READY);
170 * We need to introduce a delay in here or things tend to hang...
174 if ( lineptr >= sizeof(line) )
178 * Save character into line
183 if (isprint(c) || (c == '\n') || (c == '\r'))
190 * Loop getting characters from uart into static string until eol. If printing,
191 * display the line retrieved.
194 * prn Are we displaying characters
197 * none Line in global string 'line[]'
206 while ( c != '>' && c != '\n' && c != '\r' )
209 if ( ++i >= sizeof(line) )
212 printf ( "%s", line );
226 * Send a byte to the i960
229 * c Character to send
241 while ( CP_READ(Uart->mon_xmitmon) != UART_READY )
243 if ( CP_READ(Uart->mon_xmithost) & UART_VALID )
245 if ( !dn ) delay ( 10000 );
247 val = ( c | UART_VALID );
248 Uart->mon_xmitmon = CP_WRITE( val );
249 if ( !dn ) delay ( 10000 );
250 if ( CP_READ(Uart->mon_xmithost) & UART_VALID )
256 * Transmit a line to the i960. Eol must be included as part of text to transmit.
259 * line Character string to transmit
260 * len len of string. This allows us to include NULL's
261 * in the string/block to be transmitted.
267 xmit_to_i960 ( line, len, dn )
274 for ( i = 0; i < len; i++ )
275 xmit_byte ( line[i], dn );
279 * Send autobaud sequence to i960 monitor
290 if ( strncmp ( line, "Mon960", 6 ) == 0 )
291 xmit_to_i960 ( "\r\n\r\n\r\n\r\n", 8, 0 );
295 * Reset tty to initial state
298 * ret error code for exit()
307 sgtty.c_lflag |= ( ICANON | ECHO );
308 sgtty.c_cc[VMIN] = vmin;
309 sgtty.c_cc[VTIME] = vtime;
310 ioctl ( tty, TCSETA, &sgtty );
315 * Utility to strip off any leading path information from a filename
318 * path pathname to strip
321 * fname striped filename
330 if ( ( fname = strrchr ( path, '/' ) ) != NULL )
367 * crctab - CRC-16 constant array...
368 * from Usenet contribution by Mark G. Mendel, Network Systems Corp.
369 * (ihnp4!umn-cs!hyper!mark)
371 unsigned short crctab[1<<B] = {
372 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
373 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
374 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
375 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
376 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
377 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
378 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
379 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
380 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
381 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
382 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
383 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
384 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
385 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
386 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
387 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
388 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
389 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
390 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
391 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
392 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
393 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
394 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
395 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
396 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
397 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
398 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
399 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
400 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
401 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
402 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
403 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
407 * Hacked up xmodem protocol. Transmits the file 'filename' down to the i960
408 * using the xmodem protocol.
411 * filename name of file to transmit
415 * -1 unable to send file
418 xmitfile ( filename )
432 char buf[BUFSIZE + 6];
433 char blockbuf[BUFSIZE + 6];
436 int bufsize = BUFSIZE;
442 if ( ( fd = open ( filename, O_RDONLY ) ) < 0 )
446 stat ( filename, &stb );
449 * Determine number of 128 bytes sectors to transmit
451 numsect = ( stb.st_size / 128 ) + 1;
454 fprintf ( stderr, "Downloading %d sectors from %s\n",
458 * Send DO'wnload' command to i960
460 xmit_to_i960 ( "do\r\n", 4, 0 );
462 * Wait for response from i960 indicating download in progress
464 while ( strncmp ( line, "Downloading", 11 ) != 0 )
469 * Get startup character from i960
472 while ( ( c = getbyte(0) ) != NAK && c != CRCCHR )
473 if ( ++attempts > NAKMAX )
474 error ( "Remote system not responding" );
479 } while ( c != NAK && c != CRCCHR );
482 attempts = errors = sendfin = extrachr = 0;
485 * Loop over each sector to be sent
488 if ( extrachr >= 128 )
497 * Read a sectors worth of data from the file into
498 * an internal buffer.
500 for ( bufcntr = 0; bufcntr < bufsize; )
506 if ( ( n = read ( fd, &c, 1 ) ) == 0 )
511 buf[bufcntr++] = CTRLZ;
521 * Fill in xmodem protocol values. Block size and sector number
524 blockbuf[bbufcntr++] = (bufsize == 1024) ? STX : SOH;
525 blockbuf[bbufcntr++] = sectnum;
526 blockbuf[bbufcntr++] = ~sectnum;
531 * Loop over the internal buffer computing the checksum of the
534 for ( bufcntr = 0; bufcntr < bufsize; bufcntr++ )
536 blockbuf[bbufcntr++] = buf[bufcntr];
539 checksum = (checksum<<B) ^ crctab[(checksum>>(W-B)) ^ buf[bufcntr]];
541 checksum = ((checksum + buf[bufcntr]) & 0xff);
546 * Place the checksum at the end of the transmit buffer
551 blockbuf[bbufcntr++] = ((checksum >> 8) & 0xff);
552 blockbuf[bbufcntr++] = (checksum & 0xff);
554 blockbuf[bbufcntr++] = checksum;
559 * Make several attempts to send the data to the i960
564 * Transmit the sector + protocol to the i960
566 xmit_to_i960 ( blockbuf, bbufcntr, 1 );
569 * Inform user where we're at
572 printf ( "Sector %3d %3dk\r",
573 sectnum, (sectnum * bufsize) / 1024 );
577 * Get response from i960
579 sendresp = getbyte(0);
582 * If i960 didn't like the sector
584 if ( sendresp != ACK )
589 * Are we supposed to cancel the transfer?
591 if ( ( sendresp & 0x7f ) == CAN )
592 if ( getbyte(0) == CAN )
593 error ( "Send canceled at user's request" );
596 } while ( ( sendresp != ACK ) && ( attempts < RETRYMAX ) && ( errors < ERRORMAX ) );
603 } while ( !sendfin && ( attempts < RETRYMAX ) && ( errors < ERRORMAX ) );
606 * Did we expire all our allows attempts?
608 if ( attempts >= RETRYMAX )
610 xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 );
611 error ( "Remote system not responding" );
615 * Check for too many transmission errors
617 if ( errors >= ERRORMAX )
619 xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 );
620 error ( "Too many errors in transmission" );
626 * Indicate the transfer is complete
628 xmit_byte ( EOT, 1 );
631 * Wait until i960 acknowledges us
633 while ( ( c = getbyte(0) ) != ACK && ( ++attempts < RETRYMAX ) )
634 xmit_byte ( EOT, 1 );
636 if ( attempts >= RETRYMAX )
637 error ( "Remote system not responding on completion" );
640 * After download, we'll see a few more command
641 * prompts as the CP does its stuff. Ignore them.
643 while ( strncmp ( line, "=>", 2 ) != 0 )
646 while ( strncmp ( line, "=>", 2 ) != 0 )
649 while ( strncmp ( line, "=>", 2 ) != 0 )
653 * Tell the i960 to start executing the downloaded code
655 xmit_to_i960 ( "go\r\n", 4, 0 );
658 * Get the messages the CP will spit out
659 * after the GO command.
671 loadmicrocode ( ucode, size, ram )
695 * Check that we understand this header
697 memcpy(&binhdr, ucode, sizeof(binhdr));
698 if ( strncmp ( (caddr_t)&binhdr.Id, "fore", 4 ) != 0 ) {
699 fprintf ( stderr, "Unrecognized format in micorcode file." );
705 * We always swap the SunOS microcode file...
710 * We need to swap the header start/entry words...
713 for ( n = 0; n < sizeof(u_long); n++ )
717 for ( n = 0; n < sizeof(u_long); n++ )
723 * Set pointer to RAM load location
725 bufp = (ram + binhdr.start);
733 lp = (u_long *) ucode;
735 for ( i = 0; i < size / sizeof(long); i++ )
737 lp[i] = CP_WRITE(lp[i]);
743 for ( j = 0; j < 4; j++ )
749 bcopy ( (caddr_t)ucode, bufp, size );
752 * With .bin extension, we need to specify start address on 'go'
758 sprintf ( cmd, "go %lx\r\n", binhdr.entry );
760 xmit_to_i960 ( cmd, strlen ( cmd ), 0 );
762 while ( strncmp ( line, cmd, strlen(cmd) - 3 ) != 0 )
772 sendbinfile ( fname, ram )
797 if ( ( fd = open ( fname, O_RDONLY ) ) < 0 )
801 * Read the .bin header from the file
803 if ( ( read ( fd, &binhdr, sizeof(binhdr) ) ) != sizeof(binhdr) )
810 * Check that we understand this header
812 if ( strncmp ( (caddr_t)&binhdr.Id, "fore", 4 ) != 0 ) {
813 fprintf ( stderr, "Unrecognized format in micorcode file." );
820 * We always swap the SunOS microcode file...
825 * We need to swap the header start/entry words...
828 for ( n = 0; n < sizeof(u_long); n++ )
832 for ( n = 0; n < sizeof(u_long); n++ )
843 * Set pointer to RAM load location
845 bufp = (ram + binhdr.start);
852 * Need to swap longs - copy file into temp buffer
854 while ( ( n = read ( fd, (char *)buffer, sizeof(buffer))) > 0 )
859 for ( i = 0; i < sizeof(buffer) / sizeof(long); i++ )
861 buffer[i] = CP_WRITE(buffer[i]);
867 for ( j = 0; j < 4; j++ )
874 * Copy swapped buffer into CP RAM
877 bcopy ( (caddr_t)buffer, bufp, n );
879 printf ( "%d\r", cnt );
883 while ( ( n = read ( fd, bufp, 128 ) ) > 0 )
887 printf ( "%d\r", cnt );
893 * With .bin extension, we need to specify start address on 'go'
899 sprintf ( cmd, "go %lx\r\n", binhdr.entry );
901 xmit_to_i960 ( cmd, strlen ( cmd ), 0 );
903 while ( strncmp ( line, cmd, strlen(cmd) - 3 ) != 0 )
916 * Program to download previously processed microcode to series-200 host adapter
923 int fd; /* mmap for Uart */
924 u_char *ram; /* pointer to RAM */
925 Mon960 *Mon; /* Uart */
929 int binary = 0; /* Send binary file */
930 caddr_t buf; /* Ioctl buffer */
931 char bus_dev[80]; /* Bus device to mmap on */
932 struct atminfreq req;
933 struct air_cfg_rsp *air; /* Config info response structure */
934 int buf_len; /* Size of ioctl buffer */
935 char *devname = "\0"; /* Device to download */
936 char *dirname = NULL; /* Directory path to objd files */
937 char *objfile = NULL; /* Command line object filename */
938 u_char *ucode = NULL; /* Pointer to microcode */
939 int ucode_size = 0; /* Length of microcode */
940 char *sndfile = NULL; /* Object filename to download */
941 char filename[64]; /* Constructed object filename */
942 char base[64]; /* sba200/sba200e/pca200e basename */
943 int ext = 0; /* 0 == bin 1 == objd */
944 struct stat sbuf; /* Used to find if .bin or .objd */
947 progname = (char *)basename(argv[0]);
948 comm_mode = strcmp ( progname, "fore_comm" ) == 0;
950 while ( ( c = getopt ( argc, argv, "i:d:f:berv" ) ) != -1 )
956 dirname = (char *)strdup ( optarg );
962 devname = (char *)strdup ( optarg );
965 objfile = (char *)strdup ( optarg );
974 printf ( "usage: %s [-v] [-i intf] [-d dirname] [-f objfile]\n", argv[0] );
981 setbuf ( stdout, NULL );
983 if ( ( fd = socket ( AF_ATM, SOCK_DGRAM, 0 ) ) < 0 )
985 perror ( "Cannot create ATM socket" );
989 * Over allocate memory for returned data. This allows
990 * space for IOCTL reply info as well as config info.
992 buf_len = 4 * sizeof(struct air_cfg_rsp);
993 if ( ( buf = (caddr_t)malloc(buf_len) ) == NULL )
995 perror ( "Cannot allocate memory for reply" );
999 * Fill in request paramaters
1001 req.air_opcode = AIOCS_INF_CFG;
1002 req.air_buf_addr = buf;
1003 req.air_buf_len = buf_len;
1006 * Copy interface name into ioctl request
1008 strcpy ( req.air_cfg_intf, devname );
1013 if ( ( ioctl ( fd, AIOCINFO, (caddr_t)&req ) ) ) {
1014 perror ( "ioctl (AIOCSINFO)" );
1018 * Reset buffer pointer
1020 req.air_buf_addr = buf;
1028 * Loop through all attached adapters
1030 for (; req.air_buf_len >= sizeof(struct air_cfg_rsp);
1031 buf += sizeof(struct air_cfg_rsp),
1032 req.air_buf_len -= sizeof(struct air_cfg_rsp)) {
1035 * Point to vendor info
1037 air = (struct air_cfg_rsp *)buf;
1039 if (air->acp_vendor == VENDOR_FORE )
1045 sprintf ( bus_dev, DEV_NAME, air->acp_busslot );
1047 sprintf ( bus_dev, DEV_NAME );
1051 * Setup signal handlers
1053 signal ( SIGINT, SIG_IGN );
1054 signal ( SIGQUIT, SIG_IGN );
1057 * If comm_mode, setup terminal for single char I/O
1060 tty = open ( _PATH_TTY, O_RDWR );
1061 ioctl ( tty, TCGETA, &sgtty );
1062 sgtty.c_lflag &= ~( ICANON | ECHO );
1063 vmin = sgtty.c_cc[VMIN];
1064 vtime = sgtty.c_cc[VTIME];
1065 sgtty.c_cc[VMIN] = 0;
1066 sgtty.c_cc[VTIME] = 0;
1067 ioctl ( tty, TCSETA, &sgtty );
1071 * Open bus for memory access
1073 if ( ( fd = open ( bus_dev, O_RDWR ) ) < 0 )
1075 perror ( "open bus_dev" );
1076 fprintf(stderr, "%s download failed (%s)\n",
1077 air->acp_intf, bus_dev);
1082 * Map in the RAM memory to get access to the Uart
1084 #ifdef __FreeBSD__ /*XXX*/
1085 ram = (u_char *) mmap(0, PCA200E_MMAP_SIZE,
1087 ram = (u_char *) mmap(0, air->acp_ramsize,
1089 PROT_READ | PROT_WRITE, MAP_SHARED | MAP_HASSEMAPHORE,
1091 if (ram == (u_char *)-1) {
1092 perror ( "mmap ram" );
1093 fprintf(stderr, "%s download failed\n",
1098 Mon = (Mon960 *)(ram + MON960_BASE);
1099 Uart = (Mon960 *)&(Mon->mon_xmitmon);
1102 * Determine endianess
1104 switch ( Mon->mon_bstat ) {
1105 case BOOT_COLDSTART:
1112 switch (ntohl(Mon->mon_bstat)) {
1113 case BOOT_COLDSTART:
1121 fprintf(stderr, "%s unknown status\n",
1131 u_int *hcr = (u_int *)(ram + PCA200E_HCR_OFFSET);
1132 PCA200E_HCR_INIT(*hcr, PCA200E_RESET_BD);
1134 PCA200E_HCR_CLR(*hcr, PCA200E_RESET_BD);
1140 static struct timeval timeout = { 0, 0 };
1144 * We want to talk with the i960 monitor
1148 * Loop forever accepting characters
1155 * Check for data from the terminal
1158 FD_SET ( fileno(stdin), &fdr );
1160 if ( ( ns = select ( FD_SETSIZE, &fdr, NULL, NULL,
1161 &timeout ) ) < 0 ) {
1162 perror ( "select" );
1170 nr = read ( fileno(stdin), &c, 1 );
1181 xmit_byte ( 27, 0 );
1189 * Check for data from the i960
1191 if ( CP_READ(Uart->mon_xmithost) & UART_VALID ) {
1195 if ( strcmp ( line, "Mon960" ) == 0 )
1201 * Make sure the driver is loaded and that the CP
1202 * is ready for commands
1204 if ( CP_READ(Mon->mon_bstat) == BOOT_RUNNING )
1207 "%s is up and running - no download allowed.\n",
1213 if ( CP_READ(Mon->mon_bstat) != BOOT_MONREADY )
1216 "%s is not ready for downloading.\n",
1223 * Indicate who we're downloading
1226 printf ( "Downloading code for %s\n",
1230 * Look for the i960 monitor message.
1231 * We should see this after a board reset.
1233 while ( strncmp ( line, "Mon960", 6 ) != 0 &&
1234 strncmp ( line, "=>", 2 ) != 0 )
1235 getline( verbose ); /* Verbose */
1240 if ( strncmp ( line, "Mon960", 6 ) == 0 ) {
1241 xmit_to_i960 ( "\r\n\r\n\r\n\r\n", 8, 0 );
1246 * Keep reading until we get a command prompt
1248 while ( strncmp ( line, "=>", 2 ) != 0 )
1249 getline( verbose ); /* Verbose */
1252 * Choose the correct microcode file based on the
1253 * adapter type the card claims to be.
1255 switch ( air->acp_device )
1257 case DEV_FORE_SBA200:
1258 sprintf ( base, "sba200" );
1261 case DEV_FORE_SBA200E:
1262 sprintf ( base, "sba200e" );
1265 case DEV_FORE_PCA200E:
1266 sprintf ( base, "pca200e" );
1271 fprintf(stderr, "Unknown adapter type: %d\n",
1277 if ( objfile == NULL ) {
1278 switch ( air->acp_device ) {
1279 case DEV_FORE_SBA200:
1280 case DEV_FORE_SBA200E:
1281 sprintf ( filename, "%s.bin%d", base,
1283 if ( stat ( filename, &sbuf ) == -1 ) {
1284 sprintf ( filename, "%s/%s.bin%d",
1287 if ( stat ( filename, &sbuf ) == -1 ) {
1289 sprintf ( filename, "%s.objd%d",
1290 base, air->acp_bustype );
1291 if ( stat(filename, &sbuf) == -1 ) {
1293 "%s/%s.objd%d", dirname,
1296 if ( stat ( filename, &sbuf ) != -1 )
1305 case DEV_FORE_PCA200E:
1306 /* Use compiled in microcode */
1307 ucode = pca200e_microcode;
1308 ucode_size = pca200e_microcode_size;
1316 if ( ext && !binary )
1317 err = xmitfile ( sndfile );
1318 else if (sndfile != NULL)
1319 err = sendbinfile ( sndfile, ram );
1321 err = loadmicrocode( ucode, ucode_size, ram );
1324 fprintf(stderr, "%s download failed\n",
1331 * Download completed - wait around a while for
1332 * the driver to initialize the adapter
1334 aap = (Aali *)(ram + CP_READ(Mon->mon_appl));
1335 for (i = 0; i < MAX_CHECK; i++, sleep(1)) {
1336 u_long hb1, hb2, hb3;
1338 hb3 = CP_READ(Mon->mon_bstat);
1339 if (hb3 != BOOT_RUNNING) {
1341 printf("bstat %x\n", hb3);
1345 hb1 = CP_READ(aap->aali_heartbeat);
1347 hb2 = CP_READ(aap->aali_heartbeat);
1349 printf("hb %x %x\n", hb1, hb2);