Testbios help with nvidia 6800Gt and simple how to

Dave Aubin daubin at actuality-systems.com
Tue Oct 5 14:02:01 CEST 2004


I've taken the time to put together a simple testbios faq.
I hope it is helpful.  Feedback and additions are welcome.

Thanks,
Dave

Testbios (vgabios) Faq

Date: 10/5/2004
Author(s): David Aubin 	daubin at actuality-systems.com

Purpose:  Testbios is an i386 emulator that sits on top of user
space linux.  It's primary purpose is to provide program video rom's in
to
the cached memory area.

Faq Contents:
1.  Where to obtain testbios
2.  Prerequisites
3.  How to build testbios
4.  How to retrieve a good video bios
5.  How to use testbios

1.  Where to obtain testbios
	A. Testbios(vgabios) can be retrieved from the
linuxbios/freebios source tree:
http://www.linuxbios.org/developer/download/index.html

2.  Prerequisites
	A. You must have installed pci-utils
		i.  Get
http://atrey.karlin.mff.cuni.cz/~mj/pciutils.shtml

3.  How to build testbios:
	A.  cd freebios/util/vgabios
	B.  Edit ./Makefile and fill in the correct values for your
environment
	    I build on a 64 AMD so my makefile looks like this

--Being ./Makefile for x64--
CC       =  gcc
ARCH     := $(shell uname -m | sed -e s,i[3456789]86,i386,)
INCLUDE  =  -I ../pciutils-2.1.11
CFLAGS   =  -Wall -Ix86emu/include -O2 -g $(INCLUDE)

INTOBJS  =  int10.o int15.o int16.o int1a.o inte6.o
OBJECTS  =  testbios.o helper_exec.o helper_mem.o $(INTOBJS)
LDFLAGS  =  -static-libgcc -static

LIBS     =  x86emu/src/x86emu/libx86emu.a
../pciutils-2.1.11/lib/libpci.a

# user space pci is the only option right now.
OBJECTS += pci-userspace.o

ifeq ($(shell if test "$(ARCH)" == "x86_64" ; then echo 1; fi), 1)
        CFLAGS +=-m32 -march=i386
	endif

	all: testbios

	testbios: $(OBJECTS) $(LIBS)
	        $(CC) $(CFLAGS) -o testbios $(OBJECTS) $(LDFLAGS)
$(LIBS)

helper_exec.o: helper_exec.c test.h

x86emu/src/x86emu/libx86emu.a:
        $(MAKE) -C x86emu/src/x86emu/ -f makefile.linux

	clean:
	        $(MAKE) -C x86emu/src/x86emu/ -f makefile.linux clean
	        rm -f *.o *~ testbios

	distclean: clean
	        $(MAKE) -C x86emu/src/x86emu/ -f makefile.linux clean

--End ./Makefile--

	C.  Edit ~vgabios/x86emu/src/x86emu/makefile.linux and fill in
the correct values for your environment
	    I build on a 64 AMD so my makefile looks like this

--Begin ~vgabios/x86emu/src/x86emu/makefile.linux--
########################################################################
#####
#
#						Realmode X86 Emulator
Library
#
#            	Copyright (C) 1996-1999 SciTech Software, Inc.
#
#
========================================================================
#
#  Permission to use, copy, modify, distribute, and sell this software
and
#  its documentation for any purpose is hereby granted without fee,
#  provided that the above copyright notice appear in all copies and
that
#  both that copyright notice and this permission notice appear in
#  supporting documentation, and that the name of the authors not be
used
#  in advertising or publicity pertaining to distribution of the
software
#  without specific, written prior permission.  The authors makes no
#  representations about the suitability of this software for any
purpose.
#  It is provided "as is" without express or implied warranty.
#
#  THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
NO
#  EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF
#  USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
#  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR
#  PERFORMANCE OF THIS SOFTWARE.
#
#
========================================================================
#
# Descripton:   Linux specific makefile for the x86emu library.
#
########################################################################
#####

TARGETLIB = libx86emu.a


OBJS=\
debug.o \
decode.o \
fpu.o \
ops.o \
ops2.o \
prim_ops.o \
sys.o

$(TARGETLIB): $(OBJS)
	ar rv $(TARGETLIB) $(OBJS)

	INCS   = -I. -Ix86emu -I../../include
	CFLAGS += -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG
-DDEBUG
	ARCH   := $(shell uname -m | sed -e s,i[3456789]86,i386,)
	ifeq ($(shell if test "$(ARCH)" == "x86_64" ; then echo 1; fi),
1)
	        CFLAGS +=-m32 -march=i386
		endif


.c.o:
#	gcc -m32 -march=i386 -g -O -Wall -c $(CFLAGS) $(INCS) $*.c
	gcc -g -O -Wall -c $(CFLAGS) $(INCS) $*.c

