Browse Source

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).
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
d606edb41d
1 changed files with 96 additions and 0 deletions
  1. 96
    0
      src/arch/i386/drivers/net/undionly.c

+ 96
- 0
src/arch/i386/drivers/net/undionly.c View File

@@ -0,0 +1,96 @@
1
+/*
2
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
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.
8
+ *
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.
13
+ *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <stdint.h>
20
+#include <stdlib.h>
21
+#include <string.h>
22
+#include <gpxe/device.h>
23
+#include <undi.h>
24
+#include <undinet.h>
25
+#include <undipreload.h>
26
+
27
+/** @file
28
+ *
29
+ * "Pure" UNDI driver
30
+ *
31
+ * This is the UNDI driver without explicit support for PCI or any
32
+ * other bus type.  It is capable only of using the preloaded UNDI
33
+ * device.  It must not be combined in an image with any other
34
+ * drivers.
35
+ *
36
+ * If you want a PXE-loadable image that contains only the UNDI
37
+ * driver, build "bin/undionly.kpxe".
38
+ *
39
+ * If you want any other image format, or any other drivers in
40
+ * addition to the UNDI driver, build e.g. "bin/undi.dsk".
41
+ */
42
+
43
+/**
44
+ * Probe UNDI root bus
45
+ *
46
+ * @v rootdev		UNDI bus root device
47
+ *
48
+ * Scans the UNDI bus for devices and registers all devices it can
49
+ * find.
50
+ */
51
+static int undibus_probe ( struct root_device *rootdev ) {
52
+	int rc;
53
+
54
+	/* Check for a valie preloaded UNDI device */
55
+	if ( ! preloaded_undi.entry.segment ) {
56
+		DBG ( "No preloaded UNDI device found!\n" );
57
+		return -ENODEV;
58
+	}
59
+
60
+	/* Add to device hierarchy */
61
+	preloaded_undi.dev.parent = &rootdev->dev;
62
+	list_add ( &preloaded_undi.dev.siblings, &rootdev->dev.children);
63
+	INIT_LIST_HEAD ( &preloaded_undi.dev.children );
64
+
65
+	/* Create network device */
66
+	if ( ( rc = undinet_probe ( &preloaded_undi ) ) != 0 )
67
+		goto err;
68
+
69
+	return 0;
70
+
71
+ err:
72
+	list_del ( &preloaded_undi.dev.siblings );
73
+	return rc;
74
+}
75
+
76
+/**
77
+ * Remove UNDI root bus
78
+ *
79
+ * @v rootdev		UNDI bus root device
80
+ */
81
+static void undibus_remove ( struct root_device *rootdev __unused ) {
82
+	undinet_remove ( &preloaded_undi );
83
+	list_del ( &preloaded_undi.dev.siblings );
84
+}
85
+
86
+/** UNDI bus root device driver */
87
+static struct root_driver undi_root_driver = {
88
+	.probe = undibus_probe,
89
+	.remove = undibus_remove,
90
+};
91
+
92
+/** UNDI bus root device */
93
+struct root_device undi_root_device __root_device = {
94
+	.name = "UNDI",
95
+	.driver = &undi_root_driver,
96
+};

Loading…
Cancel
Save