Subject: Re: Firmware upload - generalize it?
To: Martin Husemann <martin@duskware.de>
From: Jachym Holecek <freza@liberouter.org>
List: tech-kern
Date: 05/28/2005 17:44:21
> On Fri, May 27, 2005 at 11:54:11PM -0700, marius aamodt eriksen wrote:
> > see
> > 
> >   http://www.openbsd.org/cgi-bin/man.cgi?query=loadfirmware&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html
> > 
> > for details.
> 
> Either I can't parse that man page correctly or it is completely not what
> I was thinking of (the minor issue of placing the firmware images left
> aside for now).
> 
> What I would do is:
> 
>  - create two kernel functions fwdownload_register_hook and 
>    fwdownload_remove_hook. Drivers register their download function
>    with this - passing the device name and a token (most cases: softc pointer)

A signle download function like

  static int
  foo_ucode_load(void *token, size_t len, u_char *data)

may be subomptimal in some cases -- for large gate arrays (imagine
high-end Xilinx Virtex models) data[] can easily become a few megabits.
Passing it all at once would be memory vastage, though I'm not sure
it would be a big problem.

FWIW, what I did recently was to create /dev/fpga0 that operates as
follows:

  1. upon open(), boot sequence is initiated
  2. successive writes load data, checking for CRC error from device
  3. close() checks for success acknowledgement from device

Anyway, having unified framework for firmware upload would be nice.

	Regards,
		-- Jachym Holecek