Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MAnrt-0003YZ-Hm for mharc-grub-devel@gnu.org; Sun, 31 May 2009 12:26:41 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MAnrr-0003XM-Ep for grub-devel@gnu.org; Sun, 31 May 2009 12:26:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MAnrk-0003UV-0W for grub-devel@gnu.org; Sun, 31 May 2009 12:26:37 -0400 Received: from [199.232.76.173] (port=50315 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MAnrj-0003UN-SQ for grub-devel@gnu.org; Sun, 31 May 2009 12:26:31 -0400 Received: from mail-ew0-f162.google.com ([209.85.219.162]:43117) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MAnrj-0007jt-0G for grub-devel@gnu.org; Sun, 31 May 2009 12:26:31 -0400 Received: by ewy6 with SMTP id 6so9039381ewy.42 for ; Sun, 31 May 2009 09:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:in-reply-to :references:content-type:date:message-id:mime-version:x-mailer; bh=2p/MkpXtsgIIyj7d8gvlDWlVVeKv1rZnFvvZMX1tY5E=; b=rTx1+vsIWqwvWjhmis4QNcTQsLR26yZ++Xao6N7qc+e8HPkokcKhSrGEW1yuAT0a5c 5vLAdnoraN8hYVRineYUO/tIzcSUwgMPkQHTE990LpiTJJ5JSJHe/WOXzFbhstPAJDGk JHFezPUaoOFiWR+2OHScIo9RmxEMHMhXtB1ow= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:in-reply-to:references:content-type:date:message-id :mime-version:x-mailer; b=FCkvJLjKV/tv96cBATaIphVQ2kS936ou8Y+BTjXnPbmwGYagy8EdAiyqhGgttibfEP R1Vz66bufQSvz7A5PLnRNLTpKyXAdOhHj7vwVKhLimgXFGNFaFLcu4PlYh0lgLkr0yJu deo8L8SUVKwsSwSBWPbHanvNYXWxdXMLX65DM= Received: by 10.210.42.20 with SMTP id p20mr5237466ebp.92.1243787189759; Sun, 31 May 2009 09:26:29 -0700 (PDT) Received: from ?192.168.1.100? (89.141.11.145.dyn.user.ono.com [89.141.11.145]) by mx.google.com with ESMTPS id 5sm157954eyh.30.2009.05.31.09.26.28 (version=SSLv3 cipher=RC4-MD5); Sun, 31 May 2009 09:26:29 -0700 (PDT) From: Javier =?ISO-8859-1?Q?Mart=EDn?= To: The development of GRUB 2 In-Reply-To: References: <49E3E0FB.1070907@verizon.net> <1242265918.21129.27.camel@mj> <1242309828.12546.15.camel@mj> <1242325022.6056.7.camel@mj> <1243764078.22342.10.camel@accesodirecto.casa> <1243774114.8044.2.camel@accesodirecto.casa> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-4kMgUdfsivpp0xd7T5Sl" Date: Sun, 31 May 2009 18:26:29 +0200 Message-Id: <1243787189.8044.21.camel@accesodirecto.casa> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: status grub2 port of grub-legasy map command X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2009 16:26:40 -0000 --=-4kMgUdfsivpp0xd7T5Sl Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable El dom, 31-05-2009 a las 18:00 +0200, Vladimir 'phcoder' Serbinenko escribi=C3=B3: > 2009/5/31 Javier Mart=C3=ADn : > > El dom, 31-05-2009 a las 13:36 +0200, Vladimir 'phcoder' Serbinenko > > escribi=C3=B3: > >> Doing some tests I discovered that freedos MBR (but not the > >> bootsector) relies on %dl being preserved across int 0x13. In the > >> patch you can see additional hassle to preserve %dx. > > Do not do this. Some BIOS functions (like ah=3D08h) return data in dl. > > Clients should not expect data in registers to be preserved across > > interrupt calls. I don't know if there is something like a 8086/PC-BIOS > > ABI document that we can find to confirm the non-preservation of dl, bu= t > > the FreeDOS MBR should be fixed then. > Thank you for pointing ah=3D8 function > AFAIK there is no normative reference. The source which was mainly > used for long years is helppc and it states following: > - registers DS, BX, CX and DX are preserved > (http://heim.ifi.uio.no/~stanisls/helppc/int_13.html) > But now this reference is terribly outdated. > SeaBIOS preserves %dl too > According to wikipedia ah=3D8 is the only function which returns in %dl. > I will write an updated version which restores %dx only if ah!=3D8 Do not waste your time doing so. There are many other functions that return data in DX, some of them specific to certain systems or TSRs - check Ralf Brown's Interrupt List [0] for a possibly very incomplete reference. The fuss about DS, BS, CX and DX being preserved is quite false, as even Wikipedia shows at [[INT 13]]: just check ah=3D41h, which returns in both BX and CX. The only semi-rational action we can take is to reverse the mapping _only_ if %dl still contains the mapped data we passed into the int13 handler, but that leaves the question - how do we know that some 0x81 is actually the 0x81 we put there in substitution of the 0x80 the payload called with, and not the true result of the call? > > I managed to get the right %dl passed with the following procedure: > > let's say I want to boot FreeDOS on hd1, but I will drivemap it so that > > it will become hd0. Instead of doing this: > > root=3D(hd1,1) > > drivemap -s (hd0) (hd1) > > chainloader +1 > > I do the following: > > root=3D(hd0) > > drivemap -s (hd0) (hd1) > > chainloader (hd1,1)+1 > > This gets the right number into %dl (I have not checked multiboot), but > > I acknowledge that it's nothing more than a hack. > And it sets es:di (pointer to partition table entry) to incorrect value I have yet to find a bootsector that uses such information. IIrc, there were so many buggy BIOSes out there that it was unreliable anyways: MBRs just check their own memory and bootsectors forget about it entirely. Nevertheless, this issue deserves a deeper look. > > I cannot see a way for > > drivemap to access that data and modify it according to the mappings > > without breaking modularity with multiboot and chainloader > I think of something like having a function pointer in kernel > int (*grub_get_biosdisk) (grub_device_t dev) =3D grub_get_biosdisk_basic; > static int grub_get_biosdisk_basic (grub_device_t dev) > { > if (! dev) > return 0xff; > if (! dev->disk) > return 0xff; > if (! dev->disk->dev) > return 0xff; > if (dev->disk->dev->id !=3D GRUB_DISK_DEVICE_BIOSDISK_ID) > return 0xff; > return (int) dev->disk->id; > } > Which can be easily overridden by drivemap > But I don't really like this approach Neither do I, but it might be the only non-100%-hackish approach. I think this part should be addressed by a wider audience (coughs at the passive listeners in the list). > > Regarding grub2 using its own drivers, we have no reliable way of > > conclusively saying that (ata2)=3D=3D(hd1), so we'd better say nothing = at > > all and keep dl=3Dffh as we do currently. > I thought of introducing a variable "biosdrive" and doing something like > root=3Data1 > biosdrive=3D0x81 > chainloader +1 > boot > Setting %dl to 0xff if drive can't be determined reliably and isn't > supplied by user is a good possibility. I'll do so. Er... AfaIk that's what chainloader and multiboot do when they cannot determine the boot disk. Regarding that "biosdrive", it would add more complexity to what already is a non-simple system. I'd say that either this mapping gets done automagically or the current hack is better, since it is so obviously a hack that if we cannot solve it future developers will still have an itch to get rid of it. [0] http://www.ctyme.com/intr/int-13.htm --=20 -- Lazy, Oblivious, Recurrent Disaster -- Habbit --=-4kMgUdfsivpp0xd7T5Sl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Esto es una parte de mensaje firmado digitalmente -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iQIcBAABAgAGBQJKIq+xAAoJEKSl+Fbdeo72ENUQAKHC/mqAV2FRY/Rg7TYj+I7Q 4TNJ/XAbUDZ07OPlKaqOx5yASFNcpdrdZyYDekc2Ox8v8EyfuHSmm+VpGYyey0MC P964sVEQZgJ7ttyrlP6QuNXnqAzv4VhRPZmIoo2dUfS1NWrM7IaJ1DwHaOWvEebo kg3OgLNRzFPBxo88fBwAXGUt81w4n0kyvw/xKtHPFxov0nyfABI9wRIlQ0DpfurC FzJFwBJmzXSDhQ5CCu8kTE2aX4K+GzXVAEHs9lnFadFXonyhNSazv58aj/hvP7OM 3bvedisBPpd6XWRPMxtcSrq7cGMlrLEGhgOXJ58gIFbN3X+iiekLnVoOZ6eiHXZC X+HPri1WsKbuVaZSPHXeE76p4DP9O1QcALuP4SA9BEPSd8+AXm33NvrzQN9AilHt yhu+QUVMWx/7yNhlgR/TLgcLczjaKnrAinC53l+3+lBchwOuTS2KEpSqfBCUXanG hJaqIPzdcKXOq9vU1NQkL+C2Rzxc6JgWTJ+5rWECmKKJ3s3jGKT/aWiyObAoT7sZ 6xucZFCq8R6MbtW/TSkKdAzySsDJFJ/OtfIE9GSIP9g6z1Z0Om17wByNX1VhFOJP +O4C1KY9FLo9DglG+KV2NW9OPPVottHYRmK5UkGfdmW9fi4Jk3MX4dkeH0CvFgTa X6TFEbEuRWI4roanXkcT =xomu -----END PGP SIGNATURE----- --=-4kMgUdfsivpp0xd7T5Sl--