source: bootcd/isolinux/syslinux-6.03/gnu-efi/gnu-efi-3.0/lib/init.c @ dd1be7c

Last change on this file since dd1be7c was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 3.7 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 = uefi_call_wrapper(
72                            BS->HandleProtocol,
73                                3,
74                            ImageHandle,
75                            &LoadedImageProtocol,
76                            (VOID*)&LoadedImage
77                            );
78
79            if (!EFI_ERROR(Status)) {
80                PoolAllocationType = LoadedImage->ImageDataType;
81            }
82           
83            EFIDebugVariable ();
84        }
85
86        //
87        // Initialize Guid table
88        //
89
90        InitializeGuid();
91
92        InitializeLibPlatform(ImageHandle,SystemTable);
93    }
94
95    //
96    //
97    //
98
99    if (ImageHandle && UnicodeInterface == &LibStubUnicodeInterface) {
100        LangCode = LibGetVariable (VarLanguage, &EfiGlobalVariable);
101        InitializeUnicodeSupport (LangCode);
102        if (LangCode) {
103            FreePool (LangCode);
104        }
105    }
106}
107
108VOID
109InitializeUnicodeSupport (
110    CHAR8 *LangCode
111    )
112{
113    EFI_UNICODE_COLLATION_INTERFACE *Ui;
114    EFI_STATUS                      Status;
115    CHAR8                           *Languages;
116    UINTN                           Index, Position, Length;
117    UINTN                           NoHandles;
118    EFI_HANDLE                      *Handles;
119
120    //
121    // If we don't know it, lookup the current language code
122    //
123
124    LibLocateHandle (ByProtocol, &UnicodeCollationProtocol, NULL, &NoHandles, &Handles);
125    if (!LangCode || !NoHandles) {
126        goto Done;
127    }
128
129    //
130    // Check all driver's for a matching language code
131    //
132
133    for (Index=0; Index < NoHandles; Index++) {
134        Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handles[Index], &UnicodeCollationProtocol, (VOID*)&Ui);
135        if (EFI_ERROR(Status)) {
136            continue;
137        }
138
139        //
140        // Check for a matching language code
141        //
142
143        Languages = Ui->SupportedLanguages;
144        Length = strlena(Languages);
145        for (Position=0; Position < Length; Position += ISO_639_2_ENTRY_SIZE) {
146
147            //
148            // If this code matches, use this driver
149            //
150
151            if (CompareMem (Languages+Position, LangCode, ISO_639_2_ENTRY_SIZE) == 0) {
152                UnicodeInterface = Ui;
153                goto Done;
154            }
155        }
156    }
157
158Done:
159    //
160    // Cleanup
161    //
162
163    if (Handles) {
164        FreePool (Handles);
165    }
166}
167
168VOID
169EFIDebugVariable (
170    VOID
171    )
172{
173    EFI_STATUS      Status;
174    UINT32          Attributes;
175    UINTN           DataSize;
176    UINTN           NewEFIDebug;
177
178    DataSize = sizeof(EFIDebug);
179    Status = uefi_call_wrapper(RT->GetVariable, 5, L"EFIDebug", &EfiGlobalVariable, &Attributes, &DataSize, &NewEFIDebug);
180    if (!EFI_ERROR(Status)) {
181        EFIDebug = NewEFIDebug;
182    }
183}
Note: See TracBrowser for help on using the repository browser.