Functions | Variables
undionly.c File Reference

"Pure" UNDI driver More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ipxe/device.h>
#include <ipxe/init.h>
#include <ipxe/pci.h>
#include <undi.h>
#include <undinet.h>
#include <undipreload.h>

Go to the source code of this file.


static int undibus_probe (struct root_device *rootdev)
 Probe UNDI root bus. More...
static void undibus_remove (struct root_device *rootdev __unused)
 Remove UNDI root bus. More...
static void undionly_shutdown (int booting)
 Prepare for exit. More...
struct startup_fn startup_undionly __startup_fn (STARTUP_LATE)


static struct device undibus_dev
 UNDI root bus device. More...
static struct root_driver undi_root_driver
 UNDI bus root device driver. More...
struct root_device undi_root_device __root_device
 UNDI bus root device. More...

Detailed Description

"Pure" UNDI driver

This is the UNDI driver without explicit support for PCI or any other bus type. It is capable only of using the preloaded UNDI device. It must not be combined in an image with any other drivers.

If you want a PXE-loadable image that contains only the UNDI driver, build "bin/undionly.kpxe".

If you want any other image format, or any other drivers in addition to the UNDI driver, build e.g. "bin/undi.dsk".

Definition in file undionly.c.

Function Documentation



◆ undibus_probe()

static int undibus_probe ( struct root_device rootdev)

Probe UNDI root bus.

rootdevUNDI bus root device

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

Definition at line 64 of file undionly.c.

64  {
65  struct undi_device *undi = &preloaded_undi;
66  struct device *dev = &undibus_dev;
67  int rc;
69  /* Check for a valie preloaded UNDI device */
70  if ( ! undi->entry.segment ) {
71  DBG ( "No preloaded UNDI device found!\n" );
72  return -ENODEV;
73  }
75  /* Add to device hierarchy */
76  dev->driver_name = "undionly";
77  if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
78  dev->desc.bus_type = BUS_TYPE_PCI;
79  dev->desc.location = undi->pci_busdevfn;
80  dev->desc.vendor = undi->pci_vendor;
81  dev->desc.device = undi->pci_device;
82  snprintf ( dev->name, sizeof ( dev->name ),
83  "0000:%02x:%02x.%x", PCI_BUS ( undi->pci_busdevfn ),
84  PCI_SLOT ( undi->pci_busdevfn ),
85  PCI_FUNC ( undi->pci_busdevfn ) );
86  } else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
88  snprintf ( dev->name, sizeof ( dev->name ), "ISAPNP" );
89  }
90  dev->parent = &rootdev->dev;
91  list_add ( &dev->siblings, &rootdev->dev.children);
92  INIT_LIST_HEAD ( &dev->children );
94  /* Create network device */
95  if ( ( rc = undinet_probe ( undi, dev ) ) != 0 )
96  goto err;
98  return 0;
100  err:
101  list_del ( &dev->siblings );
102  return rc;
103 }
#define PCI_FUNC(busdevfn)
Definition: pci.h:281
#define PCI_BUS(busdevfn)
Definition: pci.h:279
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
int undinet_probe(struct undi_device *undi, struct device *dev)
Probe UNDI device.
Definition: undinet.c:888
char name[40]
Definition: device.h:75
ISAPnP card select number field is invalid.
Definition: undi.h:90
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
UINT16_t isapnp_csn
ISAPnP card select number, or UNDI_NO_ISAPNP_CSN.
Definition: undi.h:36
static struct device undibus_dev
UNDI root bus device.
Definition: undionly.c:54
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
A hardware device.
Definition: device.h:73
#define BUS_TYPE_PCI
PCI bus type.
Definition: device.h:43
#define preloaded_undi
Definition: undipreload.h:16
const char * driver_name
Driver name.
Definition: device.h:77
unsigned int location
Definition: device.h:29
SEGOFF16_t entry
Entry point.
Definition: undi.h:28
UINT16_t pci_device
PCI device ID.
Definition: undi.h:48
#define PCI_SLOT(busdevfn)
Definition: pci.h:280
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
UINT16_t pci_vendor
PCI vendor ID.
Definition: undi.h:43
#define ENODEV
No such device.
Definition: errno.h:509
PCI bus:dev.fn field is invalid.
Definition: undi.h:87
An UNDI device.
Definition: undi.h:22
UINT16_t pci_busdevfn
PCI bus:dev.fn, or UNDI_NO_PCI_BUSDEVFN.
Definition: undi.h:34
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
unsigned int bus_type
Bus type.
Definition: device.h:24
unsigned int device
Device ID.
Definition: device.h:33
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
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
ISAPnP bus type.
Definition: device.h:46

