qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 14/23] PPC: KVM: Add generic function to read ho


From: Scott Wood
Subject: Re: [Qemu-devel] [PATCH 14/23] PPC: KVM: Add generic function to read host clockfreq
Date: Thu, 21 Jul 2011 14:06:26 -0500

On Thu, 21 Jul 2011 20:59:40 +0200
Alexander Graf <address@hidden> wrote:

> >> +uint32_t kvmppc_get_clockfreq(void)
> >> +{
> >> +    char buf[512];
> >> +    uint32_t tb;
> >> +    FILE *f;
> >> +    int len;
> >> +
> >> +    if (kvmppc_find_cpu_dt(buf, sizeof(buf))) {
> >> +        return 0;
> >> +    }
> >> +
> >> +    snprintf(buf, sizeof(buf), "%s/clock-frequency", buf);
> >> +
> >> +    f = fopen(buf, "rb");
> >> +    if (!f) {
> >> +        return -1;
> >> +    }
> >> +
> >> +    len = fread(&tb, sizeof(tb), 1, f);
> >> +    if (len != 1) {
> >> +        goto err;
> >> +    }
> >> +
> >> +    return tb;
> >> +err:
> >> +    fclose(f);
> >> +    return 0;
> >> +}
> > 
> > Need to convert endian from big to host.  
> 
> Hm. This is kvm specific code for ppc, so only ever runs on host==big :)

Sigh.  I looked at what file it was specifically to check whether it was
in a ppc or generic file, and somehow I still didn't see the "ppc". :-P

> > Also, the frequency can be 64-bit.
> 
> Would the parameter just be 2 cells then? Got an example how this works?

Yes, it would be 2 cells.  Just check the property length.

-Scott




reply via email to

[Prev in Thread] Current Thread [Next in Thread]