Page 1 of 1

Code to change BIOS boot sequence

Posted: Tue May 06, 2008 8:02 am
by cjjoy1980
I have written a code to change boot sequence (sometimes want my system to boot from network) using C program, using port 70 h and 71H. I followed the following procedure:

1. Dumped the CMOS contents with the current boot sequence into a file.
2. Changed the boot sequence manually and again read the CMOS contents into a file.
3. From these two file contents I observed values are being changed at 3 locations ( 1 for boot sequence and other 2 boot sequence).
4. wrote C code to write into these 3 locations
5. I was able to write successfully
6. When I restarted, I got the error. System CMOS checksum error and BIOS was updated with default value.

Can anybody help me out with this.. Is this the correct method or is their any other way??

Posted: Tue May 06, 2008 9:34 am
by cp
almost everything correct. except you obviously forgot to calculate the cmos checksum and write it back into the cmos.
i don't know if there's a standard way to calculate the checksum over the cmos contents.

Posted: Tue May 27, 2008 4:09 pm
by prostar
For many of leagacy bios, your design may work as expected if you re-compute the cmos checksum to the correct value.

But for newly UEFI based bios, your design won't work as expcted. Because these bios store the seetings in system flash directly.

Code to change BIOS boot sequence

Posted: Wed May 28, 2008 9:15 am
by fzabkar
I once analysed an old AMI 386 BIOS with 128-bytes of CMOS RAM. In that particular case there were two 2-byte checksums.

The first was at CMOS RAM addresses 2E-2F. It summed the contents of addresses 10h to 2Dh.

The second was at 3E-3F and summed the contents of addresses 34h to 3Dh and 40h to 7Fh.

I don't know if this regime still applies.

Posted: Sun Jun 29, 2008 8:45 am
by indianoutlaw187
The above statement is correct and the checksum is stored in 2e,2f, and 3e, 3f for non-EFI BIOS. EFI based BIOS store everything to flash.

So to help you, you need to understand the checksum method your BIOS uses and which locations are used to compute the checksum. This can vary from one BIOS to another. Simply change some of the BIOS options and see how it affects the contents of 2e,2f,3e,3f. Keep in mind that on Intel based systems, locations above the first 128 bytes are accessed using IO ports 72 and 73.

Code to change BIOS boot sequence

Posted: Tue Jul 15, 2008 2:03 pm
by zwzzhh
I agree with prostar. Because I use this method to test in UEFI based bios platform. But, it doesn't work.
However, I am not sure whether the bios store the setting in system flash directly or not. Because I haven't got any evidence about it.

I will be thankful, if who can give me evidence about it.