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