23 auto status = LibLocateProtocol(&GraphicsOutputProtocol,
24 reinterpret_cast<void **
>(&
gop));
25 if (EFI_ERROR(status)) {
27 throw std::runtime_error(
"EFI_ERROR(status)");
30 debug << L
"LibLocateProtocol(GraphicsOutputProtocol, &gop) returned "
33 throw std::runtime_error(
"gop == nullptr");
38 uint32_t _height)
const {
39 EFI_STATUS status = EFI_SUCCESS;
41 for (uint32_t i = 0; i <
gop->Mode->MaxMode; i++) {
42 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info =
nullptr;
43 uint64_t mode_info_size = 0;
44 status = uefi_call_wrapper(
gop->QueryMode, 4,
gop, i, &mode_info_size,
46 if (EFI_ERROR(status)) {
48 throw std::runtime_error(
"EFI_ERROR(status)");
51 if ((mode_info->PixelFormat == _format) &&
52 (mode_info->HorizontalResolution == _width) &&
53 (mode_info->VerticalResolution == _height)) {
54 status = uefi_call_wrapper(
gop->SetMode, 2,
gop, i);
55 if (EFI_ERROR(status)) {
57 throw std::runtime_error(
"EFI_ERROR(status)");
60 status = uefi_call_wrapper(gBS->FreePool, 1, mode_info);
61 if (EFI_ERROR(status)) {
63 throw std::runtime_error(
"EFI_ERROR(status)");
67 debug << L
"Current Mode: " <<
gop->Mode->Mode << L
", Version: "
69 <<
gop->Mode->Info->PixelFormat << L
", Horizontal: "
70 <<
gop->Mode->Info->HorizontalResolution << L
", Vertical: "
71 <<
gop->Mode->Info->VerticalResolution << L
", ScanLine: "
72 <<
gop->Mode->Info->PixelsPerScanLine << L
", FrameBufferBase: "
79 debug << L
"Current Mode: " <<
gop->Mode->Mode << L
", Version: "
81 <<
gop->Mode->Info->PixelFormat << L
", Horizontal: "
82 <<
gop->Mode->Info->HorizontalResolution << L
", Vertical: "
83 <<
gop->Mode->Info->VerticalResolution << L
", ScanLine: "
84 <<
gop->Mode->Info->PixelsPerScanLine << L
", FrameBufferBase: "
89 for (uint32_t i = 0; i <
gop->Mode->MaxMode; i++) {
90 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info =
nullptr;
91 uint64_t mode_info_size = 0;
92 auto status = uefi_call_wrapper(
gop->QueryMode, 4,
gop, i, &mode_info_size,
94 if (EFI_ERROR(status)) {
96 throw std::runtime_error(
"EFI_ERROR(status)");
100 <<
gop->Mode->Info->Version << L
", Format: "
101 <<
gop->Mode->Info->PixelFormat << L
", Horizontal: "
102 <<
gop->Mode->Info->HorizontalResolution << L
", Vertical: "
103 <<
gop->Mode->Info->VerticalResolution << L
", ScanLine: "
106 status = uefi_call_wrapper(gBS->FreePool, 1, mode_info);
107 if (EFI_ERROR(status)) {
109 throw std::runtime_error(
"EFI_ERROR(status)");
void set_mode(EFI_GRAPHICS_PIXEL_FORMAT _format=PixelBlueGreenRedReserved8BitPerColor, uint32_t _width=DEFAULT_WIDTH, uint32_t _height=DEFAULT_HEIGHT) const
EFI_GRAPHICS_OUTPUT_PROTOCOL * gop
static auto endl(ostream &_ostream) -> ostream &
static auto hex_x(ostream &_ostream) -> ostream &
static auto hex_X(ostream &_ostream) -> ostream &
static ostream debug
全局输出流