Browse Source

[block] Centralise "san-drive" setting

The concept of the SAN drive number is meaningful only in a BIOS
environment, where it represents the INT13 drive number (0x80 for the
first hard disk).  We retain this concept in a UEFI environment to
allow for a simple way for iPXE commands to refer to SAN drives.

Centralise the concept of the default drive number, since it is shared
between all supported environments.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
e7ee2eda4b

+ 0
- 28
src/arch/x86/interface/pcbios/int13.c View File

44
 #include <ipxe/pci.h>
44
 #include <ipxe/pci.h>
45
 #include <ipxe/iso9660.h>
45
 #include <ipxe/iso9660.h>
46
 #include <ipxe/eltorito.h>
46
 #include <ipxe/eltorito.h>
47
-#include <ipxe/dhcp.h>
48
-#include <ipxe/settings.h>
49
 #include <realmode.h>
47
 #include <realmode.h>
50
 #include <bios.h>
48
 #include <bios.h>
51
 #include <biosint.h>
49
 #include <biosint.h>
1992
 	return 0;
1990
 	return 0;
1993
 }
1991
 }
1994
 
1992
 
1995
-/** The "san-drive" setting */
1996
-const struct setting san_drive_setting __setting ( SETTING_SANBOOT_EXTRA,
1997
-						   san-drive ) = {
1998
-	.name = "san-drive",
1999
-	.description = "SAN drive number",
2000
-	.tag = DHCP_EB_SAN_DRIVE,
2001
-	.type = &setting_type_uint8,
2002
-};
2003
-
2004
-/**
2005
- * Get default SAN drive number
2006
- *
2007
- * @ret drive		Default drive number
2008
- */
2009
-static unsigned int int13_default_drive ( void ) {
2010
-	unsigned long drive;
2011
-
2012
-	/* Use "san-drive" setting, if specified */
2013
-	if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
2014
-		return drive;
2015
-
2016
-	/* Otherwise, default to booting from first hard disk */
2017
-	return 0x80;
2018
-}
2019
-
2020
-PROVIDE_SANBOOT ( pcbios, san_default_drive, int13_default_drive );
2021
 PROVIDE_SANBOOT ( pcbios, san_hook, int13_hook );
1993
 PROVIDE_SANBOOT ( pcbios, san_hook, int13_hook );
2022
 PROVIDE_SANBOOT ( pcbios, san_unhook, int13_unhook );
1994
 PROVIDE_SANBOOT ( pcbios, san_unhook, int13_unhook );
2023
 PROVIDE_SANBOOT ( pcbios, san_boot, int13_boot );
1995
 PROVIDE_SANBOOT ( pcbios, san_boot, int13_boot );

+ 0
- 1
src/core/null_sanboot.c View File

43
 	return -EOPNOTSUPP;
43
 	return -EOPNOTSUPP;
44
 }
44
 }
45
 
45
 
46
-PROVIDE_SANBOOT_INLINE ( null, san_default_drive );
47
 PROVIDE_SANBOOT ( null, san_hook, null_san_hook );
46
 PROVIDE_SANBOOT ( null, san_hook, null_san_hook );
48
 PROVIDE_SANBOOT ( null, san_unhook, null_san_unhook );
47
 PROVIDE_SANBOOT ( null, san_unhook, null_san_unhook );
49
 PROVIDE_SANBOOT ( null, san_boot, null_san_boot );
48
 PROVIDE_SANBOOT ( null, san_boot, null_san_boot );

+ 39
- 0
src/core/sanboot.c View File

39
 #include <ipxe/timer.h>
39
 #include <ipxe/timer.h>
40
 #include <ipxe/process.h>
40
 #include <ipxe/process.h>
41
 #include <ipxe/iso9660.h>
41
 #include <ipxe/iso9660.h>
42
+#include <ipxe/dhcp.h>
43
+#include <ipxe/settings.h>
42
 #include <ipxe/sanboot.h>
44
 #include <ipxe/sanboot.h>
43
 
45
 
46
+/**
47
+ * Default SAN drive number
48
+ *
49
+ * The drive number is a meaningful concept only in a BIOS
50
+ * environment, where it represents the INT13 drive number (0x80 for
51
+ * the first hard disk).  We retain it in other environments to allow
52
+ * for a simple way for iPXE commands to refer to SAN drives.
53
+ */
54
+#define SAN_DEFAULT_DRIVE 0x80
55
+
44
 /**
56
 /**
45
  * Timeout for block device commands (in ticks)
57
  * Timeout for block device commands (in ticks)
46
  *
58
  *
541
 
553
 
542
 	/* Add to list of SAN devices */
554
 	/* Add to list of SAN devices */
