]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c
474748d332d8df1eb7f786f2dd0f4054a218f951
[mirror_edk2.git] / MdePkg / Library / PeiServicesTablePointerLibKr1 / PeiServicesTablePointer.c
1 /*++
2
3 Copyright (c) 2006 Intel Corporation. All rights reserved
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
10 Intel Corporation.
11
12
13 Module Name:
14
15 PeiServicesTablePointer.c
16
17 Abstract:
18
19 PEI Services Table Pointer Library.
20
21 --*/
22
23
24 /**
25 Reads the current value of Kr1.
26
27 @return The current value of Kr1.
28
29 **/
30 UINT64
31 EFIAPI
32 AsmReadKr1 (
33 VOID
34 );
35
36 /**
37 Writes the current value of Kr1.
38
39 @param Value The 64-bit value to write to Kr1.
40
41 **/
42 VOID
43 EFIAPI
44 AsmWriteKr1 (
45 IN UINT64 Value
46 );
47
48 /**
49 The function returns the pointer to PeiServices.
50
51 The function returns the pointer to PeiServices.
52 It will ASSERT() if the pointer to PeiServices is NULL.
53
54 @retval The pointer to PeiServices.
55
56 **/
57 EFI_PEI_SERVICES **
58 EFIAPI
59 GetPeiServicesTablePointer (
60 VOID
61 )
62 {
63 EFI_PEI_SERVICES **PeiServices;
64
65 PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadKr1 ();
66 ASSERT (PeiServices != NULL);
67 return PeiServices;
68 }
69
70 /**
71 The constructor function caches the pointer to PEI services.
72
73 The constructor function caches the pointer to PEI services.
74 It will always return EFI_SUCCESS.
75
76 @param FfsHeader Pointer to FFS header the loaded driver.
77 @param PeiServices Pointer to the PEI services.
78
79 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
80
81 **/
82 EFI_STATUS
83 EFIAPI
84 PeiServicesTablePointerLibConstructor (
85 IN EFI_FFS_FILE_HEADER *FfsHeader,
86 IN EFI_PEI_SERVICES **PeiServices
87 )
88 {
89 AsmWriteKr1 ((UINT64)(UINTN)PeiServices);
90 return EFI_SUCCESS;
91 }