查询和设置BIOS属性的API

发布于 2024-11-14 17:22:20 字数 111 浏览 2 评论 0原文

假设我想更改 Linux 计算机的 BIOS 设置(如果重要的话,假设是 Ubuntu 11)。有哪些类型的 API 可以让您查询和操作 BIOS 设置?

此外,进行此类开发的良好资源是什么?

Let's say I would like to change a setting in the BIOS of my computer in Linux (let's say Ubuntu 11 if it matters.) What types of APIs exist to allow you query and manipulate BIOS setting?

Further, what are good resources for doing this type of development?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

沧桑㈠ 2024-11-21 17:22:21

这一切都取决于“BIOS 设置”的含义。

在传统的PC/AT PC机器固件中,“BIOS设置”保存在与实时时钟芯片相关的非易失性RAM中。对于 NVRAM 的各个字节所代表的内容几乎没有标准化(尽管有一些常见约定),并且它们的含义因固件供应商和固件版本而异。用于操作 RTC NVRAM 的工具包括 Linux 和 FreeBSD /dev/nvram 设备。

但这并不是现代 PC 上唯一的非易失性 RAM。实际上,“BIOS ROM”也是非易失性 RAM。 (在正常操作中不能只对其进行写入。必须执行魔法才能启用写入周期。但它不是只读存储器。)后来的 PC 固件使用这个大得多(可能高达16MiB(而不是 256 字节)非易失性 RAM 用于设置存储。扩展系统配置数据和臭名昭著的 DMI 池等系统管理数据都存储在那里。用于操作这些数据的工具包括使用 /dev/mem 的 Linux dmidecode 实用程序。

在具有 EFI 固件的现代 PC 上,“BIOS”NVRAM 通常是存储 EFI 固件环境变量的位置。这些可以通过 uefivars 等工具进行操作,依次 依赖 /sys/firmware/efi 文件系统(虽然有些间接,但实际上,导出用于变量的内核模式 EFI API 到应用程序模式)。 EFI 变量是现代 EFI 固件的“设置”,控制着一系列内容,从 EFI 启动管理器菜单上的内容(参见 efibootmgr 实用程序)到构成系统控制台的设备。

This all depends from what one means by "BIOS setting".

In traditional, PC/AT, PC machine firmware, the "BIOS settings" are saved in the non-volatile RAM associated with the real-time clock chip. There is pretty much no standardization as to what the individual bytes of NVRAM represent (although there are a couple of common conventions) and their meanings vary from firmware vendor to firmware vendor, and from firmware release to firmware release. Tools for manipulating the RTC NVRAM include the Linux and FreeBSD /dev/nvram device.

But this isn't the only non-volatile RAM on a modern PC. The "BIOS ROM" is also, in reality, non-volatile RAM. (One cannot just write to it in normal operation. One has to perform magic incantations to enable write cycles. But it is not Read-Only Memory.) Later PC firmwares use this much larger (potentially up to 16MiB as opposed to 256 bytes) non-volatile RAM for settings storage. System management data such as Extended System Configuration Data and the infamous DMI Pool are stored there. Tools for manipulating these data include the Linux dmidecode utility which uses /dev/mem.

On a modern PC with EFI firmware, the "BIOS" NVRAM is usually where the EFI firmware environment variables are stored. These can be manipulated by tools such as uefivars, which in their turn rely upon the /sys/firmware/efi filesystem (which effectively, albeit somewhat indirectly, exports the kernel-mode EFI API for variables to application mode). EFI variables are the "settings" of modern EFI firmwares, controlling a range of things from what's on the EFI Boot Manager menu (c.f. the efibootmgr utility) to what devices constitute the system console.

混浊又暗下来 2024-11-21 17:22:21

我正在尝试在我的 wiki 上整理一个工具列表来执行此操作:
https://wiki.xkyle.com/Configuing_BIOS_From_Linux

虽然从技术上讲不是 API,但它们是执行您操作的方法正在问。

它们是特定于供应商的,并且适用于服务器。

  • Intel 服务器:Syscfg 实用程序
  • Dell PowerEdge C 服务器:setupbios 或其 syscfg
  • HP 服务器:CONREP 实用程序

I'm trying to curate a list of tools to do this on my wiki:
https://wiki.xkyle.com/Configuing_BIOS_From_Linux

While not technically API's, they are methods to do what you are asking.

They are vendor specific, and for servers.

  • Intel Severs: Syscfg utility
  • Dell PowerEdge C Servers: setupbios or their syscfg
  • HP Servers: the CONREP utility
地狱即天堂 2024-11-21 17:22:20

CMOS 内存存在于正常地址空间之外,不能
包含直接可执行代码。可通过 IN 和 OUT 到达
端口号 70h (112d) 和 71h (113d) 处的命令。要读取 CMOS 字节,
使用要读取的字节地址执行到端口 70h 的 OUT 操作
来自端口 71h 的 IN 将检索请求的信息。

您可以使用 inboutb 宏从这些端口读取和写入,以获取存储在 CMOS 中的整个 BIOS 设置。有关存储的设置内存格式,请查看:http://bochs.sourceforge.net/ techspec/CMOS-reference.txt

这些映射实际上取决于供应商,但其中大多数应该是通用的。

虽然这不是一个 API,但是通过它您可以直接访问 CMOS 内存并制作您自己的 API。对于快速程序,我建议使用 API。在这种情况下查看@Nemo 的答案。

The CMOS memory exists outside of the normal address space and cannot
contain directly executable code. It is reachable through IN and OUT
commands at port number 70h (112d) and 71h (113d). To read a CMOS byte,
an OUT to port 70h is executed with the address of the byte to be read and
an IN from port 71h will then retrieve the requested information.

You can use the inb and outb macros to read and write from these ports to get the entire BIOS settings stored in the CMOS. For the settings memory format stored have a look at: http://bochs.sourceforge.net/techspec/CMOS-reference.txt

These mappings are actually vendor dependent, but most of them should be common.

Although this is not an API, but with this you can make direct access to the CMOS memory and make your own API. For a quick program i would recommend getting an API. Check out @Nemo's answer in this case.

×眷恋的温暖 2024-11-21 17:22:20

flashrom 是一个用于在 Linux 中刷新新 BIOS 映像的实用程序。

要修改 BIOS 设置本身,您可以使用 /dev/nvram 设备。

此页面提供了有关这两个方面的良好信息。

请注意,NVRAM 内容的含义完全取决于 BIOS 本身;不同的 BIOS 甚至同一 BIOS 的不同版本之间也会有所不同。因此,您唯一可以可靠地做的就是将 BIOS 设置保存在一个系统上,并将它们恢复到相同的系统上。

flashrom is a utility for flashing a new BIOS image from within Linux.

To modify the BIOS settings themselves, you can use the /dev/nvram device.

This page provides good information on both of these.

Note that the meaning of the NVRAM contents depends entirely on the BIOS itself; it will vary from BIOS to BIOS and even between revisions of the same BIOS. So the only thing you can reliably do is save the BIOS settings on one system and restore them onto an identical system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文