iPXE
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>
#include <config/isa.h>

Go to the source code of this file.

Macros

#define ISA_EXTRA_PROBE_ADDR_COUNT    ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
#define ISA_IOIDX_MIN(driver)
#define ISA_IOIDX_MAX(driver)
#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.

Macro Definition Documentation

◆ ISA_EXTRA_PROBE_ADDR_COUNT

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

Definition at line 39 of file isa.c.

39#define ISA_EXTRA_PROBE_ADDR_COUNT \
40 ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )

◆ ISA_IOIDX_MIN

#define ISA_IOIDX_MIN ( driver)
Value:
#define ISA_EXTRA_PROBE_ADDR_COUNT
Definition isa.c:39

Definition at line 42 of file isa.c.

Referenced by isabus_probe().

◆ ISA_IOIDX_MAX

#define ISA_IOIDX_MAX ( driver)
Value:
( -1 )

Definition at line 44 of file isa.c.

Referenced by isabus_probe().

◆ ISA_IOADDR

#define ISA_IOADDR ( driver,
ioidx )
Value:
( ( (ioidx) >= 0 ) ? \
(driver)->probe_addrs[(ioidx)] : \
static isa_probe_addr_t isa_extra_probe_addrs[]
Definition isa.c:34

Definition at line 49 of file isa.c.

49#define ISA_IOADDR( driver, ioidx ) \
50 ( ( (ioidx) >= 0 ) ? \
51 (driver)->probe_addrs[(ioidx)] : \
52 *( isa_extra_probe_addrs + (ioidx) + ISA_EXTRA_PROBE_ADDR_COUNT ) )

Referenced by isabus_probe().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER )

◆ isabus_remove()

void isabus_remove ( struct root_device * rootdev)
static

Remove ISA root bus.

Parameters
rootdevISA bus root device

Definition at line 152 of file isa.c.

152 {
153 struct isa_device *isa;
154 struct isa_device *tmp;
155
156 list_for_each_entry_safe ( isa, tmp, &rootdev->dev.children,
157 dev.siblings ) {
158 isa_remove ( isa );
159 list_del ( &isa->dev.siblings );
160 free ( isa );
161 }
162}
static void isa_remove(struct isa_device *isa)
Remove an ISA device.
Definition isa.c:82
unsigned long tmp
Definition linux_pci.h:65
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition list.h:459
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
struct list_head children
Devices attached to this device.
Definition device.h:87
struct list_head siblings
Devices on the same bus.
Definition device.h:85
An ISA device.
Definition isa.h:12
struct device dev
Generic device.
Definition isa.h:14
struct device dev
Device chain.
Definition device.h:103

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

Referenced by isabus_probe().

◆ isa_probe()

int isa_probe ( struct isa_device * isa)
static

Probe an ISA device.

Parameters
isaISA device
Return values
rcReturn status code

Definition at line 62 of file isa.c.

62 {
63 int rc;
64
65 DBG ( "Trying ISA driver %s at I/O %04x\n",
66 isa->driver->name, isa->ioaddr );
67
68 if ( ( rc = isa->driver->probe ( isa ) ) != 0 ) {
69 DBG ( "...probe failed\n" );
70 return rc;
71 }
72
73 DBG ( "...device found\n" );
74 return 0;
75}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
struct isa_driver * driver
Driver for this device.
Definition isa.h:18
uint16_t ioaddr
I/O address.
Definition isa.h:16
const char * name
Name.
Definition isa.h:36
int(* probe)(struct isa_device *isa)
Probe device.
Definition isa.h:52

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

Referenced by isabus_probe().

◆ isa_remove()

void isa_remove ( struct isa_device * isa)
static

Remove an ISA device.

Parameters
isaISA device

Definition at line 82 of file isa.c.

82 {
83 isa->driver->remove ( isa );
84 DBG ( "Removed ISA%04x\n", isa->ioaddr );
85}
void(* remove)(struct isa_device *isa)
Remove device.
Definition isa.h:58

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

Referenced by isabus_remove().

◆ isabus_probe()

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

