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