iPXE
Functions | Variables
eisa.c File Reference
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/io.h>
#include <unistd.h>
#include <ipxe/eisa.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static void eisabus_remove (struct root_device *rootdev)
 Remove EISA root bus. More...
 
void eisa_device_enabled (struct eisa_device *eisa, int enabled)
 Reset and enable/disable an EISA device. More...
 
static int eisa_probe (struct eisa_device *eisa)
 Probe an EISA device. More...
 
static void eisa_remove (struct eisa_device *eisa)
 Remove an EISA device. More...
 
static int eisabus_probe (struct root_device *rootdev)
 Probe EISA root bus. More...
 

Variables

static struct root_driver eisa_root_driver
 EISA bus root device driver. More...
 
struct root_device eisa_root_device __root_device
 EISA bus root device. More...
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ eisabus_remove()

static void eisabus_remove ( struct root_device rootdev)
static

Remove EISA root bus.

Parameters
rootdevEISA bus root device

Definition at line 168 of file eisa.c.

168  {
169  struct eisa_device *eisa;
170  struct eisa_device *tmp;
171 
172  list_for_each_entry_safe ( eisa, tmp, &rootdev->dev.children,
173  dev.siblings ) {
174  eisa_remove ( eisa );
175  list_del ( &eisa->dev.siblings );
176  free ( eisa );
177  }
178 }
An EISA device.
Definition: eisa.h:38
struct device dev
Device chain.
Definition: device.h:99
unsigned long tmp
Definition: linux_pci.h:53
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#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:458
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
struct list_head children
Devices attached to this device.
Definition: device.h:83
struct device dev
Generic device.
Definition: eisa.h:40
static void eisa_remove(struct eisa_device *eisa)
Remove an EISA device.
Definition: eisa.c:85

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

Referenced by eisabus_probe().

◆ eisa_device_enabled()

void eisa_device_enabled ( struct eisa_device eisa,
int  enabled 
)

Reset and enable/disable an EISA device.

Parameters
eisaEISA device
enabled1=enable, 0=disable

Definition at line 20 of file eisa.c.

20  {
21  /* Set reset line high for 1000 µs. Spec says 500 µs, but
22  * this doesn't work for all cards, so we are conservative.
23  */
25  udelay ( 1000 ); /* Must wait 800 */
26 
27  /* Set reset low and write a 1 to ENABLE. Delay again, in
28  * case the card takes a while to wake up.
29  */
31  eisa->ioaddr + EISA_GLOBAL_CONFIG );
32  udelay ( 1000 ); /* Must wait 800 */
33 
34  DBG ( "EISA %s device %02x\n", ( enabled ? "enabled" : "disabled" ),
35  eisa->slot );
36 }
uint32_t enabled
Bitmask of enabled AENQ groups (host -> device)
Definition: ena.h:14
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
unsigned int slot
Slot number.
Definition: eisa.h:42
#define EISA_CMD_RESET
Definition: eisa.h:24
uint16_t ioaddr
I/O address.
Definition: eisa.h:44
#define outb(data, io_addr)
Definition: io.h:309
#define EISA_CMD_ENABLE
Definition: eisa.h:25
#define EISA_GLOBAL_CONFIG
Definition: eisa.h:22
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, EISA_CMD_ENABLE, EISA_CMD_RESET, EISA_GLOBAL_CONFIG, enabled, eisa_device::ioaddr, outb, eisa_device::slot, and udelay().

Referenced by disable_eisa_device(), and enable_eisa_device().

◆ eisa_probe()

static int eisa_probe ( struct eisa_device eisa)
static

Probe an EISA device.

Parameters
eisaEISA device
Return values
rcReturn status code

Searches for a driver for the EISA device. If a driver is found, its probe() routine is called.

Definition at line 47 of file eisa.c.