543
 	list_add_tail ( &sandev->list, &san_devices );
555
 	list_add_tail ( &sandev->list, &san_devices );
556
+	DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
544
 
557
 
545
 	return 0;
558
 	return 0;
546
 }
559
 }
560
 
573
 
561
 	/* Remove from list of SAN devices */
574
 	/* Remove from list of SAN devices */
562
 	list_del ( &sandev->list );
575
 	list_del ( &sandev->list );
576
+	DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
577
+}
578
+
579
+/** The "san-drive" setting */
580
+const struct setting san_drive_setting __setting ( SETTING_SANBOOT_EXTRA,
581
+						   san-drive ) = {
582
+	.name = "san-drive",
583
+	.description = "SAN drive number",
584
+	.tag = DHCP_EB_SAN_DRIVE,
585
+	.type = &setting_type_uint8,
586
+};
587
+
588
+/**
589
+ * Get default SAN drive number
590
+ *
591
+ * @ret drive		Default drive number
592
+ */
593
+unsigned int san_default_drive ( void ) {
594
+	unsigned long drive;
595
+
596
+	/* Use "san-drive" setting, if specified */
597
+	if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
598
+		return drive;
599
+
600
+	/* Otherwise, default to booting from first hard disk */
601
+	return SAN_DEFAULT_DRIVE;
563
 }
602
 }

+ 0
- 9
src/include/ipxe/efi/efi_block.h View File

15
 #define SANBOOT_PREFIX_efi __efi_
15
 #define SANBOOT_PREFIX_efi __efi_
16
 #endif
16
 #endif
17
 
17
 
18
-static inline __always_inline unsigned int
19
-SANBOOT_INLINE ( efi, san_default_drive ) ( void ) {
20
-	/* Drive numbers don't exist as a concept under EFI.  We
21
-	 * arbitarily choose to use drive 0x80 to minimise differences
22
-	 * with a standard BIOS.
23
-	 */
24
-	return 0x80;
25
-}
26
-
27
 #endif /* _IPXE_EFI_BLOCK_H */
18
 #endif /* _IPXE_EFI_BLOCK_H */

+ 0
- 5
src/include/ipxe/null_sanboot.h View File

15
 #define SANBOOT_PREFIX_null __null_
15
 #define SANBOOT_PREFIX_null __null_
16
 #endif
16
 #endif
17
 
17
 
18
-static inline __always_inline unsigned int
19
-SANBOOT_INLINE ( null, san_default_drive ) ( void ) {
20
-	return 0;
21
-}
22
-
23
 #endif /* _IPXE_NULL_SANBOOT_H */
18
 #endif /* _IPXE_NULL_SANBOOT_H */

+ 1
- 7
src/include/ipxe/sanboot.h View File

95
 /* Include all architecture-dependent sanboot API headers */
95
 /* Include all architecture-dependent sanboot API headers */
96
 #include <bits/sanboot.h>
96
 #include <bits/sanboot.h>
97
 
97
 
98
-/**
99
- * Get default SAN drive number
100
- *
101
- * @ret drive		Default drive number
102
- */
103
-unsigned int san_default_drive ( void );
104
-
105
 /**
98
 /**
106
  * Hook SAN device
99
  * Hook SAN device
107
  *
100
  *
212
 extern struct san_device * alloc_sandev ( struct uri *uri, size_t priv_size );
205
 extern struct san_device * alloc_sandev ( struct uri *uri, size_t priv_size );
213
 extern int register_sandev ( struct san_device *sandev );
206
 extern int register_sandev ( struct san_device *sandev );
214
 extern void unregister_sandev ( struct san_device *sandev );
207
 extern void unregister_sandev ( struct san_device *sandev );
208
+extern unsigned int san_default_drive ( void );
215
 
209
 
216
 #endif /* _IPXE_SANBOOT_H */
210
 #endif /* _IPXE_SANBOOT_H */

+ 0
- 1
src/interface/efi/efi_block.c View File

1055
 	return rc;
1055
 	return rc;
1056
 }
1056
 }
1057
 
1057
 
1058
-PROVIDE_SANBOOT_INLINE ( efi, san_default_drive );
1059
 PROVIDE_SANBOOT ( efi, san_hook, efi_block_hook );
1058
 PROVIDE_SANBOOT ( efi, san_hook, efi_block_hook );
1060
 PROVIDE_SANBOOT ( efi, san_unhook, efi_block_unhook );
1059
 PROVIDE_SANBOOT ( efi, san_unhook, efi_block_unhook );
1061
 PROVIDE_SANBOOT ( efi, san_describe, efi_block_describe );
1060
 PROVIDE_SANBOOT ( efi, san_describe, efi_block_describe );

Loading…
Cancel
Save