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