source: mainline/boot/arch/ia64/loader/gefi/lib/init.c@ 86018c1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 86018c1 was 7208b6c, checked in by Jakub Vana <jakub.vana@…>, 17 years ago

Basic IA64 boot and kernel suport for real machines

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*++
2
3Copyright (c) 1998 Intel Corporation
4
5Module Name:
6
7
8Abstract:
9
10
11
12
13Revision History
14
15--*/
16
17#include "lib.h"
18
19VOID
20EFIDebugVariable (
21 VOID
22 );
23
24VOID
25InitializeLib (
26 IN EFI_HANDLE ImageHandle,
27 IN EFI_SYSTEM_TABLE *SystemTable
28 )
29/*++
30
31Routine Description:
32
33 Initializes EFI library for use
34
35Arguments:
36
37 Firmware's EFI system table
38
39Returns:
40
41 None
42
43--*/
44{
45 EFI_LOADED_IMAGE *LoadedImage;
46 EFI_STATUS Status;
47 CHAR8 *LangCode;
48
49 if (!LibInitialized) {
50 LibInitialized = TRUE;
51 LibFwInstance = FALSE;
52
53 //
54 // Set up global pointer to the system table, boot services table,
55 // and runtime services table
56 //
57
58 ST = SystemTable;
59 BS = SystemTable->BootServices;
60 RT = SystemTable->RuntimeServices;
61// ASSERT (CheckCrc(0, &ST->Hdr));
62// ASSERT (CheckCrc(0, &BS->Hdr));
63// ASSERT (CheckCrc(0, &RT->Hdr));
64
65
66 //
67 // Initialize pool allocation type
68 //
69
70 if (ImageHandle) {
71 Status = BS->HandleProtocol (
72 ImageHandle,
73 &LoadedImageProtocol,
74 (VOID*)&LoadedImage
75 );
76
77 if (!EFI_ERROR(Status)) {
78 PoolAllocationType = LoadedImage->ImageDataType;
79 }
80
81 EFIDebugVariable ();
82 }
83
84 //
85 // Initialize Guid table
86 //
87
88 InitializeGuid();
89
90 InitializeLibPlatform(ImageHandle,SystemTable);
91 }
92
93 //
94 //
95 //
96
97 if (ImageHandle && UnicodeInterface == &LibStubUnicodeInterface) {
98 LangCode = LibGetVariable (VarLanguage, &EfiGlobalVariable);
99 InitializeUnicodeSupport (LangCode);
100 if (LangCode) {
101 FreePool (LangCode);
102 }
103 }
104}
105
106VOID
107InitializeUnicodeSupport (
108 CHAR8 *LangCode
109 )
110{
111 EFI_UNICODE_COLLATION_INTERFACE *Ui;
112 EFI_STATUS Status;
113 CHAR8 *Languages;
114 UINTN Index, Position, Length;
115 UINTN NoHandles;
116 EFI_HANDLE *Handles;
117
118 //
119 // If we don't know it, lookup the current language code
120 //
121
122 LibLocateHandle (ByProtocol, &UnicodeCollationProtocol, NULL, &NoHandles, &Handles);
123 if (!LangCode || !NoHandles) {
124 goto Done;
125 }
126
127 //
128 // Check all driver's for a matching language code
129 //
130
131 for (Index=0; Index < NoHandles; Index++) {
132 Status = BS->HandleProtocol (Handles[Index], &UnicodeCollationProtocol, (VOID*)&Ui);
133 if (EFI_ERROR(Status)) {
134 continue;
135 }
136
137 //
138 // Check for a matching language code
139 //
140
141 Languages = Ui->SupportedLanguages;
142 Length = strlena(Languages);
143 for (Position=0; Position < Length; Position += ISO_639_2_ENTRY_SIZE) {
144
145 //
146 // If this code matches, use this driver
147 //
148
149 if (CompareMem (Languages+Position, LangCode, ISO_639_2_ENTRY_SIZE) == 0) {
150 UnicodeInterface = Ui;
151 goto Done;
152 }
153 }
154 }
155
156Done:
157 //
158 // Cleanup
159 //
160
161 if (Handles) {
162 FreePool (Handles);
163 }
164}
165
166VOID
167EFIDebugVariable (
168 VOID
169 )
170{
171 EFI_STATUS Status;
172 UINT32 Attributes;
173 UINTN DataSize;
174 UINTN NewEFIDebug;
175
176 DataSize = sizeof(EFIDebug);
177 Status = RT->GetVariable(L"EFIDebug", &EfiGlobalVariable, &Attributes, &DataSize, &NewEFIDebug);
178 if (!EFI_ERROR(Status)) {
179 EFIDebug = NewEFIDebug;
180 }
181}
Note: See TracBrowser for help on using the repository browser.