]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004 - 2008, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | CommonLib.h\r | |
15 | \r | |
16 | Abstract:\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 | |
30 | VOID\r | |
31 | PeiZeroMem (\r | |
32 | IN VOID *Buffer,\r | |
33 | IN UINTN Size\r | |
34 | )\r | |
35 | ;\r | |
36 | \r | |
37 | VOID\r | |
38 | PeiCopyMem (\r | |
39 | IN VOID *Destination,\r | |
40 | IN VOID *Source,\r | |
41 | IN UINTN Length\r | |
42 | )\r | |
43 | ;\r | |
44 | \r | |
45 | VOID\r | |
46 | ZeroMem (\r | |
47 | IN VOID *Buffer,\r | |
48 | IN UINTN Size\r | |
49 | )\r | |
50 | ;\r | |
51 | \r | |
52 | VOID\r | |
53 | CopyMem (\r | |
54 | IN VOID *Destination,\r | |
55 | IN VOID *Source,\r | |
56 | IN UINTN Length\r | |
57 | )\r | |
58 | ;\r | |
59 | \r | |
60 | INTN\r | |
61 | CompareGuid (\r | |
62 | IN EFI_GUID *Guid1,\r | |
63 | IN EFI_GUID *Guid2\r | |
64 | )\r | |
65 | ;\r | |
66 | \r | |
67 | EFI_STATUS\r | |
68 | GetFileImage (\r | |
69 | IN CHAR8 *InputFileName,\r | |
70 | OUT CHAR8 **InputFileImage,\r | |
71 | OUT UINT32 *BytesRead\r | |
72 | )\r | |
73 | ;\r | |
74 | \r | |
75 | EFI_STATUS\r | |
76 | PutFileImage (\r | |
77 | IN CHAR8 *OutputFileName,\r | |
78 | IN CHAR8 *OutputFileImage,\r | |
79 | IN UINT32 BytesToWrite\r | |
80 | )\r | |
81 | ;\r | |
82 | /*++\r | |
83 | \r | |
84 | Routine Description:\r | |
85 | \r | |
86 | This function opens a file and writes OutputFileImage into the file.\r | |
87 | \r | |
88 | Arguments:\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 | |
94 | Returns:\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 | |
103 | UINT8\r | |
104 | CalculateChecksum8 (\r | |
105 | IN UINT8 *Buffer,\r | |
106 | IN UINTN Size\r | |
107 | )\r | |
108 | ;\r | |
109 | \r | |
110 | UINT8\r | |
111 | CalculateSum8 (\r | |
112 | IN UINT8 *Buffer,\r | |
113 | IN UINTN Size\r | |
114 | )\r | |
115 | ;\r | |
116 | \r | |
117 | UINT16\r | |
118 | CalculateChecksum16 (\r | |
119 | IN UINT16 *Buffer,\r | |
120 | IN UINTN Size\r | |
121 | )\r | |
122 | ;\r | |
123 | \r | |
124 | UINT16\r | |
125 | CalculateSum16 (\r | |
126 | IN UINT16 *Buffer,\r | |
127 | IN UINTN Size\r | |
128 | )\r | |
129 | ;\r | |
130 | \r | |
131 | EFI_STATUS\r | |
132 | PrintGuid (\r | |
133 | IN EFI_GUID *Guid\r | |
134 | )\r | |
135 | ;\r | |
136 | \r | |
137 | #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r | |
138 | EFI_STATUS\r | |
139 | PrintGuidToBuffer (\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 | |
156 | size_t _filelength(int fd);\r | |
157 | #ifndef __CYGWIN__\r | |
158 | char *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 |