47  {
48  struct eisa_driver *driver;
49  struct eisa_device_id *id;
50  unsigned int i;
51  int rc;
52 
53  DBG ( "Adding EISA device %02x (%04x:%04x (\"%s\") io %x)\n",
54  eisa->slot, eisa->vendor_id, eisa->prod_id,
55  isa_id_string ( eisa->vendor_id, eisa->prod_id ), eisa->ioaddr );
56 
58  for ( i = 0 ; i < driver->id_count ; i++ ) {
59  id = &driver->ids[i];
60  if ( id->vendor_id != eisa->vendor_id )
61  continue;
62  if ( ISA_PROD_ID ( id->prod_id ) !=
63  ISA_PROD_ID ( eisa->prod_id ) )
64  continue;
65  eisa->driver = driver;
66  eisa->dev.driver_name = id->name;
67  DBG ( "...using driver %s\n", eisa->dev.driver_name );
68  if ( ( rc = driver->probe ( eisa, id ) ) != 0 ) {
69  DBG ( "......probe failed\n" );
70  continue;
71  }
72  return 0;
73  }
74  }
75 
76  DBG ( "...no driver found\n" );
77  return -ENOTTY;
78 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint16_t vendor_id
Manufacturer ID.
Definition: eisa.h:46
char * isa_id_string(unsigned int vendor, unsigned int product)
Definition: isa_ids.c:11
int(* probe)(struct eisa_device *eisa, const struct eisa_device_id *id)
Probe device.
Definition: eisa.h:72
struct eisa_driver * driver
Driver for this device.
Definition: eisa.h:50
An EISA device ID list entry.
Definition: eisa.h:28
unsigned int slot
Slot number.
Definition: eisa.h:42
const char * driver_name
Driver name.
Definition: device.h:77
unsigned int id_count
Number of entries in EISA ID table.
Definition: eisa.h:64
uint8_t id
Request identifier.
Definition: ena.h:12
An EISA driver.
Definition: eisa.h:60
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
uint16_t ioaddr
I/O address.
Definition: eisa.h:44
#define ISA_PROD_ID(product)
Definition: isa_ids.h:45
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
#define EISA_DRIVERS
EISA driver table.
Definition: eisa.h:83
struct eisa_device_id * ids
EISA ID table.
Definition: eisa.h:62
struct device dev
Generic device.
Definition: eisa.h:40
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint16_t prod_id
Product ID.
Definition: eisa.h:48

References DBG, eisa_device::dev, eisa_device::driver, device::driver_name, EISA_DRIVERS, ENOTTY, for_each_table_entry, id, eisa_driver::id_count, eisa_driver::ids, eisa_device::ioaddr, isa_id_string(), ISA_PROD_ID, eisa_driver::probe, eisa_device::prod_id, rc, eisa_device::slot, and eisa_device::vendor_id.

Referenced by eisabus_probe().

◆ eisa_remove()

static void eisa_remove ( struct eisa_device eisa)
static

Remove an EISA device.

Parameters
eisaEISA device

Definition at line 85 of file eisa.c.

85  {
86  eisa->driver->remove ( eisa );
87  DBG ( "Removed EISA device %02x\n", eisa->slot );
88 }
struct eisa_driver * driver
Driver for this device.
Definition: eisa.h:50
unsigned int slot
Slot number.
Definition: eisa.h:42
void(* remove)(struct eisa_device *eisa)
Remove device.
Definition: eisa.h:79
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, eisa_device::driver, eisa_driver::remove, and eisa_device::slot.

Referenced by eisabus_remove().

◆ eisabus_probe()

static int eisabus_probe ( struct root_device rootdev)
static

Probe EISA root bus.

Parameters
rootdevEISA bus root device

Scans the EISA bus for devices and registers all devices it can find.

Definition at line 98 of file eisa.c.

