Date: Wed, 03 Apr 2002 12:59:28 -0800 From: Terry Lambert <tlambert2@mindspring.com> To: "Kreider, Carl" <carl.kreider@windriver.com> Cc: freebsd-questions@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: read a file from a driver Message-ID: <3CAB6D30.7CDAFB80@mindspring.com> References: <20020403101614.A12363@indy.doctordesign.com>
next in thread | previous in thread | raw e-mail | index | archive | help
"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? For drivers which must be active in the boot path, it is generally necessary to embed the firmware in the driver as data. This is what FreeBSD does for the Adaptec SCSI drivers. For drivers that need to be active after boot time, but before the mi_startup() is complete, you can load the data in a module that contains the data. THis is similar to compiling the data into the kernel, but puts it at a minor level of abstraction. For drivers that only need to be there before the rc files start executing or the other CPUs have been started, you can do kernel level file I/O. THis was discussed in some detail over the past year on the FreeBSD-current mailing list. THis is not recommended, since FreeBSD has porr support for kernel level file I/O compared to other OSs (e.g. AIX has excellent kernel interfaces for almost all system calls, since it puts its abstraction barriers in the right places). For most drivers which are not accessed until some way into the user space bot process, or some time after the system is up, the general model is to open the driver and to push the data down into the kernel via an ioctl(). THis is, in fact, how the LKM system worked to load loadable kernel modules: it pushed the modules over the user/kernel boundary into allocated memory, a chunk at a time. It really depends on *when* in the boot process the driver *must* be functional and available, as to which approach you should use. Using the "kernel file I/O" approach has an incredibly narrow window of utility, and since it's hard to do anyway... my recommendation is to pick another option. -- Terry 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?3CAB6D30.7CDAFB80>