]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/Common/CommonLib.h
Sync BaseTools Branch (version r2321) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / C / Common / CommonLib.h
CommitLineData
30fdf114
LG
1/** @file\r
2\r
40d841f6
LG
3Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
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
LG
27#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r
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
148#define ASSERT(x) assert(x)\r
149\r
150#ifdef __GNUC__\r
151#include <stdio.h>\r
152#include <sys/stat.h>\r
153#define stricmp strcasecmp\r
154#define _stricmp strcasecmp\r
155#define strnicmp strncasecmp\r
156#define strcmpi strcasecmp\r
157size_t _filelength(int fd);\r
158#ifndef __CYGWIN__\r
159char *strlwr(char *s);\r
160#endif\r
161#endif\r
162\r
163//\r
164// On windows, mkdir only has one parameter.\r
165// On unix, it has two parameters\r
166//\r
167#if defined(__GNUC__)\r
168#define mkdir(dir, perm) mkdir(dir, perm)\r
169#else\r
170#define mkdir(dir, perm) mkdir(dir)\r
171#endif\r
172\r
173#endif\r