2 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 FILE_LICENCE ( GPL2_OR_LATER );
26 #include <ipxe/device.h>
27 #include <ipxe/init.h>
31 #include <undipreload.h>
37 * This is the UNDI driver without explicit support for PCI or any
38 * other bus type. It is capable only of using the preloaded UNDI
39 * device. It must not be combined in an image with any other
42 * If you want a PXE-loadable image that contains only the UNDI
43 * driver, build "bin/undionly.kpxe".
45 * If you want any other image format, or any other drivers in
46 * addition to the UNDI driver, build e.g. "bin/undi.dsk".
52 * @v rootdev UNDI bus root device
54 * Scans the UNDI bus for devices and registers all devices it can
57 static int undibus_probe ( struct root_device *rootdev ) {
58 struct undi_device *undi = &preloaded_undi;
61 /* Check for a valie preloaded UNDI device */
62 if ( ! undi->entry.segment ) {
63 DBG ( "No preloaded UNDI device found!\n" );
67 /* Add to device hierarchy */
68 undi->dev.driver_name = "undionly";
69 if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
70 undi->dev.desc.bus_type = BUS_TYPE_PCI;
71 undi->dev.desc.location = undi->pci_busdevfn;
72 undi->dev.desc.vendor = undi->pci_vendor;
73 undi->dev.desc.device = undi->pci_device;
74 snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
75 "UNDI-PCI%02x:%02x.%x",
76 PCI_BUS ( undi->pci_busdevfn ),
77 PCI_SLOT ( undi->pci_busdevfn ),
78 PCI_FUNC ( undi->pci_busdevfn ) );
79 } else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
80 undi->dev.desc.bus_type = BUS_TYPE_ISAPNP;
81 snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
84 undi->dev.parent = &rootdev->dev;
85 list_add ( &undi->dev.siblings, &rootdev->dev.children);
86 INIT_LIST_HEAD ( &undi->dev.children );
88 /* Create network device */
89 if ( ( rc = undinet_probe ( undi ) ) != 0 )
95 list_del ( &undi->dev.siblings );
100 * Remove UNDI root bus
102 * @v rootdev UNDI bus root device
104 static void undibus_remove ( struct root_device *rootdev __unused ) {
105 struct undi_device *undi = &preloaded_undi;
107 undinet_remove ( undi );
108 list_del ( &undi->dev.siblings );
111 /** UNDI bus root device driver */
112 static struct root_driver undi_root_driver = {
113 .probe = undibus_probe,
114 .remove = undibus_remove,
117 /** UNDI bus root device */
118 struct root_device undi_root_device __root_device = {
119 .dev = { .name = "UNDI" },
120 .driver = &undi_root_driver,
126 * @v booting System is shutting down for OS boot
128 static void undionly_shutdown ( int booting ) {
129 /* If we are shutting down to boot an OS, clear the "keep PXE
133 preloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;
136 struct startup_fn startup_undionly __startup_fn ( STARTUP_LATE ) = {
137 .shutdown = undionly_shutdown,