References device_description::bus_type, BUS_TYPE_ISAPNP, BUS_TYPE_PCI, device::children, DBG, device::desc, root_device::dev, device_description::device, device::driver_name, ENODEV, undi_device::entry, INIT_LIST_HEAD, undi_device::isapnp_csn, list_add, list_del, device_description::location, device::name, device::parent, PCI_BUS, undi_device::pci_busdevfn, undi_device::pci_device, PCI_FUNC, PCI_SLOT, undi_device::pci_vendor, preloaded_undi, rc, device::siblings, snprintf(), UNDI_NO_ISAPNP_CSN, UNDI_NO_PCI_BUSDEVFN, undibus_dev, undinet_probe(), and device_description::vendor.

◆ undibus_remove()

static void undibus_remove ( struct root_device *rootdev  __unused)

Remove UNDI root bus.

rootdevUNDI bus root device

Definition at line 110 of file undionly.c.

110  {
111  struct undi_device *undi = &preloaded_undi;
112  struct device *dev = &undibus_dev;
114  undinet_remove ( undi );
115  list_del ( &dev->siblings );
116 }
void undinet_remove(struct undi_device *undi)
Remove UNDI device.
Definition: undinet.c:1042
static struct device undibus_dev
UNDI root bus device.
Definition: undionly.c:54
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
A hardware device.
Definition: device.h:73
#define preloaded_undi
Definition: undipreload.h:16
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
An UNDI device.
Definition: undi.h:22

References list_del, preloaded_undi, device::siblings, undibus_dev, and undinet_remove().

◆ undionly_shutdown()

static void undionly_shutdown ( int  booting)

Prepare for exit.

bootingSystem is shutting down for OS boot

Definition at line 135 of file undionly.c.

135  {
136  /* If we are shutting down to boot an OS, clear the "keep PXE
137  * stack" flag.
138  */
139  if ( booting )
141 }
#define preloaded_undi
Definition: undipreload.h:16
UNDI flag: keep stack resident.
Definition: undi.h:102

References preloaded_undi, and UNDI_FL_KEEP_ALL.

◆ __startup_fn()

struct startup_fn startup_undionly __startup_fn ( STARTUP_LATE  )

Variable Documentation

◆ undibus_dev

struct device undibus_dev

UNDI root bus device.

Definition at line 54 of file undionly.c.

Referenced by undibus_probe(), and undibus_remove().

◆ undi_root_driver

struct root_driver undi_root_driver
Initial value:
= {
.probe = undibus_probe,
.remove = undibus_remove,
static int undibus_probe(struct root_device *rootdev)
Probe UNDI root bus.
Definition: undionly.c:64
static void undibus_remove(struct root_device *rootdev __unused)
Remove UNDI root bus.
Definition: undionly.c:110

UNDI bus root device driver.

Definition at line 119 of file undionly.c.

◆ __root_device

struct root_device undi_root_device __root_device
Initial value:
= {
.dev = { .name = "UNDI" },
.driver = &undi_root_driver,
static struct root_driver undi_root_driver
UNDI bus root device driver.
Definition: undionly.c:119

UNDI bus root device.

Definition at line 125 of file undionly.c.