From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KOYck-00050m-4s for mharc-grub-devel@gnu.org; Thu, 31 Jul 2008 09:55:22 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOYch-0004wh-KM for grub-devel@gnu.org; Thu, 31 Jul 2008 09:55:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOYcf-0004uc-Vs for grub-devel@gnu.org; Thu, 31 Jul 2008 09:55:19 -0400 Received: from [199.232.76.173] (port=51668 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOYcf-0004uJ-Pc for grub-devel@gnu.org; Thu, 31 Jul 2008 09:55:17 -0400 Received: from gw02.mail.saunalahti.fi ([195.197.172.116]:53709) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KOYcf-0002Nh-2n for grub-devel@gnu.org; Thu, 31 Jul 2008 09:55:17 -0400 Received: from saimaza.webmail.saunalahti.fi (saimaza.webmail.saunalahti.fi [195.197.55.116]) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 15DE6139485 for ; Thu, 31 Jul 2008 16:55:11 +0300 (EEST) Date: Thu, 31 Jul 2008 16:55:11 +0300 (EEST) From: chaac@nic.fi To: The development of GRUB 2 Message-ID: <23656916.573861217512511895.JavaMail.chaac@nic.fi> MIME-Version: 1.0 Content-Type: text/plain; Charset=iso-8859-1; Format=Flowed Content-Transfer-Encoding: quoted-printable X-Mailer: Saunalahti webmail - http://saunalahti.fi X-Originating-IP: 118.6.251.117 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) Subject: Re: [PATCH] Move assembly code out of the kernel 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: Thu, 31 Jul 2008 13:55:20 -0000 Bean [bean123ch@gmail.com] kirjoitti:=20 > Hi, >=20 > Currently, most assembly code are in startup.S. This is normally used > to ensure that the function address are below 1m, which is required if > it would switch to real mode and call bios services. However, this > make the kernel larger. For example, the biosdisk functions are only > used by biodisk module, they should not be placed inside the kernel. >=20 > This patch support splitting such code from startup.S. For example, we > create a new module biosdisk_stub.mod for assembly code of biosdisk. > Instead of call prot_to_real and real_to_prot, we call > grub_call_real_stub to enter real mode. grub_call_real_stub would copy > the code to real mode and do the mode switch. >=20 > To avoid unnecessary memory transfer, grub_call_real_stub would not > erase the real mode stub when it's done, so that it can be used > directly next time. When the stub area is full, it zero it out and > start anew. The area uses a simple verification method so that the old > mapping is invalidated, the code would need be copied again on their > next use. >=20 > The patch shows how to do it for the biosdisk module, here is the new > grub_biosdisk_rw_int13_extensions function. >=20 > REAL_STUB_START(grub_biosdisk_rw_int13_extensions) > =09movb=09%dh, %ah > =09movw=09%cx, %ds > =09int=09$0x13=09=09/* do the operation */ > =09movb=09%ah, %dl=09/* save return value */ > =09lret > REAL_STUB_END(grub_biosdisk_rw_int13_extensions) >=20 > FUNCTION(grub_biosdisk_rw_int13_extensions) > =09pushl=09%ebp > =09pushl=09%esi >=20 > =09/* compute the address of disk_address_packet */ > =09movw=09%cx, %si > =09xorw=09%cx, %cx > =09shrl=09$4, %ecx=09/* save the segment to cx */ >=20 > =09/* ah */ > =09movb=09%al, %dh >=20 > =09leal=09grub_biosdisk_rw_int13_extensions_stub, %eax > =09call=09EXT_C(grub_call_real_stub) >=20 > =09movb=09%dl, %al=09/* return value in %eax */ >=20 > =09popl=09%esi > =09popl=09%ebp >=20 > =09ret >=20 > Real mode code is enclosed between REAL_STUB_START and REAL_STUB_END, > no need to use .code16 and .code32 as it's handled by the macro. In > the main function, use >=20 > =09leal=09grub_biosdisk_rw_int13_extensions_stub, %eax > =09call=09EXT_C(grub_call_real_stub) >=20 > to invoke grub_call_real_stub. grub_biosdisk_rw_int13_extensions_stub > is defined in the REAL_STUB_START macro. >=20 > This same method can be applied to loaders, vbe, etc. In fact, almost > all function behind grub_call_real_stub can be moved out of startup.S. I have made generic function that does basically the same thing for bios se= rvice 0x10 (video). In that modification you prepare registers structure th= at will be configured during real mode switching. I am yet to commit it for= review, but I think it would be more generic way to do this. When I come b= ack from my holiday I will commit the code for review. So please wait a bit before committing this :) Thanks, Vesa J=E4=E4skel=E4inen