Date: Thu, 11 Apr 2002 23:22:37 +0100 From: Brian Somers <brian@freebsd-services.com> To: Julian Elischer <julian@elischer.org> Cc: "Kreider, Carl" <carl.kreider@windriver.com>, freebsd-questions@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: read a file from a driver Message-ID: <200204112222.g3BMMbOF049012@hak.lan.Awfulhak.org> In-Reply-To: Message from Julian Elischer <julian@elischer.org> of "Wed, 03 Apr 2002 10:32:35 -0800." <Pine.BSF.4.21.0204031031050.26496-100000@InterJet.elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
There's an example of how to do this in the ``digi'' driver. It loads it's firmware module on-the-fly (if it can) and dumps it afterwards. As you can see, this saves a bunch of runtime space (digi is the base driver, digi_* are the firmware modules): $ ls -l /boot/kernel/digi* -r-xr-xr-x 1 root wheel 36911 Mar 29 00:48 /boot/kernel/digi.ko -r-xr-xr-x 1 root wheel 17800 Mar 29 00:48 /boot/kernel/digi_CX.ko -r-xr-xr-x 1 root wheel 69548 Mar 29 00:48 /boot/kernel/digi_CX_PCI.ko -r-xr-xr-x 1 root wheel 68764 Mar 29 00:48 /boot/kernel/digi_EPCX.ko -r-xr-xr-x 1 root wheel 70336 Mar 29 00:48 /boot/kernel/digi_EPCX_PCI.ko -r-xr-xr-x 1 root wheel 11400 Mar 29 00:48 /boot/kernel/digi_Xe.ko -r-xr-xr-x 1 root wheel 72852 Mar 29 00:48 /boot/kernel/digi_Xem.ko -r-xr-xr-x 1 root wheel 73608 Mar 29 00:48 /boot/kernel/digi_Xr.ko Unfortunately, if you want to load digi from loader.conf, you have to explicitly load the firmware module(s) too as the module load function is called before the filesystem is available. FWIW, Solaris has a crude interface that will allow you to open and getc/putc a file. It's smart enough to know that it should talk to the boot prom if roodev isn't yet set. I believe it was required for Solaris' drivers to be able to read their .conf files at boot time, and was sufficient to allow access to other files in the software I was writing. > generally the answer is "You can't do that" > > BUT > > you could make a loadable module with the firmware, > and load both the module and the driver before booting from > the boot blocks.. > then you can unload the firmware module after booting > (or whenever) > > > > On Wed, 3 Apr 2002, Kreider, Carl wrote: > > > > > I am working on an embedded project running FreeBSD, and my driver > > for our custom card needs to load an FPGA with code. I know I can > > compile the code in as data, but for ease of development, I would > > rather fetch the FPGA code from a file. With a driver in kernel > > space. Really. > > > > Can it be done? If so, how? open() and read() are obviously in libc > > which rules them out. Do I have to write my own in assembler? > > > > -- > > Carl Kreider > > Wind River Doctor Design Services > > 700 E Beardsley Suite 14A > > Elkhart Indiana 46514 > > 219-206-8050 x104 > > carl.kreider@windriver.com ckreider@doctordesign.com > > ckreider@acm.org ckreider@gte.net > > ============================================================= > > On two occasions I have been asked [by members of Parliament], 'Pray, Mr. > > Babbage, if you put into the machine wrong figures, will the right answers > > come out?' I am not able rightly to apprehend the kind of confusion of > > ideas that could provoke such a question. > > -- Charles Babbage > > ============================================================= -- Brian <brian@freebsd-services.com> <brian@Awfulhak.org> http://www.freebsd-services.com/ <brian@[uk.]FreeBSD.org> Don't _EVER_ lose your sense of humour ! <brian@[uk.]OpenBSD.org> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204112222.g3BMMbOF049012>