+\r
+/**\r
+ A dedicated timer is used to poll underlying media status. In case of\r
+ cable swap, a new round auto configuration will be initiated. The timer \r
+ will signal the IP4 to run the auto configuration again. IP4 driver will free\r
+ old IP address related resource, such as route table and Interface, then\r
+ initiate a DHCP process by IP4Config->Start to acquire new IP, eventually\r
+ create route table for new IP address.\r
+\r
+ @param[in] Event The IP4 service instance's heart beat timer.\r
+ @param[in] Context The IP4 service instance.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MediaChangeDetect (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ BOOLEAN OldMediaPresent;\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;\r
+ IP4_CONFIG_INSTANCE *Instance; \r
+\r
+ Instance = (IP4_CONFIG_INSTANCE *) Context;\r
+\r
+ OldMediaPresent = Instance->MediaPresent;\r
+ \r
+ //\r
+ // Get fresh mode data from MNP, since underlying media status may change\r
+ //\r
+ Status = Instance->Mnp->GetModeData (Instance->Mnp, NULL, &SnpModeData);\r
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {\r
+ return;\r
+ }\r
+\r
+ Instance->MediaPresent = SnpModeData.MediaPresent;\r
+ //\r
+ // Media transimit Unpresent to Present means new link movement is detected.\r
+ //\r
+ if (!OldMediaPresent && Instance->MediaPresent) {\r
+ //\r
+ // Signal the IP4 to run the auto configuration again. IP4 driver will free\r
+ // old IP address related resource, such as route table and Interface, then \r
+ // initiate a DHCP round by IP4Config->Start to acquire new IP, eventually \r
+ // create route table for new IP address.\r
+ //\r
+ if (Instance->ReconfigEvent != NULL) {\r
+ Status = gBS->SignalEvent (Instance->ReconfigEvent);\r
+ DispatchDpc ();\r
+ }\r
+ }\r
+}\r