.cpp.o:
#	gcc -m32 -march=i386 -c $(CFLAGS) $(INCS) $*.cpp
	gcc -c $(CFLAGS) $(INCS) $*.cpp

clean:
	rm -f *.a *.o

validate:	validate.o libx86emu.a
	gcc -o validate validate.o -lx86emu -L.

--End ~vgabios/x86emu/src/x86emu/makefile.linux--

	D.  Once built you could have a 32bit testbios executable made.
Depending on your embedded environment you might want to have it built
shared as the above example makes it static.  Just remove -static-libgcc
-static from the LDFLAGS on ./Makefile if you wish to have it built
shared.

4.  How to retrieve a good video bios
	A.  There are sites that have video bios roms on their website.
	    I know of this one for nvidia cards:
	    http://whitebunny.demon.nl/hardware/chipset_nvidia.html
	B.  However you should be able to retrieve your own video bios
as well
	    with linux.
	    i.  Boot up a machine with a commercial bios (not linux
bios) with
	    	the video card you wish to work under linux bios.
	    ii. From the command line enter:
	        dd if=/dev/mem of=vgabios.bin skip=1536 count=128 or 
		dd if=/dev/mem of=vgabios.bin bs=1k count=64 skip=786432

		This assumes you card's bios is cached in 0xc0000.  You
		can see where and how much your card's bios is using by
		doing a cat iomem | grep "Video ROM"

		a.  dd Explained (man dd to learn more):
			1.  if is the location to retrieve from.
			2.  of is the output file (your rom image)
			3.  skip jumps n blocks where the default n is
512 bytes
			4.  count is how many blocks you wish to read
			5.  bs is the block size
	C.  You now have a video bios image

5.  How to use testbios
	A.  Currently testbios only works from user space linux
(10/4/04)
	B.  Example from a linux command line or script enter the
following to
	    get your video bios programmed:
	    ./testbios -s 65536 --abseg /dev/mem ./vgabios.bin
	    i. Testbios explained
	    	a.  -s <size> how much of the video bios is there
		b.  --abseg where would you like to write this (/dev/mem
default)
		c.  filename of video bios
		d.  -d diag mode <pci busdevfn>
			1.  How to get pci busdevfn
				A.  lspci
				B.  look for your video card
					Example:
					2:00:00
					2 (00 << 3) | 00 = 0x200
					Example:
					00:12.0:
					0 (12 << 3) | 0 = 0x90
		e. -t dump 
		f. -c codesegment Where do you want to start, default is
0xc0000
		g. -b base  Where do you want base to be default is
0xc000
		h. -i instruction pointer usually left off as the
default



-----Original Message-----
From: linuxbios-admin at clustermatic.org
[mailto:linuxbios-admin at clustermatic.org] On Behalf Of Dave Aubin
Sent: Tuesday, October 05, 2004 2:22 PM
To: Richard Smith
Cc: linuxbios at clustermatic.org
Subject: RE: Testbios help with nvidia 6800Gt and simple how to

Hi,

  Thank you:)  Yes, it was at 0xc0000-0xc7fff, which is only 32k.
But the image I got from the windows tool was 64k (double 8000).
Weird.  I would like to stay away from window tools.
  The info you provided is nice.  I wish there was a way for us To make
a faq and we could add this to the testbios faq.  There Is a lot of good
info on the clustermatic list, but it is all Dispersed.  
  Ron if I write a simple faq can you provide some mechanism to Allow
updates to it?

Thanks,
Dave 

-----Original Message-----
From: Richard Smith [mailto:rsmith at bitworks.com]
Sent: Tuesday, October 05, 2004 2:16 PM
To: Dave Aubin
Cc: linuxbios at clustermatic.org
Subject: Re: Testbios help with nvidia 6800Gt and simple how to

Dave Aubin wrote:

> It seems my dd returned an unusable binary.  I found a good binary for

> The nvidia card from here:
> http://whitebunny.demon.nl/hardware/chipset_nvidia.html
> 

I was wondering about your dd command that but I had not had a chance to
respond yet.

This is what I use:

dd if=/dev/mem of=vbios.bin bs=1k count=64 skip=786432

That will rip the bios from 0x0c0000.  You can verify that you actually
have bios there with

  'hd -s 0x0c0000 -n 256 /dev/mem'

in some cases it may be located at 0x0e0000 rather than 0x0c0000.

It should start with the 0x55aa (Little endian) or 0xaa55 (big endian)
and futher on you should see some text identifying the bios.


--
Richard A. Smith


_______________________________________________
Linuxbios mailing list
Linuxbios at clustermatic.org
http://www.clustermatic.org/mailman/listinfo/linuxbios



More information about the coreboot mailing list