-
Notifications
You must be signed in to change notification settings - Fork 5
/
FastbootCommands.c
767 lines (651 loc) · 18 KB
/
FastbootCommands.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
#include "EFIDroidUi.h"
#define SIDELOAD_FILENAME L"Sideload.efi"
extern UINT64 gRenderTime;
extern UINT64 gSyncTime;
extern UINT64 gRenderFrames;
extern UINT64 gSyncFrames;
STATIC VOID
CommandRebootInternal (
CONST CHAR16 *Reason
)
{
FastbootOkay("");
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, Reason?StrLen(Reason):0, (CHAR16*)Reason);
}
STATIC VOID
CommandReboot (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
CommandRebootInternal(NULL);
}
STATIC VOID
CommandRebootRecovery (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
CommandRebootInternal(L"recovery");
}
STATIC VOID
CommandRebootBootloader (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
CommandRebootInternal(L"bootloader");
}
STATIC VOID
CommandRebootDownload (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
CommandRebootInternal(L"download");
}
STATIC VOID
CommandPowerOff (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
FastbootInfo("You have 5s to unplug your USB cable :)");
FastbootOkay("");
gBS->Stall(5*1000000);
gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
}
STATIC VOID
CommandBoot (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
if (gFastbootMBHandle) {
FastbootInfo("INFO: redirect boot to Multiboot ROM");
}
// stop fastboot
FastbootOkay("");
FastbootStopNow();
// check if we need to enable patching
BOOLEAN DisablePatching = TRUE;
CHAR8* Var = UtilGetEFIDroidVariable("fastboot-enable-boot-patch");
if (Var && !AsciiStrCmp(Var, "1")) {
DisablePatching = FALSE;
FreePool(Var);
}
// force patching for multiboot ROM's
if (gFastbootMBHandle) {
DisablePatching = FALSE;
}
// boot Android
LoaderBootFromBuffer(Data, Size, gFastbootMBHandle, DisablePatching, FALSE, NULL);
// start fastboot
FastbootInit();
}
STATIC EFI_TEXT_STRING mOutputStringOrig = NULL;
STATIC EFI_TEXT_STRING mErrOutputStringOrig = NULL;
STATIC CHAR8 mOutputBuffer[FASTBOOT_COMMAND_MAX_LENGTH];
STATIC UINTN mOutputBufferPos = 0;
STATIC
EFI_STATUS
EFIAPI
OutputStringHook (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN CHAR16 *String
)
{
CHAR8* AsciiString = Unicode2Ascii(String);
if(AsciiString) {
UINTN i;
for(i=0; i<AsciiStrLen(AsciiString); i++) {
CHAR8 c = AsciiString[i];
mOutputBuffer[mOutputBufferPos++] = c;
if(mOutputBufferPos==sizeof(mOutputBuffer)-1-4 || c=='\n' || c=='\r') {
mOutputBuffer[mOutputBufferPos] = 0;
FastbootInfo(mOutputBuffer);
mOutputBufferPos = 0;
}
}
FreePool(AsciiString);
}
return EFI_SUCCESS;
}
STATIC EFI_GUID mPcdShellFile = { 0x7C04A583, 0x9E3E, 0x4f1c, {0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1}};
STATIC VOID
CommandShell (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
VOID* LoadOptions = NULL;
UINTN LoadOptionsSize = 0;
CHAR8 Buffer[59];
// convert to unicode
CHAR16* UnicodeCommand = Ascii2Unicode(Arg);
if(UnicodeCommand==NULL) {
FastbootFail("Memory error");
return;
}
// get shell device path
Status = UtilGetFvApplicationDevicePath(&mPcdShellFile, &DevicePath);
if(EFI_ERROR(Status)) {
AsciiSPrint(Buffer, 59, "Error: %r", Status);
FastbootFail(Buffer);
return;
}
// build load options
CONST CHAR16* LoadOptionsStr = L"-nomap -nostartup -noversion -_exit ";
LoadOptionsSize = StrSize(LoadOptionsStr) + StrSize(UnicodeCommand) - sizeof(CHAR16);
LoadOptions = AllocateCopyPool(LoadOptionsSize, LoadOptionsStr);
StrCat (LoadOptions, UnicodeCommand);
// initialize console hook
mOutputBufferPos = 0;
mOutputStringOrig = gST->ConOut->OutputString;
mErrOutputStringOrig = gST->StdErr->OutputString;
gST->ConOut->OutputString = OutputStringHook;
gST->StdErr->OutputString = OutputStringHook;
// start shell
Status = UtilStartEfiApplication(DevicePath, LoadOptionsSize, LoadOptions);
FreePool(LoadOptions);
// flush output buffer
if(mOutputBufferPos>0)
FastbootInfo(mOutputBuffer);
// restore console
gST->StdErr->OutputString = mErrOutputStringOrig;
gST->ConOut->OutputString = mOutputStringOrig;
// print status
if(EFI_ERROR(Status)) {
AsciiSPrint(Buffer, 59, "Error: %r", Status);
FastbootFail(Buffer);
return;
}
FastbootOkay("");
}
STATIC VOID
CommandDisplayInfo (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
CHAR8 Buffer[59];
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
EFI_LK_DISPLAY_PROTOCOL *LKDisplay;
UINT32 ModeIndex;
UINTN MaxMode;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
EFI_STATUS Status;
AsciiSPrint(Buffer, 59, "render:%llu sync:%llu", gRenderFrames==0?0ULL:gRenderTime/gRenderFrames, gSyncFrames==0?0ULL:gSyncTime/gSyncFrames);
FastbootInfo(Buffer);
// get graphics protocol
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **) &Gop);
if (EFI_ERROR (Status)) {
AsciiSPrint(Buffer, 59, "Error: %r", Status);
FastbootFail(Buffer);
return;
}
MaxMode = Gop->Mode->MaxMode;
AsciiSPrint(Buffer, 59, "%u mode%a", MaxMode, MaxMode>1?"s":"");
FastbootInfo(Buffer);
AsciiSPrint(Buffer, 59, "buffer: 0x%08x-0x%08x",
(UINTN)Gop->Mode->FrameBufferBase,
(UINTN)Gop->Mode->FrameBufferBase+Gop->Mode->FrameBufferSize
);
FastbootInfo(Buffer);
// get LKDisplay protocol
Status = gBS->LocateProtocol (&gEfiLKDisplayProtocolGuid, NULL, (VOID **) &LKDisplay);
if (!EFI_ERROR (Status)) {
AsciiSPrint(Buffer, 59, "density: %u", LKDisplay->GetDensity(LKDisplay));
FastbootInfo(Buffer);
LK_DISPLAY_FLUSH_MODE FlushMode = LKDisplay->GetFlushMode(LKDisplay);
if (FlushMode==LK_DISPLAY_FLUSH_MODE_AUTO)
AsciiSPrint(Buffer, 59, "flush_mode: auto");
else if (FlushMode==LK_DISPLAY_FLUSH_MODE_MANUAL)
AsciiSPrint(Buffer, 59, "flush_mode: manual");
else
AsciiSPrint(Buffer, 59, "flush_mode: invalid");
FastbootInfo(Buffer);
AsciiSPrint(Buffer, 59, "portrait mode: %u", LKDisplay->GetPortraitMode());
FastbootInfo(Buffer);
AsciiSPrint(Buffer, 59, "landscape mode: %u", LKDisplay->GetLandscapeMode());
FastbootInfo(Buffer);
}
for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) {
Status = Gop->QueryMode (
Gop,
ModeIndex,
&SizeOfInfo,
&Info
);
if (!EFI_ERROR (Status)) {
AsciiSPrint(Buffer, 59, "mode %u:%a", ModeIndex, ModeIndex==Gop->Mode->Mode?" (active)":"");
FastbootInfo(Buffer);
AsciiSPrint(Buffer, 59, " res: %ux%u", Info->HorizontalResolution, Info->VerticalResolution);
FastbootInfo(Buffer);
AsciiSPrint(Buffer, 59, " scanline: %upx", Info->PixelsPerScanLine);
FastbootInfo(Buffer);
if (Info->PixelFormat==PixelRedGreenBlueReserved8BitPerColor)
AsciiSPrint(Buffer, 59, " format: RGB888");
else if (Info->PixelFormat==PixelBlueGreenRedReserved8BitPerColor)
AsciiSPrint(Buffer, 59, " format: BGR888");
else if (Info->PixelFormat==PixelBitMask) {
AsciiSPrint(Buffer, 59, " format: mask %08x/%08x/%08x",
Info->PixelInformation.RedMask,
Info->PixelInformation.GreenMask,
Info->PixelInformation.BlueMask
);
}
else if (Info->PixelFormat==PixelBltOnly)
AsciiSPrint(Buffer, 59, " format: unknown");
else
AsciiSPrint(Buffer, 59, " format: invalid");
FastbootInfo(Buffer);
FreePool (Info);
}
}
FastbootOkay("");
}
STATIC VOID
CommandExit (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
FastbootOkay("");
FastbootRequestStop();
}
STATIC
VOID
CommandScreenShot (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
SCREENSHOT *ScreenShot;
CHAR8 Response[128];
UINTN Index;
// show list of screenshots
if(Arg[0]==0) {
FastbootInfo("available screenshots:");
for (ScreenShot = gScreenShotList,Index=0; ScreenShot; ScreenShot = ScreenShot->Next,Index++) {
AsciiSPrint(Response, sizeof(Response), "\t%d: %u bytes", Index, ScreenShot->Len);
FastbootInfo(Response);
}
FastbootOkay("");
}
else {
UINT8 ScreenShotIndex = atoi (Arg);
for (ScreenShot = gScreenShotList,Index=0; ScreenShot; ScreenShot = ScreenShot->Next,Index++) {
if(Index!=ScreenShotIndex)
continue;
FastbootSendBuf(ScreenShot->Data, ScreenShot->Len);
FastbootOkay("");
return;
}
FastbootFail("screenshot not found");
}
}
STATIC
RETURN_STATUS
EFIAPI
IterateVariablesCallbackPrint (
IN VOID *Context,
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
)
{
EFI_STATUS Status;
CONST CHAR16 *Arg;
Status = EFI_SUCCESS;
Arg = Context;
// show our variables only
if (!CompareGuid(VendorGuid, &gEFIDroidVariableGuid))
return Status;
// show specific variable only
if (Arg && StrCmp(VariableName, Arg))
return Status;
UINTN BufSize = StrLen(VariableName) + DataSize + 10 + 1;
CHAR8 *Buf = AllocatePool(BufSize);
if (Buf == NULL)
return EFI_OUT_OF_RESOURCES;
AsciiSPrint(Buf, BufSize, "%s: %a\n", VariableName, (CONST CHAR8*)Data);
FastbootSendString(Buf, AsciiStrLen(Buf));
FreePool(Buf);
return Status;
}
STATIC
VOID
CommandGetNvVar (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
EFI_STATUS Status;
CHAR8 Buf[100];
CHAR16 *Arg16;
Arg16 = NULL;
if(AsciiStrLen(Arg)>0) {
Arg16 = Ascii2Unicode(Arg);
ASSERT(Arg16);
}
Status = UtilIterateVariables(IterateVariablesCallbackPrint, Arg16);
if (Arg16)
FreePool(Arg16);
if(EFI_ERROR(Status)) {
AsciiSPrint(Buf, sizeof(Buf), "%r", Status);
FastbootFail(Buf);
}
else {
FastbootOkay("");
}
}
STATIC
VOID
CommandSetNvVar (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
EFI_STATUS Status;
CHAR8 Buf[100];
CONST CHAR8 *Name;
CONST CHAR8 *Value;
CHAR8 *Ptr;
Status = EFI_SUCCESS;
Name = Arg;
Value = NULL;
for (Ptr=Arg; *Ptr; Ptr++) {
if(Ptr[0]==' ') {
Ptr[0] = '\0';
Value = &Ptr[1];
break;
}
}
Status = UtilSetEFIDroidVariable(Name, Value);
if(EFI_ERROR(Status)) {
AsciiSPrint(Buf, sizeof(Buf), "%r", Status);
FastbootFail(Buf);
}
else {
FastbootOkay("");
}
}
typedef struct {
CHAR16 *PartitionName;
VOID *Data;
UINTN DataSize;
BOOLEAN Done;
} FLASH_CONTEXT;
STATIC
EFI_STATUS
HandleBlockIoFlash (
IN EFI_HANDLE Handle,
IN VOID *Instance,
IN VOID *VoidContext
)
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo = NULL;
EFI_PARTITION_NAME_PROTOCOL *PartitionNameProtocol = NULL;
FLASH_CONTEXT *Context;
CHAR8 Buf[100];
Context = VoidContext;
if(Context->Done)
return EFI_SUCCESS;
//
// Get the BlockIO protocol on that handle
//
BlockIo = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiBlockIoProtocolGuid,
(VOID **)&BlockIo
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Get the PartitionName protocol on that handle
//
Status = gBS->HandleProtocol (
Handle,
&gEfiPartitionNameProtocolGuid,
(VOID **)&PartitionNameProtocol
);
if (EFI_ERROR (Status) || PartitionNameProtocol->Name[0]==0) {
return Status;
}
if (StrCmp(PartitionNameProtocol->Name, Context->PartitionName)) {
return EFI_NOT_FOUND;
}
Context->Done = TRUE;
UINTN SizeAligned = ROUNDDOWN(Context->DataSize, BlockIo->Media->BlockSize);
UINTN SizeLeft = Context->DataSize - SizeAligned;
if (SizeAligned>0) {
Status = BlockIo->WriteBlocks(BlockIo, BlockIo->Media->MediaId, 0, SizeAligned, Context->Data);
if (EFI_ERROR(Status)) {
AsciiSPrint(Buf, sizeof(Buf), "can't write blocks %r", Status);
FastbootFail(Buf);
return Status;
}
}
if (SizeLeft>0) {
UINTN NumTmpBufPages = ROUNDUP(BlockIo->Media->BlockSize, EFI_PAGE_SIZE)/EFI_PAGE_SIZE;
VOID *TmpBuf = AllocateAlignedPages(NumTmpBufPages, BlockIo->Media->BlockSize);
if (TmpBuf == NULL) {
FastbootFail("can't allocate memory");
return EFI_OUT_OF_RESOURCES;
}
ZeroMem(TmpBuf, BlockIo->Media->BlockSize);
CopyMem(TmpBuf, Context->Data + SizeAligned, SizeLeft);
Status = BlockIo->WriteBlocks(BlockIo, BlockIo->Media->MediaId, SizeAligned, BlockIo->Media->BlockSize, TmpBuf);
FreeAlignedPages(TmpBuf, NumTmpBufPages);
if (EFI_ERROR(Status)) {
AsciiSPrint(Buf, sizeof(Buf), "can't write blocks %r", Status);
FastbootFail(Buf);
return Status;
}
}
FastbootOkay("");
return EFI_SUCCESS;
}
VOID
HandleFileFlash (
EFI_FILE_PROTOCOL *File,
VOID *Data,
UINTN DataSize
)
{
UINT64 FileSize = 0;
EFI_STATUS Status;
CHAR8 Buf[100];
// get file size
Status = FileHandleGetSize(File, &FileSize);
if (EFI_ERROR (Status)) {
AsciiSPrint(Buf, sizeof(Buf), "can't get file size: %r", Status);
FastbootFail(Buf);
goto Done;
}
// validate size
if (DataSize>FileSize) {
FastbootFail("data size exceeds partition size");
goto Done;
}
// write data
UINTN WriteSize = DataSize;
Status = FileHandleWrite(File, &WriteSize, Data);
if (EFI_ERROR (Status)) {
AsciiSPrint(Buf, sizeof(Buf), "can't write: %r", Status);
FastbootFail(Buf);
goto Done;
}
// validate return value
if (WriteSize!=DataSize) {
AsciiSPrint(Buf, sizeof(Buf), "short write: %u/%u bytes written", WriteSize, DataSize);
FastbootFail(Buf);
goto Done;
}
FastbootOkay("");
Done:
return;
}
STATIC
VOID
CommandFlash (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
FSTAB *FsTab;
EFI_FILE_PROTOCOL *EspDir;
FLASH_CONTEXT Context;
EFI_STATUS Status;
CHAR8 Buf[100];
if (gFastbootMBHandle) {
// get partition
CHAR16 *NameUnicode = Ascii2Unicode(Arg);
if (!NameUnicode) {
FastbootFail("can't allocate memory");
return;
}
PARTITION_LIST_ITEM *Item = LoaderGetPartitionItem(gFastbootMBHandle, NameUnicode);
FreePool(NameUnicode);
if (!Item) {
FastbootFail("partition not found");
return;
}
if (!Item->IsFile) {
FastbootFail("partition is not a file");
return;
}
// open File
EFI_FILE_PROTOCOL *PartitionFile = NULL;
Status = gFastbootMBHandle->ROMDirectory->Open (
gFastbootMBHandle->ROMDirectory,
&PartitionFile,
Item->Value,
EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE,
0
);
if (EFI_ERROR(Status)) {
AsciiSPrint(Buf, sizeof(Buf), "can't open replacement partition: %r", Status);
FastbootFail(Buf);
return;
}
// flash
FastbootInfo("INFO: redirect flash to Multiboot ROM");
HandleFileFlash (PartitionFile, Data, (UINTN)Size);
// close
FileHandleClose(PartitionFile);
return;
}
FsTab = AndroidLocatorGetMultibootFsTab ();
EspDir = AndroidLocatorGetEspDir ();
if (FsTab && EspDir) {
// handle the special uefi prefix
BOOLEAN IsUefiFlash = FALSE;
if (!AsciiStrnCmp(Arg, "uefi_", 5)) {
Arg += 5;
IsUefiFlash = TRUE;
}
FSTAB_REC* Rec = FstabGetByPartitionName(FsTab, Arg);
if(Rec && FstabIsUEFI(Rec)) {
EFI_FILE_PROTOCOL *PartitionFile = NULL;
// this is a uefi partition flash
if (IsUefiFlash) {
FastbootInfo("INFO: flash to UEFI partition");
goto DO_BLOCKIO_FLASH;
}
// build filename
UINTN PathBufSize = 100*sizeof(CHAR16);
CHAR16 *PathBuf = AllocateZeroPool(PathBufSize);
ASSERT(PathBuf);
UnicodeSPrint(PathBuf, PathBufSize, L"partition_%a.img", Rec->mount_point+1);
// open File
Status = EspDir->Open (
EspDir,
&PartitionFile,
PathBuf,
EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE,
0
);
FreePool(PathBuf);
if (EFI_ERROR(Status)) {
AsciiSPrint(Buf, sizeof(Buf), "can't open replacement partition: %r", Status);
FastbootFail(Buf);
return;
}
// flash
FastbootInfo("INFO: redirect flash to ESP");
HandleFileFlash (PartitionFile, Data, (UINTN)Size);
// close
FileHandleClose(PartitionFile);
return;
}
}
DO_BLOCKIO_FLASH:
Context.PartitionName = Ascii2Unicode(Arg);
Context.Data = Data;
Context.DataSize = (UINTN)Size;
Context.Done = FALSE;
// flash
VisitAllInstancesOfProtocol (
&gEfiBlockIoProtocolGuid,
HandleBlockIoFlash,
&Context
);
if(Context.PartitionName)
FreePool(Context.PartitionName);
if(!Context.Done)
FastbootFail("partition not found");
}
STATIC
VOID
CommandErase (
CHAR8 *Arg,
VOID *Data,
UINT32 Size
)
{
FastbootInfo("WARNING: erase is not supported");
FastbootOkay("");
}
VOID
FastbootCommandsAdd (
VOID
)
{
FastbootRegister("flash:", CommandFlash);
FastbootRegister("erase:", CommandErase);
FastbootRegister("reboot", CommandReboot);
FastbootRegister("reboot-bootloader", CommandRebootBootloader);
FastbootRegister("oem reboot-recovery", CommandRebootRecovery);
FastbootRegister("oem reboot-download", CommandRebootDownload);
FastbootRegister("oem poweroff", CommandPowerOff);
FastbootRegister("boot", CommandBoot);
FastbootRegister("oem shell", CommandShell);
FastbootRegister("oem displayinfo", CommandDisplayInfo);
FastbootRegister("oem exit", CommandExit);
FastbootRegister("oem screenshot", CommandScreenShot);
FastbootRegister("oem getnvvar", CommandGetNvVar);
FastbootRegister("oem setnvvar", CommandSetNvVar);
}