From owner-freebsd-questions@FreeBSD.ORG Mon Jan 23 00:54:14 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5005A16A41F for ; Mon, 23 Jan 2006 00:54:14 +0000 (GMT) (envelope-from derek@computinginnovations.com) Received: from betty.computinginnovations.com (dsl081-142-072.chi1.dsl.speakeasy.net [64.81.142.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id A4BB143D45 for ; Mon, 23 Jan 2006 00:54:11 +0000 (GMT) (envelope-from derek@computinginnovations.com) Received: from p17.computinginnovations.com (dhcp-10-20-30-100.computinginnovations.com [10.20.30.100]) (authenticated bits=0) by betty.computinginnovations.com (8.13.5/8.12.11) with ESMTP id k0N0rtbp001676; Sun, 22 Jan 2006 18:53:56 -0600 (CST) Message-Id: <6.0.0.22.2.20060122184912.0258fc50@mail.computinginnovations.com> X-Sender: derek@mail.computinginnovations.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Date: Sun, 22 Jan 2006 18:53:45 -0600 To: Nicolas Blais , freebsd-questions@freebsd.org From: Derek Ragona In-Reply-To: <200601221851.03015.nb_root@videotron.ca> References: <20060121203306.25121.qmail@simone.iecc.com> <200601221851.03015.nb_root@videotron.ca> Mime-Version: 1.0 X-ComputingInnovations-MailScanner-Information: Please contact the ISP for more information X-ComputingInnovations-MailScanner: Found to be clean X-MailScanner-From: derek@computinginnovations.com Content-Type: text/plain; charset="us-ascii"; format=flowed X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: John Levine Subject: Re: C/C++ call to detect cpu? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2006 00:54:14 -0000 Nicolas, I have commented assembler code for the intel family of CPU's. This code goes back to the i386 and also takes into account the CPU string, and will calculate the clock speed. I do call this as a library function from c/c++ programs. Unfortunately this is written for Microsoft's MASM, and I have never ported it to gas. If you want a copy I can send you the assembler source code and/or the commented listing as well. -Derek At 05:50 PM 1/22/2006, Nicolas Blais wrote: >On Saturday 21 January 2006 15:33, John Levine wrote: > > >Other than 'grep'ing dmesg, is there a way to know the current cpu such as > > > a struct with the machine's cpu and cpu feature (kinda like a time_t > > > struct)? > > > > $ sysctl hw.model > > hw.model: AMD Athlon(tm) 64 Processor 3000+ > > > > If you want more details write a tiny assembler routine that does a > > CPUID instruction and decode the result. Intel has a detailed application > > note about it at > > http://developer.intel.ru/design/xeon/applnots/241618.htm > > > > R's, > > John > >Thanks, that was great help, I was able to get the Processor Name string >using >info from that pdf. Using asm instead of sysctl will ensure a bit more >portability. >Unfortunatly, getting the actual processor speed (in Mhz) is more complicated >according to that pdf, would you have any suggestions? > >Thanks, >Nicolas. >-- >FreeBSD 7.0-CURRENT #0: Sat Jan 21 11:33:22 EST 2006 >root@clk01a:/usr/obj/usr/src/sys/CLK01A >PGP? (updated 16 Nov 05) : http://www.clkroot.net/security/nb_root.asc