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

    你可能感兴趣的文章
    OpenStack自动化安装部署实战(附OpenStack实验环境)
    查看>>
    openstack虚拟机迁移live-migration中libvirt配置
    查看>>
    OpenStack项目管理实战
    查看>>
    OpenStreetMap初探(一)——了解OpenStreetMap
    查看>>
    openSUSE 13.1 Milestone 2 发布
    查看>>
    openSUSE推出独立 GUI 包管理工具:YQPkg,简化了整个软件包管理流程
    查看>>
    OpenVSwtich(OVS)Vlan间路由实战 附实验环境
    查看>>
    Openwrt LuCI模块练习详细步骤
    查看>>
    openwrt_git_pull命令提示merger冲突时如何解决?
    查看>>
    OpenWrt包管理软件opkg的使用(极路由)
    查看>>
    OpenWrt固件编译刷机完全总结
    查看>>
    Open××× for Linux搭建之二
    查看>>
    Open×××有线网络时使用正常,无线网络时使用报错的解决方案
    查看>>
    Operation not supported on read-only collection 的解决方法 - [Windows Phone开发技巧系列1]
    查看>>
    OperationResult
    查看>>
    Operations Manager 2007 R2系列之仪表板(多)视图
    查看>>
    operator new and delete
    查看>>
    operator new 与 operator delete
    查看>>
    operator() error
    查看>>
    OPPO K3在哪里打开USB调试模式的完美方法
    查看>>