]>
Commit | Line | Data |
---|---|---|
1a3eaf06 | 1 | /** @file\r |
2 | SAL 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 | #include <IndustryStandard/Sal.h>\r | |
18 | \r | |
19 | #include <Library/SalLib.h>\r | |
20 | #include <Library/UefiLib.h>\r | |
21 | #include <Library/DebugLib.h>\r | |
22 | \r | |
23 | #include <Guid/SalSystemTable.h>\r | |
24 | \r | |
25 | EFI_PLABEL mPlabel;\r | |
26 | SAL_PROC mSalProcEntry;\r | |
27 | \r | |
28 | /**\r | |
29 | Makes a SAL procedure call.\r | |
30 | \r | |
31 | This is a wrapper function to make a SAL procedure call.\r | |
32 | No parameter checking is performed on the 8 input parameters,\r | |
33 | but there are some common rules that the caller should follow\r | |
34 | when making a SAL call. Any address passed to SAL as buffers\r | |
35 | for return parameters must be 8-byte aligned. Unaligned\r | |
36 | addresses may cause undefined results. For those parameters\r | |
37 | defined as reserved or some fields defined as reserved must be\r | |
38 | zero filled or the invalid argument return value may be returned\r | |
39 | or undefined result may occur during the execution of the procedure.\r | |
40 | This function is only available on IPF.\r | |
41 | \r | |
42 | @param Index The SAL procedure Index number\r | |
43 | @param Arg2 The 2nd parameter for SAL procedure calls\r | |
44 | @param Arg3 The 3rd parameter for SAL procedure calls\r | |
45 | @param Arg4 The 4th parameter for SAL procedure calls\r | |
46 | @param Arg5 The 5th parameter for SAL procedure calls\r | |
47 | @param Arg6 The 6th parameter for SAL procedure calls\r | |
48 | @param Arg7 The 7th parameter for SAL procedure calls\r | |
49 | @param Arg8 The 8th parameter for SAL procedure calls\r | |
50 | \r | |
51 | @return SAL returned registers.\r | |
52 | \r | |
53 | **/\r | |
54 | SAL_RETURN_REGS\r | |
55 | EFIAPI\r | |
56 | SalCall (\r | |
57 | IN UINT64 Index,\r | |
58 | IN UINT64 Arg2,\r | |
59 | IN UINT64 Arg3,\r | |
60 | IN UINT64 Arg4,\r | |
61 | IN UINT64 Arg5,\r | |
62 | IN UINT64 Arg6,\r | |
63 | IN UINT64 Arg7,\r | |
64 | IN UINT64 Arg8\r | |
65 | )\r | |
66 | {\r | |
67 | //\r | |
68 | // mSalProcEntry is initialized in library constructor as SAL entry.\r | |
69 | //\r | |
70 | return mSalProcEntry(\r | |
71 | Index,\r | |
72 | Arg2,\r | |
73 | Arg3,\r | |
74 | Arg4,\r | |
75 | Arg5,\r | |
76 | Arg6,\r | |
77 | Arg7,\r | |
78 | Arg8\r | |
79 | );\r | |
80 | \r | |
81 | }\r | |
82 | \r | |
83 | /**\r | |
84 | The constructor function of UEFI SAL Lib.\r | |
85 | \r | |
86 | The constructor function looks up the SAL System Table in the EFI System Configuration\r | |
87 | Table. Once the SAL System Table is found, the SAL Entry Point in the SAL System Table\r | |
88 | will be derived and stored inot a global variable for library usage.\r | |
89 | It will ASSERT() if the SAL System Table cannot be found or the data in the SAL System\r | |
90 | Table is not the valid data.\r | |
91 | \r | |
92 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
93 | @param SystemTable A pointer to the EFI System Table.\r | |
94 | \r | |
95 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
96 | \r | |
97 | **/\r | |
98 | EFI_STATUS\r | |
99 | EFIAPI\r | |
100 | UefiSalLibConstructor (\r | |
101 | IN EFI_HANDLE ImageHandle,\r | |
102 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
103 | )\r | |
104 | {\r | |
105 | EFI_STATUS Status;\r | |
106 | SAL_ST_ENTRY_POINT_DESCRIPTOR *SalStEntryDes;\r | |
107 | SAL_SYSTEM_TABLE_HEADER *SalSystemTable;\r | |
108 | \r | |
109 | Status = EfiGetSystemConfigurationTable (\r | |
110 | &gEfiSalSystemTableGuid,\r | |
111 | (VOID **) &SalSystemTable\r | |
112 | );\r | |
113 | \r | |
114 | ASSERT_EFI_ERROR (Status);\r | |
115 | \r | |
116 | //\r | |
117 | // Move the SAL System Table point to the first Entry\r | |
118 | // Due to the SAL Entry is in ascending order with the Entry type,\r | |
119 | // the type 0 Entry should be the first if exist.\r | |
120 | //\r | |
121 | SalStEntryDes = (SAL_ST_ENTRY_POINT_DESCRIPTOR *)(SalSystemTable + 1);\r | |
122 | \r | |
123 | //\r | |
124 | // Assure the SAL ENTRY Type is 0\r | |
125 | //\r | |
126 | ASSERT (SalStEntryDes->Type == EFI_SAL_ST_ENTRY_POINT);\r | |
127 | \r | |
128 | mPlabel.EntryPoint = SalStEntryDes->SalProcEntry;\r | |
129 | mPlabel.GP = SalStEntryDes->SalGlobalDataPointer;\r | |
130 | //\r | |
131 | // Make sure the EntryPoint has the real value\r | |
132 | //\r | |
133 | ASSERT ((mPlabel.EntryPoint != 0) && (mPlabel.GP != 0));\r | |
134 | \r | |
135 | mSalProcEntry = (SAL_PROC)((UINT64)&(mPlabel.EntryPoint));\r | |
136 | \r | |
137 | return EFI_SUCCESS;\r | |
138 | }\r |