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 $
27 * @(#) $DragonFly: src/sbin/atm/fore_dnld/fore_dnld.c,v 1.2 2003/06/17 04:27:32 dillon 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))
66 extern u_char pca200e_microcode[];
67 extern int pca200e_microcode_size;
70 #define DEV_NAME "/dev/sbus%d"
72 #if (defined(BSD) && (BSD >= 199103))
73 #define DEV_NAME _PATH_KMEM
83 #if (defined(BSD) && (BSD >= 199103))
85 #define TCSETA TIOCSETA
86 #define TCGETA TIOCGETA
112 return ( ntohl ( val ) );
122 return ( htonl ( val ) );
128 * Print an error message and exit.
140 printf ( "%s\n", msg );
145 * Get a byte for the uart and if printing, display it.
148 * prn Are we displaying characters
151 * c Character from uart
159 while ( ! ( CP_READ(Uart->mon_xmithost) & UART_VALID ) )
162 c = ( CP_READ(Uart->mon_xmithost) & UART_DATAMASK );
163 Uart->mon_xmithost = CP_WRITE(UART_READY);
166 * We need to introduce a delay in here or things tend to hang...
170 if ( lineptr >= sizeof(line) )
174 * Save character into line
179 if (isprint(c) || (c == '\n') || (c == '\r'))
186 * Loop getting characters from uart into static string until eol. If printing,
187 * display the line retrieved.
190 * prn Are we displaying characters
193 * none Line in global string 'line[]'
202 while ( c != '>' && c != '\n' && c != '\r' )
205 if ( ++i >= sizeof(line) )
208 printf ( "%s", line );
222 * Send a byte to the i960
225 * c Character to send
237 while ( CP_READ(Uart->mon_xmitmon) != UART_READY )
239 if ( CP_READ(Uart->mon_xmithost) & UART_VALID )
241 if ( !dn ) delay ( 10000 );
243 val = ( c | UART_VALID );
244 Uart->mon_xmitmon = CP_WRITE( val );
245 if ( !dn ) delay ( 10000 );
246 if ( CP_READ(Uart->mon_xmithost) & UART_VALID )
252 * Transmit a line to the i960. Eol must be included as part of text to transmit.
255 * line Character string to transmit
256 * len len of string. This allows us to include NULL's
257 * in the string/block to be transmitted.
263 xmit_to_i960 ( line, len, dn )
270 for ( i = 0; i < len; i++ )
271 xmit_byte ( line[i], dn );
275 * Send autobaud sequence to i960 monitor
286 if ( strncmp ( line, "Mon960", 6 ) == 0 )
287 xmit_to_i960 ( "\r\n\r\n\r\n\r\n", 8, 0 );
291 * Reset tty to initial state
294 * ret error code for exit()
303 sgtty.c_lflag |= ( ICANON | ECHO );
304 sgtty.c_cc[VMIN] = vmin;
305 sgtty.c_cc[VTIME] = vtime;
306 ioctl ( tty, TCSETA, &sgtty );
311 * Utility to strip off any leading path information from a filename
314 * path pathname to strip
317 * fname striped filename
326 if ( ( fname = strrchr ( path, '/' ) ) != NULL )
363 * crctab - CRC-16 constant array...
364 * from Usenet contribution by Mark G. Mendel, Network Systems Corp.
365 * (ihnp4!umn-cs!hyper!mark)
367 unsigned short crctab[1<<B] = {
368 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
369 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
370 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
371 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
372 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
373 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
374 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
375 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
376 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
377 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
378 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
379 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
380 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
381 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
382 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
383 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
384 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
385 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
386 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
387 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
388 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
389 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
390 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
391 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
392 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
393 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
394 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
395 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
396 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
397 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
398 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
399 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
403 * Hacked up xmodem protocol. Transmits the file 'filename' down to the i960
404 * using the xmodem protocol.
407 * filename name of file to transmit
411 * -1 unable to send file
414 xmitfile ( filename )
428 char buf[BUFSIZE + 6];
429 char blockbuf[BUFSIZE + 6];
432 int bufsize = BUFSIZE;
438 if ( ( fd = open ( filename, O_RDONLY ) ) < 0 )
442 stat ( filename, &stb );
445 * Determine number of 128 bytes sectors to transmit
447 numsect = ( stb.st_size / 128 ) + 1;
450 fprintf ( stderr, "Downloading %d sectors from %s\n",
454 * Send DO'wnload' command to i960
456 xmit_to_i960 ( "do\r\n", 4, 0 );
458 * Wait for response from i960 indicating download in progress
460 while ( strncmp ( line, "Downloading", 11 ) != 0 )
465 * Get startup character from i960
468 while ( ( c = getbyte(0) ) != NAK && c != CRCCHR )
469 if ( ++attempts > NAKMAX )
470 error ( "Remote system not responding" );
475 } while ( c != NAK && c != CRCCHR );
478 attempts = errors = sendfin = extrachr = 0;
481 * Loop over each sector to be sent
484 if ( extrachr >= 128 )
493 * Read a sectors worth of data from the file into
494 * an internal buffer.
496 for ( bufcntr = 0; bufcntr < bufsize; )
502 if ( ( n = read ( fd, &c, 1 ) ) == 0 )
507 buf[bufcntr++] = CTRLZ;
517 * Fill in xmodem protocol values. Block size and sector number
520 blockbuf[bbufcntr++] = (bufsize == 1024) ? STX : SOH;
521 blockbuf[bbufcntr++] = sectnum;
522 blockbuf[bbufcntr++] = ~sectnum;
527 * Loop over the internal buffer computing the checksum of the
530 for ( bufcntr = 0; bufcntr < bufsize; bufcntr++ )
532 blockbuf[bbufcntr++] = buf[bufcntr];
535 checksum = (checksum<<B) ^ crctab[(checksum>>(W-B)) ^ buf[bufcntr]];
537 checksum = ((checksum + buf[bufcntr]) & 0xff);
542 * Place the checksum at the end of the transmit buffer
547 blockbuf[bbufcntr++] = ((checksum >> 8) & 0xff);
548 blockbuf[bbufcntr++] = (checksum & 0xff);
550 blockbuf[bbufcntr++] = checksum;
555 * Make several attempts to send the data to the i960
560 * Transmit the sector + protocol to the i960
562 xmit_to_i960 ( blockbuf, bbufcntr, 1 );
565 * Inform user where we're at
568 printf ( "Sector %3d %3dk\r",
569 sectnum, (sectnum * bufsize) / 1024 );
573 * Get response from i960
575 sendresp = getbyte(0);
578 * If i960 didn't like the sector
580 if ( sendresp != ACK )
585 * Are we supposed to cancel the transfer?
587 if ( ( sendresp & 0x7f ) == CAN )
588 if ( getbyte(0) == CAN )
589 error ( "Send canceled at user's request" );
592 } while ( ( sendresp != ACK ) && ( attempts < RETRYMAX ) && ( errors < ERRORMAX ) );
599 } while ( !sendfin && ( attempts < RETRYMAX ) && ( errors < ERRORMAX ) );
602 * Did we expire all our allows attempts?
604 if ( attempts >= RETRYMAX )
606 xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 );
607 error ( "Remote system not responding" );
611 * Check for too many transmission errors
613 if ( errors >= ERRORMAX )
615 xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 ), xmit_byte ( CAN, 1 );
616 error ( "Too many errors in transmission" );
622 * Indicate the transfer is complete
624 xmit_byte ( EOT, 1 );
627 * Wait until i960 acknowledges us
629 while ( ( c = getbyte(0) ) != ACK && ( ++attempts < RETRYMAX ) )
630 xmit_byte ( EOT, 1 );
632 if ( attempts >= RETRYMAX )
633 error ( "Remote system not responding on completion" );
636 * After download, we'll see a few more command
637 * prompts as the CP does its stuff. Ignore them.
639 while ( strncmp ( line, "=>", 2 ) != 0 )
642 while ( strncmp ( line, "=>", 2 ) != 0 )
645 while ( strncmp ( line, "=>", 2 ) != 0 )
649 * Tell the i960 to start executing the downloaded code
651 xmit_to_i960 ( "go\r\n", 4, 0 );
654 * Get the messages the CP will spit out
655 * after the GO command.
667 loadmicrocode ( ucode, size, ram )
691 * Check that we understand this header
693 memcpy(&binhdr, ucode, sizeof(binhdr));
694 if ( strncmp ( (caddr_t)&binhdr.Id, "fore", 4 ) != 0 ) {
695 fprintf ( stderr, "Unrecognized format in micorcode file." );
701 * We always swap the SunOS microcode file...
706 * We need to swap the header start/entry words...
709 for ( n = 0; n < sizeof(u_long); n++ )
713 for ( n = 0; n < sizeof(u_long); n++ )
719 * Set pointer to RAM load location
721 bufp = (ram + binhdr.start);
729 lp = (u_long *) ucode;
731 for ( i = 0; i < size / sizeof(long); i++ )
733 lp[i] = CP_WRITE(lp[i]);
739 for ( j = 0; j < 4; j++ )
745 bcopy ( (caddr_t)ucode, bufp, size );
748 * With .bin extension, we need to specify start address on 'go'
754 sprintf ( cmd, "go %lx\r\n", binhdr.entry );
756 xmit_to_i960 ( cmd, strlen ( cmd ), 0 );
758 while ( strncmp ( line, cmd, strlen(cmd) - 3 ) != 0 )
768 sendbinfile ( fname, ram )
793 if ( ( fd = open ( fname, O_RDONLY ) ) < 0 )
797 * Read the .bin header from the file
799 if ( ( read ( fd, &binhdr, sizeof(binhdr) ) ) != sizeof(binhdr) )
806 * Check that we understand this header
808 if ( strncmp ( (caddr_t)&binhdr.Id, "fore", 4 ) != 0 ) {
809 fprintf ( stderr, "Unrecognized format in micorcode file." );
816 * We always swap the SunOS microcode file...
821 * We need to swap the header start/entry words...
824 for ( n = 0; n < sizeof(u_long); n++ )
828 for ( n = 0; n < sizeof(u_long); n++ )
839 * Set pointer to RAM load location
841 bufp = (ram + binhdr.start);
848 * Need to swap longs - copy file into temp buffer
850 while ( ( n = read ( fd, (char *)buffer, sizeof(buffer))) > 0 )
855 for ( i = 0; i < sizeof(buffer) / sizeof(long); i++ )
857 buffer[i] = CP_WRITE(buffer[i]);
863 for ( j = 0; j < 4; j++ )
870 * Copy swapped buffer into CP RAM
873 bcopy ( (caddr_t)buffer, bufp, n );
875 printf ( "%d\r", cnt );
879 while ( ( n = read ( fd, bufp, 128 ) ) > 0 )
883 printf ( "%d\r", cnt );
889 * With .bin extension, we need to specify start address on 'go'
895 sprintf ( cmd, "go %lx\r\n", binhdr.entry );
897 xmit_to_i960 ( cmd, strlen ( cmd ), 0 );
899 while ( strncmp ( line, cmd, strlen(cmd) - 3 ) != 0 )
912 * Program to download previously processed microcode to series-200 host adapter
919 int fd; /* mmap for Uart */
920 u_char *ram; /* pointer to RAM */
921 Mon960 *Mon; /* Uart */
925 int binary = 0; /* Send binary file */
926 caddr_t buf; /* Ioctl buffer */
927 char bus_dev[80]; /* Bus device to mmap on */
928 struct atminfreq req;
929 struct air_cfg_rsp *air; /* Config info response structure */
930 int buf_len; /* Size of ioctl buffer */
931 char *devname = "\0"; /* Device to download */
932 char *dirname = NULL; /* Directory path to objd files */
933 char *objfile = NULL; /* Command line object filename */
934 u_char *ucode = NULL; /* Pointer to microcode */
935 int ucode_size = 0; /* Length of microcode */
936 char *sndfile = NULL; /* Object filename to download */
937 char filename[64]; /* Constructed object filename */
938 char base[64]; /* sba200/sba200e/pca200e basename */
939 int ext = 0; /* 0 == bin 1 == objd */
940 struct stat sbuf; /* Used to find if .bin or .objd */
943 progname = (char *)basename(argv[0]);
944 comm_mode = strcmp ( progname, "fore_comm" ) == 0;
946 while ( ( c = getopt ( argc, argv, "i:d:f:berv" ) ) != -1 )
952 dirname = (char *)strdup ( optarg );
958 devname = (char *)strdup ( optarg );
961 objfile = (char *)strdup ( optarg );
970 printf ( "usage: %s [-v] [-i intf] [-d dirname] [-f objfile]\n", argv[0] );
977 setbuf ( stdout, NULL );
979 if ( ( fd = socket ( AF_ATM, SOCK_DGRAM, 0 ) ) < 0 )
981 perror ( "Cannot create ATM socket" );
985 * Over allocate memory for returned data. This allows
986 * space for IOCTL reply info as well as config info.
988 buf_len = 4 * sizeof(struct air_cfg_rsp);
989 if ( ( buf = (caddr_t)malloc(buf_len) ) == NULL )
991 perror ( "Cannot allocate memory for reply" );
995 * Fill in request paramaters
997 req.air_opcode = AIOCS_INF_CFG;
998 req.air_buf_addr = buf;
999 req.air_buf_len = buf_len;
1002 * Copy interface name into ioctl request
1004 strcpy ( req.air_cfg_intf, devname );
1009 if ( ( ioctl ( fd, AIOCINFO, (caddr_t)&req ) ) ) {
1010 perror ( "ioctl (AIOCSINFO)" );
1014 * Reset buffer pointer
1016 req.air_buf_addr = buf;
1024 * Loop through all attached adapters
1026 for (; req.air_buf_len >= sizeof(struct air_cfg_rsp);
1027 buf += sizeof(struct air_cfg_rsp),
1028 req.air_buf_len -= sizeof(struct air_cfg_rsp)) {
1031 * Point to vendor info
1033 air = (struct air_cfg_rsp *)buf;
1035 if (air->acp_vendor == VENDOR_FORE )
1041 sprintf ( bus_dev, DEV_NAME, air->acp_busslot );
1043 sprintf ( bus_dev, DEV_NAME );
1047 * Setup signal handlers
1049 signal ( SIGINT, SIG_IGN );
1050 signal ( SIGQUIT, SIG_IGN );
1053 * If comm_mode, setup terminal for single char I/O
1056 tty = open ( _PATH_TTY, O_RDWR );
1057 ioctl ( tty, TCGETA, &sgtty );
1058 sgtty.c_lflag &= ~( ICANON | ECHO );
1059 vmin = sgtty.c_cc[VMIN];
1060 vtime = sgtty.c_cc[VTIME];
1061 sgtty.c_cc[VMIN] = 0;
1062 sgtty.c_cc[VTIME] = 0;
1063 ioctl ( tty, TCSETA, &sgtty );
1067 * Open bus for memory access
1069 if ( ( fd = open ( bus_dev, O_RDWR ) ) < 0 )
1071 perror ( "open bus_dev" );
1072 fprintf(stderr, "%s download failed (%s)\n",
1073 air->acp_intf, bus_dev);
1078 * Map in the RAM memory to get access to the Uart
1080 #ifdef __FreeBSD__ /*XXX*/
1081 ram = (u_char *) mmap(0, PCA200E_MMAP_SIZE,
1083 ram = (u_char *) mmap(0, air->acp_ramsize,
1085 PROT_READ | PROT_WRITE, MAP_SHARED | MAP_HASSEMAPHORE,
1087 if (ram == (u_char *)-1) {
1088 perror ( "mmap ram" );
1089 fprintf(stderr, "%s download failed\n",
1094 Mon = (Mon960 *)(ram + MON960_BASE);
1095 Uart = (Mon960 *)&(Mon->mon_xmitmon);
1098 * Determine endianess
1100 switch ( Mon->mon_bstat ) {
1101 case BOOT_COLDSTART:
1108 switch (ntohl(Mon->mon_bstat)) {
1109 case BOOT_COLDSTART:
1117 fprintf(stderr, "%s unknown status\n",
1127 u_int *hcr = (u_int *)(ram + PCA200E_HCR_OFFSET);
1128 PCA200E_HCR_INIT(*hcr, PCA200E_RESET_BD);
1130 PCA200E_HCR_CLR(*hcr, PCA200E_RESET_BD);
1136 static struct timeval timeout = { 0, 0 };
1140 * We want to talk with the i960 monitor
1144 * Loop forever accepting characters
1151 * Check for data from the terminal
1154 FD_SET ( fileno(stdin), &fdr );
1156 if ( ( ns = select ( FD_SETSIZE, &fdr, NULL, NULL,
1157 &timeout ) ) < 0 ) {
1158 perror ( "select" );
1166 nr = read ( fileno(stdin), &c, 1 );
1177 xmit_byte ( 27, 0 );
1185 * Check for data from the i960
1187 if ( CP_READ(Uart->mon_xmithost) & UART_VALID ) {
1191 if ( strcmp ( line, "Mon960" ) == 0 )
1197 * Make sure the driver is loaded and that the CP
1198 * is ready for commands
1200 if ( CP_READ(Mon->mon_bstat) == BOOT_RUNNING )
1203 "%s is up and running - no download allowed.\n",
1209 if ( CP_READ(Mon->mon_bstat) != BOOT_MONREADY )
1212 "%s is not ready for downloading.\n",
1219 * Indicate who we're downloading
1222 printf ( "Downloading code for %s\n",
1226 * Look for the i960 monitor message.
1227 * We should see this after a board reset.
1229 while ( strncmp ( line, "Mon960", 6 ) != 0 &&
1230 strncmp ( line, "=>", 2 ) != 0 )
1231 getline( verbose ); /* Verbose */
1236 if ( strncmp ( line, "Mon960", 6 ) == 0 ) {
1237 xmit_to_i960 ( "\r\n\r\n\r\n\r\n", 8, 0 );
1242 * Keep reading until we get a command prompt
1244 while ( strncmp ( line, "=>", 2 ) != 0 )
1245 getline( verbose ); /* Verbose */
1248 * Choose the correct microcode file based on the
1249 * adapter type the card claims to be.
1251 switch ( air->acp_device )
1253 case DEV_FORE_SBA200:
1254 sprintf ( base, "sba200" );
1257 case DEV_FORE_SBA200E:
1258 sprintf ( base, "sba200e" );
1261 case DEV_FORE_PCA200E:
1262 sprintf ( base, "pca200e" );
1267 fprintf(stderr, "Unknown adapter type: %d\n",
1273 if ( objfile == NULL ) {
1274 switch ( air->acp_device ) {
1275 case DEV_FORE_SBA200:
1276 case DEV_FORE_SBA200E:
1277 sprintf ( filename, "%s.bin%d", base,
1279 if ( stat ( filename, &sbuf ) == -1 ) {
1280 sprintf ( filename, "%s/%s.bin%d",
1283 if ( stat ( filename, &sbuf ) == -1 ) {
1285 sprintf ( filename, "%s.objd%d",
1286 base, air->acp_bustype );
1287 if ( stat(filename, &sbuf) == -1 ) {
1289 "%s/%s.objd%d", dirname,
1292 if ( stat ( filename, &sbuf ) != -1 )
1301 case DEV_FORE_PCA200E:
1302 /* Use compiled in microcode */
1303 ucode = pca200e_microcode;
1304 ucode_size = pca200e_microcode_size;
1312 if ( ext && !binary )
1313 err = xmitfile ( sndfile );
1314 else if (sndfile != NULL)
1315 err = sendbinfile ( sndfile, ram );
1317 err = loadmicrocode( ucode, ucode_size, ram );
1320 fprintf(stderr, "%s download failed\n",
1327 * Download completed - wait around a while for
1328 * the driver to initialize the adapter
1330 aap = (Aali *)(ram + CP_READ(Mon->mon_appl));
1331 for (i = 0; i < MAX_CHECK; i++, sleep(1)) {
1332 u_long hb1, hb2, hb3;
1334 hb3 = CP_READ(Mon->mon_bstat);
1335 if (hb3 != BOOT_RUNNING) {
1337 printf("bstat %x\n", hb3);
1341 hb1 = CP_READ(aap->aali_heartbeat);
1343 hb2 = CP_READ(aap->aali_heartbeat);
1345 printf("hb %x %x\n", hb1, hb2);