M efigop/screenshot/cmd_i386.c => efigop/screenshot/cmd_i386.c +1 -0
@@ 59,6 59,7 @@ const struct cmd_table cmd_machine[] = {
{ "gop", CMDT_CMD, Xgop_efi },
{ "exit", CMDT_CMD, Xexit_efi },
{ "poweroff", CMDT_CMD, Xpoweroff_efi },
+ { "screenshot", CMDT_CMD, Xscreenshot_efi },
#ifdef DEBUG
{ "regs", CMDT_CMD, Xregs },
#endif
M efigop/screenshot/efiboot.c => efigop/screenshot/efiboot.c +33 -0
@@ 1059,3 1059,36 @@ Xgop_efi(void)
return (0);
}
+
+int
+Xscreenshot_efi() {
+ if (cmd.argc < 2) {
+ printf("Error: file name needed\n");
+ /* Returning a non-zero value causes a weird boot attempt for some reason */
+ return (0);
+ }
+
+ void *FrameBufferBase;
+ UINTN FrameBufferSize;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *gopi;
+ EFI_GUID fs_guid = SIMPLE_FILE_SYSTEM_PROTOCOL;
+ EFI_FILE_IO_INTERFACE *IOVolume;
+ EFI_FILE_HANDLE Volume;
+ EFI_FILE_HANDLE FileHandle;
+ CHAR16 FileName[] = {cmd.argv[1][0], '\0'};
+ UINTN nhandles;
+ EFI_HANDLE *handles = NULL;
+
+ BS->LocateProtocol(&gop_guid, NULL, (void **)&gop);
+ gopi = gop->Mode->Info;
+ FrameBufferBase = (void *)gop->Mode->FrameBufferBase;
+ FrameBufferSize = gopi->VerticalResolution * gopi->PixelsPerScanLine * 4;
+
+ BS->LocateHandleBuffer(ByProtocol, &fs_guid, NULL, &nhandles, &handles);
+ BS->HandleProtocol(handles[0], &fs_guid, (void **)&IOVolume);
+ IOVolume->OpenVolume(IOVolume, &Volume);
+ Volume->Open(Volume, &FileHandle, FileName, EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
+ FileHandle->Write(FileHandle, &FrameBufferSize, FrameBufferBase);
+ FileHandle->Close(FileHandle);
+ return (0);
+}
M efigop/screenshot/efiboot.h => efigop/screenshot/efiboot.h +1 -0
@@ 36,6 36,7 @@ int Xexit_efi(void);
void efi_makebootargs(void);
int Xpoweroff_efi(void);
+int Xscreenshot_efi(void);
extern void (*run_i386)(u_long, u_long, int, int, int, int, int, int, int, int)
__attribute__ ((noreturn));