简体   繁体   English

使用C语言更改BIOS设置

[英]Change BIOS settings using the C language

我想知道是否有任何方法可以编写C程序来更改RAM和GFX卡之间共享的内存量,或者一般如何联系BIOS设置?

You can access the BIOS settings via I/O port 70h and 71h. 您可以通过I / O端口70h和71h访问BIOS设置。 (Some chipsets also have an extended CMOS at 72/73 or similar.) (有些芯片组还有72/73或类似的扩展CMOS。)

What OS are you using? 你用的是什么操作系统? If you are running Windows, you won't be able to do port I/O directly from an application, you'll have to write a kernel mode driver, or use a third-party toolkit like WinIO. 如果您运行的是Windows,则无法直接从应用程序执行端口I / O,您必须编写内核模式驱动程序,或使用WinIO等第三方工具包。 Under Linux, you can use /dev/nvram to get at the CMOS settings. 在Linux下,您可以使用/ dev / nvram来获取CMOS设置。 (Assuming the Linux nvram driver has support for your chipset. Otherwise use /dev/port.) (假设Linux nvram驱动程序支持您的芯片组。否则使用/ dev / port。)

Once you get at the CMOS bits, the next task will be figuring out which location in CMOS corresponds to the Video Memory Setting. 一旦获得CMOS位,下一个任务就是确定CMOS中的哪个位置对应于视频存储器设置。

Here is a (woefully incomplete) map of CMOS memory locations: http://ivs.cs.uni-magdeburg.de/~zbrog/asm/cmos.html 这是一个(可悲的是不完整的)CMOS内存位置图: http//ivs.cs.uni-magdeburg.de/~zbrog/asm/cmos.html

The map of CMOS locations is extremely specific to the motherboard, BIOS, and BIOS rev. CMOS位置的地图非常特定于主板,BIOS和BIOS rev。 (The CMOS map can change between BIOS revs as new menu options are added/removed.) Maybe your motherboard vendor can provide you with a CMOS map. (当添加/删除新的菜单选项时,CMOS映射可以在BIOS转速之间切换。)也许您的主板供应商可以为您提供CMOS映射。 They have the tools to generate such a map (it is part of the BIOS compilation process), but they may not be willing to share it. 他们有生成这种地图的工具(它是BIOS编译过程的一部分),但他们可能不愿意分享它。

Without a map, there are other methods to determine which bits in CMOS represent the Video Memory Size. 如果没有映射,还有其他方法可以确定CMOS中的哪些位代表视频内存大小。 Try dumping the CMOS settings with various memory sizes and figure out which bits change. 尝试转储具有各种内存大小的CMOS设置,并找出哪些位发生变化。

Some other details: 其他一些细节:

  1. Outside of a few "standard" CMOS bits, most of them are extremely platform dependent, I hope you weren't planning on making a general-purpose application out of this. 除了一些“标准”CMOS位之外,其中大多数都是非常依赖平台的,我希望你不打算用它来制作一个通用的应用程序。

  2. There are checksums at certain offsets in CMOS. CMOS中的某些偏移处有校验和。 After you change the CMOS value, you will have to fix up the checksum to reflect the changes. 更改CMOS值后,您必须修复校验和以反映更改。

  3. Once you change the setting, it won't take effect to the next reboot (when the BIOS reads the CMOS settings and initializes the chipset). 更改设置后,它将不会生效到下次重新启动(当BIOS读取CMOS设置并初始化芯片组时)。

  4. Is this an Intel chipset? 这是英特尔芯片组吗? Intel graphics cores have a magic feature called Dynamic Video Memory Technology (DVMT) which tweaks video memory usage based on how graphics-intensive the running application is. 英特尔图形核心具有称为动态视频内存技术(DVMT)的神奇功能,可根据运行应用程序的图形密集程度调整视频内存使用量。 http://www.intel.com/support/graphics/sb/cs-010488.htm I'm not sure if other chipset vendors have a similar technology. http://www.intel.com/support/graphics/sb/cs-010488.htm我不确定其他芯片组供应商是否有类似的技术。

  5. Throw all of this out the window on a modern UEFI system, which typically uses a nonvolatile storage partition in the BIOS flash chip for the settings. 在现代UEFI系统上抛出所有这些,这通常使用BIOS闪存芯片中的非易失性存储分区进行设置。 (Some CMOS locations are populated for legacy compatibility on a UEFI system.) (在UEFI系统上填充了一些CMOS位置以实现传统兼容性。)

Short answer: No. 简答:不。

Long answer: Don't mess with user's BIOS. 答案很长:不要乱用用户的BIOS。 There's a reason why there are no APIs or the like to do it. 这就是为什么没有API或类似的原因。 My computer, my settings. 我的电脑,我的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM