isa.c File Reference

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <gpxe/io.h>
#include <gpxe/isa.h>

Go to the source code of this file.

Defines

#define ISA_EXTRA_PROBE_ADDR_COUNT   ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
#define ISA_IOIDX_MIN(driver)   ( -ISA_EXTRA_PROBE_ADDR_COUNT )
#define ISA_IOIDX_MAX(driver)   ( (int) (driver)->addr_count - 1 )
#define ISA_IOADDR(driver, ioidx)

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void isabus_remove (struct root_device *rootdev)
 Remove ISA root bus.
static int isa_probe (struct isa_device *isa)
 Probe an ISA device.
static void isa_remove (struct isa_device *isa)
 Remove an ISA device.
static int isabus_probe (struct root_device *rootdev)
 Probe ISA root bus.

Variables

static isa_probe_addr_t isa_extra_probe_addrs []
static struct root_driver isa_root_driver
 ISA bus root device driver.
struct root_device isa_root_device __root_device
 ISA bus root device.


Define Documentation

#define ISA_EXTRA_PROBE_ADDR_COUNT   ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )

Definition at line 38 of file isa.c.

#define ISA_IOIDX_MIN ( driver   )     ( -ISA_EXTRA_PROBE_ADDR_COUNT )

Definition at line 41 of file isa.c.

Referenced by isabus_probe().

#define ISA_IOIDX_MAX ( driver   )     ( (int) (driver)->addr_count - 1 )

Definition at line 45 of file isa.c.

Referenced by isabus_probe().

#define ISA_IOADDR ( driver,
ioidx   ) 

Value:

( ( (ioidx) < 0 ) ?                                               \
          isa_extra_probe_addrs[ (ioidx) + ISA_EXTRA_PROBE_ADDR_COUNT ] : \
          (driver)->probe_addrs[(ioidx)] )

Definition at line 48 of file isa.c.

Referenced by isabus_probe().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void isabus_remove ( struct root_device rootdev  )  [static]

Remove ISA root bus.

Parameters:
rootdev ISA bus root device

Definition at line 150 of file isa.c.

References device::children, isa_device::dev, root_device::dev, free(), isa_remove(), list_del, list_for_each_entry_safe, and device::siblings.

Referenced by isabus_probe().

00150                                                           {
00151         struct isa_device *isa;
00152         struct isa_device *tmp;
00153 
00154         list_for_each_entry_safe ( isa, tmp, &rootdev->dev.children,
00155                                    dev.siblings ) {
00156                 isa_remove ( isa );
00157                 list_del ( &isa->dev.siblings );
00158                 free ( isa );
00159         }
00160 }

static int isa_probe ( struct isa_device isa  )  [static]

Probe an ISA device.

Parameters:
isa ISA device
Return values:
rc Return status code

Definition at line 61 of file isa.c.

References DBG, isa_device::driver, isa_device::ioaddr, isa_driver::name, and isa_driver::probe.

Referenced by isabus_probe().

00061                                                 {
00062         int rc;
00063 
00064         DBG ( "Trying ISA driver %s at I/O %04x\n",
00065               isa->driver->name, isa->ioaddr );
00066 
00067         if ( ( rc = isa->driver->probe ( isa ) ) != 0 ) {
00068                 DBG ( "...probe failed\n" );
00069                 return rc;
00070         }
00071 
00072         DBG ( "...device found\n" );
00073         return 0;
00074 }

static void isa_remove ( struct isa_device isa  )  [static]

Remove an ISA device.

Parameters:
isa ISA device

Definition at line 81 of file isa.c.

References DBG, isa_device::driver, isa_device::ioaddr, and isa_driver::remove.

Referenced by isabus_remove().

00081                                                   {
00082         isa->driver->remove ( isa );
00083         DBG ( "Removed ISA%04x\n", isa->ioaddr );
00084 }

static int isabus_probe ( struct root_device rootdev  )  [static]

Probe ISA root bus.

Parameters:
rootdev ISA bus root device
Scans the ISA bus for devices and registers all devices it can find.

Definition at line 94 of file isa.c.

References device_description::bus_type, BUS_TYPE_ISA, device::children, device::desc, root_device::dev, isa_device::dev, device_description::device, isa_device::driver, ENOMEM, for_each_table_entry, free(), INIT_LIST_HEAD, isa_device::ioaddr, ISA_DRIVERS, ISA_IOADDR, ISA_IOIDX_MAX, ISA_IOIDX_MIN, isa_probe(), isabus_remove(), list_add, list_del, malloc(), memset(), device::name, NULL, device::parent, isa_driver::prod_id, device::siblings, snprintf(), device_description::vendor, and isa_driver::vendor_id.

00094                                                         {
00095         struct isa_device *isa = NULL;
00096         struct isa_driver *driver;
00097         int ioidx;
00098         int rc;
00099 
00100         for_each_table_entry ( driver, ISA_DRIVERS ) {
00101                 for ( ioidx = ISA_IOIDX_MIN ( driver ) ;
00102                       ioidx <= ISA_IOIDX_MAX ( driver ) ; ioidx++ ) {
00103                         /* Allocate struct isa_device */
00104                         if ( ! isa )
00105                                 isa = malloc ( sizeof ( *isa ) );
00106                         if ( ! isa ) {
00107                                 rc = -ENOMEM;
00108                                 goto err;
00109                         }
00110                         memset ( isa, 0, sizeof ( *isa ) );
00111                         isa->driver = driver;
00112                         isa->ioaddr = ISA_IOADDR ( driver, ioidx );
00113 
00114                         /* Add to device hierarchy */
00115                         snprintf ( isa->dev.name, sizeof ( isa->dev.name ),
00116                                    "ISA%04x", isa->ioaddr );
00117                         isa->dev.desc.bus_type = BUS_TYPE_ISA;
00118                         isa->dev.desc.vendor = driver->vendor_id;
00119                         isa->dev.desc.device = driver->prod_id;
00120                         isa->dev.parent = &rootdev->dev;
00121                         list_add ( &isa->dev.siblings,
00122                                    &rootdev->dev.children );
00123                         INIT_LIST_HEAD ( &isa->dev.children );
00124 
00125                         /* Try probing at this I/O address */
00126                         if ( isa_probe ( isa ) == 0 ) {
00127                                 /* isadev registered, we can drop our ref */
00128                                 isa = NULL;
00129                         } else {
00130                                 /* Not registered; re-use struct */
00131                                 list_del ( &isa->dev.siblings );
00132                         }
00133                 }
00134         }
00135 
00136         free ( isa );
00137         return 0;
00138 
00139  err:
00140         free ( isa );
00141         isabus_remove ( rootdev );
00142         return rc;
00143 }


Variable Documentation

Initial value:

 {



}

Definition at line 33 of file isa.c.

struct root_driver isa_root_driver [static]

Initial value:

 {
        .probe = isabus_probe,
        .remove = isabus_remove,
}
ISA bus root device driver.

Definition at line 163 of file isa.c.

struct root_device isa_root_device __root_device

Initial value:

 {
        .dev = { .name = "ISA" },
        .driver = &isa_root_driver,
}
ISA bus root device.

Definition at line 169 of file isa.c.


Generated on Tue Apr 6 20:01:16 2010 for gPXE by  doxygen 1.5.7.1