]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / DxeServicesTableLib / DxeServicesTableLib.c
1 /** @file
2 This library implement library class DxeServiceTableLib.
3 It produce EFI_DXE_SERVICE pointer in global variable gDS in library's constructure.
4
5 A DXE driver can use gDS pointer to access services in EFI_DXE_SERVICE, if this
6 DXE driver declare that use DxeServicesTableLib library class and link to this
7 library instance.
8
9 Please attention this library instance can not be used util EFI_SYSTEM_TABLE was
10 initialized.
11
12 This library contains construct function to retrieve EFI_DXE_SERVICE, this construct
13 function will be invoked in DXE driver's autogen file.
14
15 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
16 SPDX-License-Identifier: BSD-2-Clause-Patent
17
18 **/
19
20 #include <PiDxe.h>
21 #include <Guid/DxeServices.h>
22 #include <Library/DxeServicesTableLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/UefiLib.h>
25
26 //
27 // Cache copy of the DXE Services Table
28 //
29 EFI_DXE_SERVICES *gDS = NULL;
30
31 /**
32 The constructor function caches the pointer of DXE Services Table.
33
34 The constructor function caches the pointer of DXE Services Table.
35 It will ASSERT() if that operation fails.
36 It will ASSERT() if the pointer of DXE Services Table is NULL.
37 It will always return EFI_SUCCESS.
38
39 @param ImageHandle The firmware allocated handle for the EFI image.
40 @param SystemTable A pointer to the EFI System Table.
41
42 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
43
44 **/
45 EFI_STATUS
46 EFIAPI
47 DxeServicesTableLibConstructor (
48 IN EFI_HANDLE ImageHandle,
49 IN EFI_SYSTEM_TABLE *SystemTable
50 )
51 {
52 EFI_STATUS Status;
53
54 //
55 // Cache copy of the DXE Services Table
56 //
57 Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **)&gDS);
58 ASSERT_EFI_ERROR (Status);
59 ASSERT (gDS != NULL);
60
61 return Status;
62 }