iPXE
Functions | Variables
undi.c File Reference

UNDI PCI driver. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ipxe/pci.h>
#include <undi.h>
#include <undirom.h>
#include <undiload.h>
#include <undinet.h>
#include <undipreload.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static struct undi_romundipci_find_rom (struct pci_device *pci)
 Find UNDI ROM for PCI device.
static int undipci_probe (struct pci_device *pci)
 Probe PCI device.
static void undipci_remove (struct pci_device *pci)
 Remove PCI device.

Variables

static struct pci_device_id undipci_nics []
struct pci_driver undipci_driver __pci_driver_fallback

Detailed Description

UNDI PCI driver.

Definition in file undi.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )
static struct undi_rom* undipci_find_rom ( struct pci_device pci) [static, read]

Find UNDI ROM for PCI device.

Parameters:
pciPCI device
Return values:
undiromUNDI ROM, or NULL

Try to find a driver for this device. Try an exact match on the ROM address first, then fall back to a vendor/device ID match only

Definition at line 48 of file undi.c.

References pci_device::device, pci_bar_start(), PCI_ROM_ADDRESS, undirom_find_pci(), and pci_device::vendor.

Referenced by undipci_probe().

                                                                     {
        struct undi_rom *undirom;
        unsigned long rombase;
        
        rombase = pci_bar_start ( pci, PCI_ROM_ADDRESS );
        undirom = undirom_find_pci ( pci->vendor, pci->device, rombase );
        if ( ! undirom )
                undirom = undirom_find_pci ( pci->vendor, pci->device, 0 );
        return undirom;
}
static int undipci_probe ( struct pci_device pci) [static]

Probe PCI device.

Parameters:
pciPCI device
idPCI ID
Return values:
rcReturn status code

Definition at line 66 of file undi.c.

References pci_device::busdevfn, DBGC, pci_device::dev, ENODEV, ENOMEM, free, memcpy(), memset(), NULL, pci_set_drvdata(), preloaded_undi, rc, undi_load_pci(), undi_unload(), undinet_probe(), undipci_find_rom(), and zalloc().

                                                    {
        struct undi_device *undi;
        struct undi_rom *undirom;
        int rc;

        /* Allocate UNDI device structure */
        undi = zalloc ( sizeof ( *undi ) );
        if ( ! undi )
                return -ENOMEM;
        pci_set_drvdata ( pci, undi );

        /* Find/create our pixie */
        if ( preloaded_undi.pci_busdevfn == pci->busdevfn ) {
                /* Claim preloaded UNDI device */
                DBGC ( undi, "UNDI %p using preloaded UNDI device\n", undi );
                memcpy ( undi, &preloaded_undi, sizeof ( *undi ) );
                memset ( &preloaded_undi, 0, sizeof ( preloaded_undi ) );
        } else {
                /* Find UNDI ROM for PCI device */
                if ( ! ( undirom = undipci_find_rom ( pci ) ) ) {
                        rc = -ENODEV;
                        goto err_find_rom;
                }

                /* Call UNDI ROM loader to create pixie */
                if ( ( rc = undi_load_pci ( undi, undirom,
                                            pci->busdevfn ) ) != 0 ) {
                        goto err_load_pci;
                }
        }

        /* Create network device */
        if ( ( rc = undinet_probe ( undi, &pci->dev ) ) != 0 )
                goto err_undinet_probe;
        
        return 0;

 err_undinet_probe:
        undi_unload ( undi );
 err_find_rom:
 err_load_pci:
        free ( undi );
        pci_set_drvdata ( pci, NULL );
        return rc;
}
static void undipci_remove ( struct pci_device pci) [static]

Remove PCI device.

Parameters:
pciPCI device

Definition at line 117 of file undi.c.

References free, NULL, pci_get_drvdata(), pci_set_drvdata(), undi_unload(), and undinet_remove().

                                                      {
        struct undi_device *undi = pci_get_drvdata ( pci );

        undinet_remove ( undi );
        undi_unload ( undi );
        free ( undi );
        pci_set_drvdata ( pci, NULL );
}

Variable Documentation

struct pci_device_id undipci_nics[] [static]
Initial value:
 {
        PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)", 0 ),
}

Definition at line 126 of file undi.c.

struct pci_driver undipci_driver __pci_driver_fallback
Initial value:
 {
        .ids = undipci_nics,
        .id_count = ( sizeof ( undipci_nics ) / sizeof ( undipci_nics[0] ) ),
        .class = PCI_CLASS_ID ( PCI_CLASS_NETWORK, PCI_ANY_ID, PCI_ANY_ID ),
        .probe = undipci_probe,
        .remove = undipci_remove,
}

Definition at line 130 of file undi.c.