]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiSalLib/UefiSalLib.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / UefiSalLib / UefiSalLib.c
CommitLineData
1a3eaf06 1/** @file\r
e43e4b3e 2 SAL Library implementation retrieving the SAL Entry Point from the SAL System Table\r
a0720bb8 3 register in the EFI System Configuration Table.\r
1a3eaf06 4\r
9095d37b 5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
19388d29 6 This program and the accompanying materials are\r
1a3eaf06 7 licensed and made available under the terms and conditions of\r
8 the BSD License which accompanies this distribution. The full\r
9 text of the license may be found at\r
2fc59a00 10 http://opensource.org/licenses/bsd-license.php.\r
9095d37b 11\r
1a3eaf06 12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <PiDxe.h>\r
18#include <IndustryStandard/Sal.h>\r
19\r
20#include <Library/SalLib.h>\r
21#include <Library/UefiLib.h>\r
22#include <Library/DebugLib.h>\r
23\r
24#include <Guid/SalSystemTable.h>\r
25\r
26EFI_PLABEL mPlabel;\r
27SAL_PROC mSalProcEntry;\r
28\r
29/**\r
30 Makes a SAL procedure call.\r
9095d37b
LG
31\r
32 This is a wrapper function to make a SAL procedure call.\r
1a3eaf06 33 No parameter checking is performed on the 8 input parameters,\r
34 but there are some common rules that the caller should follow\r
35 when making a SAL call. Any address passed to SAL as buffers\r
36 for return parameters must be 8-byte aligned. Unaligned\r
37 addresses may cause undefined results. For those parameters\r
38 defined as reserved or some fields defined as reserved must be\r
39 zero filled or the invalid argument return value may be returned\r
40 or undefined result may occur during the execution of the procedure.\r
41 This function is only available on IPF.\r
42\r
58380e9c 43 @param Index The SAL procedure Index number.\r
44 @param Arg2 The 2nd parameter for SAL procedure calls.\r
45 @param Arg3 The 3rd parameter for SAL procedure calls.\r
46 @param Arg4 The 4th parameter for SAL procedure calls.\r
47 @param Arg5 The 5th parameter for SAL procedure calls.\r
48 @param Arg6 The 6th parameter for SAL procedure calls.\r
49 @param Arg7 The 7th parameter for SAL procedure calls.\r
50 @param Arg8 The 8th parameter for SAL procedure calls.\r
1a3eaf06 51\r
52 @return SAL returned registers.\r
53\r
54**/\r
55SAL_RETURN_REGS\r
56EFIAPI\r
57SalCall (\r
58 IN UINT64 Index,\r
59 IN UINT64 Arg2,\r
60 IN UINT64 Arg3,\r
61 IN UINT64 Arg4,\r
62 IN UINT64 Arg5,\r
63 IN UINT64 Arg6,\r
64 IN UINT64 Arg7,\r
65 IN UINT64 Arg8\r
66 )\r
67{\r
68 //\r
69 // mSalProcEntry is initialized in library constructor as SAL entry.\r
70 //\r
71 return mSalProcEntry(\r
72 Index,\r
73 Arg2,\r
74 Arg3,\r
75 Arg4,\r
76 Arg5,\r
77 Arg6,\r
78 Arg7,\r
79 Arg8\r
80 );\r
81\r
82}\r
83\r
84/**\r
85 The constructor function of UEFI SAL Lib.\r
86\r
87 The constructor function looks up the SAL System Table in the EFI System Configuration\r
88 Table. Once the SAL System Table is found, the SAL Entry Point in the SAL System Table\r
e43e4b3e 89 will be derived and stored into a global variable for library usage.\r
1a3eaf06 90 It will ASSERT() if the SAL System Table cannot be found or the data in the SAL System\r
91 Table is not the valid data.\r
92\r
93 @param ImageHandle The firmware allocated handle for the EFI image.\r
94 @param SystemTable A pointer to the EFI System Table.\r
95\r
96 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
97\r
98**/\r
99EFI_STATUS\r
100EFIAPI\r
101UefiSalLibConstructor (\r
102 IN EFI_HANDLE ImageHandle,\r
103 IN EFI_SYSTEM_TABLE *SystemTable\r
104 )\r
105{\r
106 EFI_STATUS Status;\r
107 SAL_ST_ENTRY_POINT_DESCRIPTOR *SalStEntryDes;\r
108 SAL_SYSTEM_TABLE_HEADER *SalSystemTable;\r
109\r
110 Status = EfiGetSystemConfigurationTable (\r
111 &gEfiSalSystemTableGuid,\r
112 (VOID **) &SalSystemTable\r
113 );\r
1a3eaf06 114 ASSERT_EFI_ERROR (Status);\r
d64ac715 115 ASSERT (SalSystemTable != NULL);\r
1a3eaf06 116\r
117 //\r
e43e4b3e 118 // Check the first entry of SAL System Table,\r
119 // because the SAL entry is in ascending order with the entry type,\r
120 // the type 0 entry should be the first if exist.\r
1a3eaf06 121 //\r
122 SalStEntryDes = (SAL_ST_ENTRY_POINT_DESCRIPTOR *)(SalSystemTable + 1);\r
123\r
124 //\r
125 // Assure the SAL ENTRY Type is 0\r
126 //\r
127 ASSERT (SalStEntryDes->Type == EFI_SAL_ST_ENTRY_POINT);\r
128\r
129 mPlabel.EntryPoint = SalStEntryDes->SalProcEntry;\r
130 mPlabel.GP = SalStEntryDes->SalGlobalDataPointer;\r
131 //\r
e43e4b3e 132 // Make sure the EntryPoint has the valid value\r
1a3eaf06 133 //\r
134 ASSERT ((mPlabel.EntryPoint != 0) && (mPlabel.GP != 0));\r
135\r
136 mSalProcEntry = (SAL_PROC)((UINT64)&(mPlabel.EntryPoint));\r
137\r
138 return EFI_SUCCESS;\r
139}\r