diff options
Diffstat (limited to 'MdeModulePkg/Universal/Network/MnpDxe')
-rw-r--r-- | MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c | 52 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c | 4 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h | 3 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h | 30 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c | 58 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c | 9 |
6 files changed, 132 insertions, 24 deletions
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c index af642a50d9..115185afe2 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c @@ -1,7 +1,7 @@ /** @file
Implementation of Managed Network Protocol private services.
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -356,6 +356,22 @@ MnpInitializeDeviceData ( }
//
+ // Create the timer for media detection.
+ //
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL | EVT_TIMER,
+ TPL_CALLBACK,
+ MnpCheckMediaStatus,
+ MnpDeviceData,
+ &MnpDeviceData->MediaDetectTimer
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "MnpInitializeDeviceData: CreateEvent for media detection failed.\n"));
+
+ goto ERROR;
+ }
+
+ //
// Create the timer for tx timeout check.
//
Status = gBS->CreateEvent (
@@ -382,6 +398,10 @@ ERROR: gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer);
}
+ if (MnpDeviceData->MediaDetectTimer != NULL) {
+ gBS->CloseEvent (MnpDeviceData->MediaDetectTimer);
+ }
+
if (MnpDeviceData->PollTimer != NULL) {
gBS->CloseEvent (MnpDeviceData->PollTimer);
}
@@ -443,9 +463,10 @@ MnpDestroyDeviceData ( //
// Close the event.
//
- gBS->CloseEvent (&MnpDeviceData->TxTimeoutEvent);
- gBS->CloseEvent (&MnpDeviceData->TimeoutCheckTimer);
- gBS->CloseEvent (&MnpDeviceData->PollTimer);
+ gBS->CloseEvent (MnpDeviceData->TxTimeoutEvent);
+ gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer);
+ gBS->CloseEvent (MnpDeviceData->MediaDetectTimer);
+ gBS->CloseEvent (MnpDeviceData->PollTimer);
//
// Free the tx buffer.
@@ -1010,6 +1031,24 @@ MnpStart ( goto ErrorExit;
}
+
+ //
+ // Start the media detection timer.
+ //
+ Status = gBS->SetTimer (
+ MnpDeviceData->MediaDetectTimer,
+ TimerPeriodic,
+ MNP_MEDIA_DETECT_INTERVAL
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG (
+ (EFI_D_ERROR,
+ "MnpStart, gBS->SetTimer for MediaDetectTimer %r.\n",
+ Status)
+ );
+
+ goto ErrorExit;
+ }
}
}
@@ -1096,6 +1135,11 @@ MnpStop ( Status = gBS->SetTimer (MnpDeviceData->TimeoutCheckTimer, TimerCancel, 0);
//
+ // Cancel the media detect timer.
+ //
+ Status = gBS->SetTimer (MnpDeviceData->MediaDetectTimer, TimerCancel, 0);
+
+ //
// Stop the simple network.
//
Status = MnpStopSnp (MnpDeviceData->Snp);
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c index e3abd48cf3..d2d5924c77 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c @@ -1,7 +1,7 @@ /** @file
Implementation of driver entry point and driver binding protocol.
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -336,7 +336,7 @@ MnpDriverBindingStop ( }
//
- // Destroy the Mnp device data
+ // Destroy Mnp Device Data
//
MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
FreePool (MnpDeviceData);
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h index e9698d2aac..d410af2726 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h @@ -1,7 +1,7 @@ /** @file
Declaration of strctures and functions for MnpDxe driver.
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -70,6 +70,7 @@ typedef struct { BOOLEAN EnableSystemPoll;
EFI_EVENT TimeoutCheckTimer;
+ EFI_EVENT MediaDetectTimer;
UINT32 UnicastCount;
UINT32 BroadcastCount;
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h b/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h index d35086221e..54a61c3961 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h @@ -1,7 +1,7 @@ /** @file
Declaration of structures and functions of MnpDxe driver.
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds
#define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds
+#define MNP_MEDIA_DETECT_INTERVAL (500 * TICKS_PER_MS) // 500 milliseconds
#define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds
#define MNP_INIT_NET_BUFFER_NUM 512
#define MNP_NET_BUFFER_INCREASEMENT 64
@@ -448,9 +449,8 @@ MnpFreeNbuf ( /**
Remove the received packets if timeout occurs.
- @param[in] Event The event this notify function registered to.
- @param[in] Context Pointer to the context data registered to the
- event.
+ @param[in] Event The event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the event.
**/
VOID
@@ -461,18 +461,32 @@ MnpCheckPacketTimeout ( );
/**
+ Poll to update MediaPresent field in SNP ModeData by Snp.GetStatus().
+
+ @param[in] Event The event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the event.
+
+**/
+VOID
+EFIAPI
+MnpCheckMediaStatus (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+/**
Poll to receive the packets from Snp. This function is either called by upperlayer
protocols/applications or the system poll timer notify mechanism.
- @param[in] Event The event this notify function registered to.
- @param[in, out] Context Pointer to the context data registered to the event.
+ @param[in] Event The event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the event.
**/
VOID
EFIAPI
MnpSystemPoll (
- IN EFI_EVENT Event,
- IN OUT VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c index 65268a8d74..32cffd5730 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c @@ -1,7 +1,7 @@ /** @file
Implementation of Managed Network Protocol I/O functions.
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -211,6 +211,18 @@ MnpSyncSendPacket ( HeaderSize = Snp->Mode->MediaHeaderSize - TxData->HeaderLength;
//
+ // Check media status before transmit packet.
+ // Note: media status will be updated by periodic timer MediaDetectTimer.
+ //
+ if (!Snp->Mode->MediaPresent) {
+ //
+ // Media not present, skip packet transmit and report EFI_NO_MEDIA
+ //
+ Status = EFI_NO_MEDIA;
+ goto SIGNAL_TOKEN;
+ }
+
+ //
// Start the timeout event.
//
Status = gBS->SetTimer (
@@ -998,9 +1010,8 @@ EXIT: /**
Remove the received packets if timeout occurs.
- @param[in] Event The event this notify function registered to.
- @param[in] Context Pointer to the context data registered to the
- event.
+ @param[in] Event The event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the event.
**/
VOID
@@ -1066,18 +1077,49 @@ MnpCheckPacketTimeout ( }
/**
+ Poll to update MediaPresent field in SNP ModeData by Snp->GetStatus().
+
+ @param[in] Event The event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the event.
+
+**/
+VOID
+EFIAPI
+MnpCheckMediaStatus (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ MNP_DEVICE_DATA *MnpDeviceData;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ UINT32 InterruptStatus;
+
+ MnpDeviceData = (MNP_DEVICE_DATA *) Context;
+ NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
+
+ Snp = MnpDeviceData->Snp;
+ if (Snp->Mode->MediaPresentSupported) {
+ //
+ // Upon successful return of GetStatus(), the MediaPresent field of
+ // EFI_SIMPLE_NETWORK_MODE will be updated to reflect any change of media status
+ //
+ Snp->GetStatus (Snp, &InterruptStatus, NULL);
+ }
+}
+
+/**
Poll to receive the packets from Snp. This function is either called by upperlayer
protocols/applications or the system poll timer notify mechanism.
- @param[in] Event The event this notify function registered to.
- @param[in, out] Context Pointer to the context data registered to the event.
+ @param[in] Event The event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the event.
**/
VOID
EFIAPI
MnpSystemPoll (
- IN EFI_EVENT Event,
- IN OUT VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
MNP_DEVICE_DATA *MnpDeviceData;
diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c index e34936f3b8..1f7b1e6bf0 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c @@ -1,7 +1,7 @@ /** @file
Implementation of Managed Network Protocol public services.
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full
@@ -52,6 +52,7 @@ MnpGetModeData ( EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
+ UINT32 InterruptStatus;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -73,6 +74,12 @@ MnpGetModeData ( // Copy the underlayer Snp mode data.
//
Snp = Instance->MnpServiceData->MnpDeviceData->Snp;
+
+ //
+ // Upon successful return of GetStatus(), the Snp->Mode->MediaPresent
+ // will be updated to reflect any change of media status
+ //
+ Snp->GetStatus (Snp, &InterruptStatus, NULL);
CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData));
}
|