VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/AppPkg/ReadMe.txt@ 48674

最後變更 在這個檔案從48674是 48674,由 vboxsync 提交於 11 年 前

EFI: Export newly imported tinaocore UEFI sources to OSE.

  • 屬性 svn:eol-style 設為 native
檔案大小: 19.0 KB
 
1 EDK II Standard Libraries
2 ReadMe
3 Beta Release
4 4:03 PM 8/2/2011
5
6
7OVERVIEW
8========
9This document describes the EDK II specific aspects of installing, building, and
10using the Standard C Library component of the EDK II Application Development
11Kit, EADK.
12
13The EADK is comprised of three packages: AppPkg, StdLib, and StdLibPrivateInternalFiles.
14
15 AppPkg This package contains applications which demonstrate use of the
16 Standard C Library.
17 These applications reside in AppPkg/Applications.
18
19 Enquire This is a program that determines many properties of the
20 C compiler and the target machine that Enquire is run on. The
21 only changes required to port this 1990s era Unix program to
22 EDK II were the addition of eight pragmas to enquire.c in
23 order to disable some Microsoft VC++ specific warnings.
24
25 Hello This is a very simple EDK II native application that doesn't use
26 any features of the Standard C Library.
27
28 Main This application is functionally identical to Hello, except that
29 it uses the Standard C Library to provide a main() entry point.
30
31 Python A port of the Python-2.7.1 interpreter for UEFI. This
32 application is disabled by default. Un-comment the line for
33 PythonCore.inf in the [Components] section of AppPkg.dsc to
34 enable building Python.
35
36 Sockets A collection of applications demonstrating use of the
37 EDK II Socket Libraries. These applications include:
38
39 * DataSink
40 * DataSource
41 * GetHostByAddr
42 * GetHostByDns
43 * GetHostByName
44 * GetNetByAddr
45 * GetNetByName
46 * GetServByName
47 * GetServByPort
48 * RecvDgram
49 * SetHostName
50 * SetSockOpt
51 * TftpServer
52 * WebServer
53
54 StdLib The StdLib package contains the standard header files as well as
55 implementations of the standard libraries.
56
57 StdLibPrivateInternalFiles The contents of this package are for the
58 exclusive use of the library implementations in StdLib. Please do
59 not use anything from this package in your application or else
60 unexpected behavior may occur.
61 This package may be removed in a future release.
62
63
64RELEASE NOTES
65=============
66This release of the EADK has some restrictions, as described below.
67
68 1. Only the Microsoft VS2005 and VS2008, Intel C Compiler 10.1 (or later),
69 GCC 4.3 (mingw32), GCC 4.4, and GCC 4.5 C compilers are supported for
70 Ia32 or X64 CPU architectures.
71
72 2. The target machine must be running firmware which provides the
73 UEFI 2.3 HII protocol.
74
75 3. The EADK has not been through Intel's Quality Assurance process. This
76 means that specified standards compliance has not been validated, nor
77 has it undergone formal functionality testing.
78
79 4. Applications must be launched from within the EFI Shell.
80
81 5. All file paths must use the forward slash, '/', as the separator
82 character.
83
84 6. Absolute file paths may optionally be prefixed by a volume specifier
85 such as "FS0:". The volume specifier is separated from the remainder
86 of the path by a single colon ':'. The volume specifier must be one of
87 the Shell's mapped volume names as shown by the "map" command.
88
89 7. Absolute file paths that don't begin with a volume specifier;
90 e.g. paths that begin with "/", are relative to the currently selected
91 volume. When the EFI Shell starts, there is NO selected volume.
92
93 8. The tmpfile(), and related, functions require that the current volume
94 have a temporary directory as specified in <paths.h>. This directory
95 is specified by macro _PATH_TMP.
96
97The Standard C Library provided by this package is a "hosted" implementation
98conforming to the ISO/IEC 9899-1990 C Language Standard with Addendum 1. This
99is commonly referred to as the "C 95" specification or ISO/IEC 9899:199409.
100The following instructions assume that you have an existing EDK II or UDK 2010
101source tree that has been configured to build with your tool chain. For
102convenience, it is assumed that your EDK II source tree is located at
103C:\Source\Edk2.
104
105
106INSTALLATION
107============
108The EADK is integrated within the EDK II source tree and is included with
109current EDK II check-outs. If they are missing from your tree, they may be
110installed by extracting, downloading or copying them to the root of your EDK II
111source tree. The three package directories should be peers to the Conf,
112MdePkg, Nt32Pkg, etc. directories.
113
114The Python 2.7.1 distribution must be downloaded from python.org before the
115Python application can be built. Extracting Python-2.7.1.tgz into the
116AppPkg\Applications\Python directory will produce a Python-2.7.1 directory
117containing the Python distribution. Python files that had to be modified for
118EDK II are in the AppPkg\Applications\Python\PyMod-2.7.1 directory. These
119files need to be copied into the corresponding directories within Python-2.7.1.
120
121There are some boiler-plate declarations and definitions that need to be
122included in your application's INF and DSC build files. These are described
123in the CONFIGURATION section, below.
124
125
126BUILDING
127========
128It is not necessary to build the libraries separately from the target
129application(s). If the application references the libraries, as described in
130USAGE, below; the required libraries will be built as needed.
131To build the applications included in AppPkg, one would execute the following
132commands within the "Visual Studio Command Prompt" window:
133
134 > cd C:\Source\Edk2
135 > .\edksetup.bat
136 > build ?a X64 ?p AppPkg\AppPkg.dsc
137
138This will produce the application executables: Enquire.efi, Hello.efi, and
139Main.efi in the C:\Source\Edk2\Build\AppPkg\DEBUG_VS2008\X64 directory; with
140the DEBUG_VS2008 component being replaced with the actual tool chain and build
141type you have selected in Conf\Tools_def.txt. These executables can now be
142loaded onto the target platform and executed.
143
144If you examine the AppPkg.dsc file, you will notice that the StdLib package is
145referenced in order to resolve the library classes comprising the Standard
146C Library. This, plus referencing the StdLib package in your application's
147.inf file is all that is needed to link your application to the standard
148libraries.
149
150
151USAGE
152=====
153This implementation of the Standard C Library is comprised of 16 separate
154libraries in addition to the standard header files. Nine of the libraries are
155associated with use of one of the standard headers; thus, if the header is used
156in an application, it must be linked with the associated library. Three
157libraries are used to provide the Console and File-system device abstractions.
158The libraries and associated header files are described in the following table.
159
160 Library
161 Class Header File(s) Notes
162---------- ---------------- -------------------------------------------------
163LibC -- Use Always -- This library is always required.
164LibCtype ctype.h, wctype.h Character classification and mapping
165LibLocale locale.h Localization types, macros, and functions
166LibMath math.h Mathematical functions, types, and macros
167LibStdio stdio.h Standard Input and Output functions, types, and
168 macros
169LibStdLib stdlib.h General Utilities for numeric conversion, random
170 num., etc.
171LibString string.h String copying, concatenation, comparison,
172 & search
173LibSignal signal.h Functions and types for handling run-time
174 conditions
175LibTime time.h Time and Date types, macros, and functions
176LibUefi sys/EfiSysCall.h Provides the UEFI system interface and
177 "System Calls"
178LibWchar wchar.h Extended multibyte and wide character utilities
179LibNetUtil Network address and number manipulation utilities
180DevConsole Automatically provided File I/O abstractions for
181 the UEFI Console device. No need to list this
182 library class in your INF file(s).
183DevShell Add if desired File I/O abstractions using UEFI shell
184 facilities. Add this to the application's main
185 INF file if file-system access needed.
186DevUtility -- Do Not Use -- Utility functions used by the Device abstractions
187LibGdtoa -- Do Not Use -- This library is used internally and should not
188 need to be explicitly specified by an
189 application. It must be defined as one of the
190 available library classes in the application's
191 DSC file.
192
193 Table 1: Standard Libraries
194 ============================
195
196
197These libraries must be fully described in the [LibraryClasses] section of the
198application package's DSC file. Then, each individual application needs to
199specify which libraries to link to by specifying the Library Class, from the
200above table, in the [LibraryClasses] section of the application's INF file. The
201AppPkg.dsc, StdLib.dsc, and Enquire.inf files provide good examples of this.
202More details are in the CONFIGURATION section, below.
203
204Within the source files of the application, use of the Standard headers and
205library functions follow standard C programming practices as formalized by
206ISO/IEC 9899:1990, with Addendum 1, (C 95) C language specification.
207
208
209CONFIGURATION
210=============
211DSC Files
212---------
213
214All EDK II packages which build applications that use the standard libraries
215must include some "boilerplate" text in the package's .dsc file. To make it
216easier, and to reduce cut-and-paste errors, the "boilerplate" text has been
217consolidated into a single file, StdLib/StdLib.inc, which can be included in
218your .dsc file using the !include directive. The provided AppPkg.dsc and
219StdLib.dsc files do this on their last line.
220
221Each affected section of the DSC file is described below.
222
223 [LibraryClasses]
224 #
225 # Common Libraries
226 #
227 BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
228 BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
229
230 TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
231 # To run in an emulation environment, such as NT32, comment out
232 # the TimerLib description above and un-comment the line below.
233 # TimerLib| MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
234
235 #
236 # C Standard Libraries
237 #
238 LibC|StdLib/LibC/LibC.inf
239 LibStdLib|StdLib/LibC/StdLib/StdLib.inf
240 LibString|StdLib/LibC/String/String.inf
241 LibWchar|StdLib/LibC/Wchar/Wchar.inf
242 LibCType|StdLib/LibC/Ctype/Ctype.inf
243 LibTime|StdLib/LibC/Time/Time.inf
244 LibStdio|StdLib/LibC/Stdio/Stdio.inf
245 LibGdtoa|StdLib/LibC/gdtoa/gdtoa.inf
246 LibLocale|StdLib/LibC/Locale/Locale.inf
247 LibUefi|StdLib/LibC/Uefi/Uefi.inf
248 LibMath|StdLib/LibC/Math/Math.inf
249 LibSignal|StdLib/LibC/Signal/Signal.inf
250 LibNetUtil|StdLib/LibC/LibGcc/LibGcc.inf
251
252 # Libraries for device abstractions within the Standard C Library.
253 # Applications should not directly access any functions defined
254 # in these libraries.
255 DevUtility|StdLib/LibC/Uefi/Devices/daUtility.inf
256 DevConsole|StdLib/LibC/Uefi/Devices/daConsole.inf
257 DevShell|StdLib/LibC/Uefi/Devices/daShell.inf
258
259 Figure 1: Library Class Descriptions
260 ====================================
261
262
263Descriptions of the Library Classes comprising the Standard Libraries must be
264included in your application package's DSC file, as shown in Figure 1: Library
265Class Descriptions, above.
266
267The directives in Figure 2: Package Component Descriptions will create
268instances of the BaseLib and BaseMemoryLib library classes that are built
269with Link-time-Code-Generation disabled. This is necessary when using the
270Microsoft tool chains in order to allow the library's functions to be
271resolved during the second pass of the linker during Link-Time-Code-Generation
272of the application.
273
274 [Components]
275 # BaseLib and BaseMemoryLib need to be built with the /GL- switch
276 # when using the Microsoft tool chains. This is required so that
277 # the library functions can be resolved during the second pass of
278 # the linker during link-time-code-generation.
279 #
280 MdePkg/Library/BaseLib/BaseLib.inf {
281 <BuildOptions>
282 MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t /GL-
283 }
284 MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf {
285 <BuildOptions>
286 MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t /GL-
287 }
288
289 Figure 2: Package Component Descriptions
290 ========================================
291
292
293The NULL TimerLib instance must be selected if you desire to run your
294application under an emulation environment -- unless there is a supported
295TimerLib for that environment. For example, the InOsEmuPkg provides a
296DxeTimerLib which can be used for the TimerLib instance.
297
298The "boilerplate" text in StdLib.inc will automatically adjust which Timer
299Library is instantiated based upon whether the $(EMULATE) macro has been
300defined, or not.
301
302 ###
303 # Select the correct TimerLib instance depending upon whether running under
304 # an emulation environment, or not.
305 !ifndef $(EMULATE)
306 # Not running in an Emulation Environment
307 [LibraryClasses.IA32.UEFI_APPLICATION]
308 TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
309
310 [LibraryClasses.X64.UEFI_APPLICATION]
311 TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
312
313 [LibraryClasses.IPF.UEFI_APPLICATION]
314 PalLib|MdePkg/Library/UefiPalLib/UefiPalLib.inf
315 TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
316
317 !else
318 # Use this instance if Running in an Emulation Environment.
319 [LibraryClasses.Common.UEFI_APPLICATION]
320 TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
321 !endif
322
323 Figure 3: Timer Library Selection
324 =================================
325
326
327Each compiler assumes, by default, that it will be used with standard libraries
328and headers provided by the compiler vendor. Many of these assumptions are
329incorrect for the UEFI environment. By including a BuildOptions section, as
330shown in Figure 3: Package Build Options, these assumptions can be
331tailored for compatibility with UEFI and the EDK II Standard Libraries.
332
333 [BuildOptions]
334 INTEL:*_*_IA32_CC_FLAGS = /Qfreestanding
335 MSFT:*_*_IA32_CC_FLAGS = /X /Zc:wchar_t
336 GCC:*_*_IA32_CC_FLAGS = /ffreestanding ?nostdinc ?nostdlib
337
338 # The Build Options, below, are only used when building the C library
339 # to be run under an emulation environment. The clock() system call
340 # is modified to return -1 indicating that it is unsupported.
341 # Just un-comment the lines below and select the correct
342 # TimerLib instance, above.
343
344 # INTEL:*_*_IA32_CC_FLAGS = /D NT32dvm
345 # MSFT:*_*_IA32_CC_FLAGS = /D NT32dvm
346 # GCC:*_*_IA32_CC_FLAGS = -DNT32dvm
347
348 Figure 4: Package Build Options
349 ===============================
350
351The "boilerplate" text can be included using a !include directive in the
352package's .dsc file. The provided AppPkg.dsc and StdLib.dsc files include
353the "boilerplate" text as follows:
354
355 # Include Boilerplate text required for building with the Standard Libraries.
356 #
357 #############################################################################
358 !include StdLib/StdLib.inc
359
360 Figure 5: "Boilerplate" Inclusion
361 =================================
362
363
364INF Files
365=========
366The INF files for most modules will not require special directives in order to
367support the Standard Libraries. The two cases which could occur are described
368below.
369
370 [LibraryClasses]
371 UefiLib
372 LibC
373 LibString
374 LibStdio
375 DevShell
376
377 Figure 6: Module Library Classes
378 ================================
379
380
381Modules of type UEFI_APPLICATION that perform file I/O should include library
382class DevShell. Including this library class will allow file operations to be
383handled by the UEFI Shell. Without this class, only Console I/O is permitted.
384
385 [BuildOptions]
386 INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
387 MSFT:*_*_*_CC_FLAGS = /Oi- /wd4018 /wd4131
388 GCC:*_*_IPF_SYMRENAME_FLAGS = --redefine-syms=Rename.txt
389
390 Figure 7: Module Build Options
391 ==============================
392
393
394An application's INF file may need to include a [BuildOptions] section
395specifying additional compiler and linker flags necessary to allow the
396application to be built. Usually, this section is not needed. When building
397code from external sources, though, it may be necessary to disable some
398warnings or enable/disable some compiler features.
399
400
401IMPLEMENTATION-Specific Features
402================================
403It is very strongly recommended that applications not use the long or
404unsigned long types. The size of this type varies between compilers and is one
405of the less portable aspects of C. Instead, one should use the UEFI defined
406types whenever possible. Use of these types, listed below for reference,
407ensures that the declared objects have unambiguous, explicitly declared, sizes
408and characteristics.
409
410 UINT64 INT64 UINT32 INT32 UINT16 CHAR16
411 INT16 BOOLEAN UINT8 CHAR8 INT8
412 UINTN INTN PHYSICALADDRESS
413
414There are similar types declared in sys/types.h and related files.
415
416The types UINTN and INTN have the native width of the target processor
417architecture. Thus, INTN on IA32 has a width of 32 bits while INTN on X64 and
418IPF has a width of 64 bits.
419
420For maximum portability, data objects intended to hold addresses should be
421declared with type intptr_t or uintptr_t. These types, declared in
422sys/stdint.h, can be used to create objects capable of holding pointers. Note
423that these types will generate different sized objects on different processor
424architectures. If a constant size across all processors and compilers is
425needed, use type PHYSICAL_ADDRESS.
426
427Though not specifically required by the ISO/IEC 9899 standard, this
428implementation of the Standard C Library provides the following system calls
429which are declared in sys/EfiSysCall.h.
430
431 close dup dup2 fcntl
432 fstat getcwd ioctl isatty
433 lseek lstat mkdir open
434 poll read rename rmdir
435 stat unlink write
436
437The open function will accept file names of "stdin:", "stdout:", and "stderr:"
438which cause the respective streams specified in the UEFI System Table to be
439opened. Normally, these are associated with the console device. When the
440application is first started, these streams are automatically opened on File
441Descriptors 0, 1, and 2 respectively.
442
443
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette