Subject: Re: access to external proms for PCI
To: Garrett D'Amore <>
From: Garrett D'Amore <>
List: tech-kern
Date: 12/13/2005 09:39:44
Garrett D'Amore wrote:

A few missing things below, sorry:

>Therefore, I propose this new API:
>/* determine the size of PCI expansion ROM */
>size_t pci_exrom_size(pci_chipset_tag_t, pcitag_t);
>/* copy raw expansion rom contents to kernel buffer */
>boolean_t pci_exrom_copy(pci_chipset_tag_t, pcitag_t, size_t offset,
>size_t cnt, void *dest);
>#define PCI_EXROM_CODE_X86   0
>#define PCI_EXROM_CODE_OBP   1
>struct pci_exrom {
>    SIMPLEQ_ENTRY(pci_exrom)   next;
void *image;
void *code; /* perhaps in lieu of code_offset below? */

>    uint16_t                   data_offset;
>    uint16_t                   code_offset;
>    /* these are parsed details from the data section */
>    pci_vendor_id_t            vendor;
>    pci_product_id_t           product;
>    uint32_t                   class_code;
>    size_t                     image_len;
>    uint8_t                    code_type;
>    uint16_t                   vpd_offset; /* removed in PCI 2.2 */
>    uint16_t                   revision;   /* code revision level */
>struct pci_exrom *pci_exrom_parse(void *image, size_t size);
And then the question is does the parser allocate a separate copy of the
passed in image after it parses it, or does it just set pointers to
point to locations within the image passed in?  I kind of prefer the
latter, but some folks might argue that it makes sense to allocate
separate to simplify book-keeping.  It also makes it possible to free up
ROM images that aren't interesting for the named architecture (e.g. free
up OBP storage on x86 machines, or vice versa.)  I think these
considerations are minor.

Now it also occurs to me that these routines may also be useful for
certain other scenarios.  For example, when hotplugging devices on
certain Solaris machines, there is a userland Fcode interpreter that
initializes the devices using something like this.  We could do this as
well.  Some (brain-damaged!) devices actually *require* BIOS or OBP
initialization, and having userland interpretation/execution could be
used to support hotplugging of those devices.  (ATI framebuffers are an
example from the x86 universe.   There are certain SCSI adapters that
have this property in the OBP universe.)

Garrett D'Amore                
Sr. Staff Engineer          Extending the Power of 64-bit UNIX Computing
Tadpole Computer, Inc.                             Phone: (951) 325-2134