Module read a file?
I'm modifying a PCMCIA driver module so that it can load new firmware into the card when it's inserted.
Rather than including the firmware inside the module's binary, I would much rather be able to read it out of the filesystem.
Are their any good examples of kernel code or kernel modules reading a file out of the filesystem that I could copy or at least look to for inspiration?
Signature · 2 lines
Mark Atwood | I'm wearing black only until I find something darker. [email protected] | http://www.pobox.com/~mra
Quoted 10 lines · Mark Atwood
I'm modifying a PCMCIA driver module so that it can load new firmware into the card when it's inserted.
Rather than including the firmware inside the module's binary, I would much rather be able to read it out of the filesystem.
Are their any good examples of kernel code or kernel modules reading a file out of the filesystem that I could copy or at least look to for inspiration?
What about adding an ioctl() and making a userspace tool to pass the new firmware down in a buffer? This lets you do more complicated error-checking and maybe some sort of validation of the firmware in userspace, saving on kernel size.
Chris
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 11 lines · Christopher Friesen
Quoted 5 lines · Mark Atwood
I'm modifying a PCMCIA driver module so that it can load new firmware into the card when it's inserted.
Are their any good examples of kernel code or kernel modules reading a file out of the filesystem that I could copy or at least look to for inspiration?What about adding an
ioctl()and making a userspace tool to pass the new firmware down in a buffer? This lets you do more complicated error-checking and maybe some sort of validation of the firmware in userspace, saving on kernel size.
Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Having to remember "run this userspace tool after every card reset" (which includes power suspends and so forth) would be a major pain.
Besides, the card already has a good validator in it.
Signature · 2 lines
Mark Atwood | I'm wearing black only until I find something darker. [email protected] | http://www.pobox.com/~mra
Quoted 9 lines · Mark Atwood
Quoted 7 lines · Christopher Friesen
Quoted 5 lines · Mark Atwood
I'm modifying a PCMCIA driver module so that it can load new firmware into the card when it's inserted.
Are their any good examples of kernel code or kernel modules reading a file out of the filesystem that I could copy or at least look to for inspiration?
Quoted 8 lines
Quoted 4 lines
What about adding an
ioctl()and making a userspace tool to pass the new firmware down in a buffer? This lets you do more complicated error-checking and maybe some sort of validation of the firmware in userspace, saving on kernel size.Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Ah, okay. I was assuming that the firmware was stored in nonvolatile memory.
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 4 lines · Mark Atwood
Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Then add a script in the proper place in the linux-hotplug [1] package, which will run everytime your card is inserted. This is how USB firmware loads will be done in 2.5.
thanks,
greg k-h
Quoted 13 lines · Mark Atwood
Quoted 11 lines · Christopher Friesen
Quoted 5 lines · Mark Atwood
I'm modifying a PCMCIA driver module so that it can load new firmware into the card when it's inserted.
Are their any good examples of kernel code or kernel modules reading a file out of the filesystem that I could copy or at least look to for inspiration?What about adding an
ioctl()and making a userspace tool to pass the new firmware down in a buffer? This lets you do more complicated error-checking and maybe some sort of validation of the firmware in userspace, saving on kernel size.
Quoted 7 lines
Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Having to remember "run this userspace tool after every card reset" (which includes power suspends and so forth) would be a major pain.
Have a userspace job which
1) sleeps in the kernel
2) when woken, delivers the data from the filesystem via ioctl to the driver
3) goes back to sleep
Have a driver which
1) wakes the user space job
2) receives the data via ioctl
3) reloads the card
The userspace job is started at boot and lives forever. Its probably easiest to build the driver into the kernel.
johna
Quoted 3 lines
Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Longer term that is precisely what the hot plug interface is there fore
Quoted 4 lines
Having to remember "run this userspace tool after every card reset" (which includes power suspends and so forth) would be a major pain.
Besides, the card already has a good validator in it.
What do you do if the card is compiled in and initialised before the firmware holding fs is mounted ?
Quoted 5 lines · Alan Cox
Quoted 3 lines
Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Longer term that is precisely what the hot plug interface is there fore
And in the longer term, I plan on migrating this product over to the hot plug interface.
In the medium term, this will be a really useful feature for quite a few users of this driver.
In the short term, I just want to get this thing working.
Quoted 8 lines
Quoted 5 lines
Having to remember "run this userspace tool after every card reset" (which includes power suspends and so forth) would be a major pain.
Besides, the card already has a good validator in it.
What do you do if the card is compiled in and initialised before the firmware holding fs is mounted ?
Tell the packager and/or user of the module Dont Do That, and have the card_reset and card_insert functions return with an error.
Signature · 2 lines
Mark Atwood | I'm wearing black only until I find something darker. [email protected] | http://www.pobox.com/~mra
Check the PSS sound driver code. In either 2.2.x or 2.4.x. It allows you to load a firmware from a selected file.
----- Original Message -----
From: "Mark Atwood" <[email protected]>
To: "Linux Kernel Development" <[email protected]>
Sent: Thursday, October 11, 2001 4:48 PM
Subject: Module read a file?
Quoted 19 lines
I'm modifying a PCMCIA driver module so that it can load new firmware into the card when it's inserted.
Rather than including the firmware inside the module's binary, I would much rather be able to read it out of the filesystem.
Are their any good examples of kernel code or kernel modules reading a file out of the filesystem that I could copy or at least look to for inspiration?
--
Mark Atwood | I'm wearing black only until I find something darker.
[email protected] | http://www.pobox.com/~mra
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 10 lines · Mark Atwood
Quoted 4 lines
Because the firmware is stored in volitile memory on the card, and vanishes on a card reset or removal, and I would like to have it Just Work with the pcmcia-cs package with minimal changes.
Then add a script in the proper place in the linux-hotplug [1] package, which will run everytime your card is inserted. This is how USB firmware loads will be done in 2.5.
Or, the existing PCMCIA scripts from the pcmcia-cs package in /etc/pcmcia
Assuming the card is recognised in some way, perhaps as a memory card, you just stick the program to load the code into memory.opts