# Would it be possible to add support for saving BIOS on S3 Graphic cards?



## stickedy (Jan 7, 2009)

Sadly there's no Windows tool for saving BIOS image of S3 Graphics cards, but perhaps it would be possible to add the support to GPU-Z? I have a tool to flash VGA BIOS for S3 Graphics cards but it's rather useless without a simple way to extract the BIOS.

However, with Linux a rather simple Python script makes it possible to save the BIOS image. I don't know how much is Linux specific, but I guess it should also be possible with Windows?

http://unichrome.cvs.sourceforge.net/unichrome/utils/ (it's part of the work for UniChrome/OpenChrome open source driver)

```
#! /usr/bin/env python
#
# Reads VGA rom on standard x86 memory location.
# Tries to retrieve pci vendor and card ids from pci data structure.
# Writes image out to /tmp/VGAROM_<vendor>_<device>.img.
#
#
# /dev/mem is probably awfully linux specific
#
# Luc Verhaegen -- nothing copyrightable here.

from array import array
import sys

if __name__ == "__main__":
    mem = open("/dev/mem", "rb")
    mem.seek(0xC0000)

    rom = array("B")
    rom.fromfile(mem, 3)

    if (rom[0] != 0x55) and (rom[1] != 0xAA):
        print "No x86 video rom found."
        mem.close()
        sys.exit()
        
    size = rom[2] * 512
    print "x86 video rom found: %d bytes large." % size
    rom.fromfile(mem, size - 3)
    mem.close()
    
    crc = 0;
    for byte in rom:
        crc = crc + byte
        if crc > 0xFF:
            crc = crc - 0x100
            
    if crc:
        print "Checksum failed."

    # Read location of pci data.
    pciloc = rom[0x18]

    # check signature
    if ((rom[pciloc] != 0x50) or (rom[pciloc + 1] != 0x43) or
        (rom[pciloc + 2] != 0x49) or (rom[pciloc + 3] != 0x52)):
        print "no PCIR signature."

        name = "/tmp/VGAROM_unknown.img"
    else:
        vendor = "%04X" % ((rom[pciloc + 5] << 8) | rom[pciloc + 4])
        device = "%04X" % ((rom[pciloc + 7] << 8) | rom[pciloc + 6])

        name = "/tmp/VGAROM_%s_%s.img" % (vendor, device)

    dump = open(name, "wb")
    print "Writing complete rom to %s" % name
    rom.tofile(dump)
```

Please!


----------



## W1zzard (Jan 27, 2009)

reading the rom from c0000 is not reliable enough. i asked s3 for how to read the rom but they didnt give a useful answer


----------



## stickedy (Jan 27, 2009)

W1zzard said:


> reading the rom from c0000 is not reliable enough. i asked s3 for how to read the rom but they didnt give a useful answer


Thanks for your reply! I'm not really a programmer so I guess you know more about those things than myself, but I read the BIOS from two S3 cards with this script and compared it to a "leaked" BIOS from S3 Graphics and the files were identical, at least nothing was viewable missing. Don't know how this works with Windows *shrug*

Is this "reading from c0000 is not reliable enough" some special thing or a general concern? If it could work, perhaps I could test an implementation if it works or not (if it's not to complicated to implement).

However, thanks that you have looked into it!


----------



## stickedy (Feb 4, 2009)

There's a reply on S3 Graphic's support forum and it seems that someone from S3 Graphics will contact you soon on this topic (or did it already happen?).


----------



## W1zzard (Feb 4, 2009)

they did contact me yesterday night


----------

