]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/DxeDpcLib/DpcLib.c
Move Undi driver to common section.
[mirror_edk2.git] / MdeModulePkg / Library / DxeDpcLib / DpcLib.c
CommitLineData
36ee91ca 1/** @file\r
2\r
3Copyright (c) 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 DpcLib.c\r
15\r
16Abstract:\r
17\r
18**/\r
19\r
20#include <PiDxe.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/UefiBootServicesTableLib.h>\r
23#include <Protocol/Dpc.h>\r
24\r
25//\r
26// Pointer to the DPC Protocol\r
27//\r
28EFI_DPC_PROTOCOL *mDpc;\r
29\r
30/**\r
31 This constructor function caches the EFI_DPC_PROTOCOL pointer.\r
32\r
33 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
34 @param[in] SystemTable A pointer to the EFI System Table.\r
35\r
36 @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.\r
37\r
38**/\r
39EFI_STATUS\r
40EFIAPI\r
41DpcLibConstructor (\r
42 IN EFI_HANDLE ImageHandle,\r
43 IN EFI_SYSTEM_TABLE *SystemTable\r
44 )\r
45{\r
46 EFI_STATUS Status;\r
47\r
48 //\r
49 // Locate the EFI_DPC_PROTOCOL in the handle database\r
50 //\r
51 Status = gBS->LocateProtocol (&gEfiDpcProtocolGuid, NULL, (VOID **)&mDpc);\r
52 ASSERT_EFI_ERROR (Status);\r
53\r
54 return EFI_SUCCESS;\r
55}\r
56\r
57/**\r
58 Add a Deferred Procedure Call to the end of the DPC queue.\r
59\r
60 @param DpcTpl The EFI_TPL that the DPC should be invoked.\r
61 @param DpcProcedure Pointer to the DPC's function.\r
62 @param DpcContext Pointer to the DPC's context. Passed to DpcProcedure\r
63 when DpcProcedure is invoked.\r
64\r
65 @retval EFI_SUCCESS The DPC was queued.\r
66 @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL.\r
67 @retval EFI_INVALID_PARAMETER DpcProcedure is NULL.\r
68 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to\r
69 add the DPC to the queue.\r
70\r
71**/\r
72EFI_STATUS\r
73QueueDpc (\r
74 IN EFI_TPL DpcTpl,\r
75 IN EFI_DPC_PROCEDURE DpcProcedure,\r
76 IN VOID *DpcContext\r
77 )\r
78{\r
79 //\r
80 // Call the EFI_DPC_PROTOCOL to queue the DPC\r
81 //\r
82 return mDpc->QueueDpc (mDpc, DpcTpl, DpcProcedure, DpcContext);\r
83}\r
84\r
85/**\r
86 Dispatch the queue of DPCs. ALL DPCs that have been queued with a DpcTpl\r
87 value greater than or equal to the current TPL are invoked in the order that\r
88 they were queued. DPCs with higher DpcTpl values are invoked before DPCs with\r
89 lower DpcTpl values.\r
90\r
91 @retval EFI_SUCCESS One or more DPCs were invoked.\r
92 @retval EFI_NOT_FOUND No DPCs were invoked.\r
93\r
94**/\r
95EFI_STATUS\r
96DispatchDpc (\r
97 VOID\r
98 )\r
99{\r
100 //\r
101 // Call the EFI_DPC_PROTOCOL to dispatch previously queued DPCs\r
102 //\r
103 return mDpc->DispatchDpc (mDpc);\r
104}\r