当前位置: 首页 > article >正文

UEFI EDK2框架学习 (四)——UEFI图形化

一、修改protocol.c

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <stdio.h>


EFI_STATUS
EFIAPI
UefiMain(
  IN EFI_HANDLE ImageHandle,
  IN EFI_SYSTEM_TABLE *SystemTable
) {
  EFI_STATUS Status = EFI_SUCCESS;
  UINTN NoHandles = 0;
  EFI_HANDLE *Buffer = NULL;
  Status = gBS->LocateHandleBuffer(
    ByProtocol,
    &gEfiGraphicsOutputProtocolGuid,
    NULL,
    &NoHandles,
    &Buffer
  );

  Print(L"Status = %d", Status);
  if (EFI_ERROR(Status)) {
    Print(L"Failed to LocateHandleBuffer. \n");
    return Status;
  }
  Print(L"Hello, Protocol\n");

  EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
  Status = gBS->OpenProtocol(
    Buffer[0],
    &gEfiGraphicsOutputProtocolGuid,
    (VOID**)&Gop,
    ImageHandle,
    NULL,
    EFI_OPEN_PROTOCOL_GET_PROTOCOL
  );

  Print(L"Status = %d", Status);
  if (EFI_ERROR(Status)) {
    Print(L"Failed to OpenProtocol. \n");
    return Status;
  }

  UINTN SizeOfInfo = 0;
  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
  UINTN i = 0;

  for (; i < Gop->Mode->MaxMode; i++) {
    Status = Gop->QueryMode(Gop, i, &SizeOfInfo, &Info);

    if (EFI_ERROR(Status)) {
      Print(L"Failed to Querymode. \n");
      return Status;
    }

    PrintL(L"Mode %d, H = %d, V = %d", i, Info->HorizontalResolution, Info->VerticalResolution);
  }
  
  Status = Gop->SetMode(Gop, 22);
  if (EFI_ERROR(Status)) {
    Print(L"Failed to Querymode. \n");
    return Status;
  }

  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Red = {0, 0, 255, 0};

  Gop->Blt(
    Gop,
    &Red,
    EfiBltVideoFill,
    0,0,   // source x y
    0,0,
    100,100,  // wid  height
    0
  );

  if (EFI_ERROR(Status)) {
    Print(L"Failed to Blt. \n");
    return Status;
  }


  Gop->Blt(
    Gop,
    &Red,
    EfiBltVideoFill,
    0,0,   // source x y
    200, 200,
    100,100,  // wid  height
    0
  );  // copy

    if (EFI_ERROR(Status)) {
    Print(L"Failed to Blt. \n");
    return Status;
  }
  return Status;
}

二、build


http://www.kler.cn/news/361899.html

相关文章:

  • Jupyter Notebook汉化(中文版)
  • 天润融通大模型文本机器人,让客服迈入“无人化”的第一步
  • [实时计算flink]作业开发上线流程及规范
  • 数据结构——广义表
  • 【RL Latest Tech】安全强化学习(Safe RL):理论、方法与应用
  • 使用JUC包的AtomicXxxFieldUpdater实现更新的原子性
  • 设计模式05-创建型模式(建造者/原型/单例模式/Java)
  • 使用js和canvas实现绘制一只丑萌的小猫,一步步绘制
  • 电感的学习
  • Tomcat怎么调整参数以优化性能
  • 【MySQL备份】Percona XtraBackup
  • 中医大模型开源!数据集开源!自己训练一个中医大模型吧!
  • 简单介绍冯诺依曼体系
  • 深入理解 JavaScript 中的剩余参数和扩展运算符
  • 对比学习)
  • C++ 标准库:功能与应用解析
  • 考研408考试科目之计算机数据结构在科技应用——未来之窗学习通
  • 安卓設備上怎麼設置HTTP代理?
  • IIS不能使用Delete方法
  • Spring事务底层源码解析(二)
  • 大数据分析案例-基于随机森林模型的机器学习工程师岗位薪资预测
  • SQLI LABS | Less-3 GET-Error based-Single quotes with twist-String
  • 11种经典时间序列预测方法:理论、Python实现与应用
  • Linux云计算 |【第五阶段】ARCHITECTURE-DAY4
  • LabVIEW水质监测系统
  • leetcode 3191. 使二进制数组全部等于 1 的最少操作次数 I 中等