95 {
96 struct isa_device *isa = NULL;
97 struct isa_driver *driver;
98 long ioidx;
99 int rc;
100
102 for ( ioidx = ISA_IOIDX_MIN ( driver ) ;
103 ioidx <= ISA_IOIDX_MAX ( driver ) ; ioidx++ ) {
104 /* Allocate struct isa_device */
105 if ( ! isa )
106 isa = malloc ( sizeof ( *isa ) );
107 if ( ! isa ) {
108 rc = -ENOMEM;
109 goto err;
110 }
111 memset ( isa, 0, sizeof ( *isa ) );
112 isa->driver = driver;
113 isa->ioaddr = ISA_IOADDR ( driver, ioidx );
114
115 /* Add to device hierarchy */
116 snprintf ( isa->dev.name, sizeof ( isa->dev.name ),
117 "ISA%04x", isa->ioaddr );
118 isa->dev.driver_name = driver->name;
120 isa->dev.desc.vendor = driver->vendor_id;
121 isa->dev.desc.device = driver->prod_id;
122 isa->dev.parent = &rootdev->dev;
123 list_add ( &isa->dev.siblings,
124 &rootdev->dev.children );
125 INIT_LIST_HEAD ( &isa->dev.children );
126
127 /* Try probing at this I/O address */
128 if ( isa_probe ( isa ) == 0 ) {
129 /* isadev registered, we can drop our ref */
130 isa = NULL;
131 } else {
132 /* Not registered; re-use struct */
133 list_del ( &isa->dev.siblings );
134 }
135 }
136 }
137
138 free ( isa );
139 return 0;
140
141 err:
142 free ( isa );
143 isabus_remove ( rootdev );
144 return rc;
145}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define BUS_TYPE_ISA
ISA bus type.
Definition device.h:56
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ISA_DRIVERS
ISA driver table.
Definition isa.h:62
void * memset(void *dest, int character, size_t len) __nonnull
static int isa_probe(struct isa_device *isa)
Probe an ISA device.
Definition isa.c:62
#define ISA_IOIDX_MAX(driver)
Definition isa.c:44
#define ISA_IOADDR(driver, ioidx)
Definition isa.c:49
static void isabus_remove(struct root_device *rootdev)
Remove ISA root bus.
Definition isa.c:152
#define ISA_IOIDX_MIN(driver)
Definition isa.c:42
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition list.h:46
#define list_add(new, head)
Add a new entry to the head of a list.
Definition list.h:70
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:621
unsigned int bus_type
Bus type.
Definition device.h:25
unsigned int device
Device ID.
Definition device.h:34
unsigned int vendor
Vendor ID.
Definition device.h:32
struct device_description desc
Device description.
Definition device.h:83
struct device * parent
Bus device.
Definition device.h:89
const char * driver_name
Driver name.
Definition device.h:81
char name[40]
Name.
Definition device.h:79
An ISA driver.
Definition isa.h:34
uint16_t vendor_id
Manufacturer ID to be assumed for this device.
Definition isa.h:42
uint16_t prod_id
Product ID to be assumed for this device.
Definition isa.h:44
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition tables.h:386
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition vsprintf.c:383

References device_description::bus_type, BUS_TYPE_ISA, device::children, device::desc, isa_device::dev, root_device::dev, device_description::device, isa_device::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(), device::name, isa_driver::name, NULL, device::parent, isa_driver::prod_id, rc, device::siblings, snprintf(), device_description::vendor, and isa_driver::vendor_id.

Variable Documentation

◆ isa_extra_probe_addrs

isa_probe_addr_t isa_extra_probe_addrs[]
static
Initial value:
= {
}

Definition at line 34 of file isa.c.

34 {
35#ifdef ISA_PROBE_ADDRS
36 ISA_PROBE_ADDRS
37#endif
38};

◆ isa_root_driver

struct root_driver isa_root_driver
static
Initial value:
= {
.probe = isabus_probe,
.remove = isabus_remove,
}
static int isabus_probe(struct root_device *rootdev)
Probe ISA root bus.
Definition isa.c:95

ISA bus root device driver.

Definition at line 165 of file isa.c.

165 {
166 .probe = isabus_probe,
167 .remove = isabus_remove,
168};

◆ __root_device

struct root_device isa_root_device __root_device
Initial value:
= {
.dev = { .name = "ISA" },
.driver = &isa_root_driver,
}
static struct root_driver isa_root_driver
ISA bus root device driver.
Definition isa.c:165

ISA bus root device.

Definition at line 171 of file isa.c.

171 {
172 .dev = { .name = "ISA" },
173 .driver = &isa_root_driver,
174};