98  {
99  struct eisa_device *eisa = NULL;
100  unsigned int slot;
101  uint8_t system;
102  int rc;
103 
104  /* Check for EISA system board */
105  system = inb ( EISA_VENDOR_ID );
106  if ( system & 0x80 ) {
107  DBG ( "No EISA system board (read %02x)\n", system );
108  return -ENODEV;
109  }
110 
111  for ( slot = EISA_MIN_SLOT ; slot <= EISA_MAX_SLOT ; slot++ ) {
112  /* Allocate struct eisa_device */
113  if ( ! eisa )
114  eisa = malloc ( sizeof ( *eisa ) );
115  if ( ! eisa ) {
116  rc = -ENOMEM;
117  goto err;
118  }
119  memset ( eisa, 0, sizeof ( *eisa ) );
120  eisa->slot = slot;
121  eisa->ioaddr = EISA_SLOT_BASE ( eisa->slot );
122 
123  /* Test for board present */
124  outb ( 0xff, eisa->ioaddr + EISA_VENDOR_ID );
125  eisa->vendor_id =
126  le16_to_cpu ( inw ( eisa->ioaddr + EISA_VENDOR_ID ) );
127  eisa->prod_id =
128  le16_to_cpu ( inw ( eisa->ioaddr + EISA_PROD_ID ) );
129  if ( eisa->vendor_id & 0x80 ) {
130  /* No board present */
131  continue;
132  }
133 
134  /* Add to device hierarchy */
135  snprintf ( eisa->dev.name, sizeof ( eisa->dev.name ),
136  "EISA%02x", slot );
137  eisa->dev.desc.bus_type = BUS_TYPE_EISA;
138  eisa->dev.desc.vendor = eisa->vendor_id;
139  eisa->dev.desc.device = eisa->prod_id;
140  eisa->dev.parent = &rootdev->dev;
141  list_add ( &eisa->dev.siblings, &rootdev->dev.children );
142  INIT_LIST_HEAD ( &eisa->dev.children );
143 
144  /* Look for a driver */
145  if ( eisa_probe ( eisa ) == 0 ) {
146  /* eisadev registered, we can drop our ref */
147  eisa = NULL;
148  } else {
149  /* Not registered; re-use struct */
150  list_del ( &eisa->dev.siblings );
151  }
152  }
153 
154  free ( eisa );
155  return 0;
156 
157  err:
158  free ( eisa );
159  eisabus_remove ( rootdev );
160  return rc;
161 }
static int eisa_probe(struct eisa_device *eisa)
Probe an EISA device.
Definition: eisa.c:47
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
#define EISA_PROD_ID
Definition: eisa.h:21
uint16_t vendor_id
Manufacturer ID.
Definition: eisa.h:46
char name[40]
Name.
Definition: device.h:75
#define EISA_MIN_SLOT
Definition: eisa.h:16
An EISA device.
Definition: eisa.h:38
struct device dev
Device chain.
Definition: device.h:99
unsigned int vendor
Vendor ID.
Definition: device.h:31
struct device * parent
Bus device.
Definition: device.h:85
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static void eisabus_remove(struct root_device *rootdev)
Remove EISA root bus.
Definition: eisa.c:168
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int slot
Slot number.
Definition: eisa.h:42
#define BUS_TYPE_EISA
EISA bus type.
Definition: device.h:49
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define EISA_VENDOR_ID
Definition: eisa.h:20
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
#define ENODEV
No such device.
Definition: errno.h:509
unsigned char uint8_t
Definition: stdint.h:10
uint8_t slot
Slot.
Definition: edd.h:16
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
#define le16_to_cpu(value)
Definition: byteswap.h:112
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
uint16_t ioaddr
I/O address.
Definition: eisa.h:44
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
#define outb(data, io_addr)
Definition: io.h:309
unsigned int bus_type
Bus type.
Definition: device.h:24
unsigned int device
Device ID.
Definition: device.h:33
#define EISA_MAX_SLOT
Definition: eisa.h:17
struct list_head children
Devices attached to this device.
Definition: device.h:83
struct device_description desc
Device description.
Definition: device.h:79
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
struct device dev
Generic device.
Definition: eisa.h:40
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint16_t prod_id
Product ID.
Definition: eisa.h:48
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:24
void * memset(void *dest, int character, size_t len) __nonnull
#define EISA_SLOT_BASE(n)
Definition: eisa.h:18

References device_description::bus_type, BUS_TYPE_EISA, device::children, DBG, device::desc, eisa_device::dev, root_device::dev, device_description::device, EISA_MAX_SLOT, EISA_MIN_SLOT, eisa_probe(), EISA_PROD_ID, EISA_SLOT_BASE, EISA_VENDOR_ID, eisabus_remove(), ENODEV, ENOMEM, free, inb(), INIT_LIST_HEAD, inw(), eisa_device::ioaddr, le16_to_cpu, list_add, list_del, malloc(), memset(), device::name, NULL, outb, device::parent, eisa_device::prod_id, rc, device::siblings, slot, eisa_device::slot, snprintf(), system, device_description::vendor, and eisa_device::vendor_id.

Variable Documentation

◆ eisa_root_driver

struct root_driver eisa_root_driver
static
Initial value:
= {
.probe = eisabus_probe,
.remove = eisabus_remove,
}
static void eisabus_remove(struct root_device *rootdev)
Remove EISA root bus.
Definition: eisa.c:168
static int eisabus_probe(struct root_device *rootdev)
Probe EISA root bus.
Definition: eisa.c:98

EISA bus root device driver.

Definition at line 181 of file eisa.c.

◆ __root_device

struct root_device eisa_root_device __root_device
Initial value:
= {
.dev = { .name = "EISA" },
.driver = &eisa_root_driver,
}
static struct root_driver eisa_root_driver
EISA bus root device driver.
Definition: eisa.c:181

EISA bus root device.

Definition at line 187 of file eisa.c.