Advanced BIOS tweaking – Hendrik de Jong
If you decide to use this guide and modify your BIOS, be prepared to revive your board when things go wrong. Make sure you have a DOS/Win98 -95 startup disk that will automatically flash your BIOS. If things are really bad, you may have to order a new chip from Bad Flash ($23.50 shipped). I will not be held responsible for whatever you decide to use this information for.
With everybody out there using specific tweaks, I thought it would be more useful to explain how to make your own option ROM rather than me making one that will only satisfy some of you. Also, this way you can incorporate it in your own favorite BIOS image.
So far, I’ve only tested this process on the 694x chip. If you try to do this on a different VIA chipset-based board, let me know and I’ll include a compatibility list. Many thanks to ‘programmer’ who supplied the basic template and wrote one of the tools you’ll need.
You’ll need the following files:
The following assembly file (tweak.asm) sets 4-way interleave (toggle bit 1), and sets active to precharge to 5 (toggle bit 6) on a MSI 694D-PRO motherboard.
- pushad
- mov eax,0x80000064 ; specifies offset
- mov dx,0xcf8
- out dx,eax
- mov dx,0xcfc
- in eax,dx
- and eax,0xBCBCBCBC ; and operations set bits to 0
- or eax,0x02020202 ; or operations set bits to 1
- out dx,eax
- popad
- ret
In the example above, we want to toggle bit 6 to 0 and bit 1 to 1. You can see how it is done by converting BCBCBCBC and 02020202 (hex) to binary using the conversion table below:
Use an AND instruction to toggle specific bits to 0
reg: | 67 | 66 | 65 | 64 |
hex: | B C | B C | B C | B C |
bin: | 1011 1100 | 1011 1100 | 1011 1100 | 1011 1100 |
bit: | 31 | 0 |
Use an OR instruction to toggle bits to 1
reg: | 67 | 66 | 65 | 64 |
hex: | 0 2 | 0 2 | 0 2 | 0 2 |
bin: | 0000 0010 | 0000 0010 | 0000 0010 | 0000 0010 |
bit: | 31 | 0 |
The 0’s highlighted in bold control the active to precharge bit. The other zeros are there to set the interleave bits to 0 just to make sure. The 1’s in in bold control the 4-way interleave bit. The AND and OR instructions only change a bit when you use a 0 and a 1 respectively – the other bits remain unchanged.
I would advise to change only those bits that are not accessible through the standard BIOS. Note that the VIA chipsets only respond to dword calls, so when you specify offset 64, you will actually be tweaking reg 67-64. Use wpcredit in 32-bit mode to view the register settings.
If for some reason you would like to toggle bit 2 in offset 71 to 1 (PCI fast back to back write enable) you have to load offset 70, use an AND instruction that will leave everything alone (11111111111111111111111111111111 bin = FFFFFFFF hex) use an OR instruction that will toggle the desired bit (00000000000000000000010000000000 bin = 00000400 hex).
- mov eax,0x80000070
- mov dx,0xcf8
- out dx,eax
- mov dx,0xcfc
- in eax,dx
- and eax,0xFFFFFFFF
- or eax,0x00000400
- out dx,eax
Off course, if you want to change multiple bits in this range, you can do it all at the same time. Some of you might comment that the AND instruction is not necessary because it does nothing, but I found it to be more reliable to keep it in there. It also keeps the whole process in a standard fashion.
Binary to Hex Conversion Table
binary hexadecimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
If you want to add other tweaks, just copy the green lines in the example file, and paste them in before the “popad” instruction.
- pushad
- mov eax,0x80000064
- mov dx,0xcf8
- out dx,eax
- mov dx,0xcfc
- in eax,dx
- and eax,0xBCBCBCBC
- or eax,0x2020202
- out dx,eax
- mov eax,0x80000064
- mov dx,0xcf8
- out dx,eax
- mov dx,0xcfc
- in eax,dx
- and eax,0xBCBCBCBC
- or eax,0x2020202
- out dx,eax
- popad
- ret
Then just change the values in red to your desired offset and logical values, for instance setting reg 50 and 51 to FF.
- pushad
- mov eax,0x80000050
- mov dx,0xcf8
- out dx,eax
- mov dx,0xcfc
- in eax,dx
- and eax,0xFFFFFFFF
- or eax,0x0000FFFF
- out dx,eax
- mov eax,0x80000064
- mov dx,0xcf8
- out dx,eax
- mov dx,0xcfc
- in eax,dx
- and eax,0xBCBCBCBC
- or eax,0x2020202
- out dx,eax
- popad
- ret
One problem here is that the BIOS does not allow for reg 50 to be set to FF, and the result will be FC instead, which is too bad, because that is a 10% performance loss right there. Let me know if you figure out a way to do this.
Once you’ve incorporated all the tweaks, you’ll have to assemble your .asm file.
Download nasm and unzip. Copy tweak.asm in the nasm directory and convert it with the following command line:
You can actually test this file by just double-clicking it (not in Win2000). Either boot in Win98 and check to see if the tweak.com file correctly sets the registers with wpcredit, or boot in DOS and check with chiphot.
After you’ve tested the file, you have to convert it to a ROM file, with com2rom (runs in Windows). Copy all the files from com2rom in your nasm directory and start com2rom. Just tell the program what file to convert, and you’ll have your .bin file.
The next step will be the incorporation of your option ROM into your BIOS image. I’ve had good success with cbrom208, but you may need a different version depending on your BIOS version. Incorporate this file using the following command line:
cbrom208 yourBIOS.bin /isa tweak.bin
Check to see if the file was incorporated with the following command line:
Flash the new BIOS, and keep your fingers crossed.
This guide is meant to provide you with a foolproof method for making an option ROM without explaining too much. If you have any comments or feel that I’ve made a mistake, or if you have any information to share, let me know. Once again, if you try this on a different VIA chipset, please let me know how it worked out.
Good luck!
Be the first to comment