Sync to trunk head (r42241)
[reactos.git] / reactos / drivers / network / dd / pcnet / pcnet.c
index ee8a0f7..a89d45e 100644 (file)
@@ -607,12 +607,18 @@ MiSyncMediaDetection(
 {
   PADAPTER Adapter = (PADAPTER)SynchronizeContext;
   NDIS_MEDIA_STATE MediaState = MiGetMediaState(Adapter);
 {
   PADAPTER Adapter = (PADAPTER)SynchronizeContext;
   NDIS_MEDIA_STATE MediaState = MiGetMediaState(Adapter);
+  UINT MediaSpeed = MiGetMediaSpeed(Adapter);
+  BOOLEAN FullDuplex = MiGetMediaDuplex(Adapter);
 
   DPRINT("Called\n");
   DPRINT("MediaState: %d\n", MediaState);
 
   DPRINT("Called\n");
   DPRINT("MediaState: %d\n", MediaState);
-  if (MediaState != Adapter->MediaState)
+  if (MediaState != Adapter->MediaState ||
+      MediaSpeed != Adapter->MediaSpeed ||
+      FullDuplex != Adapter->FullDuplex)
     {
       Adapter->MediaState = MediaState;
     {
       Adapter->MediaState = MediaState;
+      Adapter->MediaSpeed = MediaSpeed;
+      Adapter->FullDuplex = FullDuplex;
       return TRUE;
     }
   return FALSE;
       return TRUE;
     }
   return FALSE;
@@ -721,10 +727,29 @@ MiInitChip(
   NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR0);
   NdisRawWritePortUshort(Adapter->PortOffset + RDP, CSR0_STRT|CSR0_INIT|CSR0_IENA);
 
   NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR0);
   NdisRawWritePortUshort(Adapter->PortOffset + RDP, CSR0_STRT|CSR0_INIT|CSR0_IENA);
 
-  /* detect the media state */
+  /* Allow LED programming */
+  NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR2);
+  NdisRawWritePortUshort(Adapter->PortOffset + BDP, BCR2_LEDPE);
+
+  /* LED0 is configured for link status (on = up, off = down) */
   NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR4);
   NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR4);
-  NdisRawWritePortUshort(Adapter->PortOffset + BDP, BCR4_LNKSTE|BCR4_FDLSE);
+  NdisRawWritePortUshort(Adapter->PortOffset + BDP, BCR4_LNKSTE | BCR4_PSE);
+
+  /* LED1 is configured for link duplex (on = full, off = half) */
+  NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR5);
+  NdisRawWritePortUshort(Adapter->PortOffset + BDP, BCR5_FDLSE | BCR5_PSE);
+
+  /* LED2 is configured for link speed (on = 100M, off = 10M) */
+  NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR6);
+  NdisRawWritePortUshort(Adapter->PortOffset + BDP, BCR6_E100 | BCR6_PSE);
+
+  /* LED3 is configured for trasmit/receive activity */
+  NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR7);
+  NdisRawWritePortUshort(Adapter->PortOffset + BDP, BCR7_XMTE | BCR7_RCVE | BCR7_PSE);
+
   Adapter->MediaState = MiGetMediaState(Adapter);
   Adapter->MediaState = MiGetMediaState(Adapter);
+  Adapter->FullDuplex = MiGetMediaDuplex(Adapter);
+  Adapter->MediaSpeed = MiGetMediaSpeed(Adapter);
 
   DPRINT("card started\n");
 
 
   DPRINT("card started\n");
 
@@ -1240,6 +1265,30 @@ MiSetMulticast(
   return NDIS_STATUS_SUCCESS;
 }
 
   return NDIS_STATUS_SUCCESS;
 }
 
+BOOLEAN
+NTAPI
+MiGetMediaDuplex(PADAPTER Adapter)
+{
+  ULONG Data;
+
+  NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR5);
+  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
+
+  return Data & BCR5_LEDOUT;
+}
+
+UINT
+NTAPI
+MiGetMediaSpeed(PADAPTER Adapter)
+{
+  ULONG Data;
+
+  NdisRawWritePortUshort(Adapter->PortOffset + RAP, BCR4);
+  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
+
+  return Data & BCR6_LEDOUT ? 100 : 10;
+}
+
 NDIS_MEDIA_STATE
 NTAPI
 MiGetMediaState(PADAPTER Adapter)
 NDIS_MEDIA_STATE
 NTAPI
 MiGetMediaState(PADAPTER Adapter)