Index: c/src/lib/libbsp/i386/i386ex/network/network.c
===================================================================
--- c/src/lib/libbsp/i386/i386ex/network/network.c	(revision 73f6236bc09b3cadf0aa030e16396154421f3e30)
+++ c/src/lib/libbsp/i386/i386ex/network/network.c	(revision 9d813800b3b582853de841479b6c1f96818b2071)
@@ -5,4 +5,5 @@
 
 void dump_scb(void);
+void printk_time(void);
 
 #ifdef DBG_VERSION
@@ -35,8 +36,5 @@
 void dumpQ(void);
 
-#define UTI_596_ASSERT( condition, str )
-/*
- * {  if (!( condition ) ) printf(str); }
- */
+#define UTI_596_ASSERT( condition, str ) { if (!( condition ) ) printk(str); }
 int count_rx = 0;
 
@@ -107,5 +105,4 @@
 #define RBUF_SIZE	1520
 
-#define UTI_596_RFD_NUMBER 4
 
 /*
@@ -260,5 +257,5 @@
     
     uti596_softc.pEndRFA -> next = I596_NULL;
-    UTI_596_ASSERT(uti596_softc.countRFD == UTI_596_RFD_NUMBER,"INIT:WRONG RFD COUNT\n" ); 
+    UTI_596_ASSERT(uti596_softc.countRFD == RX_BUF_COUNT,"INIT:WRONG RFD COUNT\n" ); 
     
 #ifdef DBG_596_RFA
@@ -523,4 +520,8 @@
 {
   int boguscnt = 1000;
+  rtems_status_code status_code;
+  struct i596_cmd *pCmd;
+ 
+  pCmd = sc->pCmdHead;  /* This is a tx command for sure (99.99999%)  */
   
   /* reset the board  */
@@ -566,4 +567,16 @@
   
   sc->pCmdHead     = sc->scb.pCmd = I596_NULL;
+  /*
+   * Wake the transmitter if needed. 
+   */
+  if ( uti596_softc.txDaemonTid && pCmd != I596_NULL ){  
+    printf("****RESET: wakes transmitter!\n");
+    status_code = rtems_event_send (uti596_softc.txDaemonTid, 
+			   INTERRUPT_EVENT);
+    
+    if ( status_code != RTEMS_SUCCESSFUL )
+      printk("****ERROR:Could NOT send event to tid 0x%x : %s\n",
+	     uti596_softc.txDaemonTid, rtems_status_text (status_code) );
+  }
   
 #ifdef DBG_596
@@ -964,8 +977,11 @@
 
   /* abort ALL of the current work */
-  sc->scb.command = CUC_ABORT | RX_ABORT;
-
-  outport_word(CHAN_ATTN,0);
-  UTI_WAIT_COMMAND_ACCEPTED(4000, "reset: abort requested");
+    /* FEB 17 REMOVED 
+    >>>>>
+    sc->scb.command = CUC_ABORT | RX_ABORT;
+    outport_word(CHAN_ATTN,0);
+    UTI_WAIT_COMMAND_ACCEPTED(4000, "reset: abort requested");
+    <<<<< 
+    */
 
   uti596_reset_hardware(&uti596_softc); /* reset the ethernet hardware. must re-config */
@@ -1015,5 +1031,7 @@
     printf("Reset Set Address Failed\n");
   /*******/
