From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1TAnWC-0004gw-4x for mharc-grub-devel@gnu.org; Sun, 09 Sep 2012 15:50:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAnW9-0004f5-7o for grub-devel@gnu.org; Sun, 09 Sep 2012 15:50:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAnW7-0001ya-2d for grub-devel@gnu.org; Sun, 09 Sep 2012 15:50:05 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:58889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAnW6-0001uP-Ln for grub-devel@gnu.org; Sun, 09 Sep 2012 15:50:02 -0400 Received: by wibhq4 with SMTP id hq4so1174658wib.12 for ; Sun, 09 Sep 2012 12:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; bh=jnBZ/55gf2a8ulD7OCAuidGP92wJ4CQTAQfB7Gbi4E0=; b=KbESUkeQ4wxSHwr/D/gMmuOzR9g8IIKh/ZN3twzF1muwscynSQ0A75SETUkGnPrbrJ +3YC8dlnhc3/rd9lpcJwvLhIRDhGJM9HgVn8o+yrAGFTFa2y76EEyIlbyXitIfeyyoRD 01TuPTQl48QeK+3P2oH7XPueWopf9l6XnxfAZHzdtrNpy6i6w+1ClMELksDz09kTypkK Z2qXd1mqDjZhyPokt8so4i0Vw8hrmyqYiAof/B+DPmaS8Op1UbPLyZZcJFA7u1qW9iMK LEw+5pnCfKBKPqSAP8hYztrrDtvd8FWvDhScSJqY0Ak2vGVrGk+Mg5FNND8ZcXLPc7sf McLw== Received: by 10.180.84.169 with SMTP id a9mr12086961wiz.8.1347220200774; Sun, 09 Sep 2012 12:50:00 -0700 (PDT) Received: from debian.x201.phnet (21-233.197-178.cust.bluewin.ch. [178.197.233.21]) by mx.google.com with ESMTPS id t7sm19144418wix.6.2012.09.09.12.49.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 12:49:59 -0700 (PDT) Message-ID: <504CF2E4.7070705@gmail.com> Date: Sun, 09 Sep 2012 21:49:56 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.6esrpre) Gecko/20120817 Icedove/10.0.6 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: [PATCH] Improve FreeDOS direct loading support compatibility. References: <4FF82A25.9070504@gmail.com> In-Reply-To: X-Enigmail-Version: 1.4.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig2D5C4555446CF15BE41EA238" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.171 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Sep 2012 19:50:07 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2D5C4555446CF15BE41EA238 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08.07.2012 10:28, C. Masloch wrote: >=20 > Thanks for the help. The attached patch includes spaces around all > operators, doesn't include the void cast, and doesn't mention (E)DR-DOS= > any longer. I recently learned that the dl register requirement is > present in prior releases of the FreeDOS kernel too, still called DOS-C= =2E > These DOS-C releases already are under GPLv2+ so I hope it is okay to > mention them in the comment, as the attached patch does. >=20 > Regards, > Chris >=20 > improve-freedos-compatibility-2.diff >=20 >=20 > Subject: [PATCH] Improve FreeDOS direct loading support compatibility > Date: Sun, 08 Jul 2012 10:08:29 +0200 > From: "C. Masloch" >=20 > ChangeLog | 15 ++++++ > grub-core/lib/i386/relocator.c | 2 + > grub-core/lib/i386/relocator16.S | 5 ++ > grub-core/loader/i386/pc/freedos.c | 82 +++++++++++++++++++++++++++++= ++++++-- > include/grub/i386/relocator.h | 1 + > 5 files changed, 100 insertions(+), 5 deletions(-) >=20 > # HG changeset patch > # User C. Masloch > # Date 1341734778 -7200 > # Node ID 3c587f7d6d1e80c73ec0c4a664feebb788f00ed1 > # Parent 73948d0f69334ef6b60e60c16389742c402c2f3e > Improve FreeDOS direct loading support compatibility. >=20 > diff --git a/ChangeLog b/ChangeLog > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,18 @@ > +2012-06-30 C. Masloch > + > + Improve FreeDOS direct loading support compatibility. > + > + * include/grub/i386/relocator.h (grub_relocator16_state): > + New member ebp. > + * grub-core/lib/i386/relocator.c (grub_relocator16_ebp): New extern > + variable. > + (grub_relocator16_boot): Handle %ebp. > + * grub-core/lib/i386/relocator16.S: Likewise. > + * grub-core/loader/i386/pc/freedos.c: > + Load BPB to pass kernel which partition to load from. > + Check that kernel file is not too large. > + Set register dl to BIOS unit number as well. > + > 2012-06-27 Vladimir Serbinenko > =20 > * configure.ac: Bump version to 2.00. > diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/reloca= tor.c > --- a/grub-core/lib/i386/relocator.c > +++ b/grub-core/lib/i386/relocator.c > @@ -54,6 +54,7 @@ > extern grub_uint32_t grub_relocator16_edx; > extern grub_uint32_t grub_relocator16_ebx; > extern grub_uint32_t grub_relocator16_esi; > +extern grub_uint32_t grub_relocator16_ebp; > =20 > extern grub_uint16_t grub_relocator16_keep_a20_enabled; > =20 > @@ -225,6 +226,7 @@ > grub_relocator16_ss =3D state.ss; > grub_relocator16_sp =3D state.sp; > =20 > + grub_relocator16_ebp =3D state.ebp; > grub_relocator16_ebx =3D state.ebx; > grub_relocator16_edx =3D state.edx; > grub_relocator16_esi =3D state.esi; > diff --git a/grub-core/lib/i386/relocator16.S b/grub-core/lib/i386/relo= cator16.S > --- a/grub-core/lib/i386/relocator16.S > +++ b/grub-core/lib/i386/relocator16.S > @@ -259,6 +259,11 @@ > VARIABLE(grub_relocator16_ebx) > .long 0 > =20 > + /* movl imm32, %ebp. */ > + .byte 0x66, 0xbd > +VARIABLE(grub_relocator16_ebp) > + .long 0 > + > /* Cleared direction flag is of no problem with any current > payload and makes this implementation easier. */ > cld > diff --git a/grub-core/loader/i386/pc/freedos.c b/grub-core/loader/i386= /pc/freedos.c > --- a/grub-core/loader/i386/pc/freedos.c > +++ b/grub-core/loader/i386/pc/freedos.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > =20 > GRUB_MOD_LICENSE ("GPLv3+"); > =20 > @@ -40,8 +41,23 @@ > static grub_uint32_t ebx =3D 0xffffffff; > =20 > #define GRUB_FREEDOS_SEGMENT 0x60 > +#define GRUB_FREEDOS_ADDR (GRUB_FREEDOS_SEGMENT << 4) > #define GRUB_FREEDOS_STACK_SEGMENT 0x1fe0 > -#define GRUB_FREEDOS_STACK_POINTER 0x8000 > +#define GRUB_FREEDOS_STACK_BPB_POINTER 0x7c00 > +#define GRUB_FREEDOS_BPB_ADDR ((GRUB_FREEDOS_STACK_SEGMENT << 4= ) \ > + + GRUB_FREEDOS_STACK_BPB_POINTE= R) > + > +/* FreeDOS boot.asm passes register sp as exactly this. Importantly, > + it must point below the BPB (to avoid overwriting any of it). */ > +#define GRUB_FREEDOS_STACK_POINTER (GRUB_FREEDOS_STACK_BPB_POI= NTER \ > + - 0x60) > + > +/* In this, the additional 8192 bytes are the stack reservation; the > + remaining parts trivially give the maximum allowed size. */ > +#define GRUB_FREEDOS_MAX_SIZE ((GRUB_FREEDOS_STACK_SEGMENT << 4= ) \ > + + GRUB_FREEDOS_STACK_POINTER \ > + - GRUB_FREEDOS_ADDR \ > + - 8192) > =20 > static grub_err_t > grub_freedos_boot (void) > @@ -49,14 +65,29 @@ > struct grub_relocator16_state state =3D {=20 > .cs =3D GRUB_FREEDOS_SEGMENT, > .ip =3D 0, > - .ds =3D 0, > + > + /* This is not strictly necessary for the current FreeDOS kernel > + but improves potential compatibility with others. > + There is no harm in setting this. */ > + .ds =3D GRUB_FREEDOS_STACK_SEGMENT, > .es =3D 0, > .fs =3D 0, > .gs =3D 0, > .ss =3D GRUB_FREEDOS_STACK_SEGMENT, > .sp =3D GRUB_FREEDOS_STACK_POINTER, > + .ebp =3D GRUB_FREEDOS_STACK_BPB_POINTER, > .ebx =3D ebx, > - .edx =3D 0, > + > + /* This is not strictly necessary for the current FreeDOS kernel > + but is crucial for potential compatibility with the load > + protocols of other DOS-like kernels and loaders (including > + the older FreeDOS kernel releases called DOS-C). > + (Among those, FreeDOS's new load protocol must be considered > + a special case in that it doesn't require register dl to pass > + the unit number. Incidentally, the current FreeDOS boot.asm > + does pass it in both registers.) > + There is no harm in setting this. */ > + .edx =3D ebx, > .a20 =3D 1 > }; > grub_video_set_mode ("text", 0, 0); > @@ -79,8 +110,9 @@ > { > grub_file_t file =3D 0; > grub_err_t err; > - void *kernelsys; > + void *bs, *kernelsys; > grub_size_t kernelsyssize; > + grub_device_t dev; > =20 > if (argc =3D=3D 0) > return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"))= ; > @@ -95,12 +127,52 @@ > if (! file) > goto fail; > =20 > + { > + grub_relocator_chunk_t ch; > + err =3D grub_relocator_alloc_chunk_addr (rel, &ch, GRUB_FREEDOS_BP= B_ADDR, > + GRUB_DISK_SECTOR_SIZE); I don't understand this. Shouldn't it be at 0x7c00 ? Do you plan to contribute more? If so I'd prefer to make you sign a copyright assignment, otherwise this patch can go in, once it's clear with addresses. --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig2D5C4555446CF15BE41EA238 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAlBM8uQACgkQNak7dOguQgmYowD9FRih6Lt3DK17Il7NI7loLZBB sCcleFFcsVSRaqLRB3wA/AtL3BTh/TjBh0qqJgJgQlgWtW6otYagCUKyEWqy8tbf =MyiW -----END PGP SIGNATURE----- --------------enig2D5C4555446CF15BE41EA238--