Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Ihn84-0005nN-QO for mharc-grub-devel@gnu.org; Tue, 16 Oct 2007 10:10:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ihn83-0005nE-2F for grub-devel@gnu.org; Tue, 16 Oct 2007 10:10:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ihn81-0005mo-Mh for grub-devel@gnu.org; Tue, 16 Oct 2007 10:10:38 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ihn81-0005mj-Bj for grub-devel@gnu.org; Tue, 16 Oct 2007 10:10:37 -0400 Received: from smtp-vbr7.xs4all.nl ([194.109.24.27]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ihn80-0003QV-PK for grub-devel@gnu.org; Tue, 16 Oct 2007 10:10:37 -0400 Received: from localhost.localdomain (249-174.surfsnel.dsl.internl.net [145.99.174.249]) by smtp-vbr7.xs4all.nl (8.13.8/8.13.8) with ESMTP id l9GEAOwo051107 for ; Tue, 16 Oct 2007 16:10:25 +0200 (CEST) (envelope-from mgerards@xs4all.nl) From: Marco Gerards To: The development of GRUB 2 References: <20071015143857.GA26571@thorin> Mail-Copies-To: mgerards@xs4all.nl Date: Tue, 16 Oct 2007 16:11:28 +0200 In-Reply-To: <20071015143857.GA26571@thorin> (Robert Millan's message of "Mon, 15 Oct 2007 16:38:57 +0200") Message-ID: <87wstnqhdb.fsf@xs4all.nl> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 Subject: Re: [PATCH] Implement grub_sleep() and grub_ticksleep() 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: Tue, 16 Oct 2007 14:10:39 -0000 Robert Millan writes: > This patch implements grub_sleep() and grub_ticksleep(). Great! > 2007-10-15 Robert Millan > > * include/grub/time.h: New file. > > * include/grub/i386/pc/time.h (KERNEL_TIME_HEADER): Rename all > instances to ... > (KERNEL_MACHINE_TIME_HEADER): ... this. > * include/grub/powerpc/ieee1275/time.h: Likewise. > * include/grub/sparc64/ieee1275/time.h: Likewise. Better just repeat the same process for the last two lines. > * kern/i386/efi/init.c: Include `grub/time.h'. > (grub_ticksleep): New function. > * kern/i386/pc/init.c: Likewise. > * kern/powerpc/ieee1275/init.c: Likewise. > * kern/sparc64/ieee1275/init.c: Likewise. Please repeat is. Only use likewise when the change to one function is the same. Better do too much instead of not enough. > +#include > +#include > + > +void EXPORT_FUNC(grub_ticksleep) (grub_uint32_t ticks); > + > +static __inline void > +grub_sleep (grub_uint32_t s) > +{ > + grub_ticksleep (s * GRUB_TICKS_PER_SECOND); > +} Sleeping entire seconds is a bit much. Can you also add this for smaller time instances? If you divide, please round up so that no waiting at all is avoided. Most of the time you can better wait a bit too long, I think. > +static __inline void > +grub_cpu_idle () > +{ > +#if defined(__i386__) > + __asm__ __volatile__ ("hlt"); > + /* FIXME: add other CPUs here */ > +#endif > +} This should go into a arch specific headerfile. > +#endif /* ! KERNEL_TIME_HEADER */ > diff -Nur grub2/kern/i386/efi/init.c grub2.ticks/kern/i386/efi/init.c > --- grub2/kern/i386/efi/init.c 2007-07-22 01:32:27.000000000 +0200 > +++ grub2.ticks/kern/i386/efi/init.c 2007-10-15 16:28:06.000000000 +0200 > @@ -25,6 +25,16 @@ > #include > #include > #include > +#include > + > +void > +grub_ticksleep (grub_uint32_t ticks) > +{ > + grub_uint32_t end_at; > + end_at = grub_get_rtc () + ticks; > + while (grub_get_rtc () < end_at) > + grub_cpu_idle (); > +} Why do you recreate this for every arch? This seems portable as long as you can sleep a bit from time to time. -- Marco