]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/DxeDpcLib/DpcLib.c
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Library / DxeDpcLib / DpcLib.c
1 /** @file
2 Help functions to access UDP service.
3
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 **/
7
8 #include <Uefi.h>
9 #include <Library/DebugLib.h>
10 #include <Library/UefiBootServicesTableLib.h>
11 #include <Protocol/Dpc.h>
12
13 //
14 // Pointer to the DPC Protocol
15 //
16 EFI_DPC_PROTOCOL *mDpc;
17
18 /**
19 This constructor function caches the EFI_DPC_PROTOCOL pointer.
20
21 @param[in] ImageHandle The firmware allocated handle for the EFI image.
22 @param[in] SystemTable A pointer to the EFI System Table.
23
24 @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.
25
26 **/
27 EFI_STATUS
28 EFIAPI
29 DpcLibConstructor (
30 IN EFI_HANDLE ImageHandle,
31 IN EFI_SYSTEM_TABLE *SystemTable
32 )
33 {
34 EFI_STATUS Status;
35
36 //
37 // Locate the EFI_DPC_PROTOCOL in the handle database
38 //
39 Status = gBS->LocateProtocol (&gEfiDpcProtocolGuid, NULL, (VOID **)&mDpc);
40 ASSERT_EFI_ERROR (Status);
41
42 return Status;
43 }
44
45 /**
46 Add a Deferred Procedure Call to the end of the DPC queue.
47
48 @param[in] DpcTpl The EFI_TPL that the DPC should be invoked.
49 @param[in] DpcProcedure Pointer to the DPC's function.
50 @param[in] DpcContext Pointer to the DPC's context. Passed to DpcProcedure
51 when DpcProcedure is invoked.
52
53 @retval EFI_SUCCESS The DPC was queued.
54 @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL.
55 @retval EFI_INVALID_PARAMETER DpcProcedure is NULL.
56 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
57 add the DPC to the queue.
58
59 **/
60 EFI_STATUS
61 EFIAPI
62 QueueDpc (
63 IN EFI_TPL DpcTpl,
64 IN EFI_DPC_PROCEDURE DpcProcedure,
65 IN VOID *DpcContext OPTIONAL
66 )
67 {
68 //
69 // Call the EFI_DPC_PROTOCOL to queue the DPC
70 //
71 return mDpc->QueueDpc (mDpc, DpcTpl, DpcProcedure, DpcContext);
72 }
73
74 /**
75 Dispatch the queue of DPCs. ALL DPCs that have been queued with a DpcTpl
76 value greater than or equal to the current TPL are invoked in the order that
77 they were queued. DPCs with higher DpcTpl values are invoked before DPCs with
78 lower DpcTpl values.
79
80 @retval EFI_SUCCESS One or more DPCs were invoked.
81 @retval EFI_NOT_FOUND No DPCs were invoked.
82
83 **/
84 EFI_STATUS
85 EFIAPI
86 DispatchDpc (
87 VOID
88 )
89 {
90 //
91 // Call the EFI_DPC_PROTOCOL to dispatch previously queued DPCs
92 //
93 return mDpc->DispatchDpc (mDpc);
94 }