add a simple 24mhz clock for the versatile
PATCH 1/1 add a simple 24mhz clock for the versatile
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.
Cheers,
Jason.
hw/arm_sysctl.c +4 -2
@@ -71,8 +71,10 @@ static uint32_t arm_sysctl_read(void *opcase 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 */
Quoted 2 lines
+ 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
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
Quoted 11 lines · Paul Brook
Quoted 3 lines
+
uint64_tnow =qemu_get_clock(vm_clock);
+ return (uint32_t)(now*.024);We should be able to do this without resorting to floating point arithmetic.
Paul
Signature · 3 lines
-- Jonathan Kalbfeld +1 323 620 6682
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: [email protected]
[mailto:[email protected]] On Behalf Of Jonathan Kalbfeld
Sent: Friday, March 30, 2007 12:50 PM To: [email protected] 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 <[email protected]> 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
Quoted 6 lines · Jason
uint64_tnow =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