From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Riley Williams" Subject: Re: open file in kernel model Date: Fri, 9 May 2003 07:19:44 +0100 Sender: linux-8086-owner@vger.kernel.org Message-ID: References: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Id: Content-Type: text/plain; charset="us-ascii" To: JinuM , linux-8086@vger.kernel.org Hi Jinu. > I am trying to write a firmware loader driver. Instead of reading > the firmware as a buffer (predefined array) we would like to read > the firmware from a file (say /root/firmware). Are you assuming that there is only one piece of firmware to be loaded in the entire system, or is this driver for a specific device? > Do we have some function which reads the file contents in kernel > mode. There probably is (I'm no expert on that part of the system), but I doubt using such a function is appropriate for your declared task: 1. If this is a generic driver, it would probably need to handle multiple firmware blobs, so would need to have access to more than one file. 2. Even if it is for a specific device, the filename it needs to read will vary from one system to another. There have been quite a few discussions recently regarding firmware loading in the kernel, and at least one major Linux distributor now rips ANY "binary blobs" out of the kernel because of legal issues. The kernel developers are essentially moving over to the following general scheme: 1. The kernel itself neither contains the "binary blob" that is the firmware, nor knows where to obtain it. This is the requirement to avoid several hot legal issues, and also allows any updated firmware to be installed far easier than any other method. 2. The kernel provides an interface usable by any driver requiring firmware, where that driver can state its requirement. There are currently several candidates for this interface and it is unclear which will eventually be decided on. 3. A usermode program checks that the relevant requirement has been met, then feeds the relevant firmware to the driver. /sbin/hotplug is apparently a prime candidate for this interface. You may wish to consider such a scheme if you are working on a driver for a particular device. From the driver's viewpoint, this basically comes down to registering some means for a usermode program to supply the driver with the relevant firmware. This could be an ioctl that the usermode program can call with an open file handle as parameter, and the driver then reads the contents of that file into the firmware, or it could be a special node in the file system that the usermode program writes to and the driver copies anything written to that file straight into the firmware slot. Best wishes from Riley. --- * Nothing as pretty as a smile, nothing as ugly as a frown. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.478 / Virus Database: 275 - Release Date: 6-May-2003