Preliminary Bios Modification Guide

Table of Contents

Bios Chip Hacking trick

Finally I found the trick to hack my bios safely without using the so called Bios Savior, the trick as follows:

Preliminary Award Bios Modification Guide

Before proceeding to the tutorial, I assume that you already knows the basic structure of an x86 mainboard bios file, i.e. what is original.tmp and what is an option/expansion rom. If you don't, then look for some info on the web. I'll provide these info's in this website when I have enough time to type it down :).

Here's another important thing to note: The ISA option ROM vs PCI option ROM . I've tried to add option rom which is exactly the same using /PCI and /ISA option in CBROM ver 2.07 but it behaves really different, as a note, I built the option rom using plain *.com file using masm with ml version 6.14 (from masm32 distribution) and link.exe version 5.31 from masm611 distribution, the description is as follows:

So, we'll stick to the proven solution, i.e. the ISA option ROM. You are free to test the PCI option ROM and if you are success to implement it, please inform me.

-- BEGIN UPDATE --

Finally I know the reason why the PCI expansion ROM version, is not executed. To be able to successfully execute PCI expansion ROM there are 2 things that have to be accomplished :

-- END UPDATE -- The purpose of this mod is to patch certain chipset registers in Host bridge (contained in the northbridge chipset of my mobo). There are two ways to accomplish the task:

detailed description :

;;------------------- TEST.ASM ---------------------------------------------------

 .386 

;;------------------------------------------------------- 

;;Macro definition 

;;-------------------------------------------------------

 PATCH_PCI  macro  reg_addr,mask

         mov     eax,reg_addr    ;fetch  addr of the regs to be patched

         mov     dx,in_port      ;fetch input port addr of PCI cfg space

         out     dx,eax

         mov     dx,out_port

         in      eax,dx

         or      eax,mask        ;mask the regs value (activate

                                 ;certain        bits)

         out     dx,eax

                 endm  

CSEG    SEGMENT PARA PUBLIC USE16 'CODE'

         ASSUME CS:CSEG

         ORG 0

;;Expansion rom header

         DB      55h             ;;Rom signature byte 1

         DB      0AAh            ;;Rom signature byte 2

         DB      01h             ;;512 bytes

         call    INIT            ;;jump to initialization

         retf                    ;;return far to main bios routine (original.tmp)

;;equates, have been tested d00d & works fine

         in_port         equ 0cf8h

         out_port        equ 0cfch

         ioq_mask        equ 00000080h

         ioq_reg         equ 80000050h

         bank_mask       equ 20000844h

         bank_reg        equ 80000068h

         tlb_mask        equ 00000008h

         tlb_reg         equ 8000006ch

         dram_mask       equ 00020202h

         dram_reg        equ 80000064h

          ORG 100h

INIT    PROC    NEAR

         pushad

         PATCH_PCI ioq_reg, ioq_mask     ;patch the ioq reg

         PATCH_PCI dram_reg, dram_mask   ;patch the DRAM

                                         ;controller i.e. the

                                         ;interleaving part

         PATCH_PCI bank_reg, bank_mask   ;patch bank active

                                         ;page ctl reg

         PATCH_PCI tlb_reg, tlb_mask     ;Activate Fast TLB

                                         ;lookup

         popad         retn              ;return to this rom's header

INIT    ENDP                  

ORG 200h                ;extend the file into 512 bytes

CSEG            ENDS

                     END

;;-------------------------- END OF TEST.ASM ------------------------------------

Address         Hexadecimal contents                             ASCII 

00000000     55AA 01E8 FA00 CB4D 0000 0000 0000 0000         U..............M 

00000010     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000020     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000030     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000040     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000050     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000060     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000070     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000080     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000090     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000000A0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000000B0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000000C0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000000D0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000000E0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000000F0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000100     6660 66B8 5000 0080 BAF8 0C66 EFBA FC0C         f`f.P......f.... 

00000110     66ED 660D 8000 0000 66EF 66B8 6400 0080         f.f.....f.f.d... 

00000120     BAF8 0C66 EFBA FC0C 66ED 660D 0202 0200         ...f....f.f..... 

00000130     66EF 66B8 6800 0080 BAF8 0C66 EFBA FC0C         f.f.h......f.... 

00000140     66ED 660D 4008 0020 66EF 66B8 6C00 0080         f.f.@.. f.f.l... 

00000150     BAF8 0C66 EFBA FC0C 66ED 660D 0800 0000         ...f....f.f..... 

00000160     66EF 6661 C300 0000 0000 0000 0000 0000         f.fa............ 

00000170     0000 0000 0000 0000 0000 0000 0000 0000          ................ 

00000180     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

00000190     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000001A0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000001B0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000001C0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000001D0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000001E0     0000 0000 0000 0000 0000 0000 0000 0000         ................ 

000001F0     0000 0000 0000 0000 0000 0000 0000 004D         ................. 

   pushad          ;32 bit pushad (that's why uses 66 prefix) to save all regs

         mov eax,80000064        ;enable pci configuration access mechanism 1 to offset 64

         mov dx,0cf8     ;of device 00:00:00

         out dx,eax

         mov dx,ocfc     ;get the data of offsets 64,65,66

         in  eax,dx

         or  eax,00020202        ;turn on bit 1 of offsets 64,65,66

         out dx,eax                                       

         ...             ;these instruction repeat above codes to set different

         ...             ;offsets

         popad           ;32 bit popad (that's why uses 66 prefix) to restore all regs

         ret             ;near return to the header post E8 FA 00

Pinczakko notes on building an error free .COM file using MASM611

;;----------------------------------------------------------------------------------

     .386                    ;;Processor type to use (actually) availabe GPR

     option segment:use16    ;;USE 66h,67 prefix for 32 bits operand 

.MODEL TINY             ;;generic com file format                          

;;This is where you should put your macro declarations  

.CODE org 100h                ;;com begins at 100h, then comes the real routine 

start:

         pushad                  ;save all GPR

         mov eax,dram_reg        ;fetch the address of the regs

         mov dx,in_port          ;fetch the input port addr config space

         out dx,eax

         mov dx,out_port

         in  eax,dx

         or  eax,dram_mask       ;mask the regs value

         out dx,eax

         popad                   ;restore all GPR

         retn                    ;return near to the header

;;The following part actually not only for equates but possibly also for

;;data declaration

         dram_mask       equ 00020202h

         dram_reg        equ 80000064h

         in_port         equ 0cf8h

         out_port        equ 0cfch

                  end start  

;;-----------------------------------------------------------------------------------

ML /AT hello.asm /link /TINY

That's all. Happy modding, just find the tools needed and be aware that I have no responsibility to the damage that my occur if you are doing what I've explained here. Proceed at your own risk.

Latest update: August 10th, 8:22 JAVT

copyright © Darmawan M S a.k.a Pinczakko