]>
Commit | Line | Data |
---|---|---|
1a3eaf06 | 1 | /** @file\r |
e43e4b3e | 2 | PAL Library implementation retrieving the PAL Entry Point from the SAL System Table\r |
3 | register in the EFI System Confguration Table.\r | |
1a3eaf06 | 4 | \r |
5 | Copyright (c) 2007 - 2008, Intel Corporation All rights\r | |
6 | reserved. This program and the accompanying materials are\r | |
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 | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
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 | \r | |
19 | #include <IndustryStandard/Sal.h>\r | |
20 | #include <Library/UefiLib.h>\r | |
21 | #include <Library/BaseLib.h>\r | |
22 | #include <Library/DebugLib.h>\r | |
23 | \r | |
24 | #include <Guid/SalSystemTable.h>\r | |
25 | \r | |
26 | UINT64 mPalProcEntry;\r | |
27 | \r | |
28 | /**\r | |
29 | Makes a PAL procedure call.\r | |
30 | \r | |
31 | This is a wrapper function to make a PAL procedure call. Based on the Index value,\r | |
32 | this API will make static or stacked PAL call. Architected procedures may be designated\r | |
33 | as required or optional. If a PAL procedure is specified as optional, a unique return\r | |
34 | code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.\r | |
35 | This indicates that the procedure is not present in this PAL implementation. It is the\r | |
36 | caller's responsibility to check for this return code after calling any optional PAL\r | |
37 | procedure. No parameter checking is performed on the 4 input parameters, but there are\r | |
38 | some common rules that the caller should follow when making a PAL call. Any address\r | |
39 | passed to PAL as buffers for return parameters must be 8-byte aligned. Unaligned addresses\r | |
40 | may cause undefined results. For those parameters defined as reserved or some fields\r | |
41 | defined as reserved must be zero filled or the invalid argument return value may be\r | |
42 | returned or undefined result may occur during the execution of the procedure.\r | |
43 | This function is only available on IPF.\r | |
44 | \r | |
3745e1a6 | 45 | @param Index The PAL procedure Index number.\r |
46 | @param Arg2 The 2nd parameter for PAL procedure calls.\r | |
47 | @param Arg3 The 3rd parameter for PAL procedure calls.\r | |
48 | @param Arg4 The 4th parameter for PAL procedure calls.\r | |
1a3eaf06 | 49 | \r |
98ea597b | 50 | @return Structure returned from the PAL Call procedure, including the status and return value.\r |
1a3eaf06 | 51 | \r |
52 | **/\r | |
53 | PAL_CALL_RETURN\r | |
54 | EFIAPI\r | |
55 | PalCall (\r | |
56 | IN UINT64 Index,\r | |
57 | IN UINT64 Arg2,\r | |
58 | IN UINT64 Arg3,\r | |
59 | IN UINT64 Arg4\r | |
60 | )\r | |
61 | {\r | |
62 | //\r | |
63 | // mPalProcEntry is initialized in library constructor as PAL entry.\r | |
64 | //\r | |
65 | return AsmPalCall (\r | |
66 | mPalProcEntry,\r | |
67 | Index,\r | |
68 | Arg2,\r | |
69 | Arg3,\r | |
70 | Arg4\r | |
71 | );\r | |
72 | \r | |
73 | }\r | |
74 | \r | |
75 | /**\r | |
76 | The constructor function of UEFI Pal Lib.\r | |
77 | \r | |
78 | The constructor function looks up the SAL System Table in the EFI System Configuration\r | |
79 | Table. Once the SAL System Table is found, the PAL Entry Point in the SAL System Table\r | |
e43e4b3e | 80 | will be derived and stored into a global variable for library usage.\r |
1a3eaf06 | 81 | It will ASSERT() if the SAL System Table cannot be found or the data in the SAL System\r |
82 | Table is not the valid data.\r | |
83 | \r | |
84 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
85 | @param SystemTable A pointer to the EFI System Table.\r | |
86 | \r | |
87 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | EFIAPI\r | |
92 | UefiPalLibConstructor (\r | |
93 | IN EFI_HANDLE ImageHandle,\r | |
94 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
95 | )\r | |
96 | {\r | |
97 | EFI_STATUS Status;\r | |
98 | SAL_ST_ENTRY_POINT_DESCRIPTOR *SalStEntryDes;\r | |
99 | SAL_SYSTEM_TABLE_HEADER *SalSystemTable;\r | |
100 | \r | |
101 | Status = EfiGetSystemConfigurationTable (\r | |
102 | &gEfiSalSystemTableGuid,\r | |
103 | (VOID **) &SalSystemTable\r | |
104 | );\r | |
1a3eaf06 | 105 | ASSERT_EFI_ERROR (Status);\r |
75a38141 | 106 | ASSERT (SalSystemTable != NULL);\r |
1a3eaf06 | 107 | \r |
108 | //\r | |
e43e4b3e | 109 | // Check the first entry of SAL System Table,\r |
110 | // because the SAL entry is in ascending order with the entry type,\r | |
111 | // the type 0 entry should be the first if exist.\r | |
1a3eaf06 | 112 | //\r |
113 | SalStEntryDes = (SAL_ST_ENTRY_POINT_DESCRIPTOR *)(SalSystemTable + 1);\r | |
114 | \r | |
115 | //\r | |
116 | // Assure the SAL ENTRY Type is 0\r | |
117 | //\r | |
118 | ASSERT (SalStEntryDes->Type == EFI_SAL_ST_ENTRY_POINT);\r | |
119 | \r | |
120 | mPalProcEntry = SalStEntryDes->PalProcEntry;\r | |
121 | //\r | |
122 | // Make sure the PalCallAddress has the valid value\r | |
123 | //\r | |
124 | ASSERT (mPalProcEntry != 0);\r | |
125 | \r | |
126 | return EFI_SUCCESS;\r | |
127 | }\r |