]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/Source/C/Common/CommonLib.h
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / C / Common / CommonLib.h
... / ...
CommitLineData
1/** @file\r
2\r
3Copyright (c) 2004 - 2008, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
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
26#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r
27//\r
28// Function declarations\r
29//\r
30VOID\r
31PeiZeroMem (\r
32 IN VOID *Buffer,\r
33 IN UINTN Size\r
34 )\r
35;\r
36\r
37VOID\r
38PeiCopyMem (\r
39 IN VOID *Destination,\r
40 IN VOID *Source,\r
41 IN UINTN Length\r
42 )\r
43;\r
44\r
45VOID\r
46ZeroMem (\r
47 IN VOID *Buffer,\r
48 IN UINTN Size\r
49 )\r
50;\r
51\r
52VOID\r
53CopyMem (\r
54 IN VOID *Destination,\r
55 IN VOID *Source,\r
56 IN UINTN Length\r
57 )\r
58;\r
59\r
60INTN\r
61CompareGuid (\r
62 IN EFI_GUID *Guid1,\r
63 IN EFI_GUID *Guid2\r
64 )\r
65;\r
66\r
67EFI_STATUS\r
68GetFileImage (\r
69 IN CHAR8 *InputFileName,\r
70 OUT CHAR8 **InputFileImage,\r
71 OUT UINT32 *BytesRead\r
72 )\r
73;\r
74\r
75EFI_STATUS\r
76PutFileImage (\r
77 IN CHAR8 *OutputFileName,\r
78 IN CHAR8 *OutputFileImage,\r
79 IN UINT32 BytesToWrite\r
80 )\r
81;\r
82/*++\r
83\r
84Routine Description:\r
85\r
86 This function opens a file and writes OutputFileImage into the file.\r
87\r
88Arguments:\r
89\r
90 OutputFileName The name of the file to write.\r
91 OutputFileImage A pointer to the memory buffer.\r
92 BytesToWrite The size of the memory buffer.\r
93\r
94Returns:\r
95\r
96 EFI_SUCCESS The function completed successfully.\r
97 EFI_INVALID_PARAMETER One of the input parameters was invalid.\r
98 EFI_ABORTED An error occurred.\r
99 EFI_OUT_OF_RESOURCES No resource to complete operations.\r
100\r
101**/\r
102\r
103UINT8\r
104CalculateChecksum8 (\r
105 IN UINT8 *Buffer,\r
106 IN UINTN Size\r
107 )\r
108;\r
109\r
110UINT8\r
111CalculateSum8 (\r
112 IN UINT8 *Buffer,\r
113 IN UINTN Size\r
114 )\r
115;\r
116\r
117UINT16\r
118CalculateChecksum16 (\r
119 IN UINT16 *Buffer,\r
120 IN UINTN Size\r
121 )\r
122;\r
123\r
124UINT16\r
125CalculateSum16 (\r
126 IN UINT16 *Buffer,\r
127 IN UINTN Size\r
128 )\r
129;\r
130\r
131EFI_STATUS\r
132PrintGuid (\r
133 IN EFI_GUID *Guid\r
134 )\r
135;\r
136\r
137#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r
138EFI_STATUS\r
139PrintGuidToBuffer (\r
140 IN EFI_GUID *Guid,\r
141 IN OUT UINT8 *Buffer,\r
142 IN UINT32 BufferLen,\r
143 IN BOOLEAN Uppercase\r
144 )\r
145;\r
146\r
147#define ASSERT(x) assert(x)\r
148\r
149#ifdef __GNUC__\r
150#include <stdio.h>\r
151#include <sys/stat.h>\r
152#define stricmp strcasecmp\r
153#define _stricmp strcasecmp\r
154#define strnicmp strncasecmp\r
155#define strcmpi strcasecmp\r
156size_t _filelength(int fd);\r
157#ifndef __CYGWIN__\r
158char *strlwr(char *s);\r
159#endif\r
160#endif\r
161\r
162//\r
163// On windows, mkdir only has one parameter.\r
164// On unix, it has two parameters\r
165//\r
166#if defined(__GNUC__)\r
167#define mkdir(dir, perm) mkdir(dir, perm)\r
168#else\r
169#define mkdir(dir, perm) mkdir(dir)\r
170#endif\r
171\r
172#endif\r