From owner-freebsd-current Thu Jun 11 09:13:14 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA20285 for freebsd-current-outgoing; Thu, 11 Jun 1998 09:13:14 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA20265 for ; Thu, 11 Jun 1998 09:13:11 -0700 (PDT) (envelope-from julian@whistle.com) Received: (from daemon@localhost) by alpo.whistle.com (8.8.5/8.8.5) id JAA29699; Thu, 11 Jun 1998 09:05:31 -0700 (PDT) Received: from current1.whistle.com(207.76.205.22) via SMTP by alpo.whistle.com, id smtpd029696; Thu Jun 11 16:05:30 1998 Date: Thu, 11 Jun 1998 09:05:25 -0700 (PDT) From: Julian Elischer To: luigi@labinfo.iet.unipi.it, Bruce Evans cc: current@FreeBSD.ORG Subject: Re: floating point usage within the kernel - howto ? In-Reply-To: <199806110938.TAA31787@godzilla.zeta.org.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 11 Jun 1998, Bruce Evans wrote: > >a local user has a need to do some Floating Point computations within > >the kernel. I think this is not possible without explicitly > >saving&restoring the FP register around the task, is this correct ? > >And if this is true, is there any trick/asm routine to call to do the > >saving & restoring of the registers ? > > You don't want to do this. > > The usual asm("fnsave ...; fldcw ...") to save the old state and > initialize the new state, and asm("frstor ...") to restore the old > state works in some cases (essentially, if you have a modern i*86 CPU > and don't call any kernel function that already uses floating point). > This is used (with some optimizations) for kernel bcopies on P5's. > General code can't both use the FPU or call bcopy (or bzero) without > breaking the optimizations. There are more complications and the > same restrictions for copyin() and copyout(). There are different > complications on plain i386's. Beware of future MMX optimisations which would use the floating point registers without you being aware of it.. I agree with Mike get an example of the calculations that need to be done of every cycle and the accuracy needed and maybe we can figure out an optimised fixed-point version. Any calculations that need to be done at a different timescape (e.g. calibrations etc. shoul dbe done in a user-process, possibly running under rtprio. the driver should use the aquite_timer0() call to ensure that it's lowest level routines are called at 1000Hz. (we do this at various rates, and the pcaudio driver does it at 16000 Hz so 1000 Hz is no challenge). > > Bruce > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message