]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/Common/CommonLib.h
Add IMAGE_ATTRIBUTE_UEFI_IMAGE definition from UEFI 2.4 specification.
[mirror_edk2.git] / BaseTools / Source / C / Common / CommonLib.h
CommitLineData
30fdf114
LG
1/** @file\r
2\r
1be2ed90 3Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
40d841f6 4This program and the accompanying materials\r
30fdf114
LG
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 CommonLib.h\r
15\r
16Abstract:\r
17\r
18 Common library assistance routines.\r
19\r
20**/\r
21\r
22#ifndef _EFI_COMMON_LIB_H\r
23#define _EFI_COMMON_LIB_H\r
24\r
25#include <Common/UefiBaseTypes.h>\r
b36d134f 26#include <Common/BuildVersion.h>\r
30fdf114 27#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r
1be2ed90
HC
28\r
29#define MAX_LONG_FILE_PATH 500\r
30\r
31#ifdef __cplusplus\r
32extern "C" {\r
33#endif\r
30fdf114
LG
34//\r
35// Function declarations\r
36//\r
37VOID\r
38PeiZeroMem (\r
39 IN VOID *Buffer,\r
40 IN UINTN Size\r
41 )\r
42;\r
43\r
44VOID\r
45PeiCopyMem (\r
46 IN VOID *Destination,\r
47 IN VOID *Source,\r
48 IN UINTN Length\r
49 )\r
50;\r
51\r
52VOID\r
53ZeroMem (\r
54 IN VOID *Buffer,\r
55 IN UINTN Size\r
56 )\r
57;\r
58\r
59VOID\r
60CopyMem (\r
61 IN VOID *Destination,\r
62 IN VOID *Source,\r
63 IN UINTN Length\r
64 )\r
65;\r
66\r
67INTN\r
68CompareGuid (\r
69 IN EFI_GUID *Guid1,\r
70 IN EFI_GUID *Guid2\r
71 )\r
72;\r
73\r
74EFI_STATUS\r
75GetFileImage (\r
76 IN CHAR8 *InputFileName,\r
77 OUT CHAR8 **InputFileImage,\r
78 OUT UINT32 *BytesRead\r
79 )\r
80;\r
81\r
82EFI_STATUS\r
83PutFileImage (\r
84 IN CHAR8 *OutputFileName,\r
85 IN CHAR8 *OutputFileImage,\r
86 IN UINT32 BytesToWrite\r
87 )\r
88;\r
89/*++\r
90\r
91Routine Description:\r
92\r
93 This function opens a file and writes OutputFileImage into the file.\r
94\r
95Arguments:\r
96\r
97 OutputFileName The name of the file to write.\r
98 OutputFileImage A pointer to the memory buffer.\r
99 BytesToWrite The size of the memory buffer.\r
100\r
101Returns:\r
102\r
103 EFI_SUCCESS The function completed successfully.\r
104 EFI_INVALID_PARAMETER One of the input parameters was invalid.\r
105 EFI_ABORTED An error occurred.\r
106 EFI_OUT_OF_RESOURCES No resource to complete operations.\r
107\r
108**/\r
109\r
110UINT8\r
111CalculateChecksum8 (\r
112 IN UINT8 *Buffer,\r
113 IN UINTN Size\r
114 )\r
115;\r
116\r
117UINT8\r
118CalculateSum8 (\r
119 IN UINT8 *Buffer,\r
120 IN UINTN Size\r
121 )\r
122;\r
123\r
124UINT16\r
125CalculateChecksum16 (\r
126 IN UINT16 *Buffer,\r
127 IN UINTN Size\r
128 )\r
129;\r
130\r
131UINT16\r
132CalculateSum16 (\r
133 IN UINT16 *Buffer,\r
134 IN UINTN Size\r
135 )\r
136;\r
137\r
138EFI_STATUS\r
139PrintGuid (\r
140 IN EFI_GUID *Guid\r
141 )\r
142;\r
143\r
144#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r
145EFI_STATUS\r
146PrintGuidToBuffer (\r
147 IN EFI_GUID *Guid,\r
148 IN OUT UINT8 *Buffer,\r
149 IN UINT32 BufferLen,\r
150 IN BOOLEAN Uppercase\r
151 )\r
152;\r
153\r
1be2ed90
HC
154CHAR8 *\r
155LongFilePath (\r
156 IN CHAR8 *FileName\r
157);\r
158/*++\r
159\r
160Routine Description:\r
161 Convert FileName to the long file path, which can support larger than 260 length. \r
162\r
163Arguments:\r
164 FileName - FileName. \r
165\r
166Returns:\r
167 LongFilePath A pointer to the converted long file path.\r
168 \r
169--*/\r
170\r
171#ifdef __cplusplus\r
172}\r
173#endif\r
174\r
30fdf114
LG
175#define ASSERT(x) assert(x)\r
176\r
177#ifdef __GNUC__\r
178#include <stdio.h>\r
179#include <sys/stat.h>\r
180#define stricmp strcasecmp\r
181#define _stricmp strcasecmp\r
182#define strnicmp strncasecmp\r
183#define strcmpi strcasecmp\r
184size_t _filelength(int fd);\r
185#ifndef __CYGWIN__\r
186char *strlwr(char *s);\r
187#endif\r
188#endif\r
189\r
190//\r
191// On windows, mkdir only has one parameter.\r
192// On unix, it has two parameters\r
193//\r
194#if defined(__GNUC__)\r
195#define mkdir(dir, perm) mkdir(dir, perm)\r
196#else\r
197#define mkdir(dir, perm) mkdir(dir)\r
198#endif\r
199\r
200#endif\r