#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gpxe/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_rom * | undipci_find_rom (struct pci_device *pci) |
| Find UNDI ROM for PCI device. | |
| static int | undipci_probe (struct pci_device *pci, const struct pci_device_id *id __unused) |
| 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 |
Definition in file undi.c.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static struct undi_rom* undipci_find_rom | ( | struct pci_device * | pci | ) | [static, read] |
Find UNDI ROM for PCI device.
| pci | PCI device |
| undirom | UNDI ROM, or NULL |
Definition at line 47 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().
00047 { 00048 struct undi_rom *undirom; 00049 unsigned long rombase; 00050 00051 rombase = pci_bar_start ( pci, PCI_ROM_ADDRESS ); 00052 undirom = undirom_find_pci ( pci->vendor, pci->device, rombase ); 00053 if ( ! undirom ) 00054 undirom = undirom_find_pci ( pci->vendor, pci->device, 0 ); 00055 return undirom; 00056 }
| static int undipci_probe | ( | struct pci_device * | pci, | |
| const struct pci_device_id *id | __unused | |||
| ) | [static] |
Probe PCI device.
| pci | PCI device | |
| id | PCI ID |
| rc | Return status code |
Definition at line 65 of file undi.c.
References pci_device::bus, device::children, pci_device::class, DBGC, device::desc, pci_device::dev, undi_device::dev, pci_device::devfn, ENODEV, ENOMEM, ENOTTY, free(), INIT_LIST_HEAD, list_add, list_del, memcpy, memset(), device::name, NULL, device::parent, PCI_BASE_CLASS, PCI_BASE_CLASS_NETWORK, PCI_BUSDEVFN, pci_set_drvdata(), preloaded_undi, device::siblings, snprintf(), undi_load_pci(), undi_unload(), undinet_probe(), undipci_find_rom(), and zalloc().
00066 { 00067 struct undi_device *undi; 00068 struct undi_rom *undirom; 00069 unsigned int busdevfn = PCI_BUSDEVFN ( pci->bus, pci->devfn ); 00070 int rc; 00071 00072 /* Ignore non-network devices */ 00073 if ( PCI_BASE_CLASS ( pci->class ) != PCI_BASE_CLASS_NETWORK ) 00074 return -ENOTTY; 00075 00076 /* Allocate UNDI device structure */ 00077 undi = zalloc ( sizeof ( *undi ) ); 00078 if ( ! undi ) 00079 return -ENOMEM; 00080 pci_set_drvdata ( pci, undi ); 00081 00082 /* Find/create our pixie */ 00083 if ( preloaded_undi.pci_busdevfn == busdevfn ) { 00084 /* Claim preloaded UNDI device */ 00085 DBGC ( undi, "UNDI %p using preloaded UNDI device\n", undi ); 00086 memcpy ( undi, &preloaded_undi, sizeof ( *undi ) ); 00087 memset ( &preloaded_undi, 0, sizeof ( preloaded_undi ) ); 00088 } else { 00089 /* Find UNDI ROM for PCI device */ 00090 if ( ! ( undirom = undipci_find_rom ( pci ) ) ) { 00091 rc = -ENODEV; 00092 goto err_find_rom; 00093 } 00094 00095 /* Call UNDI ROM loader to create pixie */ 00096 if ( ( rc = undi_load_pci ( undi, undirom, busdevfn ) ) != 0 ) 00097 goto err_load_pci; 00098 } 00099 00100 /* Add to device hierarchy */ 00101 snprintf ( undi->dev.name, sizeof ( undi->dev.name ), 00102 "UNDI-%s", pci->dev.name ); 00103 memcpy ( &undi->dev.desc, &pci->dev.desc, sizeof ( undi->dev.desc ) ); 00104 undi->dev.parent = &pci->dev; 00105 INIT_LIST_HEAD ( &undi->dev.children ); 00106 list_add ( &undi->dev.siblings, &pci->dev.children ); 00107 00108 /* Create network device */ 00109 if ( ( rc = undinet_probe ( undi ) ) != 0 ) 00110 goto err_undinet_probe; 00111 00112 return 0; 00113 00114 err_undinet_probe: 00115 undi_unload ( undi ); 00116 list_del ( &undi->dev.siblings ); 00117 err_find_rom: 00118 err_load_pci: 00119 free ( undi ); 00120 pci_set_drvdata ( pci, NULL ); 00121 return rc; 00122 }
| static void undipci_remove | ( | struct pci_device * | pci | ) | [static] |
Remove PCI device.
| pci | PCI device |
Definition at line 129 of file undi.c.
References undi_device::dev, free(), list_del, NULL, pci_get_drvdata(), pci_set_drvdata(), device::siblings, undi_unload(), and undinet_remove().
00129 { 00130 struct undi_device *undi = pci_get_drvdata ( pci ); 00131 00132 undinet_remove ( undi ); 00133 undi_unload ( undi ); 00134 list_del ( &undi->dev.siblings ); 00135 free ( undi ); 00136 pci_set_drvdata ( pci, NULL ); 00137 }
struct pci_device_id undipci_nics[] [static] |
| struct pci_driver undipci_driver __pci_driver |
Initial value:
{
.ids = undipci_nics,
.id_count = ( sizeof ( undipci_nics ) / sizeof ( undipci_nics[0] ) ),
.probe = undipci_probe,
.remove = undipci_remove,
}
1.5.7.1