Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (20 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c
r85718 r99404 10 10 #include "PxeBcImpl.h" 11 11 12 CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = {12 CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = { 13 13 "blksize", 14 14 "timeout", … … 18 18 }; 19 19 20 21 20 /** 22 21 This is a callback function when packets are received or transmitted in Mtftp driver. … … 40 39 EFIAPI 41 40 PxeBcMtftp6CheckPacket ( 42 IN EFI_MTFTP6_PROTOCOL 43 IN EFI_MTFTP6_TOKEN 44 IN UINT16 45 IN EFI_MTFTP6_PACKET 46 ) 47 { 48 PXEBC_PRIVATE_DATA *Private;49 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;50 EFI_STATUS Status;51 52 Private = (PXEBC_PRIVATE_DATA *)Token->Context;53 Callback 54 Status 41 IN EFI_MTFTP6_PROTOCOL *This, 42 IN EFI_MTFTP6_TOKEN *Token, 43 IN UINT16 PacketLen, 44 IN EFI_MTFTP6_PACKET *Packet 45 ) 46 { 47 PXEBC_PRIVATE_DATA *Private; 48 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback; 49 EFI_STATUS Status; 50 51 Private = (PXEBC_PRIVATE_DATA *)Token->Context; 52 Callback = Private->PxeBcCallback; 53 Status = EFI_SUCCESS; 55 54 56 55 if (Packet->OpCode == EFI_MTFTP6_OPCODE_ERROR) { … … 59 58 // 60 59 Private->Mode.TftpErrorReceived = TRUE; 61 Private->Mode.TftpError.ErrorCode = (UINT8) 60 Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode; 62 61 AsciiStrnCpyS ( 63 62 Private->Mode.TftpError.ErrorString, 64 63 PXE_MTFTP_ERROR_STRING_LENGTH, 65 (CHAR8 *) 64 (CHAR8 *)Packet->Error.ErrorMessage, 66 65 PXE_MTFTP_ERROR_STRING_LENGTH - 1 67 66 ); … … 74 73 // 75 74 Status = Callback->Callback ( 76 Callback,77 Private->Function,78 TRUE,79 PacketLen,80 (EFI_PXE_BASE_CODE_PACKET *)Packet81 );75 Callback, 76 Private->Function, 77 TRUE, 78 PacketLen, 79 (EFI_PXE_BASE_CODE_PACKET *)Packet 80 ); 82 81 if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) { 83 82 // … … 96 95 } 97 96 98 99 97 /** 100 98 This function is to get the size of a file using Tftp. … … 115 113 EFI_STATUS 116 114 PxeBcMtftp6GetFileSize ( 117 IN PXEBC_PRIVATE_DATA 118 IN EFI_MTFTP6_CONFIG_DATA 119 IN UINT8 120 IN UINTN 121 IN UINTN 122 IN OUT UINT64 123 ) 124 { 125 EFI_MTFTP6_PROTOCOL 126 EFI_MTFTP6_OPTION 127 EFI_MTFTP6_PACKET 128 EFI_MTFTP6_OPTION 129 UINT32 130 UINT8 131 UINTN 132 UINT32 133 EFI_STATUS 115 IN PXEBC_PRIVATE_DATA *Private, 116 IN EFI_MTFTP6_CONFIG_DATA *Config, 117 IN UINT8 *Filename, 118 IN UINTN *BlockSize, 119 IN UINTN *WindowSize, 120 IN OUT UINT64 *BufferSize 121 ) 122 { 123 EFI_MTFTP6_PROTOCOL *Mtftp6; 124 EFI_MTFTP6_OPTION ReqOpt[3]; 125 EFI_MTFTP6_PACKET *Packet; 126 EFI_MTFTP6_OPTION *Option; 127 UINT32 PktLen; 128 UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX]; 129 UINTN OptBufSize; 130 UINT32 OptCnt; 131 EFI_STATUS Status; 134 132 135 133 *BufferSize = 0; … … 151 149 // Build the required options for get info. 152 150 // 153 ReqOpt[0].OptionStr = (UINT8 *) 151 ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX]; 154 152 PxeBcUintnToAscDec (0, OptBuf, OptBufSize); 155 ReqOpt[0].ValueStr 153 ReqOpt[0].ValueStr = OptBuf; 156 154 157 155 if (BlockSize != NULL) { 158 ReqOpt[OptCnt].OptionStr = (UINT8 *) 159 ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);160 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);156 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 157 ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 158 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 161 159 PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, OptBufSize); 162 160 OptCnt++; … … 164 162 165 163 if (WindowSize != NULL) { 166 ReqOpt[OptCnt].OptionStr = (UINT8 *) 167 ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);168 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);164 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX]; 165 ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 166 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 169 167 PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, OptBufSize); 170 168 OptCnt++; … … 176 174 Filename, 177 175 NULL, 178 (UINT8) 176 (UINT8)OptCnt, 179 177 ReqOpt, 180 178 &PktLen, … … 187 185 // 188 186 Private->Mode.TftpErrorReceived = TRUE; 189 Private->Mode.TftpError.ErrorCode = (UINT8) 187 Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode; 190 188 AsciiStrnCpyS ( 191 189 Private->Mode.TftpError.ErrorString, 192 190 PXE_MTFTP_ERROR_STRING_LENGTH, 193 (CHAR8 *) 191 (CHAR8 *)Packet->Error.ErrorMessage, 194 192 PXE_MTFTP_ERROR_STRING_LENGTH - 1 195 193 ); 196 194 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; 197 195 } 196 198 197 goto ON_ERROR; 199 198 } … … 207 206 PktLen, 208 207 Packet, 209 (UINT32 *) 208 (UINT32 *)&OptCnt, 210 209 &Option 211 210 ); … … 219 218 Status = EFI_NOT_FOUND; 220 219 while (OptCnt != 0) { 221 if (AsciiStrnCmp ((CHAR8 *) 222 *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *) 220 if (AsciiStrnCmp ((CHAR8 *)Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) { 221 *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *)(Option[OptCnt - 1].ValueStr)); 223 222 Status = EFI_SUCCESS; 224 223 } 224 225 225 OptCnt--; 226 226 } 227 227 228 FreePool (Option); 228 229 … … 231 232 FreePool (Packet); 232 233 } 234 233 235 Mtftp6->Configure (Mtftp6, NULL); 234 236 235 237 return Status; 236 238 } 237 238 239 239 240 /** … … 256 257 EFI_STATUS 257 258 PxeBcMtftp6ReadFile ( 258 IN PXEBC_PRIVATE_DATA 259 IN EFI_MTFTP6_CONFIG_DATA 260 IN UINT8 261 IN UINTN 262 IN UINTN 263 IN UINT8 264 IN OUT UINT64 265 IN BOOLEAN 266 ) 267 { 268 EFI_MTFTP6_PROTOCOL 269 EFI_MTFTP6_TOKEN 270 EFI_MTFTP6_OPTION 271 UINT32 272 UINT8 273 UINT8 274 EFI_STATUS 259 IN PXEBC_PRIVATE_DATA *Private, 260 IN EFI_MTFTP6_CONFIG_DATA *Config, 261 IN UINT8 *Filename, 262 IN UINTN *BlockSize, 263 IN UINTN *WindowSize, 264 IN UINT8 *BufferPtr, 265 IN OUT UINT64 *BufferSize, 266 IN BOOLEAN DontUseBuffer 267 ) 268 { 269 EFI_MTFTP6_PROTOCOL *Mtftp6; 270 EFI_MTFTP6_TOKEN Token; 271 EFI_MTFTP6_OPTION ReqOpt[2]; 272 UINT32 OptCnt; 273 UINT8 BlksizeBuf[10]; 274 UINT8 WindowsizeBuf[10]; 275 EFI_STATUS Status; 275 276 276 277 Status = EFI_DEVICE_ERROR; … … 285 286 286 287 if (BlockSize != NULL) { 287 ReqOpt[OptCnt].OptionStr = (UINT8 *) 288 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 288 289 ReqOpt[OptCnt].ValueStr = BlksizeBuf; 289 290 PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf)); … … 292 293 293 294 if (WindowSize != NULL) { 294 ReqOpt[OptCnt].OptionStr = (UINT8 *) 295 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX]; 295 296 ReqOpt[OptCnt].ValueStr = WindowsizeBuf; 296 297 PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf)); … … 298 299 } 299 300 300 301 Token.Event = NULL; 302 Token.OverrideData = NULL; 303 Token.Filename = Filename; 304 Token.ModeStr = NULL; 305 Token.OptionCount = OptCnt; 306 Token.OptionList = ReqOpt; 307 Token.Context = Private; 301 Token.Event = NULL; 302 Token.OverrideData = NULL; 303 Token.Filename = Filename; 304 Token.ModeStr = NULL; 305 Token.OptionCount = OptCnt; 306 Token.OptionList = ReqOpt; 307 Token.Context = Private; 308 308 309 309 if (DontUseBuffer) { 310 Token.BufferSize 311 Token.Buffer 310 Token.BufferSize = 0; 311 Token.Buffer = NULL; 312 312 } else { 313 Token.BufferSize 314 Token.Buffer 313 Token.BufferSize = *BufferSize; 314 Token.Buffer = BufferPtr; 315 315 } 316 316 … … 329 329 return Status; 330 330 } 331 332 331 333 332 /** … … 349 348 EFI_STATUS 350 349 PxeBcMtftp6WriteFile ( 351 IN PXEBC_PRIVATE_DATA 352 IN EFI_MTFTP6_CONFIG_DATA 353 IN UINT8 354 IN BOOLEAN 355 IN UINTN 356 IN UINT8 357 IN OUT UINT64 358 ) 359 { 360 EFI_MTFTP6_PROTOCOL 361 EFI_MTFTP6_TOKEN 362 EFI_MTFTP6_OPTION 363 UINT32 364 UINT8 365 EFI_STATUS 350 IN PXEBC_PRIVATE_DATA *Private, 351 IN EFI_MTFTP6_CONFIG_DATA *Config, 352 IN UINT8 *Filename, 353 IN BOOLEAN Overwrite, 354 IN UINTN *BlockSize, 355 IN UINT8 *BufferPtr, 356 IN OUT UINT64 *BufferSize 357 ) 358 { 359 EFI_MTFTP6_PROTOCOL *Mtftp6; 360 EFI_MTFTP6_TOKEN Token; 361 EFI_MTFTP6_OPTION ReqOpt[1]; 362 UINT32 OptCnt; 363 UINT8 OptBuf[128]; 364 EFI_STATUS Status; 366 365 367 366 Status = EFI_DEVICE_ERROR; … … 376 375 377 376 if (BlockSize != NULL) { 378 ReqOpt[0].OptionStr = (UINT8 *) 377 ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 379 378 ReqOpt[0].ValueStr = OptBuf; 380 379 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); … … 405 404 } 406 405 407 408 406 /** 409 407 This function is to read the data (file) from a directory using Tftp. … … 425 423 EFI_STATUS 426 424 PxeBcMtftp6ReadDirectory ( 427 IN PXEBC_PRIVATE_DATA 428 IN EFI_MTFTP6_CONFIG_DATA 429 IN UINT8 430 IN UINTN 431 IN UINTN 432 IN UINT8 433 IN OUT UINT64 434 IN BOOLEAN 435 ) 436 { 437 EFI_MTFTP6_PROTOCOL 438 EFI_MTFTP6_TOKEN 439 EFI_MTFTP6_OPTION 440 UINT32 441 UINT8 442 UINT8 443 EFI_STATUS 425 IN PXEBC_PRIVATE_DATA *Private, 426 IN EFI_MTFTP6_CONFIG_DATA *Config, 427 IN UINT8 *Filename, 428 IN UINTN *BlockSize, 429 IN UINTN *WindowSize, 430 IN UINT8 *BufferPtr, 431 IN OUT UINT64 *BufferSize, 432 IN BOOLEAN DontUseBuffer 433 ) 434 { 435 EFI_MTFTP6_PROTOCOL *Mtftp6; 436 EFI_MTFTP6_TOKEN Token; 437 EFI_MTFTP6_OPTION ReqOpt[2]; 438 UINT32 OptCnt; 439 UINT8 BlksizeBuf[10]; 440 UINT8 WindowsizeBuf[10]; 441 EFI_STATUS Status; 444 442 445 443 Status = EFI_DEVICE_ERROR; … … 454 452 455 453 if (BlockSize != NULL) { 456 ReqOpt[OptCnt].OptionStr = (UINT8 *) 454 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 457 455 ReqOpt[OptCnt].ValueStr = BlksizeBuf; 458 456 PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf)); … … 461 459 462 460 if (WindowSize != NULL) { 463 ReqOpt[OptCnt].OptionStr = (UINT8 *) 461 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX]; 464 462 ReqOpt[OptCnt].ValueStr = WindowsizeBuf; 465 463 PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf)); … … 467 465 } 468 466 469 Token.Event 470 Token.OverrideData 471 Token.Filename 472 Token.ModeStr 473 Token.OptionCount 474 Token.OptionList 475 Token.Context 467 Token.Event = NULL; 468 Token.OverrideData = NULL; 469 Token.Filename = Filename; 470 Token.ModeStr = NULL; 471 Token.OptionCount = OptCnt; 472 Token.OptionList = ReqOpt; 473 Token.Context = Private; 476 474 477 475 if (DontUseBuffer) { 478 Token.BufferSize 479 Token.Buffer 476 Token.BufferSize = 0; 477 Token.Buffer = NULL; 480 478 } else { 481 Token.BufferSize 482 Token.Buffer 479 Token.BufferSize = *BufferSize; 480 Token.Buffer = BufferPtr; 483 481 } 484 482 … … 497 495 return Status; 498 496 } 499 500 497 501 498 /** … … 520 517 EFIAPI 521 518 PxeBcMtftp4CheckPacket ( 522 IN EFI_MTFTP4_PROTOCOL 523 IN EFI_MTFTP4_TOKEN 524 IN UINT16 525 IN EFI_MTFTP4_PACKET 526 ) 527 { 528 PXEBC_PRIVATE_DATA *Private;529 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;530 EFI_STATUS Status;531 532 Private = (PXEBC_PRIVATE_DATA *)Token->Context;533 Callback 534 Status 519 IN EFI_MTFTP4_PROTOCOL *This, 520 IN EFI_MTFTP4_TOKEN *Token, 521 IN UINT16 PacketLen, 522 IN EFI_MTFTP4_PACKET *Packet 523 ) 524 { 525 PXEBC_PRIVATE_DATA *Private; 526 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback; 527 EFI_STATUS Status; 528 529 Private = (PXEBC_PRIVATE_DATA *)Token->Context; 530 Callback = Private->PxeBcCallback; 531 Status = EFI_SUCCESS; 535 532 536 533 if (Packet->OpCode == EFI_MTFTP4_OPCODE_ERROR) { … … 539 536 // 540 537 Private->Mode.TftpErrorReceived = TRUE; 541 Private->Mode.TftpError.ErrorCode = (UINT8) 538 Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode; 542 539 AsciiStrnCpyS ( 543 540 Private->Mode.TftpError.ErrorString, 544 541 PXE_MTFTP_ERROR_STRING_LENGTH, 545 (CHAR8 *) 542 (CHAR8 *)Packet->Error.ErrorMessage, 546 543 PXE_MTFTP_ERROR_STRING_LENGTH - 1 547 544 ); … … 554 551 // 555 552 Status = Callback->Callback ( 556 Callback,557 Private->Function,558 TRUE,559 PacketLen,560 (EFI_PXE_BASE_CODE_PACKET *)Packet561 );553 Callback, 554 Private->Function, 555 TRUE, 556 PacketLen, 557 (EFI_PXE_BASE_CODE_PACKET *)Packet 558 ); 562 559 if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) { 563 560 // … … 576 573 } 577 574 578 579 575 /** 580 576 This function is to get size of a file using Tftp. … … 595 591 EFI_STATUS 596 592 PxeBcMtftp4GetFileSize ( 597 IN PXEBC_PRIVATE_DATA 598 IN EFI_MTFTP4_CONFIG_DATA 599 IN UINT8 600 IN UINTN 601 IN UINTN 602 IN OUT UINT64 603 ) 604 { 605 EFI_MTFTP4_PROTOCOL *Mtftp4;606 EFI_MTFTP4_OPTION ReqOpt[3];607 EFI_MTFTP4_PACKET *Packet;608 EFI_MTFTP4_OPTION *Option;609 UINT32 PktLen;610 UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX];611 UINTN OptBufSize;612 UINT32 OptCnt;613 EFI_STATUS Status;593 IN PXEBC_PRIVATE_DATA *Private, 594 IN EFI_MTFTP4_CONFIG_DATA *Config, 595 IN UINT8 *Filename, 596 IN UINTN *BlockSize, 597 IN UINTN *WindowSize, 598 IN OUT UINT64 *BufferSize 599 ) 600 { 601 EFI_MTFTP4_PROTOCOL *Mtftp4; 602 EFI_MTFTP4_OPTION ReqOpt[3]; 603 EFI_MTFTP4_PACKET *Packet; 604 EFI_MTFTP4_OPTION *Option; 605 UINT32 PktLen; 606 UINT8 OptBuf[PXE_MTFTP_OPTBUF_MAXNUM_INDEX]; 607 UINTN OptBufSize; 608 UINT32 OptCnt; 609 EFI_STATUS Status; 614 610 615 611 *BufferSize = 0; … … 631 627 // Build the required options for get info. 632 628 // 633 ReqOpt[0].OptionStr = (UINT8 *) 629 ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX]; 634 630 PxeBcUintnToAscDec (0, OptBuf, OptBufSize); 635 ReqOpt[0].ValueStr 631 ReqOpt[0].ValueStr = OptBuf; 636 632 637 633 if (BlockSize != NULL) { 638 ReqOpt[OptCnt].OptionStr = (UINT8 *) 639 ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);640 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);634 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 635 ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 636 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 641 637 PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, OptBufSize); 642 638 OptCnt++; … … 644 640 645 641 if (WindowSize != NULL) { 646 ReqOpt[OptCnt].OptionStr = (UINT8 *) 647 ReqOpt[OptCnt].ValueStr = (UINT8 *) (ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);648 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1);642 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX]; 643 ReqOpt[OptCnt].ValueStr = (UINT8 *)(ReqOpt[OptCnt-1].ValueStr + AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 644 OptBufSize -= (AsciiStrLen ((CHAR8 *)ReqOpt[OptCnt-1].ValueStr) + 1); 649 645 PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, OptBufSize); 650 646 OptCnt++; … … 656 652 Filename, 657 653 NULL, 658 (UINT8) 654 (UINT8)OptCnt, 659 655 ReqOpt, 660 656 &PktLen, … … 667 663 // 668 664 Private->Mode.TftpErrorReceived = TRUE; 669 Private->Mode.TftpError.ErrorCode = (UINT8) 665 Private->Mode.TftpError.ErrorCode = (UINT8)Packet->Error.ErrorCode; 670 666 AsciiStrnCpyS ( 671 667 Private->Mode.TftpError.ErrorString, 672 668 PXE_MTFTP_ERROR_STRING_LENGTH, 673 (CHAR8 *) 669 (CHAR8 *)Packet->Error.ErrorMessage, 674 670 PXE_MTFTP_ERROR_STRING_LENGTH - 1 675 671 ); 676 672 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; 677 673 } 674 678 675 goto ON_ERROR; 679 676 } … … 687 684 PktLen, 688 685 Packet, 689 (UINT32 *) 686 (UINT32 *)&OptCnt, 690 687 &Option 691 688 ); … … 699 696 Status = EFI_NOT_FOUND; 700 697 while (OptCnt != 0) { 701 if (AsciiStrnCmp ((CHAR8 *) 702 *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *) 698 if (AsciiStrnCmp ((CHAR8 *)Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) { 699 *BufferSize = AsciiStrDecimalToUint64 ((CHAR8 *)(Option[OptCnt - 1].ValueStr)); 703 700 Status = EFI_SUCCESS; 704 701 } 702 705 703 OptCnt--; 706 704 } 705 707 706 FreePool (Option); 708 707 … … 711 710 FreePool (Packet); 712 711 } 712 713 713 Mtftp4->Configure (Mtftp4, NULL); 714 714 715 715 return Status; 716 716 } 717 718 717 719 718 /** … … 736 735 EFI_STATUS 737 736 PxeBcMtftp4ReadFile ( 738 IN PXEBC_PRIVATE_DATA 739 IN EFI_MTFTP4_CONFIG_DATA 740 IN UINT8 741 IN UINTN 742 IN UINTN 743 IN UINT8 744 IN OUT UINT64 745 IN BOOLEAN 746 ) 747 { 748 EFI_MTFTP4_PROTOCOL *Mtftp4;749 EFI_MTFTP4_TOKEN Token;750 EFI_MTFTP4_OPTION ReqOpt[2];751 UINT32 OptCnt;752 UINT8 BlksizeBuf[10];753 UINT8 WindowsizeBuf[10];754 EFI_STATUS Status;737 IN PXEBC_PRIVATE_DATA *Private, 738 IN EFI_MTFTP4_CONFIG_DATA *Config, 739 IN UINT8 *Filename, 740 IN UINTN *BlockSize, 741 IN UINTN *WindowSize, 742 IN UINT8 *BufferPtr, 743 IN OUT UINT64 *BufferSize, 744 IN BOOLEAN DontUseBuffer 745 ) 746 { 747 EFI_MTFTP4_PROTOCOL *Mtftp4; 748 EFI_MTFTP4_TOKEN Token; 749 EFI_MTFTP4_OPTION ReqOpt[2]; 750 UINT32 OptCnt; 751 UINT8 BlksizeBuf[10]; 752 UINT8 WindowsizeBuf[10]; 753 EFI_STATUS Status; 755 754 756 755 Status = EFI_DEVICE_ERROR; … … 765 764 766 765 if (BlockSize != NULL) { 767 ReqOpt[OptCnt].OptionStr = (UINT8 *) 766 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 768 767 ReqOpt[OptCnt].ValueStr = BlksizeBuf; 769 768 PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf)); … … 772 771 773 772 if (WindowSize != NULL) { 774 ReqOpt[OptCnt].OptionStr = (UINT8 *) 773 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX]; 775 774 ReqOpt[OptCnt].ValueStr = WindowsizeBuf; 776 775 PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf)); … … 778 777 } 779 778 780 Token.Event 781 Token.OverrideData 782 Token.Filename 783 Token.ModeStr 784 Token.OptionCount 785 Token.OptionList 786 Token.Context 779 Token.Event = NULL; 780 Token.OverrideData = NULL; 781 Token.Filename = Filename; 782 Token.ModeStr = NULL; 783 Token.OptionCount = OptCnt; 784 Token.OptionList = ReqOpt; 785 Token.Context = Private; 787 786 788 787 if (DontUseBuffer) { 789 Token.BufferSize 790 Token.Buffer 788 Token.BufferSize = 0; 789 Token.Buffer = NULL; 791 790 } else { 792 Token.BufferSize 793 Token.Buffer 791 Token.BufferSize = *BufferSize; 792 Token.Buffer = BufferPtr; 794 793 } 795 794 … … 808 807 return Status; 809 808 } 810 811 809 812 810 /** … … 828 826 EFI_STATUS 829 827 PxeBcMtftp4WriteFile ( 830 IN PXEBC_PRIVATE_DATA 831 IN EFI_MTFTP4_CONFIG_DATA 832 IN UINT8 833 IN BOOLEAN 834 IN UINTN 835 IN UINT8 836 IN OUT UINT64 837 ) 838 { 839 EFI_MTFTP4_PROTOCOL *Mtftp4;840 EFI_MTFTP4_TOKEN Token;841 EFI_MTFTP4_OPTION ReqOpt[1];842 UINT32 OptCnt;843 UINT8 OptBuf[128];844 EFI_STATUS Status;828 IN PXEBC_PRIVATE_DATA *Private, 829 IN EFI_MTFTP4_CONFIG_DATA *Config, 830 IN UINT8 *Filename, 831 IN BOOLEAN Overwrite, 832 IN UINTN *BlockSize, 833 IN UINT8 *BufferPtr, 834 IN OUT UINT64 *BufferSize 835 ) 836 { 837 EFI_MTFTP4_PROTOCOL *Mtftp4; 838 EFI_MTFTP4_TOKEN Token; 839 EFI_MTFTP4_OPTION ReqOpt[1]; 840 UINT32 OptCnt; 841 UINT8 OptBuf[128]; 842 EFI_STATUS Status; 845 843 846 844 Status = EFI_DEVICE_ERROR; … … 849 847 Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT; 850 848 851 Status 849 Status = Mtftp4->Configure (Mtftp4, Config); 852 850 if (EFI_ERROR (Status)) { 853 851 return Status; … … 855 853 856 854 if (BlockSize != NULL) { 857 ReqOpt[0].OptionStr = (UINT8 *) 855 ReqOpt[0].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 858 856 ReqOpt[0].ValueStr = OptBuf; 859 857 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); … … 884 882 } 885 883 886 887 884 /** 888 885 This function is to get data (file) from a directory using Tftp. … … 904 901 EFI_STATUS 905 902 PxeBcMtftp4ReadDirectory ( 906 IN PXEBC_PRIVATE_DATA 907 IN EFI_MTFTP4_CONFIG_DATA 908 IN UINT8 909 IN UINTN 910 IN UINTN 911 IN UINT8 912 IN OUT UINT64 913 IN BOOLEAN 914 ) 915 { 916 EFI_MTFTP4_PROTOCOL *Mtftp4;917 EFI_MTFTP4_TOKEN Token;918 EFI_MTFTP4_OPTION ReqOpt[2];919 UINT32 OptCnt;920 UINT8 BlksizeBuf[10];921 UINT8 WindowsizeBuf[10];922 EFI_STATUS Status;903 IN PXEBC_PRIVATE_DATA *Private, 904 IN EFI_MTFTP4_CONFIG_DATA *Config, 905 IN UINT8 *Filename, 906 IN UINTN *BlockSize, 907 IN UINTN *WindowSize, 908 IN UINT8 *BufferPtr, 909 IN OUT UINT64 *BufferSize, 910 IN BOOLEAN DontUseBuffer 911 ) 912 { 913 EFI_MTFTP4_PROTOCOL *Mtftp4; 914 EFI_MTFTP4_TOKEN Token; 915 EFI_MTFTP4_OPTION ReqOpt[2]; 916 UINT32 OptCnt; 917 UINT8 BlksizeBuf[10]; 918 UINT8 WindowsizeBuf[10]; 919 EFI_STATUS Status; 923 920 924 921 Status = EFI_DEVICE_ERROR; … … 933 930 934 931 if (BlockSize != NULL) { 935 ReqOpt[OptCnt].OptionStr = (UINT8 *) 932 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 936 933 ReqOpt[OptCnt].ValueStr = BlksizeBuf; 937 934 PxeBcUintnToAscDec (*BlockSize, ReqOpt[OptCnt].ValueStr, sizeof (BlksizeBuf)); … … 940 937 941 938 if (WindowSize != NULL) { 942 ReqOpt[OptCnt].OptionStr = (UINT8 *) 939 ReqOpt[OptCnt].OptionStr = (UINT8 *)mMtftpOptions[PXE_MTFTP_OPTION_WINDOWSIZE_INDEX]; 943 940 ReqOpt[OptCnt].ValueStr = WindowsizeBuf; 944 941 PxeBcUintnToAscDec (*WindowSize, ReqOpt[OptCnt].ValueStr, sizeof (WindowsizeBuf)); … … 946 943 } 947 944 948 Token.Event 949 Token.OverrideData 950 Token.Filename 951 Token.ModeStr 952 Token.OptionCount 953 Token.OptionList 954 Token.Context 945 Token.Event = NULL; 946 Token.OverrideData = NULL; 947 Token.Filename = Filename; 948 Token.ModeStr = NULL; 949 Token.OptionCount = OptCnt; 950 Token.OptionList = ReqOpt; 951 Token.Context = Private; 955 952 956 953 if (DontUseBuffer) { 957 Token.BufferSize 958 Token.Buffer 954 Token.BufferSize = 0; 955 Token.Buffer = NULL; 959 956 } else { 960 Token.BufferSize 961 Token.Buffer 957 Token.BufferSize = *BufferSize; 958 Token.Buffer = BufferPtr; 962 959 } 963 960 … … 976 973 return Status; 977 974 } 978 979 975 980 976 /** … … 996 992 EFI_STATUS 997 993 PxeBcTftpGetFileSize ( 998 IN PXEBC_PRIVATE_DATA 999 IN VOID 1000 IN UINT8 1001 IN UINTN 1002 IN UINTN 1003 IN OUT UINT64 994 IN PXEBC_PRIVATE_DATA *Private, 995 IN VOID *Config, 996 IN UINT8 *Filename, 997 IN UINTN *BlockSize, 998 IN UINTN *WindowSize, 999 IN OUT UINT64 *BufferSize 1004 1000 ) 1005 1001 { … … 1007 1003 return PxeBcMtftp6GetFileSize ( 1008 1004 Private, 1009 (EFI_MTFTP6_CONFIG_DATA *) 1005 (EFI_MTFTP6_CONFIG_DATA *)Config, 1010 1006 Filename, 1011 1007 BlockSize, … … 1016 1012 return PxeBcMtftp4GetFileSize ( 1017 1013 Private, 1018 (EFI_MTFTP4_CONFIG_DATA *) 1014 (EFI_MTFTP4_CONFIG_DATA *)Config, 1019 1015 Filename, 1020 1016 BlockSize, … … 1024 1020 } 1025 1021 } 1026 1027 1022 1028 1023 /** … … 1045 1040 EFI_STATUS 1046 1041 PxeBcTftpReadFile ( 1047 IN PXEBC_PRIVATE_DATA 1048 IN VOID 1049 IN UINT8 1050 IN UINTN 1051 IN UINTN 1052 IN UINT8 1053 IN OUT UINT64 1054 IN BOOLEAN 1042 IN PXEBC_PRIVATE_DATA *Private, 1043 IN VOID *Config, 1044 IN UINT8 *Filename, 1045 IN UINTN *BlockSize, 1046 IN UINTN *WindowSize, 1047 IN UINT8 *BufferPtr, 1048 IN OUT UINT64 *BufferSize, 1049 IN BOOLEAN DontUseBuffer 1055 1050 ) 1056 1051 { … … 1058 1053 return PxeBcMtftp6ReadFile ( 1059 1054 Private, 1060 (EFI_MTFTP6_CONFIG_DATA *) 1055 (EFI_MTFTP6_CONFIG_DATA *)Config, 1061 1056 Filename, 1062 1057 BlockSize, … … 1069 1064 return PxeBcMtftp4ReadFile ( 1070 1065 Private, 1071 (EFI_MTFTP4_CONFIG_DATA *) 1066 (EFI_MTFTP4_CONFIG_DATA *)Config, 1072 1067 Filename, 1073 1068 BlockSize, … … 1080 1075 } 1081 1076 1082 1083 1077 /** 1084 1078 This function is a wrapper to write file using TFTP. … … 1099 1093 EFI_STATUS 1100 1094 PxeBcTftpWriteFile ( 1101 IN PXEBC_PRIVATE_DATA 1102 IN VOID 1103 IN UINT8 1104 IN BOOLEAN 1105 IN UINTN 1106 IN UINT8 1107 IN OUT UINT64 1095 IN PXEBC_PRIVATE_DATA *Private, 1096 IN VOID *Config, 1097 IN UINT8 *Filename, 1098 IN BOOLEAN Overwrite, 1099 IN UINTN *BlockSize, 1100 IN UINT8 *BufferPtr, 1101 IN OUT UINT64 *BufferSize 1108 1102 ) 1109 1103 { … … 1111 1105 return PxeBcMtftp6WriteFile ( 1112 1106 Private, 1113 (EFI_MTFTP6_CONFIG_DATA *) 1107 (EFI_MTFTP6_CONFIG_DATA *)Config, 1114 1108 Filename, 1115 1109 Overwrite, … … 1121 1115 return PxeBcMtftp4WriteFile ( 1122 1116 Private, 1123 (EFI_MTFTP4_CONFIG_DATA *) 1117 (EFI_MTFTP4_CONFIG_DATA *)Config, 1124 1118 Filename, 1125 1119 Overwrite, … … 1130 1124 } 1131 1125 } 1132 1133 1126 1134 1127 /** … … 1151 1144 EFI_STATUS 1152 1145 PxeBcTftpReadDirectory ( 1153 IN PXEBC_PRIVATE_DATA 1154 IN VOID 1155 IN UINT8 1156 IN UINTN 1157 IN UINTN 1158 IN UINT8 1159 IN OUT UINT64 1160 IN BOOLEAN 1146 IN PXEBC_PRIVATE_DATA *Private, 1147 IN VOID *Config, 1148 IN UINT8 *Filename, 1149 IN UINTN *BlockSize, 1150 IN UINTN *WindowSize, 1151 IN UINT8 *BufferPtr, 1152 IN OUT UINT64 *BufferSize, 1153 IN BOOLEAN DontUseBuffer 1161 1154 ) 1162 1155 { … … 1164 1157 return PxeBcMtftp6ReadDirectory ( 1165 1158 Private, 1166 (EFI_MTFTP6_CONFIG_DATA *) 1159 (EFI_MTFTP6_CONFIG_DATA *)Config, 1167 1160 Filename, 1168 1161 BlockSize, … … 1175 1168 return PxeBcMtftp4ReadDirectory ( 1176 1169 Private, 1177 (EFI_MTFTP4_CONFIG_DATA *) 1170 (EFI_MTFTP4_CONFIG_DATA *)Config, 1178 1171 Filename, 1179 1172 BlockSize, … … 1185 1178 } 1186 1179 } 1187
Note:
See TracChangeset
for help on using the changeset viewer.