1. Add DPC protocol and DpcLib library in MdeModulePkg.
2. Add DpcDxe module and DxeDpcLib module in MdeModulePkg 3. Port network stack module to use DPC. 4. Use MIN, and MAX defined in MdePkg to replace NET_MIN and NET_MAX. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4307 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -192,7 +192,7 @@ Udp4CreateService (
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_TIMER | EVT_NOTIFY_SIGNAL,
|
||||
NET_TPL_FAST_TIMER,
|
||||
NET_TPL_TIMER,
|
||||
Udp4CheckTimeout,
|
||||
Udp4Service,
|
||||
&Udp4Service->TimeoutEvent
|
||||
@@ -618,8 +618,8 @@ Udp4BuildIp4ConfigData (
|
||||
Ip4ConfigData->AcceptBroadcast = Udp4ConfigData->AcceptBroadcast;
|
||||
Ip4ConfigData->AcceptPromiscuous = Udp4ConfigData->AcceptPromiscuous;
|
||||
Ip4ConfigData->UseDefaultAddress = Udp4ConfigData->UseDefaultAddress;
|
||||
Ip4ConfigData->StationAddress = Udp4ConfigData->StationAddress;
|
||||
Ip4ConfigData->SubnetMask = Udp4ConfigData->SubnetMask;
|
||||
CopyMem (&Ip4ConfigData->StationAddress, &Udp4ConfigData->StationAddress, sizeof (EFI_IPv4_ADDRESS));
|
||||
CopyMem (&Ip4ConfigData->SubnetMask, &Udp4ConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS));
|
||||
|
||||
//
|
||||
// use the -1 magic number to disable the receiving process of the ip instance.
|
||||
@@ -891,6 +891,7 @@ Udp4DgramSent (
|
||||
//
|
||||
Token->Status = Status;
|
||||
gBS->SignalEvent (Token->Event);
|
||||
NetLibDispatchDpc ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,6 +936,12 @@ Udp4DgramRcvd (
|
||||
//
|
||||
Udp4IcmpHandler ((UDP4_SERVICE_DATA *) Context, IcmpError, NetSession, Packet);
|
||||
}
|
||||
|
||||
//
|
||||
// Dispatch the DPC queued by the NotifyFunction of the rx token's events
|
||||
// which are signaled with received data.
|
||||
//
|
||||
NetLibDispatchDpc ();
|
||||
}
|
||||
|
||||
|
||||
@@ -1033,11 +1040,10 @@ Udp4CancelTokens (
|
||||
// The token is a receive token. Abort it and remove it from the Map.
|
||||
//
|
||||
TokenToCancel = (EFI_UDP4_COMPLETION_TOKEN *) Item->Key;
|
||||
NetMapRemoveItem (Map, Item, NULL);
|
||||
|
||||
TokenToCancel->Status = EFI_ABORTED;
|
||||
gBS->SignalEvent (TokenToCancel->Event);
|
||||
|
||||
NetMapRemoveItem (Map, Item, NULL);
|
||||
}
|
||||
|
||||
if (Arg != NULL) {
|
||||
@@ -1057,28 +1063,23 @@ Udp4CancelTokens (
|
||||
|
||||
**/
|
||||
VOID
|
||||
Udp4FlushRxData (
|
||||
IN NET_LIST_ENTRY *RcvdDgramQue
|
||||
Udp4FlushRcvdDgram (
|
||||
IN UDP4_INSTANCE_DATA *Instance
|
||||
)
|
||||
{
|
||||
UDP4_RXDATA_WRAP *Wrap;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_RECYCLE);
|
||||
|
||||
while (!NetListIsEmpty (RcvdDgramQue)) {
|
||||
while (!NetListIsEmpty (&Instance->RcvdDgramQue)) {
|
||||
//
|
||||
// Iterate all the Wraps in the RcvdDgramQue.
|
||||
//
|
||||
Wrap = NET_LIST_HEAD (RcvdDgramQue, UDP4_RXDATA_WRAP, Link);
|
||||
Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link);
|
||||
|
||||
//
|
||||
// The Wrap will be removed from the RcvdDgramQue by this function call.
|
||||
//
|
||||
Udp4RecycleRxDataWrap (NULL, (VOID *) Wrap);
|
||||
}
|
||||
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
}
|
||||
|
||||
|
||||
@@ -1383,6 +1384,7 @@ Udp4InstanceDeliverDgram (
|
||||
EFI_UDP4_COMPLETION_TOKEN *Token;
|
||||
NET_BUF *Dup;
|
||||
EFI_UDP4_RECEIVE_DATA *RxData;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if (!NetListIsEmpty (&Instance->RcvdDgramQue) &&
|
||||
!NetMapIsEmpty (&Instance->RxTokens)) {
|
||||
@@ -1401,7 +1403,7 @@ Udp4InstanceDeliverDgram (
|
||||
NetbufFree (Wrap->Packet);
|
||||
|
||||
Wrap->Packet = Dup;
|
||||
}
|
||||
}
|
||||
|
||||
NetListRemoveHead (&Instance->RcvdDgramQue);
|
||||
|
||||
@@ -1422,9 +1424,11 @@ Udp4InstanceDeliverDgram (
|
||||
Token->Status = EFI_SUCCESS;
|
||||
Token->Packet.RxData = &Wrap->RxData;
|
||||
|
||||
gBS->SignalEvent (Token->Event);
|
||||
|
||||
OldTpl = NET_RAISE_TPL (NET_TPL_RECYCLE);
|
||||
NetListInsertTail (&Instance->DeliveredDgramQue, &Wrap->Link);
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
gBS->SignalEvent (Token->Event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -261,8 +261,8 @@ Udp4LeaveGroup (
|
||||
);
|
||||
|
||||
VOID
|
||||
Udp4FlushRxData (
|
||||
IN NET_LIST_ENTRY *RcvdDgramQue
|
||||
Udp4FlushRcvdDgram (
|
||||
IN UDP4_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
|
@@ -180,7 +180,7 @@ Udp4Configure (
|
||||
StationAddress = NTOHL (StationAddress);
|
||||
SubnetMask = NTOHL (SubnetMask);
|
||||
RemoteAddress = NTOHL (RemoteAddress);
|
||||
|
||||
|
||||
|
||||
if (!UdpConfigData->UseDefaultAddress &&
|
||||
(!IP4_IS_VALID_NETMASK (SubnetMask) ||
|
||||
@@ -284,12 +284,14 @@ Udp4Configure (
|
||||
//
|
||||
// Cancel all the user tokens.
|
||||
//
|
||||
Udp4InstanceCancelToken (Instance, NULL);
|
||||
Instance->Udp4Proto.Cancel (&Instance->Udp4Proto, NULL);
|
||||
|
||||
//
|
||||
// Remove the buffered RxData for this instance.
|
||||
//
|
||||
Udp4FlushRxData (&Instance->RcvdDgramQue);
|
||||
Udp4FlushRcvdDgram (Instance);
|
||||
|
||||
////bugbug ASSERT (NetListIsEmpty (&Instance->DeliveredDgramQue));
|
||||
}
|
||||
|
||||
Udp4SetVariableData (Instance->Udp4Service);
|
||||
@@ -772,7 +774,8 @@ Udp4Receive (
|
||||
//
|
||||
Status = NetMapInsertTail (&Instance->RxTokens, Token, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_READY;
|
||||
Status = EFI_NOT_READY;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -785,6 +788,11 @@ Udp4Receive (
|
||||
//
|
||||
Udp4InstanceDeliverDgram (Instance);
|
||||
|
||||
//
|
||||
// Dispatch the DPC queued by the NotifyFunction of Token->Event.
|
||||
//
|
||||
NetLibDispatchDpc ();
|
||||
|
||||
ON_EXIT:
|
||||
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
@@ -847,6 +855,11 @@ Udp4Cancel (
|
||||
//
|
||||
Status = Udp4InstanceCancelToken (Instance, Token);
|
||||
|
||||
//
|
||||
// Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
|
||||
//
|
||||
NetLibDispatchDpc ();
|
||||
|
||||
NET_RESTORE_TPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
|
Reference in New Issue
Block a user