Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Nov 1996 23:06:20 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        100120.3121@CompuServe.COM, Tor.Egge@idt.ntnu.no
Cc:        freebsd-current@freebsd.org, freebsd-stable@freebsd.org
Subject:   Re: Follow on Atlantis board
Message-ID:  <199611111206.XAA11539@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>When using gdb on /usr/obj/usr/src/sys/i386/boot/biosboot/boot in
>FreeBSD 3.0-current and disassembling the boot function, you'll
>see that early in the function, the boot device is placed in %edi.
>The compiler correctly (according to the calling conventions) assumes 
>that %edi is not modified by any routine called. Both memsize() and
>get_diskinfo() are called before the content of %edi is saved in the
>dosdev variable. They have a good chance of stomping upon the contents
>of %edi on some bioses.

Good work.  The problem is almost certainly in get_diskinfo().  It
is documented to clobber ES:DI in some manuals:

Phoenix "System BIOS ...":
	ES:DI = Address of Fixed Disk Parameters table
Van Gilluwe "The Undocumented PC":
	This function does _not_ return a pointer to the drive type
	table as is commonly indicated in many other technical
	references.
Ralf Brown's Interrupt List version 45:
	(PC,XT286,CONV,PS,ESDI,SCSI):
	ES:DI -> drive parameter table (floppies only)
	[Long bug list: sometimes bogusly returns success for drives
	after the last; sometimes returns wrong number of drives.]

This problem apparently became serious when I optimised some things.
I think dosdev used to be kept in memory, and apparently nothing
important was kept in %edi.

>This means that it's OK to clobber most registers except %ebx, %esi,
>%edi and %ebp. (%eax is a special case, it may contain a return
>value).

I think the other registers are preserved as insurance against the
function call protocol changing.  This isn't worthwhile, since the
function call protocol is more likely to change in other ways, but
but I'll keep preserving all(?) registers for now.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611111206.XAA11539>