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