-  
+
+  sc->pCmdHead = sc->pCmdTail = sc->scb.pCmd = I596_NULL; /* Feb 17. clear these out */
+
 #ifdef DBG_RESET
   printf( "After reset, status and command: 0x%x, 0x%x\n", 
@@ -1025,5 +1043,5 @@
   /* restore the RFA */
 
-  dumpQ();
+  /*dumpQ();*/
 
   if ( sc->pLastUnkRFD != I596_NULL ) {
@@ -1053,16 +1071,16 @@
   uti596clearListStatus(sc->pBeginRFA );
 
-  dumpQ(); /* purely for testing */
-
-  sc->irqInfo.on(&sc->irqInfo);  /* moved here. Was originally after command issued. */
+  /*  dumpQ();*/
+
+  printf("Reset:Starting NIC\n");
   sc->scb.command = RX_START;
-
+  sc->started = 1;               /* we assume that the start works */
+  sc->resetDone = 1;             /* moved here from after channel attn. */
   outport_word(CHAN_ATTN,0 ); 
   UTI_WAIT_COMMAND_ACCEPTED(4000, "reset");
+  printf("Reset:Start complete \n");
+  UTI_596_ASSERT(sc->pCmdHead == I596_NULL, "Reset: CMD not cleared\n");
+  sc->irqInfo.on(&sc->irqInfo);  /* moved back here. Tried it before RX command issued. */
     
-  sc->resetDone = 1;
-  
-  sc->started = 1;
-
   /* uti596addCmd(&uti506_softc.nop); */ /* just for fun */
   
@@ -1230,14 +1248,10 @@
      uti596_softc.pCmdHead = uti596_softc.pCmdTail = uti596_softc.scb.pCmd = pCmd;
 
-     UTI_WAIT_COMMAND_ACCEPTED(10000,"Add Polled command: wait prev"); /* ensure prev command complete */
+     UTI_WAIT_COMMAND_ACCEPTED(10000,"Add Polled command: wait prev");
 
      uti596_softc.scb.command = CUC_START;
      outport_word (CHAN_ATTN,0);
 
-     UTI_WAIT_COMMAND_ACCEPTED(2000000,"Add Polled command: start"); /* ensure previous command complete */
-     /*     if ( !(pCmd -> status & STAT_C ) ){
-	    printf("****FAILED poll command\n"); 
-	    }
-	    */
+     UTI_WAIT_COMMAND_ACCEPTED(2000000,"Add Polled command: start"); 
      uti596_softc.pCmdHead = uti596_softc.pCmdTail = uti596_softc.scb.pCmd = I596_NULL;
 
@@ -1269,16 +1283,20 @@
 	  
 	  /*
-	   * Send packets till queue is empty
+	   * Send packets till queue is empty.
+	   * Ensure that irq is on before sending.
 	   */
 	  for (;;) { 
-	    /*
-	     * Get the next mbuf chain to transmit.
-	     */
-	    IF_DEQUEUE(&ifp->if_snd, m);
-	    if (!m)
-	      break;
-	    
-	    send_packet (ifp, m); /* blocks */
-	  }  
+	      /* Feb 17: No need to make sure a reset is in progress,
+	       *         Since reset daemon runs at same priority as this thread
+	       */
+	      /*
+	       * Get the next mbuf chain to transmit.
+	       */
+	      IF_DEQUEUE(&ifp->if_snd, m);
+	      if (!m)
+		break;
+	      
+	      send_packet (ifp, m); /* blocks */
+	  } /* end for */
 	  ifp->if_flags &= ~IFF_OACTIVE; /* no more to send, mark output inactive  */
 	}
@@ -1295,4 +1313,6 @@
         struct uti596_softc *sc = (struct uti596_softc *)arg;
 	rtems_event_set events;
+	rtems_time_of_day tm_struct;
+
 	/* struct ifnet *ifp = &sc->arpcom.ac_if; */
 
@@ -1305,5 +1325,7 @@
 				      RTEMS_NO_TIMEOUT, &events);
 
-	  printf("reset daemon: Resetting NIC\n");
+	  rtems_clock_get(RTEMS_CLOCK_GET_TOD, &tm_struct);
+	  printf("reset daemon: Resetting NIC @ %d:%d:%d \n",
+		 tm_struct.hour, tm_struct.minute, tm_struct.second);
 
 	  sc->stats.nic_reset_count++;
@@ -1912,4 +1934,10 @@
  UTI_WAIT_COMMAND_ACCEPTED(20000, "****ERROR:on ISR entry");
 
+ if ( !(i8259s_cache & 0x20 )) {
+   printk("****Error: network ISR running, no IRR!\n");
+   printk("****Error: i8259s_cache = 0x%x\n",i8259s_cache );
+   printk_time();
+ }
+
  scbStatus = uti596_softc.scb.status & 0xf000;
 
@@ -1925,5 +1953,5 @@
    }
    else {
-     printk("\n***INFO:ISR won't process now\n");
+     printk("***INFO: ACK'd w/o processing. status = %x\n", scbStatus);
      return;
    }
