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

    你可能感兴趣的文章
    Python:替换嵌套字典中的值
    查看>>
    Python:爬取数据出现response.status_code为403解决方法
    查看>>
    Python:爬取数据出现response.status_code为418解决方法
    查看>>
    Python:生成“元组集“;来自“元组列表“;不考虑顺序
    查看>>
    Python:生成具有趋势的随机时间序列数据(例如周期性、指数衰减等)
    查看>>
    Python:用渐进式数字重命名列表中的重复项而不对列表进行排序
    查看>>
    Python:矩形参数无效
    查看>>
    Python:语法进阶
    查看>>
    Python:调用复制函数时调用 Python 对象时超出了最大递归深度
    查看>>
    Python:这两个 import 语句有什么区别?
    查看>>
    Python:通过串口从 Velleman k8090 读取数据
    查看>>
    python:遍历具有列表值的字典
    查看>>
    Python:降低精度 pandas 时间戳数据帧
    查看>>
    python:非阻塞子进程,检查标准输出
    查看>>
    PythonABC多重继承
    查看>>
    Pythonargparse中的多个参数
    查看>>
    Python关于 *args 和 **kwargs 参数的详解(全)
    查看>>
    Pythonfrozenset散列算法/实现
    查看>>
    PythonGTK+3:通过单击列对树视图进行排序
    查看>>
    pythonnumpy生成二进制流_python/numpy生成的二进制文件,由C读取
    查看>>