博客
关于我
ami smbios读取与修改 (断电不能保存)
阅读量:160 次
发布时间:2019-02-28

本文共 4773 字,大约阅读时间需要 15 分钟。

EFI系统是极端固件接口的一种标准,主要用于描述计算机固件的各种功能。以下是关于EFI代码和相关文件的详细说明。

1. 代码分析

int macdbg_dmphex_kernel(const char* buff_in, int len) {    int retval = 0;    int x, y, tot, lineoff;    const char* curr;    CHAR16 buff[1024];    UINTN index;    DEBUG((EFI_D_INFO, "dump addr -> 0x%x: \n", buff_in));    //.DEBUG((EFI_D_INFO, "len = 0x%x.\n", len));    lineoff = 0;    curr = buff_in;    tot = 0;    for (x = 0; x + 16 < len;) {        index = 0x00;        memset(buff, 0x00, sizeof(buff));        Swprintf(&buff[index], L"0x%04x: ", lineoff);        index = Wcslen(buff);        //DEBUG((EFI_D_INFO, "index = %d\n", index));        //DEBUG((EFI_D_INFO, "debug.0 = %s\n", buff));        //DEBUG((EFI_D_INFO, "debug.1 = %S\n", buff));        for (y = 0; y < 16; y++) {            Swprintf(&buff[index], L"%02x ", (unsigned char)*(curr + y));            index = Wcslen(buff);        }        Swprintf(&buff[index], L"%s", L" ");        index = Wcslen(buff);        for (y = 0; y < 16; y++) {            char c;            c = *(curr + y);            if (c > 31 && c < 127) {                Swprintf(&buff[index], L"%c", c);            } else {                Swprintf(&buff[index], L"%c", L'.');            }            index = Wcslen(buff);        }        tot++;        curr += 16;        x += 16;        lineoff += 16;        Swprintf(&buff[index], L"%s", L"\n");        //printk("%s", buff);        //DEBUG((EFI_D_INFO, "debug.2 = %s\n", buff));        DEBUG((EFI_D_INFO, "%s", buff));        //DEBUG((EFI_D_INFO, "debug.3 = %S\n", buff));    }    //do last line    //Ser_Printf("tot %d.\r\n", tot);    //Ser_Printf("len %d.\r\n", len);    index = 0x00;    memset(buff, 0x00, sizeof(buff));    if (tot < len) {        curr = (buff_in + tot);        Swprintf(&buff[index], L"0x%04x: ", lineoff);        index = Wcslen(buff);        for (y = 0; y < (len - tot); y++) {            Swprintf(&buff[index], L"%02x ", (unsigned char)*(curr + y));            index = Wcslen(buff);        }        //padding with spaces        //printk("(len - tot) %d.\r\n", (len - tot));        if ((len - tot) < 16) {            for (y = 0; y < (16 - (len - tot)); y++) {                Swprintf(&buff[index], L"%s", L" ");                index = index + 3;            }        }        Swprintf(&buff[index], L"%s", L" ");        index = Wcslen(buff);        for (y = 0; y < (len - tot); y++) {            char c;            c = *(curr + y);            if (c > 31 && c < 127) {                Swprintf(&buff[index], L"%c", c);            } else {                Swprintf(&buff[index], L"%c", L'.');            }            index = Wcslen(buff);        }    }    Swprintf(&buff[index], L"%s", L"\n");    //printk("%s", buff);    DEBUG((EFI_D_INFO, "%s\n", buff));    return retval;}

2. INF文件分析

## @fileComponent description file for EFI Shell module.This is a binary module containing multiple binary shell applications.All .efi file tagged with "ToolCode="DUMMY"" in following file list are raw EFI application,and they are can be run in shell environment.Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.## This program and the accompanying materialsare licensed and made available under the terms and conditions of the BSD Licensewhich accompanies this distribution. The full text of the license may be found athttp://opensource.org/licenses/bsd-license.phpTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.#### [Defines]INF_VERSION = 0x00010006BASE_NAME = FullShell##  FILE_GUID = c57ad6b7-0515-40a8-9d21-551652854e37FILE_GUID = 7C04A583-9E3E-4f1c-AD65-E05268D0B4D2MODULE_TYPE = UEFI_APPLICATIONVERSION_STRING = 1.0ENTRY_POINT = UefiMain##  VALID_ARCHITECTURES = IA32 X64 IPF#[Sources]kbLEDTest.c[Packages]MdePkg/MdePkg.decServerCommonPkg/ServerCommonPkg.decIntelFrameworkPkg/IntelFrameworkPkg.decAmiCompatibilityPkg/AmiCompatibilityPkg.decShellPkg/ShellPkg.decMdeModulePkg/MdeModulePkg.decAmiPkg/AmiPkg.decMdeModulePkg/MdeModulePkg.decIntelFrameworkModulePkg/IntelFrameworkModulePkg.dec[LibraryClasses]UefiDriverEntryPointMemoryAllocationLibUefiBootServicesTableLibDebugLibUefiLibWheaPlatformHooksLibUefiApplicationEntryPointAmiDxeLibUefiUsbLibUefiLibIoLibShellCEntryLibUefiShellDebug1CommandsLib[Protocols]gEfiSmbiosProtocolGuid[Guids]gEfiSmbiosTableGuid

3. 功能模块说明

  • macdbg_dmphex_kernel函数:用于解析和显示二进制数据,适用于调试和显示 hexadecimal 格式的数据。
  • SMBIOS表操作:通过 EFI 系统配置表获取 SMBIOS 表信息,支持字符串操作和数据解析。
  • EFI 主函数:实现了 EFI Shell 模块的主功能,包括协议获取、字符串更新以及 SMBIOS 表的处理。
  • 4. 开发工具

    • EFI 开发环境:需要安装支持 EFI 开发的工具链,包括编译器、链接器和调试工具。
    • SMBIOS 协议支持:需要正确配置 EFI 系统表和 SMBIOS 协议 GUID。

    5. 使用方法

  • 导入项目:将项目文件添加到开发环境中,配置好必要的路径和依赖项。
  • 编译和链接:使用项目配置文件生成可执行文件或共享库。
  • 测试和调试:通过调试工具验证功能是否正常,检查日志输出和错误信息。
  • 通过以上分析,可以清晰地了解 EFI Shell 模块的功能实现和相关文件结构,方便开发者进行后续的扩展和优化工作。

    转载地址:http://vkxd.baihongyu.com/

    你可能感兴趣的文章
    plsql查询乱码问题解决
    查看>>
    PLSQL的DBMS_GETLINE
    查看>>
    quartz简单demo,教你最快使用quartz
    查看>>
    PlutoSDR学习笔记(一)—函数API手册
    查看>>
    Quartz安装包中的15个example
    查看>>
    Quartz学习总结(2)——定时任务框架Quartz详解
    查看>>
    pm2 start命令中的json格式详解
    查看>>
    pm2启动报错
    查看>>
    pm2通过配置文件部署nodejs代码到服务器
    查看>>
    Unknown character set: 'utf8mb4'
    查看>>
    PML调用PDMS内核命令研究
    查看>>
    PMM安装-第一篇
    查看>>
    PMP知识要点(第九章)
    查看>>
    PNETLab 镜像包官方下载太慢?不急,最新版本PNET_4.2.10分享!
    查看>>
    pnpm : 无法加载文件...
    查看>>
    pnpm 如何安装指定版本
    查看>>
    pnpm的设计与npm的对比
    查看>>
    pocoserver无限重启_Poco::TCPServer框架解析
    查看>>
    POCO库中文编程参考指南(4)Poco::Net::IPAddress
    查看>>
    Quartz基本使用(二)
    查看>>