From d606edb41dc0df82ea4f6bc23296720d37d6fe84 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 9 Jan 2007 03:20:22 +0000 Subject: [PATCH] Added UNDI root bus driver (which saves including all the PCI bus code, UNDI ROM code etc. when you just want a "undi.kpxe"-type image). This driver cannot be used in conjunction with any other driver (it will crash), or in any other format than .kpxe (it just won't find any network devices). --- src/arch/i386/drivers/net/undionly.c | 96 ++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/arch/i386/drivers/net/undionly.c diff --git a/src/arch/i386/drivers/net/undionly.c b/src/arch/i386/drivers/net/undionly.c new file mode 100644 index 00000000..5b8ff977 --- /dev/null +++ b/src/arch/i386/drivers/net/undionly.c @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2007 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +/** @file + * + * "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". + */ + +/** + * Probe UNDI root bus + * + * @v rootdev UNDI bus root device + * + * Scans the UNDI bus for devices and registers all devices it can + * find. + */ +static int undibus_probe ( struct root_device *rootdev ) { + int rc; + + /* Check for a valie preloaded UNDI device */ + if ( ! preloaded_undi.entry.segment ) { + DBG ( "No preloaded UNDI device found!\n" ); + return -ENODEV; + } + + /* Add to device hierarchy */ + preloaded_undi.dev.parent = &rootdev->dev; + list_add ( &preloaded_undi.dev.siblings, &rootdev->dev.children); + INIT_LIST_HEAD ( &preloaded_undi.dev.children ); + + /* Create network device */ + if ( ( rc = undinet_probe ( &preloaded_undi ) ) != 0 ) + goto err; + + return 0; + + err: + list_del ( &preloaded_undi.dev.siblings ); + return rc; +} + +/** + * Remove UNDI root bus + * + * @v rootdev UNDI bus root device + */ +static void undibus_remove ( struct root_device *rootdev __unused ) { + undinet_remove ( &preloaded_undi ); + list_del ( &preloaded_undi.dev.siblings ); +} + +/** UNDI bus root device driver */ +static struct root_driver undi_root_driver = { + .probe = undibus_probe, + .remove = undibus_remove, +}; + +/** UNDI bus root device */ +struct root_device undi_root_device __root_device = { + .name = "UNDI", + .driver = &undi_root_driver, +};