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