|
@@ -49,6 +49,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
49
|
49
|
*
|
50
|
50
|
*/
|
51
|
51
|
|
|
52
|
+/** Device location of preferred autoboot device */
|
|
53
|
+struct device_description autoboot_device;
|
|
54
|
+
|
52
|
55
|
/* Disambiguate the various error causes */
|
53
|
56
|
#define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT )
|
54
|
57
|
#define EINFO_ENOENT_BOOT \
|
|
@@ -73,15 +76,6 @@ __weak int pxe_menu_boot ( struct net_device *netdev __unused ) {
|
73
|
76
|
return -ENOTSUP;
|
74
|
77
|
}
|
75
|
78
|
|
76
|
|
-/**
|
77
|
|
- * Identify the boot network device
|
78
|
|
- *
|
79
|
|
- * @ret netdev Boot network device
|
80
|
|
- */
|
81
|
|
-static struct net_device * find_boot_netdev ( void ) {
|
82
|
|
- return NULL;
|
83
|
|
-}
|
84
|
|
-
|
85
|
79
|
/**
|
86
|
80
|
* Parse next-server and filename into a URI
|
87
|
81
|
*
|
|
@@ -427,22 +421,37 @@ int netboot ( struct net_device *netdev ) {
|
427
|
421
|
return rc;
|
428
|
422
|
}
|
429
|
423
|
|
|
424
|
+/**
|
|
425
|
+ * Test if network device matches the autoboot device location
|
|
426
|
+ *
|
|
427
|
+ * @v netdev Network device
|
|
428
|
+ * @ret is_autoboot Network device matches the autoboot device location
|
|
429
|
+ */
|
|
430
|
+static int is_autoboot_device ( struct net_device *netdev ) {
|
|
431
|
+
|
|
432
|
+ return ( ( netdev->dev->desc.bus_type == autoboot_device.bus_type ) &&
|
|
433
|
+ ( netdev->dev->desc.location == autoboot_device.location ) );
|
|
434
|
+}
|
|
435
|
+
|
430
|
436
|
/**
|
431
|
437
|
* Boot the system
|
432
|
438
|
*/
|
433
|
|
-int autoboot ( void ) {
|
434
|
|
- struct net_device *boot_netdev;
|
|
439
|
+static int autoboot ( void ) {
|
435
|
440
|
struct net_device *netdev;
|
436
|
441
|
int rc = -ENODEV;
|
437
|
442
|
|
438
|
|
- /* If we have an identifable boot device, try that first */
|
439
|
|
- if ( ( boot_netdev = find_boot_netdev() ) )
|
440
|
|
- rc = netboot ( boot_netdev );
|
441
|
|
-
|
442
|
|
- /* If that fails, try booting from any of the other devices */
|
|
443
|
+ /* Try booting from each network device. If we have a
|
|
444
|
+ * specified autoboot device location, then use only devices
|
|
445
|
+ * matching that location.
|
|
446
|
+ */
|
443
|
447
|
for_each_netdev ( netdev ) {
|
444
|
|
- if ( netdev == boot_netdev )
|
|
448
|
+
|
|
449
|
+ /* Skip any non-matching devices, if applicable */
|
|
450
|
+ if ( autoboot_device.bus_type &&
|
|
451
|
+ ( ! is_autoboot_device ( netdev ) ) )
|
445
|
452
|
continue;
|
|
453
|
+
|
|
454
|
+ /* Attempt booting from this device */
|
446
|
455
|
rc = netboot ( netdev );
|
447
|
456
|
}
|
448
|
457
|
|