@@ -1935,4 +1963,5 @@
   
  if ( (scbStatus & SCB_STAT_CX) && !(scbStatus & SCB_STAT_CNA) ){
+   printk_time();
    printk("\n*****ERROR: Command Complete, and CNA available: 0x%x\nResetting...", scbStatus);
    uti596_softc.nic_reset = 1;
@@ -1941,4 +1970,5 @@
 
  if ( !(scbStatus & SCB_STAT_CX) && (scbStatus & SCB_STAT_CNA) ) {
+   printk_time();
    printk("\n*****ERROR: CNA, NO CX:0x%x\nResetting...",scbStatus);
    uti596_softc.nic_reset = 1;
@@ -1947,4 +1977,5 @@
 
  if ( scbStatus & SCB_CUS_SUSPENDED ) {
+   printk_time();
    printk("\n*****ERROR: Command unit suspended!:0x%x\nResetting...",scbStatus);
    uti596_softc.nic_reset = 1;
@@ -1953,4 +1984,5 @@
 
  if ( scbStatus & RU_SUSPENDED  ) {
+   printk_time();
    printk("\n*****ERROR: Receive unit suspended!:0x%x\nResetting...",scbStatus);
    uti596_softc.nic_reset = 1;
@@ -1959,5 +1991,9 @@
  
  if ( scbStatus & SCB_STAT_RNR ) {
+   printk_time();
    printk("\n*****WARNING: RNR %x\n",scbStatus);
+   printk("*****INFO: RFD cmd: %x status:%x\n",
+	  uti596_softc.pBeginRFA -> cmd,
+	  uti596_softc.pBeginRFA -> stat);
  }
  
@@ -2030,5 +2066,4 @@
      if ( uti596_softc.countRFD != 0 ) {
        printk("****ERROR:Count is %d, but begin ptr is NULL\n",uti596_softc.countRFD );
-       dumpQ();
      }
    }
@@ -2056,5 +2091,5 @@
      
      /* 
-      * Adjust the drivers command block list 
+      * Adjust the command block list 
       */
      uti596_softc.pCmdHead = pIsrCmd -> next;
@@ -2109,5 +2144,5 @@
 	   printk("wake TX:0x%x\n",uti596_softc.txDaemonTid);
 #endif
-	   if ( uti596_softc.txDaemonTid ){  /* Ensure that the transmitter is waiting */
+	   if ( uti596_softc.txDaemonTid ){  /* Ensure that the transmitter is present */
 	     sc = rtems_event_send (uti596_softc.txDaemonTid, 
 				    INTERRUPT_EVENT);
@@ -2167,20 +2202,21 @@
    } /* end if pIsrCmd != NULL && pIsrCmd->stat & STAT_C  */
    else {
-
-     /* Reset the ethernet card, and wake the transmitter (if necessary) */
-
-     printk("****INFO: Resetting board ( tx )\n");
-     uti596_softc.nic_reset = 1;
-     if ( uti596_softc.txDaemonTid){  /* Ensure that a transmitter is waiting */
-       /*  printk("*****INFO:Wake Transmitter\n"); */
-       sc = rtems_event_send (uti596_softc.txDaemonTid, 
-			      INTERRUPT_EVENT);
+     if ( pIsrCmd != I596_NULL ) { /* The command MAY be NULL from a RESET */
        
-       if ( sc != RTEMS_SUCCESSFUL )
-	 printk("****ERROR:Could NOT send event to tid 0x%x : %s\n",uti596_softc.txDaemonTid, rtems_status_text (sc) );
+       /* Reset the ethernet card, and wake the transmitter (if necessary) */
+       printk_time();
+       printk("****INFO: Request board reset ( tx )\n");
+       uti596_softc.nic_reset = 1;
+       if ( uti596_softc.txDaemonTid){  /* Ensure that a transmitter is present */
+	 sc = rtems_event_send (uti596_softc.txDaemonTid, 
+				INTERRUPT_EVENT);
+	 
+	 if ( sc != RTEMS_SUCCESSFUL )
+	   printk("****ERROR:Could NOT send event to tid 0x%x : %s\n",uti596_softc.txDaemonTid, rtems_status_text (sc) );
 #ifdef DBG_RAW_ISR
-       else
-	 printk("****INFO:Tx wake: %#x\n",uti596_softc.txDaemonTid);
+	 else
+	   printk("****INFO:Tx wake: %#x\n",uti596_softc.txDaemonTid);
 #endif	   
+       }
      }
    } 
@@ -2215,5 +2251,4 @@
 	       printk("***ERROR:UNK: %p not end->next: %p, end: %p\n",
 		      uti596_softc.pLastUnkRFD,uti596_softc.pEndRFA -> next,uti596_softc.pEndRFA);
-	       dumpQ();
 	       printk("***INFO:countRFD now %d\n",	 uti596_softc.countRFD);
 	       printk("\n\n");
@@ -2235,5 +2270,4 @@
 	   if ( uti596_softc.countRFD != 0 ) {
 	     printk("****INFO:About to set begin to NULL, with count == %d\n", uti596_softc.countRFD );
-	     dumpQ();
 	     printk("\n\n");
 	   }
@@ -2258,5 +2292,4 @@
 	 if(uti596_softc.countRFD != 0) {
 	   printk("****ERROR:Begin pointer is NULL, but count == %d\n",uti596_softc.countRFD);
-	   dumpQ();
 	 }
 #endif
@@ -2269,5 +2302,4 @@
 	 if ( uti596_softc.countRFD <= 0) {
 	   printk("****ERROR:Begin pointer is not NULL, but count == %d\n",uti596_softc.countRFD);
-	   dumpQ();
 	 }
 #endif
@@ -2295,7 +2327,13 @@
 #endif
      
-     if ( uti596_softc.countRFD > 1 &&                              /* there is at least TWO */
-	  !( uti596_softc.pBeginRFA -> stat & (STAT_C | STAT_B ))) { /* restart when not in use !! */
-       
+     if ( uti596_softc.countRFD > 1) {
+       /****REMOVED FEB 18.
+	 &&            
+	  !( uti596_softc.pBeginRFA -> stat & (STAT_C | STAT_B ))) { 
+       *****/
+       printk_time();
+       printk("****INFO: pBeginRFA -> stat = 0x%x\n",uti596_softc.pBeginRFA -> stat);
+       printk("****INFO: pBeginRFA -> cmd = 0x%x\n",uti596_softc.pBeginRFA -> cmd);
+       uti596_softc.pBeginRFA -> stat = 0;
        UTI_596_ASSERT(uti596_softc.scb.command == 0, "****ERROR:scb command must be zero\n");
        uti596_softc.scb.pRfd = uti596_softc.pBeginRFA;
@@ -2305,5 +2343,6 @@
        outport_word(CHAN_ATTN, 0);
     }
-     else {
+     /*****REMOVED FEB 18.
+       else {
        printk("****WARNING: Receiver NOT Started -- countRFD = %d\n", uti596_softc.countRFD);
        printk("82596 cmd: 0x%x, status: 0x%x RFA len: %d\n",
@@ -2316,5 +2355,5 @@
 	     pISR_Rfd != I596_NULL;
 	     pISR_Rfd = pISR_Rfd->next) 
-	 printk("Frame @ %p, status: %2.2x, cmd: %2.2x\n",
+	 printk("Frame @ %x, status: %x, cmd: %x\n",
 		pISR_Rfd, pISR_Rfd->stat, pISR_Rfd->cmd);
        
@@ -2323,5 +2362,5 @@
 	     pISR_Rfd != I596_NULL;
 	     pISR_Rfd = pISR_Rfd->next) 
-	 printk("Frame @ %p, status: %2.2x, cmd: %2.2x\n",
+	 printk("Frame @ %x, status: %x, cmd: %x\n",
 		pISR_Rfd, pISR_Rfd->stat, pISR_Rfd->cmd);
        
@@ -2331,12 +2370,13 @@
 	     pISR_Rfd != I596_NULL;
 	     pISR_Rfd = pISR_Rfd->next) 
-	 printk("Frame @ %p, status: %2.2x, cmd: %2.2x\n",
+	 printk("Frame @ %x, status: %x, cmd: %x\n",
 		pISR_Rfd, pISR_Rfd->stat, pISR_Rfd->cmd);
        printk("\nUnknown: %p\n",uti596_softc.pLastUnkRFD);
      }
+     *****/
    } /* end stat_rnr */	 
 
  } /* end if receiver started */
- UTI_596_ASSERT(uti596_softc.scb.status == scbStatus, "****WARNING:scbStatus change!\n");
+ /* UTI_596_ASSERT(uti596_softc.scb.status == scbStatus, "****WARNING:scbStatus change!\n"); */
  
 #ifdef DBG_ISR
@@ -2704,5 +2744,5 @@
   
 }
-void dump_scb(){
+void dump_scb(void){
   printk("status 0x%x\n",uti596_softc.scb.status);
   printk("command 0x%x\n",uti596_softc.scb.command);
@@ -2719,2 +2759,8 @@
 }
 
+void printk_time(void){
+    rtems_time_of_day tm_struct;
+
+    rtems_clock_get(RTEMS_CLOCK_GET_TOD, &tm_struct);
+    printk("Current time: %d:%d:%d \n", tm_struct.hour, tm_struct.minute, tm_struct.second);  
+}
