qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile
@ 2007-03-30 16:48 Jason Wessel
  2007-03-30 17:28 ` Paul Brook
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Wessel @ 2007-03-30 16:48 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]


This patch implements a simple 24mhz clock for the versatile board such 
that functions in the linux kernel can make use of these stamps.  An 
example user of this is the printk time stamps when using the "time" 
parameter on the kernel boot line.

signed-off-by: jason.wessel@windriver.com

Cheers,
Jason.

[-- Attachment #2: arm_24mhz_clock.patch --]
[-- Type: text/x-patch, Size: 524 bytes --]

Index: qemu/hw/arm_sysctl.c
===================================================================
--- qemu.orig/hw/arm_sysctl.c
+++ qemu/hw/arm_sysctl.c
@@ -71,8 +71,10 @@ static uint32_t arm_sysctl_read(void *op
     case 0x58: /* BOOTCS */
         return 0;
     case 0x5c: /* 24MHz */
-        /* ??? not implemented.  */
-        return 0;
+    {   
+        uint64_t now = qemu_get_clock(vm_clock);
+        return (uint32_t)(now*.024);
+    }
     case 0x60: /* MISC */
         return 0;
     case 0x84: /* PROCID0 */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile
  2007-03-30 16:48 [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile Jason Wessel
@ 2007-03-30 17:28 ` Paul Brook
  2007-03-30 17:49   ` Jonathan Kalbfeld
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Brook @ 2007-03-30 17:28 UTC (permalink / raw)
  To: qemu-devel

> +        uint64_t now = qemu_get_clock(vm_clock);
> +        return (uint32_t)(now*.024);

We should be able to do this without resorting to floating point arithmetic.

Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile
  2007-03-30 17:28 ` Paul Brook
@ 2007-03-30 17:49   ` Jonathan Kalbfeld
  2007-03-30 23:30     ` Wessel, Jason
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Kalbfeld @ 2007-03-30 17:49 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 434 bytes --]

If you're ok you can shift it left 4 bits, then add half that result then
shift right 10 bits.

Of course, you'll only get 23.4Mhz that way :-)

jonathan

On 3/30/07, Paul Brook <paul@codesourcery.com> wrote:
>
> > + uint64_t now = qemu_get_clock(vm_clock);
> > + return (uint32_t)(now*.024);
>
> We should be able to do this without resorting to floating point
> arithmetic.
>
> Paul
>
>
>


-- 
--
Jonathan Kalbfeld
+1 323 620 6682

[-- Attachment #2: Type: text/html, Size: 772 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile
  2007-03-30 17:49   ` Jonathan Kalbfeld
@ 2007-03-30 23:30     ` Wessel, Jason
  2007-03-30 23:39       ` andrzej zaborowski
  0 siblings, 1 reply; 5+ messages in thread
From: Wessel, Jason @ 2007-03-30 23:30 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

uint64_t now = qemu_get_clock(vm_clock);
return (uint32_t)((now*3)/125);

The optimizer should fix this up with no floating point ops.
 
Jason.



________________________________

	From: qemu-devel-bounces+jason.wessel=windriver.com@nongnu.org
[mailto:qemu-devel-bounces+jason.wessel=windriver.com@nongnu.org] On
Behalf Of Jonathan Kalbfeld
	Sent: Friday, March 30, 2007 12:50 PM
	To: qemu-devel@nongnu.org
	Subject: Re: [Qemu-devel] [PATCH] add a simple 24mhz clock for
the versatile
	
	
	If you're ok you can shift it left 4 bits, then add half that
result then shift right 10 bits.
	
	Of course, you'll only get 23.4Mhz that way :-)
	
	jonathan
	
	
	On 3/30/07, Paul Brook <paul@codesourcery.com> wrote: 

		> + uint64_t now = qemu_get_clock(vm_clock);
		> + return (uint32_t)(now*.024);
		
		We should be able to do this without resorting to
floating point arithmetic.
		
		Paul
		
		
		




	-- 
	--
	Jonathan Kalbfeld
	+1 323 620 6682 


[-- Attachment #2: Type: text/html, Size: 2495 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile
  2007-03-30 23:30     ` Wessel, Jason
@ 2007-03-30 23:39       ` andrzej zaborowski
  0 siblings, 0 replies; 5+ messages in thread
From: andrzej zaborowski @ 2007-03-30 23:39 UTC (permalink / raw)
  To: qemu-devel

On 31/03/07, Wessel, Jason <jason.wessel@windriver.com> wrote:
>
>
> uint64_t now = qemu_get_clock(vm_clock);
> return (uint32_t)((now*3)/125);
>
> The optimizer should fix this up with no floating point ops.

Adding to the bikeshed discussion (www.bikeshed.com) this is still not
correct as vm_clock is to be used with ticks_per_sec.

return muldiv64(qemu_get_clock(vm_clock), 24000000, ticks_per_sec);

Regards,
Andrzej

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-30 23:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-30 16:48 [Qemu-devel] [PATCH] add a simple 24mhz clock for the versatile Jason Wessel
2007-03-30 17:28 ` Paul Brook
2007-03-30 17:49   ` Jonathan Kalbfeld
2007-03-30 23:30     ` Wessel, Jason
2007-03-30 23:39       ` andrzej zaborowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).