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