简体   繁体   中英

Change BIOS settings using the C language

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

You can access the BIOS settings via I/O port 70h and 71h. (Some chipsets also have an extended CMOS at 72/73 or similar.)

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. Under Linux, you can use /dev/nvram to get at the CMOS settings. (Assuming the Linux nvram driver has support for your chipset. Otherwise use /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.

Here is a (woefully incomplete) map of CMOS memory locations: 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. (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. 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.

Without a map, there are other methods to determine which bits in CMOS represent the Video Memory Size. Try dumping the CMOS settings with various memory sizes and figure out which bits change.

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.

  2. There are checksums at certain offsets in CMOS. After you change the CMOS value, you will have to fix up the checksum to reflect the changes.

  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).

  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. http://www.intel.com/support/graphics/sb/cs-010488.htm I'm not sure if other chipset vendors have a similar technology.

  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. (Some CMOS locations are populated for legacy compatibility on a UEFI system.)

Short answer: No.

Long answer: Don't mess with user's BIOS. There's a reason why there are no APIs or the like to do it. My computer, my settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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