On Thu, 21 Jul 2011 20:59:40 +0200
Alexander Graf <ag...@suse.de> 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