]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/SafeIntLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Library / SafeIntLib.h
CommitLineData
d7a09cb8
SB
1/** @file\r
2 This library provides helper functions to prevent integer overflow during\r
3 type conversion, addition, subtraction, and multiplication.\r
4\r
5 Copyright (c) 2017, Microsoft Corporation\r
6\r
7 All rights reserved.\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d7a09cb8
SB
9\r
10**/\r
2f88bd3a 11\r
d7a09cb8
SB
12#ifndef __INT_SAFE_LIB_H__\r
13#define __INT_SAFE_LIB_H__\r
14\r
15//\r
16// It is common for -1 to be used as an error value\r
17//\r
18#define INT8_ERROR ((INT8) -1)\r
19#define UINT8_ERROR MAX_UINT8\r
20#define CHAR8_ERROR ((CHAR8)(MAX_INT8))\r
21#define INT16_ERROR ((INT16) -1)\r
22#define UINT16_ERROR MAX_UINT16\r
23#define CHAR16_ERROR MAX_UINT16\r
24#define INT32_ERROR ((INT32) -1)\r
25#define UINT32_ERROR MAX_UINT32\r
26#define INT64_ERROR ((INT64) -1)\r
27#define UINT64_ERROR MAX_UINT64\r
28#define INTN_ERROR ((INTN) -1)\r
29#define UINTN_ERROR MAX_UINTN\r
30\r
31//\r
32// CHAR16 is defined to be the same as UINT16, so for CHAR16\r
33// operations redirect to the UINT16 ones:\r
34//\r
35#define SafeInt8ToChar16 SafeInt8ToUint16\r
36#define SafeInt16ToChar16 SafeInt16ToUint16\r
37#define SafeInt32ToChar16 SafeInt32ToUint16\r
38#define SafeUint32ToChar16 SafeUint32ToUint16\r
39#define SafeInt64ToChar16 SafeInt64ToUint16\r
40#define SafeUint64ToChar16 SafeUint64ToUint16\r
41#define SafeIntnToChar16 SafeIntnToUint16\r
42#define SafeUintnToChar16 SafeUintnToUint16\r
43\r
2f88bd3a
MK
44#define SafeChar16ToInt8 SafeUint16ToInt8\r
45#define SafeChar16ToUint8 SafeUint16ToUint8\r
46#define SafeChar16ToChar8 SafeUint16ToChar8\r
47#define SafeChar16ToInt16 SafeUint16ToInt16\r
d7a09cb8 48\r
2f88bd3a
MK
49#define SafeChar16Mult SafeUint16Mult\r
50#define SafeChar16Sub SafeUint16Sub\r
51#define SafeChar16Add SafeUint16Add\r
d7a09cb8
SB
52\r
53//\r
54// Conversion functions\r
55//\r
56// There are three reasons for having conversion functions:\r
57//\r
58// 1. We are converting from a signed type to an unsigned type of the same\r
59// size, or vice-versa.\r
60//\r
61// 2. We are converting to a smaller type, and we could therefore possibly\r
62// overflow.\r
63//\r
64// 3. We are converting to a bigger type, and we are signed and the type we are\r
65// converting to is unsigned.\r
66//\r
67\r
68/**\r
69 INT8 -> UINT8 conversion\r
70\r
71 Converts the value specified by Operand to a value specified by Result type\r
72 and stores the converted value into the caller allocated output buffer\r
73 specified by Result. The caller must pass in a Result buffer that is at\r
74 least as large as the Result type.\r
75\r
76 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
77\r
78 If the conversion results in an overflow or an underflow condition, then\r
79 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
80\r
81 @param[in] Operand Operand to be converted to new type\r
82 @param[out] Result Pointer to the result of conversion\r
83\r
84 @retval RETURN_SUCCESS Successful conversion\r
85 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
86 @retval RETURN_INVALID_PARAMETER Result is NULL\r
87**/\r
88RETURN_STATUS\r
89EFIAPI\r
90SafeInt8ToUint8 (\r
91 IN INT8 Operand,\r
92 OUT UINT8 *Result\r
93 );\r
94\r
95/**\r
96 INT8 -> CHAR8 conversion\r
97\r
98 Converts the value specified by Operand to a value specified by Result type\r
99 and stores the converted value into the caller allocated output buffer\r
100 specified by Result. The caller must pass in a Result buffer that is at\r
101 least as large as the Result type.\r
102\r
103 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
104\r
105 If the conversion results in an overflow or an underflow condition, then\r
106 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
107\r
108 @param[in] Operand Operand to be converted to new type\r
109 @param[out] Result Pointer to the result of conversion\r
110\r
111 @retval RETURN_SUCCESS Successful conversion\r
112 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
113 @retval RETURN_INVALID_PARAMETER Result is NULL\r
114**/\r
115RETURN_STATUS\r
116EFIAPI\r
117SafeInt8ToChar8 (\r
118 IN INT8 Operand,\r
119 OUT CHAR8 *Result\r
120 );\r
121\r
122/**\r
123 INT8 -> UINT16 conversion\r
124\r
125 Converts the value specified by Operand to a value specified by Result type\r
126 and stores the converted value into the caller allocated output buffer\r
127 specified by Result. The caller must pass in a Result buffer that is at\r
128 least as large as the Result type.\r
129\r
130 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
131\r
132 If the conversion results in an overflow or an underflow condition, then\r
133 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
134\r
135 @param[in] Operand Operand to be converted to new type\r
136 @param[out] Result Pointer to the result of conversion\r
137\r
138 @retval RETURN_SUCCESS Successful conversion\r
139 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
140 @retval RETURN_INVALID_PARAMETER Result is NULL\r
141**/\r
142RETURN_STATUS\r
143EFIAPI\r
144SafeInt8ToUint16 (\r
145 IN INT8 Operand,\r
146 OUT UINT16 *Result\r
147 );\r
148\r
149/**\r
150 INT8 -> UINT32 conversion\r
151\r
152 Converts the value specified by Operand to a value specified by Result type\r
153 and stores the converted value into the caller allocated output buffer\r
154 specified by Result. The caller must pass in a Result buffer that is at\r
155 least as large as the Result type.\r
156\r
157 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
158\r
159 If the conversion results in an overflow or an underflow condition, then\r
160 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
161\r
162 @param[in] Operand Operand to be converted to new type\r
163 @param[out] Result Pointer to the result of conversion\r
164\r
165 @retval RETURN_SUCCESS Successful conversion\r
166 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
167 @retval RETURN_INVALID_PARAMETER Result is NULL\r
168**/\r
169RETURN_STATUS\r
170EFIAPI\r
171SafeInt8ToUint32 (\r
172 IN INT8 Operand,\r
173 OUT UINT32 *Result\r
174 );\r
175\r
176/**\r
177 INT8 -> UINTN conversion\r
178\r
179 Converts the value specified by Operand to a value specified by Result type\r
180 and stores the converted value into the caller allocated output buffer\r
181 specified by Result. The caller must pass in a Result buffer that is at\r
182 least as large as the Result type.\r
183\r
184 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
185\r
186 If the conversion results in an overflow or an underflow condition, then\r
187 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
188\r
189 @param[in] Operand Operand to be converted to new type\r
190 @param[out] Result Pointer to the result of conversion\r
191\r
192 @retval RETURN_SUCCESS Successful conversion\r
193 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
194 @retval RETURN_INVALID_PARAMETER Result is NULL\r
195**/\r
196RETURN_STATUS\r
197EFIAPI\r
198SafeInt8ToUintn (\r
199 IN INT8 Operand,\r
200 OUT UINTN *Result\r
201 );\r
202\r
203/**\r
204 INT8 -> UINT64 conversion\r
205\r
206 Converts the value specified by Operand to a value specified by Result type\r
207 and stores the converted value into the caller allocated output buffer\r
208 specified by Result. The caller must pass in a Result buffer that is at\r
209 least as large as the Result type.\r
210\r
211 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
212\r
213 If the conversion results in an overflow or an underflow condition, then\r
214 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
215\r
216 @param[in] Operand Operand to be converted to new type\r
217 @param[out] Result Pointer to the result of conversion\r
218\r
219 @retval RETURN_SUCCESS Successful conversion\r
220 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
221 @retval RETURN_INVALID_PARAMETER Result is NULL\r
222**/\r
223RETURN_STATUS\r
224EFIAPI\r
225SafeInt8ToUint64 (\r
226 IN INT8 Operand,\r
227 OUT UINT64 *Result\r
228 );\r
229\r
230/**\r
231 UINT8 -> INT8 conversion\r
232\r
233 Converts the value specified by Operand to a value specified by Result type\r
234 and stores the converted value into the caller allocated output buffer\r
235 specified by Result. The caller must pass in a Result buffer that is at\r
236 least as large as the Result type.\r
237\r
238 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
239\r
240 If the conversion results in an overflow or an underflow condition, then\r
241 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
242\r
243 @param[in] Operand Operand to be converted to new type\r
244 @param[out] Result Pointer to the result of conversion\r
245\r
246 @retval RETURN_SUCCESS Successful conversion\r
247 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
248 @retval RETURN_INVALID_PARAMETER Result is NULL\r
249**/\r
250RETURN_STATUS\r
251EFIAPI\r
252SafeUint8ToInt8 (\r
253 IN UINT8 Operand,\r
254 OUT INT8 *Result\r
255 );\r
256\r
257/**\r
258 UINT8 -> CHAR8 conversion\r
259\r
260 Converts the value specified by Operand to a value specified by Result type\r
261 and stores the converted value into the caller allocated output buffer\r
262 specified by Result. The caller must pass in a Result buffer that is at\r
263 least as large as the Result type.\r
264\r
265 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
266\r
267 If the conversion results in an overflow or an underflow condition, then\r
268 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
269\r
270 @param[in] Operand Operand to be converted to new type\r
271 @param[out] Result Pointer to the result of conversion\r
272\r
273 @retval RETURN_SUCCESS Successful conversion\r
274 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
275 @retval RETURN_INVALID_PARAMETER Result is NULL\r
276**/\r
277RETURN_STATUS\r
278EFIAPI\r
279SafeUint8ToChar8 (\r
280 IN UINT8 Operand,\r
281 OUT CHAR8 *Result\r
282 );\r
283\r
284/**\r
285 INT16 -> INT8 conversion\r
286\r
287 Converts the value specified by Operand to a value specified by Result type\r
288 and stores the converted value into the caller allocated output buffer\r
289 specified by Result. The caller must pass in a Result buffer that is at\r
290 least as large as the Result type.\r
291\r
292 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
293\r
294 If the conversion results in an overflow or an underflow condition, then\r
295 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
296\r
297 @param[in] Operand Operand to be converted to new type\r
298 @param[out] Result Pointer to the result of conversion\r
299\r
300 @retval RETURN_SUCCESS Successful conversion\r
301 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
302 @retval RETURN_INVALID_PARAMETER Result is NULL\r
303**/\r
304RETURN_STATUS\r
305EFIAPI\r
306SafeInt16ToInt8 (\r
307 IN INT16 Operand,\r
308 OUT INT8 *Result\r
309 );\r
310\r
311/**\r
312 INT16 -> CHAR8 conversion\r
313\r
314 Converts the value specified by Operand to a value specified by Result type\r
315 and stores the converted value into the caller allocated output buffer\r
316 specified by Result. The caller must pass in a Result buffer that is at\r
317 least as large as the Result type.\r
318\r
319 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
320\r
321 If the conversion results in an overflow or an underflow condition, then\r
322 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
323\r
324 @param[in] Operand Operand to be converted to new type\r
325 @param[out] Result Pointer to the result of conversion\r
326\r
327 @retval RETURN_SUCCESS Successful conversion\r
328 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
329 @retval RETURN_INVALID_PARAMETER Result is NULL\r
330**/\r
331RETURN_STATUS\r
332EFIAPI\r
333SafeInt16ToChar8 (\r
334 IN INT16 Operand,\r
335 OUT CHAR8 *Result\r
336 );\r
337\r
338/**\r
339 INT16 -> UINT8 conversion\r
340\r
341 Converts the value specified by Operand to a value specified by Result type\r
342 and stores the converted value into the caller allocated output buffer\r
343 specified by Result. The caller must pass in a Result buffer that is at\r
344 least as large as the Result type.\r
345\r
346 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
347\r
348 If the conversion results in an overflow or an underflow condition, then\r
349 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
350\r
351 @param[in] Operand Operand to be converted to new type\r
352 @param[out] Result Pointer to the result of conversion\r
353\r
354 @retval RETURN_SUCCESS Successful conversion\r
355 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
356 @retval RETURN_INVALID_PARAMETER Result is NULL\r
357**/\r
358RETURN_STATUS\r
359EFIAPI\r
360SafeInt16ToUint8 (\r
2f88bd3a
MK
361 IN INT16 Operand,\r
362 OUT UINT8 *Result\r
d7a09cb8
SB
363 );\r
364\r
365/**\r
366 INT16 -> UINT16 conversion\r
367\r
368 Converts the value specified by Operand to a value specified by Result type\r
369 and stores the converted value into the caller allocated output buffer\r
370 specified by Result. The caller must pass in a Result buffer that is at\r
371 least as large as the Result type.\r
372\r
373 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
374\r
375 If the conversion results in an overflow or an underflow condition, then\r
376 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
377\r
378 @param[in] Operand Operand to be converted to new type\r
379 @param[out] Result Pointer to the result of conversion\r
380\r
381 @retval RETURN_SUCCESS Successful conversion\r
382 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
383 @retval RETURN_INVALID_PARAMETER Result is NULL\r
384**/\r
385RETURN_STATUS\r
386EFIAPI\r
387SafeInt16ToUint16 (\r
388 IN INT16 Operand,\r
389 OUT UINT16 *Result\r
390 );\r
391\r
392/**\r
393 INT16 -> UINT32 conversion\r
394\r
395 Converts the value specified by Operand to a value specified by Result type\r
396 and stores the converted value into the caller allocated output buffer\r
397 specified by Result. The caller must pass in a Result buffer that is at\r
398 least as large as the Result type.\r
399\r
400 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
401\r
402 If the conversion results in an overflow or an underflow condition, then\r
403 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
404\r
405 @param[in] Operand Operand to be converted to new type\r
406 @param[out] Result Pointer to the result of conversion\r
407\r
408 @retval RETURN_SUCCESS Successful conversion\r
409 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
410 @retval RETURN_INVALID_PARAMETER Result is NULL\r
411**/\r
412RETURN_STATUS\r
413EFIAPI\r
414SafeInt16ToUint32 (\r
415 IN INT16 Operand,\r
416 OUT UINT32 *Result\r
417 );\r
418\r
419/**\r
420 INT16 -> UINTN conversion\r
421\r
422 Converts the value specified by Operand to a value specified by Result type\r
423 and stores the converted value into the caller allocated output buffer\r
424 specified by Result. The caller must pass in a Result buffer that is at\r
425 least as large as the Result type.\r
426\r
427 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
428\r
429 If the conversion results in an overflow or an underflow condition, then\r
430 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
431\r
432 @param[in] Operand Operand to be converted to new type\r
433 @param[out] Result Pointer to the result of conversion\r
434\r
435 @retval RETURN_SUCCESS Successful conversion\r
436 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
437 @retval RETURN_INVALID_PARAMETER Result is NULL\r
438**/\r
439RETURN_STATUS\r
440EFIAPI\r
441SafeInt16ToUintn (\r
442 IN INT16 Operand,\r
443 OUT UINTN *Result\r
444 );\r
445\r
446/**\r
447 INT16 -> UINT64 conversion\r
448\r
449 Converts the value specified by Operand to a value specified by Result type\r
450 and stores the converted value into the caller allocated output buffer\r
451 specified by Result. The caller must pass in a Result buffer that is at\r
452 least as large as the Result type.\r
453\r
454 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
455\r
456 If the conversion results in an overflow or an underflow condition, then\r
457 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
458\r
459 @param[in] Operand Operand to be converted to new type\r
460 @param[out] Result Pointer to the result of conversion\r
461\r
462 @retval RETURN_SUCCESS Successful conversion\r
463 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
464 @retval RETURN_INVALID_PARAMETER Result is NULL\r
465**/\r
466RETURN_STATUS\r
467EFIAPI\r
468SafeInt16ToUint64 (\r
469 IN INT16 Operand,\r
470 OUT UINT64 *Result\r
471 );\r
472\r
473/**\r
474 UINT16 -> INT8 conversion\r
475\r
476 Converts the value specified by Operand to a value specified by Result type\r
477 and stores the converted value into the caller allocated output buffer\r
478 specified by Result. The caller must pass in a Result buffer that is at\r
479 least as large as the Result type.\r
480\r
481 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
482\r
483 If the conversion results in an overflow or an underflow condition, then\r
484 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
485\r
486 @param[in] Operand Operand to be converted to new type\r
487 @param[out] Result Pointer to the result of conversion\r
488\r
489 @retval RETURN_SUCCESS Successful conversion\r
490 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
491 @retval RETURN_INVALID_PARAMETER Result is NULL\r
492**/\r
493RETURN_STATUS\r
494EFIAPI\r
495SafeUint16ToInt8 (\r
496 IN UINT16 Operand,\r
497 OUT INT8 *Result\r
498 );\r
499\r
500/**\r
501 UINT16 -> CHAR8 conversion\r
502\r
503 Converts the value specified by Operand to a value specified by Result type\r
504 and stores the converted value into the caller allocated output buffer\r
505 specified by Result. The caller must pass in a Result buffer that is at\r
506 least as large as the Result type.\r
507\r
508 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
509\r
510 If the conversion results in an overflow or an underflow condition, then\r
511 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
512\r
513 @param[in] Operand Operand to be converted to new type\r
514 @param[out] Result Pointer to the result of conversion\r
515\r
516 @retval RETURN_SUCCESS Successful conversion\r
517 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
518 @retval RETURN_INVALID_PARAMETER Result is NULL\r
519**/\r
520RETURN_STATUS\r
521EFIAPI\r
522SafeUint16ToChar8 (\r
523 IN UINT16 Operand,\r
524 OUT CHAR8 *Result\r
525 );\r
526\r
527/**\r
528 UINT16 -> UINT8 conversion\r
529\r
530 Converts the value specified by Operand to a value specified by Result type\r
531 and stores the converted value into the caller allocated output buffer\r
532 specified by Result. The caller must pass in a Result buffer that is at\r
533 least as large as the Result type.\r
534\r
535 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
536\r
537 If the conversion results in an overflow or an underflow condition, then\r
538 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
539\r
540 @param[in] Operand Operand to be converted to new type\r
541 @param[out] Result Pointer to the result of conversion\r
542\r
543 @retval RETURN_SUCCESS Successful conversion\r
544 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
545 @retval RETURN_INVALID_PARAMETER Result is NULL\r
546**/\r
547RETURN_STATUS\r
548EFIAPI\r
549SafeUint16ToUint8 (\r
2f88bd3a
MK
550 IN UINT16 Operand,\r
551 OUT UINT8 *Result\r
d7a09cb8
SB
552 );\r
553\r
554/**\r
555 UINT16 -> INT16 conversion\r
556\r
557 Converts the value specified by Operand to a value specified by Result type\r
558 and stores the converted value into the caller allocated output buffer\r
559 specified by Result. The caller must pass in a Result buffer that is at\r
560 least as large as the Result type.\r
561\r
562 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
563\r
564 If the conversion results in an overflow or an underflow condition, then\r
565 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
566\r
567 @param[in] Operand Operand to be converted to new type\r
568 @param[out] Result Pointer to the result of conversion\r
569\r
570 @retval RETURN_SUCCESS Successful conversion\r
571 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
572 @retval RETURN_INVALID_PARAMETER Result is NULL\r
573**/\r
574RETURN_STATUS\r
575EFIAPI\r
576SafeUint16ToInt16 (\r
577 IN UINT16 Operand,\r
578 OUT INT16 *Result\r
579 );\r
580\r
581/**\r
582 INT32 -> INT8 conversion\r
583\r
584 Converts the value specified by Operand to a value specified by Result type\r
585 and stores the converted value into the caller allocated output buffer\r
586 specified by Result. The caller must pass in a Result buffer that is at\r
587 least as large as the Result type.\r
588\r
589 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
590\r
591 If the conversion results in an overflow or an underflow condition, then\r
592 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
593\r
594 @param[in] Operand Operand to be converted to new type\r
595 @param[out] Result Pointer to the result of conversion\r
596\r
597 @retval RETURN_SUCCESS Successful conversion\r
598 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
599 @retval RETURN_INVALID_PARAMETER Result is NULL\r
600**/\r
601RETURN_STATUS\r
602EFIAPI\r
603SafeInt32ToInt8 (\r
604 IN INT32 Operand,\r
605 OUT INT8 *Result\r
606 );\r
607\r
608/**\r
609 INT32 -> CHAR8 conversion\r
610\r
611 Converts the value specified by Operand to a value specified by Result type\r
612 and stores the converted value into the caller allocated output buffer\r
613 specified by Result. The caller must pass in a Result buffer that is at\r
614 least as large as the Result type.\r
615\r
616 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
617\r
618 If the conversion results in an overflow or an underflow condition, then\r
619 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
620\r
621 @param[in] Operand Operand to be converted to new type\r
622 @param[out] Result Pointer to the result of conversion\r
623\r
624 @retval RETURN_SUCCESS Successful conversion\r
625 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
626 @retval RETURN_INVALID_PARAMETER Result is NULL\r
627**/\r
628RETURN_STATUS\r
629EFIAPI\r
630SafeInt32ToChar8 (\r
631 IN INT32 Operand,\r
632 OUT CHAR8 *Result\r
633 );\r
634\r
635/**\r
636 INT32 -> UINT8 conversion\r
637\r
638 Converts the value specified by Operand to a value specified by Result type\r
639 and stores the converted value into the caller allocated output buffer\r
640 specified by Result. The caller must pass in a Result buffer that is at\r
641 least as large as the Result type.\r
642\r
643 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
644\r
645 If the conversion results in an overflow or an underflow condition, then\r
646 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
647\r
648 @param[in] Operand Operand to be converted to new type\r
649 @param[out] Result Pointer to the result of conversion\r
650\r
651 @retval RETURN_SUCCESS Successful conversion\r
652 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
653 @retval RETURN_INVALID_PARAMETER Result is NULL\r
654**/\r
655RETURN_STATUS\r
656EFIAPI\r
657SafeInt32ToUint8 (\r
2f88bd3a
MK
658 IN INT32 Operand,\r
659 OUT UINT8 *Result\r
d7a09cb8
SB
660 );\r
661\r
662/**\r
663 INT32 -> INT16 conversion\r
664\r
665 Converts the value specified by Operand to a value specified by Result type\r
666 and stores the converted value into the caller allocated output buffer\r
667 specified by Result. The caller must pass in a Result buffer that is at\r
668 least as large as the Result type.\r
669\r
670 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
671\r
672 If the conversion results in an overflow or an underflow condition, then\r
673 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
674\r
675 @param[in] Operand Operand to be converted to new type\r
676 @param[out] Result Pointer to the result of conversion\r
677\r
678 @retval RETURN_SUCCESS Successful conversion\r
679 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
680 @retval RETURN_INVALID_PARAMETER Result is NULL\r
681**/\r
682RETURN_STATUS\r
683EFIAPI\r
684SafeInt32ToInt16 (\r
685 IN INT32 Operand,\r
686 OUT INT16 *Result\r
687 );\r
688\r
689/**\r
690 INT32 -> UINT16 conversion\r
691\r
692 Converts the value specified by Operand to a value specified by Result type\r
693 and stores the converted value into the caller allocated output buffer\r
694 specified by Result. The caller must pass in a Result buffer that is at\r
695 least as large as the Result type.\r
696\r
697 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
698\r
699 If the conversion results in an overflow or an underflow condition, then\r
700 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
701\r
702 @param[in] Operand Operand to be converted to new type\r
703 @param[out] Result Pointer to the result of conversion\r
704\r
705 @retval RETURN_SUCCESS Successful conversion\r
706 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
707 @retval RETURN_INVALID_PARAMETER Result is NULL\r
708**/\r
709RETURN_STATUS\r
710EFIAPI\r
711SafeInt32ToUint16 (\r
712 IN INT32 Operand,\r
713 OUT UINT16 *Result\r
714 );\r
715\r
d7a09cb8
SB
716/**\r
717 INT32 -> UINT32 conversion\r
718\r
719 Converts the value specified by Operand to a value specified by Result type\r
720 and stores the converted value into the caller allocated output buffer\r
721 specified by Result. The caller must pass in a Result buffer that is at\r
722 least as large as the Result type.\r
723\r
724 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
725\r
726 If the conversion results in an overflow or an underflow condition, then\r
727 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
728\r
729 @param[in] Operand Operand to be converted to new type\r
730 @param[out] Result Pointer to the result of conversion\r
731\r
732 @retval RETURN_SUCCESS Successful conversion\r
733 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
734 @retval RETURN_INVALID_PARAMETER Result is NULL\r
735**/\r
736RETURN_STATUS\r
737EFIAPI\r
738SafeInt32ToUint32 (\r
739 IN INT32 Operand,\r
740 OUT UINT32 *Result\r
741 );\r
742\r
743/**\r
744 INT32 -> UINTN conversion\r
745\r
746 Converts the value specified by Operand to a value specified by Result type\r
747 and stores the converted value into the caller allocated output buffer\r
748 specified by Result. The caller must pass in a Result buffer that is at\r
749 least as large as the Result type.\r
750\r
751 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
752\r
753 If the conversion results in an overflow or an underflow condition, then\r
754 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
755\r
756 @param[in] Operand Operand to be converted to new type\r
757 @param[out] Result Pointer to the result of conversion\r
758\r
759 @retval RETURN_SUCCESS Successful conversion\r
760 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
761 @retval RETURN_INVALID_PARAMETER Result is NULL\r
762**/\r
763RETURN_STATUS\r
764EFIAPI\r
765SafeInt32ToUintn (\r
766 IN INT32 Operand,\r
767 OUT UINTN *Result\r
768 );\r
769\r
770/**\r
771 INT32 -> UINT64 conversion\r
772\r
773 Converts the value specified by Operand to a value specified by Result type\r
774 and stores the converted value into the caller allocated output buffer\r
775 specified by Result. The caller must pass in a Result buffer that is at\r
776 least as large as the Result type.\r
777\r
778 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
779\r
780 If the conversion results in an overflow or an underflow condition, then\r
781 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
782\r
783 @param[in] Operand Operand to be converted to new type\r
784 @param[out] Result Pointer to the result of conversion\r
785\r
786 @retval RETURN_SUCCESS Successful conversion\r
787 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
788 @retval RETURN_INVALID_PARAMETER Result is NULL\r
789**/\r
790RETURN_STATUS\r
791EFIAPI\r
792SafeInt32ToUint64 (\r
793 IN INT32 Operand,\r
794 OUT UINT64 *Result\r
795 );\r
796\r
797/**\r
798 UINT32 -> INT8 conversion\r
799\r
800 Converts the value specified by Operand to a value specified by Result type\r
801 and stores the converted value into the caller allocated output buffer\r
802 specified by Result. The caller must pass in a Result buffer that is at\r
803 least as large as the Result type.\r
804\r
805 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
806\r
807 If the conversion results in an overflow or an underflow condition, then\r
808 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
809\r
810 @param[in] Operand Operand to be converted to new type\r
811 @param[out] Result Pointer to the result of conversion\r
812\r
813 @retval RETURN_SUCCESS Successful conversion\r
814 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
815 @retval RETURN_INVALID_PARAMETER Result is NULL\r
816**/\r
817RETURN_STATUS\r
818EFIAPI\r
819SafeUint32ToInt8 (\r
820 IN UINT32 Operand,\r
821 OUT INT8 *Result\r
822 );\r
823\r
824/**\r
825 UINT32 -> CHAR8 conversion\r
826\r
827 Converts the value specified by Operand to a value specified by Result type\r
828 and stores the converted value into the caller allocated output buffer\r
829 specified by Result. The caller must pass in a Result buffer that is at\r
830 least as large as the Result type.\r
831\r
832 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
833\r
834 If the conversion results in an overflow or an underflow condition, then\r
835 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
836\r
837 @param[in] Operand Operand to be converted to new type\r
838 @param[out] Result Pointer to the result of conversion\r
839\r
840 @retval RETURN_SUCCESS Successful conversion\r
841 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
842 @retval RETURN_INVALID_PARAMETER Result is NULL\r
843**/\r
844RETURN_STATUS\r
845EFIAPI\r
846SafeUint32ToChar8 (\r
847 IN UINT32 Operand,\r
848 OUT CHAR8 *Result\r
849 );\r
850\r
851/**\r
852 UINT32 -> UINT8 conversion\r
853\r
854 Converts the value specified by Operand to a value specified by Result type\r
855 and stores the converted value into the caller allocated output buffer\r
856 specified by Result. The caller must pass in a Result buffer that is at\r
857 least as large as the Result type.\r
858\r
859 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
860\r
861 If the conversion results in an overflow or an underflow condition, then\r
862 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
863\r
864 @param[in] Operand Operand to be converted to new type\r
865 @param[out] Result Pointer to the result of conversion\r
866\r
867 @retval RETURN_SUCCESS Successful conversion\r
868 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
869 @retval RETURN_INVALID_PARAMETER Result is NULL\r
870**/\r
871RETURN_STATUS\r
872EFIAPI\r
873SafeUint32ToUint8 (\r
2f88bd3a
MK
874 IN UINT32 Operand,\r
875 OUT UINT8 *Result\r
d7a09cb8
SB
876 );\r
877\r
878/**\r
879 UINT32 -> INT16 conversion\r
880\r
881 Converts the value specified by Operand to a value specified by Result type\r
882 and stores the converted value into the caller allocated output buffer\r
883 specified by Result. The caller must pass in a Result buffer that is at\r
884 least as large as the Result type.\r
885\r
886 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
887\r
888 If the conversion results in an overflow or an underflow condition, then\r
889 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
890\r
891 @param[in] Operand Operand to be converted to new type\r
892 @param[out] Result Pointer to the result of conversion\r
893\r
894 @retval RETURN_SUCCESS Successful conversion\r
895 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
896 @retval RETURN_INVALID_PARAMETER Result is NULL\r
897**/\r
898RETURN_STATUS\r
899EFIAPI\r
900SafeUint32ToInt16 (\r
901 IN UINT32 Operand,\r
902 OUT INT16 *Result\r
903 );\r
904\r
905/**\r
906 UINT32 -> UINT16 conversion\r
907\r
908 Converts the value specified by Operand to a value specified by Result type\r
909 and stores the converted value into the caller allocated output buffer\r
910 specified by Result. The caller must pass in a Result buffer that is at\r
911 least as large as the Result type.\r
912\r
913 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
914\r
915 If the conversion results in an overflow or an underflow condition, then\r
916 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
917\r
918 @param[in] Operand Operand to be converted to new type\r
919 @param[out] Result Pointer to the result of conversion\r
920\r
921 @retval RETURN_SUCCESS Successful conversion\r
922 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
923 @retval RETURN_INVALID_PARAMETER Result is NULL\r
924**/\r
925RETURN_STATUS\r
926EFIAPI\r
927SafeUint32ToUint16 (\r
928 IN UINT32 Operand,\r
929 OUT UINT16 *Result\r
930 );\r
931\r
932/**\r
933 UINT32 -> INT32 conversion\r
934\r
935 Converts the value specified by Operand to a value specified by Result type\r
936 and stores the converted value into the caller allocated output buffer\r
937 specified by Result. The caller must pass in a Result buffer that is at\r
938 least as large as the Result type.\r
939\r
940 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
941\r
942 If the conversion results in an overflow or an underflow condition, then\r
943 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
944\r
945 @param[in] Operand Operand to be converted to new type\r
946 @param[out] Result Pointer to the result of conversion\r
947\r
948 @retval RETURN_SUCCESS Successful conversion\r
949 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
950 @retval RETURN_INVALID_PARAMETER Result is NULL\r
951**/\r
952RETURN_STATUS\r
953EFIAPI\r
954SafeUint32ToInt32 (\r
955 IN UINT32 Operand,\r
956 OUT INT32 *Result\r
957 );\r
958\r
959/**\r
960 UINT32 -> INTN conversion\r
961\r
962 Converts the value specified by Operand to a value specified by Result type\r
963 and stores the converted value into the caller allocated output buffer\r
964 specified by Result. The caller must pass in a Result buffer that is at\r
965 least as large as the Result type.\r
966\r
967 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
968\r
969 If the conversion results in an overflow or an underflow condition, then\r
970 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
971\r
972 @param[in] Operand Operand to be converted to new type\r
973 @param[out] Result Pointer to the result of conversion\r
974\r
975 @retval RETURN_SUCCESS Successful conversion\r
976 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
977 @retval RETURN_INVALID_PARAMETER Result is NULL\r
978**/\r
979RETURN_STATUS\r
980EFIAPI\r
981SafeUint32ToIntn (\r
982 IN UINT32 Operand,\r
983 OUT INTN *Result\r
984 );\r
985\r
986/**\r
987 INTN -> INT8 conversion\r
988\r
989 Converts the value specified by Operand to a value specified by Result type\r
990 and stores the converted value into the caller allocated output buffer\r
991 specified by Result. The caller must pass in a Result buffer that is at\r
992 least as large as the Result type.\r
993\r
994 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
995\r
996 If the conversion results in an overflow or an underflow condition, then\r
997 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
998\r
999 @param[in] Operand Operand to be converted to new type\r
1000 @param[out] Result Pointer to the result of conversion\r
1001\r
1002 @retval RETURN_SUCCESS Successful conversion\r
1003 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1004 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1005**/\r
1006RETURN_STATUS\r
1007EFIAPI\r
1008SafeIntnToInt8 (\r
1009 IN INTN Operand,\r
1010 OUT INT8 *Result\r
1011 );\r
1012\r
1013/**\r
1014 INTN -> CHAR8 conversion\r
1015\r
1016 Converts the value specified by Operand to a value specified by Result type\r
1017 and stores the converted value into the caller allocated output buffer\r
1018 specified by Result. The caller must pass in a Result buffer that is at\r
1019 least as large as the Result type.\r
1020\r
1021 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1022\r
1023 If the conversion results in an overflow or an underflow condition, then\r
1024 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1025\r
1026 @param[in] Operand Operand to be converted to new type\r
1027 @param[out] Result Pointer to the result of conversion\r
1028\r
1029 @retval RETURN_SUCCESS Successful conversion\r
1030 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1031 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1032**/\r
1033RETURN_STATUS\r
1034EFIAPI\r
1035SafeIntnToChar8 (\r
1036 IN INTN Operand,\r
1037 OUT CHAR8 *Result\r
1038 );\r
1039\r
1040/**\r
1041 INTN -> UINT8 conversion\r
1042\r
1043 Converts the value specified by Operand to a value specified by Result type\r
1044 and stores the converted value into the caller allocated output buffer\r
1045 specified by Result. The caller must pass in a Result buffer that is at\r
1046 least as large as the Result type.\r
1047\r
1048 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1049\r
1050 If the conversion results in an overflow or an underflow condition, then\r
1051 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1052\r
1053 @param[in] Operand Operand to be converted to new type\r
1054 @param[out] Result Pointer to the result of conversion\r
1055\r
1056 @retval RETURN_SUCCESS Successful conversion\r
1057 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1058 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1059**/\r
1060RETURN_STATUS\r
1061EFIAPI\r
1062SafeIntnToUint8 (\r
2f88bd3a
MK
1063 IN INTN Operand,\r
1064 OUT UINT8 *Result\r
d7a09cb8
SB
1065 );\r
1066\r
1067/**\r
1068 INTN -> INT16 conversion\r
1069\r
1070 Converts the value specified by Operand to a value specified by Result type\r
1071 and stores the converted value into the caller allocated output buffer\r
1072 specified by Result. The caller must pass in a Result buffer that is at\r
1073 least as large as the Result type.\r
1074\r
1075 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1076\r
1077 If the conversion results in an overflow or an underflow condition, then\r
1078 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1079\r
1080 @param[in] Operand Operand to be converted to new type\r
1081 @param[out] Result Pointer to the result of conversion\r
1082\r
1083 @retval RETURN_SUCCESS Successful conversion\r
1084 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1085 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1086**/\r
1087RETURN_STATUS\r
1088EFIAPI\r
1089SafeIntnToInt16 (\r
1090 IN INTN Operand,\r
1091 OUT INT16 *Result\r
1092 );\r
1093\r
1094/**\r
1095 INTN -> UINT16 conversion\r
1096\r
1097 Converts the value specified by Operand to a value specified by Result type\r
1098 and stores the converted value into the caller allocated output buffer\r
1099 specified by Result. The caller must pass in a Result buffer that is at\r
1100 least as large as the Result type.\r
1101\r
1102 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1103\r
1104 If the conversion results in an overflow or an underflow condition, then\r
1105 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1106\r
1107 @param[in] Operand Operand to be converted to new type\r
1108 @param[out] Result Pointer to the result of conversion\r
1109\r
1110 @retval RETURN_SUCCESS Successful conversion\r
1111 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1112 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1113**/\r
1114RETURN_STATUS\r
1115EFIAPI\r
1116SafeIntnToUint16 (\r
1117 IN INTN Operand,\r
1118 OUT UINT16 *Result\r
1119 );\r
1120\r
1121/**\r
1122 INTN -> INT32 conversion\r
1123\r
1124 Converts the value specified by Operand to a value specified by Result type\r
1125 and stores the converted value into the caller allocated output buffer\r
1126 specified by Result. The caller must pass in a Result buffer that is at\r
1127 least as large as the Result type.\r
1128\r
1129 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1130\r
1131 If the conversion results in an overflow or an underflow condition, then\r
1132 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1133\r
1134 @param[in] Operand Operand to be converted to new type\r
1135 @param[out] Result Pointer to the result of conversion\r
1136\r
1137 @retval RETURN_SUCCESS Successful conversion\r
1138 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1139 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1140**/\r
1141RETURN_STATUS\r
1142EFIAPI\r
1143SafeIntnToInt32 (\r
1144 IN INTN Operand,\r
1145 OUT INT32 *Result\r
1146 );\r
1147\r
1148/**\r
1149 INTN -> UINT32 conversion\r
1150\r
1151 Converts the value specified by Operand to a value specified by Result type\r
1152 and stores the converted value into the caller allocated output buffer\r
1153 specified by Result. The caller must pass in a Result buffer that is at\r
1154 least as large as the Result type.\r
1155\r
1156 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1157\r
1158 If the conversion results in an overflow or an underflow condition, then\r
1159 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1160\r
1161 @param[in] Operand Operand to be converted to new type\r
1162 @param[out] Result Pointer to the result of conversion\r
1163\r
1164 @retval RETURN_SUCCESS Successful conversion\r
1165 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1166 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1167**/\r
1168RETURN_STATUS\r
1169EFIAPI\r
1170SafeIntnToUint32 (\r
1171 IN INTN Operand,\r
1172 OUT UINT32 *Result\r
1173 );\r
1174\r
1175/**\r
1176 INTN -> UINTN conversion\r
1177\r
1178 Converts the value specified by Operand to a value specified by Result type\r
1179 and stores the converted value into the caller allocated output buffer\r
1180 specified by Result. The caller must pass in a Result buffer that is at\r
1181 least as large as the Result type.\r
1182\r
1183 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1184\r
1185 If the conversion results in an overflow or an underflow condition, then\r
1186 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1187\r
1188 @param[in] Operand Operand to be converted to new type\r
1189 @param[out] Result Pointer to the result of conversion\r
1190\r
1191 @retval RETURN_SUCCESS Successful conversion\r
1192 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1193 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1194**/\r
1195RETURN_STATUS\r
1196EFIAPI\r
1197SafeIntnToUintn (\r
1198 IN INTN Operand,\r
1199 OUT UINTN *Result\r
1200 );\r
1201\r
1202/**\r
1203 INTN -> UINT64 conversion\r
1204\r
1205 Converts the value specified by Operand to a value specified by Result type\r
1206 and stores the converted value into the caller allocated output buffer\r
1207 specified by Result. The caller must pass in a Result buffer that is at\r
1208 least as large as the Result type.\r
1209\r
1210 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1211\r
1212 If the conversion results in an overflow or an underflow condition, then\r
1213 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1214\r
1215 @param[in] Operand Operand to be converted to new type\r
1216 @param[out] Result Pointer to the result of conversion\r
1217\r
1218 @retval RETURN_SUCCESS Successful conversion\r
1219 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1220 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1221**/\r
1222RETURN_STATUS\r
1223EFIAPI\r
1224SafeIntnToUint64 (\r
1225 IN INTN Operand,\r
1226 OUT UINT64 *Result\r
1227 );\r
1228\r
1229/**\r
1230 UINTN -> INT8 conversion\r
1231\r
1232 Converts the value specified by Operand to a value specified by Result type\r
1233 and stores the converted value into the caller allocated output buffer\r
1234 specified by Result. The caller must pass in a Result buffer that is at\r
1235 least as large as the Result type.\r
1236\r
1237 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1238\r
1239 If the conversion results in an overflow or an underflow condition, then\r
1240 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1241\r
1242 @param[in] Operand Operand to be converted to new type\r
1243 @param[out] Result Pointer to the result of conversion\r
1244\r
1245 @retval RETURN_SUCCESS Successful conversion\r
1246 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1247 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1248**/\r
1249RETURN_STATUS\r
1250EFIAPI\r
1251SafeUintnToInt8 (\r
1252 IN UINTN Operand,\r
1253 OUT INT8 *Result\r
1254 );\r
1255\r
1256/**\r
1257 UINTN -> CHAR8 conversion\r
1258\r
1259 Converts the value specified by Operand to a value specified by Result type\r
1260 and stores the converted value into the caller allocated output buffer\r
1261 specified by Result. The caller must pass in a Result buffer that is at\r
1262 least as large as the Result type.\r
1263\r
1264 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1265\r
1266 If the conversion results in an overflow or an underflow condition, then\r
1267 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1268\r
1269 @param[in] Operand Operand to be converted to new type\r
1270 @param[out] Result Pointer to the result of conversion\r
1271\r
1272 @retval RETURN_SUCCESS Successful conversion\r
1273 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1274 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1275**/\r
1276RETURN_STATUS\r
1277EFIAPI\r
1278SafeUintnToChar8 (\r
1279 IN UINTN Operand,\r
1280 OUT CHAR8 *Result\r
1281 );\r
1282\r
1283/**\r
1284 UINTN -> UINT8 conversion\r
1285\r
1286 Converts the value specified by Operand to a value specified by Result type\r
1287 and stores the converted value into the caller allocated output buffer\r
1288 specified by Result. The caller must pass in a Result buffer that is at\r
1289 least as large as the Result type.\r
1290\r
1291 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1292\r
1293 If the conversion results in an overflow or an underflow condition, then\r
1294 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1295\r
1296 @param[in] Operand Operand to be converted to new type\r
1297 @param[out] Result Pointer to the result of conversion\r
1298\r
1299 @retval RETURN_SUCCESS Successful conversion\r
1300 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1301 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1302**/\r
1303RETURN_STATUS\r
1304EFIAPI\r
1305SafeUintnToUint8 (\r
2f88bd3a
MK
1306 IN UINTN Operand,\r
1307 OUT UINT8 *Result\r
d7a09cb8
SB
1308 );\r
1309\r
1310/**\r
1311 UINTN -> INT16 conversion\r
1312\r
1313 Converts the value specified by Operand to a value specified by Result type\r
1314 and stores the converted value into the caller allocated output buffer\r
1315 specified by Result. The caller must pass in a Result buffer that is at\r
1316 least as large as the Result type.\r
1317\r
1318 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1319\r
1320 If the conversion results in an overflow or an underflow condition, then\r
1321 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1322\r
1323 @param[in] Operand Operand to be converted to new type\r
1324 @param[out] Result Pointer to the result of conversion\r
1325\r
1326 @retval RETURN_SUCCESS Successful conversion\r
1327 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1328 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1329**/\r
1330RETURN_STATUS\r
1331EFIAPI\r
1332SafeUintnToInt16 (\r
1333 IN UINTN Operand,\r
1334 OUT INT16 *Result\r
1335 );\r
1336\r
1337/**\r
1338 UINTN -> UINT16 conversion\r
1339\r
1340 Converts the value specified by Operand to a value specified by Result type\r
1341 and stores the converted value into the caller allocated output buffer\r
1342 specified by Result. The caller must pass in a Result buffer that is at\r
1343 least as large as the Result type.\r
1344\r
1345 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1346\r
1347 If the conversion results in an overflow or an underflow condition, then\r
1348 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1349\r
1350 @param[in] Operand Operand to be converted to new type\r
1351 @param[out] Result Pointer to the result of conversion\r
1352\r
1353 @retval RETURN_SUCCESS Successful conversion\r
1354 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1355 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1356**/\r
1357RETURN_STATUS\r
1358EFIAPI\r
1359SafeUintnToUint16 (\r
1360 IN UINTN Operand,\r
1361 OUT UINT16 *Result\r
1362 );\r
1363\r
1364/**\r
1365 UINTN -> INT32 conversion\r
1366\r
1367 Converts the value specified by Operand to a value specified by Result type\r
1368 and stores the converted value into the caller allocated output buffer\r
1369 specified by Result. The caller must pass in a Result buffer that is at\r
1370 least as large as the Result type.\r
1371\r
1372 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1373\r
1374 If the conversion results in an overflow or an underflow condition, then\r
1375 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1376\r
1377 @param[in] Operand Operand to be converted to new type\r
1378 @param[out] Result Pointer to the result of conversion\r
1379\r
1380 @retval RETURN_SUCCESS Successful conversion\r
1381 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1382 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1383**/\r
1384RETURN_STATUS\r
1385EFIAPI\r
1386SafeUintnToInt32 (\r
1387 IN UINTN Operand,\r
1388 OUT INT32 *Result\r
1389 );\r
1390\r
1391/**\r
1392 UINTN -> UINT32 conversion\r
1393\r
1394 Converts the value specified by Operand to a value specified by Result type\r
1395 and stores the converted value into the caller allocated output buffer\r
1396 specified by Result. The caller must pass in a Result buffer that is at\r
1397 least as large as the Result type.\r
1398\r
1399 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1400\r
1401 If the conversion results in an overflow or an underflow condition, then\r
1402 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1403\r
1404 @param[in] Operand Operand to be converted to new type\r
1405 @param[out] Result Pointer to the result of conversion\r
1406\r
1407 @retval RETURN_SUCCESS Successful conversion\r
1408 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1409 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1410**/\r
1411RETURN_STATUS\r
1412EFIAPI\r
1413SafeUintnToUint32 (\r
1414 IN UINTN Operand,\r
1415 OUT UINT32 *Result\r
1416 );\r
1417\r
1418/**\r
1419 UINTN -> INTN conversion\r
1420\r
1421 Converts the value specified by Operand to a value specified by Result type\r
1422 and stores the converted value into the caller allocated output buffer\r
1423 specified by Result. The caller must pass in a Result buffer that is at\r
1424 least as large as the Result type.\r
1425\r
1426 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1427\r
1428 If the conversion results in an overflow or an underflow condition, then\r
1429 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1430\r
1431 @param[in] Operand Operand to be converted to new type\r
1432 @param[out] Result Pointer to the result of conversion\r
1433\r
1434 @retval RETURN_SUCCESS Successful conversion\r
1435 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1436 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1437**/\r
1438RETURN_STATUS\r
1439EFIAPI\r
1440SafeUintnToIntn (\r
1441 IN UINTN Operand,\r
1442 OUT INTN *Result\r
1443 );\r
1444\r
1445/**\r
1446 UINTN -> INT64 conversion\r
1447\r
1448 Converts the value specified by Operand to a value specified by Result type\r
1449 and stores the converted value into the caller allocated output buffer\r
1450 specified by Result. The caller must pass in a Result buffer that is at\r
1451 least as large as the Result type.\r
1452\r
1453 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1454\r
1455 If the conversion results in an overflow or an underflow condition, then\r
1456 Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1457\r
1458 @param[in] Operand Operand to be converted to new type\r
1459 @param[out] Result Pointer to the result of conversion\r
1460\r
1461 @retval RETURN_SUCCESS Successful conversion\r
1462 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1463 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1464**/\r
1465RETURN_STATUS\r
1466EFIAPI\r
1467SafeUintnToInt64 (\r
1468 IN UINTN Operand,\r
1469 OUT INT64 *Result\r
1470 );\r
1471\r
1472/**\r
1473 INT64 -> INT8 conversion\r
1474\r
1475 Converts the value specified by Operand to a value specified by Result type\r
1476 and stores the converted value into the caller allocated output buffer\r
1477 specified by Result. The caller must pass in a Result buffer that is at\r
1478 least as large as the Result type.\r
1479\r
1480 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1481\r
1482 If the conversion results in an overflow or an underflow condition, then\r
1483 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1484\r
1485 @param[in] Operand Operand to be converted to new type\r
1486 @param[out] Result Pointer to the result of conversion\r
1487\r
1488 @retval RETURN_SUCCESS Successful conversion\r
1489 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1490 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1491**/\r
1492RETURN_STATUS\r
1493EFIAPI\r
1494SafeInt64ToInt8 (\r
1495 IN INT64 Operand,\r
1496 OUT INT8 *Result\r
1497 );\r
1498\r
1499/**\r
1500 INT64 -> CHAR8 conversion\r
1501\r
1502 Converts the value specified by Operand to a value specified by Result type\r
1503 and stores the converted value into the caller allocated output buffer\r
1504 specified by Result. The caller must pass in a Result buffer that is at\r
1505 least as large as the Result type.\r
1506\r
1507 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1508\r
1509 If the conversion results in an overflow or an underflow condition, then\r
1510 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1511\r
1512 @param[in] Operand Operand to be converted to new type\r
1513 @param[out] Result Pointer to the result of conversion\r
1514\r
1515 @retval RETURN_SUCCESS Successful conversion\r
1516 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1517 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1518**/\r
1519RETURN_STATUS\r
1520EFIAPI\r
1521SafeInt64ToChar8 (\r
1522 IN INT64 Operand,\r
1523 OUT CHAR8 *Result\r
1524 );\r
1525\r
1526/**\r
1527 INT64 -> UINT8 conversion\r
1528\r
1529 Converts the value specified by Operand to a value specified by Result type\r
1530 and stores the converted value into the caller allocated output buffer\r
1531 specified by Result. The caller must pass in a Result buffer that is at\r
1532 least as large as the Result type.\r
1533\r
1534 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1535\r
1536 If the conversion results in an overflow or an underflow condition, then\r
1537 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1538\r
1539 @param[in] Operand Operand to be converted to new type\r
1540 @param[out] Result Pointer to the result of conversion\r
1541\r
1542 @retval RETURN_SUCCESS Successful conversion\r
1543 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1544 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1545**/\r
1546RETURN_STATUS\r
1547EFIAPI\r
1548SafeInt64ToUint8 (\r
1549 IN INT64 Operand,\r
1550 OUT UINT8 *Result\r
1551 );\r
1552\r
1553/**\r
1554 INT64 -> INT16 conversion\r
1555\r
1556 Converts the value specified by Operand to a value specified by Result type\r
1557 and stores the converted value into the caller allocated output buffer\r
1558 specified by Result. The caller must pass in a Result buffer that is at\r
1559 least as large as the Result type.\r
1560\r
1561 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1562\r
1563 If the conversion results in an overflow or an underflow condition, then\r
1564 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1565\r
1566 @param[in] Operand Operand to be converted to new type\r
1567 @param[out] Result Pointer to the result of conversion\r
1568\r
1569 @retval RETURN_SUCCESS Successful conversion\r
1570 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1571 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1572**/\r
1573RETURN_STATUS\r
1574EFIAPI\r
1575SafeInt64ToInt16 (\r
1576 IN INT64 Operand,\r
1577 OUT INT16 *Result\r
1578 );\r
1579\r
1580/**\r
1581 INT64 -> UINT16 conversion\r
1582\r
1583 Converts the value specified by Operand to a value specified by Result type\r
1584 and stores the converted value into the caller allocated output buffer\r
1585 specified by Result. The caller must pass in a Result buffer that is at\r
1586 least as large as the Result type.\r
1587\r
1588 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1589\r
1590 If the conversion results in an overflow or an underflow condition, then\r
1591 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1592\r
1593 @param[in] Operand Operand to be converted to new type\r
1594 @param[out] Result Pointer to the result of conversion\r
1595\r
1596 @retval RETURN_SUCCESS Successful conversion\r
1597 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1598 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1599**/\r
1600RETURN_STATUS\r
1601EFIAPI\r
1602SafeInt64ToUint16 (\r
1603 IN INT64 Operand,\r
1604 OUT UINT16 *Result\r
1605 );\r
1606\r
1607/**\r
1608 INT64 -> INT32 conversion\r
1609\r
1610 Converts the value specified by Operand to a value specified by Result type\r
1611 and stores the converted value into the caller allocated output buffer\r
1612 specified by Result. The caller must pass in a Result buffer that is at\r
1613 least as large as the Result type.\r
1614\r
1615 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1616\r
1617 If the conversion results in an overflow or an underflow condition, then\r
1618 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1619\r
1620 @param[in] Operand Operand to be converted to new type\r
1621 @param[out] Result Pointer to the result of conversion\r
1622\r
1623 @retval RETURN_SUCCESS Successful conversion\r
1624 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1625 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1626**/\r
1627RETURN_STATUS\r
1628EFIAPI\r
1629SafeInt64ToInt32 (\r
1630 IN INT64 Operand,\r
1631 OUT INT32 *Result\r
1632 );\r
1633\r
1634/**\r
1635 INT64 -> UINT32 conversion\r
1636\r
1637 Converts the value specified by Operand to a value specified by Result type\r
1638 and stores the converted value into the caller allocated output buffer\r
1639 specified by Result. The caller must pass in a Result buffer that is at\r
1640 least as large as the Result type.\r
1641\r
1642 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1643\r
1644 If the conversion results in an overflow or an underflow condition, then\r
1645 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1646\r
1647 @param[in] Operand Operand to be converted to new type\r
1648 @param[out] Result Pointer to the result of conversion\r
1649\r
1650 @retval RETURN_SUCCESS Successful conversion\r
1651 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1652 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1653**/\r
1654RETURN_STATUS\r
1655EFIAPI\r
1656SafeInt64ToUint32 (\r
1657 IN INT64 Operand,\r
1658 OUT UINT32 *Result\r
1659 );\r
1660\r
1661/**\r
1662 INT64 -> INTN conversion\r
1663\r
1664 Converts the value specified by Operand to a value specified by Result type\r
1665 and stores the converted value into the caller allocated output buffer\r
1666 specified by Result. The caller must pass in a Result buffer that is at\r
1667 least as large as the Result type.\r
1668\r
1669 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1670\r
1671 If the conversion results in an overflow or an underflow condition, then\r
1672 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1673\r
1674 @param[in] Operand Operand to be converted to new type\r
1675 @param[out] Result Pointer to the result of conversion\r
1676\r
1677 @retval RETURN_SUCCESS Successful conversion\r
1678 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1679 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1680**/\r
1681RETURN_STATUS\r
1682EFIAPI\r
1683SafeInt64ToIntn (\r
1684 IN INT64 Operand,\r
1685 OUT INTN *Result\r
1686 );\r
1687\r
1688/**\r
1689 INT64 -> UINTN conversion\r
1690\r
1691 Converts the value specified by Operand to a value specified by Result type\r
1692 and stores the converted value into the caller allocated output buffer\r
1693 specified by Result. The caller must pass in a Result buffer that is at\r
1694 least as large as the Result type.\r
1695\r
1696 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1697\r
1698 If the conversion results in an overflow or an underflow condition, then\r
1699 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1700\r
1701 @param[in] Operand Operand to be converted to new type\r
1702 @param[out] Result Pointer to the result of conversion\r
1703\r
1704 @retval RETURN_SUCCESS Successful conversion\r
1705 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1706 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1707**/\r
1708RETURN_STATUS\r
1709EFIAPI\r
1710SafeInt64ToUintn (\r
1711 IN INT64 Operand,\r
1712 OUT UINTN *Result\r
1713 );\r
1714\r
1715/**\r
1716 INT64 -> UINT64 conversion\r
1717\r
1718 Converts the value specified by Operand to a value specified by Result type\r
1719 and stores the converted value into the caller allocated output buffer\r
1720 specified by Result. The caller must pass in a Result buffer that is at\r
1721 least as large as the Result type.\r
1722\r
1723 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1724\r
1725 If the conversion results in an overflow or an underflow condition, then\r
1726 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1727\r
1728 @param[in] Operand Operand to be converted to new type\r
1729 @param[out] Result Pointer to the result of conversion\r
1730\r
1731 @retval RETURN_SUCCESS Successful conversion\r
1732 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1733 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1734**/\r
1735RETURN_STATUS\r
1736EFIAPI\r
1737SafeInt64ToUint64 (\r
1738 IN INT64 Operand,\r
1739 OUT UINT64 *Result\r
1740 );\r
1741\r
1742/**\r
1743 UINT64 -> INT8 conversion\r
1744\r
1745 Converts the value specified by Operand to a value specified by Result type\r
1746 and stores the converted value into the caller allocated output buffer\r
1747 specified by Result. The caller must pass in a Result buffer that is at\r
1748 least as large as the Result type.\r
1749\r
1750 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1751\r
1752 If the conversion results in an overflow or an underflow condition, then\r
1753 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1754\r
1755 @param[in] Operand Operand to be converted to new type\r
1756 @param[out] Result Pointer to the result of conversion\r
1757\r
1758 @retval RETURN_SUCCESS Successful conversion\r
1759 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1760 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1761**/\r
1762RETURN_STATUS\r
1763EFIAPI\r
1764SafeUint64ToInt8 (\r
1765 IN UINT64 Operand,\r
1766 OUT INT8 *Result\r
1767 );\r
1768\r
1769/**\r
1770 UINT64 -> CHAR8 conversion\r
1771\r
1772 Converts the value specified by Operand to a value specified by Result type\r
1773 and stores the converted value into the caller allocated output buffer\r
1774 specified by Result. The caller must pass in a Result buffer that is at\r
1775 least as large as the Result type.\r
1776\r
1777 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1778\r
1779 If the conversion results in an overflow or an underflow condition, then\r
1780 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1781\r
1782 @param[in] Operand Operand to be converted to new type\r
1783 @param[out] Result Pointer to the result of conversion\r
1784\r
1785 @retval RETURN_SUCCESS Successful conversion\r
1786 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1787 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1788**/\r
1789RETURN_STATUS\r
1790EFIAPI\r
1791SafeUint64ToChar8 (\r
1792 IN UINT64 Operand,\r
1793 OUT CHAR8 *Result\r
1794 );\r
1795\r
1796/**\r
1797 UINT64 -> UINT8 conversion\r
1798\r
1799 Converts the value specified by Operand to a value specified by Result type\r
1800 and stores the converted value into the caller allocated output buffer\r
1801 specified by Result. The caller must pass in a Result buffer that is at\r
1802 least as large as the Result type.\r
1803\r
1804 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1805\r
1806 If the conversion results in an overflow or an underflow condition, then\r
1807 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1808\r
1809 @param[in] Operand Operand to be converted to new type\r
1810 @param[out] Result Pointer to the result of conversion\r
1811\r
1812 @retval RETURN_SUCCESS Successful conversion\r
1813 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1814 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1815**/\r
1816RETURN_STATUS\r
1817EFIAPI\r
1818SafeUint64ToUint8 (\r
1819 IN UINT64 Operand,\r
1820 OUT UINT8 *Result\r
1821 );\r
1822\r
1823/**\r
1824 UINT64 -> INT16 conversion\r
1825\r
1826 Converts the value specified by Operand to a value specified by Result type\r
1827 and stores the converted value into the caller allocated output buffer\r
1828 specified by Result. The caller must pass in a Result buffer that is at\r
1829 least as large as the Result type.\r
1830\r
1831 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1832\r
1833 If the conversion results in an overflow or an underflow condition, then\r
1834 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1835\r
1836 @param[in] Operand Operand to be converted to new type\r
1837 @param[out] Result Pointer to the result of conversion\r
1838\r
1839 @retval RETURN_SUCCESS Successful conversion\r
1840 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1841 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1842**/\r
1843RETURN_STATUS\r
1844EFIAPI\r
1845SafeUint64ToInt16 (\r
1846 IN UINT64 Operand,\r
1847 OUT INT16 *Result\r
1848 );\r
1849\r
1850/**\r
1851 UINT64 -> UINT16 conversion\r
1852\r
1853 Converts the value specified by Operand to a value specified by Result type\r
1854 and stores the converted value into the caller allocated output buffer\r
1855 specified by Result. The caller must pass in a Result buffer that is at\r
1856 least as large as the Result type.\r
1857\r
1858 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1859\r
1860 If the conversion results in an overflow or an underflow condition, then\r
1861 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1862\r
1863 @param[in] Operand Operand to be converted to new type\r
1864 @param[out] Result Pointer to the result of conversion\r
1865\r
1866 @retval RETURN_SUCCESS Successful conversion\r
1867 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1868 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1869**/\r
1870RETURN_STATUS\r
1871EFIAPI\r
1872SafeUint64ToUint16 (\r
1873 IN UINT64 Operand,\r
1874 OUT UINT16 *Result\r
1875 );\r
1876\r
1877/**\r
1878 UINT64 -> INT32 conversion\r
1879\r
1880 Converts the value specified by Operand to a value specified by Result type\r
1881 and stores the converted value into the caller allocated output buffer\r
1882 specified by Result. The caller must pass in a Result buffer that is at\r
1883 least as large as the Result type.\r
1884\r
1885 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1886\r
1887 If the conversion results in an overflow or an underflow condition, then\r
1888 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1889\r
1890 @param[in] Operand Operand to be converted to new type\r
1891 @param[out] Result Pointer to the result of conversion\r
1892\r
1893 @retval RETURN_SUCCESS Successful conversion\r
1894 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1895 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1896**/\r
1897RETURN_STATUS\r
1898EFIAPI\r
1899SafeUint64ToInt32 (\r
1900 IN UINT64 Operand,\r
1901 OUT INT32 *Result\r
1902 );\r
1903\r
1904/**\r
1905 UINT64 -> UINT32 conversion\r
1906\r
1907 Converts the value specified by Operand to a value specified by Result type\r
1908 and stores the converted value into the caller allocated output buffer\r
1909 specified by Result. The caller must pass in a Result buffer that is at\r
1910 least as large as the Result type.\r
1911\r
1912 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1913\r
1914 If the conversion results in an overflow or an underflow condition, then\r
1915 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1916\r
1917 @param[in] Operand Operand to be converted to new type\r
1918 @param[out] Result Pointer to the result of conversion\r
1919\r
1920 @retval RETURN_SUCCESS Successful conversion\r
1921 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1922 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1923**/\r
1924RETURN_STATUS\r
1925EFIAPI\r
1926SafeUint64ToUint32 (\r
1927 IN UINT64 Operand,\r
1928 OUT UINT32 *Result\r
1929 );\r
1930\r
1931/**\r
1932 UINT64 -> INTN conversion\r
1933\r
1934 Converts the value specified by Operand to a value specified by Result type\r
1935 and stores the converted value into the caller allocated output buffer\r
1936 specified by Result. The caller must pass in a Result buffer that is at\r
1937 least as large as the Result type.\r
1938\r
1939 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1940\r
1941 If the conversion results in an overflow or an underflow condition, then\r
1942 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1943\r
1944 @param[in] Operand Operand to be converted to new type\r
1945 @param[out] Result Pointer to the result of conversion\r
1946\r
1947 @retval RETURN_SUCCESS Successful conversion\r
1948 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1949 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1950**/\r
1951RETURN_STATUS\r
1952EFIAPI\r
1953SafeUint64ToIntn (\r
1954 IN UINT64 Operand,\r
1955 OUT INTN *Result\r
1956 );\r
1957\r
1958/**\r
1959 UINT64 -> UINTN conversion\r
1960\r
1961 Converts the value specified by Operand to a value specified by Result type\r
1962 and stores the converted value into the caller allocated output buffer\r
1963 specified by Result. The caller must pass in a Result buffer that is at\r
1964 least as large as the Result type.\r
1965\r
1966 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1967\r
1968 If the conversion results in an overflow or an underflow condition, then\r
1969 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1970\r
1971 @param[in] Operand Operand to be converted to new type\r
1972 @param[out] Result Pointer to the result of conversion\r
1973\r
1974 @retval RETURN_SUCCESS Successful conversion\r
1975 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
1976 @retval RETURN_INVALID_PARAMETER Result is NULL\r
1977**/\r
1978RETURN_STATUS\r
1979EFIAPI\r
1980SafeUint64ToUintn (\r
1981 IN UINT64 Operand,\r
1982 OUT UINTN *Result\r
1983 );\r
1984\r
1985/**\r
1986 UINT64 -> INT64 conversion\r
1987\r
1988 Converts the value specified by Operand to a value specified by Result type\r
1989 and stores the converted value into the caller allocated output buffer\r
1990 specified by Result. The caller must pass in a Result buffer that is at\r
1991 least as large as the Result type.\r
1992\r
1993 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
1994\r
1995 If the conversion results in an overflow or an underflow condition, then\r
1996 Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
1997\r
1998 @param[in] Operand Operand to be converted to new type\r
1999 @param[out] Result Pointer to the result of conversion\r
2000\r
2001 @retval RETURN_SUCCESS Successful conversion\r
2002 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2003 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2004**/\r
2005RETURN_STATUS\r
2006EFIAPI\r
2007SafeUint64ToInt64 (\r
2008 IN UINT64 Operand,\r
2009 OUT INT64 *Result\r
2010 );\r
2011\r
2012//\r
2013// Addition functions\r
2014//\r
2015\r
2016/**\r
2017 UINT8 addition\r
2018\r
2019 Performs the requested operation using the input parameters into a value\r
2020 specified by Result type and stores the converted value into the caller\r
2021 allocated output buffer specified by Result. The caller must pass in a\r
2022 Result buffer that is at least as large as the Result type.\r
2023\r
2024 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2025\r
2026 If the requested operation results in an overflow or an underflow condition,\r
2027 then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2028\r
2029 @param[in] Augend A number to which addend will be added\r
2030 @param[in] Addend A number to be added to another\r
2031 @param[out] Result Pointer to the result of addition\r
2032\r
2033 @retval RETURN_SUCCESS Successful addition\r
2034 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2035 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2036**/\r
2037RETURN_STATUS\r
2038EFIAPI\r
2039SafeUint8Add (\r
2040 IN UINT8 Augend,\r
2041 IN UINT8 Addend,\r
2042 OUT UINT8 *Result\r
2043 );\r
2044\r
2045/**\r
2046 UINT16 addition\r
2047\r
2048 Performs the requested operation using the input parameters into a value\r
2049 specified by Result type and stores the converted value into the caller\r
2050 allocated output buffer specified by Result. The caller must pass in a\r
2051 Result buffer that is at least as large as the Result type.\r
2052\r
2053 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2054\r
2055 If the requested operation results in an overflow or an underflow condition,\r
2056 then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2057\r
2058 @param[in] Augend A number to which addend will be added\r
2059 @param[in] Addend A number to be added to another\r
2060 @param[out] Result Pointer to the result of addition\r
2061\r
2062 @retval RETURN_SUCCESS Successful addition\r
2063 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2064 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2065**/\r
2066RETURN_STATUS\r
2067EFIAPI\r
2068SafeUint16Add (\r
2069 IN UINT16 Augend,\r
2070 IN UINT16 Addend,\r
2071 OUT UINT16 *Result\r
2072 );\r
2073\r
2074/**\r
2075 UINT32 addition\r
2076\r
2077 Performs the requested operation using the input parameters into a value\r
2078 specified by Result type and stores the converted value into the caller\r
2079 allocated output buffer specified by Result. The caller must pass in a\r
2080 Result buffer that is at least as large as the Result type.\r
2081\r
2082 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2083\r
2084 If the requested operation results in an overflow or an underflow condition,\r
2085 then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2086\r
2087 @param[in] Augend A number to which addend will be added\r
2088 @param[in] Addend A number to be added to another\r
2089 @param[out] Result Pointer to the result of addition\r
2090\r
2091 @retval RETURN_SUCCESS Successful addition\r
2092 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2093 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2094**/\r
2095RETURN_STATUS\r
2096EFIAPI\r
2097SafeUint32Add (\r
2098 IN UINT32 Augend,\r
2099 IN UINT32 Addend,\r
2100 OUT UINT32 *Result\r
2101 );\r
2102\r
2103/**\r
2104 UINTN addition\r
2105\r
2106 Performs the requested operation using the input parameters into a value\r
2107 specified by Result type and stores the converted value into the caller\r
2108 allocated output buffer specified by Result. The caller must pass in a\r
2109 Result buffer that is at least as large as the Result type.\r
2110\r
2111 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2112\r
2113 If the requested operation results in an overflow or an underflow condition,\r
2114 then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2115\r
2116 @param[in] Augend A number to which addend will be added\r
2117 @param[in] Addend A number to be added to another\r
2118 @param[out] Result Pointer to the result of addition\r
2119\r
2120 @retval RETURN_SUCCESS Successful addition\r
2121 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2122 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2123**/\r
2124RETURN_STATUS\r
2125EFIAPI\r
2126SafeUintnAdd (\r
2127 IN UINTN Augend,\r
2128 IN UINTN Addend,\r
2129 OUT UINTN *Result\r
2130 );\r
2131\r
2132/**\r
2133 UINT64 addition\r
2134\r
2135 Performs the requested operation using the input parameters into a value\r
2136 specified by Result type and stores the converted value into the caller\r
2137 allocated output buffer specified by Result. The caller must pass in a\r
2138 Result buffer that is at least as large as the Result type.\r
2139\r
2140 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2141\r
2142 If the requested operation results in an overflow or an underflow condition,\r
2143 then Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2144\r
2145 @param[in] Augend A number to which addend will be added\r
2146 @param[in] Addend A number to be added to another\r
2147 @param[out] Result Pointer to the result of addition\r
2148\r
2149 @retval RETURN_SUCCESS Successful addition\r
2150 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2151 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2152**/\r
2153RETURN_STATUS\r
2154EFIAPI\r
2155SafeUint64Add (\r
2156 IN UINT64 Augend,\r
2157 IN UINT64 Addend,\r
2158 OUT UINT64 *Result\r
2159 );\r
2160\r
2161//\r
2162// Subtraction functions\r
2163//\r
2164\r
2165/**\r
2166 UINT8 subtraction\r
2167\r
2168 Performs the requested operation using the input parameters into a value\r
2169 specified by Result type and stores the converted value into the caller\r
2170 allocated output buffer specified by Result. The caller must pass in a\r
2171 Result buffer that is at least as large as the Result type.\r
2172\r
2173 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2174\r
2175 If the requested operation results in an overflow or an underflow condition,\r
2176 then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2177\r
2178 @param[in] Minuend A number from which another is to be subtracted.\r
2179 @param[in] Subtrahend A number to be subtracted from another\r
2180 @param[out] Result Pointer to the result of subtraction\r
2181\r
2182 @retval RETURN_SUCCESS Successful subtraction\r
2183 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2184 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2185**/\r
2186RETURN_STATUS\r
2187EFIAPI\r
2188SafeUint8Sub (\r
2189 IN UINT8 Minuend,\r
2190 IN UINT8 Subtrahend,\r
2191 OUT UINT8 *Result\r
2192 );\r
2193\r
2194/**\r
2195 UINT16 subtraction\r
2196\r
2197 Performs the requested operation using the input parameters into a value\r
2198 specified by Result type and stores the converted value into the caller\r
2199 allocated output buffer specified by Result. The caller must pass in a\r
2200 Result buffer that is at least as large as the Result type.\r
2201\r
2202 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2203\r
2204 If the requested operation results in an overflow or an underflow condition,\r
2205 then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2206\r
2207 @param[in] Minuend A number from which another is to be subtracted.\r
2208 @param[in] Subtrahend A number to be subtracted from another\r
2209 @param[out] Result Pointer to the result of subtraction\r
2210\r
2211 @retval RETURN_SUCCESS Successful subtraction\r
2212 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2213 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2214**/\r
2215RETURN_STATUS\r
2216EFIAPI\r
2217SafeUint16Sub (\r
2218 IN UINT16 Minuend,\r
2219 IN UINT16 Subtrahend,\r
2220 OUT UINT16 *Result\r
2221 );\r
2222\r
2223/**\r
2224 UINT32 subtraction\r
2225\r
2226 Performs the requested operation using the input parameters into a value\r
2227 specified by Result type and stores the converted value into the caller\r
2228 allocated output buffer specified by Result. The caller must pass in a\r
2229 Result buffer that is at least as large as the Result type.\r
2230\r
2231 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2232\r
2233 If the requested operation results in an overflow or an underflow condition,\r
2234 then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2235\r
2236 @param[in] Minuend A number from which another is to be subtracted.\r
2237 @param[in] Subtrahend A number to be subtracted from another\r
2238 @param[out] Result Pointer to the result of subtraction\r
2239\r
2240 @retval RETURN_SUCCESS Successful subtraction\r
2241 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2242 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2243**/\r
2244RETURN_STATUS\r
2245EFIAPI\r
2246SafeUint32Sub (\r
2247 IN UINT32 Minuend,\r
2248 IN UINT32 Subtrahend,\r
2249 OUT UINT32 *Result\r
2250 );\r
2251\r
2252/**\r
2253 UINTN subtraction\r
2254\r
2255 Performs the requested operation using the input parameters into a value\r
2256 specified by Result type and stores the converted value into the caller\r
2257 allocated output buffer specified by Result. The caller must pass in a\r
2258 Result buffer that is at least as large as the Result type.\r
2259\r
2260 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2261\r
2262 If the requested operation results in an overflow or an underflow condition,\r
2263 then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2264\r
2265 @param[in] Minuend A number from which another is to be subtracted.\r
2266 @param[in] Subtrahend A number to be subtracted from another\r
2267 @param[out] Result Pointer to the result of subtraction\r
2268\r
2269 @retval RETURN_SUCCESS Successful subtraction\r
2270 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2271 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2272**/\r
2273RETURN_STATUS\r
2274EFIAPI\r
2275SafeUintnSub (\r
2276 IN UINTN Minuend,\r
2277 IN UINTN Subtrahend,\r
2278 OUT UINTN *Result\r
2279 );\r
2280\r
2281/**\r
2282 UINT64 subtraction\r
2283\r
2284 Performs the requested operation using the input parameters into a value\r
2285 specified by Result type and stores the converted value into the caller\r
2286 allocated output buffer specified by Result. The caller must pass in a\r
2287 Result buffer that is at least as large as the Result type.\r
2288\r
2289 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2290\r
2291 If the requested operation results in an overflow or an underflow condition,\r
2292 then Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2293\r
2294 @param[in] Minuend A number from which another is to be subtracted.\r
2295 @param[in] Subtrahend A number to be subtracted from another\r
2296 @param[out] Result Pointer to the result of subtraction\r
2297\r
2298 @retval RETURN_SUCCESS Successful subtraction\r
2299 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2300 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2301**/\r
2302RETURN_STATUS\r
2303EFIAPI\r
2304SafeUint64Sub (\r
2305 IN UINT64 Minuend,\r
2306 IN UINT64 Subtrahend,\r
2307 OUT UINT64 *Result\r
2308 );\r
2309\r
2310//\r
2311// Multiplication functions\r
2312//\r
2313\r
2314/**\r
2315 UINT8 multiplication\r
2316\r
2317 Performs the requested operation using the input parameters into a value\r
2318 specified by Result type and stores the converted value into the caller\r
2319 allocated output buffer specified by Result. The caller must pass in a\r
2320 Result buffer that is at least as large as the Result type.\r
2321\r
2322 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2323\r
2324 If the requested operation results in an overflow or an underflow condition,\r
2325 then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2326\r
2327 @param[in] Multiplicand A number that is to be multiplied by another\r
2328 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2329 @param[out] Result Pointer to the result of multiplication\r
2330\r
2331 @retval RETURN_SUCCESS Successful multiplication\r
2332 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2333 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2334**/\r
2335RETURN_STATUS\r
2336EFIAPI\r
2337SafeUint8Mult (\r
2338 IN UINT8 Multiplicand,\r
2339 IN UINT8 Multiplier,\r
2340 OUT UINT8 *Result\r
2341 );\r
2342\r
2343/**\r
2344 UINT16 multiplication\r
2345\r
2346 Performs the requested operation using the input parameters into a value\r
2347 specified by Result type and stores the converted value into the caller\r
2348 allocated output buffer specified by Result. The caller must pass in a\r
2349 Result buffer that is at least as large as the Result type.\r
2350\r
2351 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2352\r
2353 If the requested operation results in an overflow or an underflow condition,\r
2354 then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2355\r
2356 @param[in] Multiplicand A number that is to be multiplied by another\r
2357 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2358 @param[out] Result Pointer to the result of multiplication\r
2359\r
2360 @retval RETURN_SUCCESS Successful multiplication\r
2361 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2362 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2363**/\r
2364RETURN_STATUS\r
2365EFIAPI\r
2366SafeUint16Mult (\r
2367 IN UINT16 Multiplicand,\r
2368 IN UINT16 Multiplier,\r
2369 OUT UINT16 *Result\r
2370 );\r
2371\r
2372/**\r
2373 UINT32 multiplication\r
2374\r
2375 Performs the requested operation using the input parameters into a value\r
2376 specified by Result type and stores the converted value into the caller\r
2377 allocated output buffer specified by Result. The caller must pass in a\r
2378 Result buffer that is at least as large as the Result type.\r
2379\r
2380 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2381\r
2382 If the requested operation results in an overflow or an underflow condition,\r
2383 then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2384\r
2385 @param[in] Multiplicand A number that is to be multiplied by another\r
2386 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2387 @param[out] Result Pointer to the result of multiplication\r
2388\r
2389 @retval RETURN_SUCCESS Successful multiplication\r
2390 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2391 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2392**/\r
2393RETURN_STATUS\r
2394EFIAPI\r
2395SafeUint32Mult (\r
2396 IN UINT32 Multiplicand,\r
2397 IN UINT32 Multiplier,\r
2398 OUT UINT32 *Result\r
2399 );\r
2400\r
2401/**\r
2402 UINTN multiplication\r
2403\r
2404 Performs the requested operation using the input parameters into a value\r
2405 specified by Result type and stores the converted value into the caller\r
2406 allocated output buffer specified by Result. The caller must pass in a\r
2407 Result buffer that is at least as large as the Result type.\r
2408\r
2409 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2410\r
2411 If the requested operation results in an overflow or an underflow condition,\r
2412 then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2413\r
2414 @param[in] Multiplicand A number that is to be multiplied by another\r
2415 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2416 @param[out] Result Pointer to the result of multiplication\r
2417\r
2418 @retval RETURN_SUCCESS Successful multiplication\r
2419 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2420 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2421**/\r
2422RETURN_STATUS\r
2423EFIAPI\r
2424SafeUintnMult (\r
2425 IN UINTN Multiplicand,\r
2426 IN UINTN Multiplier,\r
2427 OUT UINTN *Result\r
2428 );\r
2429\r
2430/**\r
2431 UINT64 multiplication\r
2432\r
2433 Performs the requested operation using the input parameters into a value\r
2434 specified by Result type and stores the converted value into the caller\r
2435 allocated output buffer specified by Result. The caller must pass in a\r
2436 Result buffer that is at least as large as the Result type.\r
2437\r
2438 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2439\r
2440 If the requested operation results in an overflow or an underflow condition,\r
2441 then Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2442\r
2443 @param[in] Multiplicand A number that is to be multiplied by another\r
2444 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2445 @param[out] Result Pointer to the result of multiplication\r
2446\r
2447 @retval RETURN_SUCCESS Successful multiplication\r
2448 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2449 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2450**/\r
2451RETURN_STATUS\r
2452EFIAPI\r
2453SafeUint64Mult (\r
2454 IN UINT64 Multiplicand,\r
2455 IN UINT64 Multiplier,\r
2456 OUT UINT64 *Result\r
2457 );\r
2458\r
2459//\r
2460// Signed operations\r
2461//\r
2462// Strongly consider using unsigned numbers.\r
2463//\r
2464// Signed numbers are often used where unsigned numbers should be used.\r
2465// For example file sizes and array indices should always be unsigned.\r
2466// Subtracting a larger positive signed number from a smaller positive\r
2467// signed number with SafeInt32Sub will succeed, producing a negative number,\r
2468// that then must not be used as an array index (but can occasionally be\r
2469// used as a pointer index.) Similarly for adding a larger magnitude\r
2470// negative number to a smaller magnitude positive number.\r
2471//\r
2472// This library does not protect you from such errors. It tells you if your\r
2473// integer operations overflowed, not if you are doing the right thing\r
2474// with your non-overflowed integers.\r
2475//\r
2476// Likewise you can overflow a buffer with a non-overflowed unsigned index.\r
2477//\r
2478\r
2479//\r
2480// Signed addition functions\r
2481//\r
2482\r
2483/**\r
2484 INT8 Addition\r
2485\r
2486 Performs the requested operation using the input parameters into a value\r
2487 specified by Result type and stores the converted value into the caller\r
2488 allocated output buffer specified by Result. The caller must pass in a\r
2489 Result buffer that is at least as large as the Result type.\r
2490\r
2491 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2492\r
2493 If the requested operation results in an overflow or an underflow condition,\r
2494 then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2495\r
2496 @param[in] Augend A number to which addend will be added\r
2497 @param[in] Addend A number to be added to another\r
2498 @param[out] Result Pointer to the result of addition\r
2499\r
2500 @retval RETURN_SUCCESS Successful addition\r
2501 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2502 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2503**/\r
2504RETURN_STATUS\r
2505EFIAPI\r
2506SafeInt8Add (\r
2507 IN INT8 Augend,\r
2508 IN INT8 Addend,\r
2509 OUT INT8 *Result\r
2510 );\r
2511\r
2512/**\r
2513 CHAR8 Addition\r
2514\r
2515 Performs the requested operation using the input parameters into a value\r
2516 specified by Result type and stores the converted value into the caller\r
2517 allocated output buffer specified by Result. The caller must pass in a\r
2518 Result buffer that is at least as large as the Result type.\r
2519\r
2520 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2521\r
2522 If the requested operation results in an overflow or an underflow condition,\r
2523 then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2524\r
2525 @param[in] Augend A number to which addend will be added\r
2526 @param[in] Addend A number to be added to another\r
2527 @param[out] Result Pointer to the result of addition\r
2528\r
2529 @retval RETURN_SUCCESS Successful addition\r
2530 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2531 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2532**/\r
2533RETURN_STATUS\r
2534EFIAPI\r
2535SafeChar8Add (\r
2536 IN CHAR8 Augend,\r
2537 IN CHAR8 Addend,\r
2538 OUT CHAR8 *Result\r
2539 );\r
2540\r
2541/**\r
2542 INT16 Addition\r
2543\r
2544 Performs the requested operation using the input parameters into a value\r
2545 specified by Result type and stores the converted value into the caller\r
2546 allocated output buffer specified by Result. The caller must pass in a\r
2547 Result buffer that is at least as large as the Result type.\r
2548\r
2549 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2550\r
2551 If the requested operation results in an overflow or an underflow condition,\r
2552 then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2553\r
2554 @param[in] Augend A number to which addend will be added\r
2555 @param[in] Addend A number to be added to another\r
2556 @param[out] Result Pointer to the result of addition\r
2557\r
2558 @retval RETURN_SUCCESS Successful addition\r
2559 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2560 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2561**/\r
2562RETURN_STATUS\r
2563EFIAPI\r
2564SafeInt16Add (\r
2565 IN INT16 Augend,\r
2566 IN INT16 Addend,\r
2567 OUT INT16 *Result\r
2568 );\r
2569\r
2570/**\r
2571 INT32 Addition\r
2572\r
2573 Performs the requested operation using the input parameters into a value\r
2574 specified by Result type and stores the converted value into the caller\r
2575 allocated output buffer specified by Result. The caller must pass in a\r
2576 Result buffer that is at least as large as the Result type.\r
2577\r
2578 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2579\r
2580 If the requested operation results in an overflow or an underflow condition,\r
2581 then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2582\r
2583 @param[in] Augend A number to which addend will be added\r
2584 @param[in] Addend A number to be added to another\r
2585 @param[out] Result Pointer to the result of addition\r
2586\r
2587 @retval RETURN_SUCCESS Successful addition\r
2588 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2589 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2590**/\r
2591RETURN_STATUS\r
2592EFIAPI\r
2593SafeInt32Add (\r
2594 IN INT32 Augend,\r
2595 IN INT32 Addend,\r
2596 OUT INT32 *Result\r
2597 );\r
2598\r
2599/**\r
2600 INTN Addition\r
2601\r
2602 Performs the requested operation using the input parameters into a value\r
2603 specified by Result type and stores the converted value into the caller\r
2604 allocated output buffer specified by Result. The caller must pass in a\r
2605 Result buffer that is at least as large as the Result type.\r
2606\r
2607 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2608\r
2609 If the requested operation results in an overflow or an underflow condition,\r
2610 then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2611\r
2612 @param[in] Augend A number to which addend will be added\r
2613 @param[in] Addend A number to be added to another\r
2614 @param[out] Result Pointer to the result of addition\r
2615\r
2616 @retval RETURN_SUCCESS Successful addition\r
2617 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2618 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2619**/\r
2620RETURN_STATUS\r
2621EFIAPI\r
2622SafeIntnAdd (\r
2623 IN INTN Augend,\r
2624 IN INTN Addend,\r
2625 OUT INTN *Result\r
2626 );\r
2627\r
2628/**\r
2629 INT64 Addition\r
2630\r
2631 Performs the requested operation using the input parameters into a value\r
2632 specified by Result type and stores the converted value into the caller\r
2633 allocated output buffer specified by Result. The caller must pass in a\r
2634 Result buffer that is at least as large as the Result type.\r
2635\r
2636 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2637\r
2638 If the requested operation results in an overflow or an underflow condition,\r
2639 then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2640\r
2641 @param[in] Augend A number to which addend will be added\r
2642 @param[in] Addend A number to be added to another\r
2643 @param[out] Result Pointer to the result of addition\r
2644\r
2645 @retval RETURN_SUCCESS Successful addition\r
2646 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2647 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2648**/\r
2649RETURN_STATUS\r
2650EFIAPI\r
2651SafeInt64Add (\r
2652 IN INT64 Augend,\r
2653 IN INT64 Addend,\r
2654 OUT INT64 *Result\r
2655 );\r
2656\r
2657//\r
2658// Signed subtraction functions\r
2659//\r
2660\r
2661/**\r
2662 INT8 Subtraction\r
2663\r
2664 Performs the requested operation using the input parameters into a value\r
2665 specified by Result type and stores the converted value into the caller\r
2666 allocated output buffer specified by Result. The caller must pass in a\r
2667 Result buffer that is at least as large as the Result type.\r
2668\r
2669 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2670\r
2671 If the requested operation results in an overflow or an underflow condition,\r
2672 then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2673\r
2674 @param[in] Minuend A number from which another is to be subtracted.\r
2675 @param[in] Subtrahend A number to be subtracted from another\r
2676 @param[out] Result Pointer to the result of subtraction\r
2677\r
2678 @retval RETURN_SUCCESS Successful subtraction\r
2679 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2680 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2681**/\r
2682RETURN_STATUS\r
2683EFIAPI\r
2684SafeInt8Sub (\r
2685 IN INT8 Minuend,\r
2686 IN INT8 Subtrahend,\r
2687 OUT INT8 *Result\r
2688 );\r
2689\r
2690/**\r
2691 CHAR8 Subtraction\r
2692\r
2693 Performs the requested operation using the input parameters into a value\r
2694 specified by Result type and stores the converted value into the caller\r
2695 allocated output buffer specified by Result. The caller must pass in a\r
2696 Result buffer that is at least as large as the Result type.\r
2697\r
2698 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2699\r
2700 If the requested operation results in an overflow or an underflow condition,\r
2701 then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2702\r
2703 @param[in] Minuend A number from which another is to be subtracted.\r
2704 @param[in] Subtrahend A number to be subtracted from another\r
2705 @param[out] Result Pointer to the result of subtraction\r
2706\r
2707 @retval RETURN_SUCCESS Successful subtraction\r
2708 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2709 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2710**/\r
2711RETURN_STATUS\r
2712EFIAPI\r
2713SafeChar8Sub (\r
2714 IN CHAR8 Minuend,\r
2715 IN CHAR8 Subtrahend,\r
2716 OUT CHAR8 *Result\r
2717 );\r
2718\r
2719/**\r
2720 INT16 Subtraction\r
2721\r
2722 Performs the requested operation using the input parameters into a value\r
2723 specified by Result type and stores the converted value into the caller\r
2724 allocated output buffer specified by Result. The caller must pass in a\r
2725 Result buffer that is at least as large as the Result type.\r
2726\r
2727 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2728\r
2729 If the requested operation results in an overflow or an underflow condition,\r
2730 then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2731\r
2732 @param[in] Minuend A number from which another is to be subtracted.\r
2733 @param[in] Subtrahend A number to be subtracted from another\r
2734 @param[out] Result Pointer to the result of subtraction\r
2735\r
2736 @retval RETURN_SUCCESS Successful subtraction\r
2737 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2738 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2739**/\r
2740RETURN_STATUS\r
2741EFIAPI\r
2742SafeInt16Sub (\r
2743 IN INT16 Minuend,\r
2744 IN INT16 Subtrahend,\r
2745 OUT INT16 *Result\r
2746 );\r
2747\r
2748/**\r
2749 INT32 Subtraction\r
2750\r
2751 Performs the requested operation using the input parameters into a value\r
2752 specified by Result type and stores the converted value into the caller\r
2753 allocated output buffer specified by Result. The caller must pass in a\r
2754 Result buffer that is at least as large as the Result type.\r
2755\r
2756 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2757\r
2758 If the requested operation results in an overflow or an underflow condition,\r
2759 then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2760\r
2761 @param[in] Minuend A number from which another is to be subtracted.\r
2762 @param[in] Subtrahend A number to be subtracted from another\r
2763 @param[out] Result Pointer to the result of subtraction\r
2764\r
2765 @retval RETURN_SUCCESS Successful subtraction\r
2766 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2767 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2768**/\r
2769RETURN_STATUS\r
2770EFIAPI\r
2771SafeInt32Sub (\r
2772 IN INT32 Minuend,\r
2773 IN INT32 Subtrahend,\r
2774 OUT INT32 *Result\r
2775 );\r
2776\r
2777/**\r
2778 INTN Subtraction\r
2779\r
2780 Performs the requested operation using the input parameters into a value\r
2781 specified by Result type and stores the converted value into the caller\r
2782 allocated output buffer specified by Result. The caller must pass in a\r
2783 Result buffer that is at least as large as the Result type.\r
2784\r
2785 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2786\r
2787 If the requested operation results in an overflow or an underflow condition,\r
2788 then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2789\r
2790 @param[in] Minuend A number from which another is to be subtracted.\r
2791 @param[in] Subtrahend A number to be subtracted from another\r
2792 @param[out] Result Pointer to the result of subtraction\r
2793\r
2794 @retval RETURN_SUCCESS Successful subtraction\r
2795 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2796 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2797**/\r
2798RETURN_STATUS\r
2799EFIAPI\r
2800SafeIntnSub (\r
2801 IN INTN Minuend,\r
2802 IN INTN Subtrahend,\r
2803 OUT INTN *Result\r
2804 );\r
2805\r
2806/**\r
2807 INT64 Subtraction\r
2808\r
2809 Performs the requested operation using the input parameters into a value\r
2810 specified by Result type and stores the converted value into the caller\r
2811 allocated output buffer specified by Result. The caller must pass in a\r
2812 Result buffer that is at least as large as the Result type.\r
2813\r
2814 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2815\r
2816 If the requested operation results in an overflow or an underflow condition,\r
2817 then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2818\r
2819 @param[in] Minuend A number from which another is to be subtracted.\r
2820 @param[in] Subtrahend A number to be subtracted from another\r
2821 @param[out] Result Pointer to the result of subtraction\r
2822\r
2823 @retval RETURN_SUCCESS Successful subtraction\r
2824 @retval RETURN_BUFFER_TOO_SMALL Underflow\r
2825 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2826**/\r
2827RETURN_STATUS\r
2828EFIAPI\r
2829SafeInt64Sub (\r
2830 IN INT64 Minuend,\r
2831 IN INT64 Subtrahend,\r
2832 OUT INT64 *Result\r
2833 );\r
2834\r
2835//\r
2836// Signed multiplication functions\r
2837//\r
2838\r
2839/**\r
2840 INT8 multiplication\r
2841\r
2842 Performs the requested operation using the input parameters into a value\r
2843 specified by Result type and stores the converted value into the caller\r
2844 allocated output buffer specified by Result. The caller must pass in a\r
2845 Result buffer that is at least as large as the Result type.\r
2846\r
2847 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2848\r
2849 If the requested operation results in an overflow or an underflow condition,\r
2850 then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2851\r
2852 @param[in] Multiplicand A number that is to be multiplied by another\r
2853 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2854 @param[out] Result Pointer to the result of multiplication\r
2855\r
2856 @retval RETURN_SUCCESS Successful multiplication\r
2857 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2858 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2859**/\r
2860RETURN_STATUS\r
2861EFIAPI\r
2862SafeInt8Mult (\r
2863 IN INT8 Multiplicand,\r
2864 IN INT8 Multiplier,\r
2865 OUT INT8 *Result\r
2866 );\r
2867\r
2868/**\r
2869 CHAR8 multiplication\r
2870\r
2871 Performs the requested operation using the input parameters into a value\r
2872 specified by Result type and stores the converted value into the caller\r
2873 allocated output buffer specified by Result. The caller must pass in a\r
2874 Result buffer that is at least as large as the Result type.\r
2875\r
2876 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2877\r
2878 If the requested operation results in an overflow or an underflow condition,\r
2879 then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2880\r
2881 @param[in] Multiplicand A number that is to be multiplied by another\r
2882 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2883 @param[out] Result Pointer to the result of multiplication\r
2884\r
2885 @retval RETURN_SUCCESS Successful multiplication\r
2886 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2887 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2888**/\r
2889RETURN_STATUS\r
2890EFIAPI\r
2891SafeChar8Mult (\r
2892 IN CHAR8 Multiplicand,\r
2893 IN CHAR8 Multiplier,\r
2894 OUT CHAR8 *Result\r
2895 );\r
2896\r
2897/**\r
2898 INT16 multiplication\r
2899\r
2900 Performs the requested operation using the input parameters into a value\r
2901 specified by Result type and stores the converted value into the caller\r
2902 allocated output buffer specified by Result. The caller must pass in a\r
2903 Result buffer that is at least as large as the Result type.\r
2904\r
2905 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2906\r
2907 If the requested operation results in an overflow or an underflow condition,\r
2908 then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2909\r
2910 @param[in] Multiplicand A number that is to be multiplied by another\r
2911 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2912 @param[out] Result Pointer to the result of multiplication\r
2913\r
2914 @retval RETURN_SUCCESS Successful multiplication\r
2915 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2916 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2917**/\r
2918RETURN_STATUS\r
2919EFIAPI\r
2920SafeInt16Mult (\r
2921 IN INT16 Multiplicand,\r
2922 IN INT16 Multiplier,\r
2923 OUT INT16 *Result\r
2924 );\r
2925\r
2926/**\r
2927 INT32 multiplication\r
2928\r
2929 Performs the requested operation using the input parameters into a value\r
2930 specified by Result type and stores the converted value into the caller\r
2931 allocated output buffer specified by Result. The caller must pass in a\r
2932 Result buffer that is at least as large as the Result type.\r
2933\r
2934 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2935\r
2936 If the requested operation results in an overflow or an underflow condition,\r
2937 then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2938\r
2939 @param[in] Multiplicand A number that is to be multiplied by another\r
2940 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2941 @param[out] Result Pointer to the result of multiplication\r
2942\r
2943 @retval RETURN_SUCCESS Successful multiplication\r
2944 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2945 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2946**/\r
2947RETURN_STATUS\r
2948EFIAPI\r
2949SafeInt32Mult (\r
2950 IN INT32 Multiplicand,\r
2951 IN INT32 Multiplier,\r
2952 OUT INT32 *Result\r
2953 );\r
2954\r
2955/**\r
2956 INTN multiplication\r
2957\r
2958 Performs the requested operation using the input parameters into a value\r
2959 specified by Result type and stores the converted value into the caller\r
2960 allocated output buffer specified by Result. The caller must pass in a\r
2961 Result buffer that is at least as large as the Result type.\r
2962\r
2963 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2964\r
2965 If the requested operation results in an overflow or an underflow condition,\r
2966 then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2967\r
2968 @param[in] Multiplicand A number that is to be multiplied by another\r
2969 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2970 @param[out] Result Pointer to the result of multiplication\r
2971\r
2972 @retval RETURN_SUCCESS Successful multiplication\r
2973 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
2974 @retval RETURN_INVALID_PARAMETER Result is NULL\r
2975**/\r
2976RETURN_STATUS\r
2977EFIAPI\r
2978SafeIntnMult (\r
2979 IN INTN Multiplicand,\r
2980 IN INTN Multiplier,\r
2981 OUT INTN *Result\r
2982 );\r
2983\r
2984/**\r
2985 INT64 multiplication\r
2986\r
2987 Performs the requested operation using the input parameters into a value\r
2988 specified by Result type and stores the converted value into the caller\r
2989 allocated output buffer specified by Result. The caller must pass in a\r
2990 Result buffer that is at least as large as the Result type.\r
2991\r
2992 If Result is NULL, RETURN_INVALID_PARAMETER is returned.\r
2993\r
2994 If the requested operation results in an overflow or an underflow condition,\r
2995 then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.\r
2996\r
2997 @param[in] Multiplicand A number that is to be multiplied by another\r
2998 @param[in] Multiplier A number by which the multiplicand is to be multiplied\r
2999 @param[out] Result Pointer to the result of multiplication\r
3000\r
3001 @retval RETURN_SUCCESS Successful multiplication\r
3002 @retval RETURN_BUFFER_TOO_SMALL Overflow\r
3003 @retval RETURN_INVALID_PARAMETER Result is NULL\r
3004**/\r
3005RETURN_STATUS\r
3006EFIAPI\r
3007SafeInt64Mult (\r
3008 IN INT64 Multiplicand,\r
3009 IN INT64 Multiplier,\r
3010 OUT INT64 *Result\r
3011 );\r
3012\r
3013#endif // __INT_SAFE_LIB_H__\r