Received: from eggs.gnu.org ([140.186.70.92]:55781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjyZu-0006Pg-IP for qemu-devel@nongnu.org; Thu, 21 Jul 2011 15:06:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QjyZt-0007C5-O9 for qemu-devel@nongnu.org; Thu, 21 Jul 2011 15:06:34 -0400 Received: from db3ehsobe003.messaging.microsoft.com ([213.199.154.141]:29650 helo=DB3EHSOBE003.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjyZt-0007Az-Bq for qemu-devel@nongnu.org; Thu, 21 Jul 2011 15:06:33 -0400 Date: Thu, 21 Jul 2011 14:06:26 -0500 From: Scott Wood Message-ID: <20110721140626.57587111@schlenkerla.am.freescale.net> In-Reply-To: <6AB341E9-F6B8-4B47-AD74-5DC8B33C091D@suse.de> References: <1311211654-14326-1-git-send-email-agraf@suse.de> <1311211654-14326-15-git-send-email-agraf@suse.de> <20110721125118.4e64ec21@schlenkerla.am.freescale.net> <6AB341E9-F6B8-4B47-AD74-5DC8B33C091D@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 14/23] PPC: KVM: Add generic function to read host clockfreq List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: QEMU-devel Developers On Thu, 21 Jul 2011 20:59:40 +0200 Alexander Graf 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