Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/EmbeddedPkg/Application
- Timestamp:
- Apr 14, 2023 3:17:44 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156854
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 6 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/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
r85718 r99404 21 21 EFI_STATUS 22 22 ValidateAndroidMediaDevicePath ( 23 IN EFI_DEVICE_PATH 23 IN EFI_DEVICE_PATH *DevicePath 24 24 ) 25 25 { 26 EFI_DEVICE_PATH_PROTOCOL 26 EFI_DEVICE_PATH_PROTOCOL *Node, *NextNode; 27 27 28 28 NextNode = DevicePath; 29 29 while (NextNode != NULL) { 30 30 Node = NextNode; 31 if (Node->Type == MEDIA_DEVICE_PATH && 32 Node->SubType == MEDIA_HARDDRIVE_DP) { 31 if ((Node->Type == MEDIA_DEVICE_PATH) && 32 (Node->SubType == MEDIA_HARDDRIVE_DP)) 33 { 33 34 return EFI_SUCCESS; 34 35 } 36 35 37 NextNode = NextDevicePathNode (Node); 36 38 } 39 37 40 return EFI_INVALID_PARAMETER; 38 41 } … … 41 44 EFIAPI 42 45 AndroidBootAppEntryPoint ( 43 IN EFI_HANDLE 44 IN EFI_SYSTEM_TABLE 46 IN EFI_HANDLE ImageHandle, 47 IN EFI_SYSTEM_TABLE *SystemTable 45 48 ) 46 49 { … … 57 60 BootPathStr = (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath); 58 61 ASSERT (BootPathStr != NULL); 59 Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, 60 (VOID **)&EfiDevicePathFromTextProtocol); 61 ASSERT_EFI_ERROR(Status); 62 Status = gBS->LocateProtocol ( 63 &gEfiDevicePathFromTextProtocolGuid, 64 NULL, 65 (VOID **)&EfiDevicePathFromTextProtocol 66 ); 67 ASSERT_EFI_ERROR (Status); 62 68 DevicePath = (EFI_DEVICE_PATH *)EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (BootPathStr); 63 69 ASSERT (DevicePath != NULL); … … 68 74 } 69 75 70 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, 71 &DevicePath, &Handle); 76 Status = gBS->LocateDevicePath ( 77 &gEfiDevicePathProtocolGuid, 78 &DevicePath, 79 &Handle 80 ); 72 81 if (EFI_ERROR (Status)) { 73 82 return Status; … … 77 86 Handle, 78 87 &gEfiBlockIoProtocolGuid, 79 (VOID **) 88 (VOID **)&BlockIo, 80 89 gImageHandle, 81 90 NULL, … … 87 96 } 88 97 89 MediaId = BlockIo->Media->MediaId;98 MediaId = BlockIo->Media->MediaId; 90 99 BlockSize = BlockIo->Media->BlockSize; 91 Buffer = AllocatePages (EFI_SIZE_TO_PAGES (sizeof(ANDROID_BOOTIMG_HEADER)));100 Buffer = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER))); 92 101 if (Buffer == NULL) { 93 102 return EFI_BUFFER_TOO_SMALL; 94 103 } 104 95 105 /* Load header of boot.img */ 96 106 Status = BlockIo->ReadBlocks ( … … 106 116 return Status; 107 117 } 118 108 119 BootImgSize = ALIGN_VALUE (BootImgSize, BlockSize); 109 FreePages (Buffer, EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER)));120 FreePages (Buffer, EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER))); 110 121 111 122 /* Both PartitionStart and PartitionSize are counted as block size. */ -
trunk/src/VBox/Devices/EFI/FirmwareNew/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
r85718 r99404 17 17 EFI_STATUS 18 18 ParseAndroidBootImg ( 19 IN VOID 19 IN VOID *BootImg, 20 20 OUT VOID **Kernel, 21 OUT UINTN 21 OUT UINTN *KernelSize, 22 22 OUT VOID **Ramdisk, 23 OUT UINTN 24 OUT CHAR8 23 OUT UINTN *RamdiskSize, 24 OUT CHAR8 *KernelArgs 25 25 ) 26 26 { 27 ANDROID_BOOTIMG_HEADER 28 UINT8 27 ANDROID_BOOTIMG_HEADER *Header; 28 UINT8 *BootImgBytePtr; 29 29 30 30 // Cast to UINT8 so we can do pointer arithmetic 31 BootImgBytePtr = (UINT8 *) 31 BootImgBytePtr = (UINT8 *)BootImg; 32 32 33 Header = (ANDROID_BOOTIMG_HEADER *) 33 Header = (ANDROID_BOOTIMG_HEADER *)BootImg; 34 34 35 if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC, 36 ANDROID_BOOT_MAGIC_LENGTH) != 0) { 35 if (AsciiStrnCmp ( 36 (CONST CHAR8 *)Header->BootMagic, 37 ANDROID_BOOT_MAGIC, 38 ANDROID_BOOT_MAGIC_LENGTH 39 ) != 0) 40 { 37 41 return EFI_INVALID_PARAMETER; 38 42 } … … 44 48 ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize)); 45 49 46 *KernelSize = Header->KernelSize;47 *Kernel = BootImgBytePtr + Header->PageSize;50 *KernelSize = Header->KernelSize; 51 *Kernel = BootImgBytePtr + Header->PageSize; 48 52 *RamdiskSize = Header->RamdiskSize; 49 53 50 54 if (Header->RamdiskSize != 0) { 51 *Ramdisk = (VOID *) 52 + Header->PageSize53 + ALIGN_VALUE (Header->KernelSize, Header->PageSize));55 *Ramdisk = (VOID *)(BootImgBytePtr 56 + Header->PageSize 57 + ALIGN_VALUE (Header->KernelSize, Header->PageSize)); 54 58 } 55 59 56 AsciiStrnCpyS (KernelArgs, ANDROID_BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs, 57 ANDROID_BOOTIMG_KERNEL_ARGS_SIZE); 60 AsciiStrnCpyS ( 61 KernelArgs, 62 ANDROID_BOOTIMG_KERNEL_ARGS_SIZE, 63 Header->KernelArgs, 64 ANDROID_BOOTIMG_KERNEL_ARGS_SIZE 65 ); 58 66 59 67 return EFI_SUCCESS; -
trunk/src/VBox/Devices/EFI/FirmwareNew/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
r85718 r99404 26 26 */ 27 27 28 STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport;29 STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform;30 31 STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;28 STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport; 29 STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform; 30 31 STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut; 32 32 33 33 typedef enum { … … 37 37 } ANDROID_FASTBOOT_STATE; 38 38 39 STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState;39 STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState; 40 40 41 41 // When in ExpectDataState, the number of bytes of data to expect: 42 STATIC UINT64 mNumDataBytes;42 STATIC UINT64 mNumDataBytes; 43 43 // .. and the number of bytes so far received this data phase 44 STATIC UINT64 mBytesReceivedSoFar;44 STATIC UINT64 mBytesReceivedSoFar; 45 45 // .. and the buffer to save data into 46 STATIC UINT8 *mDataBuffer = NULL;46 STATIC UINT8 *mDataBuffer = NULL; 47 47 48 48 // Event notify functions, from which gBS->Exit shouldn't be called, can signal 49 49 // this event when the application should exit 50 STATIC EFI_EVENT mFinishedEvent;51 52 STATIC EFI_EVENT mFatalSendErrorEvent;50 STATIC EFI_EVENT mFinishedEvent; 51 52 STATIC EFI_EVENT mFatalSendErrorEvent; 53 53 54 54 // This macro uses sizeof - only use it on arrays (i.e. string literals) 55 #define SEND_LITERAL(Str) mTransport->Send (\55 #define SEND_LITERAL(Str) mTransport->Send ( \ 56 56 sizeof (Str) - 1, \ 57 57 Str, \ 58 58 &mFatalSendErrorEvent \ 59 59 ) 60 #define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1)61 62 #define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z')63 64 #define FASTBOOT_STRING_MAX_LENGTH 25665 #define FASTBOOT_COMMAND_MAX_LENGTH 6460 #define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1) 61 62 #define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z') 63 64 #define FASTBOOT_STRING_MAX_LENGTH 256 65 #define FASTBOOT_COMMAND_MAX_LENGTH 64 66 66 67 67 STATIC 68 68 VOID 69 69 HandleGetVar ( 70 IN CHAR8 *CmdArg71 ) 72 { 73 CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY";74 EFI_STATUS Status;70 IN CHAR8 *CmdArg 71 ) 72 { 73 CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY"; 74 EFI_STATUS Status; 75 75 76 76 // Respond to getvar:version with 0.4 (version of Fastboot protocol) 77 if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1 77 if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1)) { 78 78 SEND_LITERAL ("OKAY" ANDROID_FASTBOOT_VERSION); 79 79 } else { … … 91 91 VOID 92 92 HandleDownload ( 93 IN CHAR8 *NumBytesString94 ) 95 { 96 CHAR8 97 CHAR16 93 IN CHAR8 *NumBytesString 94 ) 95 { 96 CHAR8 Response[13]; 97 CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH]; 98 98 99 99 // Argument is 8-character ASCII string hex representation of number of bytes … … 123 123 } else { 124 124 ZeroMem (Response, sizeof Response); 125 AsciiSPrint (Response, sizeof Response, "DATA%x", 126 (UINT32)mNumDataBytes); 125 AsciiSPrint ( 126 Response, 127 sizeof Response, 128 "DATA%x", 129 (UINT32)mNumDataBytes 130 ); 127 131 mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent); 128 132 129 mState = ExpectDataState;133 mState = ExpectDataState; 130 134 mBytesReceivedSoFar = 0; 131 135 } … … 135 139 VOID 136 140 HandleFlash ( 137 IN CHAR8 *PartitionName141 IN CHAR8 *PartitionName 138 142 ) 139 143 { … … 162 166 SEND_LITERAL ("FAILError flashing partition."); 163 167 mTextOut->OutputString (mTextOut, L"Error flashing partition.\r\n"); 164 DEBUG (( EFI_D_ERROR, "Couldn't flash image: %r\n", Status));168 DEBUG ((DEBUG_ERROR, "Couldn't flash image: %r\n", Status)); 165 169 } else { 166 170 mTextOut->OutputString (mTextOut, L"Done.\r\n"); … … 172 176 VOID 173 177 HandleErase ( 174 IN CHAR8 *PartitionName178 IN CHAR8 *PartitionName 175 179 ) 176 180 { … … 185 189 if (EFI_ERROR (Status)) { 186 190 SEND_LITERAL ("FAILCheck device console."); 187 DEBUG (( EFI_D_ERROR, "Couldn't erase image: %r\n", Status));191 DEBUG ((DEBUG_ERROR, "Couldn't erase image: %r\n", Status)); 188 192 } else { 189 193 SEND_LITERAL ("OKAY"); … … 197 201 ) 198 202 { 199 EFI_STATUS Status;203 EFI_STATUS Status; 200 204 201 205 mTextOut->OutputString (mTextOut, L"Booting downloaded image\r\n"); … … 213 217 Status = BootAndroidBootImg (mNumDataBytes, mDataBuffer); 214 218 if (EFI_ERROR (Status)) { 215 DEBUG ((EFI_D_ERROR, "Failed to boot downloaded image: %r\n", Status)); 216 } 219 DEBUG ((DEBUG_ERROR, "Failed to boot downloaded image: %r\n", Status)); 220 } 221 217 222 // We shouldn't get here 218 223 } … … 221 226 VOID 222 227 HandleOemCommand ( 223 IN CHAR8 *Command228 IN CHAR8 *Command 224 229 ) 225 230 { … … 242 247 AcceptCmd ( 243 248 IN UINTN Size, 244 IN CONST CHAR8 *Data245 ) 246 { 247 CHAR8 249 IN CONST CHAR8 *Data 250 ) 251 { 252 CHAR8 Command[FASTBOOT_COMMAND_MAX_LENGTH + 1]; 248 253 249 254 // Max command size is 64 bytes … … 283 288 SEND_LITERAL ("INFOreboot-bootloader not supported, rebooting normally."); 284 289 } 290 285 291 SEND_LITERAL ("OKAY"); 286 292 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); 287 293 288 294 // Shouldn't get here 289 DEBUG (( EFI_D_ERROR, "Fastboot: gRT->ResetSystem didn't work\n"));295 DEBUG ((DEBUG_ERROR, "Fastboot: gRT->ResetSystem didn't work\n")); 290 296 } else if (MATCH_CMD_LITERAL ("powerdown", Command)) { 291 297 SEND_LITERAL ("OKAY"); … … 293 299 294 300 // Shouldn't get here 295 DEBUG (( EFI_D_ERROR, "Fastboot: gRT->ResetSystem didn't work\n"));301 DEBUG ((DEBUG_ERROR, "Fastboot: gRT->ResetSystem didn't work\n")); 296 302 } else if (MATCH_CMD_LITERAL ("oem", Command)) { 297 303 // The "oem" command isn't in the specification, but it was observed in the … … 314 320 AcceptData ( 315 321 IN UINTN Size, 316 IN VOID *Data317 ) 318 { 319 UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar;320 CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];321 STATIC UINTN Count = 0;322 IN VOID *Data 323 ) 324 { 325 UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar; 326 CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH]; 327 STATIC UINTN Count = 0; 322 328 323 329 // Protocol doesn't say anything about sending extra data so just ignore it. … … 332 338 // Show download progress. Don't do it for every packet as outputting text 333 339 // might be time consuming - do it on the last packet and on every 32nd packet 334 if (( Count++ % 32) == 0 || Size == RemainingBytes) {340 if (((Count++ % 32) == 0) || (Size == RemainingBytes)) { 335 341 // (Note no newline in format string - it will overwrite the line each time) 336 342 UnicodeSPrint ( … … 364 370 DataReady ( 365 371 IN EFI_EVENT Event, 366 IN VOID *Context372 IN VOID *Context 367 373 ) 368 374 { 369 375 UINTN Size; 370 VOID *Data;376 VOID *Data; 371 377 EFI_STATUS Status; 372 378 … … 375 381 if (!EFI_ERROR (Status)) { 376 382 if (mState == ExpectCmdState) { 377 AcceptCmd (Size, (CHAR8 *) 383 AcceptCmd (Size, (CHAR8 *)Data); 378 384 } else if (mState == ExpectDataState) { 379 385 AcceptData (Size, Data); … … 381 387 ASSERT (FALSE); 382 388 } 389 383 390 FreePool (Data); 384 391 } … … 402 409 FatalErrorNotify ( 403 410 IN EFI_EVENT Event, 404 IN VOID *Context411 IN VOID *Context 405 412 ) 406 413 { … … 412 419 EFIAPI 413 420 FastbootAppEntryPoint ( 414 IN EFI_HANDLE 415 IN EFI_SYSTEM_TABLE 421 IN EFI_HANDLE ImageHandle, 422 IN EFI_SYSTEM_TABLE *SystemTable 416 423 ) 417 424 { … … 420 427 EFI_EVENT WaitEventArray[2]; 421 428 UINTN EventIndex; 422 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;429 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn; 423 430 EFI_INPUT_KEY Key; 424 431 … … 426 433 427 434 Status = gBS->LocateProtocol ( 428 &gAndroidFastbootTransportProtocolGuid,429 NULL,430 (VOID **)&mTransport431 );432 if (EFI_ERROR (Status)) { 433 DEBUG (( EFI_D_ERROR, "Fastboot: Couldn't open Fastboot Transport Protocol: %r\n", Status));435 &gAndroidFastbootTransportProtocolGuid, 436 NULL, 437 (VOID **)&mTransport 438 ); 439 if (EFI_ERROR (Status)) { 440 DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Fastboot Transport Protocol: %r\n", Status)); 434 441 return Status; 435 442 } 436 443 437 Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **) 438 if (EFI_ERROR (Status)) { 439 DEBUG (( EFI_D_ERROR, "Fastboot: Couldn't open Fastboot Platform Protocol: %r\n", Status));444 Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **)&mPlatform); 445 if (EFI_ERROR (Status)) { 446 DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Fastboot Platform Protocol: %r\n", Status)); 440 447 return Status; 441 448 } … … 443 450 Status = mPlatform->Init (); 444 451 if (EFI_ERROR (Status)) { 445 DEBUG (( EFI_D_ERROR, "Fastboot: Couldn't initialise Fastboot Platform Protocol: %r\n", Status));452 DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't initialise Fastboot Platform Protocol: %r\n", Status)); 446 453 return Status; 447 454 } 448 455 449 Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **) &mTextOut); 450 if (EFI_ERROR (Status)) { 451 DEBUG ((EFI_D_ERROR, 452 "Fastboot: Couldn't open Text Output Protocol: %r\n", Status 456 Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **)&mTextOut); 457 if (EFI_ERROR (Status)) { 458 DEBUG (( 459 DEBUG_ERROR, 460 "Fastboot: Couldn't open Text Output Protocol: %r\n", 461 Status 453 462 )); 454 463 return Status; 455 464 } 456 465 457 Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **) 458 if (EFI_ERROR (Status)) { 459 DEBUG (( EFI_D_ERROR, "Fastboot: Couldn't open Text Input Protocol: %r\n", Status));466 Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **)&TextIn); 467 if (EFI_ERROR (Status)) { 468 DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Text Input Protocol: %r\n", Status)); 460 469 return Status; 461 470 } … … 464 473 Status = gBS->SetWatchdogTimer (0, 0x10000, 0, NULL); 465 474 if (EFI_ERROR (Status)) { 466 DEBUG (( EFI_D_ERROR, "Fastboot: Couldn't disable watchdog timer: %r\n", Status));475 DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't disable watchdog timer: %r\n", Status)); 467 476 } 468 477 … … 484 493 // fatal error 485 494 Status = gBS->CreateEvent ( 486 EVT_NOTIFY_SIGNAL,487 TPL_CALLBACK,488 FatalErrorNotify,489 NULL,490 &mFatalSendErrorEvent491 );495 EVT_NOTIFY_SIGNAL, 496 TPL_CALLBACK, 497 FatalErrorNotify, 498 NULL, 499 &mFatalSendErrorEvent 500 ); 492 501 ASSERT_EFI_ERROR (Status); 493 494 502 495 503 // Start listening for data 496 504 Status = mTransport->Start ( 497 ReceiveEvent498 );499 if (EFI_ERROR (Status)) { 500 DEBUG (( EFI_D_ERROR, "Fastboot: Couldn't start transport: %r\n", Status));505 ReceiveEvent 506 ); 507 if (EFI_ERROR (Status)) { 508 DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't start transport: %r\n", Status)); 501 509 return Status; 502 510 } 503 511 504 512 // Talk to the user 505 mTextOut->OutputString (mTextOut, 506 L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press RETURN or SPACE key to quit.\r\n"); 513 mTextOut->OutputString ( 514 mTextOut, 515 L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press RETURN or SPACE key to quit.\r\n" 516 ); 507 517 508 518 // Quit when the user presses any key, or mFinishedEvent is signalled … … 514 524 if (Key.ScanCode == SCAN_NULL) { 515 525 if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) || 516 (Key.UnicodeChar == L' ')) { 526 (Key.UnicodeChar == L' ')) 527 { 517 528 break; 518 529 } … … 522 533 mTransport->Stop (); 523 534 if (EFI_ERROR (Status)) { 524 DEBUG ((EFI_D_ERROR, "Warning: Fastboot Transport Stop: %r\n", Status)); 525 } 535 DEBUG ((DEBUG_ERROR, "Warning: Fastboot Transport Stop: %r\n", Status)); 536 } 537 526 538 mPlatform->UnInit (); 527 539 -
trunk/src/VBox/Devices/EFI/FirmwareNew/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
r85718 r99404 15 15 #include <Library/MemoryAllocationLib.h> 16 16 17 #define BOOTIMG_KERNEL_ARGS_SIZE 51217 #define BOOTIMG_KERNEL_ARGS_SIZE 512 18 18 19 #define ANDROID_FASTBOOT_VERSION "0.4"19 #define ANDROID_FASTBOOT_VERSION "0.4" 20 20 21 21 EFI_STATUS 22 22 BootAndroidBootImg ( 23 IN UINTN 24 IN VOID 23 IN UINTN BufferSize, 24 IN VOID *Buffer 25 25 ); 26 26 27 27 EFI_STATUS 28 28 ParseAndroidBootImg ( 29 IN VOID 29 IN VOID *BootImg, 30 30 OUT VOID **Kernel, 31 OUT UINTN 31 OUT UINTN *KernelSize, 32 32 OUT VOID **Ramdisk, 33 OUT UINTN 34 OUT CHAR8 33 OUT UINTN *RamdiskSize, 34 OUT CHAR8 *KernelArgs 35 35 ); 36 36 -
trunk/src/VBox/Devices/EFI/FirmwareNew/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
r85718 r99404 19 19 #pragma pack(1) 20 20 typedef struct { 21 MEMMAP_DEVICE_PATH 22 EFI_DEVICE_PATH_PROTOCOL 21 MEMMAP_DEVICE_PATH Node1; 22 EFI_DEVICE_PATH_PROTOCOL End; 23 23 } MEMORY_DEVICE_PATH; 24 24 #pragma pack() 25 25 26 STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =26 STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate = 27 27 { 28 28 { … … 45 45 }; 46 46 47 48 47 /** 49 48 Start an EFI Application from a Device Path … … 60 59 EFI_STATUS 61 60 StartEfiApplication ( 62 IN EFI_HANDLE 63 IN EFI_DEVICE_PATH_PROTOCOL 64 IN UINTN 65 IN VOID *LoadOptions61 IN EFI_HANDLE ParentImageHandle, 62 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, 63 IN UINTN LoadOptionsSize, 64 IN VOID *LoadOptions 66 65 ) 67 66 { 68 EFI_STATUS 69 EFI_HANDLE 70 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;67 EFI_STATUS Status; 68 EFI_HANDLE ImageHandle; 69 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; 71 70 72 71 // Load the image from the device path with Boot Services function 73 Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0, 74 &ImageHandle); 72 Status = gBS->LoadImage ( 73 TRUE, 74 ParentImageHandle, 75 DevicePath, 76 NULL, 77 0, 78 &ImageHandle 79 ); 75 80 if (EFI_ERROR (Status)) { 76 81 // … … 83 88 gBS->UnloadImage (ImageHandle); 84 89 } 90 85 91 return Status; 86 92 } … … 88 94 // Passed LoadOptions to the EFI Application 89 95 if (LoadOptionsSize != 0) { 90 Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, 91 (VOID **) &LoadedImage); 96 Status = gBS->HandleProtocol ( 97 ImageHandle, 98 &gEfiLoadedImageProtocolGuid, 99 (VOID **)&LoadedImage 100 ); 92 101 if (EFI_ERROR (Status)) { 93 102 return Status; 94 103 } 95 104 96 LoadedImage->LoadOptionsSize 97 LoadedImage->LoadOptions 105 LoadedImage->LoadOptionsSize = LoadOptionsSize; 106 LoadedImage->LoadOptions = LoadOptions; 98 107 } 99 108 … … 110 119 EFI_STATUS 111 120 BootAndroidBootImg ( 112 IN UINTN 113 IN VOID 121 IN UINTN BufferSize, 122 IN VOID *Buffer 114 123 ) 115 124 { 116 EFI_STATUS 117 CHAR8 118 VOID 119 UINTN 120 VOID 121 UINTN 122 MEMORY_DEVICE_PATH 123 CHAR16 125 EFI_STATUS Status; 126 CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE]; 127 VOID *Kernel; 128 UINTN KernelSize; 129 VOID *Ramdisk; 130 UINTN RamdiskSize; 131 MEMORY_DEVICE_PATH KernelDevicePath; 132 CHAR16 *LoadOptions, *NewLoadOptions; 124 133 125 134 Status = ParseAndroidBootImg ( 126 Buffer,127 &Kernel,128 &KernelSize,129 &Ramdisk,130 &RamdiskSize,131 KernelArgs132 );135 Buffer, 136 &Kernel, 137 &KernelSize, 138 &Ramdisk, 139 &RamdiskSize, 140 KernelArgs 141 ); 133 142 if (EFI_ERROR (Status)) { 134 143 return Status; … … 139 148 // Have to cast to UINTN before casting to EFI_PHYSICAL_ADDRESS in order to 140 149 // appease GCC. 141 KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) 142 KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) 150 KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel; 151 KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel + KernelSize; 143 152 144 153 // Initialize Linux command line … … 149 158 150 159 if (RamdiskSize != 0) { 151 NewLoadOptions = CatSPrint (LoadOptions, L" initrd=0x%x,0x%x", 152 (UINTN)Ramdisk, RamdiskSize); 160 NewLoadOptions = CatSPrint ( 161 LoadOptions, 162 L" initrd=0x%x,0x%x", 163 (UINTN)Ramdisk, 164 RamdiskSize 165 ); 153 166 FreePool (LoadOptions); 154 167 if (NewLoadOptions == NULL) { 155 168 return EFI_OUT_OF_RESOURCES; 156 169 } 170 157 171 LoadOptions = NewLoadOptions; 158 172 } 159 173 160 Status = StartEfiApplication (gImageHandle, 161 (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, 174 Status = StartEfiApplication ( 175 gImageHandle, 176 (EFI_DEVICE_PATH_PROTOCOL *)&KernelDevicePath, 162 177 StrSize (LoadOptions), 163 LoadOptions); 178 LoadOptions 179 ); 164 180 if (EFI_ERROR (Status)) { 165 DEBUG (( EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status));181 DEBUG ((DEBUG_ERROR, "Couldn't Boot Linux: %d\n", Status)); 166 182 Status = EFI_DEVICE_ERROR; 167 183 goto FreeLoadOptions; … … 170 186 // If we got here we do a confused face because BootLinuxFdt returned, 171 187 // reporting success. 172 DEBUG (( EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n"));188 DEBUG ((DEBUG_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n")); 173 189 return EFI_SUCCESS; 174 190
Note:
See TracChangeset
for help on using the changeset viewer.