iPXE
Defines | Functions | Variables
isa.c File Reference
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/io.h>
#include <ipxe/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.

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 ) ?                                              \
          (driver)->probe_addrs[(ioidx)] :                                \
          *( isa_extra_probe_addrs + (ioidx) + ISA_EXTRA_PROBE_ADDR_COUNT ) )

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:
rootdevISA bus root device

Definition at line 151 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().

                                                          {
        struct isa_device *isa;
        struct isa_device *tmp;

        list_for_each_entry_safe ( isa, tmp, &rootdev->dev.children,
                                   dev.siblings ) {
                isa_remove ( isa );
                list_del ( &isa->dev.siblings );
                free ( isa );
        }
}
static int isa_probe ( struct isa_device isa) [static]

Probe an ISA device.

Parameters:
isaISA device
Return values:
rcReturn status code

Definition at line 61 of file isa.c.

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

Referenced by isabus_probe().

                                                {
        int rc;

        DBG ( "Trying ISA driver %s at I/O %04x\n",
              isa->driver->name, isa->ioaddr );

        if ( ( rc = isa->driver->probe ( isa ) ) != 0 ) {
                DBG ( "...probe failed\n" );
                return rc;
        }

        DBG ( "...device found\n" );
        return 0;
}
static void isa_remove ( struct isa_device isa) [static]

Remove an ISA device.

Parameters:
isaISA 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().

                                                  {
        isa->driver->remove ( isa );
        DBG ( "Removed ISA%04x\n", isa->ioaddr );
}
static int isabus_probe ( struct root_device rootdev) [static]

Probe ISA root bus.

Parameters:
rootdevISA 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, isa_device::dev, root_device::dev, device_description::device, isa_device::driver, driver, device::driver_name, 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(), isa_driver::name, device::name, NULL, device::parent, isa_driver::prod_id, rc, device::siblings, snprintf(), device_description::vendor, and isa_driver::vendor_id.

                                                        {
        struct isa_device *isa = NULL;
        struct isa_driver *driver;
        int ioidx;
        int rc;

        for_each_table_entry ( driver, ISA_DRIVERS ) {
                for ( ioidx = ISA_IOIDX_MIN ( driver ) ;
                      ioidx <= ISA_IOIDX_MAX ( driver ) ; ioidx++ ) {
                        /* Allocate struct isa_device */
                        if ( ! isa )
                                isa = malloc ( sizeof ( *isa ) );
                        if ( ! isa ) {
                                rc = -ENOMEM;
                                goto err;
                        }
                        memset ( isa, 0, sizeof ( *isa ) );
                        isa->driver = driver;
                        isa->ioaddr = ISA_IOADDR ( driver, ioidx );

                        /* Add to device hierarchy */
                        snprintf ( isa->dev.name, sizeof ( isa->dev.name ),
                                   "ISA%04x", isa->ioaddr );
                        isa->dev.driver_name = driver->name;
                        isa->dev.desc.bus_type = BUS_TYPE_ISA;
                        isa->dev.desc.vendor = driver->vendor_id;
                        isa->dev.desc.device = driver->prod_id;
                        isa->dev.parent = &rootdev->dev;
                        list_add ( &isa->dev.siblings,
                                   &rootdev->dev.children );
                        INIT_LIST_HEAD ( &isa->dev.children );

                        /* Try probing at this I/O address */
                        if ( isa_probe ( isa ) == 0 ) {
                                /* isadev registered, we can drop our ref */
                                isa = NULL;
                        } else {
                                /* Not registered; re-use struct */
                                list_del ( &isa->dev.siblings );
                        }
                }
        }

        free ( isa );
        return 0;

 err:
        free ( isa );
        isabus_remove ( rootdev );
        return rc;
}

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 164 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 170 of file isa.c.