From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KNX16-00080X-PA for mharc-grub-devel@gnu.org; Mon, 28 Jul 2008 14:00:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNX14-0007xE-VA for grub-devel@gnu.org; Mon, 28 Jul 2008 14:00:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNX13-0007tr-7h for grub-devel@gnu.org; Mon, 28 Jul 2008 14:00:14 -0400 Received: from [199.232.76.173] (port=60384 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNX13-0007th-4e for grub-devel@gnu.org; Mon, 28 Jul 2008 14:00:13 -0400 Received: from aybabtu.com ([69.60.117.155]:52603) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KNX13-0007v9-4E for grub-devel@gnu.org; Mon, 28 Jul 2008 14:00:13 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1KNWuX-00010j-AQ; Mon, 28 Jul 2008 19:53:29 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1KNX06-0001V1-1K; Mon, 28 Jul 2008 19:59:14 +0200 Date: Mon, 28 Jul 2008 19:59:14 +0200 From: Robert Millan To: Colin D Bennett Message-ID: <20080728175914.GA19973@thorin> References: <20080623075438.5861e6d1@gibibit.com> <878wwi6bqy.fsf@xs4all.nl> <20080704112801.470827ea@gibibit.com> <87tzekiecu.fsf@xs4all.nl> <20080728100533.19118c0b@gibibit.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline In-Reply-To: <20080728100533.19118c0b@gibibit.com> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Cc: The development of GRUB 2 Subject: Re: [PATCH] High resolution time/TSC patch v3 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: Mon, 28 Jul 2008 18:00:15 -0000 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 28, 2008 at 10:05:33AM -0700, Colin D Bennett wrote: > Another updated TSC patch. Now it detects TSC support for x86 CPUs at > runtime and selects either the TSC or RTC time source. This way 386 > and 486 CPUs without RDTSC instruction support are supported. > > Robert Millan was interested in getting this patch merged for the > Coreboot port, so I decided to take another crack at it. Very nice. Thanks for taking the time to send this. It needed some adjustments in order to build in Coreboot (see attached patch). Unfortunately, on runtime the value returned is always 0. I didn't think this would be related to firmware in some way, but it is. Maybe some hardware needs to be initialized? Or perhaps it's a QEMU bug. > +static __inline int > +grub_cpu_is_cpuid_supported (void) > +{ > + grub_uint32_t id_supported; > + > + __asm__ ("pushfl\n\t" > + "popl %%eax /* Get EFLAGS into EAX */\n\t" > + "movl %%eax, %%ecx /* Save original flags in ECX */\n\t" > + "xorl $0x200000, %%eax /* Flip ID bit in EFLAGS */\n\t" > + "pushl %%eax /* Store modified EFLAGS on stack */\n\t" > + "popfl /* Replace current EFLAGS */\n\t" > + "pushfl /* Read back the EFLAGS */\n\t" > + "popl %%eax /* Get EFLAGS into EAX */\n\t" > + "xorl %%ecx, %%eax /* Check if flag could be modified */\n\t" > + : "=a" (id_supported) > + : /* No inputs. */ > + : /* Clobbered: */ "%rcx"); > + > + return id_supported != 0; > +} There's similar code in commands/i386/cpuid.c. I'd suggest harmonizing them. > +static __inline int > +grub_cpu_is_tsc_supported (void) > +{ > + if (! grub_cpu_is_cpuid_supported ()) > + return 0; > + > + grub_uint32_t features; > + __asm__ ("movl $1, %%eax\n\t" > + "cpuid" > + : "=d" (features) > + : /* No inputs. */ > + : /* Clobbered: */ "%rax", "%rbx", "%rcx"); > + return (features & (1 << 4)) != 0; > +} Maybe the same would make sense here. How about a generic "is_flag_supported" function? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --3V7upXqbjpZ4EhLz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="coreboot.diff" diff -x .svn -x '*.mk' -ur grub2.old/conf/i386-coreboot.rmk grub2/conf/i386-coreboot.rmk --- grub2.old/conf/i386-coreboot.rmk 2008-07-28 19:51:19.000000000 +0200 +++ grub2/conf/i386-coreboot.rmk 2008-07-28 19:44:19.000000000 +0200 @@ -16,7 +16,7 @@ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ - kern/time.c \ + kern/time.c kern/generic/rtc_get_time_ms.c kern/generic/millisleep.c \ kern/i386/dl.c kern/parser.c kern/partition.c \ kern/env.c \ term/i386/pc/console.c \ diff -x .svn -x '*.mk' -ur grub2.old/kern/i386/linuxbios/init.c grub2/kern/i386/linuxbios/init.c --- grub2.old/kern/i386/linuxbios/init.c 2008-07-28 19:51:19.000000000 +0200 +++ grub2/kern/i386/linuxbios/init.c 2008-07-28 19:44:02.000000000 +0200 @@ -61,11 +61,6 @@ } void -grub_millisleep (grub_uint32_t ms __attribute__ ((unused))) -{ -} - -void grub_exit (void) { grub_printf ("grub_exit() is not implemented.\n"); --3V7upXqbjpZ4EhLz--