博客
关于我
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/

    你可能感兴趣的文章
    Objective-C实现fischer yates shuffle洗牌算法(附完整源码)
    查看>>
    Objective-C实现FisherYates Shuffle洗牌算法(附完整源码)
    查看>>
    Objective-C实现fisherYates洗牌算法(附完整源码)
    查看>>
    Objective-C实现FloodFill洪水填充函数算法(附完整源码)
    查看>>
    Objective-C实现floor向下取整算法(附完整源码)
    查看>>
    Objective-C实现floyd warshall算法(附完整源码)
    查看>>
    Objective-C实现Floyd-Warshall算法(附完整源码)
    查看>>
    Objective-C实现FPmax算法(附完整源码)
    查看>>
    Objective-C实现frequency finder频率探测器算法(附完整源码)
    查看>>
    Objective-C实现FTP上传文件(附完整源码)
    查看>>
    Objective-C实现FTP文件上传(附完整源码)
    查看>>
    Objective-C实现FTP文件下载(附完整源码)
    查看>>
    Objective-C实现fuzzy operations模糊运算算法(附完整源码)
    查看>>
    Objective-C实现Gale-Shapley盖尔-沙普利算法(附完整源码)
    查看>>
    Objective-C实现gamma recursive伽玛递归算法(附完整源码)
    查看>>
    Objective-C实现gamma 伽玛功能算法(附完整源码)
    查看>>
    Objective-C实现gauss easte高斯复活节日期算法(附完整源码)
    查看>>
    Objective-C实现gaussian filter高斯滤波器算法(附完整源码)
    查看>>
    Objective-C实现gaussian naive bayes高斯贝叶斯算法(附完整源码)
    查看>>
    Objective-C实现gaussian高斯算法(附完整源码)
    查看>>